/* MPAS 공통 스타일 — 업무용, 표 중심 */
:root {
  --bg: #f4f6f9; --panel: #fff; --line: #dde2ea; --text: #1f2933; --muted: #6b7785;
  --primary: #1d5fbf; --primary-dark: #154a96; --danger: #c62f2f; --ok: #1e8a4c; --warn: #d9822b;
  --draft: #7b8794; --submitted: #1d5fbf; --confirmed: #1e8a4c; --returned: #c62f2f; --not-entered: #d9822b;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
h3 { font-size: 14px; margin: 14px 0 6px; }

/* 상단 바 */
.topbar { background: #1b2a41; color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 16px; min-height: 52px; flex-wrap: wrap; }
.topbar .brand { font-weight: 700; font-size: 16px; color: #fff; white-space: nowrap; }
.topbar .brand small { font-weight: 400; color: #b8c4d6; margin-left: 6px; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #d7e0ec; padding: 6px 10px; border-radius: var(--radius); }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.topbar .user { display: flex; align-items: center; gap: 10px; color: #d7e0ec; white-space: nowrap; }
.topbar .user button { background: transparent; border: 1px solid #50627d; color: #d7e0ec; }
.bell { position: relative; color: #d7e0ec; padding: 4px 6px; }
.bell .badge { position: absolute; top: -4px; right: -6px; background: var(--danger); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 5px; min-width: 18px; text-align: center; }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* 폼 */
input, select, textarea, button { font: inherit; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], select, textarea {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; background: #fff; color: var(--text); max-width: 100%;
}
input:disabled, select:disabled, textarea:disabled { background: #f0f2f5; color: var(--muted); }
textarea { width: 100%; min-height: 60px; }
label { display: inline-flex; align-items: center; gap: 6px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 13px; color: var(--muted); }
button, .btn {
  border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: var(--radius);
  padding: 6px 12px; cursor: pointer; white-space: nowrap; display: inline-block;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--primary); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--primary-dark); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.link { border: none; background: none; color: var(--primary); padding: 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: none; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--primary); color: #fff; }

/* 표 */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
th { background: #f7f9fc; font-weight: 600; font-size: 13px; color: #3e4c59; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f3f7fd; }
tr.group td { background: #eef3fa; font-weight: 600; }
tr.total td { background: #f7f9fc; font-weight: 700; }
tr.inactive td { color: var(--muted); }

/* 상태 배지 */
.badge { display: inline-block; border-radius: 10px; padding: 1px 9px; font-size: 12px; font-weight: 600; color: #fff; background: var(--draft); white-space: nowrap; }
.badge.DRAFT { background: var(--draft); }
.badge.SUBMITTED { background: var(--submitted); }
.badge.CONFIRMED { background: var(--confirmed); }
.badge.RETURNED { background: var(--returned); }
.badge.NOT_ENTERED { background: var(--not-entered); }
.badge.GENERATED { background: var(--draft); }
.badge.REVIEWED { background: var(--submitted); }
.badge.WARN { background: var(--danger); }
.badge.GOOD { background: var(--ok); }
.badge.INFO { background: var(--draft); }
.badge.PLAN { background: var(--primary); }
.badge.off { background: #aab4c0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; background: #fff; min-width: 90px; }
.chip b { display: block; font-size: 20px; }

/* 카드 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 24px; font-weight: 700; }
.card .sub { color: var(--muted); font-size: 13px; }

/* 달성률 막대 */
.rate { display: flex; align-items: center; gap: 6px; min-width: 120px; }
.rate .bar { flex: 1; height: 8px; background: #e6eaf0; border-radius: 4px; overflow: hidden; }
.rate .bar i { display: block; height: 100%; background: var(--primary); }
.rate.low .bar i { background: var(--danger); }
.rate.high .bar i { background: var(--ok); }
.rate span { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }

/* 알림·메시지 */
.alert { border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; border: 1px solid; }
.alert.error { background: #fdecec; border-color: #f2b8b8; color: #8f1f1f; }
.alert.warn { background: #fff4e5; border-color: #f5cf9b; color: #7a4a10; }
.alert.info { background: #eaf2fd; border-color: #b6d0f3; color: #1b4a8a; }
#toast { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
#toast div { background: #1b2a41; color: #fff; padding: 10px 14px; border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.2); max-width: 420px; }
#toast div.error { background: var(--danger); }
#toast div.ok { background: var(--ok); }

/* 모달 */
dialog { border: none; border-radius: 8px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .dlg-head { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
dialog .dlg-body { padding: 16px; max-height: 70vh; overflow-y: auto; }
dialog .dlg-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
dialog.wide { width: min(960px, calc(100vw - 32px)); }

/* 로그인 */
.login-box { max-width: 360px; margin: 10vh auto; }
.login-box h1 { text-align: center; }

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 14px; }
.tabs button.on { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }

/* 실적 입력 */
.entry-table input[type=number] { width: 100px; text-align: right; }
.entry-table input.note { width: 100%; min-width: 120px; }
.entry-table .dirty { background: #fffbe6; }
.chart-box { position: relative; height: 300px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) {
  .grid2 { grid-template-columns: 1fr; }
  main { padding: 10px; }
  .entry-table input[type=number] { width: 72px; }
  .entry-table th.note-col, .entry-table td.note-col { display: none; }
}

/* 인쇄 (주간보고서) */
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .topbar, .toolbar, .no-print, #toast, dialog { display: none !important; }
  main { max-width: none; padding: 0; }
  .panel { border: none; padding: 0; margin-bottom: 10px; }
  th, td { padding: 3px 5px; }
  tr, .card { page-break-inside: avoid; }
}
