/* ─── CSS Variables ──────────────────────────────────────────────────────── */
:root {
  --bg:          #0d1117;
  --bg2:         #161b22;
  --bg3:         #1c2430;
  --border:      #30363d;
  --accent:      #f97316;
  --accent2:     #3b82f6;
  --text:        #e6edf3;
  --text-dim:    #8b949e;
  --text-muted:  #6e7681;
  --green:       #22c55e;
  --yellow:      #eab308;
  --red:         #ef4444;
  --radius:      6px;
  --radius-lg:   10px;
  --shadow:      0 2px 8px rgba(0,0,0,0.4);
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; font-size: 13px; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App Shell ──────────────────────────────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon { font-size: 22px; }
.brand-title {
  font-family: 'Segoe UI', Impact, Arial Narrow, sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
}
.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.project-name {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-compute {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-compute:hover:not(:disabled) { background: #ea6b0f; }
.btn-compute:disabled { opacity: 0.6; cursor: not-allowed; }

/* ─── Body ───────────────────────────────────────────────────────────────── */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: 176px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 12px 0;
  flex-shrink: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--text-dim);
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: all 0.12s;
}
.nav-item:hover { color: var(--text); background: var(--bg3); text-decoration: none; }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(249,115,22,0.08); }
.nav-icon { font-size: 15px; }
.nav-divider { height: 1px; background: var(--border); margin: 6px 12px; }

/* ─── Main Content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.status-bar {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 5px 16px;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
  min-height: 27px;
}
.status-computing { color: var(--accent); }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 16px;
  align-content: start;
}
.col-span-2 { grid-column: span 2; }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}
.card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.card-subheader {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  margin: 4px 0 2px;
  text-transform: uppercase;
}

/* ─── Form Elements ──────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}
.form-row label {
  width: 170px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim);
}
input[type="number"], input[type="text"], select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 4px 8px;
  font-size: 13px;
  outline: none;
}
input[type="number"]:focus, input[type="text"]:focus, select:focus {
  border-color: var(--accent2);
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.input-xs  { width: 66px; }
.input-sm  { width: 90px; }
.input-md  { width: 110px; }
.input-select { width: 200px; }
.input-search { width: 260px; }
.unit-hint { font-size: 11px; color: var(--text-muted); }
.checkbox  { margin: 0; }

/* ─── Stats ──────────────────────────────────────────────────────────────── */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  border-bottom: 1px solid rgba(48,54,61,0.5);
}
.stat-label { font-size: 12px; color: var(--text-dim); }
.stat-value { font-size: 12px; font-weight: 600; color: var(--text); font-family: 'Consolas', monospace; }
.divider { height: 1px; background: var(--border); margin: 6px 0; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  transition: opacity 0.12s;
}
.btn:hover { opacity: 0.85; }
.btn-primary   { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--bg3); color: var(--text-dim); border: 1px solid var(--border); }
.btn-sm        { padding: 3px 9px; font-size: 11px; }
.btn-icon      { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 2px 5px; font-size: 13px; }
.btn-icon:hover { color: var(--red); }

/* ─── Two-column layout ──────────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.col-header { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--accent); margin-bottom: 6px; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.map-scroll {
  overflow: auto;
  padding: 0 16px 16px;
  flex: 1;
}
.timing-table {
  border-collapse: collapse;
  font-size: 11px;
  font-family: 'Consolas', monospace;
  white-space: nowrap;
}
.timing-table th, .timing-table td {
  border: 1px solid rgba(48,54,61,0.6);
  padding: 0;
}
.timing-cell {
  min-width: 48px;
  height: 24px;
  text-align: center;
  vertical-align: middle;
  cursor: default;
  font-size: 11px;
  transition: filter 0.1s;
}
.timing-cell:hover { filter: brightness(1.3); }
.map-corner  { background: var(--bg3); color: var(--text-dim); padding: 4px 8px; font-size: 11px; }
.rpm-header  { background: var(--bg3); color: var(--text-dim); padding: 4px 6px; font-size: 10px; }
.map-label   { background: var(--bg3); color: var(--text-dim); padding: 4px 8px; font-size: 11px; text-align: right; white-space: nowrap; }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-wrap: wrap;
  gap: 8px;
}
.table-title { font-size: 12px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.5px; }
.toolbar-left { display: flex; align-items: center; gap: 12px; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }

.table-footer {
  padding: 6px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.data-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.data-table th { background: var(--bg3); color: var(--text-dim); padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table td { padding: 5px 10px; border-bottom: 1px solid rgba(48,54,61,0.4); color: var(--text); }
.data-table tr:hover td { background: var(--bg3); }
.row-highlight td { color: var(--accent) !important; font-weight: 600; }

/* ─── Legend ─────────────────────────────────────────────────────────────── */
.legend-strip { display: flex; align-items: center; gap: 2px; }
.legend-label { font-size: 10px; color: var(--text-muted); padding: 0 4px; }
.legend-cell  { width: 18px; height: 14px; border-radius: 2px; }
.legend-chip  { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; color: #fff; }
.checkbox-label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-dim); cursor: pointer; }

