/* ============================================================
   MCSAero — Complete Stylesheet
   ============================================================ */

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

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

:root {
    --bg:             #08090d;
    --surface:        #0f1117;
    --surface2:       #151921;
    --border:         rgba(255,255,255,0.06);
    --border-hover:   rgba(255,255,255,0.12);
    --text:           #e6edf3;
    --text-secondary: #8b949e;
    --muted:          #6e7681;
    --accent:         #e63946;
    --accent-hover:   #ff4d5a;
    --accent-dim:     rgba(230,57,70,0.12);
    --success:        #3fb950;
    --success-bg:     rgba(63,185,80,0.1);
    --warning:        #d29922;
    --warning-bg:     rgba(210,153,34,0.1);
    --danger:         #f85149;
    --sidebar-w:      220px;
    --font:           'Inter', system-ui, -apple-system, sans-serif;
    --radius:         3px;
    --radius-lg:      5px;
    --radius-xl:      8px;
    --shadow:         0 1px 3px rgba(0,0,0,0.5);
    --shadow-lg:      0 8px 32px rgba(0,0,0,0.6);
    --bg-deep:        #030305;
    --accent-glow:    rgba(230,57,70,0.2);
    --data-color:     #58a6ff;
    --font-mono:      'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ── COLOR THEMES ──────────────────────────────────────── */

/* Charcoal — warm neutral grays */
[data-theme="charcoal"] {
    --bg:             #0e0e0e;
    --bg-deep:        #0a0a0a;
    --surface:        #161616;
    --surface2:       #1e1e1e;
    --border:         rgba(255,255,255,0.07);
    --border-hover:   rgba(255,255,255,0.14);
    --text:           #e0e0e0;
    --text-secondary: #999;
    --muted:          #666;
    --accent:         #e63946;
    --accent-hover:   #ff4d5a;
    --accent-dim:     rgba(230,57,70,0.12);

    --accent-glow:    rgba(230,57,70,0.2);
    --data-color:     #58a6ff;
    --bg-deep:        #050505;
}

/* Mocha — warm coffee/brown tones */
[data-theme="mocha"] {
    --bg:             #12100c;
    --bg-deep:        #0e0b08;
    --surface:        #1a1610;
    --surface2:       #221c14;
    --border:         rgba(210,170,120,0.1);
    --border-hover:   rgba(210,170,120,0.2);
    --text:           #e8ddd0;
    --text-secondary: #a89680;
    --muted:          #7a6b5a;
    --accent:         #e8943a;
    --accent-hover:   #f0a650;
    --accent-dim:     rgba(232,148,58,0.14);
    --success:        #8fba5a;
    --success-bg:     rgba(143,186,90,0.1);
    --warning:        #d4a040;
    --warning-bg:     rgba(212,160,64,0.1);
    --danger:         #d45050;

    --accent-glow:    rgba(232,148,58,0.2);
    --data-color:     #c4a06a;
    --bg-deep:        #080604;
}

/* Forest — deep green with emerald accent */
[data-theme="forest"] {
    --bg:             #060e08;
    --bg-deep:        #060e0a;
    --surface:        #0c1810;
    --surface2:       #121e18;
    --border:         rgba(100,200,140,0.08);
    --border-hover:   rgba(100,200,140,0.16);
    --text:           #d4e8dc;
    --text-secondary: #7fa892;
    --muted:          #5a7e6a;
    --accent:         #2ecc71;
    --accent-hover:   #45d98a;
    --accent-dim:     rgba(46,204,113,0.12);
    --success:        #2ecc71;
    --success-bg:     rgba(46,204,113,0.1);
    --warning:        #d4a840;
    --warning-bg:     rgba(212,168,64,0.1);
    --danger:         #e05555;

    --accent-glow:    rgba(46,204,113,0.2);
    --data-color:     #6bc4a0;
    --bg-deep:        #030806;
}

/* Dracula — purple accent, classic dark */
[data-theme="dracula"] {
    --bg:             #0e0c16;
    --bg-deep:        #0c0a14;
    --surface:        #161220;
    --surface2:       #1e1a2a;
    --border:         rgba(180,140,255,0.08);
    --border-hover:   rgba(180,140,255,0.16);
    --text:           #e4dff0;
    --text-secondary: #9088a8;
    --muted:          #6a6280;
    --accent:         #bd93f9;
    --accent-hover:   #cda4ff;
    --accent-dim:     rgba(189,147,249,0.14);
    --success:        #50fa7b;
    --success-bg:     rgba(80,250,123,0.1);
    --warning:        #f1fa8c;
    --warning-bg:     rgba(241,250,140,0.1);
    --danger:         #ff5555;

    --accent-glow:    rgba(189,147,249,0.2);
    --data-color:     #bd93f9;
    --bg-deep:        #060410;
}

/* Nord — blue-grey nordic palette */
[data-theme="nord"] {
    --bg:             #080c10;
    --bg-deep:        #080a0e;
    --surface:        #0e141c;
    --surface2:       #141c26;
    --border:         rgba(136,192,208,0.08);
    --border-hover:   rgba(136,192,208,0.16);
    --text:           #d8dee9;
    --text-secondary: #7b8da0;
    --muted:          #5a6d80;
    --accent:         #88c0d0;
    --accent-hover:   #9fd0de;
    --accent-dim:     rgba(136,192,208,0.14);
    --success:        #a3be8c;
    --success-bg:     rgba(163,190,140,0.1);
    --warning:        #ebcb8b;
    --warning-bg:     rgba(235,203,139,0.1);
    --danger:         #bf616a;

    --accent-glow:    rgba(136,192,208,0.2);
    --data-color:     #88c0d0;
    --bg-deep:        #040608;
}

/* Midnight — default, no override needed (uses :root values) */


html, body {
    height: 100%;
    background: var(--bg);
    background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ── LOGIN PAGE ──────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    background: var(--bg-deep);
    background-image: radial-gradient(rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.login-logo-img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    opacity: 0.85;
}

.login-page .login-card {
    border-top: 2px solid var(--accent);
    width: 100%;
    max-width: 300px;
    background: rgba(22,27,34,0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    box-shadow: var(--shadow-lg);
}

/* ── APP SHELL (sidebar + main) ──────────────────────────── */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    background-image: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(255,255,255,0.008) 3px, rgba(255,255,255,0.008) 4px);
}

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

.sidebar-logo-sub {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 2px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.brand-accent { color: var(--accent); }

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
}

.sidebar-section { margin-bottom: 4px; }

.sidebar-section-label {
    display: block;
    padding: 10px 16px 5px;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    text-decoration: none;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}

.sidebar-link.active {
    color: var(--accent);
    background: var(--accent-dim);
    border-left: 3px solid var(--accent);
    box-shadow: inset 4px 0 12px rgba(230,57,70,0.08);
    padding-left: 13px;
}

.nav-icon {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    flex-shrink: 0;
}

.sidebar-username {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

/* ── MAIN AREA ───────────────────────────────────────────── */

.main-area {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.main-content {
    padding: 28px;
    flex: 1;
}

/* ── PAGE HEADER ─────────────────────────────────────────── */

.page-header { margin-bottom: 28px; }

.page-eyebrow {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 4px;
}

.page-sub {
    font-size: 0.85rem;
    color: var(--muted);
}

/* ── STATS ROW ───────────────────────────────────────────── */

.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.stat-meta {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 4px;
}

/* ── SECTION HEADINGS ────────────────────────────────────── */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── PROJECT GRID / CARDS ────────────────────────────────── */

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
}

.project-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
    color: inherit;
}

.project-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.project-card-icon {
    font-size: 1.4rem;
}

.project-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.project-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
}

