:root {
  --ink: #15252b;
  --muted: #65747a;
  --soft-muted: #8a989d;
  --canvas: #f3f6f5;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --line: #dce5e2;
  --line-strong: #c8d6d2;
  --nav: #123c4a;
  --nav-2: #0e303b;
  --teal: #0c7c75;
  --teal-soft: #dff2ef;
  --aqua: #4eb5a7;
  --blue: #4576a6;
  --gold: #c28a38;
  --coral: #c76657;
  --violet: #786ca7;
  --shadow: 0 14px 36px rgba(18, 60, 74, 0.08);
  --radius: 18px;
  --sidebar: 258px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(243, 246, 245, .68), rgba(243, 246, 245, .78)),
    url("../img/menu_bg.png") right bottom / cover fixed no-repeat;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button, select { font: inherit; }
button { color: inherit; }

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--ink);
  background:
    linear-gradient(rgba(255,255,255,.88), rgba(255,255,255,.92)),
    url("../img/menu_bg.png") right bottom / cover no-repeat;
  transition: opacity .25s ease, visibility .25s ease;
}

.loading-screen.hidden { opacity: 0; visibility: hidden; }
.loading-screen p { margin: 0; color: var(--muted); }

.loading-logo, .brand-logo { display: block; object-fit: contain; background: #fff; }
.loading-logo { width: 58px; height: 58px; padding: 4px; border-radius: 14px; box-shadow: 0 10px 24px rgba(18,60,74,.14); animation: breathe 1.4s ease-in-out infinite; }
.loading-mark { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 14px; color: #fff; background: var(--coral); font-size: 28px; font-weight: 800; }
.brand-logo { width: 44px; height: 44px; padding: 3px; border-radius: 12px; box-shadow: 0 6px 16px rgba(5,25,31,.2); }
@keyframes breathe { 50% { transform: scale(1.06); box-shadow: 0 0 0 12px rgba(78,181,167,.12); } }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar);
  flex-direction: column;
  padding: 26px 18px;
  color: #fff;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
}

.brand-lockup, .mobile-brand { display: flex; align-items: center; gap: 12px; }
.brand-lockup { padding: 0 8px 25px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup strong { font-size: 15px; letter-spacing: .01em; }
.brand-lockup span { margin-top: 1px; color: rgba(255,255,255,.58); font-size: 12px; }

.side-nav { display: grid; gap: 7px; margin-top: 25px; }
.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border: 0;
  border-radius: 11px;
  color: rgba(255,255,255,.72);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.nav-item span { min-width: 24px; color: rgba(255,255,255,.36); font-size: 10px; letter-spacing: .12em; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); transform: translateX(2px); }
