/* ==========================================================================
   2027 정시 실전 전략 대시보드 — Clean Editorial + WCAG AAA High-Contrast
   No AI-slop gradients, no decorative bloat, strict tabular-nums alignment.
   ========================================================================== */

:root {
  --font-sans: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --base-size: 15px;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --ink: #0f172a;
  --ink-secondary: #334155;
  --ink-muted: #64748b;

  --brand: #1e40af;
  --brand-soft: #eff6ff;
  --brand-border: #bfdbfe;

  --safe-fg: #047857;
  --safe-bg: #ecfdf5;
  --safe-bd: #a7f3d0;

  --fit-fg: #1d4ed8;
  --fit-bg: #eff6ff;
  --fit-bd: #bfdbfe;

  --bold-fg: #b45309;
  --bold-bg: #fffbeb;
  --bold-bd: #fde68a;

  --reach-fg: #be123c;
  --reach-bg: #fff1f2;
  --reach-bd: #fecdd3;

  --fail-fg: #991b1b;
  --fail-bg: #fef2f2;
  --fail-bd: #fecaca;

  --neutral-fg: #334155;
  --neutral-bg: #f1f5f9;
  --neutral-bd: #cbd5e1;

  --focus-ring: #2563eb;
  --radius: 8px;
  --radius-sm: 6px;
}

/* Text Scale Accessibility Modes */
html[data-scale="md"] { --base-size: 15px; }
html[data-scale="lg"] { --base-size: 18px; }
html[data-scale="xl"] { --base-size: 21px; }

/* WCAG AAA High-Contrast Dark Mode for Low-Vision / Visually Impaired Users */
html[data-theme="high-contrast"] {
  --bg: #000000;
  --surface: #0b0f17;
  --surface-subtle: #151c28;
  --surface-hover: #1e293b;
  --border: #475569;
  --border-strong: #94a3b8;

  --ink: #ffffff;
  --ink-secondary: #e2e8f0;
  --ink-muted: #cbd5e1;

  --brand: #facc15;
  --brand-soft: #262109;
  --brand-border: #facc15;

  --safe-fg: #6ee7b7;
  --safe-bg: #06291e;
  --safe-bd: #10b981;

  --fit-fg: #93c5fd;
  --fit-bg: #0c1f3f;
  --fit-bd: #60a5fa;

  --bold-fg: #fde047;
  --bold-bg: #2e2404;
  --bold-bd: #eab308;

  --reach-fg: #fda4af;
  --reach-bg: #360b14;
  --reach-bd: #fb7185;

  --fail-fg: #fca5a5;
  --fail-bg: #3b0a0a;
  --fail-bd: #f87171;

  --neutral-fg: #e2e8f0;
  --neutral-bg: #1e293b;
  --neutral-bd: #64748b;

  --focus-ring: #facc15;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: var(--base-size);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  z-index: 1000;
}
.skip-link:focus { left: 1rem; top: 0.75rem; border-radius: var(--radius-sm); }
html[data-theme="high-contrast"] .skip-link { color: #000000; }

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Utility Bar */
.util-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.util-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.6rem;
  flex-wrap: wrap;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}
.util-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.meta-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--safe-fg);
  display: inline-block;
}
.sep { opacity: 0.5; }

.util-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.control-group {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.control-label {
  font-weight: 600;
  color: var(--ink-secondary);
  margin-right: 0.15rem;
}
.util-btn {
  appearance: none;
  background: var(--surface);
  color: var(--ink-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 0.22rem 0.55rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.util-btn:hover { background: var(--surface-subtle); }
.util-btn[aria-pressed="true"] {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}
html[data-theme="high-contrast"] .util-btn[aria-pressed="true"] {
  color: #000000;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0 1.35rem;
}
.header-inner {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brand);
}
h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.25;
}
.subtitle {
  margin: 0.45rem 0 0;
  color: var(--ink-secondary);
  font-size: 0.96rem;
}

.score-pill-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.6rem;
}
.score-pill {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.score-pill.pill-muted { opacity: 0.82; }
.pill-k {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-muted);
}
.pill-v {
  font-size: 0.98rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pill-v em {
  font-style: normal;
  font-weight: 700;
  color: var(--brand);
  margin-left: 0.2rem;
}

/* Sticky Scenario Controller */
.scenario-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}
.scenario-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  flex-wrap: wrap;
}
.scenario-groups {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}
.sg {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.sg-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-muted);
}
.seg-control {
  display: inline-flex;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.seg-btn small {
  font-size: 0.74rem;
  font-weight: 500;
  opacity: 0.85;
  margin-left: 0.15rem;
}
.seg-btn:hover { background: var(--surface); }
.seg-btn[aria-pressed="true"] {
  background: var(--brand);
  color: #ffffff;
}
html[data-theme="high-contrast"] .seg-btn[aria-pressed="true"] {
  color: #000000;
}

.gate-badge {
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 700;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
.gate-badge.gate-pass {
  background: var(--safe-bg);
  color: var(--safe-fg);
  border-color: var(--safe-bd);
}
.gate-badge.gate-fail {
  background: var(--fail-bg);
  color: var(--fail-fg);
  border-color: var(--fail-bd);
}
.gate-badge small {
  display: block;
  font-weight: 500;
  font-size: 0.76rem;
  opacity: 0.92;
}

/* Primary Tabs */
.tab-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab-nav-inner {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 700;
  padding: 0.85rem 1rem;
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* Main Wrap */
.main-wrap {
  padding-top: 1.5rem;
  padding-bottom: 3.5rem;
}
.tab-panel[hidden] { display: none; }

.section-head {
  margin-bottom: 1rem;
}
.section-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.section-desc {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-secondary);
}
.row-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.mt-24 { margin-top: 1.5rem; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
}
.kpi-value {
  margin-top: 0.3rem;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.kpi-sub {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--ink-secondary);
}

/* 3-Card Portfolio */
.three-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.pick-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-top: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.pick-card.pick-priority { border-top-color: var(--safe-fg); }
.pick-card.pick-safety { border-top-color: var(--bold-fg); }
.pick-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.group-tag {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-border);
}
.pick-univ {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.pick-dept {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-secondary);
}
.pick-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
}
.pm-k {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
}
.pm-v {
  font-size: 0.96rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.pick-reason {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-secondary);
}
.pick-risk {
  margin: auto 0 0;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-strong);
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.pick-risk strong { color: var(--ink-secondary); }

