:root {
  --bg: #f6f7f9; --card: #ffffff; --ink: #1a2332; --muted: #5b6575; --line: #e2e6ec;
  --accent: #1f5fbf; --accent-soft: #e6eefa; --pos: #1d7a4f; --neg: #b3261e; --warn: #8a5a00; --warn-soft: #fff4dc;
  --bar: #1f5fbf; --bar2: #9db7e0; --bar3: #2f9e6e;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161e; --card: #1a212c; --ink: #e8ecf2; --muted: #9aa5b5; --line: #2c3544;
    --accent: #7fb0ff; --accent-soft: #1e2d45; --pos: #5fd19a; --neg: #ff8a80; --warn: #f0c060; --warn-soft: #3a2e12;
    --bar: #6fa3f5; --bar2: #3d5680; --bar3: #4fc08d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); } .center { text-align: center; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand strong { font-size: 18px; } .brand .sub { font-size: 12px; color: var(--muted); }
.who { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 14px; white-space: nowrap; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 8px 4px; }
.tabs-top { display: none; gap: 4px; }
.tabs-top a, .tabs-bottom a { text-decoration: none; color: var(--muted); }
.tabs-top a { padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.tabs-top a.on { background: var(--accent-soft); color: var(--accent); }
.tabs-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs-bottom a { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 56px; font-size: 13px; font-weight: 600; }
.tabs-bottom .ic { font-size: 18px; line-height: 1; margin-bottom: 2px; }
.tabs-bottom a.on { color: var(--accent); }
@media (min-width: 860px) {
  body { padding-bottom: 24px; }
  .tabs-top { display: flex; } .tabs-bottom { display: none; }
}
main { max-width: 1120px; margin: 0 auto; padding: 16px; }
h2 { font-size: 20px; margin: 24px 0 8px; } h2:first-child { margin-top: 0; }
h3 { font-size: 17px; margin: 16px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.note { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 12px; font-size: 14px; margin: 8px 0; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.kpi.main { border-color: var(--accent); }
.kpi .lb { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; margin: 2px 0; overflow-wrap: anywhere; }
.kpi .s { font-size: 13px; color: var(--muted); }
.grid2 { display: grid; gap: 16px; } @media (min-width: 860px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2 > .card { margin-bottom: 0; } }

/* 가로 막대 */
.hbars { display: grid; gap: 8px; }
.hb { display: grid; grid-template-columns: minmax(64px, 30%) 1fr; gap: 8px; align-items: center; font-size: 14px; }
.hb .l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb .track { position: relative; height: 22px; background: var(--accent-soft); border-radius: 4px; }
.hb .fill { position: absolute; inset: 0 auto 0 0; background: var(--bar); border-radius: 4px; }
.hb .val { position: absolute; left: 6px; top: 0; line-height: 22px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.hb .fill + .val.in { color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
svg.chart .grid { stroke: var(--line); }

/* 표 */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; }

/* 목록 */
.filters { background: var(--bg); padding-bottom: 8px; }
@media (min-width: 860px) { .filters { position: sticky; top: 64px; z-index: 3; } }
.filters input[type=search], select, .login-card input { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.filters .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
@media (min-width: 640px) { .filters .row { grid-template-columns: repeat(4, 1fr); } }
.filters .chips { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 15px; }
.filters .chips label { display: inline-flex; gap: 6px; align-items: center; min-height: 32px; }
.chips input { width: 18px; height: 18px; }
.count { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.cards { display: grid; gap: 8px; } @media (min-width: 860px) { .cards { grid-template-columns: 1fr 1fr; } }
.co { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.co:hover { border-color: var(--accent); }
.co .t { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.co .nm { font-weight: 700; overflow-wrap: anywhere; }
.co .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.co .nums { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.co .nums b { font-weight: 700; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--pos) 15%, transparent); color: var(--pos); }
.badge.bad { background: color-mix(in srgb, var(--neg) 15%, transparent); color: var(--neg); }
.badge.gray { background: var(--line); color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.up { color: var(--pos); } .down { color: var(--neg); }

/* 상세 */
.back { display: inline-block; margin-bottom: 8px; padding: 8px 0; text-decoration: none; font-weight: 600; }
.dhead h2 { margin: 0 0 4px; overflow-wrap: anywhere; }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; font-size: 15px; }
dl.info dt { color: var(--muted); } dl.info dd { margin: 0; overflow-wrap: anywhere; }
.rounds { display: grid; gap: 8px; }
.rd { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.rd .h { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-weight: 600; }
.rd .amt { margin-left: auto; font-variant-numeric: tabular-nums; }
.rd .inv { color: var(--muted); margin-top: 4px; }
.rd .inv b { color: var(--accent); font-weight: 700; }
.case { display: block; text-decoration: none; color: inherit; }
.dl-list { display: grid; gap: 8px; } .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
@media (prefers-color-scheme: dark) { .btn { color: #0c1420; } .hb .fill + .val.in { color: #0c1420; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.seg button { font: inherit; font-size: 14px; padding: 8px 12px; border: 0; background: var(--card); color: var(--muted); cursor: pointer; min-height: 40px; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* 로그인 */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: grid; gap: 8px; }
.login-card h1 { font-size: 20px; margin: 0; } .login-card label { font-size: 14px; font-weight: 600; margin-top: 8px; }
.login-card .btn { margin-top: 8px; width: 100%; }
.err { color: var(--neg); font-size: 14px; min-height: 1.5em; margin: 0; }
@media (prefers-reduced-motion: no-preference) { .co, .btn { transition: border-color .15s, opacity .15s; } }

/* 확약사 연계 판정 · 입력 */
.seg.wrap { display: flex; flex-wrap: wrap; overflow: visible; border: 0; gap: 4px; }
.seg.wrap button { border: 1px solid var(--line); border-radius: 8px; }
.rd.open { border-color: var(--accent); }
.why { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.fld { display: grid; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.fld input, .fld select { width: 100%; font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); min-height: 44px; }
.edit { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
@media (min-width: 640px) { .edit { grid-template-columns: 1fr 1fr; } .edit .wide { grid-column: 1 / -1; } }
.edit fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 12px; margin: 0; min-width: 0; }
.pair > *, .fld input[type=date] { min-width: 0; }
.edit legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btns { display: flex; gap: 8px; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.sm { min-height: 44px; padding: 8px 12px; }
.prow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; padding: 8px 0; border-bottom: 1px solid var(--line); }
.prow .pl { grid-column: 1 / -1; font-weight: 700; }
.prow .src { font-size: 13px; color: var(--muted); align-self: center; }
.prow .src.warn { color: var(--warn); font-weight: 700; }
.prow .err { grid-column: 1 / -1; min-height: 0; }
@media (min-width: 860px) { .prow { grid-template-columns: 180px 1fr 1fr 1fr auto; } .prow .pl { grid-column: auto; align-self: center; } }
.log { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 4px; overflow-wrap: anywhere; }
.log code { font-size: 12px; }
a.brand { text-decoration: none; color: inherit; }
.hist-btn { text-decoration: none; font-weight: 600; font-size: 14px; padding: 6px 10px; min-height: 36px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--accent); }
.hist-btn.on { background: var(--accent-soft); border-color: var(--accent); }
@media (max-width: 420px) { #who-name { display: none; } }
.rd .hi { margin-top: 4px; font-weight: 600; overflow-wrap: anywhere; }
