/* ─── GOOGLE FONTS ─────────────────────────── */
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

  /* ─── DESIGN TOKENS ────────────────────────── */
  :root {
    --bg:       #030a14;
    --card:     rgba(6,14,32,0.78);
    --card2:    rgba(10,20,42,0.78);
    --overlay:  rgba(4,10,24,0.97);
    --surface:  rgba(255,255,255,0.04);
    --surface2: rgba(255,255,255,0.07);
    --surface3: rgba(255,255,255,0.11);
    --border:   rgba(255,255,255,0.07);
    --border2:  rgba(255,255,255,0.13);

    --cyan:     #06b6d4;  --cyan2:   #67e8f9;
    --blue:     #0ea5e9;  --blue2:   #7dd3fc;
    --violet:   #8b5cf6;  --violet2: #c4b5fd;
    --teal:     #14b8a6;  --teal2:   #5eead4;
    --accent:   #0ea5e9;  --accent-light: #38bdf8;  --accent2: #14b8a6;
    --accent-glow: rgba(14,165,233,0.45);

    --text:     #f0f9ff;
    --text2:    #94a3b8;
    --text3:    #475569;

    --red:      #ef4444;  --red-soft: rgba(239,68,68,0.1);   --red-border: rgba(239,68,68,0.3);
    --yellow:   #f59e0b;  --yellow-soft: rgba(245,158,11,0.1); --yellow-border: rgba(245,158,11,0.3);
    --green:    #10b981;  --green-soft: rgba(16,185,129,0.1); --green-border: rgba(16,185,129,0.3);

    --r: 14px;  --r-sm: 9px;  --r-xs: 5px;  --r-lg: 20px;

    --sh:    0 2px 8px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.7);
    --sh-md: 0 8px 32px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.5);
    --sh-lg: 0 24px 64px rgba(0,0,0,0.8);
    --sh-glow: 0 0 32px rgba(14,165,233,0.18);

    --bg-grad-1: radial-gradient(ellipse 1000px 800px at -8% -12%,  rgba(14,165,233,0.38) 0%, transparent 48%);
    --bg-grad-2: radial-gradient(ellipse 700px 600px at 108% -5%,   rgba(6,182,212,0.30)  0%, transparent 48%);
    --bg-grad-3: radial-gradient(ellipse 800px 700px at 55% 115%,   rgba(20,184,166,0.20) 0%, transparent 52%);
    --bg-grad-4: radial-gradient(ellipse 450px 400px at 82% 52%,    rgba(139,92,246,0.12) 0%, transparent 50%);
  }

  :root[data-theme='light'] {
    --bg: #f2f7ff;
    --card: rgba(255,255,255,0.88);
    --card2: rgba(255,255,255,0.92);
    --overlay: rgba(243,248,255,0.98);
    --surface: rgba(3,10,20,0.04);
    --surface2: rgba(3,10,20,0.08);
    --surface3: rgba(3,10,20,0.13);
    --border: rgba(3,10,20,0.12);
    --border2: rgba(3,10,20,0.2);

    --text: #0b1c34;
    --text2: #334155;
    --text3: #64748b;

    --bg-grad-1: radial-gradient(ellipse 1000px 800px at -8% -12%,  rgba(56,189,248,0.18) 0%, transparent 48%);
    --bg-grad-2: radial-gradient(ellipse 700px 600px at 108% -5%,   rgba(6,182,212,0.13)  0%, transparent 48%);
    --bg-grad-3: radial-gradient(ellipse 800px 700px at 55% 115%,   rgba(20,184,166,0.09) 0%, transparent 52%);
    --bg-grad-4: radial-gradient(ellipse 450px 400px at 82% 52%,    rgba(139,92,246,0.08) 0%, transparent 50%);
  }

  /* ─── RESET ─────────────────────────────────── */
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { font-size: 15px; }
  body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    background: var(--bg);
    background-image: var(--bg-grad-1), var(--bg-grad-2), var(--bg-grad-3), var(--bg-grad-4);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
  }
  input, textarea, button, select { font-family: inherit; }

  /* ─── LAYOUT ─────────────────────────────────── */
  #root { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }

  /* ─── SCROLLBAR ──────────────────────────────── */
  ::-webkit-scrollbar { width: 4px; height: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
  ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

  /* ═══════════════════════════════════════════════
     HEADER
  ═══════════════════════════════════════════════ */
  .header {
    display: flex; align-items: center; gap: 20px;
    padding: 44px 0 32px;
    position: relative;
  }
  .header-icon-wrap {
    position: relative;
    width: 62px; height: 62px; flex-shrink: 0;
    border-radius: 18px;
    background: linear-gradient(145deg, #0ea5e9 0%, #0284c7 40%, #0891b2 75%, #0d9488);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.7rem;
    box-shadow:
      0 0 0 1px rgba(255,255,255,0.18) inset,
      0 10px 32px rgba(14,165,233,0.65),
      0 0 70px rgba(14,165,233,0.35),
      0 0 120px rgba(14,165,233,0.15);
  }
  .header-icon { font-size: 1.7rem; } /* compat */
  .header-texts { flex: 1; }
  .header h1 {
    font-size: 2rem; font-weight: 900;
    letter-spacing: -0.05em; line-height: 1;
    background: linear-gradient(110deg, #ffffff 0%, #bae6fd 35%, #67e8f9 65%, #5eead4 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .header-sub {
    font-size: 0.76rem; color: var(--text3);
    margin-top: 7px; font-weight: 400; letter-spacing: 0.01em;
  }

  /* ═══════════════════════════════════════════════
     NAV  — two-level grouped navigation
  ═══════════════════════════════════════════════ */
  .nav-wrap {
    position: sticky; top: 12px; z-index: 50;
    margin-bottom: 28px;
  }
  /* ── Section bar (top row) ── */
  .nav-sections {
    display: flex; align-items: center; gap: 2px;
    padding: 4px 5px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.09);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--r) var(--r) 0 0;
    backdrop-filter: blur(36px);
    -webkit-backdrop-filter: blur(36px);
    box-shadow: 0 -2px 0 rgba(255,255,255,0.03) inset;
  }
  .nav-section-btn {
    padding: 6px 14px; border-radius: 8px; border: none;
    background: transparent; color: var(--text3);
    cursor: pointer; font-size: 0.79rem; font-weight: 500;
    transition: all 0.15s cubic-bezier(.4,0,.2,1); white-space: nowrap; flex-shrink: 0;
  }
  .nav-section-btn.active {
    background: rgba(14,165,233,0.14);
    color: var(--blue2); font-weight: 700;
    box-shadow: 0 0 0 1px rgba(14,165,233,0.3);
  }
  .nav-section-btn:hover:not(.active) { color: var(--text2); background: rgba(255,255,255,0.06); }
  .nav-sections::-webkit-scrollbar { display: none; }
  .nav-actions { margin-left: auto; display: flex; gap: 3px; align-items: center; flex-shrink: 0; }

  /* ── Sub-tab bar (bottom row) ── */
  .nav {
    display: flex; align-items: center; gap: 2px;
    padding: 4px 5px;
    background: rgba(0,0,0,0.38);
    border: 1px solid rgba(255,255,255,0.07);
    border-top: none;
    border-radius: 0 0 var(--r) var(--r);
    overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-btn {
    padding: 6px 13px; border-radius: 8px; border: none;
    background: transparent; color: var(--text3);
    cursor: pointer; font-size: 0.77rem; font-weight: 500;
    transition: all 0.16s cubic-bezier(.4,0,.2,1); white-space: nowrap; flex-shrink: 0;
    letter-spacing: 0.005em;
  }
  .nav-btn.active {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #fff; font-weight: 700;
    box-shadow: 0 2px 14px rgba(14,165,233,0.5),
                0 0 0 1px rgba(255,255,255,0.15) inset;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  }
  .nav-btn:hover:not(.active) { color: var(--text); background: rgba(255,255,255,0.07); }

  /* ═══════════════════════════════════════════════
     CARDS
  ═══════════════════════════════════════════════ */
  .card {
    background: rgba(12, 14, 28, 0.72);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    background-image: linear-gradient(160deg, rgba(255,255,255,0.05) 0%, transparent 55%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--r);
    padding: 22px 24px;
    margin-bottom: 14px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04) inset;
    position: relative;
    overflow: hidden;
  }
  .card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  }
  .card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
  .card-title { font-size: 0.97rem; font-weight: 700; letter-spacing: -0.015em; }
  .card-date   { font-size: 0.76rem; color: var(--text3); }

  /* ═══════════════════════════════════════════════
     UPLOAD ZONE
  ═══════════════════════════════════════════════ */
  .upload-zone {
    background: rgba(3,10,22,0.55);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px dashed rgba(14,165,233,0.5);
    border-radius: var(--r);
    padding: 80px 32px;
    text-align: center; cursor: pointer;
    transition: all 0.22s cubic-bezier(.4,0,.2,1);
    position: relative; overflow: hidden;
  }
  .upload-zone::after {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse 80% 70% at 50% -5%, rgba(14,165,233,0.18), transparent 65%);
    pointer-events: none;
  }
  .upload-zone:hover, .upload-zone.drag-over {
    border-color: #38bdf8; border-style: solid;
    box-shadow: 0 0 0 4px rgba(14,165,233,0.15), 0 16px 48px rgba(0,0,0,0.4),
                0 0 80px rgba(14,165,233,0.1);
    transform: translateY(-4px);
    background: rgba(3,14,32,0.65);
  }
  .upload-zone .icon {
    font-size: 3.8rem; display: block; margin-bottom: 20px;
    filter: drop-shadow(0 6px 16px rgba(14,165,233,0.45));
  }
  .upload-zone h3 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.025em; margin-bottom: 8px; }
  .upload-zone p  { color: var(--text2); font-size: 0.84rem; line-height: 1.65; }

  /* ═══════════════════════════════════════════════
     PROGRESS BAR
  ═══════════════════════════════════════════════ */
  .progress-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 22px; margin: 14px 0; }
  .progress-label { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.81rem; color: var(--text2); }
  .progress-bar  { height: 5px; background: var(--surface3); border-radius: 3px; overflow: hidden; }
  .progress-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease;
    background: linear-gradient(90deg, var(--cyan), var(--teal));
    box-shadow: 0 0 12px rgba(14,165,233,0.7); }

  /* ═══════════════════════════════════════════════
     EXAM LIST
  ═══════════════════════════════════════════════ */
  .exam-item {
    background: rgba(12,14,28,0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r);
    padding: 14px 18px 14px 20px;
    margin-bottom: 8px; cursor: pointer;
    transition: all 0.18s cubic-bezier(.4,0,.2,1);
    display: flex; align-items: center; gap: 14px;
    position: relative; overflow: hidden;
  }
  /* status line left */
  .exam-item::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    border-radius: 3px 0 0 3px; background: var(--border2); transition: all 0.2s;
  }
  .exam-item.has-bad::before  { background: var(--red);    box-shadow: 2px 0 14px rgba(239,68,68,0.6); }
  .exam-item.has-warn::before { background: var(--yellow); box-shadow: 2px 0 12px rgba(245,158,11,0.5); }
  .exam-item.has-ok::before   { background: var(--green);  box-shadow: 2px 0 12px rgba(16,185,129,0.5); }
  .exam-item:hover {
    background: var(--card2); border-color: var(--border2);
    transform: translateY(-2px); box-shadow: var(--sh-md);
  }
  .exam-item.selected {
    background: rgba(14,165,233,0.1);
    border-color: rgba(14,165,233,0.45);
    box-shadow: 0 0 0 1px rgba(14,165,233,0.2), var(--sh-glow);
  }
  .exam-thumb {
    width: 52px; height: 52px; border-radius: 10px;
    object-fit: cover; flex-shrink: 0; border: 1px solid var(--border);
  }
  .exam-info  { flex: 1; min-width: 0; }
  .exam-title { font-weight: 700; margin-bottom: 2px; font-size: 0.93rem; letter-spacing: -0.01em; }
  .exam-meta  { font-size: 0.75rem; color: var(--text3); }
  .exam-badges { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }

  /* ═══════════════════════════════════════════════
     BADGES
  ═══════════════════════════════════════════════ */
  .badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 99px;
    font-size: 0.67rem; font-weight: 700; letter-spacing: 0.02em;
  }
  .badge-red    { background: var(--red-soft);    color: var(--red);    border: 1px solid var(--red-border);    }
  .badge-yellow { background: var(--yellow-soft); color: var(--yellow); border: 1px solid var(--yellow-border); }
  .badge-green  { background: var(--green-soft);  color: var(--green);  border: 1px solid var(--green-border);  }

  /* ═══════════════════════════════════════════════
     PARAM TABLE
  ═══════════════════════════════════════════════ */
  .param-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
  .param-table th {
    text-align: left; padding: 8px 14px;
    color: var(--text3); font-weight: 700; font-size: 0.65rem;
    text-transform: uppercase; letter-spacing: 0.12em;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
  }
  .param-table td {
    padding: 9px 14px; border-bottom: 1px solid var(--border);
    vertical-align: middle; transition: background 0.1s;
  }
  .param-table tr:last-child td { border-bottom: none; }
  .param-table tbody tr:hover td { background: rgba(14,165,233,0.05); }
  .param-table tbody tr td:first-child { border-left: 3px solid transparent; transition: border-color 0.15s; }
  .param-row-bad  tbody tr td:first-child,
  .param-row-bad  td:first-child  { border-left-color: var(--red) !important; }
  .param-row-warn td:first-child  { border-left-color: var(--yellow) !important; }
  .param-row-ok   td:first-child  { border-left-color: var(--green) !important; }

  .status-ok   { color: var(--green);  font-weight: 600; }
  .status-warn { color: var(--yellow); font-weight: 600; }
  .status-bad  { color: var(--red);    font-weight: 600; }
  .trend-up    { color: var(--red);   }
  .trend-down  { color: var(--green); }
  .trend-same  { color: var(--text3); }
  .val-cell { font-weight: 700; font-size: 0.92rem; font-variant-numeric: tabular-nums; }

  /* ═══════════════════════════════════════════════
     BUTTONS
  ═══════════════════════════════════════════════ */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--r-sm); border: none;
    cursor: pointer; font-size: 0.82rem; font-weight: 600; line-height: 1;
    transition: all 0.16s cubic-bezier(.4,0,.2,1); letter-spacing: 0.01em;
    white-space: nowrap;
  }
  .btn-primary {
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 50%, #0284c7 100%);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    box-shadow: 0 4px 20px rgba(14,165,233,0.5),
                0 2px 6px rgba(0,0,0,0.3),
                0 0 0 1px rgba(255,255,255,0.15) inset;
  }
  .btn-primary:hover {
    background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 50%, #0ea5e9 100%);
    box-shadow: 0 6px 28px rgba(14,165,233,0.7),
                0 2px 8px rgba(0,0,0,0.3),
                0 0 0 1px rgba(255,255,255,0.2) inset;
    transform: translateY(-1px);
  }
  .btn-primary:active { transform: translateY(0); box-shadow: 0 2px 12px rgba(14,165,233,0.4); }
  .btn-secondary {
    background: var(--surface2); color: var(--text2);
    border: 1px solid var(--border2);
  }
  .btn-secondary:hover { background: var(--surface3); color: var(--text); border-color: rgba(14,165,233,0.4); }
  .btn-danger { background: var(--red-soft); color: var(--red); border: 1px solid var(--red-border); }
  .btn-danger:hover { background: rgba(239,68,68,0.18); }
  .btn-sm  { padding: 5px 11px; font-size: 0.75rem; border-radius: 7px; }
  .btn-icon { background: none; border: none; cursor: pointer; color: var(--text3); font-size: 1rem; padding: 5px 6px; border-radius: 7px; transition: all 0.14s; }
  .btn-icon:hover { color: var(--text); background: var(--surface2); }

  /* ═══════════════════════════════════════════════
     INPUTS
  ═══════════════════════════════════════════════ */
  .param-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; gap: 7px; align-items: center; margin-bottom: 7px; }
  @media (max-width: 600px) { .param-row { grid-template-columns: 1fr 1fr; } }
  .param-row input,
  input.input-base,
  textarea.note-input {
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border);
    color: var(--text); border-radius: 7px;
    padding: 7px 11px; font-size: 0.81rem; width: 100%;
    transition: all 0.14s; font-family: inherit;
  }
  .param-row input:focus,
  input.input-base:focus,
  textarea.note-input:focus {
    outline: none; border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.18);
  }
  .note-input { resize: vertical; min-height: 80px; }

  /* ═══════════════════════════════════════════════
     MODAL
  ═══════════════════════════════════════════════ */

  /* Toast */
  .toast {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
    z-index: 9999; padding: 12px 22px; border-radius: 14px;
    font-size: 0.88rem; font-weight: 600; white-space: nowrap;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    animation: toast-in 0.25s cubic-bezier(.4,0,.2,1);
    pointer-events: none;
  }
  .toast.ok  { background: var(--green-soft); color: var(--green); border: 1px solid var(--green-border); }
  .toast.err { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
  @keyframes toast-in { from { opacity:0; transform:translateX(-50%) translateY(12px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(3,4,12,0.88);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 16px;
  }
  .modal {
    background: rgba(8,10,22,0.82);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    background-image: linear-gradient(160deg, rgba(255,255,255,0.06) 0%, transparent 50%);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--r-lg);
    padding: 28px; max-width: 940px; width: 100%;
    max-height: 92vh; overflow-y: auto;
    box-shadow: 0 32px 80px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.06) inset,
                0 0 60px rgba(14,165,233,0.08);
  }
  .modal-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 22px; padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
  }

  /* ═══════════════════════════════════════════════
     STAT CHIPS
  ═══════════════════════════════════════════════ */
  .stat-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
  .stat-chip {
    flex: 1; min-width: 105px;
    padding: 18px 20px; border-radius: var(--r);
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; gap: 6px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: transform 0.18s, box-shadow 0.18s;
  }
  .stat-chip:hover { transform: translateY(-2px); }
  .stat-chip::before { /* top highlight */
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);
  }
  .stat-chip::after { /* inner bottom glow */
    content: ''; position: absolute; bottom: 0; left: 20%; right: 20%; height: 40px;
    border-radius: 50%; filter: blur(16px); pointer-events: none;
  }
  .stat-chip-num   { font-size: 2.1rem; font-weight: 900; line-height: 1; letter-spacing: -0.05em; word-break: break-word; overflow-wrap: break-word; }
  .stat-chip-label { font-size: 0.68rem; font-weight: 600; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.08em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stat-chip-red    {
    background: linear-gradient(145deg, rgba(239,68,68,0.18), rgba(185,28,28,0.12));
    border: 1px solid rgba(239,68,68,0.32); color: #f87171;
    box-shadow: 0 8px 32px rgba(239,68,68,0.12), inset 0 1px 0 rgba(255,255,255,0.07);
  }
  .stat-chip-red::after { background: rgba(239,68,68,0.15); }
  .stat-chip-yellow {
    background: linear-gradient(145deg, rgba(245,158,11,0.16), rgba(180,83,9,0.1));
    border: 1px solid rgba(245,158,11,0.32); color: #fbbf24;
    box-shadow: 0 8px 32px rgba(245,158,11,0.10), inset 0 1px 0 rgba(255,255,255,0.07);
  }
  .stat-chip-yellow::after { background: rgba(245,158,11,0.12); }
  .stat-chip-green  {
    background: linear-gradient(145deg, rgba(16,185,129,0.16), rgba(5,150,105,0.10));
    border: 1px solid rgba(16,185,129,0.32); color: #34d399;
    box-shadow: 0 8px 32px rgba(16,185,129,0.10), inset 0 1px 0 rgba(255,255,255,0.07);
  }
  .stat-chip-green::after { background: rgba(16,185,129,0.12); }
  .stat-chip-neutral{
    background: linear-gradient(145deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03));
    border: 1px solid rgba(255,255,255,0.12); color: var(--text2);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.07);
  }

  /* ═══════════════════════════════════════════════
     CATEGORY PILLS
  ═══════════════════════════════════════════════ */
  .cat-pills { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 18px; }
  .cat-pill {
    padding: 5px 13px; border-radius: 99px; cursor: pointer;
    font-size: 0.76rem; font-weight: 500; transition: all 0.14s;
    background: var(--surface); border: 1px solid var(--border); color: var(--text3);
  }
  .cat-pill.active { background: rgba(14,165,233,0.22); border-color: rgba(14,165,233,0.5); color: var(--blue2); font-weight: 700; box-shadow: 0 0 20px rgba(14,165,233,0.2); }
  .cat-pill:hover:not(.active) { background: var(--surface2); color: var(--text2); border-color: var(--border2); }

  /* ═══════════════════════════════════════════════
     MISC COMPONENTS
  ═══════════════════════════════════════════════ */
  .ocr-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  @media (max-width: 700px) { .ocr-split { grid-template-columns: 1fr; } }
  .ocr-raw { font-family: 'SF Mono', ui-monospace, monospace; font-size: 0.71rem; color: var(--text2); background: rgba(0,0,0,0.4); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 14px; height: 300px; overflow-y: auto; white-space: pre-wrap; }

  .table-wrap  { overflow-x: auto; }
  .sticky-col  { position: sticky; left: 0; background: var(--card); z-index: 1; }

  .section-title { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.13em; color: var(--text3); margin-bottom: 12px; }
  .empty { text-align: center; padding: 80px 24px; color: var(--text2); }
  .empty .icon { font-size: 4rem; display: block; margin-bottom: 18px; filter: drop-shadow(0 4px 18px rgba(14,165,233,0.3)); }
  .empty h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -0.01em; }

  .tag-label { display: inline-block; background: rgba(14,165,233,0.15); color: var(--blue2); border-radius: 5px; padding: 2px 8px; font-size: 0.72rem; margin: 2px; }
  .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
  .dot-red    { background: var(--red);    box-shadow: 0 0 6px var(--red); }
  .dot-green  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
  .dot-yellow { background: var(--yellow); }

  .alert { border-radius: var(--r-sm); padding: 11px 15px; font-size: 0.81rem; margin-bottom: 12px; }
  .alert-warn { background: var(--yellow-soft); border: 1px solid var(--yellow-border); color: #fbbf24; }
  .alert-info { background: rgba(14,165,233,0.08); border: 1px solid rgba(14,165,233,0.22); color: var(--blue2); }

  .param-search-wrap { position: relative; margin-bottom: 12px; }
  .param-search-input { background: rgba(0,0,0,0.35); border: 1px solid rgba(14,165,233,0.5); color: var(--text); border-radius: var(--r-sm); padding: 9px 12px; font-size: 0.83rem; width: 100%; transition: all 0.14s; }
  .param-search-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(14,165,233,0.2); border-color: var(--blue); }
  .param-search-dropdown { position: absolute; top: calc(100% + 5px); left: 0; right: 0; background: var(--overlay); border: 1px solid var(--border2); border-radius: var(--r-sm); max-height: 240px; overflow-y: auto; z-index: 200; box-shadow: 0 20px 48px rgba(0,0,0,0.65); }
  .param-search-item { padding: 9px 13px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 0.81rem; gap: 12px; transition: background 0.1s; }
  .param-search-item:hover { background: rgba(14,165,233,0.12); }
  .param-search-meta { color: var(--text3); font-size: 0.72rem; white-space: nowrap; }

  .param-info-row td { padding: 0 !important; border-bottom: none !important; }
  .param-info-panel { background: rgba(14,165,233,0.06); border-left: 2px solid var(--blue); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: 11px 15px; margin: 0 4px 8px; font-size: 0.79rem; line-height: 1.65; }
  .param-info-panel .info-desc { color: var(--text); margin-bottom: 5px; }
  .param-info-panel .info-tips { color: var(--teal); }
  .param-info-panel .info-tips-bad { color: var(--yellow); }
  .param-name-btn { background: none; border: none; color: var(--text); cursor: pointer; font-size: inherit; text-align: left; padding: 0; font-weight: 600; transition: color 0.14s; }
  .param-name-btn:hover { color: var(--violet2); }

  .img-preview { max-width: 100%; border-radius: var(--r-sm); border: 1px solid var(--border); }

  /* ═══════════════════════════════════════════════
     MISC CLASSES (carry-forward compat)
  ═══════════════════════════════════════════════ */
  .flex { display: flex; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
  .items-center { align-items: center; } .justify-between { justify-content: space-between; }
  .flex-wrap { flex-wrap: wrap; }
  .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
  .mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
  .text-sm { font-size: 0.82rem; } .text-xs { font-size: 0.72rem; }
  .text-muted { color: var(--text2); } .text-right { text-align: right; }
  .w-full { width: 100%; }
  .chart-wrap { background: rgba(12,14,28,0.72); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); border: 1px solid rgba(255,255,255,0.09); border-radius: var(--r); padding: 20px; margin-bottom: 14px; box-shadow: 0 8px 40px rgba(0,0,0,0.45); }
  .chart-inner { position: relative; height: 220px; }

  /* install & history btns (compat) */
  .install-btn { margin-left: auto; padding: 7px 12px; border-radius: 9px; border: 1px solid var(--green-border); background: var(--green-soft); color: var(--green); font-size: 0.76rem; font-weight: 700; cursor: pointer; }
  .history-btn { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border2); background: var(--surface2); color: var(--text2); font-size: 0.76rem; cursor: pointer; }
  .history-btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .ocr-steps { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
  .ocr-step  { padding: 3px 9px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); font-size: 0.71rem; font-weight: 600; }
  .ocr-step.active { border-color: var(--violet); color: var(--violet2); }
  .ocr-step.done   { border-color: var(--green-border); color: var(--green); }

  /* ═══════════════════════════════════════════════
     ANIMATIONS
  ═══════════════════════════════════════════════ */
  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes pulse {
    0%, 100% { opacity: 0.2; transform: scale(0.8); }
    50%       { opacity: 1;   transform: scale(1);   }
  }
  @keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(255,255,255,0.18) inset, 0 10px 32px rgba(14,165,233,0.65), 0 0 70px rgba(14,165,233,0.35); }
    50%       { box-shadow: 0 0 0 1px rgba(255,255,255,0.22) inset, 0 12px 40px rgba(14,165,233,0.8),  0 0 90px rgba(14,165,233,0.5); }
  }
  .card       { animation: fadeUp 0.24s ease both; }
  .exam-item  { animation: fadeUp 0.2s ease both; }
  .header-icon-wrap { animation: glowPulse 4s ease-in-out infinite; }

  .global-search-wrap { position: relative; }
  .global-search-input {
    width: 200px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.76rem;
  }
  .global-search-select {
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text2);
    border-radius: 8px;
    padding: 7px 8px;
    font-size: 0.74rem;
  }
  .global-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 340px;
    max-height: 340px;
    overflow-y: auto;
    z-index: 120;
    background: var(--overlay);
    border: 1px solid var(--border2);
    border-radius: 10px;
    box-shadow: 0 18px 44px rgba(0,0,0,0.45);
    padding: 6px;
  }
  .global-search-item {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
  }
  .global-search-item:hover { background: rgba(14,165,233,0.14); }
  .global-search-meta { font-size: 0.68rem; color: var(--text3); margin-top: 2px; }
  .global-search-hl {
    background: rgba(14,165,233,0.25);
    color: var(--text);
    border-radius: 3px;
    padding: 0 2px;
  }

  :root[data-theme='light'] .nav-sections,
  :root[data-theme='light'] .nav,
  :root[data-theme='light'] .card,
  :root[data-theme='light'] .exam-item,
  :root[data-theme='light'] .chart-wrap,
  :root[data-theme='light'] .modal,
  :root[data-theme='light'] .upload-zone,
  :root[data-theme='light'] .ocr-raw,
  :root[data-theme='light'] .param-search-dropdown,
  :root[data-theme='light'] .global-search-dropdown {
    background: rgba(255,255,255,0.92) !important;
    color: var(--text);
    border-color: var(--border2);
  }
  :root[data-theme='light'] .header h1 {
    background: linear-gradient(110deg, #0b1c34 0%, #0369a1 50%, #0f766e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  /* ═══════════════════════════════════════════════
     MOBILE — tablet (≤768px)
  ═══════════════════════════════════════════════ */
  @media (max-width: 768px) {
    body { background-attachment: scroll; } /* fix iOS Safari fixed bg bug */
    #root { padding: 0 16px 80px; }
    .header { padding: 28px 0 20px; gap: 14px; }
    .header h1 { font-size: 1.65rem; }
    .card { padding: 18px 18px; }
    .stat-chip { min-width: 90px; padding: 14px 16px; }
    .modal { padding: 22px 20px; }
    .chart-inner { height: 190px; }
    .global-search-dropdown { width: min(340px, calc(100vw - 32px)); }
  }

  /* ═══════════════════════════════════════════════
     MOBILE — smartphone (≤480px)
  ═══════════════════════════════════════════════ */
  @media (max-width: 480px) {
    #root { padding: 0 12px 90px; }

    /* Header */
    .header { padding: 20px 0 16px; gap: 12px; }
    .header-icon-wrap { width: 48px; height: 48px; border-radius: 13px; font-size: 1.3rem; }
    .header-icon { font-size: 1.3rem; }
    .header h1 { font-size: 1.35rem; }
    .header-sub { font-size: 0.68rem; margin-top: 5px; }

    /* Nav */
    .nav-sections { overflow-x: unset; flex-wrap: wrap; gap: 2px 1px; padding: 4px 3px; }
    .nav-section-btn { flex: 1 1 auto; min-width: 0; padding: 5px 6px; font-size: 0.67rem;
      display: flex; flex-direction: column; align-items: center; gap: 1px; }
    .nav-section-btn .nav-label { font-size: 0.6rem; line-height: 1; }
    .nav-actions { margin-left: 0; width: 100%; justify-content: flex-end; border-top: 1px solid rgba(255,255,255,0.06); padding-top: 3px; }
    .nav-btn { padding: 5px 10px; font-size: 0.71rem; }
    .global-search-input { width: 110px; font-size: 0.72rem; }
    .global-search-dropdown { width: calc(100vw - 24px); right: -12px; }

    /* Cards */
    .card { padding: 14px 14px; }
    .card-header { margin-bottom: 14px; }

    /* Stat chips */
    .stat-chip { padding: 12px 12px; min-width: 76px; }
    .stat-chip-num { font-size: 1.7rem; }
    .stat-chip-label { font-size: 0.62rem; }
    .stat-chips { gap: 7px; }

    /* Buttons — touch target più grande */
    .btn { padding: 10px 14px; font-size: 0.8rem; }
    .btn-sm { padding: 7px 11px; font-size: 0.74rem; }

    /* Modal — bottom sheet su mobile */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal {
      padding: 20px 16px 32px;
      border-radius: var(--r-lg) var(--r-lg) 0 0;
      max-height: 94vh;
      width: 100%;
    }

    /* Upload zone */
    .upload-zone { padding: 44px 16px; }
    .upload-zone .icon { font-size: 3rem; margin-bottom: 14px; }
    .upload-zone h3 { font-size: 1.05rem; }

    /* Tabelle parametri */
    .param-table { font-size: 0.75rem; }
    .param-table td, .param-table th { padding: 7px 8px; }
    .val-cell { font-size: 0.84rem; }

    /* Grafici */
    .chart-inner { height: 170px; }
    .chart-wrap { padding: 14px; }

    /* Exam list */
    .exam-item { padding: 11px 14px 11px 16px; gap: 10px; }
    .exam-thumb { width: 44px; height: 44px; }
    .exam-title { font-size: 0.87rem; }

    /* Sezione titoli */
    .section-title { font-size: 0.62rem; }

    /* Flex button groups */
    .flex.gap-8 { gap: 6px; flex-wrap: wrap; }
    .flex.gap-12 { gap: 8px; flex-wrap: wrap; }

    /* Badge più leggibili */
    .badge { font-size: 0.63rem; padding: 2px 7px; }

    /* Category pills */
    .cat-pill { font-size: 0.72rem; padding: 5px 11px; }
  }
