:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1a1d21;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #e90029;
  --ok: #17803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --info: #1d4ed8;
}
* { 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;
}
a { color: var(--info); }
header.top {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 24px; display: flex; align-items: center; gap: 24px; height: 82px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit; min-width: 0;
}
.brand-logo { height: 48px; width: auto; display: block; flex: none; }
.brand-co { font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand-co .dot { color: var(--accent); }
.brand-app {
  font-size: 14px; color: var(--muted); white-space: nowrap;
  padding-left: 14px; border-left: 1px solid var(--line);
}
.brand-stacked {
  flex-direction: column; align-items: center; text-align: center;
  gap: 10px; margin-bottom: 26px;
}
.brand-stacked .brand-co { font-size: 17px; }
.brand-stacked .brand-logo { height: 104px; max-width: 100%; }
.brand-stacked .brand-app { padding-left: 0; border-left: 0; font-size: 14px; white-space: normal; }
header.top nav { display: flex; gap: 18px; margin-left: auto; align-items: center; }
header.top nav a { color: var(--ink); text-decoration: none; font-size: 14px; }
header.top nav a:hover { color: var(--accent); }
.whoami { color: var(--muted); font-size: 13px; }
main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 28px 0 12px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 20px; margin-bottom: 20px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; }
.tile.alert .v { color: var(--accent); }
/* The registrations table has 11 columns and will not always fit. It scrolls
   inside its panel rather than being clipped by it. */
.table-panel { padding: 0; }
.table-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-wrap table { min-width: 1020px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: 14px; }
th:last-child, td:last-child { padding-right: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
tbody tr:hover { background: #fafbfc; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th, td { vertical-align: top; }
td.nw, th.nw { white-space: nowrap; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill.SUBMITTED { background: #e6edfd; color: var(--info); }
.pill.APPROVED  { background: #e3f4e9; color: var(--ok); }
.pill.REJECTED  { background: #fde8e8; color: var(--bad); }
.pill.EXPIRED   { background: #eceef1; color: var(--muted); }
.pill.CONFLICT  { background: #fdecd9; color: var(--warn); }
.pill.NONE      { background: #eceef1; color: var(--muted); }
form.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 18px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; color: var(--ink); min-width: 150px;
}
textarea { min-height: 70px; resize: vertical; width: 100%; }
.btn {
  font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
dl.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.flash.err { background: #fde8e8; color: var(--bad); }
.flash.ok  { background: #e3f4e9; color: var(--ok); }
.conflict-box { border: 1px solid #f0c48a; background: #fffaf2; border-radius: 9px; padding: 14px 16px; }
.empty { color: var(--muted); padding: 26px; text-align: center; }
.login-wrap { max-width: 380px; margin: 7vh auto; }
.seed { font-size: 12.5px; color: var(--muted); line-height: 1.8; }
.seed code { background: #eceef1; padding: 1px 5px; border-radius: 4px; }
@media (max-width: 760px) {
  /* The header is a single non-wrapping flex row on desktop; left alone it
     forces the whole page wider than a phone viewport. */
  header.top { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 8px 16px; }
  header.top nav { margin-left: 0; width: 100%; gap: 16px; flex-wrap: wrap; }
  .brand { flex-wrap: wrap; gap: 6px 12px; }
  .brand-logo { height: 38px; }
  .brand-app { padding-left: 0; border-left: 0; width: 100%; white-space: normal; }
  .whoami { width: 100%; order: 3; }
  main { padding: 18px 16px 48px; }
  dl.kv { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .charts { grid-template-columns: 1fr; }
  form.filters label.f, form.filters input, form.filters select { min-width: 0; width: 100%; }
  form.filters { display: grid; grid-template-columns: 1fr 1fr; }
  form.filters .btn { width: 100%; }
  /* SVG type is in viewBox units, so it shrinks with the chart. Step it up
     at narrow widths to keep the rendered size legible. */
  svg.viz .ax-label, svg.viz .seg-label { font-size: 15px; }
  svg.viz .total-label { font-size: 16px; }
}

/* --- charts ------------------------------------------------------------ */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; margin-bottom: 20px; }
.chart { margin-bottom: 0; display: flex; flex-direction: column; }
.chart h2 { margin: 0 0 3px; font-size: 15px; }
.chart-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 14px; padding: 0; font-size: 12.5px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
svg.viz { width: 100%; height: auto; overflow: visible; margin-top: auto; }
svg.viz .ax-label { font-size: 11px; fill: var(--muted); }
svg.viz .seg-label { font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; pointer-events: none; }
svg.viz .total-label { font-size: 12px; font-weight: 650; fill: var(--ink); font-variant-numeric: tabular-nums; }
svg.viz .grid { stroke: var(--line); stroke-width: 1; }
svg.viz .hit { fill: transparent; }
svg.viz [data-tip] { cursor: default; }
svg.viz path[data-tip]:hover { fill-opacity: .82; }
.viz-tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: #1a1d21; color: #fff; font-size: 12.5px; line-height: 1.4;
  padding: 7px 10px; border-radius: 7px; max-width: 260px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.viz-tip[hidden] { display: none; }
.mail-body table { width: auto; }
.mail-body td, .mail-body th { border-bottom: none; padding: 0; }
.mail-body p { margin: 0 0 10px; }

.pager { display: flex; align-items: center; gap: 14px; justify-content: center; padding: 6px 0 4px; }
.pager .btn { text-decoration: none; }
td a[href^="/deal/"], th:first-child { white-space: nowrap; }

/* KPI tiles drill the table down to their slice. */
a.tile { text-decoration: none; color: inherit; display: block; transition: border-color .12s, box-shadow .12s; }
a.tile:hover { border-color: #c3c8d0; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
a.tile:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
a.tile.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
a.tile.on .k { color: var(--accent); }
