:root {
  color-scheme: light;
  --page: #f2f6f6;
  --surface: #ffffff;
  --surface-soft: #f7f9f9;
  --text: #142427;
  --muted: #687b7e;
  --border: #dce6e7;
  --border-strong: #c8d7d9;
  --brand: #0b756e;
  --brand-dark: #075c57;
  --brand-soft: #e3f2f0;
  --blue: #536da8;
  --blue-soft: #e8edf8;
  --good: #16764d;
  --good-soft: #e5f4ec;
  --bad: #bd4048;
  --bad-soft: #fbecee;
  --warning: #9a6411;
  --warning-soft: #fff3dd;
  --shadow: 0 18px 50px rgba(28, 59, 63, .08);
  --sidebar-width: 236px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(11, 117, 110, .22);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 22px 17px;
  background: #102729;
  color: #f3f9f8;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 7px 25px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: #45c4b7;
  color: #092a28;
  font-weight: 800;
  letter-spacing: -.7px;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .2px; }
.brand small { margin-top: 2px; color: #9eb8b8; font-size: 11px; }
.nav-list { display: grid; gap: 6px; }
.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  color: #a9bdbd;
  background: transparent;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nav-item:hover { color: #ffffff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #ffffff; background: rgba(69,196,183,.14); }
.nav-icon { display: inline-grid; width: 20px; place-items: center; color: #65d0c5; font-size: 18px; }
.sidebar-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: auto;
  padding: 13px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
}
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 11px; font-weight: 650; }
.sidebar-note small { margin-top: 4px; color: #8fa9a9; font-size: 10px; line-height: 1.45; }
.status-dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: #5ad0a0; box-shadow: 0 0 0 4px rgba(90,208,160,.12); }

.main-shell { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px);
}
.topbar-copy { min-width: 0; }
.topbar-copy h1 { margin: 1px 0 0; font-size: 18px; line-height: 1.2; letter-spacing: -.25px; }
.eyebrow, .section-kicker { color: var(--brand); font-size: 10px; font-weight: 750; letter-spacing: 1.25px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.freshness { display: flex; align-items: center; gap: 7px; margin-right: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.freshness-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.button, .icon-button, .text-button {
  border: 0;
  cursor: pointer;
}
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}
.button-primary { color: #ffffff; background: var(--brand); }
.button-primary:hover { background: var(--brand-dark); }
.button-primary:disabled { cursor: not-allowed; opacity: .45; }
.button-secondary { border-color: var(--border); color: var(--text); background: var(--surface); }
.button-secondary:hover { background: var(--surface-soft); border-color: var(--border-strong); }
.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  font-size: 22px;
}
.icon-button:hover { background: var(--surface-soft); }
.menu-button { display: none; font-size: 18px; }
.text-button { padding: 5px; color: var(--brand); background: transparent; font-size: 11px; font-weight: 650; }
.text-button:hover { text-decoration: underline; }

.content { width: min(1500px, 100%); margin: 0 auto; padding: 25px 28px 35px; }
.filters, .panel, .table-panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(33, 69, 73, .035);
}
.filters { padding: 18px; }
.filter-heading, .section-heading, .panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.filter-heading { margin-bottom: 16px; }
.filter-heading h2, .section-heading h2, .panel-heading h2, .drawer-header h2 {
  margin: 3px 0 0;
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: -.2px;
}
.filter-grid { display: grid; grid-template-columns: minmax(165px,.68fr) minmax(300px,1fr) minmax(300px,1fr); gap: 13px; }
.field { display: grid; min-width: 0; gap: 6px; }
.field > span, .period-group legend { color: var(--muted); font-size: 11px; font-weight: 650; }
.field input, .field select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  background: var(--surface-soft);
}
.field input:hover, .field select:hover { border-color: var(--border-strong); }
.period-group { min-width: 0; margin: 0; padding: 9px 10px 10px; border: 1px solid var(--border); border-radius: 11px; }
.period-group legend { padding: 0 5px; }
.period-base { border-left: 3px solid var(--blue); }
.period-current { border-left: 3px solid var(--brand); }
.date-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-error { margin: 12px 0 0; color: var(--bad); font-size: 12px; }

