:root {
  --brand: #1a5f4a;
  --brand-d: #144a3a;
  --brand-mid: #24856b;
  --accent: #2d9474;
  --accent-l: #e8f5f0;
  --accent-tint: #f3faf7;
  --green: #3d8f76;
  --amber: #c9a227;
  --ink: #1e1e1e;
  --body: #3d3d3d;
  --muted: #7a7570;
  --faint: #9a9590;
  --line: #e8e4df;
  --bg: #f5f3f0;
  --card: #fff;
  --sidebar: var(--brand);
  --sidebar-2: var(--brand-d);
  --shadow: 0 1px 2px rgba(26, 95, 74, 0.04), 0 6px 22px rgba(26, 95, 74, 0.07);
  --shadow-hover: 0 8px 30px rgba(26, 95, 74, 0.12);
  --font: "Source Sans 3", system-ui, sans-serif;
  --display: "Source Sans 3", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--display);
  line-height: 1.15;
  font-weight: 700;
}

a { color: inherit; text-decoration: none; }

.ic {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  fill: currentColor;
}

.ic-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--sidebar);
  color: #e8f5f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sb-head {
  padding: 1.1rem 1.15rem 1rem;
  background: #fff;
  border-bottom: 1px solid rgba(26, 95, 74, 0.08);
}

.sb-logo {
  width: 100%;
  height: auto;
  max-height: 64px;
  object-fit: contain;
  object-position: left center;
  display: block;
}

.sb-lio {
  margin-top: 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-d);
  letter-spacing: 0.01em;
}

.sb-nav { padding: 0.9rem 0.65rem; flex: 1; }

.sb-navlabel {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  padding: 0.55rem 0.7rem 0.65rem;
}

.nav-item {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.65rem 0.7rem;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  border: 1px solid transparent;
  margin-bottom: 0.15rem;
  color: rgba(255, 255, 255, 0.82);
}

.nav-item:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.nav-item.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(201, 162, 39, 0.45);
  color: #fff;
}

.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  transition: 0.18s;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  color: #fff;
  background: var(--accent);
}

.nav-label { font-size: 0.88rem; font-weight: 600; }

.nav-soon {
  margin-left: auto;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.08);
  padding: 0.14rem 0.4rem;
  border-radius: 5px;
}

.sb-foot {
  padding: 1rem 0.85rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sb-links { display: flex; flex-direction: column; gap: 0.4rem; }

.sb-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.86rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  transition: background 0.15s, border-color 0.15s;
}

.sb-link:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}

.sb-link-primary {
  background: #fff;
  color: var(--brand);
  border-color: #fff;
}

.sb-link-primary:hover {
  background: var(--accent-l);
  border-color: var(--accent-l);
  color: var(--brand-d);
}

.sb-credit {
  margin-top: 0.35rem;
  padding: 0.7rem 0.45rem 0.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.68rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.62);
}

.sb-credit-logo {
  height: 40px;
  width: auto;
  display: block;
  flex-shrink: 0;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}

.sb-credit-copy {
  min-width: 0;
}

.sb-credit a {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sb-credit a:hover {
  color: #fff;
}

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(245, 243, 240, 0.9);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.9rem;
}

.tb-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tb-title .tb-icon {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 8px;
  background: var(--accent-l);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.tb-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  min-width: 0;
  max-width: min(420px, 46vw);
}

.tb-count {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.tb-filters {
  font-size: 0.72rem;
  color: var(--brand-mid);
  font-weight: 500;
  line-height: 1.35;
  text-align: right;
}

.tb-filters b { font-weight: 700; color: var(--brand); }

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  font-weight: 600;
  font-size: 0.83rem;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: 0.16s;
}

