/* 민들레 건강반 2026 현황 — 업무 화면 스타일
   토큰: :root 에 라이트 전부 → prefers-color-scheme:dark 와 [data-theme="dark"] 에서 덮어쓴다.
   외부 폰트·CDN 없음. */

:root {
  color-scheme: light;

  --bg:        #f4f6f8;
  --surface:   #ffffff;
  --surface-2: #f8fafb;
  --border:    #dfe4ea;
  --border-2:  #eef1f4;

  --text:      #1b2127;
  --text-2:    #46505b;
  --muted:     #6c7681;

  --accent:    #2a78d6;
  --accent-bg: rgba(42, 120, 214, 0.10);
  --track:     #e7ebef;

  --ok:        #0ca30c;
  --ok-bg:     rgba(12, 163, 12, 0.10);
  --warn:      #fab219;
  --warn-bg:   rgba(250, 178, 25, 0.16);
  --warn-text: #7a5300;
  --danger:    #c0392b;
  --danger-bg: rgba(192, 57, 43, 0.10);

  /* 분류 색 — 순서 고정 */
  --cat-1: #2a78d6;
  --cat-2: #eb6834;
  --cat-3: #1baf7a;
  --cat-4: #eda100;
  --cat-0: #98a2ac;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
          "Noto Sans KR", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "D2Coding", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:        #14181c;
    --surface:   #1b2025;
    --surface-2: #20262c;
    --border:    #2c343c;
    --border-2:  #242b32;
    --text:      #e6eaee;
    --text-2:    #b9c2cb;
    --muted:     #8e99a4;
    --accent:    #3987e5;
    --accent-bg: rgba(57, 135, 229, 0.16);
    --track:     #2a3139;
    --ok:        #35bb35;
    --ok-bg:     rgba(53, 187, 53, 0.14);
    --warn:      #fab219;
    --warn-bg:   rgba(250, 178, 25, 0.16);
    --warn-text: #f0c86a;
    --danger:    #e46e60;
    --danger-bg: rgba(228, 110, 96, 0.14);
    --cat-1: #3987e5;
    --cat-2: #f07c4d;
    --cat-3: #2ec48c;
    --cat-4: #f0b42e;
    --cat-0: #7d8892;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #14181c;
  --surface:   #1b2025;
  --surface-2: #20262c;
  --border:    #2c343c;
  --border-2:  #242b32;
  --text:      #e6eaee;
  --text-2:    #b9c2cb;
  --muted:     #8e99a4;
  --accent:    #3987e5;
  --accent-bg: rgba(57, 135, 229, 0.16);
  --track:     #2a3139;
  --ok:        #35bb35;
  --ok-bg:     rgba(53, 187, 53, 0.14);
  --warn:      #fab219;
  --warn-bg:   rgba(250, 178, 25, 0.16);
  --warn-text: #f0c86a;
  --danger:    #e46e60;
  --danger-bg: rgba(228, 110, 96, 0.14);
  --cat-1: #3987e5;
  --cat-2: #f07c4d;
  --cat-3: #2ec48c;
  --cat-4: #f0b42e;
  --cat-0: #7d8892;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── 상단 바 ─────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; }
.brand .sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.flag {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--warn);
  border-radius: 999px;
  color: var(--warn-text);
  background: var(--warn-bg);
  font-size: 11px;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.btn-ghost {
  display: inline-block;
  padding: 5px 10px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

/* ── 레이아웃 ─────────────────────────────── */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
}
.panel-error {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--text);
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.panel-head h2 { font-size: 14.5px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.note { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }

/* ── KPI ─────────────────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px 11px;
  min-width: 0;
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value {
  font-size: 26px;
  font-weight: 680;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.kpi-sub {
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 매트릭스 ─────────────────────────────── */
.matrix-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  overflow-x: auto;
}
.matrix-chunk { flex: 1 1 320px; min-width: 300px; }
table.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.matrix th {
  font-weight: 600;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  padding: 0 0 5px;
  border-bottom: 1px solid var(--border);
}
table.matrix th.mx-name { text-align: left; }
table.matrix td {
  padding: 3px 2px;
  border-bottom: 1px solid var(--border-2);
  text-align: center;
  height: 22px;
}
table.matrix td.mx-name {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 1px;
  width: 42%;
  color: var(--text-2);
}
table.matrix tbody tr:hover td { background: var(--surface-2); }
table.matrix tbody tr.is-flagged td.mx-name { color: var(--text); }
.mx-col { width: 14%; }
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
.dot-more {
  font-size: 10px;
  color: var(--muted);
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}
.mx-empty { color: var(--border); }
.mx-flag {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
  margin-right: 5px;
  vertical-align: 1px;
}

/* ── 차트 ─────────────────────────────────── */
.charts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 14px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 15px 15px;
  min-width: 0;
}
.chart-card h3 { font-size: 13.5px; }
.chart-card .unit { font-size: 11.5px; color: var(--muted); margin: 1px 0 10px; }
.bars { display: grid; gap: 5px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(56px, 26%) 1fr auto;
  align-items: center;
  gap: 9px;
}
.bar-label {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-svg { display: block; width: 100%; height: 9px; }
.bar-track { fill: var(--track); }
.bar-fill  { fill: var(--accent); }
.bar-fill.neutral { fill: var(--cat-0); }
.bar-value {
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: right;
}
.bar-value .pct { color: var(--muted); font-size: 11px; margin-left: 3px; }

/* ── 표 ──────────────────────────────────── */
.panel-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sr-label {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
input[type="search"] {
  font: inherit;
  font-size: 13px;
  padding: 5px 9px;
  min-width: 230px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
input[type="search"]::placeholder { color: var(--muted); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-2);
  border-radius: 6px;
}
table#class-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  font-size: 12.5px;
}
table#class-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--muted);
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
th.sortable::after { content: ""; display: inline-block; width: 11px; }
th.sortable[aria-sort="ascending"]::after  { content: "▲"; font-size: 8px; margin-left: 3px; }
th.sortable[aria-sort="descending"]::after { content: "▼"; font-size: 8px; margin-left: 3px; }
table#class-table td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}
table#class-table tbody tr:hover td { background: var(--surface-2); }
table#class-table tbody tr:last-child td { border-bottom: 0; }
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.cls-name { font-weight: 600; white-space: nowrap; }
.dim { color: var(--muted); }

.cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.cat-dot {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex: none;
  background: var(--cat-0);
}
.cat-1 .cat-dot { background: var(--cat-1); }
.cat-2 .cat-dot { background: var(--cat-2); }
.cat-3 .cat-dot { background: var(--cat-3); }
.cat-4 .cat-dot { background: var(--cat-4); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1.5px 7px 1.5px 6px;
  border-radius: 999px;
  font-size: 11.5px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-ok    { color: var(--ok);        background: var(--ok-bg);   border-color: var(--ok); }
.badge-warn  { color: var(--warn-text); background: var(--warn-bg); border-color: var(--warn); }
.badge-mark  { font-weight: 700; }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}

.empty-row td { text-align: center; color: var(--muted); padding: 18px 0; }

/* ── 검수 ─────────────────────────────────── */
.review-grid {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 16px;
}
.review-counts { display: grid; gap: 7px; align-content: start; }
.rc {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 6px;
}
.rc-label { font-size: 12.5px; color: var(--text-2); }
.rc-value { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.review-list-box h3 { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 7px; }
.review-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.review-list li {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
  padding: 6px 10px;
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  background: var(--surface-2);
}
.review-list .rl-name { font-weight: 600; }
.review-list .rl-note { color: var(--text-2); font-size: 12.5px; }

/* ── 푸터 ─────────────────────────────────── */
.sitefoot {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px 28px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ── 로그인 ───────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}
.login-wrap {
  margin: auto;
  width: 100%;
  max-width: 380px;
  padding: 24px 18px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 24px 22px 20px;
}
.login-title { font-size: 17px; }
.login-sub { margin: 6px 0 18px; font-size: 12.5px; color: var(--muted); }
.login-label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
/* 로그인·비밀번호 변경 화면의 입력칸. 칸이 여럿이라 id 가 아니라 클래스로 건다. */
#pw, .login-card input[type="text"], .login-card input[type="password"] {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  margin-bottom: 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.login-card input:last-of-type { margin-bottom: 0; }
.login-error {
  margin: 9px 0 0;
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 6px 9px;
}
.btn-primary {
  margin-top: 14px;
  width: 100%;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 12px;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.07); }
.login-note { margin: 16px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.55; }
.login-ok { margin: 9px 0 0; font-size: 12.5px; color: var(--muted); }

/* 우상단 「누구로 들어와 있나」 — 자기가 누구인지 화면에 보여야 한다 */
.who {
  font-size: 12.5px;
  color: var(--text-2);
  align-self: center;
  margin-right: 4px;
  white-space: nowrap;
}

/* ── 반응형 ───────────────────────────────── */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  main { padding: 12px 12px 26px; }
  .topbar { padding: 10px 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: 1fr; }
  .matrix-chunk { flex-basis: 100%; }
  input[type="search"] { min-width: 0; width: 100%; }
  .panel-tools { width: 100%; }
  .sitefoot { padding: 0 12px 24px; }
}

@media print {
  .topbar-actions, .panel-tools { display: none; }
  body { background: #fff; }
  .panel, .kpi, .chart-card { box-shadow: none; }
}