/* ─── Knock page ─────────────────────────────────────────────────────────── */
.knock-summary  { display: flex; gap: 8px; padding: 10px 16px; }
.summary-chip   { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.chip-ok   { background: rgba(34,197,94,0.15);  color: var(--green); border: 1px solid var(--green); }
.chip-warn { background: rgba(239,68,68,0.15);  color: var(--red);   border: 1px solid var(--red); }
.chip-info { background: rgba(59,130,246,0.12); color: var(--accent2); border: 1px solid var(--accent2); }
.knock-legend { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Dyno page ──────────────────────────────────────────────────────────── */
.dyno-stats-bar {
  display: flex;
  gap: 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0;
}
.dyno-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 20px;
}
.dyno-stat-value { font-size: 28px; font-weight: 700; color: var(--accent); font-family: 'Consolas', monospace; }
.dyno-stat-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; }
.dyno-stat-rpm   { font-size: 11px; color: var(--text-dim); }
.dyno-stat-divider { width: 1px; background: var(--border); }
.chart-container { padding: 16px; height: 360px; position: relative; }
.dyno-table-wrap { padding: 0 16px 16px; }

/* ─── Turbo library ──────────────────────────────────────────────────────── */
.turbo-list { display: flex; flex-direction: column; gap: 6px; max-height: 400px; overflow-y: auto; margin-top: 8px; }
.turbo-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.turbo-item:hover { border-color: var(--accent2); }
.turbo-item-active { border-color: var(--accent) !important; background: rgba(249,115,22,0.08); }
.turbo-item-name  { font-weight: 600; color: var(--text); font-size: 12px; }
.turbo-item-mfr   { font-size: 11px; color: var(--accent2); }
.turbo-item-desc  { font-size: 11px; color: var(--text-muted); margin: 2px 0; }
.turbo-item-specs { font-size: 11px; color: var(--text-dim); font-family: 'Consolas', monospace; }

/* ─── Flow table ─────────────────────────────────────────────────────────── */
.flow-table table { border-collapse: collapse; width: 100%; }
.flow-table th { background: var(--bg3); color: var(--text-dim); padding: 5px 8px; font-size: 11px; border-bottom: 1px solid var(--border); text-align: left; }
.flow-table td { padding: 3px 6px; border-bottom: 1px solid rgba(48,54,61,0.3); }

