/* ═══════════════════════════════════════════════════════════════
   ARKit — Design System
   Faithful port of the standalone HTML version
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  /* Surfaces — cool paper */
  --bg: #EEF2F7;
  --bg2: #E4EAF2;
  --surface: #FFFFFF;
  --surface2: #F6F8FC;

  /* Borders — cool slate */
  --border: #D4DCE6;
  --border2: #BCC6D4;

  /* Text */
  --text:  #111827;
  --text2: #4A5568;
  --text3: #8B95A6;

  /* Accent — ink blue */
  --accent:      #1E4FC2;
  --accent2:     #2A63DC;   /* hover */
  --accent-pale: #E4ECFA;

  /* Secondary semantic */
  --gold:       #0E7C9E;   /* (ora = cyan, nome mantenuto per compat) */
  --gold-pale:  #D6ECF3;
  --green:      #2F6D8A;
  --green-pale: #DCE8F0;
  --blue:       #3D3FAA;
  --blue-pale:  #DFE0F2;

  /* Errors */
  --error-bg: #FDE8E8;
  --error-br: #F5B5B5;
  --error-fg: #A42020;

  /* Radii */
  --radius: 12px;

  /* Shadows — ink-tinted */
  --shadow:    0 2px 12px rgba(17,24,39,0.08), 0 1px 3px rgba(17,24,39,0.06);
  --shadow-lg: 0 8px 32px rgba(17,24,39,0.12), 0 2px 8px rgba(17,24,39,0.08);

  /* Fonts */
  --font-sans: 'Instrument Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Instrument Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ── SHELL ────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    box-shadow: 2px 0 16px rgba(17,24,39,0.06);
}

.brand {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    column-gap: 10px;
    justify-content: start;
    padding-left: 15px;
}
.brand > .brand-sub { grid-column: 1 / -1; }

.logo-mark {
    width: 40px;
    aspect-ratio: 247 / 214;
    display: block;
    background: var(--accent);
    -webkit-mask: url('/images/logo_mark.png') center / contain no-repeat;
            mask: url('/images/logo_mark.png') center / contain no-repeat;
}

/* Su sfondo scuro / accent, riverte a bianco */
.dark-bg .logo-mark,
.accent-bg .logo-mark { background: #FFFFFF; }

.brand-name {
    font-family: var(--font-sans);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text);
}
.brand-it {
    color: var(--accent);
    font-style: italic;
    font-weight: 700;
}
.brand-sub {
    display: block;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1;
    margin-top: 3px;
    margin-left: 10px;
}

.sidebar-section { padding: 12px 10px 6px; }
.sidebar-label {
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.10em; text-transform: uppercase;
    color: var(--text3); padding: 0 6px 6px;
}

.nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; border-radius: 8px;
    text-decoration: none; font-size: 13px; font-weight: 500;
    color: var(--text2); cursor: pointer;
    transition: all 0.15s; margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active, .nav-item ::deep(.active) {
    background: var(--accent-pale); color: var(--accent); font-weight: 600;
}
.nav-item.disabled { opacity: 0.5; pointer-events: none; }

/* Blazor NavLink active state */
.nav-item.active-nav { background: var(--accent-pale); color: var(--accent); font-weight: 600; }
a.nav-item.active    { background: var(--accent-pale); color: var(--accent); font-weight: 600; }

.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

.nav-badge {
    margin-left: auto; font-size: 9px; font-weight: 600;
    padding: 2px 6px; border-radius: 4px; letter-spacing: 0.04em;
}
.badge-soon { background: var(--bg2); color: var(--text3); }
.badge-new  { background: var(--accent-pale); color: var(--accent); }
.badge { display:inline-block; font-size:11px; font-weight:600; padding:2px 8px; border-radius:4px; letter-spacing:0.02em; }
.badge-primary { background:var(--accent-pale); color:var(--accent); }
.badge-secondary { background:var(--bg2); color:var(--text3); }

.sidebar-footer {
    margin-top: auto; padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 8px;
}
.version-tag {
    display: flex; align-items: center; gap: 6px;
    font-family: 'DM Mono', monospace; font-size: 10px;
    color: var(--text3);
}
.status-dot {
    width: 6px; height: 6px;
    border-radius: 50%; background: var(--green);
}
.lang-select {
    padding: 5px 8px;
    border: 1px solid var(--border2); border-radius: 6px;
    background: var(--surface2); font-size: 12px;
    font-family: 'Instrument Sans', sans-serif;
    color: var(--text2); cursor: pointer;
}

/* ── Sidebar collapse toggle (desktop) ──────────────────────── */
.sidebar-collapse-btn {
    display: none; /* hidden on mobile */
    align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%;
    border: 1px solid var(--border2); background: var(--surface2);
    color: var(--text3); font-size: 12px; cursor: pointer;
    position: absolute; right: -12px; top: 20px; z-index: 101;
    transition: all 0.15s;
}
.sidebar-collapse-btn:hover { background: var(--bg); color: var(--accent); border-color: var(--accent); }

@media (min-width: 769px) {
    .sidebar-collapse-btn { display: flex; }
    .sidebar { transition: width 0.2s ease; }
    .sidebar.collapsed { width: 60px; overflow: hidden; }
    .sidebar.collapsed .logo-text-group,
    .sidebar.collapsed .sidebar-label,
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .nav-badge,
    .sidebar.collapsed .version-tag span,
    .sidebar.collapsed .sidebar-footer { display: none; }
    .sidebar.collapsed .sidebar-logo { padding: 18px 12px 14px; justify-content: center; }
    .sidebar.collapsed .nav-item { justify-content: center; padding: 8px; }
    .sidebar.collapsed .nav-icon { width: auto; }
    .sidebar.collapsed .sidebar-section { padding: 12px 6px 6px; }
    .main { transition: margin-left 0.2s ease; }
    .main.sidebar-is-collapsed { margin-left: 60px; }
}

/* ── MAIN ─────────────────────────────────────────────────── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1; display: flex; flex-direction: column;
    height: 100vh; overflow: hidden;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.topbar {
    height: 48px; display: flex; align-items: center;
    padding: 0 20px; gap: 12px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.breadcrumb { display: flex; align-items: center; gap: 6px; flex: 1; }
.breadcrumb-home { font-size: 12px; color: var(--text3); }
.breadcrumb-sep  { font-size: 12px; color: var(--text3); }
.breadcrumb-current { font-size: 13px; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; gap: 6px; }

/* ── CONTENT ──────────────────────────────────────────────── */
.content {
    padding: 16px 20px;
    flex: 1; overflow-y: auto; min-height: 0;
}

