:root {
  --brand: #0E4C92;
  --accent: #14A38B;
  --ink: #1d2733;
  --ink-2: #4a5768;
  --muted: #7a8696;
  --line: #e3e7ec;
  --bg: #f4f6f9;
  --card: #ffffff;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 360px; display: flex; flex-direction: column; gap: 14px; padding: 32px; }
.login-logo { width: 220px; align-self: center; }
.login h1 { font-size: 18px; margin: 4px 0 0; text-align: center; color: var(--ink-2); font-weight: 600; }
.login label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: var(--ink-2); }
.error { background: #fdecec; color: #a12020; padding: 8px 10px; border-radius: 6px; margin: 0; }

/* ---- shell ---- */
.topbar { height: 60px; background: #fff; border-bottom: 3px solid var(--brand); display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 5; }
.logo { height: 36px; }
.topbar-title { color: var(--ink-2); font-weight: 600; border-left: 1px solid var(--line); padding-left: 16px; }
.signout { margin-left: auto; color: var(--ink-2); text-decoration: none; }
.signout:hover { color: var(--brand); }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 60px); }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .nav-head { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px 6px; }
.sidebar button { all: unset; cursor: pointer; padding: 9px 12px; border-radius: 7px; color: var(--ink-2); }
.sidebar button:hover { background: var(--bg); }
.sidebar button.active { background: color-mix(in srgb, var(--brand) 10%, white); color: var(--brand); font-weight: 600; }
.sidebar button:focus-visible { outline: 2px solid var(--brand); }
.content { padding: 20px 24px 48px; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---- filters ---- */
.filters { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end; padding: 14px 16px; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.grow { flex: 1 1 220px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
input, select { font: inherit; padding: 7px 9px; border: 1px solid #cfd6de; border-radius: 6px; background: #fff; color: var(--ink); min-height: 34px; }
.field.grow select { width: 100%; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, white); border-color: var(--brand); }
.check { display: flex; align-items: center; gap: 6px; color: var(--ink-2); padding-bottom: 8px; }
.actions { display: flex; gap: 8px; margin-left: auto; }
.btn { font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid #cfd6de; background: #fff; color: var(--ink); cursor: pointer; font-weight: 600; }
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---- report ---- */
.empty { padding: 40px; text-align: center; color: var(--muted); }
.report-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.report-head h2 { margin: 0; font-size: 22px; }
.report-head .sub { color: var(--ink-2); }
.report-head .meta { margin-left: auto; color: var(--muted); font-size: 12px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 14px 16px; border-top: 3px solid var(--brand); }
.kpi .label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .pct { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 6px; }
.kpi .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.charts { display: grid; gap: 18px; margin-bottom: 18px; }
.charts.two { grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); }
.chart-card { padding: 16px; min-width: 0; }
.chart-card h3, .table-card h3 { font-size: 15px; margin: 0 0 10px; }
.chart-wrap { position: relative; height: 300px; }

.tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; }
.table-card { padding: 16px; min-width: 0; }
.table-card.wide { grid-column: 1 / -1; }
.table-scroll { overflow: auto; max-height: 620px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--brand); color: #fff; font-weight: 600; font-size: 12px; cursor: pointer; user-select: none; }
th.num, td.num { text-align: right; }
th .arrow { opacity: .7; font-size: 10px; margin-left: 4px; }
tbody tr:nth-child(even) td { background: #f8fafc; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 8%, white); }
tfoot td { font-weight: 700; border-top: 2px solid var(--ink-2); background: #f1f4f8; position: sticky; bottom: 0; }
td.muted { color: var(--muted); }
.row-count { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }

.notes { margin-top: 18px; padding: 12px 16px; color: var(--ink-2); font-size: 12px; }
.notes ul { margin: 4px 0 0; padding-left: 18px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.err { padding: 16px; background: #fdecec; color: #a12020; border-color: #f3c2c2; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .nav-head { display: none; }
  .actions { margin-left: 0; }
}

/* ---- executive summary ---- */
.exec { padding: 18px 20px; margin-bottom: 18px; }
.exec-head { display: flex; align-items: center; gap: 12px; }
.exec-head h3 { margin: 0; font-size: 18px; }
.verdict { font-weight: 700; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #eef1f4; color: var(--ink-2); }
.verdict.good { background: #e3f4ea; color: #1a6b40; }
.verdict.warn { background: #fdf0d9; color: #8a5a0f; }
.verdict.bad  { background: #fbe4e4; color: #a12626; }
.verdict.good::before { content: '▲ '; } .verdict.bad::before { content: '▼ '; } .verdict.warn::before { content: '■ '; }
.exec-headline { color: var(--ink-2); margin: 8px 0 12px; line-height: 1.5; }
.exec-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
.exec-stats div { background: #f6f8fb; border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.exec-stats span { font-size: 11px; color: var(--muted); font-weight: 600; }
.exec-stats strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.exec-body { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 18px; align-items: start; }
.exec-chart { position: relative; height: 230px; }
.exec-lists { display: grid; gap: 10px; }
.exec-list h4 { margin: 0 0 4px; font-size: 13px; }
.exec-list ul { margin: 0; padding-left: 18px; line-height: 1.45; }
.exec-list.good h4 { color: #1a6b40; } .exec-list.bad h4 { color: #a12626; } .exec-list.act h4 { color: var(--brand); }
@media (max-width: 1000px) { .exec-body { grid-template-columns: 1fr; } }

/* ---- engagement tables ---- */
select[multiple] { min-width: 150px; padding: 4px; }
th.nosort { cursor: default; }
tr.row-subtotal td { font-weight: 700; background: #eef3fa !important; }
tr.row-total td { font-weight: 700; background: #dfe8f5 !important; border-top: 1px solid var(--brand); }
tr.row-average td { font-style: italic; background: #f3f6fb !important; border-bottom: 2px solid var(--brand); }
.eye-col { width: 34px; text-align: center; padding: 4px; }
button.eye { all: unset; cursor: pointer; font-size: 16px; line-height: 1; padding: 3px 5px; border-radius: 5px; }
button.eye:hover, button.eye:focus-visible { background: color-mix(in srgb, var(--brand) 12%, white); outline: none; }

[hidden] { display: none !important; }
