:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f0;
    --bg-input: #f5f5f5;
    --text-primary: #111111;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent: #111111;
    --accent-hover: #333333;
    --accent-light: rgba(0, 0, 0, 0.05);
    --border: #e0e0e0;
    --shadow: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --info: #555555;
    --info-hover: #333333;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --teal: #10b981;
    --alert-success-bg: #ecfdf5;
    --alert-error-bg: #fef2f2;
    --alert-info-bg: #f5f5f5;
    --modal-overlay: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1e1e1e;
    --bg-input: #141414;
    --text-primary: #f0f0f0;
    --text-secondary: #888888;
    --text-muted: #555555;
    --accent: #f0f0f0;
    --accent-hover: #cccccc;
    --accent-light: rgba(255, 255, 255, 0.06);
    --border: #2a2a2a;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --info: #aaaaaa;
    --info-hover: #888888;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --teal: #10b981;
    --alert-success-bg: #052e16;
    --alert-error-bg: #450a0a;
    --alert-info-bg: #1e1e1e;
    --modal-overlay: rgba(0, 0, 0, 0.7);
}

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

html, body { height: 100%; margin: 0; overflow: hidden; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    display: flex; flex-direction: column;
}

.container { max-width: 100%; margin: 0 auto; padding: 0; }

/* Header - full-width bar, no radius, no gaps */
header {
    background: var(--bg-secondary);
    padding: 16px 32px;
    margin-bottom: 0;
    border-radius: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    z-index: 50; flex-shrink: 0;
}
.header-content { flex: 1; }
.header-content h1 { color: var(--text-primary); font-size: 22px; font-weight: 700; margin-bottom: 1px; letter-spacing: -0.3px; }
.header-content p { color: var(--text-secondary); font-size: 14px; font-weight: 400; }

/* Theme switch — iOS-style track + thumb. Sun on left, moon on right.
   Thumb slides to indicate the CURRENT mode (light = thumb left, dark = thumb right).
   The opposite-side icon stays visible as the "switch to" hint. */
/* CRT scanlines + soft vignette behind the login form. The gradient
   is repeated horizontally and drifts upward so it never sits still,
   but slow enough to be ambient rather than distracting. */
#login-screen::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(255, 255, 255, 0.03) 0px,
            rgba(255, 255, 255, 0.03) 1px,
            transparent 1px,
            transparent 3px
        ),
        radial-gradient(ellipse at center,
            rgba(46, 204, 113, 0.06) 0%,
            rgba(0, 0, 0, 0) 60%);
    animation: scanline-drift 8s linear infinite;
    z-index: 0;
}
#login-screen::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(ellipse at center,
        rgba(0, 0, 0, 0) 60%,
        rgba(0, 0, 0, 0.55) 100%);
    z-index: 0;
}
#login-screen > * { position: relative; z-index: 1; }
@keyframes scanline-drift {
    0%   { background-position: 0 0, 0 0; }
    100% { background-position: 0 -3px, 0 0; }
}
@media (prefers-reduced-motion: reduce) {
    #login-screen::before { animation: none; }
}

#login-form {
    background: var(--bg-secondary);
    padding: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}
[data-theme="dark"] #login-form {
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-lg);
}

#login-submit {
    width: 100%;
    height: 44px;
    padding: 0;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--bg-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    box-sizing: border-box;
}
#login-submit:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.lang-select {
    width: auto;
    min-width: 160px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.lang-select:hover { border-color: var(--text-secondary); }
.lang-select:focus { outline: none; border-color: var(--accent); }

