:root {
  --mantis-red: #E30613;
  --mantis-dark-red: #9A1915;
  --mantis-black: #16171A;
  --mantis-grey-900: #1F2023;
  --mantis-grey-700: #4A4B4F;
  --mantis-grey-400: #9A9BA1;
  --mantis-grey-200: #E4E4E6;
  --mantis-grey-100: #F5F5F6;
  --mantis-white: #FFFFFF;
  --mantis-blue: #0E5D80;
  --mantis-light-blue: #5AC3E5;
  --mantis-green: #00A7A6;
  --mantis-purple: #5B4E8D;
  --mantis-amber: #C2760C;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22,23,26,0.06), 0 4px 16px rgba(22,23,26,0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--mantis-grey-100);
  color: var(--mantis-grey-900);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--mantis-white);
  border-bottom: 1px solid var(--mantis-grey-200);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar .brand img { height: 20px; display: block; }

.topbar .brand .divider { width: 1px; height: 20px; background: var(--mantis-grey-200); }

.topbar .brand .product-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--mantis-grey-700);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.topbar nav a {
  font-size: 13px;
  font-weight: 600;
  color: var(--mantis-grey-700);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
}

.topbar nav a:hover { background: var(--mantis-grey-100); }

.topbar nav a.active {
  background: rgba(227,6,19,0.08);
  color: var(--mantis-red);
}

.topbar .status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--mantis-grey-700);
}

.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mantis-green);
}

.status.stale .dot { background: var(--mantis-grey-400); }

.status .source-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--mantis-grey-100);
  color: var(--mantis-grey-700);
}

.status .source-tag.live {
  background: rgba(227,6,19,0.08);
  color: var(--mantis-red);
}

/* Data-synced timestamp + manual "Sync now" button (added 2026-08-10, per
   Courtney: "add time stamp beside the date top right so we know exactly
   when data last synced, also add in a sync button incase i want to update
   it again"). .sync-time shows data_synced_at (the actual wall-clock time
   the underlying Salesforce data was last fetched — distinct from the
   as_of/fy-tag date elsewhere on the page, which is just today's calendar
   date). .sync-btn forces a fresh fetch on click rather than waiting for
   the 90s fetch cache to expire on its own — see clear_fetch_cache() /
   POST /api/sync in the backend. */
.status .sync-time {
  font-size: 11px;
  color: var(--mantis-grey-400);
  white-space: nowrap;
}

.status .sync-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--mantis-grey-700);
  background: var(--mantis-white);
  border: 1px solid var(--mantis-grey-200);
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.4;
}

.status .sync-btn:hover { background: var(--mantis-grey-100); }

.status .sync-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.page-header .subtitle {
  font-size: 13px;
  color: var(--mantis-grey-700);
  margin-top: 4px;
}

.fy-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--mantis-grey-700);
  background: var(--mantis-white);
  border: 1px solid var(--mantis-grey-200);
  padding: 4px 10px;
  border-radius: 999px;
}

.fy-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.scenario-select {
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--mantis-grey-700);
  background: var(--mantis-white);
  border: 1px solid var(--mantis-grey-200);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

/* Section grouping (added 2026-07-31, per Courtney — elevate the look and
   feel of Closed Business, mockup approved). Breaks the page into labelled
   groups (Performance vs target / Revenue mix / Breakdowns / Partner
   contribution) instead of one long stack of visually identical cards. */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mantis-grey-400);
  margin: 32px 0 10px 0;
}
.section-label:first-child { margin-top: 0; }

.headline-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* Pipeline & Forecasting has a 5th headline card (Open Opportunities, added
   2026-07-31, per Courtney) — scoped to its own modifier class rather than
   changing .headline-grid's default 4 columns, since Executive/Closed
   Business/Marketing all still use exactly 4. */
.headline-grid-5 {
  grid-template-columns: repeat(5, 1fr);
}

.card {
  background: var(--mantis-white);
  border-radius: var(--radius);
  border: 1px solid var(--mantis-grey-200);
  box-shadow: var(--shadow);
  padding: 20px;
}

.metric-label {
  font-size: 12px;
  color: var(--mantis-grey-700);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.metric-sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--mantis-grey-700);
}

.metric-sub .delta.positive { color: var(--mantis-green); font-weight: 600; }
.metric-sub .delta.negative { color: var(--mantis-red); font-weight: 600; }

.two-col {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  align-items: start;
}