/* ── PAGE HEADER ──────────────────────────────────────────── */
.page-header {
    display: flex; align-items: flex-start;
    gap: 20px; margin-bottom: 20px;
    animation: fadeUp 0.4s ease both;
}
.page-header-icon {
    font-size: 28px; flex-shrink: 0;
    margin-top: 2px;
}
.page-title {
    font-family: 'Instrument Sans', sans-serif;
    font-size: 26px; font-weight: 700;
    letter-spacing: -0.5px; color: var(--text); line-height: 1.15;
}
.page-desc { font-size: 13px; color: var(--text2); margin-top: 4px; line-height: 1.5; }

/* ── PANEL ────────────────────────────────────────────────── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel-header {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.panel-title { font-weight: 600; color: var(--text); font-size: 13px; }
.panel-title-mono {
    font-family: 'DM Mono', monospace; font-size: 11px;
    color: var(--text3); margin-left: auto;
}
.panel-body { padding: 12px 16px; }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 8px; border: 1px solid transparent;
    font-size: 13px; font-weight: 500; cursor: pointer;
    font-family: 'Instrument Sans', sans-serif;
    transition: all 0.15s;
}
.btn-primary {
    background: var(--accent); color: white; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent2); }
.btn-ghost {
    background: var(--surface2); color: var(--text2);
    border-color: var(--border2);
}
.btn-ghost:hover { background: var(--bg2); color: var(--text); }

/* ── BOX SIMULATOR LAYOUT ─────────────────────────────────── */
.tool-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 14px; height: 100%; align-items: stretch;
}
.inputs-col {
    display: flex; flex-direction: column;
    gap: 10px; min-height: 0;
}
.results-right {
    display: flex; flex-direction: column;
    gap: 10px; min-height: 0; overflow-y: auto;
}
.chart-panel {
    flex: 1 1 auto;
    max-height: calc((100vh - 90px) * 0.62);
    min-height: 460px; display: flex; flex-direction: column; overflow: hidden;
}
.zobel-chart-panel { max-height: calc((100vh - 90px) * 0.5301); }
.chart-panel-body {
    flex: 1 1 0; min-height: 0;
    display: flex; flex-direction: column; overflow: hidden; padding: 10px 14px;
}
.chart-area {
    flex: 1 1 0; min-height: 0;
    border-radius: 8px; background: var(--bg2);
    position: relative; overflow: hidden;
}
.chart-area canvas { display: block; width: 100%; height: 100%; }
.chart-tabs-row {
    display: flex; gap: 4px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.chart-tab {
    padding: 4px 10px; border-radius: 6px;
    font-size: 11px; font-weight: 500; cursor: pointer;
    color: var(--text3); transition: all 0.15s;
}
.chart-tab:hover  { background: var(--bg2); color: var(--text); }
.chart-tab.active { background: var(--accent-pale); color: var(--accent); font-weight: 600; }

/* ── BOX TABS ─────────────────────────────────────────────── */
.box-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.box-tab {
    flex: 1; display: flex; align-items: center; justify-content: center;
    gap: 5px; padding: 7px; border-radius: 8px;
    border: 1px solid var(--border2);
    font-size: 12px; font-weight: 500; cursor: pointer;
    background: var(--surface2); color: var(--text2);
    transition: all 0.15s;
}
.box-tab.active {
    background: var(--accent-pale); border-color: rgba(30,79,194,0.35);
    color: var(--accent); font-weight: 600;
}

/* ── ALIGNMENT SELECTOR ───────────────────────────────────── */
.alignment-row {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 10px;
}
.alignment-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px; font-weight: 500; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text3);
    white-space: nowrap;
}
.alignment-select {
    flex: 1; padding: 6px 8px;
    border: 1px solid var(--border2); border-radius: 6px;
    background: var(--surface2); font-size: 12px;
    font-family: 'DM Mono', monospace; color: var(--text);
    cursor: pointer; outline: none;
    transition: border-color 0.15s;
}
.alignment-select:focus { border-color: var(--accent); }
.alignment-error {
    font-size: 11px; color: #DC2626;
    background: #FEF2F2; border: 1px solid #FECACA;
    border-radius: 6px; padding: 6px 10px; margin-bottom: 8px;
}
.alignment-warning {
    font-size: 11px; color: #92610A;
    background: var(--gold-pale); border: 1px solid #E8D48A;
    border-radius: 6px; padding: 6px 10px; margin-bottom: 8px;
}

/* ── PARAM FIELDS ─────────────────────────────────────────── */
.section-title {
    font-size: 10px; font-weight: 600; letter-spacing: 0.10em;
    text-transform: uppercase; color: var(--text3);
    margin-bottom: 8px;
}
.param-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; margin-bottom: 8px;
}
.param-field label {
    display: block;
    font-family: 'DM Mono', monospace;
    font-size: 10px; font-weight: 500; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text3); margin-bottom: 3px;
}
.param-field input[type=number] {
    width: 100%; padding: 6px 8px;
    border: 1px solid var(--border2); border-radius: 6px;
    background: var(--surface2); font-size: 12px;
    font-family: 'DM Mono', monospace; color: var(--text);
    transition: border-color 0.15s; outline: none;
}
.param-field input[type=number]:focus { border-color: var(--accent); }
.param-unit { font-size: 9px; color: var(--text3); margin-left: 2px; }

