:root {
  /* CLAUDE.md §8 brand palette */
  --cr-navy: #0F4DBC;
  --cr-blue: #00A9E0;
  --cr-green: #92D400;
  --cr-yellow: #FECB00;

  --ink: #0e1726;
  --ink-2: #52627a;
  --ink-3: #8996a8;
  --line: #e5e9f0;
  --bg: #f4f6fb;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(16, 34, 66, .06), 0 4px 16px rgba(16, 34, 66, .05);
  --radius: 12px;
  /* Nudista is the brand typeface; substituted with Inter on web (see §8). */
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1, h2, h3 { margin: 0; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  flex-wrap: wrap;
  padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--cr-navy), var(--cr-blue));
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.25);
}
.brand-title { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.controls { display: flex; gap: 12px; flex-wrap: wrap; }

.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented button {
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-weight: 600; font-size: 13px;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--card); color: var(--cr-navy); box-shadow: var(--shadow); }

.daterange { display: inline-flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; }
.daterange input[type=date] { font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--card); color: var(--ink); }
.daterange .arrow { color: var(--ink-3); }

/* ---- layout ---- */
main { padding: 22px; max-width: 1200px; margin: 0 auto; }
.period-line { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.period-line h1 { font-size: 20px; letter-spacing: -.02em; }
.period-line .muted { color: var(--ink-3); font-size: 13px; }

.grid-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; font-weight: 700; }
.card-body { padding: 6px 4px; }

/* ---- table ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; cursor: pointer; user-select: none; font-weight: 700; }
thead th:hover { color: var(--ink); }
thead th.sorted::after { content: " \25BE"; color: var(--cr-blue); }
thead th.sorted.asc::after { content: " \25B4"; }
tbody tr:hover { background: #f9fbff; }
tbody tr:last-child td { border-bottom: 0; }
.rep-name { font-weight: 600; }
.tag-badge { display: inline-block; font-weight: 700; padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.bar-cell { min-width: 120px; }
.minibar { height: 8px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.minibar > span { display: block; height: 100%; background: var(--cr-blue); }
.pill { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; background: #eef4ff; color: var(--cr-navy); margin-left: 8px; }
.pill.warn { background: #fff6e0; color: #7a5c00; }
.row-muted td { color: var(--ink-3); font-style: italic; }

button.btn { font: inherit; font-weight: 600; font-size: 13px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
button.btn:hover { color: var(--cr-navy); border-color: var(--cr-blue); }
button.btn.ghost { background: transparent; color: var(--ink-3, #6b7280); font-weight: 500; }
button.btn.ghost:hover { color: var(--cr-navy); }

/* ---- funnel ---- */
.funnel { display: flex; gap: 10px; padding: 18px; flex-wrap: wrap; }
.fstage { flex: 1 1 120px; background: var(--bg); border-radius: 10px; padding: 14px; position: relative; }
.fstage .fl { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.fstage .fv { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.fstage .fr { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.fstage.pending { opacity: .55; }
.fstage.pending .fv { color: var(--ink-3); }

/* ---- individual ---- */
.person-pick { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
select { font: inherit; font-weight: 600; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.daychart { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding: 18px; }
.daychart .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.daychart .stack { width: 100%; max-width: 46px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.daychart .seg-d { background: #cfe2ff; border-radius: 5px 5px 0 0; }
.daychart .seg-p { background: var(--cr-blue); }
.daychart .seg-c { background: var(--cr-navy); border-radius: 0 0 5px 5px; }
.daychart .dlabel { font-size: 11px; color: var(--ink-3); }
.legend { display: flex; gap: 16px; padding: 0 18px 16px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---- results / outcome mix ---- */
.mix-legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 18px 4px; font-size: 12px; color: var(--ink-2); }
.mix-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.mix-rowwrap { border-top: 1px solid var(--line); }
.mix-row { display: flex; align-items: center; gap: 12px; padding: 9px 18px 5px; }
.mix-break { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 18px 9px 18px; font-size: 11px; color: var(--ink-3); }
.mix-break .mix-bk i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.mix-name { flex: 0 0 130px; font-weight: 600; font-size: 13px; }
.mix-name .mix-sub { display: block; font-weight: 400; font-size: 11px; color: var(--ink-3); }
.mixbar { flex: 1 1 auto; display: flex; height: 20px; border-radius: 6px; overflow: hidden; background: var(--bg); min-width: 120px; }
.mixbar > span { display: block; height: 100%; }
.mix-rate { flex: 0 0 auto; font-weight: 800; font-size: 15px; letter-spacing: -.01em; width: 52px; text-align: right; }
.mix-rate .mix-rlabel { display: block; font-size: 10px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.mix-untag { flex: 0 0 auto; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }

/* ---- show rates ---- */
.sr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 22px; margin-bottom: 22px; }
.sr-head { display: flex; align-items: baseline; gap: 10px; padding: 16px 18px 6px; }
.sr-rate { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.sr-of { color: var(--ink-2); font-size: 13px; }
.sr-bar { display: flex; height: 12px; border-radius: 7px; overflow: hidden; margin: 10px 18px; background: var(--bg); }
.sr-bar > span { display: block; height: 100%; }
.sr-seg-att { background: var(--cr-green); }
.sr-seg-ns { background: #ef5b5b; }
.sr-seg-can { background: var(--cr-yellow); }
.sr-seg-un { background: #d7deea; }
.sr-key { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 18px 12px; font-size: 12px; color: var(--ink-2); }
.sr-key i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sr-note { padding: 0 18px 14px; color: var(--ink-3); font-size: 12px; }
.sr-conv { display: flex; gap: 22px; flex-wrap: wrap; padding: 12px 18px 4px; border-top: 1px solid var(--line); margin-top: 6px; }
.conv-stat .conv-val { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.conv-stat .conv-lab { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.conv-stat .conv-sub { font-size: 11px; color: var(--ink-3); }

.foot { max-width: 1200px; margin: 0 auto; padding: 8px 22px 40px; color: var(--ink-3); font-size: 12px; line-height: 1.6; }
.foot .note { margin-top: 4px; }
.loading { padding: 60px; text-align: center; color: var(--ink-3); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

@media (max-width: 640px) {
  .kpi .value { font-size: 24px; }
  th, td { padding: 9px 10px; }
}