.project-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
}

.project-updated {
    font-size: 0.75rem;
    color: var(--muted);
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ── BADGES ──────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-active {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(63,185,80,0.25);
}

.badge-planned {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(255,109,0,0.25);
}

.badge-archived {
    background: rgba(110,118,129,0.1);
    color: var(--muted);
    border: 1px solid rgba(110,118,129,0.2);
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ── QUICK LINKS ─────────────────────────────────────────── */

.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.quick-link-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
    font-size: 0.875rem;
    font-weight: 500;
}

.quick-link-card:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--text);
}

.quick-link-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.quick-link-meta {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 2px;
}

/* ── PROJECT DETAIL / HERO ───────────────────────────────── */

.project-hero {
    margin-bottom: 28px;
}

.project-hero-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.project-hero-title {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

.project-hero-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.project-hero-meta {
    font-size: 0.8rem;
    color: var(--muted);
}

/* ── DETAIL SECTIONS ─────────────────────────────────────── */

.detail-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.detail-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

/* ── LINKS LIST ──────────────────────────────────────────── */

.link-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
    width: fit-content;
}

.link-item:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--text);
}

.link-item-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.link-icon { font-size: 1rem; flex-shrink: 0; }
.link-arrow { color: var(--muted); margin-left: auto; }

.muted { color: var(--muted); }

