/* ============================================================
   n-epi — Design System
   Dark mode default. Linear.app meets NEJM aesthetic.
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
    /* Dark theme (default) */
    --bg-base: #06090f;
    --bg-surface: #0c1220;
    --bg-elevated: #111827;
    --bg-hover: #1a2332;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    /* Lightened from #64748b to meet WCAG AA (4.5:1) for small muted text
       on the dark surfaces (bg-base/surface/elevated). */
    --text-tertiary: #8b97a8;

    --accent: #5eead4;
    --accent-hover: #2dd4bf;
    --accent-muted: rgba(94, 234, 212, 0.11);

    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #818cf8;

    /* Text placed on a solid --accent fill (buttons, active chips, logo). */
    --accent-contrast: #06090f;

    --border: rgba(148, 163, 184, 0.08);
    --border-strong: rgba(148, 163, 184, 0.15);
    /* Hairline top highlight that gives cards a faint bevel in dark mode. */
    --highlight: rgba(255, 255, 255, 0.035);
    --scroll-shadow: rgba(0, 0, 0, 0.45);
    /* Opaque so the thin scrollbar thumb clears WCAG 1.4.11 (3:1 non-text)
       against both the dark and the light page background. */
    --scrollbar-thumb: #64748b;

    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    /* Formulas: a serif math face so variables, operators and Greek read as
       typeset notation rather than terminal output. */
    --font-math: 'STIX Two Math', 'Cambria Math', 'Latin Modern Math', 'Noto Serif', Georgia, 'Times New Roman', serif;

    --sidebar-width: 276px;
    --transition: 0.15s ease;
}

[data-theme="light"] {
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-elevated: #f1f5f9;
    --bg-hover: #e2e8f0;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;

    --accent: #0f766e;
    --accent-hover: #115e59;
    --accent-muted: rgba(15, 118, 110, 0.08);
    --accent-contrast: #ffffff;

    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #4f46e5;

    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.14);
    --highlight: transparent;
    --scroll-shadow: rgba(15, 23, 42, 0.12);
    --scrollbar-thumb: #64748b;

    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

/* ---- Native UI colour scheme ----
   Lets form-control popups, scrollbars and focus rings follow the app theme
   instead of the OS theme. */
:root { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

/* ---- Token aliases ----
   Several modules style panels inline with these older token names. Map them
   onto the design-system tokens above so they follow the active theme instead
   of silently resolving to nothing (transparent panels, missing borders). */
:root {
    --bg: var(--bg-base);
    --bg-primary: var(--bg-base);
    --bg-secondary: var(--bg-surface);
    --bg-tertiary: var(--bg-elevated);
    --bg-offset: var(--bg-elevated);
    --surface: var(--bg-surface);
    --surface-1: var(--bg-surface);
    --surface-2: var(--bg-elevated);
    --card-bg: var(--bg-surface);
    --text: var(--text-primary);
    --text-muted: var(--text-tertiary);
    --primary: var(--accent);
    --accent-color: var(--accent);
    --accent-bg: var(--accent-muted);
    --border-color: var(--border-strong);
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    /* Soft accent glow at the top of the canvas over a faint 32px grid. */
    background-image:
        radial-gradient(900px 440px at 50% -140px, var(--accent-muted), transparent 70%),
        linear-gradient(rgba(148, 163, 184, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.025) 1px, transparent 1px);
    background-size: auto, 32px 32px, 32px 32px;
    background-repeat: no-repeat, repeat, repeat;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: 1.9rem; letter-spacing: -0.025em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

/* Inline UI glyphs (search, link) rendered as monochrome SVG so they match
   the text colour on every platform instead of falling back to colour emoji. */
.ui-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    vertical-align: -0.125em;
}

/* ---- Scientific typography ----
   Sub/superscripts must not disturb line spacing (zα/2, p₁, χ²). */
sub, sup {
    font-size: 0.72em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}
sup { top: -0.55em; }
sub { bottom: -0.25em; }

/* Inline formula, e.g. "Formula: IR = New cases / Person-time". */
.formula {
    font-family: var(--font-math);
    font-size: 1.06em;
    color: var(--text-primary);
    white-space: nowrap;
    overflow-wrap: normal;
}

/* Displayed formula block (Learn panels, reference tables). Each line is a
   child element; labels inside stay in the UI face. */
.formula-block {
    margin: 0 0 14px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    font-family: var(--font-math);
    font-size: 1.04rem;
    line-height: 1.75;
    color: var(--text-primary);
    overflow-x: auto;
}

.formula-block > div {
    padding: 2px 0;
    white-space: nowrap;
}

.formula-block > div + div {
    border-top: 1px dashed var(--border);
}

.formula-block strong {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 6px;
}

.formula-block--compact {
    margin: 4px 0 0;
    padding: 6px 10px;
    font-size: 0.95rem;
    line-height: 1.5;
    border-left-width: 2px;
}

/* Citation source links (PubMed, DOI) as compact pills. */
.cite-link {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border: 1px solid var(--border-strong);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    border-radius: 999px;
    background: var(--accent-muted);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.5;
    text-decoration: none;
    vertical-align: 1px;
    transition: all var(--transition);
}

.cite-link:hover {
    background: var(--accent);
    color: var(--accent-contrast);
}

/* Learn panels read like a textbook sidebar. */
.learn-body {
    font-size: 0.9rem;
    line-height: 1.7;
}

.learn-body ul {
    margin: 0 0 14px 1.2em;
    padding: 0;
}

.learn-body li {
    margin: 3px 0;
}

.learn-body li + li {
    margin-top: 4px;
}

/* ---- Layout ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
    box-shadow: 18px 0 42px -40px rgba(0, 0, 0, 0.9);
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0;
    color: inherit;
    text-align: left;
    background: none;
    border: 0;
    cursor: pointer;
    font-family: var(--font-sans);
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--accent-contrast);
    font-weight: 800;
    box-shadow: 0 0 0 4px var(--accent-muted);
}

.sidebar-logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-logo-version {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    font-weight: 400;
    display: block;
    margin-top: -2px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Scroll-position-aware shadows so a long module list reads as scrollable. */
    background:
        linear-gradient(var(--bg-surface) 30%, transparent),
        linear-gradient(transparent, var(--bg-surface) 70%) 0 100%,
        radial-gradient(farthest-side at 50% 0, var(--scroll-shadow), transparent),
        radial-gradient(farthest-side at 50% 100%, var(--scroll-shadow), transparent) 0 100%;
    background-repeat: no-repeat;
    background-size: 100% 28px, 100% 28px, 100% 12px, 100% 12px;
    background-attachment: local, local, scroll, scroll;
}