/* Cards & Two-Col */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.table-card { padding: 0; overflow: hidden; }
.card-head { margin-bottom: 1rem; }
.card-head h3 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 800;
}
.card-sub {
  margin: 0.25rem 0 0;
  font-size: 0.84rem;
  color: var(--ink-muted);
}
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 1rem;
  align-items: start;
}

/* Leverage Horizontal Bars */
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.bar-item {
  display: grid;
  grid-template-columns: 11.5rem minmax(0, 1fr) 4.4rem;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.86rem;
}
.bar-name {
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-name small {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-muted);
}
.bar-track {
  height: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 2px;
  transition: width 0.2s ease;
}
.bar-fill.bar-good { background: var(--safe-fg); }
.bar-fill.bar-warn { background: var(--bold-fg); }
.bar-fill.bar-bad { background: var(--reach-fg); }
.bar-val {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.footnote {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.callout-box {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface-subtle);
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  color: var(--ink-secondary);
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th,
.data-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.compact-table th,
.compact-table td {
  padding: 0.58rem 0.75rem;
  font-size: 0.84rem;
}
.data-table th {
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
}
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tr.row-disabled { opacity: 0.62; }
.data-table tr.row-highlight { background: var(--safe-bg); }
.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.univ-cell strong { display: block; font-size: 0.92rem; }
.univ-cell span { display: block; font-size: 0.8rem; color: var(--ink-muted); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.18rem 0.52rem;
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-safe { background: var(--safe-bg); color: var(--safe-fg); border-color: var(--safe-bd); }
.badge-fit { background: var(--fit-bg); color: var(--fit-fg); border-color: var(--fit-bd); }
.badge-bold { background: var(--bold-bg); color: var(--bold-fg); border-color: var(--bold-bd); }
.badge-reach { background: var(--reach-bg); color: var(--reach-fg); border-color: var(--reach-bd); }
.badge-fail { background: var(--fail-bg); color: var(--fail-fg); border-color: var(--fail-bd); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); border-color: var(--neutral-bd); }

/* Filters & Chips */
.filter-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.filter-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
  margin-right: 0.2rem;
}
.chip {
  appearance: none;
  background: var(--surface);
  color: var(--ink-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { background: var(--surface-subtle); }
.chip.active {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}
html[data-theme="high-contrast"] .chip.active { color: #000000; }

.comp-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.expand-btn {
  appearance: none;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 0.22rem 0.55rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.expand-btn:hover { border-color: var(--brand); color: var(--brand); }

.sub-row td {
  background: var(--surface-subtle);
  padding: 0.85rem 1rem;
}
.sub-dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.55rem;
}
.sub-dept-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

/* Search & Audit Summary */
.audit-summary-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.search-box input {
  width: 290px;
  max-width: 100%;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.checkbox-inline input { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); }

/* Collapsible Ref */
.collapsible-ref summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-secondary);
}
.details-body {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--ink-secondary);
}

/* Checklist */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.check-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.check-item label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.check-item input {
  margin-top: 0.22rem;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  accent-color: var(--brand);
}
.check-item.done span {
  text-decoration: line-through;
  opacity: 0.6;
}
.btn-outline {
  appearance: none;
  background: var(--surface);
  color: var(--ink-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.85rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-subtle);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.4rem 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}
.footer-inner p { margin: 0.25rem 0; }

/* Responsive */
@media (max-width: 960px) {
  .score-pill-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-cards { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .audit-summary-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checklist-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .score-pill-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scenario-bar { position: static; }
  .bar-item { grid-template-columns: 8.5rem minmax(0, 1fr) 3.8rem; }
}

/* Print Stylesheet */
@media print {
  .util-bar, .scenario-bar, .tab-nav, .filter-row, .btn-outline, .expand-btn { display: none !important; }
  .tab-panel[hidden] { display: block !important; page-break-before: always; }
  body { background: #ffffff; color: #000000; }
  .card, .pick-card { border-color: #94a3b8; break-inside: avoid; }
}
