/*!
 * White-label brand tokens — MRS house theme (navy / blue).
 * House system: D:\MRS\MRS_BRAND\BRAND.md (and MRS_BRAND\tokens.css).
 * Override --brand-* for buyer white-label; keep legacy --bg/--accent aliases in sync.
 * Loads after app.css so these tokens win over the legacy F1-red :root in app.css.
 */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Manrope:wght@400;500;600;700;800&family=Newsreader:opsz,wght@6..72,400;6..72,600;6..72,700&display=swap");

/* ── MRS house + brand tokens (edit --brand-* / mirror white-label.config.json) ── */
:root {
  /* MRS house surfaces / ink / accent (canonical) */
  --mrs-bg: #050914;
  --mrs-elev: #0d162c;
  --mrs-blue: #3b82f6;
  --mrs-ink: #f3f6fc;
  --mrs-muted: #91a0bc;
  --mrs-font: "Manrope", system-ui, sans-serif;
  --mrs-display: "Newsreader", Georgia, serif;
  --mrs-mono: "IBM Plex Mono", ui-monospace, monospace;

  --brand-primary: var(--mrs-blue);
  --brand-accent: #60a5fa;
  --brand-bg: var(--mrs-bg);
  --brand-surface: var(--mrs-elev);
  --brand-text: var(--mrs-ink);
  --brand-muted: var(--mrs-muted);
  --brand-font: var(--mrs-font);

  /* Surfaces — authority over app.css F1-red / near-black theme */
  --bg: var(--brand-bg);
  --bg-elevated: #0a1224;
  --panel: var(--brand-surface);
  --panel-alt: #111d36;
  --panel-hi: #162448;
  --border: rgba(148, 163, 194, 0.12);
  --border-bright: rgba(96, 165, 250, 0.28);

  /* Type */
  --text: var(--brand-text);
  --text-dim: #b8c4dc;
  --subtext: var(--brand-muted);
  --text-on-accent: #ffffff;

  /* Brand accent — MRS blue (not F1 red); urgency red reserved for alerts only */
  --accent: var(--brand-primary);
  --accent-alt: var(--brand-accent);
  --accent-deep: #2563eb;
  --accent-label: #bfdbfe;
  --accent-muted: #60a5fa;
  --cyan: var(--accent-muted);
  --cyan-dim: var(--accent-label);

  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;

  --row-a: #0f1a30;
  --row-b: #0c1528;
  --input-bg: #0a1224;
  --input-fg: var(--brand-text);
  --input-border: rgba(148, 163, 194, 0.22);

  --font: var(--brand-font);
  --display: var(--mrs-display);
  --mono: var(--mrs-mono);
  --radius: 8px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);

  --red-border: color-mix(in srgb, var(--brand-primary) 42%, transparent);
  --red-glow: color-mix(in srgb, var(--brand-primary) 28%, transparent);
  --red-wash: color-mix(in srgb, var(--brand-primary) 6%, transparent);
  --red-wash-strong: color-mix(in srgb, var(--brand-primary) 11%, transparent);

  --surface-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0%, transparent 100%);
  --card-gradient: linear-gradient(
    135deg,
    color-mix(in srgb, var(--brand-primary) 5%, transparent) 0%,
    transparent 55%
  );
}

/* ── Base ── */
html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hint,
.form-rh-hint,
.form-preview-missing,
.wk-muted {
  color: var(--subtext);
  line-height: 1.5;
}

.boot-spinner {
  border-top-color: var(--accent);
}

.copyright-footer {
  color: rgba(255, 255, 255, 0.38);
}

/* ── Controls ── */
select.select-ctl option {
  background: var(--panel-hi);
  color: var(--text);
}

select,
input,
textarea,
.select-ctl,
.input-ctl {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--input-fg);
  font-size: 13px;
  min-height: 32px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28);
}