.sidebar-group {
    margin-bottom: 8px;
}

.sidebar-group-title {
    margin: 0;
    padding: 8px 20px 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: var(--text-tertiary);
}

.sidebar-group-heading {
    margin: 0;
}

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 36px;
    padding: 7px 18px 5px 20px;
    color: var(--text-tertiary);
    background: transparent;
    border: 0;
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-align: left;
    text-transform: uppercase;
    cursor: pointer;
}

.sidebar-group-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sidebar-group-chevron {
    font-size: 0.9rem;
    transition: transform var(--transition);
}

.sidebar-group-toggle[aria-expanded="false"] .sidebar-group-chevron {
    transform: rotate(-90deg);
}

.sidebar-group.current-group > .sidebar-group-heading .sidebar-group-toggle {
    color: var(--accent);
}

.sidebar-group.current-group > .sidebar-group-heading .sidebar-group-toggle::before {
    content: "";
    width: 4px;
    height: 4px;
    margin-right: 7px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.sidebar-group.current-group > .sidebar-group-heading .sidebar-group-toggle > span:first-of-type {
    margin-right: auto;
}

.sidebar-group-items {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar-group-items[hidden] {
    display: none;
}

.sidebar-module-row {
    display: flex;
    align-items: stretch;
    min-width: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 10px;
    padding: 8px 6px 8px 18px;
    color: var(--text-secondary);
    font-size: 0.87rem;
    font-family: var(--font-sans);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
    background: transparent;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 3px solid transparent;
}

.sidebar-link-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--accent-muted);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-link-icon {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    padding: 36px clamp(28px, 4vw, 64px) 56px;
    width: calc(100% - var(--sidebar-width));
    max-width: 1520px;
}

.module-header {
    margin-bottom: 30px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.module-header h1 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

.module-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 68ch;
    text-wrap: pretty;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow), inset 0 1px 0 var(--highlight);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.form-label .tooltip-trigger {
    margin-left: 4px;
    cursor: help;
}

.form-input,
.form-select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.93rem;
    font-family: var(--font-sans);
    transition: all var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

/* Custom chevron so selects match the inputs in both themes. */
.form-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 30px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px 14px;
}

[data-theme="light"] .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.form-input[type="number"] {
    font-family: var(--font-mono);
}

.form-input--small {
    height: 36px;
    font-size: 0.85rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.form-row--2 { grid-template-columns: 1fr 1fr; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row--4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

textarea.form-input {
    height: auto;
    min-height: 80px;
    padding: 12px 14px;
    resize: vertical;
    line-height: 1.5;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    outline: none;
    white-space: nowrap;
    min-width: 44px;
}

.btn-primary {
    background-color: var(--accent);
    background-image: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0) 60%);
    color: var(--accent-contrast);
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-muted), inset 0 1px 0 rgba(255,255,255,0.18);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-tertiary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    height: 34px;
    padding: 0 14px;
    font-size: 0.8rem;
}

.btn-xs {
    height: 28px;
    padding: 0 10px;
    font-size: 0.75rem;
}

.btn-icon {
    width: 44px;
    padding: 0;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    padding: 10px 18px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-sans);
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}

.tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.tab-content.active {
    display: block;
}

