:root {
  --bg:      #f3f4f6;
  --surface: #ffffff;
  --surface2:#f9fafb;
  --line:    #d1d5db;
  --line2:   #e5e7eb;
  --text:    #111827;
  --text2:   #6b7280;
  --muted:   #6b7280;
  --border:  #d1d5db;
  --accent:  #2563eb;
  --accent2: #eff6ff;
  --green:   #047857;
  --green2:  #ecfdf5;
  --yellow:  #b45309;
  --yellow2: #fffbeb;
  --red:     #b91c1c;
  --red2:    #fef2f2;
  --orange:  #b45309;
  --shadow:  0 8px 20px rgba(17,24,39,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Hero header ─────────────────────────────────────────────────────────── */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}
.hero-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}
.hero-logo {
  height: 52px;
  width: auto;
  flex-shrink: 0;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}
.hero h1 {
  margin: 6px 0 8px;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -.035em;
}
.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
  line-height: 1.45;
  font-size: 14px;
}
.hero-meta {
  display: inline-block;
  font-weight: 700;
  color: var(--accent);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
main { max-width: 1460px; margin: 0 auto; padding: 28px 32px 48px; }

/* ── Controls ───────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.control-group { display: flex; flex-direction: column; gap: 6px; }

.control-group label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}

select, input[type=text], input[type=number] {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  min-width: 160px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input[type=text]:focus, input[type=number]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ── Rep override select (inside order accordion) ───────────────────────── */
.rep-override-sel {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  min-width: unset;
  cursor: pointer;
  transition: border-color .15s;
}
.rep-override-sel:focus { border-color: var(--accent); outline: none; }
.rep-override-sel.overridden {
  border-color: var(--accent);
  background: rgba(37,99,235,.07);
  color: var(--accent);
  font-weight: 600;
}

/* ── Date range filter ──────────────────────────────────────────────────── */
.range-btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.range-btn {
  padding: 9px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.range-btn:hover { border-color: var(--accent); color: var(--accent); }
.range-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.range-clear-btn { color: var(--red); border-color: #fecdd3; }
.range-clear-btn:hover { background: #fff1f2; border-color: var(--red); color: var(--red); }
.range-custom-row { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.range-custom-row input[type=date] { min-width: 0; padding: 8px 10px; font-size: 13px; }
.range-sep { color: var(--muted); font-size: 12px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 7px;
  border: none;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 6px rgba(17,24,39,.12);
  transition: all .15s;
}
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #1d4ed8; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #035f43; }

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.stat-card .label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card .value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
}

.stat-card .value.green  { color: var(--green); }
.stat-card .value.accent { color: var(--accent); }
.stat-card .value.yellow { color: var(--yellow); }

/* ── Charts ──────────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.chart-card h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 16px;
}

.chart-wrap { position: relative; height: 240px; }
.chart-card-wide { margin-bottom: 28px; }
.chart-wrap-tall { height: 340px; }
.chart-sub {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
}
.chart-help {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text2, #475569);
  margin: -6px 0 14px;
  max-width: 880px;
}
.chart-help b { color: var(--text, #1e293b); font-weight: 700; }

/* ── Tier Movement panel ─────────────────────────────────────────────────── */
.movement-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 28px;
}
.movement-head {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 14px;
}
.movement-note { font-size: 13px; color: var(--muted); padding: 4px 0; }
.movement-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 760px) { .movement-cols { grid-template-columns: 1fr; } }
.movement-col-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.mv-up   { color: var(--green); }
.mv-down { color: var(--red); }
.mover-row {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.mover-row:last-child { border-bottom: none; }
.mover-name {
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mover-name:hover { text-decoration: underline; }
.mover-tiers { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.mover-arrow { font-weight: 700; }
.mover-meta { text-align: right; white-space: nowrap; }
.mover-gp { font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 600; margin-right: 8px; }
.mover-comm { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 700; color: var(--text); }

/* ── Table Wrap ──────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 28px;
}

.table-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
}

.table-head h2 { font-size: 15px; font-weight: 600; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--surface2);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}

.data-table td.name { font-family: 'IBM Plex Sans', sans-serif; font-size: 13px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface2); }
.data-table tfoot td { background: var(--surface2); font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 600; }
.data-table .num { text-align: right; }
.data-table .comm { color: var(--green); font-weight: 600; }

/* ── Tier Badges ──────────────────────────────────────────────────────────── */
.tier-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  font-family: 'IBM Plex Sans', sans-serif;
}

.tier-0 { background: var(--red2); color: var(--red); border: 1px solid #fecaca; }
.tier-1 { background: var(--yellow2); color: var(--yellow); border: 1px solid #fde68a; }
.tier-2 { background: var(--green2); color: var(--green); border: 1px solid #bbf7d0; }
.tier-3 { background: var(--accent2); color: var(--accent); border: 1px solid #bfdbfe; }
.tier-4 { background: #fff7ed; color: #ea580c; border: 1px solid #fed7aa; }
.tier-5 { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }

/* ── GPO Badge ────────────────────────────────────────────────────────────── */
.badge-gpo {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent2);
  color: var(--accent);
  border: 1px solid #bfdbfe;
}

.badge-credit {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--red2);
  color: var(--red);
  border: 1px solid #fecaca;
  letter-spacing: .03em;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
}

tr.credit-row td { color: var(--text2); }
tr.credit-row td.red-val { color: var(--red); font-weight: 600; }
tr.credit-subtotal-row td { border-top: 1px dashed var(--line); }

.badge-return {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--yellow2);
  color: var(--yellow);
  border: 1px solid #fde68a;
  letter-spacing: .03em;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
}

tr.return-detail-row td {
  background: #fffdf5;
  border-top: none;
  padding-top: 2px;
  padding-bottom: 2px;
}

tr.return-subtotal-row td {
  border-top: 1px dashed var(--line);
  font-size: 11px;
  color: var(--text2);
  font-style: italic;
}

.return-inv-link { color: var(--orange); }
.return-inv-link:hover { color: #92400e; }

tr.credit-detail-row td {
  background: #fef9f9;
  border-top: none;
  padding-top: 2px;
  padding-bottom: 2px;
}
tr.credit-detail-row td.red-val { color: var(--red); font-weight: 600; }

/* Unified returns & credit-memo rows shown beneath a customer line.
   Badge colors match the drill-down modal's Returns & Credit Memos section. */
tr.adj-detail-row td {
  background: #fffcf6;
  border-top: none;
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 11px;
}
tr.adj-detail-row td.name { padding-left: 32px; }
.adj-type-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-right: 6px;
  vertical-align: middle;
  white-space: nowrap;
}
.adj-type-return { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.adj-type-credit { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.adj-meta { margin-left: 6px; font-size: 10px; }
.adj-cross-period {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
  cursor: help;
}
td.adj-amt { color: var(--orange); font-weight: 600; white-space: nowrap; }
td.adj-amt-credit { color: var(--red); }

/* Manager-excluded credit memos — still listed on every ledger, but at $0
   commission impact, so they read as struck-through and greyed out. */
.adj-excl-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: #f1f5f9;
  color: var(--text2);
  border: 1px solid var(--line);
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
  cursor: help;
}
.adj-excl-strike { text-decoration: line-through; color: var(--text2); font-weight: 500; }
.adj-excl-zero   { color: var(--text2); font-weight: 800; }
.adj-excl-note   { color: var(--text2); font-size: 10px; margin-top: 2px; font-style: italic; }
td.adj-amt-excluded { color: var(--text2); }
tr.adj-excluded-row td { background: #fafafa; }
tr.adj-excluded-row td.name button { color: var(--text2); }

/* Compact inline row action (Exclude / Count a credit memo). */
.btn-mini {
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-mini:hover { border-color: var(--accent); color: var(--accent); }
.btn-mini-on {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--text);
}
tr.adj-subtotal-row td {
  background: #fffcf6;
  border-top: 1px dashed var(--line);
  font-size: 11px;
  color: var(--text2);
  font-style: italic;
  padding-top: 3px;
  padding-bottom: 4px;
}
tr.adj-subtotal-row td.name { padding-left: 32px; }

/* Returns & Credits validation ledger */
.explainer-card {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}
.explainer-card summary {
  cursor: pointer;
  font-weight: 700;
  color: #1e40af;
  font-size: 12px;
  letter-spacing: .02em;
}
.explainer-list { margin: 10px 0 4px 18px; display: grid; gap: 7px; color: var(--text2); }
.explainer-list li { line-height: 1.45; }
.adj-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.adj-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.adj-controls select, .adj-controls input[type="search"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  background: var(--card, #fff);
}
.adj-controls input[type="search"] { min-width: 240px; }
.adj-cross-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  cursor: pointer;
}

.credit-inv-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.credit-inv-link:hover { color: #1d4ed8; }

/* ── Status / Payout ─────────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.status-badge.paid    { background: var(--green2); color: var(--green); border: 1px solid #bbf7d0; }
.status-badge.pending { background: var(--yellow2); color: var(--yellow); border: 1px solid #fde68a; }

/* ── Flag ────────────────────────────────────────────────────────────────── */
.flag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.flag-green  { background: var(--green2);  color: var(--green);  border: 1px solid #bbf7d0; }
.flag-yellow { background: var(--yellow2); color: var(--yellow); border: 1px solid #fde68a; }
.flag-red    { background: var(--red2);    color: var(--red);    border: 1px solid #fecaca; }
.flag-gray   { background: #f1f5f9;        color: var(--text2);  border: 1px solid var(--line); }
.flag-orange { background: #ffedd5;        color: #9a3412;       border: 1px solid #fed7aa; }
.flag-blue   { background: var(--accent2); color: var(--accent); border: 1px solid #bfdbfe; }

/* Solid red alert dot with a white "!" — the margin-outlier marker next to GM%.
   Reads instantly at small size where a bordered pill just looked like a box. */
.alert-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
  margin-left: 5px;
}
.outlier-item-row:hover td { background: var(--accent2) !important; }

/* ── Pill ─────────────────────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}

/* ── Section Title ───────────────────────────────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ── View Tabs ───────────────────────────────────────────────────────────── */
.view-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin: 4px 0 24px;
  flex-wrap: wrap;
  overflow: auto;
}

.view-tab {
  padding: 10px 16px;
  border-radius: 7px 7px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  color: var(--muted);
  transition: .12s;
  font-family: inherit;
  white-space: nowrap;
}
.view-tab.active { background: var(--surface); color: var(--text); border-color: var(--line); position: relative; top: 1px; }
.view-tab:hover:not(.active) { color: var(--accent); }

/* ── Tier Strip (rep dashboard quick view) ──────────────────────────────── */
.tier-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-bottom: 24px;
  cursor: pointer;
}
.tier-strip:hover { border-color: var(--accent); }
.tier-strip-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.tier-strip-link { color: var(--accent); text-transform: none; letter-spacing: 0; font-weight: 600; }
.tier-strip-segs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.tier-seg {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
}
.tier-seg .ts-rate  { font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 700; }
.tier-seg .ts-range { font-size: 10px; color: var(--muted); margin: 2px 0; white-space: nowrap; }
.tier-seg .ts-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tier-seg .ts-you   { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
/* Rate colors match the tier-badge / doughnut scheme: red, yellow, green, blue, orange, purple */
.tier-seg.t0 .ts-rate { color: var(--red); }
.tier-seg.t1 .ts-rate { color: var(--yellow); }
.tier-seg.t2 .ts-rate { color: var(--green); }
.tier-seg.t3 .ts-rate { color: var(--accent); }
.tier-seg.t4 .ts-rate { color: #ea580c; }
.tier-seg.t5 .ts-rate { color: #6d28d9; }
.tier-seg.current {
  border: 2px solid var(--accent);
  background: var(--accent2);
  padding: 7px 9px;
}
@media (max-width: 700px) {
  .tier-strip-segs { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
}

/* ── Rep Achievements & Streaks 🎉 ───────────────────────────────────────── */
.ach-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 14px 18px 16px;
  margin-bottom: 24px;
}
.ach-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.ach-count {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--accent);
  font-family: 'IBM Plex Mono', monospace;
}
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}
.ach-badge {
  border: 1px solid var(--line2);
  border-radius: 7px;
  padding: 10px 8px;
  text-align: center;
  background: var(--surface2);
}
.ach-badge.earned {
  background: linear-gradient(180deg, #fffbeb, var(--surface));
  border-color: rgba(245, 158, 11, .45);
  box-shadow: 0 4px 10px rgba(245, 158, 11, .12);
}
.ach-badge.earned .ach-icon { animation: ach-pop .45s ease; }
.ach-badge.locked { opacity: .55; filter: grayscale(.85); }
.ach-icon   { font-size: 24px; line-height: 1; }
.ach-label  { font-weight: 700; font-size: 12px; margin-top: 6px; }
.ach-detail { font-size: 10.5px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
@keyframes ach-pop {
  0%   { transform: scale(.4); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.ach-meter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.ach-meter {
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background: var(--line2);
  overflow: hidden;
}
.ach-meter-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
}
.ach-meter-fill.best {
  background: linear-gradient(90deg, #f59e0b, #16a05a, #3b82f6, #7c3aed);
}
.ach-meter-note { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.ach-meter-note.best { color: var(--yellow); }
@media (max-width: 700px) {
  .ach-grid { grid-template-columns: repeat(2, 1fr); }
  .ach-meter-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .ach-meter-note { white-space: normal; text-align: right; }
}
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* ── Beat the House 🎲 ───────────────────────────────────────────────────── */
.bth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 14px 18px 16px;
  margin-bottom: 24px;
}
.bth-panel.winning { border-color: rgba(245, 158, 11, .55); }
.bth-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.bth-row {
  display: grid;
  grid-template-columns: 110px 1fr 175px;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
}
.bth-label { font-weight: 700; font-size: 13px; white-space: nowrap; }
.bth-bar-wrap {
  height: 16px;
  border-radius: 5px;
  background: var(--surface2);
  border: 1px solid var(--line2);
  overflow: hidden;
}
.bth-bar { height: 100%; border-radius: 4px; }
.bth-bar.me    { background: linear-gradient(90deg, var(--accent), #7c3aed); }
.bth-bar.house { background: linear-gradient(90deg, #6b7280, #374151); }
.bth-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.bth-wagm { font-size: 10px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.bth-verdict {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.bth-verdict.win { color: var(--yellow); }
.bth-note { font-size: 13px; color: var(--muted); }
@media (max-width: 700px) {
  .bth-row { grid-template-columns: 84px 1fr; }
  .bth-val { grid-column: 2; text-align: left; }
}

/* ── Tier proximity nudge (data table) ──────────────────────────────────── */
.tier-nudge {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent2);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

/* ── Tier Cards ──────────────────────────────────────────────────────────── */
.tier-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.tier-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.tier-card .tc-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.tier-card .tc-rate  { font-family: 'IBM Plex Mono', monospace; font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.tier-card .tc-range { font-size: 12px; color: var(--muted); }

/* Rate colors match the tier-badge / doughnut scheme: red, yellow, green, blue, orange, purple */
.tier-card.t0 .tc-rate { color: var(--red); }
.tier-card.t1 .tc-rate { color: var(--yellow); }
.tier-card.t2 .tc-rate { color: var(--green); }
.tier-card.t3 .tc-rate { color: var(--accent); }
.tier-card.t4 .tc-rate { color: #ea580c; }
.tier-card.t5 .tc-rate { color: #6d28d9; }

/* ── Calculator ──────────────────────────────────────────────────────────── */
.calc-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 28px;
  max-width: 600px;
}

.calc-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 20px;
}

.calc-fields {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}

.calc-fields .control-group { flex: 1; min-width: 140px; }

.calc-result {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: none;
}
.calc-result.show { display: block; }
.calc-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.calc-row:last-child { border-bottom: none; font-weight: 700; font-size: 16px; }
.calc-row .val { font-family: 'IBM Plex Mono', monospace; }
.calc-row.total .val { color: var(--green); font-size: 22px; }

/* ── Drill panel ──────────────────────────────────────────────────────────── */
.drill-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.drill-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface2);
}

.drill-head h3 { font-size: 14px; font-weight: 700; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  padding: 24px;
}
.modal.show { display: flex; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(480px, 96vw);
  box-shadow: 0 24px 80px rgba(0,0,0,.18);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; line-height: 1; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-body .control-group { width: 100%; }
.modal-body .control-group select,
.modal-body .control-group input { width: 100%; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }

/* ── Back button ──────────────────────────────────────────────────────────── */
.hss-portal-back {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 2147483647;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: #1B3A6B;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 9px 13px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(15,23,42,.22);
  opacity: .92;
}
.hss-portal-back:hover { opacity: 1; filter: brightness(1.06); }

/* ── Empty ────────────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 64px;
  color: var(--muted);
  font-size: 15px;
}

/* ── Rep leaderboard expand rows ─────────────────────────────────────────── */
.rep-row { cursor: pointer; }
.rep-row:hover td { background: var(--surface2); }

.rep-expand-row { display: none; }
.rep-expand-row.open { display: table-row; }

.expand-icon {
  display: inline-block;
  width: 18px;
  font-size: 10px;
  color: var(--muted);
  transition: color .12s;
}
.rep-row:hover .expand-icon { color: var(--accent); }

.expand-cell { padding: 0 !important; border-bottom: 1px solid var(--line) !important; }

.expand-inner {
  padding: 0 16px 12px 42px;
  background: var(--surface2);
  animation: expand-in .15s ease;
}

@keyframes expand-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Sub-table (customer breakdown inside expanded rep rows) ─────────────── */
.sub-table {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}
.sub-table th  { background: #e8ecf4; font-size: 10px; padding: 7px 12px; }
.sub-table td  { font-size: 11px; padding: 7px 12px; }
.sub-table tfoot td { background: #e8ecf4; font-size: 11px; padding: 7px 12px; font-weight: 600; }

/* ── Rank cell ───────────────────────────────────────────────────────────── */
.rank-cell {
  width: 36px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
}

/* ── Muted placeholder ───────────────────────────────────────────────────── */
.muted-val { color: var(--muted); }

/* ── Loading state ───────────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px;
  color: var(--muted);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error card ──────────────────────────────────────────────────────────── */
.error-card {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 12px;
  padding: 32px;
  max-width: 540px;
  margin: 40px auto;
}
.error-title { font-size: 16px; font-weight: 700; color: var(--red); margin-bottom: 8px; }
.error-msg   { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--red); margin-bottom: 12px; word-break: break-all; }
.error-hint  { font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ── Wide modal (line-item drill-down) ───────────────────────────────────── */
.modal-box-wide { width: min(980px, 96vw); }

/* ── Customer drill-down button ──────────────────────────────────────────── */
.cust-drill {
  background: none;
  border: none;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.cust-drill:hover { color: #1d4ed8; text-decoration-style: solid; }

/* ── Cost-source badge ───────────────────────────────────────────────────── */
.src-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: 'IBM Plex Sans', sans-serif;
  white-space: nowrap;
}
.src-gpo     { background: #eff6ff; color: var(--accent); border: 1px solid #bfdbfe; }
.src-primary { background: #f0fdf4; color: #166534;       border: 1px solid #bbf7d0; }

/* ── Extra button variants ───────────────────────────────────────────────── */
.btn-xs { padding: 5px 10px; font-size: 11px; border-radius: 6px; }
.btn-danger { color: var(--red) !important; border-color: #fecdd3 !important; }
.btn-danger:hover { background: #fff1f2 !important; border-color: var(--red) !important; }
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 5px; padding: 1px 5px; font-size: 11px; vertical-align: middle;
  background: none; border: 1px solid var(--line); border-radius: 4px;
  color: var(--text2); cursor: pointer; opacity: 0.55; transition: opacity .15s, color .15s;
}
.copy-btn:hover { opacity: 1; color: var(--accent); border-color: var(--accent); }

/* ── Outlier view ────────────────────────────────────────────────────────── */
.outlier-row.corrected { border-left: 3px solid var(--green); }
.outlier-row.corrected td:first-child { padding-left: 13px; }

.outlier-dev {
  color: var(--yellow);
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  white-space: nowrap;
}

.outlier-filter-bar {
  padding: 0 18px 12px;
}
.outlier-filter-input {
  width: 100%;
  max-width: 420px;
  padding: 8px 12px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.outlier-filter-input:focus {
  outline: none;
  border-color: var(--accent);
}

.outlier-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: -16px;
  margin-bottom: 28px;
  line-height: 1.6;
}

.red-val { color: var(--red); }

/* ── Correction form (inline table row) ──────────────────────────────────── */
.correction-form-row td { padding: 0 !important; border-bottom: 1px solid var(--line) !important; }

.correction-form {
  background: #f8faff;
  border-top: 2px solid var(--accent);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: expand-in .15s ease;
}

.corr-info {
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.corr-info strong { font-weight: 700; }
.corr-info .muted-val { font-size: 11px; font-family: 'IBM Plex Mono', monospace; }

.corr-fields {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.corr-field { display: flex; flex-direction: column; gap: 4px; }

.corr-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.corr-val { font-size: 13px; font-family: 'IBM Plex Mono', monospace; }
.corr-val.mono { font-family: 'IBM Plex Mono', monospace; }

.corr-input {
  width: 130px;
  min-width: 0;
  padding: 7px 10px;
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  outline: none;
}
.corr-input:focus { box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

.corr-actions { display: flex; gap: 8px; }

.corr-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 8px;
}
.corr-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: 5px 12px;
  border-bottom: 2px solid var(--line);
  text-align: left;
}
.corr-table td {
  padding: 7px 12px;
  font-size: 12px;
  border-bottom: 1px solid #eaecf3;
  vertical-align: middle;
}
.corr-table .corr-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  width: 120px;
}
.corr-table .corr-val {
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  width: 180px;
}
.corr-table td:last-child { width: 220px; }
.corr-preview-row td { border-bottom: none; font-style: italic; }
.corr-input-sm   { width: 80px  !important; }
.corr-input-wide { width: 200px !important; }

/* ── Order accordion (line-level modal) ──────────────────────────────────── */
.ord-summary-row { cursor: pointer; }
.ord-summary-row:hover td { background: #eef2fb; }
.ord-summary-row.expanded td { background: #e8edfa; }

.ord-expand-cell {
  width: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  padding-left: 8px !important;
  padding-right: 4px !important;
}

.ord-expand-icon { display: inline-block; transition: color .1s; }
.ord-summary-row:hover .ord-expand-icon { color: var(--accent); }

.ord-lines-expand { display: none; }
.ord-lines-expand.show { display: table-row; }

.ord-detail-cell {
  padding: 0 !important;
  border-bottom: 1px solid var(--line) !important;
}

.ord-detail-inner {
  overflow-x: auto;
  background: var(--surface2);
  animation: expand-in .15s ease;
}

.ord-lines-table { min-width: 900px; }
.ord-lines-table th { background: #dde3f0; font-size: 10px; padding: 7px 12px; }
.ord-lines-table td { font-size: 11px; padding: 7px 12px; background: var(--surface2); }
.ord-lines-table tbody tr:hover td { background: #d5ddf0; }

.ord-line-outlier > td:first-child { border-left: 3px solid var(--red); padding-left: 5px !important; }

/* The exact line pulled from the outlier queue for review — bold + tinted so
   it's obvious which of the invoice's lines is the one being validated. */
.ord-line-flagged > td { background: #fff4d6 !important; font-weight: 700; }
.ord-line-flagged:hover > td { background: #ffeab8 !important; }
.ord-line-flagged > td:first-child { border-left: 3px solid var(--yellow); padding-left: 5px !important; }
.flagged-caret { color: var(--yellow); font-size: 10px; font-weight: 700; }

/* ── Confirm dialog ───────────────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 2000;
}
.confirm-overlay.show { display: flex; animation: fade-in .15s ease; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.confirm-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
  padding: 28px 32px 24px;
  width: 520px; max-width: 95vw;
  animation: modal-in .18s ease;
}
.confirm-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.confirm-body {
  font-size: 13px; color: var(--text); line-height: 1.55;
  margin-bottom: 22px;
}
.confirm-body strong { font-weight: 700; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

.confirm-diff-table {
  width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px;
}
.confirm-diff-table th {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 5px 10px; border-bottom: 2px solid var(--line); text-align: left;
}
.confirm-diff-table td {
  padding: 7px 10px; border-bottom: 1px solid #eaecf3; vertical-align: middle;
}
.confirm-diff-table td:first-child { font-weight: 600; white-space: nowrap; width: 70px; }
.confirm-diff-table td:nth-child(2) { font-family: 'IBM Plex Mono', monospace; color: var(--muted); }
.confirm-diff-table td:last-child   { font-family: 'IBM Plex Mono', monospace; }
.confirm-diff-table tr:last-child td { border-bottom: none; }

/* ── Toast notification ───────────────────────────────────────────────────── */
.hss-toast {
  position: fixed; bottom: 28px; right: 28px;
  padding: 12px 20px;
  border-radius: 9px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 6px 24px rgba(0,0,0,.16);
  transform: translateY(12px); opacity: 0;
  transition: transform .22s ease, opacity .22s ease;
  pointer-events: none; z-index: 3000;
}
.hss-toast.show { transform: translateY(0); opacity: 1; }
.hss-toast-success { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.hss-toast-error   { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }

/* ── Commission statement (handout / printable PDF) ───────────────────────── */
.statement-modal .modal-box { width: min(820px, 96vw); }
.statement-actions { display: flex; gap: 10px; }

.statement-doc {
  background: #fff;
  color: #1a2035;
  padding: 36px 40px;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Statement Banner (inline header above customer table) ───────────────── */
.statement-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #1e3a8a;
  color: #fff;
  border-radius: 8px;
  padding: 14px 20px;
  margin-bottom: 12px;
}
.statement-banner-left { display: flex; flex-direction: column; gap: 3px; }
.statement-banner-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  opacity: .7;
}
.statement-banner-sub {
  font-size: 15px;
  font-weight: 600;
  font-family: 'IBM Plex Sans', sans-serif;
}
.statement-banner-btn {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  box-shadow: none;
  white-space: nowrap;
  font-size: 13px;
  padding: 9px 18px;
  font-weight: 700;
}
.statement-banner-btn:hover {
  background: rgba(255,255,255,.28);
  border-color: rgba(255,255,255,.65);
  color: #fff;
}

.statement-letterhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 3px solid #1e3a8a;
  padding-bottom: 14px;
  margin-bottom: 22px;
}
.statement-co {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 17px;
  font-weight: 600;
  color: #1e3a8a;
  letter-spacing: .02em;
}
.statement-co span { color: #8892aa; font-weight: 400; }
.statement-title { font-size: 14px; font-weight: 600; color: #8892aa; text-transform: uppercase; letter-spacing: .08em; }

.statement-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.statement-meta div { display: flex; flex-direction: column; gap: 3px; }
.statement-meta span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #8892aa; }
.statement-meta strong { font-size: 14px; font-weight: 600; }

.statement-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.statement-stat {
  border: 1px solid #e2e6ee;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.statement-stat span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #8892aa; }
.statement-stat strong { font-size: 17px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; }
.statement-stat.highlight { background: #ecfdf5; border-color: #6ee7b7; }
.statement-stat.highlight strong { color: #16a05a; }

.statement-section { margin-bottom: 26px; }
.statement-section h4 {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 10px; color: #1a2035;
}
.statement-section p { color: #4b5468; margin-bottom: 14px; max-width: 70ch; }

.statement-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.statement-table th {
  text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: #8892aa; padding: 7px 10px; border-bottom: 2px solid #e2e6ee;
}
.statement-table td { padding: 7px 10px; border-bottom: 1px solid #eaecf3; }
.statement-table th.num, .statement-table td.num { text-align: right; font-family: 'IBM Plex Mono', monospace; }
.statement-table tfoot td {
  font-weight: 700; font-family: 'IBM Plex Mono', monospace; border-top: 2px solid #e2e6ee; border-bottom: none;
}
.statement-table tr.statement-tier-hit td { background: #ecfdf5; font-weight: 600; }
.statement-table tr.statement-tier-hit td:first-child { position: relative; }
.statement-tier-hit-mark {
  display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .04em;
  color: #16a05a; background: #dcfce7; border-radius: 4px; padding: 2px 6px; margin-left: 8px;
  text-transform: uppercase; vertical-align: middle;
}

.statement-footer {
  margin-top: 8px; padding-top: 14px; border-top: 1px solid #e2e6ee;
  font-size: 11px; color: #8892aa;
}

/* On screen, the statement renders inside a scrollable modal. When printing,
   hide the entire app shell and let the statement document fill the page so
   the browser's native "Print → Save as PDF" produces a clean, text-based PDF. */
@media print {
  body.hss-printing-statement { background: #fff !important; }
  body.hss-printing-statement > *:not(.statement-modal) { display: none !important; }
  body.hss-printing-statement .statement-modal {
    position: static !important;
    inset: auto !important;
    background: none !important;
    padding: 0 !important;
    display: block !important;
  }
  body.hss-printing-statement .statement-modal .modal-box {
    width: 100% !important;
    max-width: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  body.hss-printing-statement .statement-modal .modal-head,
  body.hss-printing-statement .statement-modal .modal-foot,
  body.hss-printing-statement .statement-modal .modal-close { display: none !important; }
  body.hss-printing-statement .statement-modal .modal-body,
  body.hss-printing-statement .statement-doc { max-height: none !important; overflow: visible !important; padding: 0 !important; }
  .statement-table { break-inside: auto; }
  .statement-table tr { break-inside: avoid; }
  .statement-section { break-inside: avoid; }
}

/* ── Commission breakdown table (gross − adjustments = net) ─────────────── */
/* Detail rows live behind the customer's credits/returns expander. */
tr.adj-detail-row { display: none; }
tr.adj-detail-row.adj-open { display: table-row; }

.adj-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 8px;
  border: 1px solid #fcd34d;
  border-radius: 999px;
  background: #fffbeb;
  color: #92400e;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}
.adj-toggle:hover { background: #fef3c7; border-color: #f59e0b; }
.adj-toggle.open { background: #fef3c7; border-color: #f59e0b; }
.adj-caret { font-size: 9px; }
.adj-toggle-amt { color: #b45309; font-weight: 800; }

.adj-col-amt { color: var(--orange); font-weight: 600; white-space: nowrap; }
td.net-col { font-weight: 700; }

.breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text2);
  border-top: 1px solid var(--line2);
  background: var(--surface2);
}
.breakdown-legend strong { color: var(--text); font-weight: 700; }

/* ── Customer drill-down summary strip (mirrors the breakdown columns) ───── */
.cust-summary-strip {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 20px 18px;
  padding: 14px 18px;
  background: var(--surface2);
  border: 1px solid var(--line2);
  border-radius: 10px;
}
.css-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 96px;
}
.css-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  white-space: nowrap;
}
.css-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.css-val small { font-size: 11px; color: var(--muted); font-weight: 500; }
.css-adj  { color: var(--orange); }
.css-net  { font-weight: 800; }
.css-net-item { padding-right: 6px; }
.css-comm { color: var(--green); font-weight: 800; }
.css-op {
  align-self: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 2px;
}
.css-sep {
  width: 1px;
  background: var(--line);
  margin: 2px 8px;
}

/* ── Roomier tables & modals (less clumped, easier to scan) ──────────────── */
.data-table { font-size: 14px; }
.data-table th { padding: 13px 18px; font-size: 11.5px; }
.data-table td { padding: 14px 18px; font-size: 13.5px; }
.data-table td.name { font-size: 14.5px; }
.data-table tfoot td { font-size: 13.5px; padding: 15px 18px; }
.breakdown-table td { line-height: 1.45; }
.breakdown-table .tier-badge { font-size: 11.5px; padding: 4px 12px; }
.adj-toggle { font-size: 11.5px; padding: 3px 10px; }
tr.adj-detail-row td { padding-top: 9px; padding-bottom: 9px; }
.breakdown-legend { font-size: 13px; padding: 12px 18px; }
.stat-card .value { font-size: 28px; }
.modal-box-wide .data-table td { padding: 12px 14px; }

/* ── Outlier resolution (verify / blank-slate workflow) ─────────────────── */
.btn-verify { color: var(--green); border-color: #bbf7d0; }
.btn-verify:hover { background: var(--green2); border-color: var(--green); color: var(--green); }

/* ── Data-as-of freshness label ──────────────────────────────────────────── */
.data-asof {
  display: inline-block;
  margin-left: 4px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Mobile / small screens ──────────────────────────────────────────────── */
/* The dashboard stays fully functional on phones: controls stack, stat cards
   go two-up, tabs scroll sideways, every table pans horizontally inside its
   wrapper, and modals go full-screen. */
@media (max-width: 768px) {
  main { padding: 16px 12px 96px; }

  .hero { margin-bottom: 12px; }
  .hero-brand { gap: 12px; align-items: flex-start; }
  .hero-logo { height: 38px; }
  .hero h1 { font-size: 22px; }
  .hero p { font-size: 12.5px; }

  /* Controls: one column, full-width inputs */
  .controls { gap: 10px; margin-bottom: 16px; }
  .controls .control-group { width: 100%; }
  .controls select,
  .controls input[type=text] { width: 100%; min-width: 0; }
  .controls .btn { width: 100%; justify-content: center; }
  #export-btn { order: 9; }             /* export drops below the filters */
  .range-btn-row .range-btn { flex: 1; padding: 9px 6px; }

  /* Stat cards: two per row, tighter */
  .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .value { font-size: 20px; }
  .stat-card .label { font-size: 10px; }

  /* Tabs: single scrolling row instead of wrapping into a block */
  .view-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .view-tab { white-space: nowrap; flex-shrink: 0; padding: 9px 12px; font-size: 12px; }

  /* Tables: keep full width and pan sideways; slightly denser cells */
  .table-wrap { border-radius: 8px; }
  .table-wrap > div[style*="overflow-x"], .expand-inner { -webkit-overflow-scrolling: touch; }
  .data-table th { padding: 10px 12px; font-size: 10.5px; }
  .data-table td { padding: 11px 12px; font-size: 12.5px; }
  .data-table td.name { font-size: 13px; }
  .breakdown-table { min-width: 860px; }        /* pan, don't crush */
  .table-head { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
  .table-head h2 { font-size: 15px; }
  .breakdown-legend { font-size: 12px; padding: 10px 14px; }

  /* Tier strip: scroll sideways */
  .tier-strip-segs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tier-seg { min-width: 96px; flex-shrink: 0; }

  /* Modals: full screen so line tables have room */
  .modal-box, .modal-box-wide, .statement-modal .modal-box {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }
  .modal-box #line-modal-body,
  .modal-box .modal-body,
  .modal-box #statement-modal-body { flex: 1; max-height: none !important; overflow-y: auto; }
  .cust-summary-strip { margin: 12px 12px 14px; padding: 12px 14px; gap: 8px; }
  .css-op, .css-sep { display: none; }
  .css-item { min-width: 44%; }
  .css-val { font-size: 14.5px; }

  /* Charts stack (charts-grid already collapses at 900px) with less height */
  .chart-wrap { height: 210px; }
  .chart-card { padding: 14px; }

  /* Header meta wraps under the title cleanly */
  .data-asof { white-space: normal; }
}

@media (max-width: 480px) {
  .hero-logo { display: none; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 17px; }
  .hss-portal-back { padding: 6px 10px; font-size: 12px; }
}
