* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --ui-scale: 1;
  --desk-content-w: 904px; /* 280 + 12 + 280 + 12 + 320 */
  --bg: #050607;
  --bg-elevated: #0a0c10;
  --surface: #0e1218;
  --panel: #12171f;
  --panel-2: #171d27;
  --panel-border: rgba(180, 200, 230, 0.1);
  --panel-border-strong: rgba(200, 220, 255, 0.16);
  --text: #f4f7fb;
  --text-muted: #9aa6b8;
  --text-dim: #667084;
  --accent: #4cc9f0;
  --accent-soft: rgba(76, 201, 240, 0.16);
  --lime: #c8ff4a;
  --lime-hover: #d9ff78;
  --lime-glow: rgba(200, 255, 74, 0.38);
  --red: #ff3355;
  --red-hover: #ff5570;
  --cyan: #2de2e6;
  --input-bg: rgba(4, 6, 9, 0.88);
  --input-border: rgba(180, 200, 230, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 0 0 1px rgba(0, 0, 0, 0.45) inset,
    0 12px 36px rgba(0, 0, 0, 0.45);
  --carbon-fine: repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.028) 0 1px,
      transparent 1px 3px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(0, 0, 0, 0.28) 0 1px,
      transparent 1px 3px
    );
  --mono: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(76, 201, 240, 0.55);
}

html {
  zoom: var(--ui-scale);
}

html, body {
  height: 100%;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 50% -8%, rgba(76, 201, 240, 0.08), transparent 58%),
    radial-gradient(800px 480px at 92% 88%, rgba(200, 255, 74, 0.04), transparent 52%),
    var(--carbon-fine),
    linear-gradient(180deg, #0b0e13 0%, var(--bg) 42%, #030405 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1420px;
  margin: 0 auto;
  padding: 14px 18px 10px;
  gap: 14px;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 55%),
    var(--carbon-fine),
    var(--surface);
  border: 1px solid var(--panel-border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
}

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

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 26%, #6b778c, #10151d 68%),
    var(--carbon-fine),
    #0c1016;
  border: 1.5px solid rgba(200, 255, 74, 0.55);
  box-shadow:
    0 0 0 3px rgba(200, 255, 74, 0.1),
    0 0 22px rgba(200, 255, 74, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #f8fafc;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-text {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.1;
  background: linear-gradient(90deg, #f8fafc 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.logo-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.header-credit {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}

.header-credit-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.header-credit-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.header-credit-name em {
  font-style: normal;
  color: var(--lime);
}


/* Header layout + scale controls */
.header-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.ui-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(180, 200, 230, 0.14);
}

.ui-scale-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.ui-scale input[type="range"] {
  width: min(160px, 28vw);
  accent-color: var(--lime);
  cursor: pointer;
}

.ui-scale-val {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--lime);
  min-width: 3.2em;
  text-align: right;
}

@media (max-width: 700px) {
  .header-controls {
    order: 3;
    width: 100%;
  }
  .ui-scale {
    flex: 1 1 auto;
    justify-content: stretch;
  }
  .ui-scale input[type="range"] {
    flex: 1;
    width: auto;
  }
}

/* ── Top grid ── */
.top-grid {
  display: grid;
  /* Vehicle | Atmosphere (DA+Weather) | Results — even cards, equal height */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.card {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.05) 0%, transparent 40%),
    var(--carbon-fine),
    linear-gradient(180deg, rgba(18, 24, 34, 0.96), rgba(10, 13, 18, 0.98)),
    var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
  pointer-events: none;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), transparent);
}

.atmosphere-card {
  gap: 0;
}

.atmosphere-card .card-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.atmosphere-card .da-section {
  padding-bottom: 10px;
}

.atmosphere-card .weather-section {
  padding-top: 10px;
}

.card-divider {
  height: 1px;
  margin: 4px 0 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.14) 12%,
    rgba(34, 211, 238, 0.35) 50%,
    rgba(255, 255, 255, 0.14) 88%,
    transparent
  );
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.12);
}


.field {
  display: grid;
  grid-template-columns: max-content minmax(96px, 1fr);
  align-items: center;
  gap: 8px 10px;
}

.field > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.field input,
.field select,
.garage-search input,
select,
input[type="number"],
input[type="text"] {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--sans);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field input:hover,
.field select:hover,
.garage-search input:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.field input:focus,
.field select:focus,
.garage-search input:focus,
.btn:focus-visible,
.link-reset:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 6px 0 2px;
}