/* ---- Results Panel ---- */
.result-panel {
    background: var(--bg-elevated);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-top: 20px;
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums lining-nums;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.result-value--small {
    font-size: 1.3rem;
}

.result-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.result-detail {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.6;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.result-item {
    padding: 12px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.result-item-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums lining-nums;
    letter-spacing: -0.01em;
}

.result-item-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-strong);
    position: sticky;
    top: 0;
    background: var(--bg-surface);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.data-table .num {
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums lining-nums;
    text-align: right;
}

.data-table .highlight {
    color: var(--accent);
    font-weight: 600;
}

/* ---- Preset Buttons ---- */
.preset-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.preset-btn {
    display: inline-block;
    padding: 5px 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
}

.preset-btn:hover {
    background: var(--accent-muted);
    border-color: var(--accent);
    color: var(--accent);
}

.preset-btn.active {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
    font-weight: 500;
}

/* ---- Tooltip ---- */
.tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-tertiary);
    font-size: 0.6rem;
    font-weight: 700;
    cursor: help;
    position: relative;
    vertical-align: middle;
}

.tooltip-content {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    width: 280px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    font-weight: 400;
    line-height: 1.5;
    text-transform: none;
    letter-spacing: 0;
}

.tooltip-trigger:hover .tooltip-content,
.tooltip-trigger:focus .tooltip-content {
    display: block;
}

/* ---- Toast ---- */
.ne-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 10px 24px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.ne-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ne-toast--success { border-left: 3px solid var(--success); }
.ne-toast--error { border-left: 3px solid var(--danger); }
.ne-toast--warning { border-left: 3px solid var(--warning); }

/* ---- Theme Toggle ---- */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ---- Chart Container ---- */
.chart-container {
    position: relative;
    margin: 16px 0;
    background: var(--bg-base);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 8px;
    overflow: hidden;
}

.chart-container canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.chart-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ---- 2x2 Table ---- */
.table-2x2 {
    display: grid;
    grid-template-columns: 120px 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 1px;
    background: var(--border-strong);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 16px 0;
    max-width: 400px;
}

.table-2x2 > div {
    background: var(--bg-surface);
    padding: 10px 12px;
    text-align: center;
}