/* ─── Fuel page ──────────────────────────────────────────────────────────── */
.fuel-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.fuel-btn { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-dim); padding: 6px 16px; cursor: pointer; font-size: 12px; transition: all 0.12s; }
.fuel-btn:hover { border-color: var(--accent2); color: var(--text); }
.fuel-btn-active { background: rgba(249,115,22,0.15); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ─── Help page ──────────────────────────────────────────────────────────── */
.help-layout { display: flex; flex: 1; overflow: hidden; height: 100%; }
.help-nav {
  width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 12px 0;
}
.help-nav-title { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--text-muted); padding: 6px 16px 8px; }
.help-nav-item { display: block; padding: 6px 16px; color: var(--text-dim); font-size: 12px; border-left: 3px solid transparent; transition: all 0.12s; }
.help-nav-item:hover { color: var(--text); background: var(--bg3); text-decoration: none; }
.help-nav-active { color: var(--accent); border-left-color: var(--accent); background: rgba(249,115,22,0.08); }
.help-content { flex: 1; overflow-y: auto; padding: 24px 32px; }
.markdown-body h1 { font-size: 22px; color: var(--text); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 16px; color: var(--text); margin: 18px 0 8px; }
.markdown-body h3 { font-size: 14px; color: var(--text-dim); margin: 14px 0 6px; }
.markdown-body p  { color: var(--text-dim); line-height: 1.7; margin-bottom: 8px; font-size: 13px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.markdown-body ul { padding-left: 20px; color: var(--text-dim); font-size: 13px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body code { background: var(--bg3); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-family: 'Consolas', monospace; font-size: 12px; color: var(--accent2); }
.markdown-body pre { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; overflow-x: auto; margin: 8px 0; }
.markdown-body pre code { background: none; border: none; padding: 0; color: var(--green); font-size: 12px; }
.markdown-body .md-table { border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.markdown-body .md-table td { border: 1px solid var(--border); padding: 5px 10px; color: var(--text-dim); }
.markdown-body .md-table tr:first-child td { background: var(--bg3); color: var(--text-dim); font-weight: 600; }
.markdown-body strong { color: var(--text); font-weight: 600; }
.markdown-body a { color: var(--accent2); }

/* ─── Info box ───────────────────────────────────────────────────────────── */
.info-box {
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ─── No results ─────────────────────────────────────────────────────────── */
.no-results {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  padding: 60px;
}
.no-results-icon  { font-size: 48px; }
.no-results-title { font-size: 20px; font-weight: 600; color: var(--text-dim); }
.no-results-sub   { font-size: 13px; text-align: center; max-width: 360px; line-height: 1.6; }

/* ─── Spinner ────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Blazor error UI ────────────────────────────────────────────────────── */
#blazor-error-ui {
  background: rgba(239,68,68,0.9);
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
  color: white;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ─── Project Bar ────────────────────────────────────────────────────────── */
.project-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.project-bar-left, .project-bar-right { display: flex; gap: 4px; }
.project-bar-left { margin-right: 6px; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.project-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  z-index: 9999;
  cursor: pointer;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
}
.toast-ok    { background: #166534; color: #bbf7d0; border: 1px solid #22c55e; }
.toast-error { background: #7f1d1d; color: #fecaca; border: 1px solid #ef4444; }
@keyframes slideIn { from { transform: translateY(20px); opacity:0; } to { transform:none; opacity:1; } }

/* ─── Timing Table Edit Bar ──────────────────────────────────────────────── */
.timing-edit-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.edit-bar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}
.btn-advance { background: rgba(34,197,94,0.15);  color: #22c55e; border: 1px solid #22c55e; }
.btn-retard  { background: rgba(239,68,68,0.15);  color: #ef4444; border: 1px solid #ef4444; }
.btn-smooth  { background: rgba(249,115,22,0.15); color: var(--accent); border: 1px solid var(--accent); }
.btn-advance:hover { background: rgba(34,197,94,0.3); }
.btn-retard:hover  { background: rgba(239,68,68,0.3); }
.btn-smooth:hover  { background: rgba(249,115,22,0.3); }
.selected-count {
  margin-left: 8px;
  font-size: 11px;
  color: var(--accent2);
  font-family: 'Consolas', monospace;
}
.cell-selected { outline: 2px solid #ffd700 !important; }

/* ─── MBT Knock Indicator ────────────────────────────────────────────────── */
.knock-legend-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.knock-indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff4444;
  flex-shrink: 0;
}

/* ─── Status bar error state ─────────────────────────────────────────────── */
.status-error {
  color: #ff4444 !important;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.1) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SPLASH SCREEN
   ═══════════════════════════════════════════════════════════════════════════ */
.splash-root {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.splash-hero {
  position: relative;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 56px 60px 48px;
  overflow: hidden;
}
.splash-grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,180,216,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,180,216,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
.splash-hero-content { position: relative; z-index: 1; max-width: 800px; }

.splash-title {
  font-family: Impact, 'Arial Narrow', Arial, sans-serif;
  font-size: 72px;
  line-height: 1.0;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #ffffff 0%, #00b4d8 50%, #ffd700 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.splash-subtitle {
  font-family: Impact, 'Arial Narrow', Arial, sans-serif;
  font-size: 22px;
  color: #5a6375;
  letter-spacing: 2px;
  margin-bottom: 20px;
}
.splash-desc {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 660px;
  margin-bottom: 24px;
}
.splash-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.splash-badge {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 2px;
  border: 1px solid;
}
.badge-cyan   { color: #00b4d8; background: rgba(0,180,216,0.08);  border-color: rgba(0,180,216,0.3); }
.badge-orange { color: #ff8c00; background: rgba(255,140,0,0.08);  border-color: rgba(255,140,0,0.3); }
.badge-green  { color: #00c864; background: rgba(0,200,100,0.08);  border-color: rgba(0,200,100,0.3); }

.splash-heat-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.heat-label-sm {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  color: #3a4355;
}
.heat-bar-gradient {
  width: 180px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right,
    #1e46b4 0%, #00b4dc 22%, #00c864 44%,
    #dcdc00 65%, #ff8c00 82%, #dc1e1e 100%);
}

/* ── Sections ────────────────────────────────────────────────────────────── */
.splash-section {
  padding: 48px 60px 0;
}
.splash-section-label {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  color: #00b4d8;
  letter-spacing: 2px;
  margin-bottom: 24px;
}

/* ── Feature cards ───────────────────────────────────────────────────────── */
.splash-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 0;
}
.splash-feature-card {
  background: var(--bg2);
  padding: 20px;
  border-left: 3px solid var(--accent);
  transition: background 0.15s;
}
.splash-feature-card:hover { background: var(--bg3); }
.splash-feature-icon {
  font-size: 22px;
  margin-bottom: 10px;
}
.splash-feature-title {
  font-family: 'Consolas', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.splash-feature-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ── Physics formulas ────────────────────────────────────────────────────── */
.splash-formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.splash-formula-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.splash-formula-label {
  font-family: 'Consolas', monospace;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.splash-formula {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  color: #ffd700;
  line-height: 1.8;
  margin: 0;
  white-space: pre;
  overflow-x: auto;
}

/* ── Disclaimer ──────────────────────────────────────────────────────────── */
.splash-disclaimer {
  background: #1a0505;
  border: 1px solid #5a1a1a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 0;
}
.splash-disclaimer-inner {
  border-left: 4px solid #dc1e1e;
  padding: 28px 36px;
}
.splash-disclaimer-tag {
  display: inline-block;
  background: #2a0808;
  border: 1px solid #5a1a1a;
  border-radius: 2px;
  padding: 3px 10px;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  color: #dc1e1e;
  margin-bottom: 16px;
}
.splash-disclaimer-title {
  font-family: Impact, 'Arial Narrow', Arial, sans-serif;
  font-size: 22px;
  color: #dc1e1e;
  margin-bottom: 16px;
}
.splash-disclaimer-para {
  font-size: 13px;
  color: #b0b8c8;
  line-height: 1.7;
  margin-bottom: 10px;
}
.splash-disclaimer-para strong { color: var(--text); }
.splash-disclaimer-note {
  font-family: 'Consolas', monospace;
  font-size: 11px;
  color: #3a4355;
  margin-top: 8px;
}

/* ── Footer / Acknowledge ────────────────────────────────────────────────── */
.splash-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 60px;
  margin-top: 48px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  flex-wrap: wrap;
}
.splash-footer-text {
  font-family: 'Consolas', monospace;
  font-size: 11px;
  color: #5a6375;
}
.splash-footer-sub {
  font-size: 10px;
  color: #3a4355;
  margin-top: 3px;
}
.splash-footer-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}
.splash-btn-cancel {
  font-family: 'Consolas', monospace;
  font-size: 13px;
  color: #5a6375;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 9px 20px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.12s, border-color 0.12s;
}
.splash-btn-cancel:hover {
  color: #dc1e1e;
  border-color: #5a1a1a;
  text-decoration: none;
}
.splash-btn-ack {
  font-family: 'Consolas', monospace;
  font-size: 13px;
  font-weight: 600;
  color: #00b4d8;
  background: transparent;
  border: 1px solid #00b4d8;
  border-radius: 2px;
  padding: 9px 28px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.splash-btn-ack:hover {
  background: #00b4d8;
  color: #0d1117;
}

/* ─── Unit System Page ───────────────────────────────────────────────────── */
.units-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }

.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.units-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.units-card-title {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent);
  margin-bottom: 4px;
}
.units-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.units-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.units-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  transition: all 0.12s;
}
.units-radio:hover { background: var(--bg2); border-color: var(--border); }
.units-radio-active {
  background: rgba(249,115,22,0.1);
  border-color: rgba(249,115,22,0.4);
  color: var(--accent);
  font-weight: 600;
}
.units-radio input[type="radio"] { accent-color: var(--accent); margin: 0; }
.units-example {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 3px;
  padding: 5px 8px;
  margin-top: 4px;
}
.units-delta-note {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 4px 8px;
  border-left: 2px solid var(--accent2);
}

.units-summary {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.units-summary-title {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.units-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  border-bottom: 1px solid rgba(48,54,61,0.4);
  padding-bottom: 4px;
}
.units-summary-label { color: var(--text-dim); }
.units-summary-value {
  font-family: 'Consolas', monospace;
  color: var(--accent);
  font-weight: 600;
}

/* ─── MAP Range card extras ──────────────────────────────────────────────── */
.input-select-sm { width: 120px; }
.warn      { color: var(--yellow); font-size: 11px; }
.boost     { color: var(--green);  font-size: 11px; }
.warn-text { color: var(--yellow) !important; }
.map-validation-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--red);
  margin-top: 6px;
}
.map-validation-warn {
  background: rgba(234,179,8,0.08);
  border: 1px solid rgba(234,179,8,0.25);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--yellow);
  margin-top: 4px;
}

/* ─── Supercharger Page ──────────────────────────────────────────────────── */
.sc-type-filter { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }

.sc-type-badge {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
  font-weight: 600;
}
.sc-type-roots       { background: rgba(249,115,22,0.15); color: #f97316; }
.sc-type-tvs         { background: rgba(59,130,246,0.15); color: #3b82f6; }
.sc-type-twinscrew   { background: rgba(34,197,94,0.15);  color: #22c55e; }
.sc-type-centrifugal { background: rgba(234,179,8,0.15);  color: #eab308; }

.sc-boost-preview { display: flex; flex-direction: column; gap: 5px; }
.sc-boost-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Consolas', monospace;
  font-size: 11px;
}
.sc-boost-rpm { width: 40px; color: var(--text-muted); text-align: right; flex-shrink: 0; }
.sc-boost-bar-wrap {
  flex: 1;
  height: 12px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.sc-boost-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #22c55e, #f97316);
  border-radius: 2px;
  transition: width 0.3s;
}
.sc-boost-val { width: 38px; color: var(--text-dim); flex-shrink: 0; }

/* ─── Nav active dot (forced induction indicator) ───────────────────────── */
.nav-active-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 0 4px var(--green);
}

/* ─── Dyno Toolbar ───────────────────────────────────────────────────────── */
.dyno-toolbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dyno-toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.dyno-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dyno-toolbar-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.dyno-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
}
.dyno-check-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.dyno-check-label input { accent-color: var(--accent); }
.dyno-rerun-btn { margin-left: auto; }

.dyno-setting-group {
  display: flex;
  align-items: center;
  gap: 7px;
}
.dyno-setting-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 70px;
}
.dyno-setting-val {
  font-family: 'Consolas', monospace;
  font-size: 11px;
  color: var(--accent);
  min-width: 80px;
}
.dyno-setting-hint {
  font-size: 10px;
  color: var(--text-muted);
}
.dyno-slider {
  width: 120px;
  accent-color: var(--accent);
}

/* ─── Dyno Stats Bar ─────────────────────────────────────────────────────── */
.dyno-stat-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 10px 16px;
  gap: 4px;
}
.dyno-stat-meta {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── Taller Chart ───────────────────────────────────────────────────────── */
.chart-container-tall {
  /* Full width of main-content, tall enough to read clearly */
  padding: 16px 24px;
  height: 540px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.chart-container-tall canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ─── Project file open label-as-button ─────────────────────────────────── */
.project-file-label {
  cursor: pointer;
  user-select: none;
}
.project-file-label:hover { opacity: 0.85; }

/* ─── MBT Page parameter strip ───────────────────────────────────────────── */
.mbt-param-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-family: 'Consolas', monospace;
  font-size: 11px;
  color: var(--text-dim);
}
.mbt-param b   { color: var(--accent); font-weight: 700; }
.mbt-param-sep { color: var(--text-muted); }

/* ─── Table stats strip (AFR / IAT / ECR / MBT param strip) ─────────────── */
.table-stats-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-family: 'Consolas', monospace;
  font-size: 11px;
  color: var(--text-dim);
}
.table-stat b      { color: var(--accent); font-weight: 700; }
.table-stat-sep    { color: var(--text-muted); }

/* ─── Form hint text ─────────────────────────────────────────────────────── */
.form-hint {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
  padding: 0 2px 4px;
}

/* ─── MAP Range card — wider to fit pressure unit labels and hints ─────── */
.map-range-card {
  min-width: 420px;
}
.map-range-card .form-row label {
  width: 190px;  /* extra room for long labels like "MAP Max (kPa)" */
}
.map-range-card .unit-hint {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Dyno Calibration card — wider for long FMEP labels ────────────────── */
.dyno-calib-card {
  min-width: 400px;
}
.dyno-calib-card .form-row label {
  width: 200px;
}

/* ─── Manifold card — wider for type select and long labels ─────────────── */
.manifold-card {
  min-width: 420px;
}
.manifold-card .form-row label {
  width: 180px;
}
.manifold-card .input-select {
  width: 220px;
}

/* ─── Supercharger spec card — wider for type select ────────────────────── */
.sc-spec-card {
  min-width: 420px;
}
.sc-spec-card .form-row label {
  width: 180px;
}
.sc-spec-card .input-select {
  width: 220px;
}

/* ─── 3D Surface Page ────────────────────────────────────────────────────── */
.surface-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.surface-tab-group { display: flex; gap: 4px; }
.surface-tab {
  font-family: 'Consolas', monospace;
  font-size: 11px;
  padding: 5px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.12s;
}
.surface-tab:hover { background: var(--bg2); color: var(--text); }
.surface-tab-active {
  background: rgba(249,115,22,0.15);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.surface-toolbar-right { margin-left: auto; }
.surface-hint {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  color: var(--text-muted);
}
.surface-frame-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 135px);
  padding: 0;
}
.surface-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #0d1117;
  display: block;
}

/* ─── Inline cell editing ────────────────────────────────────────────────── */
.cell-editing { padding: 0 !important; }
.cell-edit-input {
  width: 100%;
  height: 100%;
  min-width: 48px;
  background: #0d1117;
  color: #ffd700;
  border: 2px solid #ffd700;
  border-radius: 2px;
  text-align: center;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 2px;
  outline: none;
}
.cell-edit-input::-webkit-inner-spin-button { opacity: 0; }
.edit-bar-hint {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
  font-style: italic;
}

/* ─── Full-width card — always spans all grid columns ───────────────────── */
.full-width-card {
  grid-column: 1 / -1;
}

/* ─── Engine page grid — explicit 2-col so full-width spans work reliably ── */
.engine-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 16px;
  padding: 16px;
  align-content: start;
}
.engine-grid .full-width-card {
  grid-column: 1 / 3;
}
@media (max-width: 720px) {
  .engine-grid {
    grid-template-columns: 1fr;
  }
  .engine-grid .full-width-card {
    grid-column: 1;
  }
}

/* ─── Combustion Chamber card — wider for hint text ─────────────────────── */
.chamber-card {
  min-width: 440px;
}
.chamber-card .form-row label {
  width: 185px;
}
.chamber-card .unit-hint {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Single-column grid — stacks cards vertically, no overlap possible ─── */
.single-col-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}