/* ── BREADCRUMB ──────────────────────────────────────────── */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 20px;
}

.breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

.breadcrumb-sep { color: var(--muted); }

/* ── BUTTONS ─────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(180deg, var(--accent), #c42f3a);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    font-weight: 600;
    transition: all 0.15s;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

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

.btn-ghost:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
    border-color: var(--border-hover);
}

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ── FORM ────────────────────────────────────────────────── */

.form-group { margin-bottom: 14px; }

.form-input {
    width: 100%;
    padding: 9px 13px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

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

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

.error-msg {
    padding: 9px 12px;
    background: rgba(248,81,73,0.1);
    border: 1px solid rgba(248,81,73,0.25);
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: #ff8b87;
    margin-bottom: 16px;
}

/* ── DOCS BANNER ─────────────────────────────────────────── */

.docs-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
    font-size: 0.85rem;
}

.docs-banner.ready {
    background: var(--success-bg);
    border: 1px solid rgba(63,185,80,0.25);
    color: var(--success);
}

.docs-banner.not-ready {
    background: var(--warning-bg);
    border: 1px solid rgba(210,153,34,0.25);
    color: var(--warning);
}

/* ── FOOTER ──────────────────────────────────────────────── */

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--muted);
}

/* ── MISC ────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
    font-size: 0.875rem;
}


/* ============================================================
   MOBILE / RESPONSIVE
   ============================================================ */

/* Hamburger toggle button (hidden on desktop) */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.2rem;
    padding: 6px 10px;
    cursor: pointer;
    line-height: 1;
}

/* ── Tablet (≤900px) ─────────────────────────────────────── */

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

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

    .quick-links-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Mobile (≤768px) ─────────────────────────────────────── */

@media (max-width: 768px) {
    :root {
        --sidebar-w: 0px;
    }

    .mobile-toggle {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 260px;
        min-width: 260px;
        z-index: 300;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Backdrop when sidebar is open */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.6);
        z-index: 250;
    }

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

    .main-area {
        margin-left: 0;
    }

    .topbar {
        padding: 0 16px 0 48px;
    }

    .main-content {
        padding: 16px;
    }

    .page-title {
        font-size: 1.15rem;
    }

    .stat-card {
        min-width: unset;
    }

    .project-hero-title {
        font-size: 1.3rem;
    }

    .footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }

    /* Login page adjustments */
    .login-page .login-card {
    border-top: 2px solid var(--accent);
        max-width: 280px;
        padding: 24px 20px;
    }

    .login-logo-img {
        width: 48px;
        height: 48px;
    }
}

/* ── Small phone (≤400px) ────────────────────────────────── */

@media (max-width: 400px) {
    .main-content {
        padding: 12px;
    }

    .project-card {
        padding: 14px;
    }

    .topbar {
        height: 44px;
        padding: 0 12px 0 44px;
    }

    .topbar-title {
        font-size: 0.82rem;
    }
}


/* ── FILE MANAGER ────────────────────────────────────────── */

.file-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0 16px;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.file-breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.file-breadcrumb a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.file-breadcrumb .breadcrumb-sep {
    color: var(--muted);
    font-size: 0.75rem;
}

.file-breadcrumb .breadcrumb-current {
    color: var(--text-secondary);
}