.table-2x2 .header {
    background: var(--bg-elevated);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.table-2x2 input {
    width: 100%;
    text-align: center;
    background: var(--bg-base);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1rem;
    padding: 8px;
    outline: none;
}

.table-2x2 input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

/* ---- Checklist (Critical Appraisal) ---- */
.checklist-domain {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.checklist-domain-title {
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.checklist-question {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.checklist-question:last-child {
    border-bottom: none;
}

.checklist-question-text {
    font-size: 0.87rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.radio-pill {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-secondary);
    transition: all var(--transition);
}

.radio-pill input { display: none; }
.radio-pill:has(input:checked) {
    background: var(--accent-muted);
    border-color: var(--accent);
    color: var(--accent);
}

.risk-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.risk-badge--low { background: rgba(52,211,153,0.15); color: var(--success); }
.risk-badge--some { background: rgba(251,191,36,0.15); color: var(--warning); }
.risk-badge--high { background: rgba(248,113,113,0.15); color: var(--danger); }

/* ---- Traffic Light ---- */
.traffic-light {
    display: flex;
    gap: 6px;
    align-items: center;
}

.traffic-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
}

.traffic-dot--low { background: var(--success); border-color: var(--success); }
.traffic-dot--some { background: var(--warning); border-color: var(--warning); }
.traffic-dot--high { background: var(--danger); border-color: var(--danger); }
.traffic-dot--unclear { background: var(--text-tertiary); border-color: var(--text-tertiary); }

/* ---- Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes countUp {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.animate-in {
    animation: fadeIn 0.2s ease;
}

/* ---- Filter Tags ---- */
.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.filter-tag {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-secondary);
    transition: all var(--transition);
    font-family: var(--font-sans);
}

.filter-tag:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-tag.active {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
    font-weight: 500;
}

/* ---- Search ---- */
.search-box {
    position: relative;
    margin-bottom: 16px;
}

.search-box input {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.93rem;
    outline: none;
    font-family: var(--font-sans);
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.search-box::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 50%;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    background: var(--text-tertiary);
    pointer-events: none;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---- Trial Cards ---- */
.trial-card {
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.trial-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.trial-card.expanded {
    border-color: var(--accent);
}

.trial-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.trial-card-name {
    font-weight: 600;
    color: var(--accent);
    font-size: 0.95rem;
}

.trial-card-year {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

.trial-card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.trial-card-tags {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.trial-tag {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    background: var(--bg-elevated);
    color: var(--text-tertiary);
    border: 1px solid var(--border);
}

.trial-detail {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: none;
}

.trial-card.expanded .trial-detail {
    display: block;
}

/* ---- Text Area Output ---- */
.text-output {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 0.87rem;
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-wrap;
    font-family: var(--font-sans);
    position: relative;
}

.text-output .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
}

/* ---- Expandable ---- */
.expandable-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.expandable-header::before {
    content: '▸';
    transition: transform var(--transition);
}

.expandable-header.open::before {
    transform: rotate(90deg);
}

.expandable-body {
    display: none;
    padding: 10px 0 10px 20px;
}

.expandable-header.open + .expandable-body {
    display: block;
}

/* ---- Mobile Bottom Nav ---- */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    /* Opaque fallback first: engines without color-mix() would otherwise drop
       the declaration and let content scroll through this fixed bar. */
    background: var(--bg-surface);
    background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding: 0 8px;
}

.mobile-nav-items {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: space-around;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    color: var(--text-tertiary);
    font-size: 0.6rem;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
    background: none;
    border: none;
    font-family: var(--font-sans);
}

.mobile-nav-item.active {
    color: var(--accent);
}

.mobile-nav-item-icon {
    font-size: 1.2rem;
}

/* ---- Responsive ---- */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        z-index: 300;
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0;
        padding: 24px 20px 80px;
        width: 100%;
        max-width: none;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 250;
    }

    .sidebar-overlay.visible {
        display: block;
    }
}

@media (max-width: 767px) {
    .mobile-nav {
        display: block;
    }

    .main-content {
        padding: 16px 14px 80px;
    }

    .dashboard-hero {
        align-items: stretch;
        flex-direction: column;
        gap: 16px;
    }

    .dashboard-search-btn {
        min-width: 0;
        width: 100%;
    }

    .form-row--3,
    .form-row--4 {
        grid-template-columns: 1fr 1fr;
    }

    .result-grid {
        grid-template-columns: 1fr 1fr;
    }

    .card {
        padding: 16px;
    }

    h1 { font-size: 1.4rem; }

    .tabs {
        gap: 0;
    }

    .tab {
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    .data-table {
        font-size: 0.78rem;
    }

    .data-table th, .data-table td {
        padding: 8px 6px;
    }
}

@media (max-width: 375px) {
    .form-row--2,
    .form-row--3,
    .form-row--4 {
        grid-template-columns: 1fr;
    }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ---- Misc Utilities ---- */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.text-accent { color: var(--accent); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 600; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ============================================================
   UI/UX ENHANCEMENTS — Command Palette, Favorites, Breadcrumbs,
   Keyboard Shortcuts, Enhanced Mobile, Module Footer, Dashboard
   ============================================================ */

/* ---- Sidebar Search Button (Cmd+K trigger) ---- */
.sidebar-cmd-k-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-tertiary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
}

.sidebar-cmd-k-btn:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.sidebar-cmd-k-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kbd-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    background: var(--bg-base);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: var(--font-sans);
    color: var(--text-tertiary);
    line-height: 1;
    min-width: 20px;
}

/* ---- Sidebar Favorites Star ---- */
.sidebar-fav-star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    min-height: 40px;
    margin: 0 6px 0 0;
    padding: 0;
    font-size: 0.85rem;
    color: var(--text-tertiary);
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
    line-height: 1;
}

.sidebar-module-row:hover .sidebar-fav-star,
.sidebar-fav-star:focus-visible,
.sidebar-fav-star.active {
    opacity: 1;
}

.sidebar-fav-star.active {
    color: var(--warning);
}

.sidebar-fav-star:hover {
    color: var(--warning) !important;
    opacity: 1 !important;
    background: var(--bg-hover);
}

.sidebar-favorites-group {
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.sidebar-favorites-items {
    max-height: 176px;
    overflow-y: auto;
}

/* ---- Command Palette Overlay ---- */
.cmd-palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: min(20vh, 140px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.cmd-palette-overlay.visible {
    opacity: 1;
    visibility: visible;
}

[data-theme="light"] .cmd-palette-overlay {
    background: rgba(0, 0, 0, 0.35);
}

.cmd-palette-dialog {
    width: 580px;
    max-width: calc(100vw - 32px);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: translateY(-10px);
    transition: transform 0.15s ease;
}

.cmd-palette-overlay.visible .cmd-palette-dialog {
    transform: translateY(0);
}

[data-theme="light"] .cmd-palette-dialog {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.cmd-palette-input-wrap {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}

.cmd-palette-search-icon {
    display: inline-flex;
    align-items: center;
    font-size: 1.05rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.cmd-palette-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
}

.cmd-palette-input::placeholder {
    color: var(--text-tertiary);
}

.cmd-palette-status {
    margin: 0;
    padding: 7px 16px;
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

.cmd-palette-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.cmd-palette-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    gap: 12px;
}

.cmd-palette-item[role="option"] {
    outline: none;
}

.cmd-palette-item:hover,
.cmd-palette-item.selected {
    background: var(--bg-hover);
}

.cmd-palette-item.selected {
    background: var(--accent-muted);
}

.cmd-palette-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.cmd-palette-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--accent);
    flex-shrink: 0;
}

.cmd-palette-item-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-palette-item-desc {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.cmd-palette-item-cat {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    flex-shrink: 0;
}

.cmd-palette-empty {
    padding: 32px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* ---- Shortcuts Modal ---- */
.shortcuts-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.shortcuts-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

[data-theme="light"] .shortcuts-modal-overlay {
    background: rgba(0, 0, 0, 0.35);
}

.shortcuts-modal-dialog {
    width: 420px;
    max-width: calc(100vw - 32px);
    max-height: 80vh;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

[data-theme="light"] .shortcuts-modal-dialog {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

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

.shortcuts-modal-header h3 {
    font-size: 1rem;
    color: var(--text-primary);
}

.shortcuts-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.shortcut-row kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: var(--font-sans);
    color: var(--text-primary);
    font-weight: 500;
    box-shadow: 0 1px 0 var(--border-strong);
}

.shortcuts-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.shortcut-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

/* ---- Breadcrumb Navigation ---- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    flex-wrap: wrap;
}

.breadcrumb-item {
    color: var(--text-tertiary);
}

.breadcrumb-link {
    cursor: pointer;
    transition: color var(--transition);
}

.breadcrumb-link:hover {
    color: var(--accent);
}

.breadcrumb-sep {
    color: var(--text-tertiary);
    opacity: 0.5;
    font-size: 0.9rem;
}

.breadcrumb-current {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---- Module Footer ---- */
.module-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    margin-top: 40px;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-tertiary);
    flex-wrap: wrap;
    gap: 12px;
}

.module-footer-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.module-footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.module-footer-link {
    color: var(--text-tertiary);
    transition: color var(--transition);
    font-size: 0.78rem;
}

.module-footer-link:hover {
    color: var(--accent);
}

.module-footer-share {
    font-size: 0.78rem;
}

/* ---- Dashboard / Welcome Page ---- */
.dashboard {
    max-width: 1120px;
}

.dashboard-hero {
    text-align: left;
    padding: 20px 0 28px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.dashboard-hero-copy {
    min-width: 0;
}

.dashboard-hero-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--info) 100%);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--accent-contrast);
    font-weight: 800;
    margin-bottom: 16px;
}

.dashboard-hero-title {
    font-size: clamp(2rem, 5vw, 3.4rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
    letter-spacing: -0.045em;
}

.dashboard-hero-sub {
    font-size: 1.02rem;
    color: var(--text-secondary);
    margin: 8px 0 0;
    max-width: 56ch;
    text-wrap: pretty;
}

.dashboard-search-btn-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.dashboard-search-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--text-tertiary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
    min-width: min(360px, 48%);
    justify-content: space-between;
}

.dashboard-search-btn:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* ---- Dashboard Stats ---- */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin-bottom: 36px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--bg-surface) 86%, transparent);
}