/* Revenue mix row (added 2026-07-31, per Courtney, iterated three times):
   Regional Contribution and Customer Type stack on top of each other in a
   narrower left column; Telematics Provider Contribution sits beside them
   as one tall card spanning both rows on the right — "i still want
   Telematics Provider Contribution beside it" after asking for the other
   two to stack rather than sit in a 3-up row. Source order matters here:
   Regional Contribution first, Telematics Provider Contribution second
   with .telematics-cell (grid-row: span 2), Customer Type third — grid
   auto-placement then fills left-col/row1, right-col/rows1-2, left-col/row2
   in that order. */
.revenue-mix-grid {
  display: grid;
  /* Widened 2026-07-31, per Courtney: "can you make it wider" (Regional
     Contribution / Customer Type's column) — was 0.9fr, narrower than Lead
     Source's 1fr; now wider than it. */
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.revenue-mix-grid .telematics-cell { grid-row: span 2; }

.card h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 16px 0;
}

.region-row {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--mantis-grey-100);
  font-size: 13px;
}

.region-row:last-child { border-bottom: none; }

.region-name { font-weight: 600; }

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--mantis-grey-100);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  /* FIXED 2026-07-31, per Courtney's brand guidelines review — was Mantis
     Red, which the 2026 guidelines rule out as a chart fill ("never a fill,
     never a large area"). Shared class (Telematics Provider Contribution,
     Partner Contribution, Marketing, Pipeline & Forecasting, Executive all
     use it), so this is an app-wide fix, not just Closed Business. */
  background: var(--mantis-blue);
}

.region-figure { text-align: right; font-variant-numeric: tabular-nums; color: var(--mantis-grey-700); }

/* Regional Contribution split bar (added 2026-07-31, per Courtney) — a
   single continuous bar divided proportionally between regions, replacing
   the old two-separate-bars-vs-target layout. Widths are set inline per
   segment since they're computed from live data (percentage share of the
   selected metric), not fixed CSS. */
.region-split-row {
  display: flex;
  width: 100%;
}

.region-split-bar {
  display: flex;
  width: 100%;
  /* Enlarged 2026-07-31, per Courtney: "the two boxes on the left i want to
     extend the size" (Regional Contribution + Customer Type, which both use
     this same split-bar markup) — was 36px/8px radius, went to 56px, then
     dialled back slightly per "reduce height slightly". */
  height: 46px;
  border-radius: 9px;
  overflow: hidden;
}

.opp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.opp-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--mantis-grey-700);
  padding: 8px 6px;
  border-bottom: 1px solid var(--mantis-grey-200);
}
.opp-table td { padding: 10px 6px; border-bottom: 1px solid var(--mantis-grey-100); }
.opp-table tr:last-child td { border-bottom: none; }
.opp-table .amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.stage-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--mantis-grey-100);
  color: var(--mantis-grey-700);
}
.stage-pill.commit, .stage-pill.negotiation-review { background: rgba(227,6,19,0.08); color: var(--mantis-red); }
.stage-pill.best-case { background: rgba(14,93,128,0.1); color: var(--mantis-blue); }
.stage-pill.pipeline, .stage-pill.qualification, .stage-pill.proposal-price-quote { background: rgba(0,167,166,0.1); color: var(--mantis-green); }

.notes {
  margin-top: 24px;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px dashed var(--mantis-grey-200);
  background: var(--mantis-white);
  font-size: 12px;
  color: var(--mantis-grey-700);
}
.notes h3 { font-size: 12px; margin: 0 0 8px 0; text-transform: uppercase; letter-spacing: 0.03em; }
.notes ul { margin: 0; padding-left: 18px; }
.notes li { margin-bottom: 4px; }

.funnel {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.funnel-stage {
  flex: 1;
  text-align: center;
  padding: 16px 12px;
  border-radius: var(--radius);
  background: var(--mantis-grey-100);
}

.funnel-stage .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.funnel-stage .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--mantis-grey-700); margin-top: 4px; }
.funnel-arrow { align-self: center; color: var(--mantis-grey-400); font-size: 18px; }

/* Click-to-drill-down on the funnel stages (added 2026-08-10, per Courtney:
   "can we also make these accessible by clicking on them?") — cursor +
   hover feedback only; the drill-down modal itself is marketingDetailModal,
   already styled elsewhere. */
.funnel-stage.clickable { cursor: pointer; transition: background 0.1s; }
.funnel-stage.clickable:hover { background: var(--mantis-grey-200); }

.small-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.small-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--mantis-grey-700);
  padding: 6px;
  border-bottom: 1px solid var(--mantis-grey-200);
}
.small-table td { padding: 8px 6px; border-bottom: 1px solid var(--mantis-grey-100); }
.small-table tr:last-child td { border-bottom: none; }
.small-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Sortable column headers (partner target table, added 2026-07-28) */
.small-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.small-table th.sortable:hover { color: var(--mantis-grey-900); }