/* Alerts */
.file-alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.file-alert-error {
    background: rgba(248, 81, 73, 0.12);
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.25);
}

.file-alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(63, 185, 80, 0.25);
}

/* Toolbar */
.file-toolbar {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.file-upload-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.file-upload-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.file-upload-input {
    display: none;
}

.file-choose-btn {
    cursor: pointer;
}

.file-name-text {
    font-size: 0.8rem;
    color: var(--muted);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-mkdir-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.file-input-text {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
    font-size: 0.82rem;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
    width: 180px;
}

.file-input-text:focus {
    border-color: var(--accent);
}

.file-input-text::placeholder {
    color: var(--muted);
}

/* Table */
.file-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.file-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.file-table thead {
    background: var(--surface2);
}

.file-table th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.file-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.file-table tbody tr:last-child td {
    border-bottom: none;
}

.file-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.file-th-name { width: 50%; }
.file-th-size { width: 15%; }
.file-th-modified { width: 20%; }
.file-th-actions { width: 15%; text-align: right; }

.file-cell-size,
.file-cell-modified {
    color: var(--text-secondary);
    font-size: 0.82rem;
    white-space: nowrap;
}

.file-cell-actions {
    text-align: right;
    white-space: nowrap;
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
}

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    text-decoration: none;
    transition: color 0.15s;
}

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

.file-link-dir {
    font-weight: 500;
}

.file-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.file-cell-name {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-empty {
    text-align: center;
    color: var(--muted);
    padding: 32px 14px !important;
    font-style: italic;
}

/* Delete form inline */
.file-delete-form {
    display: inline-flex;
}

/* Button variants */
.btn-xs {
    padding: 3px 8px;
    font-size: 0.72rem;
    border-radius: 4px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s;
}

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

.btn-danger-ghost {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.3);
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-danger-ghost:hover {
    background: rgba(248, 81, 73, 0.12);
    border-color: var(--danger);
}

/* ── FILE MANAGER MOBILE ─────────────────────────────────── */

@media (max-width: 768px) {
    .file-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .file-mkdir-form {
        margin-left: 0;
    }

    .file-input-text {
        width: 100%;
        flex: 1;
    }

    .file-upload-form {
        flex-wrap: wrap;
    }

    .file-th-modified,
    .file-cell-modified {
        display: none;
    }

    .file-th-size,
    .file-cell-size {
        display: none;
    }

    .file-th-name { width: 70%; }
    .file-th-actions { width: 30%; }
}

@media (max-width: 400px) {
    .file-table th,
    .file-table td {
        padding: 6px 8px;
    }

    .file-breadcrumb {
        font-size: 0.78rem;
    }
}

/* ── FILE VIEWER ─────────────────────────────────────────── */

.view-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    flex-wrap: wrap;
}

.view-filename {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.view-toolbar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.view-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* Code preview */
.code-preview {
    overflow-x: auto;
    margin: 0;
}

.code-preview pre {
    margin: 0;
    padding: 0;
    background: #282c34;
    border-radius: 0;
}

.code-preview pre code {
    display: block;
    padding: 16px 20px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    tab-size: 4;
    white-space: pre;
    overflow-x: auto;
    background: #282c34;
    color: #abb2bf;
}

/* highlight.js override to match our container */
.code-preview pre code.hljs {
    background: #282c34;
    padding: 16px 20px;
}

/* Edit mode */
.edit-block {
    padding: 0;
}

.edit-textarea {
    display: block;
    width: 100%;
    min-height: 500px;
    padding: 16px 20px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: #1e2127;
    color: #abb2bf;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    tab-size: 4;
    resize: vertical;
    outline: none;
}

.edit-textarea:focus {
    border-color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.edit-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
}

/* Image preview */
.image-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    background: var(--surface2);
    min-height: 200px;
}

.image-preview img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

/* PDF preview */
.pdf-preview {
    width: 100%;
    min-height: 80vh;
}

.pdf-preview iframe {
    width: 100%;
    height: 80vh;
    border: none;
    display: block;
}

/* Video preview */
.video-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    background: var(--bg-deep);
}