/* ── TOGGLE SWITCH ───────────────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--border2); border-radius: 20px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: ""; position: absolute; height: 14px; width: 14px;
    left: 3px; bottom: 3px; background: var(--text);
    border-radius: 50%; transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }
.absorber-label { font-size: 12px; color: var(--text2); }

/* ── DRIVER CARD ──────────────────────────────────────────── */
.driver-load-btn {
    margin-left: auto; padding: 4px 10px;
    border: 1px solid var(--border2); border-radius: 6px;
    background: var(--surface2); font-size: 11px;
    font-family: 'Instrument Sans', sans-serif;
    color: var(--text2); cursor: pointer; transition: all 0.18s;
}
.driver-load-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.driver-info-name { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.driver-info-sub  { font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; margin-bottom: 10px; }

/* ── KPI GRID ─────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kpi-card {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 10px;
}
.kpi-label { font-size: 10px; color: var(--text3); margin-bottom: 2px; font-family: 'DM Mono', monospace; }
.kpi-value { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.1; }
.kpi-unit  { font-size: 11px; color: var(--text3); margin-left: 2px; font-weight: 400; }

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(17,24,39,0.45);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.modal-box {
    background: var(--surface); border-radius: 14px;
    box-shadow: var(--shadow-lg);
    width: min(560px, 95vw); max-height: 80vh;
    display: flex; flex-direction: column; overflow: hidden;
    animation: fadeUp 0.2s ease both;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: var(--text3); padding: 2px 6px;
    border-radius: 6px; line-height: 1; transition: background 0.15s;
}
.modal-close:hover { background: var(--bg2); color: var(--text); }
.modal-search { padding: 10px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-search input {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--border2); border-radius: 8px;
    font-size: 13px; font-family: 'Instrument Sans', sans-serif;
    background: var(--surface2); color: var(--text); outline: none;
}
.modal-search input:focus { border-color: var(--accent); }
.modal-list { flex: 1; overflow-y: auto; padding: 6px 8px; }

.db-row {
    padding: 11px 14px; border-radius: 7px;
    cursor: pointer; transition: background 0.15s;
    border-bottom: 1px solid #F0EDE8;
}
.db-row:hover { background: #F5F1EB; }
.db-row-name { font-size: 13px; color: var(--text); margin-bottom: 3px; }
.db-row-name strong { color: var(--accent); }
.db-row-specs { font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; }
.db-empty { padding: 20px; color: var(--text3); text-align: center; font-size: 13px; }

/* ── HOME PAGE ────────────────────────────────────────────── */
.home-hero {
    background: linear-gradient(135deg, var(--accent), var(--gold));        /* hero: ink-blue → cyan */
                

    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px 28px; margin-bottom: 24px;
}
.hero-lead { font-size: 14px; color: #FFFFFF; line-height: 1.6; margin-bottom: 0; }
.home-section { margin-bottom: 28px; }
.home-section-title {
    font-size: 11px; font-weight: 600; letter-spacing: 0.10em;
    text-transform: uppercase; color: var(--text3);
    margin: 0 0 10px;
}
.tool-grid-home {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.tool-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    cursor: pointer; text-decoration: none; color: inherit;
    display: block; position: relative; overflow: hidden;
    transition: all 0.22s; box-shadow: var(--shadow);
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tool-card.disabled { opacity: 0.5; pointer-events: none; }
.tool-card-icon {
    width: 44px; height: 44px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-bottom: 14px;
}
.icon-orange { background: var(--accent-pale); }
.icon-gold   { background: var(--gold-pale); }
.icon-blue   { background: var(--blue-pale); }
.icon-green  { background: var(--green-pale); }
.tool-card-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.tool-card-desc { font-size: 12px; color: var(--text2); line-height: 1.5; }
.tool-card-footer {
    display: flex; align-items: center;
    margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
}
.tool-card-tag {
    font-family: 'DM Mono', monospace; font-size: 9px;
    letter-spacing: 0.06em; color: var(--text3); text-transform: uppercase;
}
.tool-card-arrow { margin-left: auto; font-size: 14px; color: var(--text3); }

/* ── TUBE AMP MATCHER ─────────────────────────────────────── */
.tube-layout {
    display: grid; grid-template-columns: 300px 1fr;
    gap: 14px; height: 100%; align-items: stretch;
}
.tube-left {
    display: flex; flex-direction: column;
    gap: 10px; min-height: 0; overflow-y: auto;
}
.tube-right { display: flex; flex-direction: column; min-height: 0; }
.tube-right > .panel { max-height: calc((100vh - 90px) * 0.9); }
.tube-file-row { display: flex; align-items: center; gap: 8px; }
.tube-file-label { font-size: 12px; font-weight: 600; color: var(--text2); min-width: 80px; }
.tube-file-input { display: none; }
.tube-file-btn {
    display: inline-flex; align-items: center;
    padding: 5px 10px; background: var(--surface2);
    border: 1px solid var(--border2); border-radius: 6px;
    font-size: 11px; font-weight: 500; color: var(--text2);
    cursor: pointer; white-space: nowrap;
    font-family: 'Instrument Sans', sans-serif;
    transition: all 0.15s;
}
.tube-file-btn:hover { background: var(--bg2); color: var(--text); }
.tube-file-name {
    font-size: 10px; font-family: 'DM Mono', monospace;
    color: var(--text3); overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; min-width: 0; flex: 1;
}
.tube-file-name.loaded { color: var(--green); font-weight: 600; }
.tube-topo-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 6px; margin-bottom: 4px;
}
.tube-topo-card {
    border: 1px solid var(--border2); border-radius: 7px;
    padding: 7px 4px; text-align: center; cursor: pointer;
    background: var(--surface2); transition: all 0.15s;
}
.tube-topo-card:hover  { border-color: var(--accent); }
.tube-topo-card.active { background: var(--accent-pale); border-color: rgba(30,79,194,0.4); }
.tube-topo-name { font-size: 12px; font-weight: 700; color: var(--text); }
.tube-topo-card.active .tube-topo-name { color: var(--accent); }
.tube-topo-sub { font-size: 9px; color: var(--text3); margin-top: 2px; font-family: 'DM Mono', monospace; }
.tube-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tube-kpi {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 10px;
}
.kpi-trend { font-size: 10px; color: var(--text3); }
.tube-chart-tabs {
    display: flex; gap: 4px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.chart-nodata {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 8px;
    color: var(--text3); font-size: 13px; pointer-events: none;
}

/* ── TUBE LOADLINE PAGE ──────────────────────────────────── */
.loadline-layout {
    display: grid; grid-template-columns: 320px 1fr;
    gap: 14px; height: 80vh; align-items: stretch;
}
.loadline-left {
    display: flex; flex-direction: column;
    gap: 10px; min-height: 0; overflow-y: auto;
}
.loadline-right { display: flex; flex-direction: column; min-height: 0; }
.form-select {
    width: 100%; padding: 7px 10px;
    border: 1px solid var(--border2); border-radius: 6px;
    background: var(--surface2); font-size: 12px;
    font-family: 'DM Mono', monospace; color: var(--text);
    cursor: pointer; outline: none;
    transition: border-color 0.15s;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239A948C' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center;
    padding-right: 28px;
}
.form-select:focus { border-color: var(--accent); }
.form-select:disabled { opacity: 0.5; cursor: not-allowed; }
.kpi-warn { color: var(--accent) !important; }

/* ── DRIVER DATABASE PAGE ─────────────────────────────────── */
.dbpage-toolbar {
    display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.dbpage-search {
    flex: 1; padding: 8px 14px; border: 1px solid var(--border2);
    border-radius: 8px; font-size: 13px;
    font-family: 'Instrument Sans', sans-serif;
    background: var(--surface); color: var(--text); outline: none;
}
.dbpage-search:focus { border-color: var(--accent); }
.dbpage-filter {
    padding: 8px 12px; border: 1px solid var(--border2);
    border-radius: 8px; font-size: 12px;
    font-family: 'Instrument Sans', sans-serif;
    background: var(--surface2); color: var(--text); cursor: pointer; outline: none;
}
.dbpage-count { font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; margin-left: auto; }
.dbpage-grid { width: 100%; border-collapse: collapse; font-size: 12px; }
.dbpage-grid thead tr { background: var(--surface2); border-bottom: 2px solid var(--border2); }
.dbpage-grid th {
    padding: 9px 10px; text-align: left;
    font-family: 'DM Mono', monospace; font-size: 10px;
    font-weight: 600; letter-spacing: 0.06em; color: var(--text2);
    text-transform: uppercase; cursor: pointer; user-select: none; white-space: nowrap;
}
.dbpage-grid th:hover { color: var(--accent); }
.dbpage-grid td {
    padding: 8px 10px; border-bottom: 1px solid var(--border);
    font-family: 'DM Mono', monospace; font-size: 11px;
}
.td-brand { font-family: 'Instrument Sans', sans-serif !important; font-size: 12px !important; font-weight: 600 !important; color: var(--text2); }
.td-model { font-family: 'Instrument Sans', sans-serif !important; font-size: 12px !important; font-weight: 700 !important; }
.dbpage-grid tbody tr:hover td { background: var(--accent-pale); }
.db-load-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 9px; background: var(--surface2);
    border: 1px solid var(--border2); border-radius: 5px;
    font-size: 11px; font-family: 'Instrument Sans', sans-serif;
    color: var(--text2); cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.db-load-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.db-empty-row { padding: 20px; text-align: center; color: var(--text3); }
.sort-arrow { margin-left: 3px; opacity: 0.4; font-size: 10px; }
.sort-arrow.active { opacity: 1; color: var(--accent); }

/* ── MISC ─────────────────────────────────────────────────── */
.alert-error {
    background: #FEF2F2; border: 1px solid #FECACA;
    color: #DC2626; border-radius: 8px; padding: 10px 14px; font-size: 13px;
}
.loading-splash {
    height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 16px;
    color: var(--text3); font-size: 14px;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── AUTH / USER MENU ─────────────────────────────────── */
.user-menu {
    display: flex; align-items: center; gap: 8px;
}
.user-name {
    font-size: 13px; font-weight: 600; color: var(--text);
}
.btn-sm {
    padding: 4px 10px; font-size: 12px;
}

/* ── AUTH MODAL ──────────────────────────────────────── */
.auth-modal {
    width: min(420px, 95vw);
}
.modal-body {
    padding: 18px 22px;
}
.auth-field {
    margin-bottom: 14px;
}
.auth-field label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text2); margin-bottom: 5px;
}
.auth-field input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border2); border-radius: 8px;
    font-size: 13px; font-family: 'Instrument Sans', sans-serif;
    background: var(--surface2); color: var(--text); outline: none;
    transition: border-color 0.15s;
}
.auth-field input:focus { border-color: var(--accent); }
.auth-field-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.auth-error {
    font-size: 12px; color: #DC2626;
    background: #FEF2F2; border: 1px solid #FECACA;
    border-radius: 6px; padding: 8px 12px; margin-bottom: 12px;
}
.auth-submit {
    width: 100%; justify-content: center; padding: 10px;
    margin-bottom: 12px;
}
.auth-switch {
    text-align: center; font-size: 12px; color: var(--text3);
}
.auth-switch a {
    color: var(--accent); font-weight: 600; text-decoration: none;
}
.auth-switch a:hover { text-decoration: underline; }

/* ── SAVE FORM ───────────────────────────────────────── */
.save-form {
    display: flex; flex-direction: column; gap: 2px;
}
.save-success {
    font-size: 12px; color: var(--green);
    background: var(--green-pale); border: 1px solid #A3D9B1;
    border-radius: 6px; padding: 8px 12px; margin-bottom: 8px;
}

/* ── PROJECTS PAGE ───────────────────────────────────── */
.projects-section { margin-bottom: 24px; }
.projects-row-wrap { position: relative; }
.projects-row {
    display: flex; gap: 14px;
    overflow-x: auto; overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    padding: 4px 2px 10px;
    scrollbar-width: thin;
}
.projects-row::-webkit-scrollbar { height: 8px; }
.projects-row::-webkit-scrollbar-thumb {
    background: var(--border2); border-radius: 4px;
}
.projects-row::-webkit-scrollbar-track { background: transparent; }
.projects-row > .project-card {
    flex: 0 0 280px;
    scroll-snap-align: start;
}
.projects-scroll-btn {
    position: absolute; top: calc(50% - 5px); transform: translateY(-50%);
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--surface); border: 1px solid var(--border);
    cursor: pointer; z-index: 2;
    box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: var(--text2);
    line-height: 1; padding: 0;
    transition: background 0.15s, color 0.15s;
}
.projects-scroll-btn:hover { background: var(--surface2); color: var(--text); }
.projects-scroll-left  { left: -10px; }
.projects-scroll-right { right: -10px; }
.project-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); transition: all 0.18s;
    display: flex; flex-direction: column;
}
.project-card:hover { box-shadow: var(--shadow-lg); }
.project-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.project-card-type {
    font-family: 'DM Mono', monospace; font-size: 9px;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--accent); background: var(--accent-pale);
    padding: 2px 8px; border-radius: 4px; font-weight: 600;
}
.project-delete-btn {
    background: none; border: none; cursor: pointer;
    font-size: 14px; color: var(--text3); padding: 2px 6px;
    border-radius: 6px; line-height: 1; transition: all 0.15s;
}
.project-delete-btn:hover { background: #FEF2F2; color: #DC2626; }
.project-card-name {
    font-size: 15px; font-weight: 700; color: var(--text);
    margin-bottom: 4px;
}
.project-card-desc {
    font-size: 12px; color: var(--text2); margin-bottom: 8px;
    line-height: 1.4;
}
.project-card-info {
    display: flex; flex-direction: column; gap: 2px;
    font-size: 11px; color: var(--text3);
    font-family: 'DM Mono', monospace;
    margin-bottom: 12px;
}
.project-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: auto; padding-top: 10px;
    border-top: 1px solid var(--border);
}
.project-card-date {
    font-size: 10px; color: var(--text3);
    font-family: 'DM Mono', monospace;
}