/* % of Target colour bands (added 2026-07-28, per Courtney):
   <33% red, 33-66% orange, 67%+ green. */
.pct-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.pct-pill.pct-red { background: rgba(227, 6, 19, 0.12); color: var(--mantis-red); }
.pct-pill.pct-orange { background: rgba(194, 118, 12, 0.14); color: var(--mantis-amber); }
.pct-pill.pct-green { background: rgba(0, 167, 166, 0.14); color: var(--mantis-green); }
.pct-pill.pct-none { background: var(--mantis-grey-100); color: var(--mantis-grey-700); }

/* Headline card colour bands (added 2026-07-31, per Courtney, mockup
   approved) — thin progress bar under the four Closed Business headline
   cards, same red/orange/green palette as .pct-pill above but its own
   <40/40-74/75+ thresholds (see headlinePctBand() in closed-business.js). */
.headline-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--mantis-grey-100);
  overflow: hidden;
  margin-top: 10px;
}
.headline-bar-fill { height: 100%; border-radius: 999px; }
.headline-bar-fill.headline-bar-red { background: var(--mantis-red); }
.headline-bar-fill.headline-bar-orange { background: var(--mantis-amber); }
.headline-bar-fill.headline-bar-green { background: var(--mantis-green); }

/* Donut breakdown widgets (added 2026-07-28, per Courtney): Lead Source,
   Core vs Pro, Dash Cam vs DVR, Vehicle Type. Pure CSS conic-gradient, no
   charting library. */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.donut::after {
  content: "";
  position: absolute;
  top: 22px;
  left: 22px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--mantis-white);
}

/* 4-up equal-height breakdown grid (added 2026-07-31, per Courtney: mockup
   approved to "elevate the look and feel" — was two separate 2-up rows,
   which let card heights drift depending on how much subtitle/footer text
   each donut carried. A single 4-column grid gives every card the same
   height (grid default align-items: stretch), and the donut itself shrinks
   slightly so it still fits comfortably at quarter-width. */
.donut-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.donut-grid-4 .card { display: flex; flex-direction: column; }
.donut-grid-4 .donut-wrap { flex-direction: column; text-align: center; gap: 12px; }
.donut-grid-4 .donut { width: 88px; height: 88px; margin: 0 auto; }
.donut-grid-4 .donut::after { top: 17px; left: 17px; width: 54px; height: 54px; }
.donut-grid-4 .donut-legend { width: 100%; }
@media (max-width: 960px) {
  .donut-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.donut-legend { flex: 1; min-width: 0; }
.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 5px 0;
}
.donut-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.donut-label { flex: 1; font-weight: 600; }
.donut-value { color: var(--mantis-grey-700); font-variant-numeric: tabular-nums; white-space: nowrap; }
.donut-pct { color: var(--mantis-grey-400); }

/* Customer Type — Records vs Subscriptions (added 2026-07-28, per Courtney).
   RESTYLED 2026-07-31 twice, per Courtney: first "styled like the first"
   (thick on-brand bar, no red), then "can we do it as 1 bar" — now one
   continuous proportional split bar, reusing .region-split-row /
   .region-split-bar (defined above, next to Regional Contribution) rather
   than a dedicated dual-bar-* set of classes. See
   renderCustomerTypeSplitBar() in closed-business.js. */

.loading, .error {
  padding: 60px 0;
  text-align: center;
  color: var(--mantis-grey-700);
  font-size: 13px;
}

/* Settings screen — Salesforce credentials form (added 2026-07-28, per
   Courtney: a local, in-app place to save production Salesforce credentials
   once, masked, instead of hand-editing backend/.env in a terminal). */
.settings-row {
  margin-bottom: 14px;
}
.settings-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--mantis-grey-700);
  margin-bottom: 6px;
}
.settings-row input,
.settings-row select {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 13px;
  padding: 9px 10px;
  border: 1px solid var(--mantis-grey-200);
  border-radius: 6px;
  background: var(--mantis-white);
  color: var(--mantis-grey-900);
}
#sfSettingsForm button[type="submit"] {
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: var(--mantis-red);
  color: #fff;
}
#sfSettingsForm button[type="submit"]:disabled {
  background: var(--mantis-grey-400);
  cursor: default;
}
.conn-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  margin-right: 8px;
}
.conn-badge.connected { background: rgba(0, 167, 166, 0.14); color: var(--mantis-green); }
.conn-badge.error { background: rgba(227, 6, 19, 0.12); color: var(--mantis-red); }
.conn-badge.unconfigured { background: var(--mantis-grey-100); color: var(--mantis-grey-700); }