.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  user-select: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.check-row label:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--panel-border);
}

.check-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.field-hint {
  margin: 0 0 4px;
  padding: 0 2px;
  font-size: 10px;
  line-height: 1.3;
  color: var(--text-muted);
}

/* ── Buttons ── */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  font-family: var(--sans);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease, border-color 0.15s ease;
  letter-spacing: 0.01em;
}

.btn:active {
  transform: translateY(1px);
}

/* Garage: fixed 74×74 square beside vertical NA/FI/EV — never % height */
.check-garage-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
}

.check-garage-row .check-row {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  padding: 0;
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
}

.check-garage-row .check-row label {
  width: 100%;
  box-sizing: border-box;
  font-size: 11px;
  padding: 3px 6px;
}

#btnGarage.btn-garage,
.btn-garage {
  background: linear-gradient(180deg, #ff3d54, var(--red));
  color: #fff;
  box-sizing: border-box;
  width: 74px !important;
  height: 74px !important;
  min-width: 74px !important;
  max-width: 74px !important;
  min-height: 74px !important;
  max-height: 74px !important;
  flex: 0 0 74px !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 4px 14px rgba(239, 35, 60, 0.28);
}

.btn-garage:hover {
  background: linear-gradient(180deg, #ff556a, var(--red-hover));
}

.vehicle-card {
  overflow: visible !important;
}

.btn-generate {
  background: linear-gradient(180deg, #3b9eff, #2563eb);
  color: #fff;
  width: 100%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-generate:hover {
  background: linear-gradient(180deg, #56abff, #3b82f6);
}

.btn-test {
  background: linear-gradient(180deg, #d4ff6a, var(--lime));
  color: #0a0c0f;
  font-size: 17px;
  font-weight: 800;
  padding: 14px 24px;
  min-width: 120px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.25) inset,
    0 0 22px var(--lime-glow),
    0 6px 18px rgba(184, 255, 60, 0.22);
}

.btn-test:hover {
  background: linear-gradient(180deg, #e2ff8a, var(--lime-hover));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.3) inset,
    0 0 28px rgba(184, 255, 60, 0.45),
    0 6px 20px rgba(184, 255, 60, 0.28);
}

.btn-drag {
  background: linear-gradient(180deg, #56f0ff, #22d3ee);
  color: #041016;
  font-size: 15px;
  font-weight: 800;
  padding: 12px 18px;
  min-width: 120px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 10px;
  margin-top: 8px;
  width: 100%;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.25) inset,
    0 0 20px rgba(34, 211, 238, 0.35),
    0 6px 16px rgba(34, 211, 238, 0.2);
}

.btn-drag:hover {
  background: linear-gradient(180deg, #7af5ff, #67e8f9);
}

.btn-ctrl {
  background: var(--panel-2);
  color: #e8ecf1;
  border: 1px solid var(--panel-border-strong);
  width: 100%;
}

.btn-ctrl:hover {
  background: #1c222b;
  border-color: rgba(255, 255, 255, 0.18);
}

.da-result {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--cyan);
  min-height: 38px;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.06) inset;
}

/* Results / time-slip — fixed footprint; scroll inside; no grow */
.results-card {
  align-self: stretch;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  /* lock card chrome; slip fills remaining height */
  background:
    linear-gradient(160deg, rgba(255, 248, 230, 0.06) 0%, transparent 42%),
    var(--carbon-fine),
    linear-gradient(180deg, rgba(18, 24, 34, 0.96), rgba(10, 13, 18, 0.98)),
    var(--panel);
}

.results-card .card-title {
  color: #d4b896;
  letter-spacing: 0.14em;
}

.results-out,
.results-out.track-slip {
  flex: 1 1 0 !important;
  box-sizing: border-box;
  width: 100%;
  min-height: 0;
  height: 0; /* flex child fills card; content never expands card */
  max-height: 100%;
  /* Classic thermal track-slip paper */
  background-color: #f3e6c8;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(120, 90, 40, 0.035) 2px,
      rgba(120, 90, 40, 0.035) 3px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 3px,
      rgba(90, 60, 20, 0.03) 3px,
      rgba(90, 60, 20, 0.03) 4px
    ),
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, 0.45), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(160, 120, 60, 0.12), transparent 50%),
    linear-gradient(180deg, #f7ecd4 0%, #efe0bc 48%, #e8d4a8 100%);
  border: 1px dashed rgba(90, 60, 20, 0.45);
  border-radius: 2px;
  padding: 8px 10px;
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: #1a140c;
  white-space: pre;
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-gutter: stable;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    inset 0 0 40px rgba(120, 80, 20, 0.08),
    0 1px 0 rgba(0, 0, 0, 0.25);
}

/* ── Dashboard ── */
.dashboard {
  display: grid;
  grid-template-columns: 280px 140px 1fr;
  gap: 12px;
  align-items: stretch;
  flex: 1;
  min-height: 300px;
}

.gauge-wrap,
.controls-col,
.chart-card {
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.04) 0%, transparent 45%),
    var(--carbon-fine),
    var(--panel);
  border: 1px solid var(--panel-border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 14px 18px;
  gap: 6px;
}

.active-vehicle-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--lime);
  text-transform: uppercase;
  max-width: 100%;
  padding: 4px 10px 2px;
  line-height: 1.3;
  text-shadow: 0 0 10px rgba(184, 255, 60, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#speedGauge {
  width: 260px;
  height: 260px;
  max-width: 100%;
  margin-top: 2px;
}

.controls-col {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  justify-content: center;
}

.run-timer {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--lime);
  padding: 10px 6px;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  background: rgba(184, 255, 60, 0.06);
  border: 1px solid rgba(184, 255, 60, 0.22);
  box-shadow:
    0 0 16px rgba(184, 255, 60, 0.12),
    inset 0 0 12px rgba(184, 255, 60, 0.04);
  letter-spacing: 0.02em;
  text-shadow: 0 0 12px rgba(184, 255, 60, 0.35);
}