/* ── Admin table ───────────────────────────────────────── */
.admin-table {
    width: 100%; border-collapse: collapse;
    font-size: 13px;
}
.admin-table th {
    text-align: left; padding: 10px 12px;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text3); border-bottom: 1px solid var(--border1);
    background: var(--bg2);
}
.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border1);
    color: var(--text1);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table-id { color: var(--text3); font-family: 'DM Mono', monospace; font-size: 12px; }
.admin-table-sortable th { cursor: pointer; user-select: none; white-space: nowrap; }
.admin-table-sortable th:hover { color: var(--accent); }

.valve-type-badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
}
.valve-type-badge.power {
    background: rgba(232, 121, 36, 0.15); color: var(--accent);
}
.valve-type-badge.signal {
    background: rgba(74, 144, 226, 0.15); color: #4a90e2;
}

.role-select {
    background: var(--bg2); color: var(--text1);
    border: 1px solid var(--border1); border-radius: 4px;
    padding: 3px 6px; font-size: 12px;
    cursor: pointer;
}
.role-badge {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
}
.role-admin { background: var(--accent); color: white; }

.btn-danger {
    background: #dc3545; color: white; border: none;
    padding: 4px 10px; border-radius: 4px; font-size: 12px;
    cursor: pointer;
}
.btn-danger:hover { background: #c82333; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── HELP PANEL ──────────────────────────────────────────── */
.help-panel {
    position: fixed; bottom: 60px; right: 20px; z-index: 900;
    width: min(380px, calc(100vw - 40px));
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    animation: fadeUp 0.2s ease both;
    max-height: 60vh; overflow-y: auto;
}
.help-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
}
.help-panel-title {
    font-size: 14px; font-weight: 700; color: var(--text);
}
.help-panel-close {
    background: none; border: none; cursor: pointer;
    font-size: 16px; color: var(--text3); padding: 2px 6px;
    border-radius: 6px; line-height: 1; transition: all 0.15s;
}
.help-panel-close:hover { background: var(--bg2); color: var(--text); }
.help-panel-body { padding: 14px 16px; }
.help-steps {
    padding-left: 20px; margin: 0 0 12px;
    font-size: 13px; color: var(--text2); line-height: 1.7;
}
.help-steps li { margin-bottom: 4px; }
.help-info {
    font-size: 12px; color: var(--text2); line-height: 1.6;
    background: var(--blue-pale); border: 1px solid #C8D8F0;
    border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
}
.help-tip {
    font-size: 12px; color: var(--text2); line-height: 1.6;
    background: var(--gold-pale); border: 1px solid #E8D48A;
    border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
}
.help-toggle {
    position: fixed; bottom: 16px; right: 20px; z-index: 901;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--surface); border: 1px solid var(--border2);
    box-shadow: var(--shadow); cursor: pointer;
    font-size: 16px; font-weight: 700; color: var(--text2);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.help-toggle:hover { background: var(--accent-pale); color: var(--accent); border-color: var(--accent); }