select:focus,
input:focus,
textarea:focus,
.select-ctl:focus,
.input-ctl:focus {
  border-color: var(--red-border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28), 0 0 0 2px var(--red-glow);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

button,
.btn {
  border-radius: 4px;
  border-color: rgba(255, 255, 255, 0.16);
  background: var(--panel-hi);
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
}

button:hover,
.btn:hover {
  border-color: rgba(255, 255, 255, 0.24);
  background: var(--panel-hi);
  color: var(--text);
}

button.primary,
.form-next-step-btn {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: var(--text-on-accent);
}

button.primary:hover,
.form-next-step-btn:hover {
  background: var(--accent-alt);
  border-color: var(--accent);
}

button.success.connected-active {
  background: #15803d;
  border-color: #166534;
}

.tab:focus-visible,
.race-topbar .tab-grid button.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ── Top bars ── */
.topbar,
.race-topbar {
  background: linear-gradient(180deg, #111d36 0%, var(--mrs-bg) 100%);
  border-color: var(--border);
}

.tb-card {
  background: var(--surface-gradient), var(--panel-alt);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
}

.tb-card-title {
  color: var(--accent-label);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.tb-circuit,
.tb-micro,
.tb-metric-sub {
  color: var(--text-dim);
}

.tb-metric-val,
.tb-fuel-val {
  color: var(--text);
}

.car-chip {
  border-radius: var(--radius);
  background: var(--panel);
  border-color: var(--border-bright);
}

.car-chip.active {
  border-color: var(--red-border);
  box-shadow: inset 3px 0 0 var(--accent);
}

.car-chip .num {
  color: var(--text);
  font-weight: 800;
}

.race-topbar .tab-grid {
  background: var(--bg-elevated);
  border-color: var(--border-bright);
  border-radius: 4px;
}

.race-topbar .tab-grid button.tab {
  color: var(--text-dim);
  background: var(--panel);
  border-color: var(--border);
}

.race-topbar .tab-grid button.tab:hover {
  background: var(--panel-hi);
  border-color: var(--border-bright);
  color: var(--text);
}

.race-topbar .tab-grid button.tab.active {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: var(--text-on-accent);
  box-shadow: none;
}

.tabbar-hang .tabbar-tabs {
  background: var(--bg-elevated);
  border-color: var(--border);
  border-radius: 0 0 6px 6px;
}

.tabbar-hang .tab {
  color: var(--text-dim);
}

.tabbar-hang .tab.active {
  color: var(--text);
}

/* ── Content shell ── */
.main {
  background: var(--bg);
}

.panel {
  padding: 14px 18px;
}

/* ── Panels & cards ── */
.card:not(.toolbar-card):not(.source-card) {
  position: relative;
  background: var(--card-gradient), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card:not(.toolbar-card):not(.source-card)::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: var(--radius) 0 0 var(--radius);
}

.card h2,
.card h3 {
  padding-left: 8px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

.toolbar-card,
.source-card {
  background: var(--panel-alt);
  border-color: var(--border);
}

.section-label {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.06em;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin-bottom: 4px;
}

/* ── Forms ── */
.form-panel-wrap {
  max-width: var(--content-max, 1320px);
  margin: 0 auto;
  width: 100%;
}

.form-layout {
  gap: 18px;
}

.form-card,
.m2-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px 20px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.form-card::before,
.m2-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.wk-settings.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.form-card-title,
.m2-card-title {
  margin: 0 0 16px 8px;
  padding-bottom: 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.form-card-title::after,
.m2-card-title::after {
  content: "";
  display: block;
  width: 32px;
  height: 2px;
  margin-top: 8px;
  background: var(--accent);
}

.form-car-row {
  margin: 0 0 14px 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

.form-car-row label {
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}

.form-cols {
  gap: 0;
}

.form-col {
  gap: 2px;
}

.form-row,
.field-row {
  margin: 0 0 0 8px;
  padding: 9px 10px;
  border-radius: 3px;
  align-items: center;
}

.form-row:nth-child(even),
.field-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}

.form-row:hover,
.field-row:hover {
  background: var(--red-wash);
}

.form-row label,
.field-row label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-transform: none;
}

.form-subhead,
.m2-subhead {
  margin: 16px 0 8px 8px;
  padding: 0 0 0 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-left: 3px solid var(--accent);
  background: none;
}

.form-row input,
.form-row select,
.form-row textarea,
.field-row input,
.field-row select,
.field-row textarea,
.form-pressure-cell input,
.wk-field input,
.wk-field select,
.m2-card input,
.m2-card select,
.m2-card textarea {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text);
}

.form-pressure-row {
  margin: 4px 0 8px 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-alt);
}

.form-pressure-cell span {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.form-notes-block {
  margin: 8px 0 0 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: var(--panel-alt);
}

.form-notes-block textarea {
  min-height: 96px;
  line-height: 1.5;
}

.form-actions {
  margin: 18px 0 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.form-preview-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.form-preview-card h3 {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.form-next-step {
  margin: 12px 0 0 8px;
  padding: 12px;
  border: 1px solid var(--red-border);
  border-radius: 4px;
  background: var(--red-wash);
}

.wk-field > span {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
}

.lt-form-grid .tb-field span,
.dv-toolbar label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;
}

/* ── Tables ── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

table.data {
  font-size: 13px;
}

table.data th {
  background: var(--panel-hi);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 9px 10px;
}

table.data td {
  padding: 8px 10px;
  color: var(--text);
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

table.data tr:nth-child(even) td {
  background: var(--row-b);
}

table.data tr:nth-child(odd) td {
  background: var(--row-a);
}

table.timing-data th {
  color: var(--text-dim);
}

table.data tr.selected td {
  outline: 1px solid var(--red-border);
  background: var(--red-wash-strong) !important;
}

table.data tr.team td {
  color: var(--text);
  font-weight: 700;
}

table.timing-data tr.follow td {
  background: var(--red-wash-strong);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ── Telemetry & status ── */
.tele-channel {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tele-channel .label {
  color: var(--text-dim);
}

.tele-channel .value {
  color: var(--text);
}

.mode-badge.live {
  color: var(--accent-label);
  border-color: var(--red-border);
  background: var(--red-wash-strong);
}

.log-line.our_car {
  color: var(--accent-label);
  font-weight: 600;
}

/* ── Insights ── */
.insight-banner {
  border: 1px solid var(--border);
  border-left: 3px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: var(--panel-alt);
  color: var(--text);
  line-height: 1.5;
}

.insight-subhead {
  color: var(--text);
  font-weight: 700;
}

.insight-alert--info {
  color: var(--text-dim);
}

.insight-banner.insight-alert--crit,
.insight-alert--crit:first-child:last-child {
  border-color: var(--red-border);
  border-left-color: var(--accent);
  background: var(--red-wash);
  color: var(--text);
}

.insight-alert--crit {
  color: var(--accent-label);
}

.insight-banner.insight-alert--warn {
  border-left-color: var(--warning);
  background: rgba(251, 191, 36, 0.08);
  color: var(--text);
}

.guide-section h4,
.guide-block .guide-caption,
.guide-image-side .caption {
  color: var(--text-dim);
  font-weight: 700;
}

/* ── Modals & toast ── */
.bridge-modal-card,
.app-modal-card {
  background: var(--panel);
  border: 1px solid var(--border-bright);
  border-top: 2px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
}

.bridge-modal-card p,
.app-modal-card p {
  color: var(--text-dim);
}

.toast {
  background: var(--panel-hi);
  border: 1px solid var(--border-bright);
  border-left: 3px solid var(--accent);
  color: var(--text);
}

/* ── Login ── */
.login-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-title {
  color: var(--text);
}

.login-sub,
.login-foot {
  color: var(--text-dim);
}

.login-field label {
  color: var(--text-dim);
  font-weight: 600;
}

.login-field input {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text);
}

.login-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-btn {
  background: var(--accent);
  font-weight: 700;
}

.login-btn:hover {
  background: var(--accent-alt);
}

.login-warning {
  border-left: 3px solid var(--accent);
  color: var(--text-dim);
}

/* ── Scrollbars ── */
.table-wrap::-webkit-scrollbar-thumb,
.main::-webkit-scrollbar-thumb,
.panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

@media (max-width: 1100px) {
  .panel {
    padding: 12px 14px;
  }

  .form-row,
  .field-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
