:root {
  --ink: #17211d;
  --muted: #68736d;
  --line: #dfe5e1;
  --paper: #f5f7f4;
  --card: #ffffff;
  --green: #165f47;
  --green-dark: #0f4333;
  --mint: #dff3e7;
  --red: #c44e45;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-geist-sans), "Pretendard", "Noto Sans KR", sans-serif;
  letter-spacing: -0.02em;
}
button { font: inherit; }

.dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  padding: 30px 22px;
  background: #10281f;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 42px;
}
.brand-mark { display: flex; align-items: center; gap: 12px; }
.brand-dot {
  width: 16px;
  height: 16px;
  border: 4px solid #8be0b8;
  border-radius: 50%;
  box-shadow: 9px -9px 0 -5px #f8b078;
}
.brand-mark div { display: grid; }
.brand-mark strong { font-size: 18px; letter-spacing: 0.08em; }
.brand-mark span { font-size: 11px; color: #9eb8ad; letter-spacing: 0.06em; }
.side-nav { display: grid; gap: 6px; }
.nav-item {
  width: 100%;
  border: 0;
  border-radius: 9px;
  padding: 13px 12px;
  display: flex;
  gap: 13px;
  align-items: center;
  background: transparent;
  color: #9eb8ad;
  text-align: left;
}
.nav-item.active { background: rgba(139, 224, 184, 0.12); color: #fff; }
.nav-item:disabled { opacity: 0.55; }
.nav-index {
  font-family: var(--font-geist-mono), monospace;
  font-size: 10px;
  color: #6c8d7f;
}
.nav-item.active .nav-index { color: #8be0b8; }
.sidebar-note {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: grid;
  gap: 4px;
}
.sidebar-note span { font-size: 9px; color: #6c8d7f; letter-spacing: 0.12em; }
.sidebar-note strong { font-size: 13px; }
.sidebar-note small { color: #9eb8ad; font-size: 10px; }

.content { min-width: 0; padding: 34px 38px 54px; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 26px;
}
.eyebrow, .section-kicker {
  margin: 0 0 8px;
  font-family: var(--font-geist-mono), monospace;
  font-size: 10px;
  letter-spacing: 0.13em;
  color: var(--green);
}
.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.055em;
}
.topbar > div > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.freshness {
  margin-top: 7px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #43ad79;
  box-shadow: 0 0 0 4px #e5f5ec;
}
.freshness div { display: grid; gap: 2px; }
.freshness strong { font-size: 11px; }
.freshness span { font-size: 10px; color: var(--muted); }

.control-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.82);
  box-shadow: 0 8px 30px rgba(20,50,37,0.04);
  display: grid;
  gap: 12px;
}
.view-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}
.segmented { display: flex; padding: 3px; border-radius: 9px; background: #e9eeeb; }
.segmented button {
  border: 0;
  padding: 9px 15px;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
  font-size: 12px;
  cursor: pointer;
}
.segmented button.selected {
  background: var(--ink);
  color: white;
  box-shadow: 0 3px 10px rgba(20,34,28,0.16);
}
.period-control { display: flex; align-items: center; gap: 8px; }
.period-control > button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 7px;
  cursor: pointer;
}
.period-control > button:disabled { opacity: 0.35; cursor: not-allowed; }
.period-control div {
  min-width: 240px;
  text-align: center;
  display: grid;
  gap: 2px;
}
.period-control strong { font-size: 13px; }
.period-control span { color: var(--muted); font-size: 10px; }
.period-control .latest-button {
  width: auto;
  padding: 0 11px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.filter-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.filter-label { flex: 0 0 65px; color: var(--muted); font-size: 11px; font-weight: 700; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-group button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: #4e5954;
  padding: 7px 11px;
  font-size: 11px;
  cursor: pointer;
  transition: 150ms ease;
}
.chip-group button:hover { border-color: #99b7a9; }
.chip-group button.active {
  background: var(--mint);
  border-color: #99d1b5;
  color: var(--green-dark);
  font-weight: 700;
}
.filter-bottom { display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.filter-row.compact { flex: 1; }
.filter-actions { display: flex; gap: 7px; }
.filter-actions button { border-radius: 8px; padding: 8px 11px; font-size: 11px; cursor: pointer; }
.detail-filter { color: white; background: var(--green); border: 1px solid var(--green); }
.detail-filter span { margin-left: 8px; }
.reset-filter { color: var(--muted); background: white; border: 1px solid var(--line); }

.kpi-section { margin-top: 28px; }
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 12px;
}
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -0.035em; }
.section-heading p, .unit { margin: 0; color: var(--muted); font-size: 10px; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(160px, 1fr)); gap: 10px; }
.kpi-card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(17,47,34,0.035);
}
.kpi-card.primary { border-top: 3px solid var(--green); padding-top: 14px; }
.kpi-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}
.kpi-title small { font-family: var(--font-geist-mono), monospace; color: #aab4af; }
.kpi-value {
  display: block;
  margin-top: 11px;
  font-size: clamp(20px, 2.05vw, 30px);
  letter-spacing: -0.055em;
  white-space: nowrap;
}
.kpi-hint { min-height: 14px; margin: 5px 0 15px; color: #8a948f; font-size: 9px; }
.comparison-list {
  padding-top: 10px;
  border-top: 1px solid #edf0ee;
  display: grid;
  gap: 7px;
}
.comparison-list div { display: flex; justify-content: space-between; gap: 8px; font-size: 9px; }
.comparison-list span { color: var(--muted); }
.comparison-list strong { font-family: var(--font-geist-mono), monospace; font-size: 9px; }
.positive { color: var(--green); }
.negative { color: var(--red); }

.insight-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 10px;
}
.comparison-card, .signal-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  padding: 17px;
}
.compact-heading { margin-bottom: 18px; }
.bar-list { display: grid; gap: 14px; }
.bar-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 10px;
  color: var(--muted);
}
.bar-label strong { color: var(--ink); font-family: var(--font-geist-mono), monospace; }
.bar-track { height: 8px; background: #edf1ee; border-radius: 99px; overflow: hidden; }
.bar-track span { display: block; height: 100%; border-radius: 99px; }
.bar-track .accent { background: var(--green); }
.bar-track .muted { background: #abc3b8; }
.signal-card {
  background: var(--green-dark);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.signal-card .section-kicker { color: #8be0b8; }
.signal-card h2 {
  margin: 8px 0 10px;
  max-width: 420px;
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: -0.04em;
}
.signal-card p { margin: 0 0 18px; color: #bcd0c7; font-size: 11px; line-height: 1.6; }
.signal-card button {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.signal-card button span { margin-left: 8px; color: #8be0b8; }

@media (max-width: 1180px) {
  .dashboard-shell { grid-template-columns: 188px minmax(0, 1fr); }
  .content { padding: 28px 26px 44px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
}

@media (max-width: 820px) {
  .dashboard-shell { display: block; }
  .sidebar { position: static; min-height: auto; padding: 18px; gap: 18px; }
  .side-nav { display: flex; overflow-x: auto; }
  .nav-item { width: auto; min-width: max-content; }
  .sidebar-note { display: none; }
  .content { padding: 22px 16px 40px; }
  .topbar, .view-row, .filter-bottom { align-items: stretch; flex-direction: column; }
  .freshness { align-self: flex-start; }
  .period-control { justify-content: space-between; }
  .period-control div { min-width: 0; flex: 1; }
  .filter-row { align-items: flex-start; flex-direction: column; gap: 7px; }
  .filter-label { flex-basis: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insight-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar h1 { font-size: 30px; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 28px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
}