.help-toggle.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ── HELP PAGE (full-page help, e.g. Zobel) ────────────── */
.help-page {
    max-width: 780px; margin: 0 auto;
    display: flex; flex-direction: column; gap: 8px;
}
.help-section {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 24px;
}
.help-section-title {
    font-size: 16px; font-weight: 700; color: var(--text);
    margin: 0 0 10px;
}
.help-section-text {
    font-size: 14px; color: var(--text2); line-height: 1.75;
    margin: 0 0 10px;
}
.help-section-text:last-child { margin-bottom: 0; }
.help-formula-box {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 8px; padding: 14px 20px; margin: 12px 0;
    text-align: center;
}
.help-formula {
    font-family: 'Courier New', Courier, monospace;
    font-size: 15px; font-weight: 600; color: var(--accent);
    line-height: 1.8;
}
.help-circuit-ascii {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 8px; padding: 12px 16px; margin: 12px 0;
    overflow-x: auto;
}
.help-circuit-ascii pre {
    margin: 0; font-size: 13px; line-height: 1.4;
    color: var(--text2); white-space: pre;
}
.help-page-nav {
    text-align: center; padding: 16px 0 8px;
}

/* ── T/S GUIDE PAGE ──────────────────────────────────────── */
.guide-intro {
    background: linear-gradient(135deg, var(--accent-pale), var(--gold-pale));
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px 24px; margin-bottom: 24px;
    font-size: 14px; color: var(--text2); line-height: 1.7;
}
.guide-section { margin-bottom: 28px; }
.guide-section-title {
    font-size: 18px; font-weight: 700; color: var(--text);
    margin-bottom: 6px;
}
.guide-section-desc {
    font-size: 13px; color: var(--text2); line-height: 1.5;
    margin-bottom: 16px;
}
.guide-param-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.guide-param-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); transition: all 0.18s;
}
.guide-param-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.guide-param-header {
    display: flex; align-items: baseline; gap: 8px;
    margin-bottom: 6px;
}
.guide-param-symbol {
    font-family: 'DM Mono', monospace; font-size: 20px;
    font-weight: 700; color: var(--accent);
}
.guide-param-unit {
    font-family: 'DM Mono', monospace; font-size: 12px;
    color: var(--text3);
}
.guide-param-name {
    font-size: 13px; font-weight: 600; color: var(--text);
    margin-bottom: 6px;
}
.guide-param-desc {
    font-size: 12px; color: var(--text2); line-height: 1.6;
    margin-bottom: 10px;
}
.guide-param-range {
    display: flex; align-items: center; gap: 6px;
    padding-top: 8px; border-top: 1px solid var(--border);
}
.guide-range-label {
    font-family: 'DM Mono', monospace; font-size: 10px;
    color: var(--text3); text-transform: uppercase;
    letter-spacing: 0.06em;
}
.guide-range-value {
    font-family: 'DM Mono', monospace; font-size: 12px;
    font-weight: 600; color: var(--text);
}

/* ── FORMULA CARD ────────────────────────────────────────── */
.guide-formula-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 24px;
    box-shadow: var(--shadow); text-align: center;
}
.guide-formula {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.formula-frac {
    display: inline-flex; flex-direction: column;
    align-items: center; gap: 2px;
}
.formula-num {
    font-family: 'DM Mono', monospace; font-size: 16px;
    font-weight: 600; color: var(--text);
    border-bottom: 2px solid var(--border2); padding-bottom: 2px;
}
.formula-den {
    font-family: 'DM Mono', monospace; font-size: 16px;
    font-weight: 700; color: var(--accent);
}
.formula-eq, .formula-plus {
    font-family: 'DM Mono', monospace; font-size: 20px;
    font-weight: 600; color: var(--text2);
}
.guide-formula-explain {
    font-size: 13px; color: var(--text2); line-height: 1.6;
    max-width: 600px; margin: 0 auto;
}

/* ── ENCLOSURE GUIDE ─────────────────────────────────────── */
.guide-enclosure-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.guide-enc-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    box-shadow: var(--shadow);
}
.guide-enc-card.sealed { border-left: 3px solid var(--accent); }
.guide-enc-card.ported { border-left: 3px solid var(--gold); }
.guide-enc-icon { font-size: 24px; margin-bottom: 8px; }
.guide-enc-name {
    font-size: 15px; font-weight: 700; color: var(--text);
    margin-bottom: 10px;
}
.guide-enc-list {
    padding-left: 18px; margin: 0;
    font-size: 13px; color: var(--text2); line-height: 1.8;
}