@media (max-width: 960px) {
  .headline-grid, .headline-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .two-col, .revenue-mix-grid { grid-template-columns: 1fr; }
  .revenue-mix-grid .telematics-cell { grid-row: auto; }
}

/* Partner drill-down (added 2026-07-28, per Courtney): clickable partner
   name on the target table, plus the modal that opens with every customer
   who signed with that partner in the current period. */
.partner-link, .detail-link {
  color: var(--mantis-blue);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}
.partner-link:hover, .detail-link:hover {
  text-decoration-color: var(--mantis-blue);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 23, 26, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-card {
  background: var(--mantis-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--mantis-grey-200);
}
.modal-header h2 {
  margin: 0;
  font-size: 16px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--mantis-grey-700);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover {
  color: var(--mantis-grey-900);
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}

/* Pipeline & Forecasting brand refresh (added 2026-08-03, per Courtney: mockup
   approved, "happy with this so far - the styling looks a little boring could
   you do a mock up using our brand guidelines"). Scoped entirely to
   body.page-pipeline (only pipeline-forecast.html carries that class) so
   Executive/Closed Business/Marketing/Settings are untouched — none of the
   base .page-header/.headline-grid/.card rules above are edited, only
   overridden here.

   The topbar is deliberately left alone: mantis-full-colour.svg's wordmark is
   near-black (#231f20) with no reversed/white variant shipped to this app, so
   it would disappear against a dark topbar. A white wordmark asset would be
   needed before the topbar itself can go dark. */

body.page-pipeline .page-header {
  background: var(--mantis-black);
  border-radius: var(--radius);
  padding: 20px 24px 22px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
body.page-pipeline .page-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--mantis-red);
}
body.page-pipeline .page-header h1 { color: var(--mantis-white); }
body.page-pipeline .page-header .subtitle { color: var(--mantis-grey-400); }
body.page-pipeline .fy-header-controls .scenario-select {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
  color: var(--mantis-white);
}
body.page-pipeline .fy-header-controls .scenario-select:hover {
  background: rgba(255,255,255,0.14);
}
body.page-pipeline .fy-header-controls input.scenario-select {
  color-scheme: dark;
}

/* Headline cards: was 5 separately-bordered/shadowed cards with 16px gaps —
   now one edge-to-edge hairline grid (gap collapses to the shared border),
   with a coloured top-edge on the three forecast-category cards so the row
   reads at a glance without repeating the category name. Open Pipeline/Open
   Opportunities stay neutral since they aren't a forecast-category slice. */
