:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1a202c; --muted: #718096;
  --line: #e2e8f0; --blue: #2b6cb0; --blue-d: #234e7d;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.dim { color: var(--muted); }

/* top bar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 10px 20px; position: sticky; top: 0; z-index: 5;
}
.topbar nav a { margin-right: 16px; color: var(--ink); font-weight: 500; }
.topbar nav a.brand { font-weight: 700; }
.topbar .actions { display: flex; align-items: center; gap: 14px; }
.inline { display: inline; margin: 0; }

/* cards & tables */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin-bottom: 18px;
}
.narrow { max-width: 420px; margin: 60px auto; text-align: center; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:hover { background: #f9fafb; }

/* forms */
input, select, button { font: inherit; }
input, select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.filters { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.btn {
  background: var(--blue); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 16px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--blue-d); }

/* tags */
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; text-transform: uppercase; letter-spacing: .03em;
}
.tag-full { background: #e6fffa; color: #234e52; }
.tag-restricted { background: #fffaf0; color: #7b341e; }
.tag-other { background: #edf2f7; color: #4a5568; }
.tag-auto { background: #fff5f5; color: #c53030; }

/* status */
.ok { color: #2f855a; } .no { color: #c53030; }
.flash { background: #e6fffa; border: 1px solid #38b2ac; color: #234e52;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

/* stat blocks */
.stats { display: flex; gap: 22px; flex-wrap: wrap; }
.stats > div { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.stats > div span { font-size: 22px; font-weight: 700; color: var(--ink); }
.stats > div.flag span { color: #c53030; }

/* two-column layout */
.cols { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
@media (max-width: 800px) { .cols { grid-template-columns: 1fr; } }

/* ---- opens matrix ---- */
/* Both-axis scroll container with a capped height so the header row and the
   recipient column both stay frozen while scrolling. */
.scrollx { overflow: auto; max-height: calc(100vh - 230px); padding: 0; }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--line); padding: 6px 8px; }

/* sticky first (recipient) column */
.matrix .sticky-col {
  position: sticky; left: 0; z-index: 2; background: #fff;
  text-align: left; min-width: 200px; max-width: 240px;
  box-shadow: 1px 0 0 var(--line);
}
/* frozen header row (sits above the sticky column) */
.matrix thead th {
  position: sticky; top: 0; z-index: 4; background: #fff;
  box-shadow: 0 1px 0 var(--line);
}
.matrix thead th.corner { z-index: 5; }

/* campaign column headers */
.matrix .vhead { min-width: 92px; max-width: 110px; text-align: center; vertical-align: bottom; line-height: 1.3; }
.matrix .vhead .date { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.matrix .vhead .ctitle {
  display: block; max-width: 104px; margin: 1px auto 2px; font-size: 11px;
  font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; cursor: help;
}
.matrix .num { text-align: right; min-width: 52px; }
.matrix td.total { text-align: right; font-weight: 700; }

/* company group row */
.matrix tr.group th.grouplabel {
  background: #eef2f7; font-size: 13px; font-weight: 700; color: var(--ink);
}
.matrix tr.group .groupfill { background: #eef2f7; }

.matrix .person a { color: var(--ink); font-weight: 500; }

/* cells + heat scale */
.matrix td.cell { text-align: center; font-variant-numeric: tabular-nums; }
.matrix td.ns { color: #cbd5e0; }
.matrix td.heat-0 { color: var(--muted); }
.matrix td.heat-1 { background: #e6f0fb; }
.matrix td.heat-2 { background: #c2daf6; }
.matrix td.heat-3 { background: #8fbdee; }
.matrix td.heat-4 { background: #5b9be0; color: #fff; font-weight: 700; }

.filters select[multiple] { min-width: 280px; }
.checks { display: flex; gap: 12px; padding-top: 4px; }
.chk { flex-direction: row !important; align-items: center; gap: 4px; color: var(--ink);
  text-transform: capitalize; font-size: 13px; cursor: pointer; }
.chk input { width: auto; }
