:root {
  --paper: #F7F4EF;
  --card: #FFFFFF;
  --line: rgba(26,28,27,.09);
  --line-strong: rgba(26,28,27,.18);
  --ink: #1A1C1B;
  --muted: #6B6F69;
  --deep: #2F5D46;
  --green: #4E8F68;
  --sage: #8FBF98;
  --gold: #D9A441;
  --gold-tint: rgba(217,164,65,.14);
  --clay: #C27A5A;
  --slate: #8C9A92;
}
* { box-sizing: border-box; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.4 "Source Sans 3", system-ui, sans-serif;
  min-width: 1200px;
}
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.top {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}
.brand .demo {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--deep);
  background: rgba(47,93,70,.1);
  border-radius: 999px;
  padding: 3px 9px;
}
.search {
  flex: 0 1 420px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}
.top .right {
  margin-left: auto;
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 28px;
  padding: 0 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.tabs a {
  padding: 13px 0 11px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  cursor: pointer;
}
.tabs a.on { color: var(--ink); border-color: var(--gold); }
.tabs a:not(.on):hover { color: var(--ink); }

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  flex-wrap: wrap;
}
.seg {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 5px 14px;
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.seg button.on { background: var(--deep); color: #F7F4EF; }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }
.seg button:not(.on):not(:disabled):hover { color: var(--ink); }
.status {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.status .ok { color: var(--deep); font-weight: 600; }
.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

main { padding: 0 28px 28px; display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.kpi { padding: 16px 20px; }
.kpi .lbl {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.kpi .val {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  font-size: 30px;
  margin: 6px 0 2px;
}
.kpi .sub { color: var(--muted); font-size: 13px; }
.kpi.accent { border-top: 3px solid var(--gold); }
.pos { color: var(--deep); }
.neg { color: var(--clay); }

.chart { padding: 18px 22px 10px; }
.chart-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.chart-head h3 { font: 500 18px Fraunces, Georgia, serif; }
.chart-head .hint { margin-left: auto; color: var(--muted); font-size: 12px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}
svg text { font-family: "Source Sans 3", sans-serif; }
svg .bar-hit { cursor: pointer; }
svg .bar-hit:hover { filter: brightness(0.92); }

table { width: 100%; border-collapse: collapse; }
.tbl { padding: 16px 22px 18px; overflow-x: auto; }
.tbl h3, #topTitle {
  font: 500 18px Fraunces, Georgia, serif;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}
.tbl h3 .btn, .btn {
  margin-left: auto;
  font: 600 12px "Source Sans 3", sans-serif;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 12px;
  color: var(--ink);
  cursor: pointer;
  background: var(--card);
}
.tbl h3 .btn:hover, .btn:hover { border-color: var(--deep); color: var(--deep); }
.panel-sub { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
th, td { padding: 6px 10px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
}
thead th.sel {
  color: var(--ink);
  background: var(--gold-tint);
  border-bottom: 2px solid var(--gold);
}
thead th.month-btn { cursor: pointer; }
thead th.month-btn:hover { color: var(--ink); }
td.month-cell { cursor: pointer; }
td.month-cell:hover { background: rgba(217,164,65,.08); }
td.sel { background: var(--gold-tint); }
tr.grp td {
  padding-top: 14px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--deep);
  border-bottom: 1px solid var(--line);
}
tr.grp td small {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  margin-left: 6px;
}
tr.tot td { font-weight: 700; }
tr.end td { font-weight: 700; border-top: 1px solid var(--line-strong); }
td.lbl { color: var(--muted); padding-left: 22px; }
tr.tot td.lbl, tr.end td.lbl { color: var(--ink); padding-left: 10px; }
tr.row-drill td.lbl {
  cursor: pointer;
  color: var(--deep);
  text-decoration: underline;
  text-decoration-color: rgba(47,93,70,.35);
  text-underline-offset: 2px;
}
tr.row-drill:hover td { background: rgba(217,164,65,.06); }
tr.row-drill td.metric-hit { cursor: pointer; }
.foot { color: var(--muted); font-size: 12px; padding: 0 2px; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(47,93,70,.1);
  color: var(--deep);
}
.badge.plg { background: rgba(78,143,104,.15); }
.badge.slg { background: rgba(140,154,146,.2); color: #3d4741; }

/* Drill overlay */
.drill {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(26,28,27,.38);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px;
  overflow-y: auto;
}
.drill-panel {
  width: min(920px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(26,28,27,.18);
  padding: 22px 24px 18px;
}
.drill-head { margin-bottom: 14px; }
.drill-back {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--deep);
  font: 600 13px "Source Sans 3", sans-serif;
  cursor: pointer;
  padding: 0;
  margin-bottom: 10px;
}
.drill-back:hover { text-decoration: underline; }
.drill-head h3 { font: 500 20px Fraunces, Georgia, serif; }
.drill-body { max-height: min(520px, 60vh); overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.drill-body table { margin: 0; }
.drill-body thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.drill-body tr.total-row td {
  font-weight: 700;
  border-top: 1px solid var(--line-strong);
  background: var(--gold-tint);
}
.drill-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}
.drill-foot .btn { margin-left: 0; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .search { display: none; }
}
