:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #1a1a19;
  --muted: #77776f;
  --line: #e4e4de;
  --accent: #b8794f;
  --accent-soft: #f3e9e0;
  --good: #2f7d54;
  --warn: #b4761c;
  --bad: #b4413c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14140f;
    --panel: #1e1e19;
    --ink: #eceae2;
    --muted: #9a988d;
    --line: #32322b;
    --accent: #d29a6c;
    --accent-soft: #2e2620;
    --good: #6fbc8e;
    --warn: #dda54e;
    --bad: #e0736c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

header.top {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
header.top h1 { font-size: 16px; margin: 0; letter-spacing: -.2px; }
header.top .sub { color: var(--muted); font-size: 12.5px; }
header.top .spacer { flex: 1; }

main { max-width: 1240px; margin: 0 auto; padding: 22px 24px 80px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

button, .btn {
  font: inherit; font-size: 13.5px;
  padding: 7px 13px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s;
}
button:hover, .btn:hover { background: var(--accent-soft); border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.06); }
button.danger:hover { border-color: var(--bad); color: var(--bad); background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm { padding: 4px 9px; font-size: 12.5px; }

input, textarea, select {
  font: inherit; font-size: 14px;
  padding: 8px 10px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card h2 { font-size: 14px; margin: 0 0 14px; letter-spacing: -.1px; }
.card h2 .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 11.5px; color: var(--muted); text-transform: none; letter-spacing: .2px; }
.kpi .value { font-size: 26px; font-weight: 620; letter-spacing: -.8px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--accent-soft); }
/* 좁은 화면에서 셀을 뭉개지 말고 가로로 스크롤시킨다 */
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 760px; }
#tbl-scans { min-width: 900px; }

code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 20px;
  font-size: 11px; background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
}
.tag.gray { background: var(--bg); color: var(--muted); border-color: var(--line); }
.tag.good { background: transparent; color: var(--good); border-color: var(--good); }

.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; font-size: 13.5px; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  background: var(--panel); color: var(--ink); max-width: 560px; width: calc(100vw - 32px);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .body { padding: 20px; }
dialog h3 { margin: 0 0 16px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { margin-bottom: 12px; }

.bars { display: grid; gap: 5px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 9px; font-size: 12.5px; }
.bar-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.bar-row .track { background: var(--bg); border-radius: 4px; height: 15px; overflow: hidden; border: 1px solid var(--line); }
.bar-row .fill { height: 100%; background: var(--accent); opacity: .75; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 132px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; min-width: 0; }
.chart .stick { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .8; }
.chart .stick.zero { background: var(--line); }
.chart .xl { font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }

.dual { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .dual, .grid2 { grid-template-columns: 1fr; } main { padding: 16px 14px 60px; } header.top { padding: 12px 14px; } }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px;
  font-size: 13.5px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