.chart-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-labels {
  position: relative;
  height: 14px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.progress-mark {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.progress-mark[data-ft="0"] {
  transform: none;
  left: 0 !important;
}

.progress-mark-end {
  transform: translateX(-100%);
}

.progress-bar {
  position: relative;
  height: 8px;
  background: #0a0c0f;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--panel-border-strong);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.progress-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.progress-ticks i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.28);
  transform: translateX(-50%);
}

.progress-fill {
  position: relative;
  z-index: 2;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #16a34a, var(--lime));
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(184, 255, 60, 0.45);
  transition: width 0.05s linear;
}

.chart-wrap {
  flex: 1;
  height: 240px;
  min-height: 240px;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: #0a0c0f;
}

.chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Footer ── */
.app-footer {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--panel-border);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.footer-credit {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.footer-credit span {
  color: var(--lime);
}

.footer-disclaimer {
  max-width: 720px;
  color: var(--text-dim);
  font-size: 11px;
}

/* ── Garage modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 8, 0.78);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 30%),
    #0e1218;
  border: 1px solid var(--panel-border-strong);
  border-radius: 14px;
  width: min(580px, 100%);
  max-height: min(740px, 92vh);
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 24px 64px rgba(0, 0, 0, 0.65);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--panel-border);
}

.modal-header h2 {
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modal-body {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.garage-search label {
  display: block;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.car-list {
  list-style: none;
  overflow: auto;
  flex: 1;
  min-height: 280px;
  max-height: 420px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: #080a0d;
  padding: 4px;
}

.car-list li {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 2px;
  cursor: pointer;
  font-size: 13px;
  color: #d1d5db;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.car-list li:hover {
  background: rgba(56, 189, 248, 0.08);
  color: #fff;
}

.car-list li.selected {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.22), rgba(56, 189, 248, 0.08));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
  font-weight: 600;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px 12px;
  border-top: 1px solid var(--panel-border);
}

.modal-actions .btn {
  flex: 1;
  min-width: 100px;
}

.btn-load {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.btn-load:hover { background: linear-gradient(180deg, #4ade80, #22c55e); }

.btn-close-modal {
  background: #1c222b;
  color: #e8ecf1;
  border: 1px solid var(--panel-border-strong);
}

.btn-close-modal:hover { background: #262d38; }

.btn-disabled {
  background: #161a20;
  color: #555;
  cursor: not-allowed;
}

.btn-add {
  background: linear-gradient(180deg, #3b9eff, #2563eb);
  color: #fff;
}
.btn-add:hover { background: linear-gradient(180deg, #56abff, #3b82f6); }

.btn-edit {
  background: #374151;
  color: #fff;
}
.btn-edit:hover { background: #4b5563; }

.btn-delete {
  background: #b91c1c;
  color: #fff;
}
.btn-delete:hover { background: #dc2626; }

.car-editor {
  display: none;
  padding: 14px 18px;
  border-top: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.25);
  gap: 10px;
  flex-direction: column;
}

.car-editor.open {
  display: flex;
}

.editor-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.editor-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.editor-grid .field {
  grid-template-columns: 140px 1fr;
}

.editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.editor-actions .btn {
  flex: 1;
}

.garage-reset-row {
  padding: 0 18px 16px;
  text-align: center;
}

.link-reset {
  background: none;
  border: none;
  color: #7dd3fc;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-family: var(--sans);
  padding: 4px 8px;
  border-radius: 4px;
}

.link-reset:hover {
  color: #bae6fd;
}


/* FWD | RWD | AWD segmented control */
.drive-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}

.drive-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.drive-seg {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  background: #0a0c0f;
  border: 1px solid var(--panel-border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.drive-opt {
  position: relative;
  cursor: pointer;
  margin: 0;
  user-select: none;
}

.drive-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drive-opt span {
  display: block;
  text-align: center;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: transparent;
  border-right: 1px solid var(--panel-border);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.drive-opt:last-child span {
  border-right: none;
}

.drive-opt:hover span {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.drive-opt input:checked + span {
  color: #0a0c0f;
  background: linear-gradient(180deg, #d4ff6a, var(--lime));
  box-shadow: 0 0 14px rgba(184, 255, 60, 0.35);
}



/* ── Desktop fixed sizes (baked Comfortable) + centered column ── */
@media (min-width: 1101px) {
  .app {
    width: var(--desk-content-w);
    max-width: var(--desk-content-w);
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
  }

  .header,
  .top-grid,
  .dashboard,
  .app-footer {
    width: 100%;
    box-sizing: border-box;
  }

  .top-grid {
    grid-template-columns: 280px 280px 320px;
    gap: 12px;
    justify-content: start;
  }

  .top-grid {
    align-items: stretch;
  }

  .top-grid > .card,
  .top-grid > .atmosphere-card,
  .top-grid > .results-card {
    height: auto !important;
    min-height: 481px;
    max-height: none !important;
    box-sizing: border-box;
    overflow: visible !important;
  }

  .vehicle-card {
    height: auto !important;
    overflow: visible !important;
  }

  .dashboard {
    grid-template-columns: 280px 140px 459px;
    gap: 12px;
    justify-content: start;
    height: 375px;
    min-height: 375px;
    max-height: 375px;
    flex: 0 0 375px;
  }

  .gauge-wrap,
  .controls-col,
  .chart-card {
    height: 375px;
    max-height: 375px;
    box-sizing: border-box;
    overflow: hidden;
  }

  .gauge-wrap {
    padding: 8px 10px 12px;
  }
}

/* Mobile / narrow: Time Slip may grow with content (desktop stays fixed+scroll) */
@media (max-width: 800px) {
  .results-card {
    overflow: visible;
    max-height: none;
    align-self: stretch;
  }
  .results-out,
  .results-out.track-slip {
    flex: 0 0 auto !important;
    height: auto !important;
    max-height: none;
    overflow-y: visible;
    overflow-x: auto;
    scrollbar-gutter: auto;
  }
  .field {
    grid-template-columns: max-content minmax(88px, 1fr);
  }
}

@media (max-width: 1100px) {
  .top-grid {
    grid-template-columns: 1fr 1fr;
  }
  .results-card {
    grid-column: 1 / -1;
  }
  .dashboard {
    grid-template-columns: 1fr 1fr;
  }
  .chart-card {
    grid-column: 1 / -1;
  }
  .header {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  .header-credit {
    align-items: center;
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 700px) {
  .top-grid,
  .dashboard {
    grid-template-columns: 1fr;
  }
  .field {
    grid-template-columns: max-content minmax(80px, 1fr);
  }
  .brand {
    flex-direction: column;
  }
}


/* ── Carbon theme polish ── */
.app-footer {
  border-top: 1px solid rgba(180, 200, 230, 0.1);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.25));
}

.field input:focus,
.field select:focus,
.garage-search input:focus {
  border-color: rgba(76, 201, 240, 0.55);
  box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.12);
}

/* HP source / transmission / locked loss (Seraph #2) */
.hp-source-row .drive-opt span,
.tx-row .drive-opt span {
  font-size: 10px;
  padding: 6px 6px;
  letter-spacing: 0.02em;
}

#loss.is-locked,
#loss:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: rgba(20, 24, 32, 0.85);
}

#lossHint {
  margin-top: -0.15rem;
  margin-bottom: 0.35rem;
}

.tx-row {
  margin-top: 0.15rem;
}
