/* ╔════════════════════════════════════════════════════════════════╗
   ║  ProjectY — Direction B "Lab Instrument" theme                 ║
   ║  Dark, monospace-forward, oscilloscope/terminal feel.          ║
   ║  Phosphor green primary, amber + cyan secondary.               ║
   ╚════════════════════════════════════════════════════════════════╝ */

:root {
    /* ── Background scale (deep matte) ────────────────────────── */
    --bg:           #0a0d10;     /* page */
    --bg-elevated:  #10141a;     /* nav, panels */
    --bg-card:      #10141a;     /* cards */
    --bg-panel:     #161b22;     /* secondary panel, table head */
    --bg-hover:     #1c222b;
    --bg-active:    #232a35;

    /* ── Borders (rule lines) ─────────────────────────────────── */
    --border:        #1f242c;    /* rule */
    --border-light:  #2a313c;    /* rule2 */
    --border-strong: #38404d;

    /* ── Text scale ───────────────────────────────────────────── */
    --text:           #e6edf3;   /* ink */
    --text-secondary: #adb5bd;
    --text-muted:     #7d8590;   /* ink2 */
    --text-dim:       #6b7488;   /* ink3 — lightened for WCAG AA (was #484f58, failed contrast) */

    /* ── Accent palette — phosphor + amber + cyan ─────────────── */
    --accent:         #5fd49a;   /* phosphor green */
    --accent-hover:   #7ee0af;
    --accent-soft:    rgba(95, 212, 154, 0.14);
    --accent-strong:  rgba(95, 212, 154, 0.28);

    --green:        #5fd49a;
    --green-soft:   rgba(95, 212, 154, 0.18);
    --red:          #e07a5f;
    --red-soft:     rgba(224, 122, 95, 0.16);
    --yellow:       #e6b86b;     /* amber */
    --yellow-soft:  rgba(230, 184, 107, 0.16);
    --orange:       #e6b86b;
    --pink:         #e07a5f;
    --cyan:         #6ec1ff;
    --cyan-soft:    rgba(110, 193, 255, 0.16);

    /* ── Typography ──────────────────────────────────────────── */
    --font: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont,
            'Segoe UI', system-ui, sans-serif;
    --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace,
            'SF Mono', Menlo, monospace;

    /* ── Spacing scale ───────────────────────────────────────── */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;
    --sp-8: 64px;

    /* ── Radius scale (sharp instrument feel) ─────────────────── */
    --r-sm: 2px;
    --r-md: 3px;
    --r-lg: 4px;
    --r-xl: 6px;

    /* ── Shadows (mostly flat — instrument aesthetic) ─────────── */
    --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.3);
    --shadow:    0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ── Base typography ──────────────────────────────────────────── */
html, body {
    font-family: var(--font);
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--text);
    background: var(--bg);
    letter-spacing: -0.005em;
}

/* ── Top nav — instrument-style ────────────────────────────── */
.topnav {
    height: 52px;
    padding: 0 var(--sp-5);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    gap: var(--sp-6);
}
.nav-brand {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: -0.01em;
    color: var(--accent);
    text-transform: lowercase;
    display: inline-flex; align-items: center; gap: 8px;
}
.nav-brand::before {
    content: ""; width: 14px; height: 14px;
    border: 1px solid var(--accent);
    background:
      linear-gradient(transparent 49%, var(--accent) 49%, var(--accent) 51%, transparent 51%);
    background-size: 100% 100%;
    flex-shrink: 0;
}
.nav-links { gap: 2px; }
.nav-links a, .nav-right > a {
    font-family: var(--mono);
    color: var(--text-muted);
    padding: 6px 11px;
    border-radius: var(--r-md);
    font-size: 0.78rem;
    font-weight: 400;
    text-transform: lowercase;
    letter-spacing: 0;
    transition: color 0.12s ease, background 0.12s ease;
}
.nav-links a:hover { background: var(--bg-hover); color: var(--text); }
.nav-links a.active {
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
}
.subnav {
    height: 40px;
    padding: 0 var(--sp-5);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    gap: 2px;
}
.subnav a {
    font-family: var(--mono);
    padding: 5px 10px;
    border-radius: var(--r-md);
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 400;
    text-transform: lowercase;
    transition: color 0.12s ease, background 0.12s ease;
}
.subnav a:hover { background: var(--bg-hover); color: var(--text); }
.subnav a.active {
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
}

main { padding: var(--sp-6) var(--sp-6) var(--sp-8); }

/* ── Page header — labelled like a lab page ──────────────────── */
.page-header {
    margin-bottom: var(--sp-5);
    padding-bottom: var(--sp-4);
    border-bottom: 1px solid var(--border);
    display: block;
    position: relative;
}
.page-header h1 {
    font-size: 1.85rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    margin-bottom: 4px;
    line-height: 1.1;
}
.page-header .subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    margin: 0;
}
.page-header::before {
    content: attr(data-label);
    display: block;
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 8px;
}

/* ── Tabs (Subject Data, Proprioception) ─────────────────────── */
.module-tabs {
    display: inline-flex;
    gap: 0;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: var(--sp-5);
    overflow: hidden;
}
.mtab {
    padding: 7px 14px;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font: 500 0.78rem var(--mono);
    text-transform: lowercase;
    border-radius: 0;
    cursor: pointer;
    transition: color 0.12s ease, background 0.12s ease;
}
.mtab:last-child { border-right: none; }
.mtab:hover { color: var(--text); background: var(--bg-hover); }
.mtab.active {
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
}