body.page-pipeline .headline-grid-5 {
  gap: 1px;
  background: var(--mantis-grey-200);
  border: 1px solid var(--mantis-grey-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
body.page-pipeline .headline-grid-5 .card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  border-top: 3px solid transparent;
}
body.page-pipeline .headline-grid-5 .card.accent-commit { border-top-color: var(--mantis-blue); }
body.page-pipeline .headline-grid-5 .card.accent-bestcase { border-top-color: var(--mantis-green); }
body.page-pipeline .headline-grid-5 .card.accent-stale { border-top-color: var(--mantis-red); }

/* Tightened vertical rhythm — closes up the dead space this page had
   accumulated (a 32px section gap plus a 16px card gap stacked on top of each
   other reads as an empty band, not a deliberate break). */
body.page-pipeline .section-label { margin: 24px 0 10px 0; }
body.page-pipeline .two-col,
body.page-pipeline .donut-grid-4 { margin-top: 0; }

/* Fix for the "still spaces" gap (added 2026-08-03, per Courtney, after
   reordering the two-col rows didn't fix it) — the base .two-col rule sets
   align-items: start, so when one side's card is taller than the other
   (e.g. Stage Distribution+Ageing stacked in one card vs a 5-row Top Open
   Opportunities table), the shorter card just stops early and leaves bare
   page background beside the taller one instead of filling the row. Grid's
   default align-items is stretch — this just removes the override, scoped
   to this page only, so both cards in a row always match height. */
body.page-pipeline .two-col { align-items: stretch; }
body.page-pipeline .two-col .card { display: flex; flex-direction: column; }

/* Login page (rebuilt 2026-08-11, v4, from the approved "MANTIS Revenue
   Intelligence Login" handover package — the "Controlled Intelligence"
   style: Muller + Bebas Neue, carbon/red tokens, exact copy). This is a
   direct port of that package's login.css onto this app's actual markup
   (login.html), scoped entirely under .login-shell so it can't leak into
   or be affected by the rest of this stylesheet — the handover's own
   approach (a local custom-property scope on .login-shell, not global
   :root overrides), which matters here because its red (#ED1C24) and
   near-black (#231F20/#111010) are NOT the same tokens as this file's own
   --mantis-red (#E30613) etc. used everywhere else in the app. That's a
   real, deliberate difference for this one screen, confirmed via the
   handover's explicit design-token table — not a mismatch to "fix" by
   reusing the global variables.

   #loginHeading and #loginSub keep their ids from the original build but
   nothing in login.js reads their text — confirmed by grep — so both are
   freely restyled/repositioned here. */

@font-face {
  font-family: "Muller";
  src: url("assets/fonts/muller-medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Muller";
  src: url("assets/fonts/muller-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Bebas Neue";
  src: url("assets/fonts/bebas-neue.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.login-shell {
  --login-red: #ed1c24;
  --login-red-dark: #c81018;
  --login-carbon: #231f20;
  --login-carbon-deep: #111010;
  --login-ink: #191718;
  --login-muted: #686366;
  --login-line: #dedbdc;
  --login-surface: #f4f3f3;
  --login-white: #ffffff;
  background: var(--login-surface);
  color: var(--login-ink);
  font-family: "Muller", Arial, Helvetica, sans-serif;
  font-weight: 500;
}

.login-shell,
.login-shell * {
  box-sizing: border-box;
}

.login-shell button,
.login-shell input {
  font: inherit;
}

.login-shell button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(480px, 0.88fr);
  overflow: hidden;
}

.brand-stage {
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: clamp(30px, 4vw, 62px) clamp(34px, 5.2vw, 86px) 34px;
  color: var(--login-white);
  background: var(--login-carbon-deep);
  isolation: isolate;
}

.brand-stage::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -230px;
  top: 22%;
  border: 1px solid rgba(237, 28, 36, 0.32);
  border-radius: 50%;
  box-shadow: 0 0 0 82px rgba(237, 28, 36, 0.025), 0 0 0 164px rgba(237, 28, 36, 0.018);
  z-index: -1;
}

.brand-stage::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 112px;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--login-red);
}

.stage-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.055);
  z-index: -1;
}

.stage-line-one { left: 9%; top: 0; width: 1px; height: 100%; }
.stage-line-two { left: 68%; top: 0; width: 1px; height: 100%; }
.stage-line-three { left: 0; top: 72%; width: 100%; height: 1px; }

.brand-header,
.login-topbar,
.brand-footer,
.login-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: block;
  width: clamp(176px, 15vw, 238px);
  height: auto;
}

.internal-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--login-red);
  box-shadow: 0 0 0 5px rgba(237, 28, 36, 0.12);
}

.brand-content {
  width: min(100%, 730px);
  margin: auto 0;
  padding: 42px 0 26px;
}

.eyebrow,
.login-kicker {
  margin: 0 0 20px;
  color: var(--login-red);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.brand-content h1 {
  margin: 0;
  max-width: 660px;
  font-family: "Bebas Neue", "Muller", sans-serif;
  font-size: clamp(58px, 6.8vw, 108px);
  font-weight: 400;
  line-height: 0.89;
  letter-spacing: 0.015em;
  text-transform: uppercase;
}

.brand-content h1 span {
  display: block;
  color: var(--login-red);
}

.brand-intro {
  max-width: 570px;
  margin: 28px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: clamp(16px, 1.35vw, 20px);
  line-height: 1.65;
}

.momentum-panel {
  margin-top: clamp(30px, 4.5vh, 52px);
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 20px 0 22px;
}

.momentum-topline {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: rgba(255, 255, 255, 0.46);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.live-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, 0.67);
}

.live-label > span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #48b982;
}

.pipeline-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 21px 0 24px;
}

.pipeline-track::before,
.pipeline-track::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  height: 1px;
}

.pipeline-track::before { background: rgba(255, 255, 255, 0.14); }
.pipeline-track::after { right: 23%; background: var(--login-red); }

.pipeline-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 10px;
  text-transform: uppercase;
}

.pipeline-stage:last-child { align-items: flex-end; }

.stage-node {
  width: 11px;
  height: 11px;
  border: 2px solid #4a4647;
  border-radius: 50%;
  background: var(--login-carbon-deep);
  display: block;
}