/* ── CTA ─────────────────────────────────────────────────── */
.guide-cta {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 24px;
    text-align: center; margin-bottom: 20px;
}
.guide-cta p {
    font-size: 14px; color: var(--text2); margin-bottom: 14px;
}
.guide-cta-buttons {
    display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}

/* ── PURPLE CARD (Home) ──────────────────────────────────── */
.icon-purple { background: #F0E8FA; }

/* ── CROSSOVER DESIGNER ───────────────────────────────────── */

/* Header with title + action buttons */
.xover-page-header { gap: 14px; align-items: center; }
.xover-page-info { flex: 1; min-width: 0; }
.xover-header-actions {
    display: flex; align-items: center; gap: 6px;
    flex-wrap: nowrap; justify-content: flex-end; flex-shrink: 0;
}
.xover-header-actions .btn,
.xover-header-actions .btn-sm {
    font-size: 12px; padding: 6px 10px;
    flex: 0 0 auto; width: auto;     /* override the global .btn-primary { width:100% } */
    white-space: nowrap;
}
.xover-action-label { display: inline; }

.xover-save-popover {
    margin-bottom: 10px; max-width: 480px; margin-left: auto;
    border: 1px solid var(--border);
}

/* Two-column layout: main work area + side panels */
.xover-layout-v2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 480px;
    gap: 14px;
    height: calc(100vh - 180px);
    align-items: stretch;
    max-width: 100%; overflow: hidden;
}
.xover-main-panel {
    display: flex; flex-direction: column;
    min-height: 0; min-width: 0; overflow: hidden;
}
.xover-config-area {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 4px 6px 4px 0;
    display: flex; flex-direction: column; gap: 8px;
}
.xover-config-toolbar {
    display: flex; gap: 6px; align-items: center;
    padding: 0 2px;
}
.xover-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 10px;
    align-content: start;
}