.dashboard-stat {
    background: transparent;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    padding: 18px;
    text-align: center;
    box-shadow: none;
}

.dashboard-stat:last-child {
    border-right: 0;
}

.dashboard-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums lining-nums;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.dashboard-stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---- Dashboard Section ---- */
.dashboard-section {
    margin-bottom: 28px;
}

.dashboard-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.dashboard-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.01em;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.dashboard-section-title::before {
    content: '';
    width: 3px;
    height: 16px;
    border-radius: 2px;
    background: var(--accent);
    flex-shrink: 0;
}

.dashboard-section-heading .dashboard-section-title {
    margin: 0;
    padding: 0;
    border: 0;
}

.dashboard-browse-all {
    min-height: 40px;
    padding: 7px 12px;
    color: var(--accent);
    background: var(--accent-muted);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.dashboard-browse-all:hover {
    color: var(--accent-contrast);
    background: var(--accent);
}

/* ---- Dashboard Module Grid ---- */
.dashboard-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.dashboard-module-card {
    display: block;
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: none;
    position: relative;
    overflow: hidden;
    color: inherit;
    font: inherit;
    text-align: left;
    appearance: none;
}

.dashboard-module-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--accent);
    opacity: 0;
    transition: opacity var(--transition);
}

.dashboard-module-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.dashboard-module-card:hover::before,
.dashboard-module-card:focus-visible::before {
    opacity: 1;
}

.dashboard-module-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent-muted);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.dashboard-module-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.dashboard-module-desc {
    display: block;
    font-size: 0.78rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* ---- Dashboard Categories ---- */
.dashboard-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.dashboard-category-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashboard-category-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.dashboard-category-num {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-muted);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
}