.theme-switch {
    position: relative;
    width: 56px;
    height: 28px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    transition: background 0.2s, border-color 0.2s;
}
.theme-switch:hover { border-color: var(--text-secondary); }
.theme-switch-icon {
    position: relative;
    z-index: 1;
    width: 14px;
    height: 14px;
    margin: 0 7px;
    color: var(--text-secondary);
    pointer-events: none;
    transition: color 0.2s;
}
.theme-switch-icon-sun { color: #d97706; }
[data-theme="dark"] .theme-switch-icon-sun { color: var(--text-secondary); }
[data-theme="dark"] .theme-switch-icon-moon { color: #93c5fd; }
.theme-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: var(--bg-secondary);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
}
[data-theme="dark"] .theme-switch-thumb {
    transform: translateX(28px);
    background: var(--bg-tertiary);
}

/* User profile button — keep round chip style next to the theme switch. */
.user-profile-button {
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    width: 36px; height: 36px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    color: var(--text-secondary);
}
.user-profile-button:hover {
    background: var(--accent-light);
    color: var(--accent);
}
.user-profile-button { color: var(--text-secondary); }
.user-profile { position: relative; }
.user-profile-dropdown {
    display: none; position: absolute; top: 50px; right: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius); padding: 8px; min-width: 200px;
    box-shadow: var(--shadow-lg); z-index: 1000; border: 1px solid var(--border);
}
.user-profile-dropdown.show { display: block; }
.user-profile-info { padding: 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.user-profile-info .username { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.user-profile-info .role { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.user-profile-dropdown button {
    width: 100%; padding: 8px 10px; background: none; border: none;
    border-radius: var(--radius-sm); color: var(--text-primary); cursor: pointer; font-size: 13px;
    transition: background 0.15s; display: flex; align-items: center; gap: 8px;
}
.user-profile-dropdown button:hover { background: var(--bg-tertiary); }

/* App layout - sidebar + main */
.app-layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* Sidebar */
.sidebar {
    width: 190px; flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-group { margin-bottom: 12px; }
.nav-group-label {
    display: block; padding: 8px 16px 6px; font-size: 11px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
.nav-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; margin: 1px 8px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; text-decoration: none; border: none; background: none; width: calc(100% - 16px);
    text-align: left;
}
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

/* Main content area */
.main-content { flex: 1; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

.content-area { padding: 16px; flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.content-area > .stats { flex-shrink: 0; }
.tab-content.active { display: flex; flex-direction: column; flex: 1; overflow-y: auto; min-height: 0; }
.tab-content.active > .card { display: flex; flex-direction: column; flex-shrink: 0; }
.card-body { flex-shrink: 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 0 12px 12px; flex-shrink: 0; }
.toolbar-filter {
    margin-left: auto; min-width: 200px; max-width: 280px;
    padding: 6px 10px; font-size: 13px;
    background: var(--bg-input, var(--bg-primary)); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.toolbar-filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* Stats row */
.stats { display: flex; gap: 10px; margin-bottom: 12px; }
.stat-card {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    flex: 1;
    display: flex; flex-direction: column; gap: 2px;
    border: none;
}
.stat-card::before { display: none; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat-label { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }

/* Hide old tabs - navigation is in sidebar now */
.tabs { display: none; }
.tab-content { display: none; }

/* In-page subtabs (e.g., Image Groups / Client Groups) */
.subtabs {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--border);
    margin: 4px 12px 16px;
}
.subtab {
    padding: 10px 16px; background: none; border: none;
    color: var(--text-secondary); cursor: pointer;
    font-size: 14px; font-weight: 500;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.subtab:hover { color: var(--text-primary); }
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Cards - white, subtle shadow, NO border */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border: none;
    padding: 0;
}
.card h2 { color: var(--text-primary); margin-bottom: 8px; font-size: 16px; font-weight: 600; padding: 12px 12px 0; }
.card-body { padding: 12px; padding-top: 0; }
.card > h2:first-child { padding-top: 12px; }
.card > .loading { padding: 12px; }
.card > button, .card > p, .card > form { margin: 0 12px 8px; }

/* Tables */
table { border-collapse: collapse; font-size: 13px; width: 100%; }
.table-scroll table { min-width: 100%; width: max-content; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.table-scroll tbody tr:nth-child(odd) { background: rgba(0, 0, 0, 0.02); }
[data-theme="dark"] .table-scroll tbody tr:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }
.table-scroll tbody tr.row-clickable { cursor: pointer; }
.table-scroll tbody tr.row-clickable:hover { background: var(--accent-light); }
/* Make the images / image-groups tables go edge-to-edge of the tab.
   Toolbar, h2 and subtabs keep their normal 12px indent. */
#images-tab .table-scroll { margin-left: -16px; margin-right: -16px; }
.table-scroll tbody tr.row-warning { background: rgba(245, 158, 11, 0.10); border-left: 3px solid var(--warning); }
.table-scroll tbody tr.row-warning:nth-child(odd) { background: rgba(245, 158, 11, 0.14); }
.table-scroll tbody tr.row-warning:hover { background: rgba(245, 158, 11, 0.20); }

/* Traffic-light status dots — compact alternative to text badges */
.status-dot {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    vertical-align: middle;
}
.status-dot.on  { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.45); }
.status-dot.off { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.35); }
.col-dot { text-align: center; width: 1%; }
.col-logo { text-align: center; width: 1%; padding-right: 0; }
.col-check { text-align: center; width: 1%; padding: 0 4px; }
tr.row-uploading { background: rgba(255, 176, 0, 0.04); }
tr.row-uploading:hover { background: rgba(255, 176, 0, 0.08); }
tr.row-upload-error { background: rgba(239, 68, 68, 0.05); }
tr.row-upload-error:hover { background: rgba(239, 68, 68, 0.10); }
.col-check input[type="checkbox"] { cursor: pointer; vertical-align: middle; margin: 0; }

.api-section { margin-bottom: 22px; }
.api-section h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-secondary); margin: 14px 0 6px; font-weight: 600; }
.api-row { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.api-row-head { display: grid; grid-template-columns: 70px minmax(220px, 360px) 1fr; gap: 12px; align-items: center; }
.api-curl { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg-tertiary); border-radius: var(--radius-sm); }
.api-curl code { flex: 1; overflow-x: auto; white-space: nowrap; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 11px; color: var(--text-secondary); }
.api-curl button { background: transparent; border: none; cursor: pointer; padding: 2px 6px; color: var(--text-secondary); display: inline-flex; align-items: center; border-radius: 3px; }
.api-curl button:hover { color: var(--text-primary); background: var(--accent-light); }
.api-curl button.copied { color: var(--success); }
.api-method { display: inline-block; min-width: 56px; padding: 3px 8px; border-radius: 3px; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 10px; font-weight: 700; text-align: center; letter-spacing: 0.5px; }
.api-method.get    { background: rgba(52, 152, 219, 0.12); color: #3498db; }
.api-method.post   { background: rgba(46, 204, 113, 0.12); color: #2ecc71; }
.api-method.put    { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.api-method.delete { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.api-method.public { background: rgba(255, 176, 0, 0.12); color: #ffb000; }
.api-row code.api-path { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12px; color: var(--text-primary); background: transparent; padding: 0; }
.api-row .api-detail { color: var(--text-secondary); font-size: 12px; }
.api-row .api-detail code { font-family: ui-monospace, monospace; font-size: 11px; padding: 1px 4px; background: var(--bg-tertiary); border-radius: 3px; color: var(--text-primary); }

.get-iso-distro { margin-bottom: 18px; }
.get-iso-distro h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-secondary); margin: 14px 0 6px; font-weight: 600; }
.get-iso-row { display: grid; grid-template-columns: minmax(180px, 1.2fr) 160px 2fr 220px; gap: 10px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.get-iso-row:last-child { border-bottom: none; }
.get-iso-label { font-size: 13px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.get-iso-mirror-sel, .get-iso-url { padding: 0 8px; height: 32px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-primary); font-size: 12px; box-sizing: border-box; min-width: 0; }
.get-iso-url { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 11px; width: 100%; }
.get-iso-actions { display: flex; align-items: center; justify-content: flex-end; width: 220px; min-width: 0; }
.get-iso-progress { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.get-iso-bar { flex: 1; height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; min-width: 60px; }
.get-iso-bar-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width 0.2s ease; }
.get-iso-status-text { font-size: 11px; color: var(--text-secondary); white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.distro-logo { display: block; margin: 0 auto; object-fit: contain; }
.distro-logo-modal { width: 32px; height: 32px; object-fit: contain; vertical-align: middle; margin-right: 10px; }
th {
    background: var(--bg-tertiary); color: var(--text-secondary);
    font-weight: 600; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.5px; user-select: none;
    position: sticky; top: 0; z-index: 10;
}
th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
th[onclick] { cursor: pointer; transition: background 0.15s; }
th[onclick]:hover { background: var(--border); }
tr:hover { background: var(--bg-tertiary); }
td:last-child { white-space: nowrap; }

/* Buttons — design system
   ────────────────────────
   .btn         = base outlined (transparent bg, neutral border) — secondary actions
   .btn-primary = solid amber — the ONE main action per toolbar
   .btn-danger  = solid red — destructive (delete, reset) only
   .btn-toggle  = outlined + amber-tinted when [aria-pressed="true"] — view/mode toggles
   .btn-icon    = 32×32 square modifier for icon-only buttons
   .btn-sm      = small variant for inline/row actions
   .btn-success / .btn-info / .btn-warning kept for backward compat — avoid in new code,
   reserve those colours for badges/dots where they actually carry meaning. */
.btn {
    height: 34px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--text-primary);
    cursor: pointer; font-size: 13px; font-weight: 500; box-sizing: border-box;
    transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px;
    line-height: 1; user-select: none; vertical-align: middle;
}
.btn:hover { background: var(--bg-tertiary); border-color: var(--text-secondary); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg-primary); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--bg-primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: white; }
.btn-success:hover { background: var(--success-hover); border-color: var(--success-hover); }
.btn-info { background: var(--info); border-color: var(--info); color: white; }
.btn-info:hover { background: var(--info-hover); border-color: var(--info-hover); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: white; }
.btn-warning:hover { background: var(--warning-hover); border-color: var(--warning-hover); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; margin: 0 2px; }
.btn svg { flex-shrink: 0; }

/* Toggle button — identical to .btn when unpressed; amber-tinted when [aria-pressed=true].
   NO base overrides here, so off-state is byte-for-byte the same as a regular .btn. */
.btn-toggle[aria-pressed="true"] {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}
.btn-toggle[aria-pressed="true"]:hover {
    background: var(--accent-light);
    border-color: var(--accent-hover);
    color: var(--accent);
}
/* Icon-only button (no text) — square, same height as .btn. */
.btn-icon {
    width: 34px;
    padding: 0;
    justify-content: center;
}
.btn-icon.btn-sm { width: 26px; }
.btn-icon svg { display: block; }

/* Modals */
.modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--modal-overlay); z-index: 1000; overflow-y: auto;
    backdrop-filter: blur(6px);
}
.modal.active { display: flex; align-items: center; justify-content: center; }

/* Slide-in side panel variant — anchors to the right edge, full height,
   transforms in from off-screen. Apply alongside .modal. */
.modal.slide-panel.active { justify-content: flex-end; align-items: stretch; }
.modal.slide-panel .modal-content {
    max-width: 560px; width: 100%; max-height: 100vh; height: 100vh;
    border-radius: 0; margin: 0;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
}
.modal.slide-panel.active .modal-content { transform: translateX(0); }

.modal-content {
    background: var(--bg-secondary); padding: 28px; border-radius: var(--radius);
    max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg); border: none;
}
.modal-header {
    margin-bottom: 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-header h2 { color: var(--text-primary); font-size: 16px; font-weight: 600; margin: 0; }

/* Forms */
.form-group { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; color: var(--text-secondary); font-weight: 500; font-size: 13px; }
input, textarea, select {
    width: 100%; padding: 10px 14px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 14px; transition: all 0.2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.checkbox-group { display: flex; align-items: center; gap: 10px; }
.checkbox-group input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* Badges */
.badge {
    display: inline-block; padding: 4px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-success { background: rgba(46, 204, 113, 0.10); color: var(--success); }
.badge-danger { background: rgba(231, 76, 60, 0.10); color: var(--danger); }
.badge-info { background: rgba(52, 152, 219, 0.10); color: var(--info); }
.badge-admin { background: var(--accent-light); color: var(--accent); }
.badge-user { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-enabled { background: rgba(46, 204, 113, 0.10); color: var(--success); }
.badge-disabled { background: var(--bg-tertiary); color: var(--text-muted); }

/* Upload */
.upload-area {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 40px; text-align: center; cursor: pointer; transition: all 0.2s;
    color: var(--text-secondary);
}
.upload-area:hover { border-color: var(--accent); background: var(--accent-light); }
.upload-area.dragging { border-color: var(--success); background: rgba(46, 204, 113, 0.06); }

/* Alerts */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 15px; border: 1px solid var(--border); }
.alert-success { background: var(--alert-success-bg); }
.alert-error { background: var(--alert-error-bg); }
.alert-info { background: var(--alert-info-bg); }

/* Inline guidance warnings inside forms / modals */
.guide-warning {
    padding: 12px 14px; border-radius: var(--radius-sm);
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-left: 3px solid var(--warning);
    display: flex; align-items: center; gap: 12px;
    font-size: 14px; color: var(--text-primary);
    margin-bottom: 12px;
}
.guide-warning .gw-text { flex: 1; }
.guide-warning .gw-text strong { color: var(--warning-hover); }
.guide-warning .btn { white-space: nowrap; }

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--text-secondary); }
.spinner {
    border: 3px solid var(--border); border-top: 3px solid var(--accent);
    border-radius: 50%; width: 28px; height: 28px;
    animation: spin 0.8s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Server info layout */
.si-section { margin-bottom: 28px; }
.si-section:last-child { margin-bottom: 0; }
.si-heading {
    font-size: 18px; font-weight: 600; color: var(--text-primary);
    margin-bottom: 16px;
}

/* Running status grid - clean cells in a white card */
.rs-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    background: var(--bg-secondary); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow);
}
.rs-metric {
    padding: 20px 22px;
    display: flex; flex-direction: column; gap: 6px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.rs-metric:last-child { border-right: none; }
.rs-label { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.rs-value { font-size: 18px; font-weight: 600; color: var(--text-primary); }

/* Resource cards - ring-gauge style */
.res-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px;
}
.res-card {
    background: var(--bg-secondary); padding: 24px 20px 22px; border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    border: none;
    transition: box-shadow 0.2s, transform 0.2s;
}
.res-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.res-label { font-size: 14px; color: var(--text-secondary); font-weight: 500; text-align: center; letter-spacing: 0.2px; text-transform: uppercase; }
.res-gauge { position: relative; width: 128px; height: 128px; }
.res-gauge svg { width: 100%; height: 100%; display: block; overflow: visible; }
.res-gauge-track { stroke: var(--border); }
.res-gauge-fill { transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1); filter: drop-shadow(0 0 6px currentColor); }
.res-gauge-text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700; letter-spacing: -0.5px;
}
.res-detail { font-size: 13px; color: var(--text-secondary); text-align: center; line-height: 1.4; }

/* Info sections - side by side at bottom */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.info-section {
    background: var(--bg-secondary); padding: 24px; border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: none;
}
.info-section h3 {
    color: var(--text-primary); font-size: 16px; font-weight: 600;
    margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.info-item { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.info-item:last-child { border-bottom: none; }
.info-label { color: var(--text-secondary); font-size: 15px; }
.info-value { color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-size: 15px; text-align: right; font-weight: 500; }

/* Sessions */
.session-item {
    background: var(--bg-tertiary); padding: 14px; border-radius: var(--radius);
    margin-bottom: 8px; border: none; border-left: 3px solid var(--success);
}
.session-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.session-ip { color: var(--accent); font-weight: 600; font-size: 14px; }
.session-filename { color: var(--text-secondary); font-size: 13px; }
.session-activity { color: var(--success); font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; }

/* Progress bars */
.progress-bar { width: 100%; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--teal); transition: width 0.4s ease; border-radius: 2px; }
.progress-text { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* Taller variant for modals */
.progress-bar.progress-bar-lg { height: 8px; border-radius: 4px; }
.progress-bar.progress-bar-lg .progress-fill { background: var(--accent); border-radius: 4px; }

/* Stats grid (used elsewhere) */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.stat-card-header { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.stat-card-title { font-weight: 500; color: var(--text-secondary); font-size: 12px; }
.stat-card-value { font-size: 28px; font-weight: 700; line-height: 1; letter-spacing: -0.5px; }
.stat-card-info { color: var(--text-secondary); font-size: 12px; margin-top: 8px; }

/* Notifications */
.notification-container {
    position: fixed; top: 20px; right: 20px; z-index: 10000;
    display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.notification {
    padding: 14px 18px; border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: white; font-size: 13px; font-weight: 500; cursor: pointer;
    transform: translateX(400px); transition: transform 0.3s ease, opacity 0.3s ease; opacity: 0;
}
.notification.show { transform: translateX(0); opacity: 1; }
.notification-success { background: var(--success); }
.notification-error { background: var(--danger); }
.notification-info { background: var(--accent); }
.notification-warning { background: var(--warning); }
.notification:hover { opacity: 0.9; }

/* Operations */
.operations-cell { min-width: 200px; }
.progress-container { width: 100%; }

/* Table scroll containers */
.table-scroll {
    overflow: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
}
.table-scroll::-webkit-scrollbar { height: 12px; width: 12px; }
.table-scroll::-webkit-scrollbar-track { background: var(--bg-tertiary); }
.table-scroll::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 6px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Pin both scrollbars inside the viewport when a tab's main content
   is a wide table. Without this, a tall table pushes its horizontal
   scrollbar off-screen because the whole tab scrolls vertically. */
.tab-content.active:has(.table-scroll):not(#settings-tab) { overflow: hidden; }
.tab-content.active:has(.table-scroll):not(#settings-tab) > .card { flex: 1; min-height: 0; }
/* Every wrapper between .card and .table-scroll must be a flex column
   so heights propagate. This catches render-target divs (#images-table)
   and subtab wrappers (#images-subtab, #clients-subtab) transparently. */
.card :has(.table-scroll) { flex: 1; min-height: 0; display: flex; flex-direction: column; }

@media (max-width: 1200px) {
    .stat-card { gap: 2px; }
    .btn { padding: 6px 12px; font-size: 12px; }
    .btn-sm { padding: 4px 8px; font-size: 11px; }
    .rs-metric { padding: 16px 18px; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .tabs { display: flex !important; }
    th, td { padding: 8px; font-size: 12px; }
    .content-area { padding: 16px; }
    .card { padding: 18px; }
    .tab { padding: 7px 14px; font-size: 13px; white-space: nowrap; }
    .card h2 { font-size: 14px; }
    .res-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .info-grid { grid-template-columns: 1fr; }
    .rs-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}