/* Driver / mic card */
.xover-driver-card {
    margin-bottom: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.xover-driver-card-header {
    cursor: pointer;
    user-select: none;
}
.xover-driver-card-header:hover { background: var(--bg2); }
.xover-driver-card-body {
    padding: 10px 12px 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.xover-driver-badge {
    font-family: 'DM Mono', monospace; font-size: 10px;
    padding: 1px 6px; border-radius: 3px;
    border: 1px solid transparent;
}
.xover-badge-ok {
    background: rgba(40,167,69,0.12);
    color: var(--green); border-color: rgba(40,167,69,0.25);
}
.xover-mic-card {
    grid-column: 1 / -1;       /* mic spans full row */
    max-width: 760px;
}
.xover-baffle-card {
    grid-column: 1 / -1;       /* baffle spans full row */
}
.xover-baffle-body {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 1.2fr);
    gap: 16px;
    align-items: start;
}
.xover-baffle-form { display: flex; flex-direction: column; gap: 8px; }
.xover-baffle-vis {
    display: flex; flex-direction: column; gap: 4px;
    align-items: center; min-width: 0;
}
.xover-baffle-svg {
    width: 100%;
    max-height: 280px;
    background: var(--bg2);
    border-radius: 6px;
}
.xover-baffle-legend {
    display: flex; gap: 12px; font-size: 10px;
    color: var(--text3); font-family: 'DM Mono', monospace;
}
@media (max-width: 720px) {
    .xover-baffle-body { grid-template-columns: 1fr; }
}

/* Form rows: horizontal field groups */
.xover-form-row {
    display: flex; gap: 8px; align-items: flex-end;
}
.xover-form-row > * { min-width: 0; }
.xover-field {
    display: flex; flex-direction: column; gap: 3px;
    flex: 1 1 0; min-width: 0;
}
.xover-form-label {
    font-size: 10px; color: var(--text3);
    text-transform: uppercase; letter-spacing: 0.5px;
    font-weight: 600;
}
.xover-form-input {
    width: 100%; padding: 5px 8px;
    border: 1px solid var(--border2); border-radius: 6px;
    font-size: 12px; font-family: 'DM Mono', monospace;
    background: var(--surface2); color: var(--text);
    box-sizing: border-box;
}
.xover-form-input:focus {
    outline: none; border-color: var(--accent);
}
.xover-form-btn {
    flex-shrink: 0; padding: 5px 10px; font-size: 12px;
}
.xover-input-with-unit {
    display: flex; align-items: center; gap: 4px;
}
.xover-input-with-unit .xover-form-input { flex: 1; }
.xover-input-with-unit .param-unit {
    font-size: 11px; color: var(--text3); flex-shrink: 0;
}

/* File picker (compact) */
.xover-file-cell {
    display: flex; flex-direction: column; gap: 3px;
    flex: 1 1 0; min-width: 0;
}
.xover-file-btn {
    display: inline-flex; align-items: center; justify-content: flex-start;
    padding: 5px 10px; border: 1px solid var(--border2);
    border-radius: 6px; cursor: pointer; font-size: 11px;
    font-family: 'DM Mono', monospace;
    background: var(--surface2); color: var(--text2);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: all 0.15s;
}
.xover-file-btn:hover { border-color: var(--accent); color: var(--text); }
.xover-file-btn.loaded {
    color: var(--green); border-color: rgba(40,167,69,0.4);
    background: rgba(40,167,69,0.06);
}

.xover-checkbox-row {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text2); cursor: pointer;
}
.xover-checkbox-row input[type=checkbox] {
    accent-color: var(--accent); width: 14px; height: 14px;
}
.xover-remove-btn { color: #DC2626; font-size: 11px; }
.xover-remove-btn:hover { background: #FEF2F2; }

/* Right column: stacked freq + impedance side panels */
.xover-side-panels {
    display: flex; flex-direction: column; gap: 10px;
    min-height: 0; min-width: 0;
}
.xover-side-panel {
    flex: 1 1 50%; min-height: 0; display: flex; flex-direction: column;
    overflow: hidden;
}
.xover-side-header { gap: 6px; }
.xover-side-action {
    background: none; border: 1px solid var(--border2); cursor: pointer;
    color: var(--text3); padding: 2px 8px; border-radius: 6px;
    font-size: 14px; line-height: 1; transition: all 0.15s;
}
.xover-side-action:hover { background: var(--bg2); color: var(--text); }

/* Tabs that only appear when narrow layout (single column) is active */
.xover-tab-narrow-only { display: none; }

/* Expanded chart modal */
.xover-expand-modal {
    background: var(--surface); border-radius: 14px;
    box-shadow: var(--shadow-lg);
    width: min(1200px, 95vw); height: min(800px, 90vh);
    display: flex; flex-direction: column; overflow: hidden;
    animation: fadeUp 0.2s ease both;
}
.xover-expand-body {
    flex: 1; min-height: 0; display: flex; flex-direction: column;
    padding: 12px 16px; overflow: hidden;
}

/* Hide button text labels when header gets crowded — keep icons only */
@media (max-width: 1500px) {
    .xover-action-label { display: none; }
}

/* Narrow fallback (<1280px): hide side panels, show all tabs in main */
@media (max-width: 1279px) {
    .xover-layout-v2 {
        grid-template-columns: 1fr;
    }
    .xover-side-panels { display: none; }
    .xover-tab-narrow-only { display: inline-block; }
}

.xover-driver-panel { margin-bottom: 10px; }
.xover-color-dot {
    width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
}

.xover-frd-grid {
    display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px;
}
.xover-frd-row {
    display: flex; align-items: center; gap: 6px;
}
.xover-frd-angle {
    font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 600;
    color: var(--text2); min-width: 32px; text-align: right;
}

.xover-comp-row {
    display: flex; align-items: center; gap: 5px;
    margin-bottom: 5px; padding: 4px 6px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px;
}
.xover-comp-pos {
    font-size: 14px; font-weight: 700; color: var(--text3);
    width: 18px; text-align: center; flex-shrink: 0;
}
.xover-comp-select {
    width: 36px; padding: 3px 4px; border: 1px solid var(--border2);
    border-radius: 4px; font-size: 12px; font-weight: 700;
    font-family: 'DM Mono', monospace; background: var(--surface);
    color: var(--text); cursor: pointer;
}
.xover-comp-value {
    flex: 1; padding: 3px 6px; border: 1px solid var(--border2);
    border-radius: 4px; font-size: 12px;
    font-family: 'DM Mono', monospace; background: var(--surface);
    color: var(--text); min-width: 0;
}
.xover-comp-unit {
    min-width: 22px; text-align: center;
}
.xover-comp-del {
    background: none; border: none; cursor: pointer;
    font-size: 15px; color: var(--text3); padding: 0 4px;
    border-radius: 4px; line-height: 1; transition: all 0.15s;
}
.xover-comp-del:hover { color: #DC2626; background: #FEF2F2; }

.xover-legend {
    display: flex; flex-wrap: wrap; gap: 10px;
    padding-top: 8px; border-top: 1px solid var(--border);
    margin-top: 8px;
}
.xover-legend-item {
    display: flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 500; color: var(--text2);
}
.xover-legend-swatch {
    width: 14px; height: 3px; border-radius: 2px; flex-shrink: 0;
}

.xover-param-row {
    display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
}
.xover-param-input {
    flex: 1; padding: 5px 8px; border: 1px solid var(--border2);
    border-radius: 6px; font-size: 12px; font-family: 'DM Mono', monospace;
    background: var(--surface2); color: var(--text); min-width: 0;
}
.xover-param-grid {
    display: grid; grid-template-columns: auto 1fr auto;
    gap: 4px 6px; align-items: center; margin-bottom: 8px;
}
.xover-param-label {
    font-size: 11px; color: var(--text3); min-width: 24px;
}

.xover-angle-toolbar {
    display: flex; gap: 4px; padding: 6px 0 4px; flex-wrap: wrap;
}
.xover-angle-toggle {
    padding: 4px 12px; border: 1px solid var(--border2); border-radius: 6px;
    background: var(--surface2); color: var(--text2); font-size: 12px;
    font-family: 'DM Mono', monospace; font-weight: 600; cursor: pointer;
    transition: all 0.15s;
}
.xover-angle-toggle:hover {
    border-color: var(--accent); color: var(--accent);
}
.xover-angle-toggle.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
}

/* ── Wizard radio buttons ────────────────────────── */
.wizard-radio {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; margin-bottom: 6px;
    border: 1px solid var(--border2); border-radius: 8px;
    cursor: pointer; font-size: 13px; color: var(--text);
    background: var(--surface2); transition: all 0.15s;
}
.wizard-radio:hover {
    border-color: var(--accent); background: var(--surface);
}
.wizard-radio input[type="radio"] {
    accent-color: var(--accent); width: 16px; height: 16px; margin: 0;
}
.wizard-spinner {
    width: 36px; height: 36px; margin: 0 auto;
    border: 3px solid var(--border2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: wizard-spin 0.8s linear infinite;
}
@keyframes wizard-spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════════
   HAMBURGER BUTTON (hidden on desktop)
═══════════════════════════════════════════════════════════════ */
.hamburger {
    display: none; /* shown via media query */
    flex-direction: column; justify-content: center; gap: 4px;
    background: none; border: none; cursor: pointer;
    padding: 6px; border-radius: 6px; flex-shrink: 0;
    transition: background 0.15s;
}
.hamburger:hover { background: var(--bg2); }
.hamburger span {
    display: block; width: 18px; height: 2px;
    background: var(--text2); border-radius: 1px;
    transition: all 0.2s;
}

/* ── SIDEBAR OVERLAY (mobile) ──────────────────────────────── */
.sidebar-overlay {
    display: none; /* shown via media query */
    position: fixed; inset: 0; z-index: 99;
    background: rgba(17,24,39,0.4);
    backdrop-filter: blur(2px);
}

/* ── COIL CALCULATOR ──────────────────────────────────────── */
.coil-layout {
    display: grid; grid-template-columns: 320px 1fr;
    gap: 14px; align-items: start;
}
.coil-left {
    display: flex; flex-direction: column; gap: 10px;
}
.coil-right { display: flex; flex-direction: column; }
.coil-kpi-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.coil-kpi {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px 12px;
}
.coil-kpi .kpi-label {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text3); margin-bottom: 2px;
}
.coil-kpi .kpi-value {
    font-family: 'DM Mono', monospace; font-size: 18px; font-weight: 700;
    color: var(--text); line-height: 1.2;
}
.coil-kpi .kpi-unit {
    font-size: 12px; font-weight: 400; color: var(--text2); margin-left: 2px;
}
.coil-schematic-body {
    display: flex; align-items: center; justify-content: center;
    padding: 12px;
}
.coil-svg {
    width: 100%; max-width: 420px; max-height: 320px; height: auto;
}
.coil-error {
    text-align: center; color: var(--text3); font-size: 13px; padding: 20px 0;
}

/* ── TABLE SCROLL WRAPPER ──────────────────────────────────── */
.table-scroll {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 1024px)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .tool-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    .tube-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .loadline-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .coil-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .chart-panel {
        max-height: 50vh;
    }
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* ── Crossover Designer: stack vertically ─────────────── */
    .xover-layout-v2 {
        grid-template-columns: 1fr;
        height: auto;
    }
    .xover-header-actions { gap: 4px; }
    .xover-angle-toolbar {
        gap: 3px;
    }
    .xover-angle-toggle {
        padding: 4px 8px;
        font-size: 11px;
    }

    /* ── Sidebar: off-canvas ──────────────────────────────── */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: block;
    }
    .main {
        margin-left: 0;
    }

    /* ── Hamburger: visible ───────────────────────────────── */
    .hamburger {
        display: flex;
    }

    /* ── Topbar ───────────────────────────────────────────── */
    .topbar {
        padding: 0 12px;
        gap: 8px;
    }
    .topbar-actions {
        gap: 4px;
    }
    .breadcrumb-home,
    .breadcrumb-sep {
        display: none;
    }

    /* ── Content ──────────────────────────────────────────── */
    .content {
        padding: 12px;
    }

    /* ── Page header ──────────────────────────────────────── */
    .page-header {
        gap: 12px;
        margin-bottom: 14px;
    }
    .page-title {
        font-size: 20px;
    }

    /* ── Tool grids stack ─────────────────────────────────── */
    .tool-grid,
    .tube-layout,
    .loadline-layout,
    .coil-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .chart-panel {
        max-height: 45vh;
    }

    /* ── KPI ──────────────────────────────────────────────── */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .tube-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* ── Home page ────────────────────────────────────────── */
    .home-hero {
        padding: 16px;
    }
    .tool-grid-home {
        grid-template-columns: 1fr;
    }

    /* ── Driver database table ────────────────────────────── */
    .dbpage-toolbar {
        flex-wrap: wrap;
    }
    .dbpage-search {
        flex: 1 1 100%;
        order: -1;
    }

    /* ── Guide page ───────────────────────────────────────── */
    .guide-param-grid {
        grid-template-columns: 1fr;
    }
    .guide-enclosure-grid {
        grid-template-columns: 1fr;
    }
    .guide-intro {
        padding: 14px 16px;
    }

    /* ── Projects ─────────────────────────────────────────── */
    .projects-row > .project-card { flex: 0 0 85vw; }
    .projects-scroll-btn { display: none; }

    /* ── Auth modal ───────────────────────────────────────── */
    .auth-field-row {
        grid-template-columns: 1fr;
    }

    /* ── Help panel ───────────────────────────────────────── */
    .help-panel {
        right: 10px; bottom: 54px;
        width: calc(100vw - 20px);
    }
    .help-toggle {
        right: 10px; bottom: 10px;
    }

    /* ── Admin tables ─────────────────────────────────────── */
    .admin-table {
        font-size: 11px;
    }
    .admin-table th,
    .admin-table td {
        padding: 8px 6px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (≤ 480px)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .page-title {
        font-size: 18px;
    }
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .kpi-value {
        font-size: 15px;
    }
    .param-grid {
        grid-template-columns: 1fr;
    }
    .tube-topo-grid {
        grid-template-columns: 1fr 1fr;
    }
    .box-tabs {
        flex-direction: column;
    }
    .topbar-actions .user-name {
        display: none;
    }
    .lang-select {
        max-width: 50px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* ── Crossover Designer: compact on small screens ─────── */
    .xover-main-panel {
        min-height: 60vh;
    }
    .xover-param-grid {
        grid-template-columns: auto 1fr auto;
        gap: 3px 4px;
    }
    .xover-angle-toolbar {
        gap: 2px;
    }
    .xover-angle-toggle {
        padding: 3px 6px;
        font-size: 10px;
    }
}

/* ── ZOBEL NETWORK ────────────────────────────────────────── */
.zobel-hint {
    font-size: 11px;
    color: var(--text3);
    margin-top: 8px;
    line-height: 1.4;
}

.zobel-legend {
    display: flex;
    gap: 18px;
    justify-content: center;
    padding: 8px 0 2px;
}

.zobel-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text2);
    font-weight: 500;
}