.btn-teal { background: var(--brand); color: #fff; }
.btn-teal:hover { background: var(--brand-d); }

.btn-ghost {
  background: #fff;
  color: var(--body);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.btn-ghost:hover { border-color: #d5d0c8; }

.fdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.content { padding: 1.7rem 1.9rem 4rem; width: 100%; }

.intro {
  color: var(--muted);
  font-size: 0.96rem;
  margin-bottom: 1.4rem;
  line-height: 1.5;
}

.area-banner {
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--accent-l), #eef8f3);
  border: 1px solid rgba(26, 95, 74, 0.16);
  color: var(--brand-d);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.45;
}

.area-banner--custom {
  background: linear-gradient(90deg, #f4f7fa, #eef2f6);
  border-color: rgba(100, 116, 139, 0.2);
  color: #334155;
  font-weight: 500;
}

.kpi-minibars {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  margin: 0.05rem 0 0.15rem;
}

.kpi-mini {
  display: grid;
  grid-template-columns: 4.2rem 1fr auto;
  align-items: center;
  gap: 0.45rem;
}

.kpi-mini-lbl {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.15;
}

.kpi-mini-track {
  height: 5px;
  background: #eef2f6;
  border-radius: 999px;
  overflow: hidden;
}

.kpi-mini-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  min-width: 0;
}

.kpi-mini.on .kpi-mini-lbl { color: var(--brand-d); }
.kpi-mini.on .kpi-mini-fill {
  background: linear-gradient(90deg, #4fa34c, var(--brand));
}

.kpi-mini-val {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 3.4rem;
  text-align: right;
}

.kpi-mini-unit {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.6rem;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.18s, box-shadow 0.18s;
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.kpi-ic {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-l), #eef6fc);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  margin-bottom: 0.85rem;
}

.kpi-val {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.kpi-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  margin-top: 0.35rem;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.page-footnote {
  font-size: 0.78rem;
  color: var(--muted);
  margin: -0.6rem 0 1.4rem;
  line-height: 1.45;
}

/* Chart grid */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.3rem;
  align-items: start;
}

.block {
  grid-column: span var(--span, 6);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
  overflow: visible;
}

.block:hover { box-shadow: var(--shadow-hover); }

.block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.4rem 0.3rem;
}

.block-title {
  font-weight: 600;
  color: #1e293b;
  font-size: 1.04rem;
}

.block-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.chart-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.chart-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: 0.15s;
}

.chart-btn:hover {
  background: var(--accent-l);
  color: var(--brand);
  border-color: rgba(26, 95, 74, 0.28);
}

.chart-wrap {
  padding: 0.7rem 1.2rem 1.1rem;
  position: relative;
  overflow: visible;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  padding: 0 1.4rem 1.3rem;
  font-size: 0.8rem;
  color: var(--body);
}

.legend > span {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.lg-key {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}

.lg-pct {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: 0.2rem;
  background: var(--accent-l);
  color: var(--brand);
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
  font-size: 0.74rem;
}

.chart-placeholder span:nth-child(1) { height: 42%; }
.chart-placeholder span:nth-child(2) { height: 68%; }
.chart-placeholder span:nth-child(3) { height: 55%; }
.chart-placeholder span:nth-child(4) { height: 82%; }
.chart-placeholder span:nth-child(5) { height: 48%; }
.chart-placeholder span:nth-child(6) { height: 63%; }

.chart-type-pill {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--brand);
  background: var(--accent-l);
  border: 1px solid rgba(26, 95, 74, 0.12);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
}

.chart-placeholder--donut {
  align-items: center;
  justify-content: center;
}

.ph-donut {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background:
    conic-gradient(
      var(--brand) 0 38%,
      var(--brand-mid) 38% 62%,
      var(--accent) 62% 82%,
      #d5e8df 82% 100%
    );
  mask: radial-gradient(circle at center, transparent 42%, #000 43%);
  -webkit-mask: radial-gradient(circle at center, transparent 42%, #000 43%);
  opacity: 0.85;
}

.chart-placeholder--diverging {
  align-items: center;
  justify-content: stretch;
  padding-inline: 1.5rem;
}

.ph-div {
  height: 28px;
  border-radius: 6px;
  opacity: 0.7;
}

.ph-div--neg {
  width: 28%;
  background: #c45c5c;
}

.ph-div--mid {
  width: 18%;
  background: #c9a227;
}

.ph-div--pos {
  width: 42%;
  background: var(--brand-mid);
}

.chart-placeholder--segmented,
.chart-placeholder--grouped {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.65rem;
  padding: 1.4rem 1.3rem;
}

.ph-stack {
  display: flex;
  height: 18px;
  border-radius: 6px;
  overflow: hidden;
  background: #eef2f0;
}

.ph-stack i {
  display: block;
  height: 100%;
}

.ph-stack:nth-child(1) i:nth-child(1) { width: 42%; background: var(--brand); }
.ph-stack:nth-child(1) i:nth-child(2) { width: 33%; background: var(--brand-mid); }
.ph-stack:nth-child(1) i:nth-child(3) { width: 25%; background: var(--accent); }
.ph-stack:nth-child(2) i:nth-child(1) { width: 28%; background: var(--brand); }
.ph-stack:nth-child(2) i:nth-child(2) { width: 40%; background: var(--brand-mid); }
.ph-stack:nth-child(2) i:nth-child(3) { width: 32%; background: var(--accent); }
.ph-stack:nth-child(3) i:nth-child(1) { width: 55%; background: var(--brand); }
.ph-stack:nth-child(3) i:nth-child(2) { width: 20%; background: var(--brand-mid); }
.ph-stack:nth-child(3) i:nth-child(3) { width: 25%; background: var(--accent); }
.ph-stack:nth-child(4) i:nth-child(1) { width: 35%; background: var(--brand); }
.ph-stack:nth-child(4) i:nth-child(2) { width: 35%; background: var(--brand-mid); }
.ph-stack:nth-child(4) i:nth-child(3) { width: 30%; background: var(--accent); }

.empty {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 3.5rem;
  text-align: center;
  color: var(--muted);
  box-shadow: var(--shadow);
}

/* Filter drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 74, 58, 0.42);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  z-index: 80;
}

.drawer-backdrop.show { opacity: 1; visibility: visible; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: 400px;
  max-width: 92vw;
  background: #fff;
  box-shadow: -14px 0 44px rgba(15, 23, 42, 0.16);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 90;
  display: flex;
  flex-direction: column;
}

.drawer.show { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.35rem 1.5rem;
  padding-top: max(1.35rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.drawer-head h3 { font-size: 1.2rem; }

.drawer-x {
  width: 34px;
  height: 34px;
  border: none;
  background: #f1f5f9;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
}

#filter-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  -webkit-overflow-scrolling: touch;
}

.drawer-foot {
  flex-shrink: 0;
  padding: 1rem 1.15rem calc(1.2rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.7rem;
  background: #fff;
}

.drawer-foot .btn {
  flex: 1;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

.fdd {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.fdd[open] {
  border-color: rgba(26, 95, 74, 0.35);
  box-shadow: 0 1px 0 rgba(26, 95, 74, 0.04);
}

.fdd summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.72rem 0.85rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.fdd summary::-webkit-details-marker { display: none; }

.fdd summary::after {
  content: "";
  margin-left: auto;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  transform: rotate(45deg);
  transition: transform 0.18s;
  flex-shrink: 0;
}

.fdd[open] summary::after {
  transform: rotate(-135deg);
  margin-top: 0.2rem;
}

.fdd-title { flex: 1; min-width: 0; }

.fdd-badge {
  display: none;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.fdd-badge.on { display: inline-flex; }

.fdd-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.15rem 0.55rem 0.65rem;
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.fdd-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.42rem 0.4rem;
  border-radius: 8px;
  font-size: 0.84rem;
  color: var(--body);
  cursor: pointer;
  line-height: 1.35;
}

.fdd-opt:hover { background: rgba(26, 95, 74, 0.06); }

.fdd-opt input {
  margin-top: 0.15rem;
  accent-color: var(--brand-mid);
  flex-shrink: 0;
  width: 15px;
  height: 15px;
}

/* Modals */
.fmodal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 74, 58, 0.45);
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.fmodal-mask.show { display: flex; }

.fmodal {
  background: #fff;
  border-radius: 16px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-hover);
  padding: 1.6rem 1.7rem 1.4rem;
}

.fmodal h3 {
  font-size: 1.2rem;
  margin-bottom: 0.55rem;
  color: var(--brand);
}

.fmodal--welcome {
  max-width: 460px;
  padding: 1.85rem 1.8rem 1.55rem;
  border: 1px solid rgba(26, 95, 74, 0.12);
  background: linear-gradient(165deg, #f7fbf9 0%, #fff 42%);
  text-align: left;
}

.fmodal-eyebrow {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-mid);
}

.fmodal--welcome h3 {
  font-size: 1.35rem;
  margin-bottom: 0.7rem;
  color: var(--brand-d);
}

.fmodal--welcome p {
  margin-bottom: 1.4rem;
  font-size: 0.98rem;
  color: var(--body);
  line-height: 1.6;
}

.fmodal--welcome .fmodal-actions {
  justify-content: flex-start;
}

.fmodal p {
  font-size: 0.92rem;
  color: var(--body);
  line-height: 1.55;
  margin-bottom: 1.25rem;
}

.fmodal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

.help-modal { max-width: 560px; padding: 0; overflow: hidden; }

.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f4f7f5, #fff);
}