.section-block { margin-top: 25px; scroll-margin-top: 95px; }
.section-heading { margin-bottom: 12px; }
.section-heading > p { margin: 0; color: var(--muted); font-size: 11px; text-align: right; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.kpi-card {
  position: relative;
  min-width: 0;
  padding: 15px 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.kpi-card::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand);
  content: "";
  opacity: 0;
}
.kpi-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.kpi-card[aria-pressed="true"] { border-color: rgba(11,117,110,.62); background: linear-gradient(135deg, var(--surface), var(--brand-soft)); }
.kpi-card[aria-pressed="true"]::after { opacity: 1; }
.kpi-label { display: block; min-height: 33px; color: var(--muted); font-size: 11px; font-weight: 650; }
.kpi-main { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 7px; }
.kpi-value { font-size: clamp(19px,2vw,24px); line-height: 1; letter-spacing: -.75px; white-space: nowrap; }
.kpi-delta { padding: 3px 7px; border-radius: 999px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.kpi-delta.good { color: var(--good); background: var(--good-soft); }
.kpi-delta.bad { color: var(--bad); background: var(--bad-soft); }
.kpi-delta.neutral { color: var(--muted); background: var(--surface-soft); }
.kpi-caption { display: block; margin-top: 8px; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.analysis-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(280px,.75fr); gap: 12px; }
.panel { min-width: 0; padding: 18px; }
.panel-subtitle { margin: 5px 0 11px; color: var(--muted); font-size: 11px; }
.legend { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-base { background: var(--blue); }
.legend-current { background: var(--brand); }
.chart-area { min-height: 292px; }
.chart-area svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 10px; }
.chart-line-base { fill: none; stroke: var(--blue); stroke-width: 2.25; }
.chart-line-current { fill: none; stroke: var(--brand); stroke-width: 2.75; }
.chart-area-current { fill: var(--brand-soft); opacity: .72; }
.chart-point-base { fill: var(--surface); stroke: var(--blue); stroke-width: 2; }
.chart-point-current { fill: var(--surface); stroke: var(--brand); stroke-width: 2.25; }
.chart-value { fill: var(--text); font-size: 10px; font-weight: 650; }
.empty-state { display: grid; min-height: 260px; place-items: center; padding: 30px; color: var(--muted); text-align: center; font-size: 12px; }

.unit-bars { display: grid; gap: 14px; margin-top: 22px; }
.unit-row { display: grid; gap: 6px; }
.unit-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.unit-row-head strong { font-size: 11px; font-weight: 650; }
.unit-row-head span { color: var(--text); font-size: 11px; font-weight: 750; }
.bar-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #42b9ae); }
.bar-fill.selected { background: linear-gradient(90deg, var(--blue), #8ca0d1); }

.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 1080px; border-collapse: collapse; font-size: 11px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { color: var(--muted); background: var(--surface-soft); font-weight: 700; }
td { font-variant-numeric: tabular-nums; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
tbody tr:hover { background: #fbfdfd; }
tbody tr:last-child td { border-bottom: 0; }
.site-footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 25px; color: var(--muted); font-size: 10px; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(9,25,27,.48);
  backdrop-filter: blur(3px);
}
.upload-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 90;
  display: flex;
  width: min(470px, 100%);
  flex-direction: column;
  transform: translateX(102%);
  background: var(--surface);
  box-shadow: -30px 0 70px rgba(8,30,32,.18);
  transition: transform .25s ease;
}
.upload-drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 23px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 23px; }
.drawer-intro { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.drop-zone {
  display: grid;
  min-height: 190px;
  place-items: center;
  align-content: center;
  padding: 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 15px;
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--brand); background: var(--brand-soft); }
.upload-symbol { display: grid; width: 44px; height: 44px; place-items: center; margin-bottom: 10px; border-radius: 13px; color: var(--brand); background: var(--brand-soft); font-size: 24px; }
.drop-zone strong { font-size: 13px; }
.drop-zone small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-help, .import-result { margin-top: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; }
.upload-help h3 { margin: 0 0 5px; font-size: 12px; }
.upload-help p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.upload-help a { display: inline-block; margin-top: 10px; color: var(--brand); font-size: 11px; font-weight: 650; }
.result-summary { color: var(--good); font-size: 12px; font-weight: 650; }
.result-errors { max-height: 170px; margin-top: 10px; overflow-y: auto; color: var(--bad); font-size: 11px; }
.result-errors ul { margin: 7px 0 0; padding-left: 18px; }
.drawer-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 23px; border-top: 1px solid var(--border); }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  max-width: min(370px, calc(100% - 32px));
  padding: 12px 15px;
  border-radius: 11px;
  color: #ffffff;
  background: #153335;
  box-shadow: var(--shadow);
  font-size: 12px;
}

@media (max-width: 1120px) {
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid > .field:first-child { grid-column: 1 / -1; }
  .analysis-grid { grid-template-columns: 1fr; }
  .unit-bars { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 860px) {
  :root { --sidebar-width: 0px; }
  .sidebar { width: 236px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 28px 0 70px rgba(8,30,32,.25); }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: inline-grid; }
  .content { padding-inline: 20px; }
  .topbar { padding-inline: 20px; }
}
@media (max-width: 680px) {
  .hide-mobile, .freshness { display: none; }
  .topbar { min-height: 68px; padding: 11px 15px; }
  .content { padding: 16px 15px 28px; }
  .filter-grid, .date-pair { grid-template-columns: 1fr; }
  .filter-grid > .field:first-child { grid-column: auto; }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .kpi-value { font-size: 19px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .section-heading > p { text-align: left; }
  .unit-bars { grid-template-columns: 1fr; }
  .site-footer { flex-direction: column; }
}
@media (max-width: 430px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar-copy .eyebrow { display: none; }
  .topbar-copy h1 { font-size: 15px; }
  .button { padding-inline: 11px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