.video-preview video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius);
}

/* Audio preview */
.audio-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 24px;
}

.audio-preview audio {
    width: 100%;
    max-width: 600px;
}

/* Binary / unknown file info */
.binary-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px;
    text-align: center;
    gap: 16px;
}

.binary-icon {
    font-size: 3rem;
}

.binary-details {
    color: var(--text-secondary);
    line-height: 1.8;
}

.binary-details strong {
    color: var(--text);
}

.binary-hint {
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* Warning alert */
.file-alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(210,153,34,0.3);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.85rem;
}

/* ── FILE VIEWER MOBILE ──────────────────────────────────── */

@media (max-width: 768px) {
    .view-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .view-toolbar-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .view-filename {
        white-space: normal;
        word-break: break-all;
    }

    .edit-textarea {
        min-height: 300px;
    }

    .pdf-preview, .pdf-preview iframe {
        height: 50vh;
        min-height: 50vh;
    }
}
/* ============================================================
   Printers page — additions for style.css
   Append this block to static/style.css
   ============================================================ */

/* ── PRINTER GRID ─────────────────────────────────────────── */

.printer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

/* Third card centred, spanning full width */
.printer-grid .printer-card:nth-child(3) {
    grid-column: 1 / -1;
    max-width: 560px;
    justify-self: center;
    width: 100%;
}

.printer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s;
}

.printer-card:hover {
    border-color: var(--border-hover);
}

/* ── Camera feed wrapper ──────────────────────────────────── */

.printer-feed-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-deep);
    overflow: hidden;
}

.printer-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Offline overlay — shown when img.errored */
.printer-feed-offline {
    display: none;
    position: absolute;
    inset: 0;
    background: #0a0a0a;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    color: var(--muted);
    font-size: 0.85rem;
}

.printer-feed-offline .offline-icon {
    font-size: 2rem;
    opacity: 0.4;
}

.printer-feed.errored {
    display: none;
}

.printer-feed.errored ~ .printer-feed-offline {
    display: flex;
}

/* ── Printer info panel ───────────────────────────────────── */

.printer-info {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.printer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.printer-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Status badges ────────────────────────────────────────── */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-idle {
    background: rgba(63, 185, 80, 0.12);
    color: #3fb950;
    border: 1px solid rgba(63, 185, 80, 0.25);
}

.status-printing {
    background: rgba(56, 139, 253, 0.12);
    color: #58a6ff;
    border: 1px solid rgba(56, 139, 253, 0.25);
    animation: pulse-blue 2s ease-in-out infinite;
}

.status-paused {
    background: rgba(210, 153, 34, 0.12);
    color: #d29922;
    border: 1px solid rgba(210, 153, 34, 0.25);
}

.status-error {
    background: rgba(248, 81, 73, 0.12);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.25);
}

.status-offline {
    background: rgba(110, 118, 129, 0.12);
    color: #6e7681;
    border: 1px solid rgba(110, 118, 129, 0.25);
}

@keyframes pulse-blue {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
}

/* ── Progress bar ─────────────────────────────────────────── */

.printer-progress-wrap {
    display: none;
}

.printer-progress-wrap.visible {
    display: block;
}

.printer-progress-bar {
    height: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.printer-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #58a6ff, #79c0ff);
    border-radius: 2px;
    transition: width 0.6s ease;
}

.printer-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* ── File label ───────────────────────────────────────────── */

.printer-file {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.printer-file.has-file {
    color: var(--text-secondary);
}

/* ── Live status strip (topbar) ───────────────────────────── */

.status-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--muted);
}

.status-strip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    flex-shrink: 0;
}

.status-strip-dot.live {
    background: var(--success);
    box-shadow: 0 0 4px var(--success);
}

/* ── Mobile ───────────────────────────────────────────────── */

@media (max-width: 768px) {
    .printer-grid {
        grid-template-columns: 1fr;
    }

    .printer-grid .printer-card:nth-child(3) {
        grid-column: auto;
        max-width: 100%;
    }
}


/* ── Utility: Monospace data ──────────────────────────────── */
.mono { font-family: var(--font-mono); }