.stage-node.active {
  border-color: var(--login-red);
  background: var(--login-red);
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.insight-strip > div {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.insight-strip p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  line-height: 1.35;
}

.insight-number {
  color: var(--login-red);
  font-family: "Bebas Neue", sans-serif;
  font-size: 24px;
  line-height: 1;
}

.brand-footer {
  justify-content: flex-start;
  gap: 16px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.footer-rule {
  width: 28px;
  height: 1px;
  background: var(--login-red);
}

.login-stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 32px clamp(34px, 4.4vw, 72px) 24px;
  background: var(--login-surface);
}

.login-topbar,
.login-footer {
  color: #878184;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.secure-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #4e494b;
}

.lock-mark {
  color: var(--login-red);
  font-size: 7px;
}

.login-wrap {
  width: min(100%, 480px);
  margin: auto;
  padding: 24px 0;
}

.mobile-logo-wrap { display: none; }

.login-card {
  padding: clamp(32px, 3.1vw, 42px);
  border: 1px solid #e3e0e1;
  border-top: 4px solid var(--login-red);
  background: var(--login-white);
  box-shadow: 0 20px 55px rgba(35, 31, 32, 0.08);
  animation: login-card-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes login-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-kicker { margin-bottom: 15px; font-size: 10px; }

.login-card h2 {
  margin: 0;
  color: var(--login-carbon);
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.login-copy {
  margin: 14px 0 24px;
  color: var(--login-muted);
  font-size: 14px;
  line-height: 1.6;
}

.field-group { margin-top: 16px; }

.field-group label,
.label-row {
  color: #3b3739;
  font-size: 12px;
  font-weight: 700;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-button,
.support-copy a {
  padding: 0;
  border: 0;
  color: #777174;
  background: transparent;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.field-group input {
  width: 100%;
  height: 48px;
  margin-top: 9px;
  padding: 0 15px;
  border: 1px solid #d7d3d4;
  border-radius: 2px;
  outline: none;
  background: #fff;
  color: var(--login-ink);
  font-size: 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-group input::placeholder { color: #aaa5a7; }

.field-group input:focus {
  border-color: var(--login-red);
  box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.1);
}

.password-field { position: relative; }
.password-field input { padding-right: 62px; }

.show-password {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-31%);
  border: 0;
  background: transparent;
  color: #6b6668;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 15px 0 19px;
  color: #6b6668;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
}

.remember-row input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--login-red);
  cursor: pointer;
}

.login-button,
.magic-link-button {
  width: 100%;
  min-height: 48px;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.login-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border: 1px solid var(--login-red);
  background: var(--login-red);
  color: var(--login-white);
}

.login-button:hover:not(:disabled) {
  border-color: var(--login-red-dark);
  background: var(--login-red-dark);
  transform: translateY(-1px);
}
.login-button:disabled { opacity: 0.7; cursor: default; transform: none; }

.button-arrow { font-size: 19px; font-weight: 500; }

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: #aaa5a7;
}

.divider span { height: 1px; background: #e5e2e3; }
.divider p { margin: 0; font-size: 10px; text-transform: uppercase; }

.magic-link-button {
  border: 1px solid #cfcacc;
  background: #fff;
  color: #393537;
}

.magic-link-button:hover:not(:disabled) { border-color: var(--login-carbon); background: #faf9f9; }
.magic-link-button:disabled { opacity: 0.7; cursor: default; }

/* .form-message is always present (reserves layout space + gives assistive
   tech a stable live region) but visually invisible until a real message
   sets .is-visible — same pattern as the approved handover. is-error/is-ok
   are an addition on top of it (not in the original demo, which only ever
   showed one neutral tone): this app has real success vs failure states
   (wrong password vs "check your email") that are worth telling apart at a
   glance, not just by reading the words. */
.form-message {
  min-height: 17px;
  margin: 10px 0 -10px;
  color: transparent;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

.form-message.is-visible { color: #6d676a; }
.form-message.is-error.is-visible { color: var(--login-red); }
.form-message.is-ok.is-visible { color: #1f8a5f; }

.support-copy {
  margin: 22px 0 0;
  color: #7d777a;
  font-size: 11px;
  text-align: center;
}

.support-copy a { color: #4f4a4c; font-weight: 700; }

.login-footer {
  padding-top: 20px;
  border-top: 1px solid #dedbdc;
}

.login-footer span:last-child { color: #4e494b; }

.login-shell button:focus-visible,
.login-shell input:focus-visible,
.login-shell a:focus-visible {
  outline: 3px solid rgba(237, 28, 36, 0.22);
  outline-offset: 2px;
}

/* Two-step verification panel (mandatory Google Authenticator, added
   2026-08-12) — lives inside .login-card in place of the password form,
   same tokens/rhythm as the rest of the approved design. */
#mfaStep .login-copy { margin-bottom: 18px; }

.mfa-steps {
  margin: 0 0 18px;
  padding-left: 18px;
  color: #6b6668;
  font-size: 12px;
  line-height: 1.7;
}
.mfa-steps li { padding-left: 4px; }
.mfa-steps strong { color: var(--login-ink); }

.mfa-qr-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.mfa-qr-wrap img {
  display: block;
  width: 168px;
  height: 168px;
  padding: 10px;
  border: 1px solid #dedbdc;
  border-radius: 2px;
  background: #fff;
  image-rendering: pixelated;
}

.mfa-secret-line {
  margin: 0 0 18px;
  color: #7d777a;
  font-size: 11px;
  text-align: center;
  line-height: 1.6;
}
.mfa-secret-line code {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid #e5e2e3;
  border-radius: 2px;
  background: var(--login-surface);
  color: var(--login-ink);
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  word-break: break-all;
  user-select: all;
}

#mfaCode {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.35em;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
}
#mfaCode::placeholder { letter-spacing: 0.35em; font-weight: 400; }

#mfaForm .login-button { margin-top: 16px; }

.mfa-back {
  display: block;
  margin: 16px auto 0;
  cursor: pointer;
}

@media (max-width: 1080px) {
  .login-shell { grid-template-columns: minmax(0, 0.95fr) minmax(430px, 1.05fr); }
  .brand-stage { padding-left: 42px; padding-right: 42px; }
  .brand-content h1 { font-size: clamp(62px, 8vw, 88px); }
  .insight-strip { grid-template-columns: 1fr; gap: 12px; }
  .brand-footer span:last-child,
  .footer-rule { display: none; }
}

@media (max-width: 820px) {
  .login-shell { display: block; min-height: 100vh; }
  .brand-stage { display: none; }
  .login-stage { min-height: 100vh; padding: 22px 24px; }
  .login-topbar > span:first-child,
  .login-footer > span:first-child { display: none; }
  .login-topbar,
  .login-footer { justify-content: flex-end; }
  .login-wrap { padding: 28px 0; }
  .mobile-logo-wrap {
    display: flex; align-items: center; justify-content: space-between;
    gap: 20px; margin-bottom: 24px;
  }
  .mobile-logo { width: 160px; height: auto; }
  .mobile-logo-wrap span {
    color: #777174; font-size: 10px; font-weight: 700;
    letter-spacing: 0.11em; text-transform: uppercase;
  }
}

@media (max-width: 520px) {
  .login-stage { padding: 18px 16px; }
  .login-topbar { padding: 0 2px; }
  .login-card { padding: 32px 24px; box-shadow: 0 12px 32px rgba(35, 31, 32, 0.08); }
  .login-card h2 { font-size: 32px; }
  .mobile-logo-wrap span { display: none; }
  .login-footer { justify-content: center; text-align: center; }
}

@media (max-height: 780px) and (min-width: 821px) {
  .brand-stage, .login-stage { min-height: 780px; }
  .brand-content { padding-top: 34px; padding-bottom: 22px; }
  .momentum-panel { margin-top: 30px; }
  .login-wrap { padding: 26px 0; }
  .login-card { padding-top: 36px; padding-bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .login-shell, .login-shell *, .login-shell *::before, .login-shell *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Users admin page (added 2026-08-10) */
.user-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--mantis-grey-200); flex-wrap: wrap;
}
.user-row:last-child { border-bottom: none; }
.user-row .user-email { font-weight: 600; font-size: 14px; }
.user-row .user-meta { font-size: 12px; color: var(--mantis-grey-700); margin-top: 2px; }
.user-row.inactive { opacity: 0.5; }

.permission-grid { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 4px; }
.permission-group { min-width: 160px; }
.permission-group .permission-group-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--mantis-grey-400); margin-bottom: 6px;
}
.permission-checkbox { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 4px; }

.advanced-restrictions {
  margin-top: 16px; padding: 14px; border: 1px dashed var(--mantis-grey-200); border-radius: 8px;
  background: var(--mantis-grey-100);
}
.advanced-restrictions .metric-label { color: var(--mantis-grey-400); }

/* ============================================================
   Responsive layer (added 2026-08-12, per James: "optimise this
   for Mobile or tablet ipad etc view... it needs to auto adapt").
   The dashboard was desktop-first with only one 960px query; this
   section makes every page adapt from phone (~375px) through
   tablet to desktop. All additive — desktop layout is untouched.
   Charts here are pure CSS (bars/donuts/split-bars), so they
   already scale with their cards; the work is layout: nav, grids,
   tables, controls, modals.
   ============================================================ */

html { -webkit-text-size-adjust: 100%; }

/* --- Tablet (iPad portrait and below) ------------------------ */
@media (max-width: 1024px) {
  main { padding: 24px 20px; }
}

/* --- The topbar: brand row + scrollable nav ------------------- */
/* Below ~1150px the 7 nav links + status cluster can't fit beside
   the logo in one row (measured: the full desktop topbar needs
   ~1310px — iPad landscape at 1024px was overflowing too, not just
   phones). The nav drops to its own full-width row and scrolls
   horizontally (native momentum scroll, hidden scrollbar) — the
   standard mobile tab-bar pattern, no JS and no hamburger to
   maintain, and auth.js's permission-based link hiding keeps
   working unchanged since the markup is identical. min-width: 0 on
   the flex items matters: flex's default min-width:auto otherwise
   lets the nowrap link row force the whole page wider than the
   viewport instead of scrolling inside its own box. */
@media (max-width: 1150px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 10px 14px;
  }
  .topbar .brand { flex-wrap: wrap; row-gap: 8px; min-width: 0; max-width: 100%; }
  .topbar .brand nav {
    order: 10;
    flex-basis: 100%;
    min-width: 0;
    max-width: 100%;
    margin-left: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar .brand nav::-webkit-scrollbar { display: none; }
  .topbar nav a { white-space: nowrap; padding: 8px 12px; }
  .topbar .status { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
}

@media (max-width: 900px) {
  /* The full-colour wordmark SVG ships with no width/height attributes
     (viewBox only, ~13.6:1 aspect), so height:20px makes it ~272px wide —
     it swallows a phone topbar. Cap it hard on small screens; object-fit
     keeps the aspect ratio instead of squashing. */
  .topbar .brand img {
    height: 16px;
    max-width: min(58vw, 220px);
    object-fit: contain;
    object-position: left center;
  }

  .status .sync-time { display: none; } /* timestamp is the first thing to give up space; Sync button stays */

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .fy-header-controls { justify-content: flex-start; }
  .scenario-select { padding: 7px 12px; } /* comfortable touch target */
}

/* --- Phone -------------------------------------------------- */
@media (max-width: 700px) {
  main { padding: 16px 12px; }

  .headline-grid,
  .headline-grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

  .card { padding: 16px; }
  .metric-value { font-size: 22px; }
  .section-label { margin-top: 24px; }
  .two-col, .revenue-mix-grid, .donut-grid-4 { gap: 12px; }

  /* Wide tables scroll sideways INSIDE their card instead of
     stretching the whole page — min-widths keep columns readable
     rather than crushing them illegibly narrow. */
  .card { overflow-x: auto; }
  .opp-table { min-width: 560px; }
  .small-table { min-width: 480px; }

  /* Funnel: 5 stages + arrows can't sit in one phone-width row —
     stages wrap into a 3+2 grid and the connector arrows go. */
  .funnel { flex-wrap: wrap; gap: 8px; }
  .funnel-arrow { display: none; }
  .funnel-stage { flex: 1 1 30%; min-width: 92px; padding: 12px 8px; }
  .funnel-stage .value { font-size: 18px; }

  .region-row { grid-template-columns: 76px 1fr 76px; gap: 8px; font-size: 12px; }
  .region-split-bar { height: 40px; }

  .modal-overlay { padding: 10px; }
  .modal-card { max-height: 92vh; }
  .modal-header { padding: 12px 14px; }
  .modal-body { padding: 12px 14px; }

  body.page-pipeline .page-header { padding: 16px 16px 18px; }

  /* iOS Safari auto-zooms any focused input with font-size < 16px,
     which knocks the whole layout out of place mid-login — 16px on
     touch-size screens prevents that without changing desktop. */
  .settings-row input,
  .settings-row select,
  .login-shell .field-group input {
    font-size: 16px;
  }

  /* Users admin page: the action buttons drop below the details
     instead of squeezing beside them. */
  .user-row > div:last-child {
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: center !important;
    width: 100%;
  }
}

/* --- Small phones -------------------------------------------- */
@media (max-width: 420px) {
  .headline-grid,
  .headline-grid-5,
  .donut-grid-4 { grid-template-columns: 1fr; }
  .topbar .brand .product-name { display: none; } /* logo + nav is enough at this size */
  .funnel-stage { flex: 1 1 45%; }
}
