:root {
  --navy: #00205b;
  --blue: #0085ca;
  --gold: #85714d;
  --ink: #1b2433;
  --muted: #5d6b80;
  --line: #dfe4ec;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ok: #1f8a4c;
  --warn: #b76e00;
  --bad: #b3261e;
  --dirty: #fff6d6;
  --new: #e8f6ee;
  --font: "Pretendard", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; }
a { color: var(--blue); }
button, input, select { font: inherit; color: inherit; }

.topbar { background: var(--navy); color: #fff; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 16px; }
.topbar .brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 10px; }
.topbar .brand small { font-weight: 400; opacity: .75; }
.topbar .spacer { flex: 1; }
.topbar a, .topbar button.link { color: #fff; opacity: .9; text-decoration: none; background: none; border: 0; cursor: pointer; }
.topbar a:hover, .topbar button.link:hover { opacity: 1; text-decoration: underline; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); display: inline-block; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 7px 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: #0a3278; }
.btn.primary:disabled { opacity: .45; cursor: default; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 8px; font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; background: #fff; }
.err { color: var(--bad); min-height: 18px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent; color: var(--muted); }
.tabs button.on { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
select.inline { border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; background: #fff; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eef2f8; color: var(--navy); white-space: nowrap; }
.pill.s-admitted, .pill.s-paid, .pill.s-coa { background: #e2f3ea; color: var(--ok); }
.pill.s-visa, .pill.s-arrived { background: var(--ok); color: #fff; }
.pill.s-incomplete { background: #fff1d6; color: var(--warn); }
.pill.s-rejected, .pill.s-withdrawn { background: #f6e1df; color: var(--bad); }
.pill.s-preparing { background: #f1f3f6; color: var(--muted); border: 1px dashed #b8c1cf; }
.pill.s-review { background: #e2effa; color: var(--blue); }

/* spreadsheet grid */
.gridwrap { overflow: auto; max-height: calc(100vh - 250px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; height: 30px; }
.grid thead th { position: sticky; top: 0; z-index: 2; background: #eef2f8; font-weight: 600; font-size: 12px; text-align: left; padding: 4px 6px; vertical-align: bottom; line-height: 1.25; }
.grid thead th .col { color: var(--muted); font-weight: 400; font-size: 11px; display: block; }
.grid th.rn, .grid td.rn { position: sticky; left: 0; z-index: 1; background: #f7f9fc; text-align: center; width: 44px; min-width: 44px; color: var(--muted); font-size: 12px; }
.grid thead th.rn { z-index: 3; }
.grid td input, .grid td select { width: 100%; height: 29px; border: 0; padding: 0 6px; background: transparent; outline: none; }
.grid td input:focus, .grid td select:focus { box-shadow: inset 0 0 0 2px var(--blue); background: #fff; }
.grid td.ro { padding: 0 6px; white-space: nowrap; color: var(--muted); }
.grid tr.dirty td:not(.rn) { background: var(--dirty); }
.grid tr.new td:not(.rn) { background: var(--new); }
.grid tr.deleted td { opacity: .4; text-decoration: line-through; }
.grid td.bad input { color: var(--bad); box-shadow: inset 0 -2px 0 var(--bad); }
.grid td.warn input { box-shadow: inset 0 -2px 0 var(--warn); }
.grid td.act { white-space: nowrap; padding: 0 4px; }

.status-bar { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 12px; margin-top: 8px; flex-wrap: wrap; }
.legend-sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid var(--line); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.kpi .v { font-size: 30px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
table.stat { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stat th, .stat td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.stat th:first-child, .stat td:first-child { text-align: left; }
.stat thead th { font-size: 12px; color: var(--muted); font-weight: 600; vertical-align: bottom; }
.stat thead th small { display: block; font-weight: 400; }
.stat td.zero { color: #c3cad6; }
.stat tfoot td { font-weight: 700; border-top: 2px solid var(--ink); }
.scroll-x { overflow-x: auto; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #eef2f8; min-width: 160px; }
.bar span { display: block; height: 100%; }
.funnel-row { display: grid; grid-template-columns: 150px 1fr 60px; gap: 10px; align-items: center; margin: 6px 0; }
.funnel-row .track { background: #eef2f8; border-radius: 4px; height: 22px; }
.funnel-row .fill { background: var(--navy); height: 100%; border-radius: 4px; }
.funnel-row .n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .two { grid-template-columns: 1fr; } .funnel-row { grid-template-columns: 110px 1fr 44px; } }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 20px; max-width: 520px; width: 92vw; }
dialog::backdrop { background: rgba(0, 20, 50, .35); }
.two > *, .kpis > * { min-width: 0; }
@media (max-width: 600px) {
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar .brand small { display: none; }
  .wrap { padding: 18px 16px 48px; }
}