.nav-item.active { color: #fff; background: rgba(78,181,167,.18); box-shadow: inset 3px 0 0 var(--aqua); }
.nav-item.active span { color: var(--aqua); }

.sidebar-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: auto;
  padding: 15px 12px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 12px;
  background: rgba(255,255,255,.045);
}
.sidebar-note strong, .sidebar-note span { display: block; }
.sidebar-note strong { font-size: 12px; }
.sidebar-note span { margin-top: 2px; color: rgba(255,255,255,.55); font-size: 11px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: #65d1b7; box-shadow: 0 0 0 5px rgba(101,209,183,.1); }

.app-shell { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: flex-end;
  padding: 12px clamp(28px, 4vw, 68px);
  border-bottom: 1px solid rgba(200,214,210,.72);
  background: rgba(243,246,245,.92);
  backdrop-filter: blur(14px);
}
.mobile-brand { display: none; font-weight: 700; }
.topbar-actions { display: flex; gap: 9px; }
.button {
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
.button-primary { color: #fff; background: var(--nav); box-shadow: 0 7px 18px rgba(18,60,74,.16); }
.button-primary:hover { background: #0b303b; }
.button-quiet { border-color: var(--line-strong); background: var(--surface); }
.mobile-filter-button { display: none; }

.main-content { width: min(100%, 1540px); margin: 0 auto; padding: 42px clamp(28px, 4vw, 68px) 68px; }
.page-intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px; align-items: end; }
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.page-intro h1 { max-width: 850px; margin: 0; font-size: clamp(27px, 3vw, 43px); line-height: 1.08; letter-spacing: -.035em; }
.page-intro > div > p:last-child { max-width: 760px; margin: 13px 0 0; color: var(--muted); font-size: 15px; }

.report-meta { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--line); box-shadow: var(--shadow); }
.report-meta div { min-width: 150px; padding: 12px 14px; background: var(--surface); }
.report-meta span, .report-meta strong { display: block; }
.report-meta span { color: var(--soft-muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.report-meta strong { margin-top: 3px; font-size: 12px; }

.filter-panel {
  margin-top: 32px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.78);
  box-shadow: 0 8px 24px rgba(18,60,74,.045);
}
.filter-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.filter-panel-head .eyebrow { display: block; margin: 0 0 3px; }
.filter-panel-head strong { font-size: 13px; }
.text-button { padding: 5px 0; border: 0; color: var(--teal); background: none; cursor: pointer; font-weight: 800; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(145px, 1fr)); gap: 12px; }
.filter-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.filter-grid select {
  width: 100%;
  min-height: 42px;
  padding: 8px 32px 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
}
.filter-grid select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(12,124,117,.1); }
.ward-filter, .theater-filter-details { display: none; }
.theater-filter-details.visible { display: block; margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.theater-filter-details summary { cursor: pointer; color: var(--ink); font-size: 13px; font-weight: 800; }
.theater-filter-details summary span { margin-left: 7px; padding: 3px 7px; border-radius: 999px; color: var(--teal); background: var(--teal-soft); font-size: 10px; }
.theater-filters { grid-template-columns: repeat(4, minmax(145px, 1fr)); margin-top: 14px; }

.dashboard-section { display: none; padding-top: 48px; }
.dashboard-section.active { display: block; animation: enter .25s ease both; }
@keyframes enter { from { opacity: .4; transform: translateY(5px); } }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 24px; }
.section-heading h2 { margin: 0; font-size: clamp(23px, 2.3vw, 31px); line-height: 1.15; letter-spacing: -.025em; }
.section-heading > p { max-width: 550px; margin: 0; color: var(--muted); text-align: right; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.kpi-grid-six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi-card {
  position: relative;
  min-height: 155px;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 9px 26px rgba(18,60,74,.05);
}
.kpi-card::after { content: ""; position: absolute; inset: auto -23px -38px auto; width: 92px; height: 92px; border-radius: 50%; background: var(--kpi-tint, var(--teal-soft)); opacity: .65; }
.kpi-label { position: relative; z-index: 1; display: block; min-height: 34px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; line-height: 1.35; text-transform: uppercase; }
.kpi-value { position: relative; z-index: 1; display: block; margin: 13px 0 7px; font-size: clamp(25px, 2.3vw, 35px); font-weight: 780; letter-spacing: -.04em; line-height: 1; }
.kpi-note { position: relative; z-index: 1; display: block; color: var(--soft-muted); font-size: 11px; line-height: 1.35; }
.kpi-note strong { color: var(--ink); }

.content-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.panel { grid-column: span 4; min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-wide { grid-column: span 8; }
.panel-full { grid-column: 1 / -1; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.panel-heading h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.panel-heading p { margin: 3px 0 0; color: var(--soft-muted); font-size: 11px; }
.chart-wrap { position: relative; width: 100%; height: 285px; min-height: 220px; }
.chart-tall { height: 338px; }
.chart-compact { height: 245px; }
.chart-wrap canvas { max-width: 100%; }

.finding-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.finding-list li { position: relative; padding: 12px 3px 12px 27px; border-bottom: 1px solid var(--line); color: #38484d; }
.finding-list li:last-child { border-bottom: 0; }
.finding-list li::before { content: ""; position: absolute; top: 19px; left: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.finding-list-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
.quality-legend { display: flex; justify-content: center; gap: 20px; color: var(--muted); font-size: 11px; }
.quality-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--legend-color); }

.method-banner, .capacity-banner, .metric-scope-note { margin-top: 18px; padding: 14px 16px; border-radius: 12px; font-size: 12px; }
.method-banner { border: 1px solid #d8d4ed; color: #504979; background: #f4f2fb; }
.capacity-banner { border: 1px solid #e8d5b4; color: #79551e; background: #fcf6ea; font-weight: 700; }
.metric-scope-note { display: none; border: 1px solid var(--line); color: var(--muted); background: var(--surface-soft); }
.metric-scope-note.visible { display: block; }

.table-wrap, .heatmap-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 10px; letter-spacing: .055em; text-align: right; text-transform: uppercase; }
th:first-child, td:first-child { text-align: left; }
td { padding: 11px 12px; border-bottom: 1px solid #e9efed; font-size: 12px; text-align: right; }
.monthly-detail-table th,
.monthly-detail-table td,
.monthly-detail-table th:first-child,
.monthly-detail-table td:first-child { text-align: center; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8faf9; }
.empty-row td { padding: 30px; color: var(--soft-muted); text-align: center !important; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; color: var(--teal); background: var(--teal-soft); font-size: 10px; font-weight: 800; }
.status-pill.warning { color: #8a5c19; background: #fbf0db; }

.heatmap-table { min-width: 850px; table-layout: fixed; }
.heatmap-table th:first-child, .heatmap-table td:first-child { position: sticky; left: 0; z-index: 2; width: 190px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; background: var(--surface); }
.heatmap-table td { padding: 8px 6px; text-align: center; }
.heat-cell { border-radius: 6px; color: #173036; font-size: 10px; font-weight: 800; }

.source-card-list { display: grid; gap: 10px; }
.source-card { padding: 13px; border-left: 3px solid var(--teal); border-radius: 8px; background: var(--surface-soft); }
.source-card strong, .source-card span { display: block; }
.source-card strong { overflow-wrap: anywhere; font-size: 12px; }
.source-card span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.methodology-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.methodology-item { padding: 14px; background: var(--surface-soft); }
.methodology-item strong, .methodology-item span { display: block; }
.methodology-item strong { margin-bottom: 5px; font-size: 12px; }
.methodology-item span { color: var(--muted); font-size: 11px; }
.alias-card { margin-bottom: 10px; padding: 13px; border-radius: 10px; background: var(--surface-soft); }
.alias-card strong, .alias-card span { display: block; }
.alias-card strong { font-size: 12px; }
.alias-card span { margin-top: 4px; color: var(--muted); font-size: 11px; }

.page-footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px clamp(28px, 4vw, 68px) 38px; color: var(--soft-muted); font-size: 11px; }
.mobile-nav { display: none; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(360px, calc(100vw - 32px)); padding: 12px 15px; border-radius: 10px; color: #fff; background: var(--nav); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s ease; }
.toast.visible { opacity: 1; transform: none; }

@media (max-width: 1380px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid.kpi-grid-six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
  :root { --sidebar: 226px; }
  .page-intro { grid-template-columns: 1fr; }
  .report-meta { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .report-meta div { min-width: 0; }
  .filter-grid, .theater-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel, .panel-wide { grid-column: span 6; }
  .panel-full { grid-column: 1 / -1; }
}

@media (max-width: 800px) {
  :root { --sidebar: 0px; --radius: 15px; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .app-shell { margin-left: 0; }
  .topbar { min-height: 58px; justify-content: space-between; padding: 9px 16px; }
  .mobile-brand, .mobile-filter-button { display: flex; }
  .mobile-brand .brand-logo { width: 36px; height: 36px; padding: 2px; border-radius: 10px; }
  .mobile-brand span { font-size: 13px; }
  .button { min-height: 38px; padding: 8px 12px; font-size: 12px; }
  .main-content { padding: 26px 16px 42px; }
  .page-intro h1 { font-size: clamp(27px, 9vw, 36px); }
  .page-intro > div > p:last-child { font-size: 13px; }
  .report-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-meta div { padding: 10px; }
  .filter-panel { display: none; margin-top: 22px; padding: 16px; }
  .filter-panel.open { display: block; animation: enter .2s ease; }
  .filter-panel-head { align-items: flex-start; }
  .filter-grid, .theater-filters { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .section-heading > p { text-align: left; }
  .dashboard-section { padding-top: 32px; }
  .kpi-grid, .kpi-grid-six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-grid.kpi-grid-six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card { min-height: 137px; padding: 15px; }
  .kpi-value { font-size: clamp(24px, 8vw, 31px); }
  .content-grid { gap: 14px; margin-top: 16px; }
  .panel, .panel-wide, .panel-full { grid-column: 1 / -1; padding: 18px; }
  .chart-wrap, .chart-tall { height: 260px; }
  .chart-compact { height: 230px; }
  .finding-list-grid { grid-template-columns: 1fr; }
  .methodology-grid { grid-template-columns: 1fr; }
  .page-footer { flex-direction: column; padding: 20px 16px 16px; }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 7px 5px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(200,214,210,.9);
    background: rgba(255,255,255,.96);
    box-shadow: 0 -8px 25px rgba(18,60,74,.09);
    backdrop-filter: blur(14px);
  }
  .mobile-nav button { display: grid; justify-items: center; gap: 1px; min-width: 0; padding: 3px 1px; border: 0; color: var(--soft-muted); background: none; font-size: 8px; font-weight: 800; cursor: pointer; }
  .mobile-nav button span { font-size: 16px; line-height: 1.2; }
  .mobile-nav button.active { color: var(--teal); }
  .toast { right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .topbar-actions { gap: 5px; }
  .mobile-brand span { display: none; }
  .report-meta { grid-template-columns: 1fr 1fr; }
  .report-meta strong { font-size: 11px; }
  .kpi-card { min-height: 132px; }
  .kpi-label { min-height: 31px; font-size: 9px; }
  .kpi-note { font-size: 9.5px; }
  .panel-heading h3 { font-size: 14px; }
  .mobile-nav button { font-size: 7px; }
}

@media (max-width: 360px) {
  .kpi-grid, .kpi-grid-six { grid-template-columns: 1fr; }
  .kpi-grid.kpi-grid-six { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { padding: 0; color: #000; background: #fff; font-size: 10px; }
  .sidebar, .topbar, .filter-panel, .mobile-nav, .page-footer, .toast, .loading-screen { display: none !important; }
  .app-shell { margin: 0; }
  .main-content { width: 100%; max-width: none; padding: 0; }
  .page-intro { grid-template-columns: 1fr auto; margin-bottom: 8mm; }
  .page-intro h1 { font-size: 22px; }
  .report-meta { box-shadow: none; }
  .dashboard-section { display: none !important; padding-top: 0; }
  .dashboard-section.active { display: block !important; }
  .panel, .kpi-card { break-inside: avoid; box-shadow: none; }
  .chart-wrap, .chart-tall, .chart-compact { height: 240px; min-height: 240px; }
  .section-heading { margin-bottom: 10px; }
  .section-heading h2 { font-size: 19px; }
  .kpi-grid, .kpi-grid-six { grid-template-columns: repeat(3, 1fr); }
  .kpi-card { min-height: 105px; padding: 12px; }
  .kpi-value { margin: 8px 0 4px; font-size: 24px; }
  .content-grid { gap: 8px; }
  .panel { padding: 12px; }
}
