:root {
  --navy: #1f3864; --navy2: #2e4a7d; --orange: #e46c0a; --orange-l: #fbe5d6; --bg: #f3f5f9; --line: #d9dee8;
  --text: #1d2433; --muted: #6b7486; --red: #e00000; --green: #1e8e3e; --blue: #2f6fd6;
  --c-sales: #dce6f2; --c-pur: #f8cbad; --c-lab: #e2efda; --c-exp: #fff2cc; --c-op: #ddebf7; --c-mp: #fce4d6; --c-pp: #e4dfec;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; }
.boot { padding: 60px; text-align: center; color: var(--muted); }
#offscreen { position: fixed; left: -30000px; top: 0; width: 1080px; pointer-events: none; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 54px; padding: 0 16px; background: var(--navy); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.topbar .brand { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; white-space: nowrap; }
.topbar .brand small { font-size: 11px; font-weight: 600; margin-left: 6px; background: var(--orange); padding: 2px 6px; border-radius: 10px; vertical-align: middle; }
.topbar .spacer { flex: 1; }
.topbar select { background: #fff; border: 0; border-radius: 6px; padding: 6px 8px; font-weight: 700; color: var(--navy); max-width: 260px; }
.topbar .who { font-size: 12px; opacity: .9; white-space: nowrap; }
.topbar .btn-icon { background: transparent; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.menu-toggle { display: none; }
.shell { display: flex; min-height: calc(100vh - 54px); }
.sidenav { width: 210px; flex: 0 0 210px; background: #fff; border-right: 1px solid var(--line); padding: 12px 8px; }
.sidenav a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.sidenav a:hover { background: #eef2f9; }
.sidenav a.active { background: var(--navy); color: #fff; }
.sidenav .sec { font-size: 11px; color: var(--muted); padding: 12px 12px 4px; font-weight: 700; }
.main { flex: 1; padding: 18px 22px 60px; min-width: 0; }
.page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.page-title h1 { font-size: 21px; margin: 0; color: var(--navy); }
.page-title .sub { color: var(--muted); font-size: 13px; }

/* cards / forms */
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; margin: 0 0 10px; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.card h2 .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; }
input, select, textarea { font-family: inherit; font-size: 14px; border: 1px solid #c5ccd8; border-radius: 6px; padding: 7px 9px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9db6e8; border-color: #6f8fd0; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input[readonly] { background: #f3f5f9; }
textarea { width: 100%; min-height: 90px; resize: vertical; line-height: 1.45; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #c5ccd8; background: #fff; color: var(--text); border-radius: 7px; padding: 8px 14px; font-weight: 700; cursor: pointer; font-size: 13px; }
.btn:hover { background: #f1f4fa; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy2); }
.btn.accent { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn.danger { color: var(--red); border-color: #f0b4b4; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 800; }
.badge.open { background: #e8f0fe; color: #1a56c4; }
.badge.closed { background: #fde7e7; color: #b42318; }
.badge.draft { background: #fff4e5; color: #b35c00; }
.badge.submitted { background: #e6f4ea; color: #137333; }
.badge.none { background: #eee; color: #777; }
.muted { color: var(--muted); }
.neg { color: var(--red) !important; }
.pos-up { color: var(--blue); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--navy); border-radius: 10px; padding: 12px 14px; }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 700; }
.kpi .v { font-size: 22px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; margin-top: 2px; color: var(--muted); }
.kpi.orange { border-left-color: var(--orange); }
.kpi.green { border-left-color: var(--green); }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; }
table.t th, table.t td { border: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
table.t th { background: #eef2f8; color: var(--navy); font-weight: 800; text-align: center; }
table.t td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.t td.l { text-align: left; }
table.t tr.sum td { font-weight: 800; background: #f6f8fc; }
table.t td input { width: 100%; min-width: 90px; border: 1px solid transparent; background: #fbfcfe; padding: 5px 6px; }
table.t td input:hover { border-color: #c5ccd8; }
table.t td.txt { white-space: pre-wrap; min-width: 280px; vertical-align: top; }
table.t th.o { background: var(--orange); color: #fff; }
table.eval td.lab { font-weight: 800; text-align: left; }
tr.r-sales td.lab, tr.r-sales td { background: var(--c-sales); }
tr.r-pur td { background: #fdeee4; }
tr.r-lab td { background: #eef6e8; }
tr.r-exp td { background: #fff8e1; }
tr.r-op td { background: #e8f1fb; }
tr.r-mp td { background: #fdf0e8; }
tr.r-pp td { background: #efecf5; }
tr.ratio td { background: #fff !important; font-size: 12px; color: #444; }
.status-dot { font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 10px; border-radius: 16px; background: #eef2f8; cursor: pointer; font-weight: 700; font-size: 12px; border: 1px solid transparent; }
.chip.on { background: var(--navy); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 9px 14px; font-weight: 800; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; font-size: 14px; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--orange); }
.chart-box { position: relative; height: 320px; }
.chart-box.tall { height: 400px; }
.diff-ok { color: var(--green); font-weight: 700; }
.diff-bad { color: var(--red); font-weight: 700; }
.report-preview { background: #dfe4ec; border-radius: 10px; padding: 16px; display: flex; justify-content: center; overflow: auto; }
.report-preview .scaler { transform-origin: top left; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1f3864 0%, #2e4a7d 60%, #e46c0a 160%); padding: 20px; }
.login-box { background: #fff; width: 380px; max-width: 100%; border-radius: 14px; padding: 30px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-box h1 { margin: 0 0 4px; color: var(--navy); font-size: 24px; }
.login-box .field { margin-top: 12px; }
.login-box input { width: 100%; padding: 10px 12px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 18px; padding: 11px; font-size: 15px; }
.err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#toast .msg { background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#toast .msg.err { background: #b42318; }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 12px; padding: 18px 20px; width: 520px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 12px; color: var(--navy); }
.sec-title { font-weight: 800; color: var(--navy); margin: 14px 0 6px; font-size: 14px; }
.help { font-size: 12px; color: var(--muted); line-height: 1.5; }
.wk-range { font-size: 12px; color: var(--muted); }
.loading { padding: 30px; text-align: center; color: var(--muted); }
.flex1 { flex: 1; }
.right { text-align: right; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(243,245,249,.96); padding: 10px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; z-index: 5; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-block; }
  .sidenav { position: fixed; top: 54px; left: 0; bottom: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 16px rgba(0,0,0,.15); }
  .sidenav.open { transform: none; }
  .main { padding: 12px 10px 60px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .topbar .who { display: none; }
  .topbar .brand { font-size: 15px; }
  .topbar select { max-width: 150px; }
}
@media print {
  .topbar, .sidenav, .toolbar, .sticky-actions { display: none !important; }
  .main { padding: 0; }
}