/* ── Tables ───────────────────────────────────────────────────── */
.tbl-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}
.data-table th {
    background: var(--bg-panel);
    color: var(--text-muted);
    font-family: var(--mono);
    font-weight: 500;
    text-transform: lowercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    z-index: 1;
}
.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table .muted { color: var(--text-dim); font-size: 0.85em; }

/* ── Group tags (HC / cLBP / aLBP) — instrument chip style ─── */
.g-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: var(--r-sm);
    font: 600 0.66rem var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--bg-panel);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.g-tag.g-hc   { background: var(--green-soft);  color: var(--green); border-color: rgba(95, 212, 154, 0.4); }
.g-tag.g-clbp { background: var(--red-soft);    color: var(--red);   border-color: rgba(224, 122, 95, 0.4); }
.g-tag.g-albp { background: var(--yellow-soft); color: var(--yellow); border-color: rgba(230, 184, 107, 0.4); }

/* ── Empty state (sauberer) ──────────────────────────────────── */
.empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border-light);
    border-radius: var(--r-lg);
    padding: var(--sp-7) var(--sp-5);
    text-align: center;
    color: var(--text-muted);
}
.empty-state .es-icon {
    font-size: 2rem; margin-bottom: var(--sp-3);
    line-height: 1; opacity: 0.85;
}
.empty-state h3 {
    font-size: 1.05rem; font-weight: 600;
    color: var(--text); margin-bottom: var(--sp-2);
    letter-spacing: -0.01em;
}
.empty-state p {
    font-size: 0.9rem; line-height: 1.6;
    max-width: 540px; margin: 0 auto;
}
.empty-state code {
    background: var(--bg-panel);
    padding: 1px 6px;
    border-radius: 4px;
    font: 500 0.83em var(--mono);
    color: var(--accent);
}

/* ── Pane info banner ────────────────────────────────────────── */
.pane-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    padding: var(--sp-4) var(--sp-5);
    margin-bottom: var(--sp-5);
    font-size: 0.92rem;
    line-height: 1.6;
}
.pane-info code {
    background: var(--bg-panel);
    padding: 1px 6px; border-radius: 4px;
    font: 500 0.85em var(--mono); color: var(--accent);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border-radius: var(--r-sm);
    font: 500 0.875rem var(--font);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn.btn-primary {
    background: var(--accent); color: var(--bg);
    border-color: var(--accent); box-shadow: var(--shadow-sm);
}
.btn.btn-primary:hover {
    background: var(--accent-hover); border-color: var(--accent-hover);
    transform: translateY(-1px); box-shadow: var(--shadow);
}
.btn.btn-sm { padding: 5px 11px; font-size: 0.8rem; }

/* ── Code/inline tags ────────────────────────────────────────── */
code {
    font-family: var(--mono);
    font-size: 0.88em;
    background: var(--bg-panel);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--accent);
}

/* ── Drive Sync Indicator ────────────────────────────────────── */
.sync-indicator {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font: 500 0.78rem var(--font);
    color: var(--text-muted);
    cursor: default;
}
.sync-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}
.sync-dot.sync-ok      { background: var(--green); box-shadow: 0 0 6px var(--green-soft); }
.sync-dot.sync-pending { background: var(--text-dim); animation: pulse 1.4s ease-in-out infinite; }
.sync-dot.sync-new     { background: var(--accent); box-shadow: 0 0 8px var(--accent-strong);
                          animation: pulse 1s ease-in-out infinite; }
@keyframes pulse {
    50% { opacity: 0.4; }
}
.sync-label { white-space: nowrap; }
.sync-link {
    color: var(--accent); text-decoration: none; font-weight: 600;
    margin-left: 2px;
}
.sync-link:hover { text-decoration: underline; }

/* ── Admin settings icon in top-nav (always visible when admin) ── */
.nav-settings-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    color: var(--text-muted);
    text-decoration: none; font-size: 1rem;
    border-radius: var(--r-sm);
    transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.nav-settings-icon:hover {
    color: var(--text);
    background: var(--bg-hover);
    transform: rotate(45deg);
}
.nav-settings-icon.active {
    color: var(--accent);
    background: var(--accent-soft);
}

/* ── Auth-required modal (login gate) ──────────────────────── */
.auth-modal {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(10, 13, 16, 0.78);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: var(--sp-4);
}
.auth-modal[hidden] { display: none; }
.auth-modal-card {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--r-md);
    padding: var(--sp-6) var(--sp-7);
    max-width: 480px; width: 100%;
    box-shadow: 0 0 0 1px var(--accent-soft) inset, 0 16px 48px rgba(0, 0, 0, 0.6);
    position: relative;
}
.auth-modal-card::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0;
    height: 2px; background: var(--accent);
}
.auth-modal-pre {
    font: 500 0.7rem var(--mono);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 8px;
}
.auth-modal-title {
    font-size: 1.4rem; font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0 0 var(--sp-3);
    color: var(--text);
}
.auth-modal-body {
    color: var(--text-secondary);
    font-size: 0.93rem;
    line-height: 1.6;
    margin: 0 0 var(--sp-5);
}
.auth-modal-body b { color: var(--text); font-weight: 600; }
.auth-modal-actions {
    display: flex; gap: var(--sp-2);
    flex-wrap: wrap;
}
.auth-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 9px 18px;
    border-radius: var(--r-md);
    font: 500 0.86rem var(--mono);
    text-decoration: none;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
}
.auth-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.auth-btn-primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    font-weight: 600;
}
.auth-btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Accessibility: visible keyboard focus (2026-05-30) — keyboard-only, pointer UX unchanged */
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,[tabindex]:focus-visible,[role="button"]:focus-visible{outline:2px solid var(--accent,#5fd49a);outline-offset:2px;border-radius:2px;}