.help-head h3 { margin: 0; font-size: 1.2rem; color: var(--brand); }

.help-body {
  padding: 1.2rem 1.4rem 1.4rem;
  max-height: min(70vh, 560px);
  overflow-y: auto;
}

.help-body h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 1.1rem 0 0.45rem;
}

.help-body h4:first-child { margin-top: 0; }

.help-body p,
.help-body li {
  font-size: 0.9rem;
  color: var(--body);
  line-height: 1.55;
}

.help-body ul {
  margin: 0.2rem 0 0 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.help-foot {
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

.help-body kbd {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f8faf9;
  color: var(--brand-d);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}

@media (max-width: 1000px) {
  .grid { grid-template-columns: 1fr; }
  .block { grid-column: 1 / -1; }
}

/* Mobile nav toggle */
.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.menu-btn-bars {
  position: relative;
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}
.menu-btn-bars::before,
.menu-btn-bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}
.menu-btn-bars::before { top: -6px; }
.menu-btn-bars::after { top: 6px; }
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  z-index: 85;
}
.nav-backdrop.show { opacity: 1; visibility: visible; }
body.nav-open { overflow: hidden; }
.tb-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 95;
    width: min(300px, 88vw);
    height: 100vh;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 14px 0 40px rgba(15, 23, 42, 0.18);
    flex-direction: column;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar {
    padding: 0.7rem 0.9rem;
    gap: 0.55rem;
    flex-wrap: wrap;
  }
  .tb-title { font-size: 1.05rem; }
  .tb-right {
    width: 100%;
    justify-content: flex-start;
    gap: 0.45rem;
  }
  .tb-meta {
    align-items: flex-start;
    max-width: none;
    flex: 1 1 100%;
    order: -1;
  }
  .tb-filters {
    text-align: left;
    -webkit-line-clamp: 3;
  }
  .btn { padding: 0.5rem 0.7rem; }
  .content { padding: 1.1rem 0.9rem 3rem; }
  .kpis {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .kpi { padding: 1rem; }
  .kpi-val { font-size: 1.55rem; }
  .block-head {
    padding: 1rem 1rem 0.2rem;
    flex-wrap: wrap;
  }
  .chart-wrap { padding: 0.5rem 0.75rem 0.9rem; }
  .legend { padding: 0 1rem 1rem; }
  .drawer { width: 100%; max-width: 100%; }
  .drawer-foot {
    flex-direction: column-reverse;
    gap: 0.55rem;
  }
  .drawer-foot .btn {
    width: 100%;
    flex: none;
  }
  .grid { gap: 1rem; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
}


/* PDF export modal */
.pdf-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.pdf-modal-mask.show { display: flex; }
.pdf-modal {
  background: #fff;
  border-radius: 16px;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-hover);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.pdf-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--line);
}
.pdf-modal-head h3 { font-size: 1.15rem; margin: 0; }
.pdf-modal-body { padding: 1.2rem 1.4rem; overflow-y: auto; }
.pdf-modal-body > p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.pdf-opt-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}
.pdf-opt-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--body);
  cursor: pointer;
}
.pdf-opt-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--brand-mid);
  cursor: pointer;
  flex-shrink: 0;
}
.pdf-custom { display: none; }
.pdf-custom.show { display: block; }
.pdf-page-list {
  max-height: min(42vh, 320px);
  overflow-y: auto;
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.pdf-page-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fafbfc;
}
.pdf-page-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.pdf-page-group-head strong { font-size: 0.88rem; color: var(--ink); }
.pdf-page-group-head button {
  border: none;
  background: none;
  color: var(--brand-mid);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.pdf-page-group-head button:hover { text-decoration: underline; }
.pdf-sublabel {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0.45rem 0 0.15rem;
}
.pdf-modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.pdf-status { font-size: 0.8rem; color: var(--muted); margin-right: auto; }
.btn-amber { background: var(--amber); color: #fff; }
.btn-amber:hover { filter: brightness(0.95); }
.btn-amber:disabled { opacity: 0.65; cursor: wait; }