.dashboard-category-title {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.dashboard-category-count {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

/* ---- Dashboard Changelog ---- */
.dashboard-changelog {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dashboard-changelog li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.87rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.dashboard-changelog li:last-child {
    border-bottom: none;
}

.dashboard-changelog li strong {
    color: var(--text-primary);
}

.dashboard-changelog li kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: var(--font-sans);
    color: var(--text-primary);
    font-weight: 500;
    vertical-align: middle;
}

/* ---- Enhanced Mobile Nav ---- */
@media (max-width: 767px) {
    .mobile-nav {
        height: 68px;
        padding: 0 4px;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .mobile-nav-item {
        padding: 6px 8px;
        font-size: 0.58rem;
        border-radius: var(--radius);
        position: relative;
    }

    .mobile-nav-item.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 2px;
        background: var(--accent);
        border-radius: 1px;
    }

    .mobile-nav-item-icon {
        font-size: 1.3rem;
    }

    /* Smoother sidebar overlay on mobile */
    .sidebar {
        transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .sidebar-overlay {
        transition: opacity 0.3s ease;
        opacity: 0;
    }

    .sidebar-overlay.visible {
        display: block;
        opacity: 1;
    }

    /* Dashboard responsive */
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-hero-title {
        font-size: 1.5rem;
    }

    .dashboard-module-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-categories {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-search-btn {
        min-width: 200px;
    }

    .breadcrumb {
        font-size: 0.72rem;
    }

    .cmd-palette-item-desc {
        display: none;
    }

    .module-footer {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 375px) {
    .dashboard-stats {
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-categories {
        grid-template-columns: 1fr;
    }
}

/* ---- Sidebar overlay transitions (all screens) ---- */
.sidebar-overlay {
    transition: opacity 0.25s ease;
}

/* ---- Mobile Header Bar ---- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--bg-surface);
    background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 90;
    padding: 0 12px;
    align-items: center;
    justify-content: space-between;
}

.mobile-header-menu,
.mobile-header-search {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.mobile-header-menu:hover,
.mobile-header-search:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mobile-header-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    letter-spacing: -0.01em;
}

@media (max-width: 1023px) {
    .mobile-header {
        display: flex;
    }

    .main-content {
        padding-top: 64px;
    }
}

@media (max-width: 767px) {
    .main-content {
        padding-top: 56px;
        padding-bottom: 84px;
    }
}

/* ── R Script Modal ───────────────────────────────── */
.r-script-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0,0,0,0.6); display: flex;
    align-items: center; justify-content: center;
    padding: 1rem; backdrop-filter: blur(4px);
}
.r-script-modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; width: 100%; max-width: 720px;
    max-height: 80vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.r-script-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
}
.r-script-title { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.r-script-actions { display: flex; gap: 0.5rem; }
.r-script-actions .btn { font-size: 0.8rem; padding: 0.3rem 0.6rem; }
.r-script-body {
    flex: 1; overflow: auto; padding: 1rem; margin: 0;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem; line-height: 1.55; color: var(--text);
    white-space: pre; tab-size: 2; background: var(--bg);
}
.r-script-btn {
    background: var(--surface) !important;
    border: 1px solid var(--accent) !important;
    color: var(--accent) !important;
    font-size: 0.8rem !important;
    margin-top: 0.5rem;
}
.r-script-btn:hover { background: var(--accent) !important; color: var(--bg) !important; }

/* ============================================================
   v2.1 Polish — Hover States, Accessibility, Mobile Touch,
   Print, Reduced Motion, Focus Rings
   ============================================================ */

/* 1. Card Hover Elevation */
.card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg), inset 0 1px 0 var(--highlight);
}

/* 2. Table Zebra Striping */
.data-table tbody tr:nth-child(even) td {
    background: var(--bg-elevated);
}
.data-table tbody tr:nth-child(even):hover td {
    background: var(--bg-hover);
}

/* 3. Table Scroll Wrapper */
.table-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
}

/* 4. Button Active/Pressed States */
.btn:active {
    transform: scale(0.97);
}
.btn-primary:active {
    background: var(--accent);
    box-shadow: none;
}

/* 5. Focus-Visible Rings (Accessibility) */
.btn:focus-visible,
.tab:focus-visible,
.filter-tag:focus-visible,
.preset-btn:focus-visible,
.trial-card:focus-visible,
.sidebar-link:focus-visible,
.sidebar-logo:focus-visible,
.sidebar-cmd-k-btn:focus-visible,
.sidebar-group-toggle:focus-visible,
.sidebar-fav-star:focus-visible,
.dashboard-search-btn:focus-visible,
.dashboard-browse-all:focus-visible,
.dashboard-module-card:focus-visible,
.dashboard-category-card:focus-visible,
.dashboard-calc-entry:focus-visible,
.mobile-nav-item:focus-visible,
.mobile-header-title:focus-visible,
.mobile-header-menu:focus-visible,
.mobile-header-search:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.form-input:focus-visible,
.form-select:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

/* 6. Disabled State Styling */
.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.form-input:disabled,
.form-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    /* background-color, not the shorthand: the shorthand would reset the
       custom chevron background-image on .form-select. */
    background-color: var(--bg-base);
}

/* 7. Reduced Motion Media Query */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 8. Print Styles */
@media print {
    .sidebar, .mobile-nav, .mobile-header, .sidebar-overlay,
    .cmd-palette-overlay, .shortcuts-modal-overlay, .module-footer,
    .btn, .btn-group, .breadcrumb, .ne-toast {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }
    .result-panel {
        border-left: 3px solid #333 !important;
        background: #f9f9f9 !important;
    }
    body {
        background: white !important;
        color: black !important;
    }
    a { color: black !important; text-decoration: underline !important; }
}

