/* ============================================================
   LPK Timing � Signal Red
   ============================================================ */

:root {
  --bg:           #0a0b0d;
  --surface:      #14161a;
  --surface-2:    #1c1f25;
  --surface-3:    #232730;
  --border:       #2a2e36;
  --text:         #e4e6ea;
  --muted:        #8a93a0;
  --accent:       #e2231a;        /* signal red */
  --accent-hover: #b91c1c;
  --accent-ink:   #ffffff;        /* text color on accent fills */
  --success:      #34d399;
  --warning:      #f0b429;
  --danger:       #ff4f4f;
  --info:         #6cb8ff;
  --radius:       6px;
  --shadow:       0 6px 24px rgba(0,0,0,0.55);
  color-scheme: dark;
}

html.light {
  --bg:           #f4f5f7;
  --surface:      #ffffff;
  --surface-2:    #eaecef;
  --surface-3:    #dfe2e7;
  --border:       #d0d4da;
  --text:         #1a1d22;
  --muted:        #5c6370;
  --accent:       #c8181f;
  --accent-hover: #a3151b;
  --accent-ink:   #ffffff;
  --shadow:       0 4px 16px rgba(0,0,0,0.10);
  color-scheme: light;
}

/* --- Light mode: override hardcoded dark values --- */
html.light .data-table tbody tr:hover td { background: #e7eaee; }
html.light .pill { background: var(--surface-2); }
html.light .btn:hover:not(:disabled) { background: var(--surface-2); }
html.light .btn-danger { background: #fde4e4; color: #8b1a1a; border-color: #f0a0a0; }
html.light .btn-danger:hover:not(:disabled) { background: #fbcece; }
html.light .alert-warning { background: #fef9ec; color: #7a5c1e; border-color: #e0c870; }
html.light .badge-ok     { background: #d4f5e4; color: #0e5c2e; border-color: #7ad4a8; }
html.light .badge-warn   { background: #fef3d4; color: #7a5c1e; border-color: #e0c870; }
html.light .badge-bad    { background: #fde4e4; color: #8b1a1a; border-color: #f0a0a0; }
html.light .badge-fast   { background: #fef3d4; color: #7a5c1e; border-color: #e0c870; }
html.light .badge-record { background: #dceeff; color: #1a4a7a; border-color: #80b8ef; }
html.light .cell-fastest { background: rgba(109,40,217,0.10); color: #6d28d9; }
html.light .subnav-link:hover { border-bottom-color: var(--border); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---- Header ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--accent);
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.brand-logo {
  height: 34px;
  width: auto;
  display: block;
}
.brand-logo-light { display: none; }
html.light .brand-logo-dark { display: none; }
html.light .brand-logo-light { display: block; }
.nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nav-user { color: var(--muted); font-size: 0.9rem; }
.logout-form { margin: 0; }

/* ---- Main content ---- */
.main-content {
  flex: 1;
  padding: 2rem 1.25rem 3rem;
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 1rem 0;
  text-align: center;
  font-size: 0.85rem;
}

/* ---- Auth card ---- */
.auth-card {
  max-width: 420px;
  margin: 3rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 0.25rem; }

.auth-header {
  text-align: center;
  margin-bottom: 1.75rem;
}
.auth-logo {
  width: 220px;
  height: auto;
  display: block;
  margin: 0 auto 1.25rem;
  color: var(--text);
}
.auth-header h1 { margin: 0 0 0.25rem; }
.auth-divider {
  border: 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 1.25rem 0 0.875rem;
}
.muted  { color: var(--muted); }
.small  { font-size: 0.85rem; }

/* ---- Theme toggle ---- */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  padding: 0.3rem 0.55rem;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }


.field { margin-bottom: 1.1rem; }
.auth-card .btn-block { margin-top: 0.5rem; }

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.field-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.25rem 0 1.5rem;
}
.field-inline label { margin: 0; }
.field-error { display: block; font-size: 0.82rem; color: var(--danger, #e05252); margin-top: 0.25rem; }

.input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }

.input-reveal { position: relative; }
.input-reveal .input { padding-right: 2.6rem; }
.reveal-btn {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.4;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  color: var(--text);
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-block { width: 100%; }
.btn-inline-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: inherit; text-decoration: underline; font: inherit;
}
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
.btn-danger {
  background: #3d1212;
  color: #ff8a8a;
  border-color: #5c1f1f;
}
.btn-danger:hover:not(:disabled) { background: #5c1f1f; }

/* ---- Flash messages ---- */
.flash-stack { margin-bottom: 1.25rem; display: grid; gap: 0.5rem; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.flash-success { border-color: var(--success); }
.flash-danger  { border-color: var(--danger); }
.flash-warning { border-color: var(--warning); }
.flash-info    { border-color: var(--info); }

/* ---- Dashboard ---- */
.hero {
  padding: 2rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.hero h1 { margin: 0 0 0.25rem; }
.hero-sub { margin: 0; color: var(--text); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
section.card + section.card { margin-top: 1rem; }
.card h2 { margin-top: 0; font-size: 1.1rem; }
.meta {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
}
.meta strong { color: var(--text); margin-right: 0.25rem; }

/* ---- Page head ---- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 { margin: 0 0 0.15rem; }
.page-head p  { margin: 0; }

/* ---- Nav links ---- */
.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 0.38rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  transition: color 0.12s, background 0.12s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { background: var(--surface-2); color: var(--accent); font-weight: 600; }

/* ---- Tables ---- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-2); }

.cell-fastest {
  background: rgba(124, 58, 237, 0.22);
  color: #c4b5fd;
  font-weight: 600;
}
.actions-col { width: 1%; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.inline-form { display: inline; margin: 0; }

/* ---- Tags ---- */
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}
.tag-admin    { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 700; }
.tag-user     { color: var(--text); }
.tag-active   { color: var(--success); border-color: var(--success); }
.tag-inactive { color: var(--danger);  border-color: var(--danger); }
.tag-you      { color: var(--info);    border-color: var(--info); margin-left: 0.25rem; }
.tag-exempt   { color: #c4b5fd; border-color: #7c3aed; background: rgba(124,58,237,0.18); }

/* ---- Forms ---- */
.form-card {
  max-width: 560px;
  margin: 1rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
}
.form-card h1 { margin: 0.5rem 0 0.25rem; }
.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { color: var(--text); }
.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}
.err {
  display: block;
  margin-top: 0.25rem;
  color: var(--danger);
  font-size: 0.85rem;
}
.hint {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.hint a { color: var(--info); }
.input-multi { min-height: 7.5rem; padding: 0.5rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* ---- Chips ---- */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-row-lg { margin-top: 0.5rem; }
.chip {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
}

/* ---- Upload grid ---- */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

/* ---- Review / ingest extras ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.form-grid .card-wide { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.7rem; }
.form-grid label input,
.form-grid label select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
}
.meta-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0.4rem 1rem; margin: 0.4rem 0 0; padding: 0; }
.meta-list > div { display: flex; justify-content: space-between; gap: 0.6rem; font-size: 0.85rem; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; color: var(--text); }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 1px 6px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.badge-ok     { background: #0e2e1c; color: #4ddd95; border: 1px solid #154f2e; }
.badge-warn   { background: #2e2308; color: #e9c870; border: 1px solid #4a3810; }
.badge-bad    { background: #2e0e0e; color: #ef7676; border: 1px solid #4a1818; }
.badge-fast   { background: #2a1d04; color: #ffd166; border: 1px solid #4a3508; margin-left: 4px; }
.badge-record { background: #082838; color: #6cb8ff; border: 1px solid #0e3f58; margin-left: 4px; }

/* ---- Alerts ---- */
.alert { padding: 0.7rem 0.9rem; border-radius: var(--radius); margin: 1rem 0; border: 1px solid; }
.alert-warning { background: #221a06; color: #f1c46a; border-color: #4a3510; }

/* ---- Drivers of interest ---- */
.color-row { display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }
.color-swatch { width: 2.4rem; height: 2.4rem; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; cursor: pointer; }
.color-chip { display: inline-block; width: 1rem; height: 1rem; border-radius: 50%; border: 1px solid #00000033; vertical-align: -2px; margin-right: 0.3rem; }

/* ---- Analytics: filter bar + session head ---- */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.25rem;
}
.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.filter-bar select {
  padding: 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.filter-bar select:disabled { opacity: 0.45; }
.session-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.meta-pills { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ---- Pills ---- */
.pill { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.8rem; color: var(--muted); }
.pill-link { display: inline-block; text-decoration: none; }
.pill-link:hover { border-color: var(--accent); color: var(--accent); }
.muted-link { color: inherit; text-decoration: none; }

.driver-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 6px; border: 1px solid var(--border); }
.muted-link:hover { color: var(--accent); }
.row-doi { box-shadow: inset 4px 0 0 0 var(--doi-color, transparent); background: color-mix(in srgb, var(--doi-color, transparent) 8%, transparent); }

/* ---- Plots page ---- */
.checkbox-label { flex-direction: row !important; align-items: center; gap: 0.5rem; }
.checkbox-label input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

/* ---- Sub-navigation ---- */
.subnav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 0 0 1.25rem 0;
  flex-wrap: wrap;
}
.subnav-link {
  padding: 0.55rem 1rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-size: 0.92rem;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.subnav-link:hover { color: var(--text); border-bottom-color: var(--border); }
.subnav-link.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- Sector ranking table ---- */
.sector-table th { text-align: left; }
.sector-table td.num, .sector-table th[colspan] { text-align: left; }
.sector-table .car-num { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 0.15rem; }
.sector-table .sector-driver { white-space: nowrap; }
.sector-table .cell-doi { box-shadow: inset 3px 0 0 0 var(--doi-color, transparent); background: color-mix(in srgb, var(--doi-color, transparent) 12%, transparent); font-weight: 600; }

.sector-toolbar { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin: 0; }
.sector-toolbar .checkbox-label { font-size: 0.85rem; color: var(--muted); margin: 0; }

/* ---- Rising / cumulative average grid ---- */
.rising-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.rising-cell { height: 600px; min-width: 0; }
@media (max-width: 900px) { .rising-grid { grid-template-columns: 1fr; } }

/* ---- Consistency box-plot grid ---- */
.consistency-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin-top: 1rem; }

/* ================================================================
   REPORTS
   ================================================================ */

/* Toolbar above the report doc � hidden at print time */
.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* The report document itself � always white like a piece of paper */
.report-doc {
  background: #ffffff !important;
  color: #1a1d22 !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  max-width: 900px;
  margin: 0 auto 2rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Report header */
.report-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.25rem;
  align-items: start;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--accent);
}
.report-header-logo img { opacity: 0.9; }
.report-title {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.25rem;
  color: #1a1d22;
}
.report-car {
  color: #c8181f;
  margin-right: 0.4rem;
}
.report-subtitle {
  font-size: 0.82rem;
  color: #5c6370;
  margin-top: 0.2rem;
}
.report-hero-stats {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}
.hero-stat {
  text-align: center;
  min-width: 56px;
}
.hero-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: #1a1d22;
}
.hero-stat-label {
  display: block;
  font-size: 0.72rem;
  color: #5c6370;
  margin-top: 0.2rem;
}

/* Report sections */
.report-section {
  margin-bottom: 1.1rem;
}
.report-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #c8181f;
  margin: 0 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #d4d7dc;
}

/* Row/cell highlight for the selected driver of interest */
.report-highlight td,
td.report-highlight {
  background: color-mix(in srgb, var(--accent) 22%, transparent) !important;
  font-weight: 700 !important;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
}
.report-fastest-row td,
td.report-fastest-row {
  background: color-mix(in srgb, var(--accent) 12%, transparent) !important;
}

/* Report table � tighter than data-table, always dark text */
.report-table { font-size: 0.82rem; color: #1a1d22; }
.report-table th { font-size: 0.75rem; color: #1a1d22; background: #edeef1; }
.report-table td { color: #1a1d22; border-color: #d4d7dc; }
.report-table tbody tr:hover td { background: #f3f4f6; }

/* Sector leaderboard: 12 columns � must fit A4 portrait width.
   Column widths come from <colgroup> classes because the thead has
   colspan'd groups that prevent table-layout:fixed from using ths. */
.report-table-sector { table-layout: fixed; width: 100%; font-size: 0.72rem; }
.report-table-sector th,
.report-table-sector td {
  padding: 0.25rem 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-table-sector .col-rank { width: 5%; }
.report-table-sector .col-drv  { width: 11.5%; }
.report-table-sector .col-time { width: 8%; }
.report-table-sector .col-gap  { width: 6%; }

/* Scrollable wrapper on screen, invisible at print */
.no-print-overflow { overflow-x: auto; }

/* Drag-and-drop component card states */
.component-card.drag-over { border-color: var(--accent) !important; background: var(--surface-2); }
.component-card { transition: opacity 0.15s; }

/* 2�2 grid for rising-average panels in reports */
.report-rising-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Page-break hints for multi-page prints */
.report-page-break { page-break-before: auto; }
.report-all-break { page-break-before: auto; margin-top: 3rem; padding-top: 2rem; border-top: 2px solid #d4d7dc; }

/* Report footer */
.report-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #5c6370;
  padding-top: 0.75rem;
  margin-top: 1.5rem;
  border-top: 1px solid #d4d7dc;
}

/* ---- Print styles ---- */
@page { size: A4; margin: 12mm; }
@media print {
  /* Hide all chrome */
  .no-print,
  .site-header,
  .site-footer,
  .flash,
  .flash-stack,
  .report-toolbar { display: none !important; }

  /* Reset layout for paper */
  body, html { background: #fff !important; color: #000 !important; font-size: 11pt; }
  .main-content { padding: 0 !important; margin: 0 !important; }

  .report-doc {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    background: #fff !important;
    color: #000 !important;
    font-size: 9pt;
    line-height: 1.35;
  }

  /* Tighter section spacing on paper */
  .report-section { margin-bottom: 0.6rem; page-break-inside: avoid; }
  .report-section-title { margin: 0 0 0.3rem; padding-bottom: 0.2rem; font-size: 10pt; }
  .report-header { padding-bottom: 0.6rem; margin-bottom: 0.75rem; }

  /* Keep accent colour for important values */
  .report-title, .report-section-title { color: #c8181f !important; }
  .report-car { color: #c8181f !important; }
  .hero-stat-value { color: #000 !important; }

  /* Tables � compact for paper */
  .data-table { border-collapse: collapse; width: 100%; }
  .data-table th, .data-table td {
    border: 1px solid #ccc !important;
    padding: 0.18rem 0.3rem !important;
    background: #fff !important;
    color: #000 !important;
  }
  .data-table thead tr { background: #f0f0f0 !important; }
  .report-highlight td,
  td.report-highlight { background: #ffe4a8 !important; font-weight: 700 !important; box-shadow: inset 0 0 0 1px #c2710c; }
  .report-fastest-row td,
  td.report-fastest-row { background: #fce8c8 !important; }

  /* Sector leaderboard: even tighter to fit 12 columns on A4 portrait */
  .report-table-sector { font-size: 7.5pt; }
  .report-table-sector th, .report-table-sector td { padding: 0.12rem 0.18rem !important; }

  /* Page breaks: don't force � let sections flow and only break when a
     section won't fit on the current page (page-break-inside: avoid above) */
  .report-page-break { page-break-before: auto; }
  .report-all-break  { page-break-before: always; margin-top: 0; padding-top: 0; border-top: none; }

  /* Let wide tables expand fully in print / PDF */
  .no-print-overflow { overflow: visible; }

  /* Rising average: keep 2x2 grid for compactness on A4 */
  .report-rising-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem; }

  /* Force plotly charts to show & shrink to fit */
  .js-plotly-plot { page-break-inside: avoid; }
  /* Tighten plot heights for paper without clipping (matches the beforeprint
     resize hook in _report_plots.html). */
  .report-plot { height: 240px !important; }
  /* Override per-section: the larger charts get a bit more room. */
  #report-lap-chart, [id^="report-lap-chart"],
  #report-consistency, [id^="report-consistency"] { height: 300px !important; }
  [id^="report-position"], [id^="report-gap"] { height: 260px !important; }
  [id^="report-rising-"] { height: 200px !important; }
}

/* ---- Billing plan cards ---- */
.plan-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.5rem;
}
@media (max-width: 640px) { .plan-cards { grid-template-columns: 1fr; } }

.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg);
  position: relative;
}
.plan-card--featured {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
}
.plan-card-badge {
  position: absolute;
  top: -0.6rem;
  left: 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}
.plan-card-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.plan-card-desc {
  font-size: 0.87rem;
  color: var(--muted);
  flex-grow: 1;
}
.plan-card-features {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.plan-card-features li::before {
  content: '?  ';
  color: var(--accent);
  font-weight: 700;
}
.plan-card-features li {
  font-size: 0.85rem;
  color: var(--text);
}

/* ---- Countdown floating widget ---- */
.cd-widget {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: var(--surface);
  border: 2px solid var(--cd-color, var(--accent));
  border-radius: var(--radius);
  padding: 0.8rem 1.1rem;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.28);
  transition: box-shadow 0.15s, border-color 0.6s;
  cursor: pointer;
  min-width: 11rem;
  max-width: 20rem;
}
.cd-widget:hover { box-shadow: 0 8px 28px rgba(0,0,0,0.38); }
.cd-widget-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 17rem;
  margin-bottom: 0.15rem;
}
.cd-widget-timer {
  font-size: 1.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--cd-color, var(--accent));
  letter-spacing: 0.04em;
  line-height: 1.15;
  transition: color 0.6s;
}
.cd-widget--done .cd-widget-timer { font-size: 1.1rem; }

/* ---- Countdown tool ---- */
.countdown-clock-row {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.countdown-clock-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 2rem;
  text-align: center;
  min-width: 14rem;
}
.countdown-clock-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.countdown-clock-time {
  font-size: 2.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* --- Waterfall Timeline --- */
.dashboard-recent {
  margin-top: 2rem;
  padding: 0;
}
.dashboard-recent h2 {
  margin-bottom: 1.5rem;
}
.waterfall {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.waterfall-item {
  display: grid;
  grid-template-columns: 100px auto 1fr;
  gap: 1rem;
  padding: 1rem;
  border-left: 3px solid var(--border);
  position: relative;
  align-items: flex-start;
  transition: background 0.2s ease;
}
.waterfall-item:hover {
  background: var(--surface);
}
.waterfall-item:first-child {
  border-left-color: var(--accent);
}
.waterfall-time {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  line-height: 1.4;
}
.waterfall-dot {
  position: absolute;
  left: -9px;
  top: 1.25rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg);
}
.waterfall-item:first-child .waterfall-dot {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(245, 166, 35, 0.4);
}
.waterfall-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.waterfall-title {
  font-weight: 600;
  color: var(--text);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.waterfall-meta {
  font-size: 0.85rem;
  color: var(--muted);
}
.waterfall-status {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  display: inline-block;
  width: fit-content;
}
.status-confirmed {
  background: color-mix(in srgb, var(--success) 15%, var(--surface));
  color: var(--success);
}
.status-draft {
  background: color-mix(in srgb, var(--warning) 15%, var(--surface));
  color: var(--warning);
}
.status-failed {
  background: color-mix(in srgb, var(--danger) 15%, var(--surface));
  color: var(--danger);
}
.waterfall-status a {
  color: inherit;
  text-decoration: underline;
}
.waterfall-status a:hover {
  text-decoration: none;
}
  letter-spacing: 0.05em;
}

.countdown-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 640px) { .countdown-panels { grid-template-columns: 1fr; } }

.countdown-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.countdown-panel.countdown-next {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.countdown-panel-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.countdown-next .countdown-panel-badge { color: var(--accent); }
.countdown-panel-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}
.countdown-panel-notes {
  font-size: 0.85rem;
  color: var(--muted);
}
.countdown-panel-when {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.countdown-panel-timer {
  font-size: 2.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
}
.countdown-after .countdown-panel-timer {
  color: var(--text);
  font-size: 2rem;
}
.countdown-done {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}
.countdown-next-status { color: var(--accent); font-weight: 600; }
.row-past td { opacity: 0.4; }
.row-next td { color: var(--accent); font-weight: 600; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.82rem; }

/* ============================================================
   Landing page (public, pre-login)
   ============================================================ */
.landing-hero {
  position: relative;
  text-align: center;
  padding: 3.5rem 1rem 3rem;
  margin: -2rem -1.25rem 2.5rem;
  background:
    radial-gradient(ellipse at top, rgba(226,35,26,0.18), transparent 60%),
    linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.landing-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
}
.landing-hero-glow {
  position: absolute;
  inset: auto 0 -40% 0;
  height: 80%;
  background: radial-gradient(ellipse at center, rgba(226,35,26,0.10), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.landing-logo {
  width: 240px;
  max-width: 60%;
  height: auto;
  margin-bottom: 1.5rem;
}
.landing-logo-light { display: none; }
html.light .landing-logo-dark { display: none; }
html.light .landing-logo-light { display: inline-block; }
.landing-title {
  font-family: "Barlow Condensed", "Barlow", -apple-system, sans-serif;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 0 0 1rem;
}
.landing-title .accent { color: var(--accent); }
.landing-lede {
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 1.55;
  color: var(--muted);
  max-width: 680px;
  margin: 0 auto 2rem;
}
.landing-cta {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.btn-lg {
  padding: 0.85rem 1.6rem;
  font-size: 1.02rem;
  letter-spacing: 0.02em;
}
.landing-note { margin: 0.75rem 0 0; }

.hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.6rem;
}
.hero-reassure {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1.4rem;
  margin: 1rem 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.hero-reassure li { white-space: nowrap; }

/* Stats / social-proof strip */
.landing-stats { padding: 0.5rem 0 1rem; }
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  text-align: center;
}
.stat-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 0.9rem;
}
.stat-num {
  display: block;
  font-family: "Barlow Condensed", "Barlow", -apple-system, sans-serif;
  font-style: italic;
  font-weight: 900;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--accent);
}
.stat-label {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

/* Inline CTA after a section */
.section-cta { text-align: center; margin-top: 2rem; }

/* Pricing teaser */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  max-width: 760px;
  margin: 0 auto;
}
.price-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem 1.4rem;
}
.price-card-featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.price-badge {
  position: absolute;
  top: -0.7rem;
  right: 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}
.price-card h3 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.price-amount {
  font-family: "Barlow Condensed", "Barlow", -apple-system, sans-serif;
  font-style: italic;
  font-weight: 900;
  font-size: 2.6rem;
  line-height: 1;
  margin: 0 0 0.5rem;
}
.price-amount span {
  font-size: 1rem;
  font-style: normal;
  font-weight: 700;
  color: var(--muted);
}
.price-sub { margin: 0 0 1rem; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.price-list { list-style: none; padding: 0; margin: 0; }
.price-list li {
  position: relative;
  padding: 0.3rem 0 0.3rem 1.4rem;
  font-size: 0.93rem;
  border-top: 1px solid var(--border);
}
.price-list li:first-child { border-top: 0; }
.price-list li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}
.pricing-note { text-align: center; margin: 1.25rem 0 0; }

.landing-section {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border);
}
.landing-section:first-of-type { border-top: 0; padding-top: 0.5rem; }
.landing-section-head {
  text-align: center;
  margin-bottom: 2rem;
}
.landing-section-head h2 {
  font-family: "Barlow Condensed", "Barlow", -apple-system, sans-serif;
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin: 0 0 0.5rem;
}
.landing-section-head p { margin: 0; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.3rem;
  transition: border-color 0.15s, transform 0.15s;
}
.feature-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.feature-icon {
  font-size: 1.6rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: rgba(226,35,26,0.12);
  color: var(--accent);
  margin-bottom: 0.85rem;
}
.feature-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}
.feature-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.landing-trust { background: transparent; }
.trust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.trust-item {
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.trust-item h4 { margin: 0 0 0.35rem; font-size: 1rem; }
.trust-item p  { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }

.flow-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.85rem;
  max-width: 760px;
  margin: 0 auto;
}
.flow-steps li {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.flow-num {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-family: "Barlow Condensed", "Barlow", -apple-system, sans-serif;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.flow-steps h4 { margin: 0 0 0.25rem; font-size: 1.02rem; }
.flow-steps p  { margin: 0; color: var(--muted); font-size: 0.94rem; line-height: 1.5; }

.landing-final {
  text-align: center;
  padding: 3rem 1rem 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
}
.landing-final h2 {
  font-family: "Barlow Condensed", "Barlow", -apple-system, sans-serif;
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0 0 1.25rem;
}

@media (max-width: 600px) {
  .landing-hero { padding: 2.5rem 0.75rem 2rem; }
  .flow-steps li { padding: 0.85rem; }
}

/* ============================================================
   Mobile navigation toggle (hamburger)
   ============================================================ */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle.is-open .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle.is-open .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   Vertical mobile optimisations
   ============================================================ */
@media (max-width: 860px) {
  .nav-toggle { display: flex; }

  /* Collapse the primary nav into a full-width vertical dropdown */
  .nav {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    z-index: 1000;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.75rem 1rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: none;
  }
  .nav.is-open { display: flex; }

  .site-header { position: relative; }
  .nav-link {
    padding: 0.7rem 0.75rem;
    font-size: 1rem;
  }
  .nav-user { font-size: 1rem; padding: 0.7rem 0.75rem; }
  .logout-form { margin-top: 0.25rem; }
  .logout-form .btn { width: 100%; }
  .nav .theme-toggle {
    align-self: flex-start;
    margin-top: 0.25rem;
    padding: 0.5rem 0.8rem;
  }
}

@media (max-width: 640px) {
  /* Tighten horizontal padding to reclaim screen width */
  .container { padding: 0 0.9rem; }
  .main-content { padding: 1.25rem 0.9rem 2.5rem; }

  /* Stack page headers and their action buttons */
  .page-head { flex-direction: column; align-items: flex-start; }
  .head-actions,
  .report-toolbar { width: 100%; }
  .head-actions .btn { flex: 1; text-align: center; }

  /* Forms and cards use full width */
  .form-card,
  .auth-card { padding: 1.25rem; margin: 1.25rem auto; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }

  /* Tables stay readable via horizontal scroll inside their wrapper */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 0.85rem; }
  .data-table th,
  .data-table td { padding: 0.5rem 0.6rem; }

  /* Report doc fits narrow screens */
  .report-doc { padding: 1.25rem 1rem; }
  .report-header { grid-template-columns: 1fr; gap: 0.75rem; }
  .report-hero-stats { flex-wrap: wrap; gap: 0.75rem; }

  /* Hero / dashboard spacing */
  .hero { padding: 1.5rem 0 0.75rem; }

  /* Keep the floating countdown widget from covering content */
  .cd-widget {
    bottom: 0.9rem;
    right: 0.9rem;
    min-width: 8.5rem;
    padding: 0.6rem 0.85rem;
  }
  .cd-widget-timer { font-size: 1.5rem; }

  /* Waterfall timeline: drop the fixed time column, stack vertically */
  .waterfall-item {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    padding: 0.85rem 0.85rem 0.85rem 1rem;
  }
  .waterfall-time { text-align: left; }
}