.zobel-legend-swatch {
    width: 20px;
    height: 3px;
    border-radius: 2px;
    display: inline-block;
}

.zobel-legend-item:first-child .zobel-legend-swatch {
    background: #9A948C !important;
    height: 2px;
    border-top: 1px dashed #9A948C;
    background: transparent !important;
}

.zobel-schematic-area {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 240px;
}

.zobel-schematic-area canvas {
    width: 100%;
    max-width: 560px;
    height: auto;
}

.zobel-schematic-caption {
    text-align: center;
    font-size: 11px;
    color: var(--text3);
    margin-top: 8px;
    line-height: 1.4;
}

/* ── Admin Stats ──────────────────────────────────────────── */

.stats-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stats-kpi-card {
    background: var(--surface1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 16px;
    text-align: center;
}

.stats-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text1);
    font-family: var(--font-mono);
}

.stats-kpi-label {
    font-size: 12px;
    color: var(--text3);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-charts-row {
    display: flex;
    gap: 16px;
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .stats-charts-row { flex-direction: column; }
}

.stats-bar-bg {
    background: var(--surface2, rgba(255,255,255,0.04));
    border-radius: 4px;
    height: 16px;
    overflow: hidden;
}

.stats-bar-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--accent), var(--gold));
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ── AMPLIFIER DESIGNER PAGE ───────────────────────────────── */
/* The amp designer reuses the .xover-layout-v2 / .xover-main-panel /
   .xover-side-panels grid from the crossover designer — only the
   parameters tab content has page-specific styling. */
.ampdesigner-params-area {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 4px 6px 4px 0;
    display: flex; flex-direction: column; gap: 8px;
}
.ampdesigner-params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
    align-content: start;
}
.ampdesigner-generator-card {
    grid-column: 1 / -1;
}
.ampdesigner-generator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    align-items: start;
}
.topology-btn {
    flex: 1; padding: 7px 10px; text-align: center;
    border: 1px solid var(--border2); border-radius: 6px;
    background: var(--surface2); font-size: 11px; font-weight: 500;
    color: var(--text2); cursor: pointer;
    transition: all 0.15s;
    font-family: 'DM Mono', monospace;
}
.topology-btn:hover { border-color: var(--accent); color: var(--text); }
.topology-btn.active {
    border-color: var(--accent); background: var(--accent-pale);
    color: var(--accent); font-weight: 600;
}
.btn-primary {
    width: 100%; padding: 9px 16px;
    border: none; border-radius: 8px;
    background: var(--accent); color: white;
    font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background 0.15s;
    font-family: 'Instrument Sans', sans-serif;
}
.btn-primary:hover { background: var(--accent2); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
    padding: 7px 14px;
    border: 1px solid var(--border2); border-radius: 6px;
    background: var(--surface); color: var(--text2);
    font-size: 12px; cursor: pointer;
    font-family: 'Instrument Sans', sans-serif;
}
.btn-secondary:hover { border-color: var(--text3); }
.modal-header {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    font-size: 14px; font-weight: 600;
}
.modal-body { padding: 14px 16px; }
.modal-footer {
    padding: 10px 16px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
}