/* 9. Mobile Touch Targets (44px minimum on mobile) */
@media (max-width: 767px) {
    .btn-sm {
        height: 40px;
        padding: 0 16px;
        font-size: 0.82rem;
    }
    .btn-xs {
        height: 36px;
        padding: 0 14px;
        font-size: 0.78rem;
    }
    .preset-btn {
        padding: 8px 14px;
        font-size: 0.78rem;
    }
    .radio-pill {
        padding: 8px 14px;
        font-size: 0.78rem;
    }
    .filter-tag {
        padding: 8px 16px;
        font-size: 0.78rem;
    }
    .tab {
        padding: 10px 14px;
        font-size: 0.8rem;
        min-height: 44px;
    }
    .trial-card {
        padding: 16px;
    }
    .checkbox-label, label.form-label {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* 10. R Script Modal Full-Screen on Mobile */
@media (max-width: 767px) {
    .r-script-overlay {
        padding: 0;
    }
    .r-script-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        height: 100vh;
    }
    .cmd-palette-dialog {
        max-width: 100%;
        border-radius: 0;
        margin: 0;
    }
    .cmd-palette-overlay {
        padding-top: 0;
    }
    .shortcuts-modal-dialog {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* 12. Form Row Single-Column on Small Screens */
@media (max-width: 480px) {
    .form-row,
    .form-row--2,
    .form-row--3,
    .form-row--4 {
        grid-template-columns: 1fr;
    }
    .result-grid {
        grid-template-columns: 1fr;
    }
    .table-2x2 {
        grid-template-columns: 80px 1fr 1fr;
        font-size: 0.85rem;
    }
}

/* 13. Smooth Scroll for Sidebar */
.sidebar-nav {
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

/* 14. Selection Color */
::selection {
    background: var(--accent);
    color: var(--accent-contrast);
}

/* 15. Form Validation States */
.form-input.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.15);
}
.form-input.is-valid {
    border-color: var(--success);
}
.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
    display: none;
}
.form-input.is-invalid + .form-error {
    display: block;
}

/* 16. Skip-to-Content Link (A11y) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: var(--accent-contrast);
    padding: 8px 16px;
    z-index: 100000;
    font-weight: 600;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 0;
}

/* 17. Result Panel Enhancements */
.result-panel--success {
    border-left-color: var(--success);
}
.result-panel--warning {
    border-left-color: var(--warning);
}
.result-panel--danger {
    border-left-color: var(--danger);
}

/* 18. Loading Spinner */
.ne-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 19. Tooltip Improvements for Mobile */
@media (max-width: 767px) {
    .tooltip-content {
        width: 220px;
        font-size: 0.75rem;
        padding: 8px 12px;
    }
    .tooltip-trigger {
        width: 20px;
        height: 20px;
        font-size: 0.65rem;
    }
}

/* 20. Safe Area Insets for Mobile Sidebar */
@supports (padding: env(safe-area-inset-left)) {
    @media (max-width: 1023px) {
        .sidebar {
            padding-left: env(safe-area-inset-left);
        }
    }
}

/* Accessibility & mobile touch-target refinements (audit 2026) */
@media (max-width: 767px) {
    /* WCAG 2.5.5 / iOS HIG: interactive targets should be at least ~44px. */
    .mobile-header-menu,
    .mobile-header-search,
    .theme-toggle {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .sidebar-link,
    .sidebar-group-toggle,
    .sidebar-fav-star {
        min-height: 44px;
    }

    .sidebar-fav-star {
        flex-basis: 44px;
        width: 44px;
        opacity: 1;
    }

    .dashboard-hero-title {
        display: none;
    }

    .dashboard-hero {
        padding-top: 4px;
    }

    .dashboard-section-heading {
        align-items: center;
    }

    .dashboard-browse-all {
        min-height: 44px;
    }

    .btn-xs,
    .btn-sm {
        min-height: 44px;
    }

    /* Keep toasts clear of the fixed bottom navigation and the home indicator. */
    .ne-toast {
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    }
}

body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 1023px) {
    .dashboard-hero-title {
        display: none;
    }
}

/* Site footer — lives inside .main-content so it clears the fixed sidebar
   on desktop and the fixed bottom nav on mobile. */
.site-footer {
    margin-top: 40px;
    padding: 20px 0 8px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

.site-footer p + p {
    margin-top: 8px;
}

.site-footer a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

/* Shown only when scripts are disabled; the app cannot render without them. */
.noscript-notice {
    margin: 0 0 24px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.site-footer a + a {
    margin-left: 15px;
}

/* Screen finish: shared surfaces and interaction states. Keep layout, type
   metrics, scientific notation, semantic status colours and print unchanged. */
@media screen {
    :root {
        --bg-base: #09121d;
        --bg-surface: #101e2e;
        --bg-elevated: #16283a;
        --bg-hover: #1c3346;
        --text-primary: #f2f7fc;
        --text-secondary: #b9c9d8;
        --text-tertiary: #9fb2c5;
        --accent: #72e4cf;
        --accent-hover: #a1f2e2;
        --accent-muted: rgba(114, 228, 207, 0.10);
        --border: rgba(165, 194, 218, 0.16);
        --border-strong: rgba(165, 194, 218, 0.29);
        --highlight: rgba(226, 244, 255, 0.07);
        --shadow: 0 2px 4px rgba(0, 8, 20, 0.12), 0 12px 28px -20px rgba(0, 8, 20, 0.65);
        --shadow-lg: 0 8px 28px -12px rgba(0, 8, 20, 0.55);
        --radius-lg: 16px;
        --radius-xl: 20px;
        --surface-sheen: rgba(191, 221, 244, 0.035);
        --canvas-glow: rgba(56, 153, 168, 0.13);
        --canvas-blue: rgba(91, 126, 204, 0.09);
        --field-bg: #0d1a28;
    }

    [data-theme="light"] {
        --bg-base: #edf3f8;
        --bg-surface: #ffffff;
        --bg-elevated: #f2f6fa;
        --bg-hover: #e7f0f5;
        --text-primary: #152c40;
        --text-secondary: #455f73;
        --text-tertiary: #536e83;
        --accent: #096e66;
        --accent-hover: #07584f;
        --accent-muted: rgba(9, 110, 102, 0.07);
        --border: rgba(56, 91, 119, 0.15);
        --border-strong: rgba(56, 91, 119, 0.30);
        --highlight: rgba(255, 255, 255, 0.95);
        --shadow: 0 2px 4px rgba(24, 54, 77, 0.025), 0 12px 28px -20px rgba(24, 54, 77, 0.27);
        --shadow-lg: 0 12px 30px -14px rgba(24, 54, 77, 0.26);
        --surface-sheen: rgba(255, 255, 255, 0.65);
        --canvas-glow: rgba(84, 176, 174, 0.11);
        --canvas-blue: rgba(93, 146, 205, 0.10);
        --field-bg: #fcfdff;
    }

    body {
        background-image:
            radial-gradient(ellipse 1000px 620px at 35% -180px, var(--canvas-glow), transparent 78%),
            radial-gradient(ellipse 740px 560px at 100% 0, var(--canvas-blue), transparent 80%);
        background-size: auto;
        background-repeat: no-repeat;
    }

    .sidebar { border-right-color: var(--border-strong); }
    .sidebar-header, .sidebar-footer, .mobile-header, .mobile-nav {
        background: linear-gradient(120deg, var(--surface-sheen), transparent), var(--bg-surface);
    }
    .sidebar-link.active {
        background: linear-gradient(90deg, var(--accent-muted), transparent);
        box-shadow: inset 0 1px var(--highlight), inset 0 -1px var(--highlight);
    }
    .sidebar-logo-icon, .dashboard-module-icon, .dashboard-category-num {
        box-shadow: inset 0 0 0 1px var(--border-strong), 0 3px 8px -4px var(--scroll-shadow);
    }

    .card, .dashboard-module-card, .dashboard-category-card, .trial-card {
        background-image: linear-gradient(145deg, var(--surface-sheen), transparent 65%);
        box-shadow: var(--shadow), inset 0 1px var(--highlight);
    }
    .dashboard-module-card:hover, .dashboard-category-card:hover {
        box-shadow: var(--shadow-lg), inset 0 1px var(--highlight);
    }
    .dashboard-module-desc { color: var(--text-secondary); }
    .dashboard-stats {
        background: linear-gradient(110deg, var(--accent-muted), transparent 80%), var(--bg-surface);
        border-color: var(--border-strong);
        box-shadow: var(--shadow), inset 0 1px var(--highlight);
    }
    .dashboard-hero { border-bottom-color: var(--border-strong); }
    .dashboard-search-btn, .sidebar-cmd-k-btn {
        color: var(--text-secondary);
        background: var(--field-bg);
        box-shadow: inset 0 1px 3px rgba(0, 8, 20, 0.05);
    }

    .form-input, .form-select {
        background-color: var(--field-bg);
        box-shadow: inset 0 1px 3px rgba(0, 8, 20, 0.05);
    }
    .btn-primary {
        box-shadow: 0 4px 12px -7px var(--accent), inset 0 1px rgba(255, 255, 255, 0.18);
    }
    .tab.active {
        background: linear-gradient(0deg, var(--accent-muted), transparent);
        box-shadow: inset 0 -1px var(--accent);
    }
    .result-panel {
        background-image: linear-gradient(110deg, var(--accent-muted), transparent);
        box-shadow: var(--shadow), inset 0 1px var(--highlight);
    }
    .data-table th {
        color: var(--text-primary);
        background: var(--bg-elevated);
        border-bottom-color: var(--border-strong);
    }
    .cmd-palette-dialog, .shortcuts-modal-dialog {
        box-shadow: 0 24px 80px -20px var(--scroll-shadow), inset 0 1px var(--highlight);
    }
}
