/* ========================================
   PORTAL THEME - PentestOps V2
   Light theme default - .dark class on <html> for dark mode
   ======================================== */


:root {
    /* Brand Colors - Purple/Indigo Accent (matching website) */
    --primary: #0F2B5B;
    --primary-dark: #091a38;
    --primary-light: #3d83f6;
    --primary-glow: rgba(0, 180, 216, 0.3);

    /* Secondary Colors */
    --secondary: #00B4D8;
    --secondary-glow: rgba(6, 182, 212, 0.3);
    --accent: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.3);

    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Severity Colors
       The severity ramp, NOT the status ramp above. Painting a High with
       --danger (#ef4444) makes it read as a Critical (#dc2626); the two are
       three lines apart here and all but indistinguishable on screen.
       --severity-unknown is a sixth presentation state, not a band: it means
       "no classified finding yet" (pending, still running, failed before it
       could observe, or a value that did not normalise). It is deliberately
       NOT --informational: "we looked and it was informational" and "we do not
       know" are different claims, and it is deliberately not green, because a
       result nobody has graded must never read as benign.
       Mirrored in portal/app/core/severity_policy.py SEVERITY_PRESENTATION. */
    --critical: #dc2626;
    --high: #f97316;
    --medium: #eab308;
    --low: #22c55e;
    --informational: #6b7280;
    --severity-unknown: #94a3b8;

    /* Severity STROKE variants, for thin lines rather than filled chips.
       A 2px curve is not a badge: on the light canvas (#F0F4F8) --medium
       #eab308 lands at about 1.9:1 contrast and --low #22c55e at about 2.2:1,
       which is fine behind a tinted chip and unreadable as a hairline. These
       darken exactly those two for light mode. html.dark resets them to the
       base tokens, which are already strong against #0A1628.
       Consumed by portal/static/js/severity-registry.js. */
    --sev-stroke-critical: #dc2626;
    --sev-stroke-high: #ea580c;
    --sev-stroke-medium: #a16207;
    --sev-stroke-low: #15803d;
    --sev-stroke-info: #6b7280;

    /* The severity bar's TRACK, and the one inset shadow in this file that is
       functional rather than decorative: it is what makes a 9px strip read as a
       filled gauge rather than as a painted stripe, so a bar that is 30% full
       looks 30% full instead of looking like a short bar. Both values move with
       the theme because a track is a surface, unlike the ramp above. */
    --es-sev-track: rgba(15, 23, 42, 0.07);
    --es-sev-track-inset: inset 0 1px 2px rgba(0, 0, 0, 0.16);
    /* The edge on a row carrying neither a critical nor a high. Quiet on
       purpose: the edge exists to be scanned past, and a row with nothing worse
       than a medium is not the reason to stop. */
    --es-sev-edge-none: rgba(15, 23, 42, 0.18);

    /* Light Theme Background (default) */
    --bg-dark: #F0F4F8;
    --bg-base: #F0F4F8;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --bg-elevated: #ffffff;
    --border: rgba(0, 0, 0, 0.08);

    /* Glass Effects - Light */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-bg-strong: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.06);
    --glass-border-subtle: rgba(0, 0, 0, 0.04);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --glass-shadow-lg: 0 25px 50px rgba(0, 0, 0, 0.12);
    --glass-hover: rgba(0, 0, 0, 0.03);

    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-white: #1e293b;

    /* ------------------------------------------------------------------
       STACKING ORDER. There was no scale before this: values ran from 1 to
       12000, chosen per component, with nothing saying what any band meant.
       The ladder below is a DESCRIPTION of what was already there, so existing
       rules keep their behaviour, plus two new bands for run windows.

       Whoever adds the next floating thing should join a band rather than pick
       a number bigger than the last one they found.

         content        in-flow decoration: timeline dots, chips, stage marks
         chrome         sidebar and sticky header. Page furniture.
         panel          persistent floating surfaces: chatbot, help drawer
         run-dock       the strip of minimised runs. Below the windows it
                        belongs to, above the page they float over.
         run-window     a floating run window. +1 when focused, so raising one
                        needs no reshuffle of the others.
         dialog         transient, dismissable, does not block the page
         modal          blocks the page behind a scrim
         toast          must outrank a modal: a failure notice about a modal
                        that is covering it is useless
         confirm        the blocking confirm. Nothing may cover it.

       The values are the ones already in use for each band, not new numbers -
       chatbot maximised is 1300, the setup modal 2000, toasts 10000, and
       base.html's themedConfirm 12000. Run windows sit between chatbot and the
       setup modal because a window is a working surface, not a dialog: a modal
       must still be able to cover one. */
    --z-content: 2;
    --z-chrome: 100;
    --z-panel: 1000;
    --z-run-dock: 1390;
    --z-run-window: 1400;
    --z-dialog: 2000;
    --z-modal: 9999;
    --z-toast: 10000;
    --z-confirm: 12000;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 60px rgba(0, 180, 216, 0.15);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Gradients (matching website) */
    --gradient-primary: linear-gradient(135deg, #0F2B5B 0%, #1a65d6 50%, #00B4D8 100%);
    --gradient-hero: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 180, 216, 0.3), transparent);

    /* Font */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Modal scrim. Navy tinted in light so the brand bleeds through; dark mode swaps in a neutral scrim. */
    --scrim: rgba(15, 43, 91, 0.45);
}

/* ========================================
   ENS DESIGN PATTERNS
   ======================================== */
.card, .stat-card, .metric-card {
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}
html.dark .card, html.dark .stat-card, html.dark .metric-card {
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}
.card:hover, .stat-card:hover { border-color: rgba(0, 180, 216, 0.15); }
.stat-card { position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; right: 0; width: 80px; height: 80px; border-radius: 50%; opacity: 0.06; background: radial-gradient(circle, currentColor, transparent); transform: translate(30%, -30%); pointer-events: none; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0, 180, 216, 0.25); }
.btn-primary:active { transform: translateY(0); }
.main-content { animation: fadeIn 0.3s ease-out; }
.modal-content { border-radius: 16px; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.badge { border-radius: 9999px; }
input:focus, select:focus, textarea:focus:not(.pa-input) { border-color: var(--secondary) !important; box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.15) !important; outline: none; }

/* ENS: rounded-2xl on all interactive elements */
.btn, button:not(.theme-toggle-btn):not(.mobile-menu-toggle) { border-radius: 16px; }
.form-control, .form-input, .form-select, .form-textarea, input[type="text"], input[type="password"], input[type="email"], input[type="search"], input[type="number"], select, textarea { border-radius: 12px; }
.modal, .modal-content { border-radius: 16px; }

/* ENS: brand-tinted button shadows */
.btn-primary { box-shadow: 0 4px 14px rgba(0, 180, 216, 0.2); }
.btn-primary:hover { box-shadow: 0 8px 25px rgba(0, 180, 216, 0.3); }
.btn-danger { box-shadow: 0 4px 14px rgba(239, 68, 68, 0.2); }
.btn-danger:hover { box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3); }
.btn-success { box-shadow: 0 4px 14px rgba(16, 185, 129, 0.2); }
.btn-success:hover { box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3); }

/* ENS: modal backdrop blur */
.modal-overlay, .modal-backdrop { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

/* ENS: empty state pattern */
.empty-state { text-align: center; padding: 4rem 1.5rem; }
.empty-state-container { background: rgba(0, 0, 0, 0.02); border: 2px dashed rgba(0, 0, 0, 0.1); border-radius: 16px; padding: 3rem; }
html.dark .empty-state-container { background: rgba(255, 255, 255, 0.03); border-color: rgba(255, 255, 255, 0.08); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state-title { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.5rem; }
.empty-state-description { font-size: 0.875rem; color: var(--text-muted, #64748b); margin-bottom: 1.5rem; }

/* v3.5.80: brand logo dark-mode = theme-swapped PNGs (no CSS filter).
 * The dark-blue brand colours wash out on dark navy, so instead of a CSS
 * filter we ship a light variant (navy recoloured to near-white, brand blue
 * kept) and swap it in when html.dark is active. Wordmark = full lockup;
 * mark = chevron icon only. Light + dark PNGs share identical dimensions so
 * the swap is seamless across sidebar / login / dashboard / empty states. */
.pentestops-wordmark--dark { display: none !important; }
html.dark .pentestops-wordmark--light { display: none !important; }
html.dark .pentestops-wordmark--dark { display: block !important; }

.pentestops-mark--dark { display: none !important; }
html.dark .pentestops-mark--light { display: none !important; }
html.dark .pentestops-mark--dark { display: inline-block !important; }

/* ENS: assistant launcher safe-zone -- the floating Ask AI launcher
 * (.pa-launcher in assist.css) sits at bottom:24px right:24px and is
 * 52px tall, in the bottom-right corner. Without this padding, page-level
 * action buttons (Generate Playbook on AI Remediation, Save on Settings)
 * end up directly under the launcher and become unclickable. 96px clears
 * the launcher without affecting normal scrolling.
 * Two classes on purpose: the base .page-content rule and every breakpoint
 * set `padding` as a shorthand, and a single class here lost to all of them,
 * so the padding that rendered was 8px to 18px. Direct child of .main-content
 * only, because some pages nest a second .page-content inside the first. */
.main-content > .page-content { padding-bottom: 96px; }

/* ENS: the launcher's 3D icon on its own contained layer, so scrolling does
 * not re-composite it every frame (the same rule as the website's chat.css). */
.pa-launcher-stage { contain: strict; will-change: transform; }

/* ENS: setup-checklist banner + modal (v3.5.77).
 * Amber warning palette -- not red (it's actionable, not broken).
 * Banner is sticky at the top of .main-content; modal is a centred
 * overlay shown once-per-session on first visit after legal verification.
 * Driven by /api/setup-status. */
.setup-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0 1.25rem 1rem 1.25rem;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.10), rgba(245, 158, 11, 0.04));
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: var(--text-primary, #0f172a);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.10);
    position: relative;
}
.setup-banner[hidden] { display: none; }
.setup-banner__icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.18);
    color: #d97706;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.setup-banner__body { flex: 1; min-width: 0; }
.setup-banner__title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}
.setup-banner__steps {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #475569);
}
.setup-banner__step {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.setup-banner__step i { font-size: 0.85rem; color: #d97706; }
.setup-banner__step--done { color: var(--success, #16a34a); }
.setup-banner__step--done i { color: var(--success, #16a34a); }
.setup-banner__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}
.setup-banner__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.875rem;
    border-radius: 10px;
    background: var(--gradient-primary, linear-gradient(135deg, #0F2B5B, #1a65d6, #00B4D8));
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}
.setup-banner__cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 180, 216, 0.30);
    color: #ffffff;
}
.setup-banner__cta[hidden] { display: none; }
.setup-banner__dismiss {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}
.setup-banner__dismiss:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary, #0f172a);
}
html.dark .setup-banner {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.04));
    border-color: rgba(245, 158, 11, 0.45);
    color: var(--text-primary, #f8fafc);
}
html.dark .setup-banner__dismiss { color: var(--text-muted, #94a3b8); }
html.dark .setup-banner__dismiss:hover { background: rgba(255, 255, 255, 0.06); color: #ffffff; }
html.dark .setup-banner__steps { color: var(--text-secondary, #cbd5e1); }

/* Responsive: stack actions below body on narrow screens. */
@media (max-width: 768px) {
    .setup-banner { flex-wrap: wrap; }
    .setup-banner__actions { width: 100%; justify-content: flex-end; }
}

/* Modal ------------------------------------------------------------- */
.setup-modal[hidden] { display: none; }
.setup-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}
.setup-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 22, 40, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.setup-modal__panel {
    position: relative;
    max-width: 520px;
    width: 100%;
    background: var(--bg-card, #ffffff);
    color: var(--text-primary, #0f172a);
    border-radius: 16px;
    padding: 2rem 1.75rem 1.5rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.30);
    border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    animation: setupModalIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes setupModalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.setup-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.setup-modal__close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary, #0f172a);
}
.setup-modal__icon {
    display: flex;
    justify-content: center;
    margin-bottom: 0.875rem;
}
.setup-modal__title {
    text-align: center;
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
    font-weight: 700;
}
.setup-modal__subtitle {
    text-align: center;
    color: var(--text-secondary, #475569);
    font-size: 0.95rem;
    margin: 0 0 1.5rem;
}
.setup-modal__list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}
.setup-modal__item {
    display: flex;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    background: rgba(15, 43, 91, 0.04);
    border: 1px solid rgba(15, 43, 91, 0.10);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.setup-modal__item--done {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.30);
}
.setup-modal__item-status {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.18);
    color: #d97706;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    margin-top: 2px;
}
.setup-modal__item--done .setup-modal__item-status {
    background: rgba(34, 197, 94, 0.18);
    color: var(--success, #16a34a);
}
.setup-modal__item-body { flex: 1; min-width: 0; }
.setup-modal__item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.setup-modal__item-desc {
    color: var(--text-secondary, #475569);
    font-size: 0.875rem;
    line-height: 1.45;
    margin-bottom: 0.5rem;
}
.setup-modal__item-cta {
    color: var(--secondary, #00B4D8);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.setup-modal__item-cta:hover { text-decoration: underline; }
.setup-modal__item--done .setup-modal__item-cta { display: none; }
.setup-modal__hint {
    text-align: center;
    color: var(--text-muted, #64748b);
    font-size: 0.8rem;
    margin: 0;
}
html.dark .setup-modal__panel {
    background: var(--bg-card, #0f172a);
    color: var(--text-primary, #f8fafc);
    border-color: rgba(255, 255, 255, 0.08);
}
html.dark .setup-modal__subtitle,
html.dark .setup-modal__item-desc { color: var(--text-secondary, #cbd5e1); }
html.dark .setup-modal__item {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}
html.dark .setup-modal__item--done {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
}
html.dark .setup-modal__close { color: var(--text-muted, #94a3b8); }
html.dark .setup-modal__close:hover { background: rgba(255, 255, 255, 0.06); color: #ffffff; }
body.setup-modal-open { overflow: hidden; }

/* ENS: table-modern */
.table-modern { width: 100%; }
.table-modern thead { border-bottom: 1px solid rgba(0, 0, 0, 0.06); }
.table-modern th { padding: 0.875rem 1.25rem; text-align: left; font-size: max(0.6875rem, var(--fit-text-min, 0px)); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted, #64748b); }
.table-modern td { padding: 1rem 1.25rem; font-size: 0.875rem; }
.table-modern tbody tr { border-bottom: 1px solid rgba(0, 0, 0, 0.04); transition: background 0.15s ease; }
.table-modern tbody tr:hover { background: rgba(0, 0, 0, 0.02); }
html.dark .table-modern thead { border-bottom-color: rgba(255, 255, 255, 0.06); }
html.dark .table-modern tbody tr { border-bottom-color: rgba(255, 255, 255, 0.03); }
html.dark .table-modern tbody tr:hover { background: rgba(0, 180, 216, 0.03); }

/* Dark theme overrides - opt-in via html.dark class */
html.dark {
    --scrim: rgba(2, 6, 23, 0.7);
    --bg-dark: #0A1628;
    --bg-base: #0A1628;
    --bg-card: #1E293B;
    --bg-card-hover: #334155;
    --bg-elevated: #1e293b;
    --border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(15, 23, 42, 0.8);
    --glass-bg-strong: rgba(15, 23, 42, 0.95);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-subtle: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glass-shadow-lg: 0 25px 50px rgba(0, 0, 0, 0.4);
    --glass-hover: rgba(255, 255, 255, 0.05);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 60px rgba(0, 180, 216, 0.3);

    /* The severity ramp itself is deliberately NOT redefined for dark: a
       Critical is the same red in both themes, which is what lets an operator
       carry one mental colour map between them. Only the STROKE variants move,
       and they move back to the base tokens: the light-mode darkening exists to
       survive #F0F4F8, and on #0A1628 it would be the darkening that is hard to
       read. */
    --sev-stroke-critical: #ef4444;
    --sev-stroke-high: #f97316;
    --sev-stroke-medium: #eab308;
    --sev-stroke-low: #22c55e;
    --sev-stroke-info: #9ca3af;
    --severity-unknown: #64748b;

    /* The track has to go the other way on a dark canvas: a lighter well and a
       deeper shadow, or the inset reads as a smudge rather than as depth. */
    --es-sev-track: rgba(255, 255, 255, 0.07);
    --es-sev-track-inset: inset 0 1px 2px rgba(0, 0, 0, 0.5);
    --es-sev-edge-none: rgba(255, 255, 255, 0.22);
}

/* Light-default element styles */
body { background: #F0F4F8; color: #1e293b; }
.sidebar { background: rgba(255, 255, 255, 0.9); border-right: 1px solid rgba(0, 0, 0, 0.08); }
.sidebar .nav-item { color: #64748b; }
.sidebar .nav-item:hover { background: rgba(0, 0, 0, 0.04); color: #1e293b; }
.sidebar .nav-item.active { background: rgba(0, 180, 216, 0.15); color: #0F2B5B; border-left: 3px solid #00B4D8; }
.card { background: rgba(255, 255, 255, 0.8); border: 1px solid rgba(0, 0, 0, 0.06); }
.card-header { border-bottom: 1px solid rgba(0, 0, 0, 0.06); }
.badge { background: rgba(0, 0, 0, 0.05); }
.modal-backdrop { background: rgba(0, 0, 0, 0.4); }
.modal-content { background: #ffffff; }
input, select, textarea { background: rgba(255, 255, 255, 0.9); border-color: rgba(0, 0, 0, 0.12); color: #1e293b; }
.table th { color: #64748b; border-bottom: 1px solid rgba(0, 0, 0, 0.08); }
.table td { border-bottom: 1px solid rgba(0, 0, 0, 0.04); }
.table tr:hover { background: rgba(0, 0, 0, 0.02); }
.topbar { background: rgba(255, 255, 255, 0.9); border-bottom: 1px solid rgba(0, 0, 0, 0.06); backdrop-filter: blur(12px); }
.top-header { background: rgba(255, 255, 255, 0.9); border-bottom: 1px solid rgba(0, 0, 0, 0.06); backdrop-filter: blur(12px); }
.metric-card { background: rgba(255, 255, 255, 0.8); }
.empty-icon { color: #94a3b8; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #94a3b8, #cbd5e1); }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #64748b, #94a3b8); }
::selection { background: rgba(0, 180, 216, 0.2); color: #0F2B5B; }
.progress-bar { background: rgba(0, 0, 0, 0.08); }
.progress-fill { background: linear-gradient(90deg, #0F2B5B, #00B4D8); }
/* Light-theme stat values: the base rule (later in file) sets a gradient
   text-clip with transparent text-fill, which renders invisible in the
   light theme on light card backgrounds. Override the fill explicitly so
   the gradient-clip is disabled in light mode and a solid dark colour is
   shown. Dark mode uses its own override below. */
.metric-value, .stat-value {
    color: #1e293b;
    -webkit-text-fill-color: #1e293b;
    background: none;
    background-clip: initial;
    -webkit-background-clip: initial;
}
.stage-progress .progress-bar { background: rgba(0, 0, 0, 0.06); }
.sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }

/* Dark mode element overrides */
html.dark body { background: #0A1628; color: #f8fafc; }
html.dark body::before { display: block; }
html.dark .sidebar { background: rgba(15, 23, 42, 0.8); border-right: 1px solid rgba(255, 255, 255, 0.08); }
html.dark .sidebar .nav-item { color: #94a3b8; }
html.dark .sidebar .nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #f8fafc; }
html.dark .sidebar .nav-item.active { background: rgba(0, 180, 216, 0.15); color: #00B4D8; border-left: 3px solid #00B4D8; }
html.dark .card { background: #1E293B; border: 1px solid rgba(255, 255, 255, 0.06); }
html.dark .card-header { border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
html.dark .badge { background: rgba(255, 255, 255, 0.05); }
html.dark .badge-primary { color: var(--primary-light); }
html.dark .modal-backdrop { background: rgba(0, 0, 0, 0.6); }
html.dark .modal-content { background: #1e293b; }
html.dark input, html.dark select, html.dark textarea { background: rgba(15, 23, 42, 0.8); border-color: rgba(255, 255, 255, 0.08); color: #f8fafc; }
html.dark .table th { color: #64748b; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
html.dark .table td { border-bottom: 1px solid rgba(255, 255, 255, 0.03); }
html.dark .table tr:hover { background: rgba(0, 180, 216, 0.03); }
html.dark .topbar { background: rgba(15, 23, 42, 0.8); border-bottom: 1px solid rgba(255, 255, 255, 0.06); backdrop-filter: blur(12px); }
html.dark .top-header { background: rgba(15, 23, 42, 0.8); border-bottom: 1px solid rgba(255, 255, 255, 0.06); backdrop-filter: blur(12px); }
html.dark .metric-card { background: #1E293B; }
html.dark .empty-icon { color: #64748b; }
html.dark ::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #334155, #475569); }
html.dark ::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #475569, #64748b); }
html.dark ::selection { background: rgba(0, 180, 216, 0.3); color: #f8fafc; }
html.dark .progress-bar { background: rgba(255, 255, 255, 0.06); }
html.dark .progress-fill { background: linear-gradient(90deg, #00B4D8, #3d83f6); }
/* Dark-theme stat values: matching the light override - disable gradient
   text-clip and use a solid bright colour for dependable readability. */
html.dark .metric-value, html.dark .stat-value {
    color: #f8fafc;
    -webkit-text-fill-color: #f8fafc;
    background: none;
    background-clip: initial;
    -webkit-background-clip: initial;
}
html.dark .stage-progress .progress-bar { background: rgba(255, 255, 255, 0.06); }
html.dark .sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }
html.dark .sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
html.dark .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }

/* Terminal/execution output - stays dark in both modes */
.execution-output { background: #0d1117; color: #c9d1d9; border-color: #30363d; }
.execution-output::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

/* Findings table severity row tinting (light default) */
.table tr[data-severity="critical"], tr.severity-critical { background: rgba(239, 68, 68, 0.06); }
.table tr[data-severity="high"], tr.severity-high { background: rgba(249, 115, 22, 0.06); }
.table tr[data-severity="medium"], tr.severity-medium { background: rgba(245, 158, 11, 0.04); }
.table tr[data-severity="low"], tr.severity-low { background: rgba(34, 197, 94, 0.04); }
.table tr[data-severity="info"], tr.severity-info { background: rgba(0, 180, 216, 0.04); }

/* Dark mode severity tinting - slightly subtler */
html.dark .table tr[data-severity="critical"], html.dark tr.severity-critical { background: rgba(239, 68, 68, 0.04); }
html.dark .table tr[data-severity="high"], html.dark tr.severity-high { background: rgba(249, 115, 22, 0.04); }
html.dark .table tr[data-severity="medium"], html.dark tr.severity-medium { background: rgba(245, 158, 11, 0.03); }
html.dark .table tr[data-severity="low"], html.dark tr.severity-low { background: rgba(34, 197, 94, 0.03); }
html.dark .table tr[data-severity="info"], html.dark tr.severity-info { background: rgba(0, 180, 216, 0.03); }

/* Light-default text visibility */
h1, h2, h3, h4 { color: #1e293b; }
p { color: #475569; }
.page-title, .section-title { color: #1e293b; }
.page-subtitle, .page-description { color: #64748b; }
label, .form-label { color: #475569; }
.nav-section-title { color: #94a3b8; }
.finding-title, .vuln-title { color: #1e293b; }
.finding-host, .vuln-target { color: #64748b; }
.tab { color: #64748b; }
.tab.active, .tab-active { color: #0F2B5B; border-bottom-color: #00B4D8; }
.breadcrumb-link { color: #64748b; }
.breadcrumb-current { color: #1e293b; }

/* Dark mode text visibility */
html.dark h1, html.dark h2, html.dark h3, html.dark h4 { color: #f8fafc; }
html.dark p { color: #94a3b8; }
html.dark .page-title, html.dark .section-title { color: #f8fafc; }
html.dark .page-subtitle, html.dark .page-description { color: #94a3b8; }
html.dark label, html.dark .form-label { color: #94a3b8; }
html.dark .nav-section-title { color: #64748b; }
html.dark .finding-title, html.dark .vuln-title { color: #f8fafc; }
html.dark .finding-host, html.dark .vuln-target { color: #94a3b8; }
html.dark .tab { color: #94a3b8; }
html.dark .tab.active, html.dark .tab-active { color: #00B4D8; border-bottom-color: #00B4D8; }
html.dark .breadcrumb-link { color: #94a3b8; }
html.dark .breadcrumb-current { color: #f8fafc; }

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}
.theme-toggle:hover {
    background: rgba(0, 180, 216, 0.1);
    color: var(--secondary);
    border-color: var(--secondary);
}

/* Reset and Base - Cross-browser normalization */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    /* The sticky .top-header covers the top of the viewport, and so do the fixed
       banners. Anything scrolled or focused into view stops below them instead
       of under them (WCAG 2.2, Focus Not Obscured). */
    scroll-padding-top: calc(5rem + var(--banner-offset, 0px));
}

body {
    font-family: var(--font-sans);
    /* 0.875rem = 14px at the 16px html base. Matches superadmin body size for
       cross-app parity. Was forced to 12px which was inconsistent and made
       inline px sizes feel disproportionate. */
    font-size: 0.875rem;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

/* GPU acceleration for animated elements */
.sidebar,
.card,
.stat-card,
.metric-card,
.btn,
.toast,
.modal,
.status-dot,
.notification-dropdown {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ========================================
   LAYOUT
   ======================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 200px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    overflow: hidden;
}

.sidebar-logo .sidebar-wordmark {
    height: 28px !important;
    max-height: 28px !important;
    width: auto !important;
    max-width: 148px !important;
    object-fit: contain !important;
}

.sidebar-logo .logo-icon {
    width: 32px;
    height: 32px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
}

.sidebar-logo h1 {
    font-size: 1.1rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tenant-badge {
    display: block;
    background: rgba(0, 180, 216, 0.1);
    color: var(--primary-light);
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-md);
    font-size: max(0.7rem, var(--fit-text-min, 0px));
    font-weight: 600;
    margin-top: 0.625rem;
    border: 1px solid rgba(0, 180, 216, 0.2);
    white-space: nowrap;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.625rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1rem;
}

.nav-section-title {
    font-size: max(0.7rem, var(--fit-text-min, 0px));
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 1rem;
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 2px;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.85rem;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(0, 180, 216, 0.1);
    color: var(--primary-light);
}

.nav-item.active {
    background: rgba(0, 180, 216, 0.15);
    color: var(--primary-light);
    border-left: 3px solid var(--secondary);
    font-weight: 600;
}

.nav-sub-item {
    padding-left: 42px;
    font-size: 0.8rem;
}

.nav-child {
    padding-left: 2.75rem;
    font-size: 0.78rem;
    opacity: 0.7;
    border-left: 2px solid rgba(0, 180, 216, 0.2);
    margin-left: 1rem;
}

.nav-child:hover {
    opacity: 1;
}

.nav-child.active {
    opacity: 1;
    border-left: 2px solid var(--secondary);
}

/* Sidebar Nav Groups - expandable submenu */
.nav-group {
    margin-bottom: 2px;
}

.sidebar .nav-group-head {
    position: relative;
}

.sidebar .nav-group .nav-group-link {
    padding-right: 2.35rem;
    margin-bottom: 0;
}

.sidebar .nav-group .nav-group-link.active {
    box-shadow: 0 0 0 1px rgba(0, 180, 216, 0.2), 0 0 16px -5px var(--secondary-glow);
}

.sidebar .nav-group-toggle {
    position: absolute;
    top: 50%;
    right: 0.3rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.45rem;
    height: 1.45rem;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: max(0.62rem, var(--fit-text-min, 0px));
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar .nav-group-toggle:hover {
    background: rgba(0, 180, 216, 0.16);
    color: var(--secondary);
}

.sidebar .nav-group-toggle:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 1px;
}

.sidebar .nav-group-toggle i {
    transition: transform 0.2s ease;
}

.sidebar .nav-group.is-open .nav-group-toggle i {
    transform: rotate(180deg);
}

.sidebar .nav-group-items {
    display: none;
    padding-top: 0.15rem;
    padding-bottom: 0.2rem;
}

.sidebar .nav-group.is-open .nav-group-items {
    display: block;
}

.sidebar .nav-group-items .nav-child {
    padding: 0.38rem 0.7rem 0.38rem 1.6rem;
    margin-bottom: 0;
    border-left: 2px solid rgba(0, 180, 216, 0.18);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.sidebar .nav-group-items .nav-child:hover {
    background: rgba(0, 180, 216, 0.1);
    border-left-color: rgba(0, 180, 216, 0.45);
    opacity: 1;
}

.sidebar .nav-group-items .nav-child.active {
    background: rgba(0, 180, 216, 0.15);
    border-left: 2px solid var(--secondary);
    color: var(--secondary);
    font-weight: 600;
    opacity: 1;
    box-shadow: 0 0 0 1px rgba(0, 180, 216, 0.18), 0 0 14px -4px var(--secondary-glow);
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    color: inherit;
}

.nav-badge {
    margin-left: auto;
    padding: 2px 0.5rem;
    font-size: max(0.7rem, var(--fit-text-min, 0px));
    font-weight: 700;
    border-radius: 20px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

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

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: #ffffff;
}

.user-info {
    flex: 1;
    min-width: 0;
}

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

.user-role {
    font-size: max(0.7rem, var(--fit-text-min, 0px));
    color: var(--text-muted);
}

/* ========================================
   MAIN CONTENT
   ======================================== */
/* Wide content is clipped here, never scrolled. `overflow-x: hidden` also made
   this element the scroll container (overflow-y computes to auto), so the
   sticky .top-header stuck to a box that never scrolls and rode off with the
   page. `clip` hides the same overflow without making a scroll container.
   min-width: 0 keeps the clip: a clipped flex item no longer gets the zero
   automatic minimum, and without it wide content stretched this box and pushed
   the header controls off screen. `hidden` stays as the fallback for a browser
   that predates `clip`. */
.main-content {
    margin-left: 200px;
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    position: relative;
    transition: margin-right 0.3s ease, width 0.3s ease, max-width 0.3s ease;
    overflow-x: hidden;
    overflow-x: clip;
}

/* Top Header */
.top-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.625rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: var(--banner-offset, 0px);
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.mobile-menu-toggle:hover {
    background: rgba(0, 180, 216, 0.1);
    color: var(--primary-light);
    border-color: rgba(0, 180, 216, 0.3);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .header-left {
        display: flex;
    }
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

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

.breadcrumb a:hover {
    color: var(--primary-light);
}

.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-action {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.header-action:hover {
    background: rgba(0, 180, 216, 0.1);
    color: var(--primary-light);
    border-color: rgba(0, 180, 216, 0.3);
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    animation: pulse 2s infinite;
    will-change: transform, opacity;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *:not(.pa-launcher):not(.pa-launcher *):not(.pa-panel):not(.pa-panel *),
    *:not(.pa-launcher):not(.pa-launcher *):not(.pa-panel):not(.pa-panel *)::before,
    *:not(.pa-launcher):not(.pa-launcher *):not(.pa-panel):not(.pa-panel *)::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Page Content */
.page-content {
    padding: 1rem 1.25rem;
    max-width: var(--fit-page-max);
    margin: 0 auto;
}

/* AI Operator Mission Control - full bleed beside sidebar (ultrawide-safe) */
.main-content:has(#aiopMain) {
    width: calc(100vw - 200px);
    max-width: none;
}
.main-content:has(#aiopMain) > .page-content {
    max-width: none !important;
    margin: 0 !important;
    width: 100%;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.page-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.page-actions {
    display: flex;
    gap: 0.75rem;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: rgba(0, 180, 216, 0.3);
    box-shadow: var(--shadow-glow);
}

/* The glass card: the same box as .card, on the glass tokens. The class used
   to carry no surface at all, so a bare glass-card rendered as nothing: no
   background, no padding, stacked cards touching. .stat-card and .modal already
   carry their own surface and spacing, so they are left out. :where() keeps the
   selector at class specificity, so a page that sizes its own card
   (.profile-card, an inline padding) still wins. */
.glass-card:where(:not(.stat-card, .modal)) {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--glass-shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    color: var(--primary-light);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

/* ========================================
   STATS GRID
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Text column inside a horizontal stat card (icon + info). min-width:0 is
   required so the label/value can shrink and wrap/ellipsize instead of
   overflowing and overlapping the mono .stat-value at narrow widths/zoom. */
.stat-info {
    min-width: 0;
    flex: 1 1 auto;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 0.875rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(0, 180, 216, 0.3);
    box-shadow: var(--shadow-glow);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: var(--gradient-primary);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 180, 216, 0.4);
}

.stat-icon.critical {
    background: linear-gradient(135deg, var(--critical), #b91c1c);
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.4);
}

.stat-icon.high {
    background: linear-gradient(135deg, var(--high), #ea580c);
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}

.stat-icon.medium {
    background: linear-gradient(135deg, var(--medium), #ca8a04);
}

.stat-icon.low {
    background: linear-gradient(135deg, var(--low), #16a34a);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.stat-icon.secondary {
    background: linear-gradient(135deg, var(--secondary), #0891b2);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2px;
    font-family: var(--font-mono);
    line-height: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ========================================
   TABLES
   ======================================== */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: rgba(0, 180, 216, 0.05);
}

.table th {
    padding: 0.5rem 0.625rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: max(0.65rem, var(--fit-text-min, 0px));
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.5rem 0.625rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background: rgba(0, 180, 216, 0.03);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    font-family: var(--font-sans);
}

.btn-primary {
    background: var(--gradient-primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 180, 216, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 180, 216, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary), #0891b2);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(6, 182, 212, 0.5);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--danger);
    color: #ffffff;
}

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

.btn-outline:hover {
    background: rgba(0, 180, 216, 0.1);
    color: var(--primary-light);
    border-color: rgba(0, 180, 216, 0.3);
}

.btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
}

/* Button Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    -webkit-animation: btn-spin 0.6s linear infinite;
    animation: btn-spin 0.6s linear infinite;
}

.btn-loading > * {
    visibility: hidden;
}

@keyframes btn-spin {
    to {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

/* Button disabled state */
.btn:disabled,
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: max(0.65rem, var(--fit-text-min, 0px));
    font-weight: 700;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
    border-color: rgba(245, 158, 11, 0.3);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.3);
}

.badge-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border-color: var(--border);
}

.badge-primary {
    background: rgba(15, 43, 91, 0.1);
    color: var(--primary);
    border-color: rgba(15, 43, 91, 0.3);
}

/* ========================================
   FORMS
   ======================================== */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: max(0.95rem, var(--fit-field-min, 0px));
    transition: all 0.3s ease;
}

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

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.1);
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* ========================================
   LOGIN PAGE
   ======================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    z-index: 10;
    background: var(--bg-dark);
}

.login-container {
    max-width: 380px;
    width: 100%;
    padding: 2.25rem 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--glass-shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo {
    font-size: 1.6rem;
    font-weight: 900;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.375rem;
    font-family: var(--font-mono);
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 1.5rem;
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: rgba(0, 180, 216, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary-light);
}

.empty-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-text {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ========================================
   ALERTS
   ======================================== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    border: 1px solid;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.alert-icon {
    font-size: 1.25rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
    border-color: rgba(245, 158, 11, 0.3);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.3);
}

/* ========================================
   SEVERITY COLORS
   ======================================== */
.severity-critical {
    background: rgba(220, 38, 38, 0.1);
    color: var(--critical);
    border-color: rgba(220, 38, 38, 0.3);
}

.severity-high {
    background: rgba(249, 115, 22, 0.1);
    color: var(--high);
    border-color: rgba(249, 115, 22, 0.3);
}

.severity-medium {
    background: rgba(234, 179, 8, 0.1);
    color: #fbbf24;
    border-color: rgba(234, 179, 8, 0.3);
}

.severity-low {
    background: rgba(34, 197, 94, 0.1);
    color: var(--low);
    border-color: rgba(34, 197, 94, 0.3);
}

.severity-info {
    background: rgba(107, 114, 128, 0.1);
    color: var(--informational);
    border-color: rgba(107, 114, 128, 0.3);
}

/* ========================================
   PROGRESS BAR
   ======================================== */
.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ========================================
   UTILITIES
   ======================================== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary-light) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-mono { font-family: var(--font-mono); }
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.mt-4 { margin-top: 1rem !important; }

.hidden { display: none !important; }

/* Visually hidden, still in the accessibility tree: a label whose control
   already says what it is (a placeholder, a first option) but must keep an
   accessible name. Without this rule such a label renders as plain text. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   RESPONSIVE - Base breakpoints
   ======================================== */

/* Large desktop (1600px and above) */
@media (min-width: 1600px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .findings-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Desktop (1440px and below) */
@media (max-width: 1440px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.625rem;
    }
}

/* Small desktop / Large tablet (1200px and below) */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

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

/* Tablet (1024px and below) */
@media (max-width: 1024px) {
    .notification-dropdown {
        width: 320px;
    }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    -webkit-transition: opacity 0.3s ease;
    transition: opacity 0.3s ease;
}

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

/* Small tablet / Large phone (768px and below) */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(84vw, 300px);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
        overflow-y: auto;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }

    .sidebar.expanded {
        transform: none;
        box-shadow: var(--glass-shadow-lg);
    }

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

    .page-content {
        padding: 0.75rem;
    }

    .page-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .page-actions {
        flex-wrap: wrap;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.625rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .top-header {
        padding: 0.625rem 0.75rem;
    }

    /* The breadcrumb gives way so the header controls stay on screen */
    .header-left {
        flex: 1 1 auto;
        min-width: 0;
        gap: var(--fit-space-sm);
    }

    .mobile-menu-toggle,
    .header-right {
        flex-shrink: 0;
    }

    .header-right {
        gap: var(--fit-space-sm);
    }

    .breadcrumb {
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
    }

    .breadcrumb .current {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .card-header {
        flex-wrap: wrap;
        gap: var(--fit-space-sm);
    }

    /* A filter group inside a card header wraps too, and no field outgrows its row */
    .card-header > div {
        flex-wrap: wrap;
        min-width: 0;
    }

    .page-content :is(input, select, textarea) {
        max-width: 100%;
    }

    .notification-dropdown {
        position: fixed;
        top: 50px;
        right: 8px;
        left: 8px;
        width: auto;
        max-width: none;
    }

    .toast-container {
        left: 12px;
        right: 12px;
        max-width: none;
    }

    .toast {
        width: 100%;
    }

    .findings-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.375rem;
    }

    .finding-count .count {
        font-size: 1.2rem;
    }

    .table-responsive {
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }
}

/* Phone (480px and below) */
@media (max-width: 480px) {
    body {
        font-size: var(--fit-text-body);
    }

    .breadcrumb > :not(.current) {
        display: none;
    }

    .page-content {
        padding: 0.5rem;
    }

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

    .stat-card {
        padding: 0.5rem;
    }

    .card {
        padding: 0.5rem;
        border-radius: var(--radius-md);
    }

    .btn {
        padding: 0.375rem 0.625rem;
        font-size: var(--fit-text-body);
    }

    .btn-lg {
        padding: 0.5rem 0.875rem;
    }

    .page-header h1 {
        font-size: var(--fit-text-title);
    }

    .findings-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.25rem;
    }

    .finding-count {
        padding: 0.375rem 3px;
    }

    .finding-count .count {
        font-size: 1rem;
    }

    .finding-count .label {
        font-size: var(--fit-text-floor);
    }
}

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

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #475569, #334155);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #64748b, #475569);
}

/* Selection */
::selection {
    background: rgba(0, 180, 216, 0.3);
    color: var(--text-primary);
}

/* ========================================
   ENHANCED STATUS INDICATORS
   ======================================== */

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    will-change: transform, opacity;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.status-dot.deploying {
    background: var(--warning);
    -webkit-animation: pulse-ring 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    animation: pulse-ring 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.status-dot.deploying::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--warning);
    -webkit-animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
    animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
    opacity: 0.75;
}

.status-dot.running {
    background: var(--success);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
}

.status-dot.stopped {
    background: var(--informational);
}

.status-dot.error {
    background: var(--danger);
    -webkit-animation: pulse-urgent 0.8s ease-in-out infinite;
    animation: pulse-urgent 0.8s ease-in-out infinite;
}

@keyframes pulse-ring {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

@keyframes ping {
    0% { transform: scale(1); opacity: 1; }
    75%, 100% { transform: scale(2); opacity: 0; }
}

@keyframes pulse-urgent {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   ENHANCED METRIC CARDS
   ======================================== */

.metric-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s ease;
    will-change: transform;
}

/* Fallback for browsers without backdrop-filter */
@supports not ((-webkit-backdrop-filter: blur(16px)) or (backdrop-filter: blur(16px))) {
    .metric-card {
        background: var(--bg-card);
    }
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--glass-shadow-lg);
    border-color: rgba(0, 180, 216, 0.4);
}

.metric-card:hover::before {
    opacity: 1;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: rgba(0, 180, 216, 0.1);
    color: var(--primary-light);
}

.metric-icon.critical {
    background: rgba(220, 38, 38, 0.1);
    color: var(--critical);
}

.metric-icon.high {
    background: rgba(249, 115, 22, 0.1);
    color: var(--high);
}

.metric-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
    font-size: max(0.7rem, var(--fit-text-min, 0px));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-badge.live {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background: var(--danger);
    border-radius: 50%;
    -webkit-animation: livePulse 2s infinite;
    animation: livePulse 2s infinite;
    will-change: transform, opacity;
}

.metric-value-container {
    margin: 1rem 0;
}

.metric-value {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.value-primary {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.value-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-trend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.trend-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.trend-indicator.positive {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.trend-indicator.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.trend-indicator.neutral {
    background: rgba(107, 114, 128, 0.1);
    color: var(--informational);
}

.trend-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.metric-sparkline {
    width: 100%;
    height: 40px;
    margin-top: 1rem;
    opacity: 0.8;
}

.severity-breakdown {
    margin-top: 1rem;
}

.severity-bar {
    display: flex;
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.severity-segment {
    height: 100%;
    transition: width 0.3s ease;
}

.severity-segment.critical {
    background: var(--critical);
}

.severity-segment.high {
    background: var(--high);
}

.severity-segment.medium {
    background: var(--medium);
}

.severity-segment.low {
    background: var(--low);
}

.severity-labels {
    display: flex;
    gap: 0.75rem;
    font-size: max(0.7rem, var(--fit-text-min, 0px));
    color: var(--text-muted);
}

/* ========================================
   NOTIFICATION CENTER
   ======================================== */

.notification-center {
    position: relative;
}

.notification-bell {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.notification-bell:hover {
    background: rgba(0, 180, 216, 0.1);
    color: var(--primary-light);
    border-color: rgba(0, 180, 216, 0.3);
}

.notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 0.3125rem;
    background: #ef4444;
    color: white;
    font-size: max(0.65rem, var(--fit-text-min, 0px));
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scaleIn 0.3s ease-out;
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 420px;
    max-width: calc(100vw - 40px);
    max-height: 600px;
    background: var(--glass-bg-strong);
    -webkit-backdrop-filter: blur(30px);
    backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow-lg);
    display: none;
    flex-direction: column;
    z-index: 1000;
    -webkit-animation: slideDown 0.2s ease-out;
    animation: slideDown 0.2s ease-out;
}

@supports not ((-webkit-backdrop-filter: blur(30px)) or (backdrop-filter: blur(30px))) {
    .notification-dropdown {
        background: var(--bg-card);
    }
}

.notification-dropdown.show {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.notification-header h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.notification-list {
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    cursor: pointer;
}

.notification-item:hover {
    background: rgba(0, 180, 216, 0.05);
}

.notification-item.unread {
    background: rgba(0, 180, 216, 0.03);
    border-left: 3px solid var(--secondary);
}

.notif-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.notif-icon.critical {
    background: rgba(220, 38, 38, 0.1);
    color: var(--critical);
}

.notif-icon.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.notif-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.notif-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.notif-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.notification-footer {
    padding: 0.75rem 1.25rem;
    text-align: center;
    border-top: 1px solid var(--border);
}

.notification-footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
}

.notification-footer a:hover {
    text-decoration: underline;
}

/* ========================================
   LIVE FEATURES
   ======================================== */

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 380px;
    max-width: calc(100vw - 40px);
}

.toast {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(30px);
    backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    box-shadow: var(--glass-shadow-lg);
    opacity: 0;
    -webkit-transform: translateX(400px);
    transform: translateX(400px);
    -webkit-transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    will-change: transform, opacity;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

@supports not ((-webkit-backdrop-filter: blur(30px)) or (backdrop-filter: blur(30px))) {
    .toast {
        background: var(--bg-card);
    }
}

.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-hide {
    opacity: 0;
    transform: translateX(400px);
}

.toast-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.toast-danger .toast-icon {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.toast-warning .toast-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.toast-info .toast-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* Live Indicator */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    animation: livePulse 2s infinite;
    box-shadow: 0 0 10px var(--danger);
}

.live-text {
    color: var(--danger);
}

@keyframes livePulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* ========================================
   PROGRESSIVE SCAN TRACKER
   ======================================== */

.scan-progress-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.scan-stages {
    margin: 1.5rem 0;
}

.stage {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    position: relative;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.stage:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 27px;
    top: 56px;
    width: 2px;
    height: calc(100% + 12px);
    background: var(--border);
}

.stage.completed {
    background: rgba(16, 185, 129, 0.05);
}

.stage.completed::after {
    background: #10b981;
}

.stage.active {
    background: rgba(0, 180, 216, 0.05);
    border-left: 3px solid var(--secondary);
}

.stage.active::after {
    background: var(--secondary);
}

.stage.pending {
    opacity: 0.6;
}

.stage-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.stage.completed .stage-indicator {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 2px solid var(--success);
}

.stage.active .stage-indicator {
    background: rgba(0, 180, 216, 0.1);
    color: var(--primary-light);
    border: 2px solid var(--secondary);
}

.stage.pending .stage-indicator {
    background: rgba(107, 114, 128, 0.1);
    color: var(--informational);
    border: 2px solid var(--border);
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.stage-content {
    flex: 1;
}

.stage-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stage-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stage-progress {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.stage-progress .progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.findings-counter {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.counter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.findings-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.finding-count {
    text-align: center;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.finding-count.flash {
    animation: flashCount 0.5s ease-out;
}

@keyframes flashCount {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.finding-count.critical {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.finding-count.high {
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.2);
}

.finding-count.medium {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.2);
}

.finding-count.low {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.finding-count .count {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.finding-count.critical .count { color: var(--critical); }
.finding-count.high .count { color: var(--high); }
.finding-count.medium .count { color: var(--medium); }
.finding-count.low .count { color: var(--low); }

.finding-count .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.scan-activity-stream {
    margin-top: 1.5rem;
}

.stream-header {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.stream-content {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.stream-item {
    display: flex;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    opacity: 0.9;
    transition: all 0.2s;
}

.stream-item.new {
    background: rgba(0, 180, 216, 0.1);
    animation: slideInDown 0.3s ease-out;
}

.stream-item:hover {
    background: rgba(255, 255, 255, 0.05);
    opacity: 1;
}

.stream-time {
    color: #6b7280;
    flex-shrink: 0;
}

.stream-scanner {
    color: #3b82f6;
    flex-shrink: 0;
    font-weight: 600;
}

.stream-message {
    color: var(--text-secondary);
    flex: 1;
}

/* ========================================
   ENHANCED ACTIVITY FEED
   ======================================== */

.activity-feed {
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
    position: relative;
}

.activity-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    position: relative;
}

.activity-item:hover {
    background: rgba(0, 180, 216, 0.03);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: 34px;
    top: 48px;
    width: 2px;
    height: calc(100% - 48px + 14px);
    background: var(--border);
}

.activity-item:last-child::before {
    display: none;
}

.activity-placeholder {
    opacity: 0.6;
    font-style: italic;
}

.activity-placeholder::before {
    display: none;
}

.activity-timeline-dot {
    position: absolute;
    left: 30px;
    top: 24px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    z-index: 2;
    border: 2px solid var(--bg-card);
}

.activity-info .activity-timeline-dot {
    background: var(--info);
}

.activity-success .activity-timeline-dot {
    background: var(--success);
}

.activity-danger .activity-timeline-dot {
    background: var(--danger);
}

.activity-warning .activity-timeline-dot {
    background: var(--warning);
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.activity-info .activity-icon {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.activity-success .activity-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.activity-danger .activity-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.activity-warning .activity-icon {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Animations */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================
   MODAL STYLES
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.25rem;
    overflow-y: auto;
    animation: fadeIn 0.2s ease-out;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--glass-shadow-lg);
    animation: scaleIn 0.2s ease-out;
    margin: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 180, 216, 0.05);
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header h2 i {
    color: var(--primary-light);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.modal-body {
    padding: 1rem 1.125rem;
    overflow-y: auto;
    flex: 1;
    color: var(--text-primary);
    min-height: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.625rem;
    padding: 0.75rem 1.125rem;
    border-top: 1px solid var(--border);
    background: var(--glass-hover);
    flex-shrink: 0;
}

/* A <form> wrapping body+footer is a flex item of .modal. Without this it
   grows to content height and overflow:hidden clips the footer on short
   screens (Generate Report required zoom-out to reach Cancel/Generate). */
.modal > form,
.modal-container > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Form elements in modal */
.modal .form-group {
    margin-bottom: 0.875rem;
}

.modal .form-label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.modal .form-control {
    padding: 0.5rem 0.75rem;
    font-size: max(0.85rem, var(--fit-field-min, 0px));
}

.modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.modal .form-control {
    width: 100%;
    padding: 0.75rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: max(0.95rem, var(--fit-field-min, 0px));
    transition: all 0.2s;
}

.modal .form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.15);
}

.modal .form-control::placeholder {
    color: var(--text-muted);
}

.modal textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.modal select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 2.25rem;
}

.modal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Custom Checkbox Styling */
.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    position: relative;
    padding: 0.625rem 0.875rem;
    background: rgba(0, 180, 216, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.custom-checkbox:hover {
    background: rgba(0, 180, 216, 0.1);
    border-color: rgba(0, 180, 216, 0.3);
}

.custom-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.custom-checkbox .checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.custom-checkbox .checkmark::after {
    content: '';
    display: none;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.custom-checkbox input[type="checkbox"]:checked + .checkmark {
    background: var(--gradient-primary);
    border-color: var(--primary-light);
}

.custom-checkbox input[type="checkbox"]:checked + .checkmark::after {
    display: block;
}

.custom-checkbox .checkbox-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.custom-checkbox .checkbox-content i {
    color: var(--primary-light);
    font-size: 1rem;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* Checkbox styling in modal (legacy) */
.modal .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.modal .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-light);
    cursor: pointer;
}

/* Glass card in modal */
.modal.glass-card {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Responsive modal */
@media (max-width: 640px) {
    .modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-overlay {
        padding: 0;
    }

    .modal .form-row {
        grid-template-columns: 1fr;
    }
}

/* Confirm modal (smaller) */
.modal.modal-confirm {
    max-width: 400px;
}

/* Shared panel helper for hand-rolled full-screen modal overlays -
   caps height and lets a tall panel scroll into reach instead of clipping. */
.modal-panel {
    width: min(560px, 92vw);
    max-height: 90vh;
    overflow-y: auto;
}

.modal.modal-confirm .modal-body {
    text-align: center;
    padding: 2rem 1.5rem;
}

.modal.modal-confirm .confirm-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.modal.modal-confirm .confirm-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.modal.modal-confirm .confirm-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.modal.modal-confirm .confirm-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.modal.modal-confirm .confirm-message {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Modal text visibility - ensure readable in both light and dark modes */
.modal h2, .modal h3, .modal-header h2 { color: var(--text-primary); }
.modal p, .modal label, .modal span { color: var(--text-primary); }
.modal .form-label { color: var(--text-secondary); }
.modal .text-secondary { color: var(--text-secondary); }
.modal input, .modal select, .modal textarea { color: var(--text-primary); background: var(--bg-elevated); border-color: var(--border); }

/* ────────────────────────────────────────────────────────────────────
 * .modal-container - alias of .modal so legacy markup renders correctly.
 * Some templates were authored with class="modal-container" rather than
 * class="modal". Without this rule those modals draw with no background
 * and you see the page bleeding through (assets.html add-asset bug).
 * Theme-aware via the same CSS variables .modal uses; works in light
 * AND dark.
 * ──────────────────────────────────────────────────────────────────── */
.modal-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--glass-shadow-lg);
    animation: scaleIn 0.2s ease-out;
    margin: 0;
    color: var(--text-primary);
}
.modal-container h2, .modal-container h3 { color: var(--text-primary); }
.modal-container p, .modal-container label, .modal-container span { color: var(--text-primary); }
.modal-container .form-label { color: var(--text-secondary); }
.modal-container .text-secondary { color: var(--text-secondary); }
.modal-container input, .modal-container select, .modal-container textarea {
    color: var(--text-primary);
    background: var(--bg-elevated);
    border-color: var(--border);
}

/* ========================================
   RESPONSIVE WEB DESIGN - Media Queries
   ======================================== */

/* Very large desktops (1600px and up) - slightly larger */
@media (min-width: 1600px) {
    body { font-size: 0.8125rem; }
    .sidebar { width: 210px; }
    .main-content { margin-left: 210px; }
    .page-content { padding: 1.125rem 1.5rem; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .stat-value { font-size: 1.35rem; }
    .page-header h1 { font-size: 1.35rem; }
}

/* Large desktops (1400px - 1599px) */
@media (min-width: 1400px) and (max-width: 1599px) {
    body { font-size: 0.75rem; }
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; }
    .page-content { padding: 1rem 1.25rem; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .stat-value { font-size: 1.25rem; }
    .page-header h1 { font-size: 1.25rem; }
}

/* Standard desktops (1200px - 1399px) - keep base compact */
@media (min-width: 1200px) and (max-width: 1399px) {
    body { font-size: 0.75rem; }
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; }
    .page-content { padding: 1rem 1.25rem; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .stat-value { font-size: 1.25rem; }
    .page-header h1 { font-size: 1.25rem; }
}

/* Small desktops / Large laptops (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    body { font-size: 0.75rem; }
    .sidebar { width: 180px; }
    .main-content { margin-left: 180px; }
    .page-content { padding: 0.875rem 1rem; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 0.625rem; }
    .stat-card { padding: 0.625rem 0.75rem; }
    .stat-value { font-size: 1.15rem; }
    .stat-label { font-size: max(0.65rem, var(--fit-text-min, 0px)); }
    .page-header h1 { font-size: 1.15rem; }
    .card { padding: 0.75rem 0.875rem; }
    .table th { padding: 0.375rem 0.5rem; font-size: max(0.6rem, var(--fit-text-min, 0px)); }
    .table td { padding: 0.375rem 0.5rem; font-size: 0.75rem; }
}

/* Tablets / Small laptops (769px - 991px) */
@media (min-width: 769px) and (max-width: 991px) {
    body { font-size: var(--fit-text-floor); }
    .sidebar { width: 160px; }
    .main-content { margin-left: 160px; }
    .page-content { padding: 0.75rem 0.875rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .stat-card { padding: 0.5rem 0.625rem; }
    .stat-value { font-size: var(--fit-text-stat); }
    .stat-label { font-size: var(--fit-text-floor); }
    .page-header h1 { font-size: 1.1rem; }
    .card { padding: 0.625rem 0.75rem; }
    .table th { padding: 0.3125rem 0.375rem; font-size: var(--fit-text-floor); }
    .table td { padding: 0.3125rem 0.375rem; font-size: var(--fit-text-floor); }
    .sidebar-header { padding: 0.75rem; }
    .nav-item { padding: 0.375rem 0.625rem; font-size: 0.8rem; }
}

/* Mobile landscape / Small tablets (576px - 767px) */
@media (max-width: 767px) {
    body { font-size: var(--fit-text-body); }
    .main-content { margin-left: 0; }
    .page-content { padding: 0.625rem 0.75rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.375rem; }
    .stat-card { padding: 0.5rem; }
    .stat-value { font-size: var(--fit-text-stat); }
    .page-header { flex-direction: column; gap: 0.625rem; margin-bottom: 0.75rem; }
    .page-header h1 { font-size: var(--fit-text-title); }
    .card { padding: 0.625rem; }
}

/* Mobile portrait (up to 575px) */
@media (max-width: 575px) {
    body { font-size: var(--fit-text-body); }
    .page-content { padding: 0.5rem 0.625rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.375rem; }
    .stat-card { padding: 0.375rem 0.5rem; }
    .stat-value { font-size: var(--fit-text-stat); }
    .stat-label { font-size: var(--fit-text-floor); }
    .page-header h1 { font-size: var(--fit-text-title); }
    .card { padding: 0.5rem; margin-bottom: 0.5rem; }
    .table th { padding: 0.25rem; font-size: var(--fit-text-floor); }
    .table td { padding: 0.25rem; font-size: var(--fit-text-body); }
    .btn { padding: 0.375rem 0.625rem; font-size: var(--fit-text-body); }
}

/* ========================================
   ENS THEME - ANIMATIONS & UTILITIES
   ======================================== */

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.96) translateY(4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 180, 216, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(0, 180, 216, 0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fadeIn { animation: fadeIn 0.3s ease-out; }
.animate-fadeInScale { animation: fadeInScale 0.25s ease-out; }
.animate-slideInRight { animation: slideInRight 0.3s ease-out; }
.animate-pulseGlow { animation: pulseGlow 2s ease-in-out infinite; }

/* Staggered children animation */
.animate-stagger > * { animation: fadeIn 0.3s ease-out both; }
.animate-stagger > *:nth-child(1) { animation-delay: 0s; }
.animate-stagger > *:nth-child(2) { animation-delay: 0.05s; }
.animate-stagger > *:nth-child(3) { animation-delay: 0.1s; }
.animate-stagger > *:nth-child(4) { animation-delay: 0.15s; }
.animate-stagger > *:nth-child(5) { animation-delay: 0.2s; }
.animate-stagger > *:nth-child(6) { animation-delay: 0.25s; }

/* Shimmer loading skeleton - dark default */
.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
.shimmer-dark, html.dark .shimmer {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

/* Glow effect */
.glow-cyan {
    box-shadow: 0 0 20px rgba(0, 180, 216, 0.15), 0 0 40px rgba(0, 180, 216, 0.08);
}

/* ========================================
 * GPU ACCELERATION (compositor layer hints)
 * Selective `will-change` + `translateZ(0)` on elements that animate
 * frequently - pushes rendering to the visitor's device GPU so
 * fades/hovers/scrolls feel smoother. Honors prefers-reduced-motion.
 * ======================================== */
html { scroll-behavior: smooth; }

.modal,
.modal-content,
.modal-overlay {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Same (0,1,0) specificity trap documented on .upgrade-banner: the class rule
 * above sets `display: flex`, which ties the UA-stylesheet `[hidden]` rule and
 * wins, because author styles beat the UA sheet. `overlay.hidden = true` in JS
 * therefore had no effect, and since .modal-overlay is fixed, full-viewport and
 * z-index 9999, the dialog could not be dismissed and it swallowed every click
 * on the page behind it. */
.modal-overlay[hidden] { display: none; }

.stat-card,
.metric-card,
.scan-card,
.finding-card,
.glass-card,
.card {
    contain: paint;
    transform: translateZ(0);
}

.btn,
.btn-primary,
.btn-secondary,
.btn-outline,
.nav-item,
.sidebar-link {
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: transform, opacity;
}

/* Tables: contain layout to keep large lists from triggering page-wide
 * reflow when rows update */
.data-table,
.findings-table,
.scans-table {
    contain: layout style;
}

/* Honor user OS reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    *:not(.pa-launcher):not(.pa-launcher *):not(.pa-panel):not(.pa-panel *),
    *:not(.pa-launcher):not(.pa-launcher *):not(.pa-panel):not(.pa-panel *)::before,
    *:not(.pa-launcher):not(.pa-launcher *):not(.pa-panel):not(.pa-panel *)::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===========================================================
 * Tenant-app upgrade banner + modal (used by tenant-upgrade.js).
 * Themed to match the portal - uses --gradient-primary,
 * --bg-card, --text-primary, --border, --accent (amber for the
 * notice icon, cyan-glow on hover). Security severity flips to
 * --critical / --danger so it reads loud without abandoning the
 * brand language.
 * =========================================================== */
.upgrade-banner {
    display: block;
    /* Warning-yellow theme - sits at the top of every page when an
     * update is available. Uses --warning (#f59e0b) for the accent
     * border + icon, with a soft yellow background so it doesn't
     * dominate the page but is impossible to miss. */
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.16) 0%, rgba(245, 158, 11, 0.10) 100%);
    color: #78350f;
    padding: 0.65rem 1.25rem;
    margin: 0;
    border-bottom: 2px solid var(--warning);
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.18);
    font-family: var(--font-sans);
}
html.dark .upgrade-banner {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.18) 0%, rgba(245, 158, 11, 0.10) 100%);
    color: #fcd34d;
    border-bottom-color: rgba(245, 158, 11, 0.55);
}
/* Defense-in-depth: the class selector .upgrade-banner has the same
 * (0,1,0) specificity as the UA-stylesheet `[hidden]` rule. With
 * `.upgrade-banner` declared later in this file (later wins on tie),
 * the `hidden` attribute alone was being ignored - the banner showed
 * with its static placeholder text even when JS hadn't yet decided
 * whether an update is actually available. This explicit rule
 * disambiguates: if `hidden` is set, the banner is hidden regardless
 * of the .upgrade-banner display. JS toggles `hidden` via
 * banner.hidden = true/false. */
.upgrade-banner[hidden] { display: none; }
.upgrade-banner--security {
    background: linear-gradient(135deg, #7f1d1d 0%, var(--critical) 50%, #ef4444 100%);
}
.upgrade-banner__inner {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    max-width: 1280px;
    margin: 0 auto;
}
.upgrade-banner__icon {
    font-size: 1.05rem;
    flex-shrink: 0;
    color: var(--warning);
}
.upgrade-banner--security .upgrade-banner__icon {
    color: var(--critical);
}
.upgrade-banner__text {
    flex: 1 1 auto;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: #78350f;
}
html.dark .upgrade-banner__text { color: #fef3c7; }
.upgrade-banner__text strong {
    font-weight: 700;
    color: #78350f;
    letter-spacing: 0.01em;
}
html.dark .upgrade-banner__text strong { color: #fcd34d; }
.upgrade-banner__text a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-size: 0.8rem;
    transition: color 0.2s ease;
}
html.dark .upgrade-banner__text a { color: var(--secondary); }
.upgrade-banner__text a:hover { color: var(--primary-dark); }
html.dark .upgrade-banner__text a:hover { color: #ffffff; }
.upgrade-banner__action {
    background: var(--warning);
    color: #ffffff;
    border: 0;
    border-radius: var(--radius-md);
    padding: 0.45rem 1rem;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
}
.upgrade-banner__action:hover {
    transform: translateY(-1px);
    background: #d97706;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.55);
}
.upgrade-banner--security .upgrade-banner__action {
    background: var(--critical);
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4);
}
.upgrade-banner--security .upgrade-banner__action:hover {
    background: #991b1b;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.55);
}
.upgrade-banner__dismiss {
    background: transparent;
    border: 0;
    color: rgba(120, 53, 15, 0.6);
    opacity: 1;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s ease;
}
.upgrade-banner__dismiss:hover { color: #78350f; }
html.dark .upgrade-banner__dismiss { color: rgba(252, 211, 77, 0.7); }
html.dark .upgrade-banner__dismiss:hover { color: #fcd34d; }

/* ============================================================
 * Upgrade-confirmation modal - smart 3-option flow.
 * All classes scoped under .upgrade-modal / .upgrade-choice /
 * .upgrade-btn so the site-wide .modal / .btn rules (used in
 * 220+ places) are never affected. Light + dark theme inherit
 * via CSS custom properties from main.css :root and html.dark.
 * ============================================================ */
.upgrade-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: upgrade-modal-fade 0.18s ease-out;
}
.upgrade-modal[hidden] { display: none; }
@keyframes upgrade-modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.upgrade-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
html.dark .upgrade-modal__backdrop { background: rgba(0, 0, 0, 0.65); }

.upgrade-modal__panel {
    position: relative;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    animation: upgrade-modal-rise 0.22s ease-out;
}
.upgrade-modal__panel--wide { max-width: 560px; }
@keyframes upgrade-modal-rise {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}
html.dark .upgrade-modal__panel { background: #1E293B; border-color: rgba(255, 255, 255, 0.08); }

.upgrade-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.4rem 0.9rem;
    border-bottom: 1px solid var(--border);
}
html.dark .upgrade-modal__header { border-bottom-color: rgba(255, 255, 255, 0.06); }
.upgrade-modal__header-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.upgrade-modal__header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.upgrade-modal__subtitle {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}
.upgrade-modal__close {
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.upgrade-modal__close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}
html.dark .upgrade-modal__close:hover { background: rgba(255, 255, 255, 0.06); }

.upgrade-modal__body {
    padding: 1.1rem 1.4rem 0.4rem;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text-primary);
}

/* Compact list of running scans shown above the choice cards.
 * Hidden via [hidden] when scan count is 0. */
.upgrade-modal__scan-list {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.22);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.95rem;
}
html.dark .upgrade-modal__scan-list {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.28);
}
.upgrade-modal__scan-list[hidden] { display: none; }
.upgrade-modal__scan-list-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--warning);
    margin-bottom: 0.35rem;
}
.upgrade-modal__scan-list-header i { font-size: 0.85rem; }
.upgrade-modal__scan-items {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
    max-height: 92px;
    overflow-y: auto;
}
.upgrade-modal__scan-items li {
    padding: 0.18rem 0;
    border-bottom: 1px dashed transparent;
}
.upgrade-modal__scan-items li + li { border-top: 1px dashed var(--border); }
html.dark .upgrade-modal__scan-items li + li { border-top-color: rgba(255, 255, 255, 0.04); }

.upgrade-modal__hint {
    margin: 0 0 0.85rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.upgrade-modal__components {
    list-style: none;
    margin: 0 0 0.85rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    counter-reset: upg-step;
}
.upgrade-modal__component {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color, rgba(127, 127, 127, 0.18));
    border-radius: 10px;
    background: var(--bg-subtle, rgba(127, 127, 127, 0.05));
    counter-increment: upg-step;
}
.upgrade-modal__component::before {
    content: counter(upg-step);
    flex-shrink: 0;
    width: 1.45rem;
    height: 1.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary, #6366f1);
    color: #fff;
    font-size: max(0.72rem, var(--fit-text-min, 0px));
    font-weight: 700;
}
.upgrade-modal__component-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}
.upgrade-modal__component-ver {
    margin-left: auto;
    font-family: var(--font-mono, monospace);
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.upgrade-modal__safety {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin: 0 0 0.95rem;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.4;
}
.upgrade-modal__safety i {
    color: #22c55e;
    margin-top: 0.12rem;
    flex-shrink: 0;
}
.upgrade-overlay__safety {
    margin: 0.9rem 0 0;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
}
.upgrade-modal__footnote {
    margin: 0.95rem 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.upgrade-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.9rem 1.4rem 1.1rem;
    border-top: 1px solid var(--border);
    background: transparent;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
html.dark .upgrade-modal__footer { border-top-color: rgba(255, 255, 255, 0.06); }

/* ============================================================
 * Choice cards - one button per upgrade option.
 * Recommended (deferred), Destructive (immediate).
 * ============================================================ */
.upgrade-choice-grid {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.upgrade-choice {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.16s, background 0.16s, transform 0.08s, box-shadow 0.16s;
}
.upgrade-choice:hover {
    border-color: var(--secondary);
    background: var(--bg-card-hover);
    box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.1);
}
.upgrade-choice:active { transform: scale(0.997); }
.upgrade-choice:disabled { opacity: 0.55; cursor: not-allowed; }
html.dark .upgrade-choice {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.08);
}
html.dark .upgrade-choice:hover {
    background: rgba(0, 180, 216, 0.06);
    border-color: var(--secondary);
}

.upgrade-choice__icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
}
.upgrade-choice--recommended .upgrade-choice__icon {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}
.upgrade-choice--destructive .upgrade-choice__icon {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.upgrade-choice__text {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    flex: 1;
    min-width: 0;
}
.upgrade-choice__title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.upgrade-choice__desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.4;
}
.upgrade-choice__badge {
    font-size: max(0.65rem, var(--fit-text-min, 0px));
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.12rem 0.45rem;
    border-radius: 9999px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    font-weight: 700;
}
.upgrade-choice__chevron {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: transform 0.15s, color 0.15s;
}
.upgrade-choice:hover .upgrade-choice__chevron {
    color: var(--secondary);
    transform: translateX(2px);
}

/* Loading state - a choice button can show a spinner while the
 * deferred-install / install-now request is in flight. */
.upgrade-choice--loading {
    pointer-events: none;
    opacity: 0.85;
}
.upgrade-choice--loading .upgrade-choice__chevron::before {
    content: "";
    display: block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: upgrade-spin 0.7s linear infinite;
}
.upgrade-choice--loading .upgrade-choice__chevron { content: ""; }
.upgrade-choice--loading .upgrade-choice__chevron i { display: none; }

/* ============================================================
 * Generic upgrade-flow buttons (used in the modal footer only).
 * ============================================================ */
.upgrade-btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.upgrade-btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.upgrade-btn--ghost:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}
html.dark .upgrade-btn--ghost { border-color: rgba(255, 255, 255, 0.1); }
html.dark .upgrade-btn--ghost:hover { background: rgba(255, 255, 255, 0.04); }
.upgrade-btn--primary {
    background: var(--gradient-primary);
    color: #ffffff;
    border-color: transparent;
}
.upgrade-btn--primary:hover { filter: brightness(1.07); }
.upgrade-btn--primary:disabled { opacity: 0.55; cursor: progress; }

/* Dashboard-card "Install Update" button - top-right of Pentest
 * Environment card header (enterprise: update affordance beside status,
 * env details stay visible). Yellow warning theme matches the page
 * banner. Hidden by default; tenant-upgrade.js shows it when
 * /api/upgrade/status reports update_available=true. */
.dashboard-upgrade-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--warning);
    color: #ffffff;
    border: 0;
    border-radius: 9999px;
    padding: 0.5rem 1.05rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
    transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.dashboard-upgrade-btn[hidden] { display: none; }
.dashboard-upgrade-btn:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.5);
}
.dashboard-upgrade-btn:active { transform: translateY(0); }
.dashboard-upgrade-btn i { font-size: 0.95rem; }
.dashboard-upgrade-btn__tag {
    font-size: max(0.7rem, var(--fit-text-min, 0px));
    opacity: 0.92;
    background: rgba(255, 255, 255, 0.22);
    padding: 0.1rem 0.5rem;
    border-radius: 9999px;
    font-family: var(--font-mono);
    font-weight: 500;
}
.dashboard-upgrade-btn__tag:empty { display: none; }
html.dark .dashboard-upgrade-btn {
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.28);
}
html.dark .dashboard-upgrade-btn:hover {
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.45);
}

.env-card-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.dashboard-upgrade-btn--header {
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.3);
}
.dashboard-upgrade-btn--header i { font-size: 0.85rem; }
.dashboard-upgrade-btn--header .dashboard-upgrade-btn__tag {
    font-size: max(0.65rem, var(--fit-text-min, 0px));
    padding: 0.05rem 0.4rem;
}

/* Pending-state badge - shown on the BANNER when a deferred
 * upgrade has been queued. Replaces the "Install update" button
 * with a "Scheduled: applies after scans finish" pill. */
.upgrade-banner--pending {
    background: linear-gradient(135deg, #0EA5E9 0%, #0F2B5B 100%);
}
.upgrade-banner__pending-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: auto;
}
.upgrade-banner__pending-pill i { font-size: 0.8rem; }

/* Installing overlay - full-screen, shown after promote click while the
 * portal pod is being replaced. */
.upgrade-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f1f5f9;
}
.upgrade-overlay[hidden] { display: none; }
.upgrade-overlay__panel { text-align: center; max-width: 440px; padding: 2.25rem 2rem; }
.upgrade-overlay__panel h2 { margin: 1rem 0 0.5rem; font-size: 1.15rem; font-weight: 700; color: #ffffff; }
.upgrade-overlay__panel p { color: #cbd5e1; font-size: 0.9rem; margin: 0; line-height: 1.5; }
.upgrade-overlay__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--secondary, #00B4D8);
    border-radius: 50%;
    margin: 0 auto;
    animation: upgrade-spin 0.9s linear infinite;
}
@keyframes upgrade-spin { to { transform: rotate(360deg); } }

/* Live canary progress - populated by renderOverlayProgress(). Shows
 * a thin animated progress bar + step text + ETA. Theme-aware: the
 * overlay backdrop is always dark (it's a modal), so the bar itself
 * uses cyan accent. */
.upgrade-overlay__progress {
    margin-top: 1.5rem;
    text-align: left;
}
.upgrade-overlay__progress-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 9999px;
    overflow: hidden;
}
.upgrade-overlay__progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--secondary, #00B4D8), var(--primary-light, #3d83f6));
    transition: width 0.6s ease;
    border-radius: 9999px;
}
.upgrade-overlay__progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.55rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-mono, monospace);
}

/* Secondary breakdown row - shown only when BOTH rollouts are
 * actively progressing (rare). Each row labels its component and
 * shows the step text. */
.upgrade-overlay__breakdown {
    margin-top: 1.25rem;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    text-align: left;
}
.upgrade-overlay__breakdown[hidden] { display: none; }
.upgrade-overlay__breakdown-row {
    display: flex;
    justify-content: space-between;
    gap: 0.85rem;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.75);
    padding: 0.2rem 0;
}
.upgrade-overlay__breakdown-row + .upgrade-overlay__breakdown-row {
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    margin-top: 0.3rem;
    padding-top: 0.45rem;
}
.upgrade-overlay__breakdown-label {
    flex-shrink: 0;
    font-family: var(--font-mono, monospace);
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.02em;
}
.upgrade-overlay__breakdown-status {
    text-align: right;
    flex: 1;
    min-width: 0;
}

/* Shown only after Argo reports fully_updated (all pods on new version). */
.upgrade-complete-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
}
.upgrade-complete-modal[hidden] { display: none; }
.upgrade-complete-modal__panel {
    max-width: 440px;
    width: 100%;
    padding: 1.75rem 1.5rem;
    text-align: center;
    border-radius: 12px;
    background: var(--bg-elevated, #ffffff);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.3));
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}
.upgrade-complete-modal__icon {
    font-size: 2rem;
    color: var(--success, #16a34a);
    margin-bottom: 0.5rem;
}
.upgrade-complete-modal__panel h2 {
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
    color: var(--text-primary, #0f172a);
}
.upgrade-complete-modal__body {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary, #64748b);
}
.upgrade-complete-modal__tags {
    margin: 0 0 1.25rem;
    font-size: 0.78rem;
    font-family: var(--font-mono, ui-monospace, monospace);
    color: var(--text-muted, #94a3b8);
}
.upgrade-complete-modal__tags[hidden] { display: none; }

/* ===========================================================
 * Dashboard "Upgrading…" panel
 *
 * Rendered by dashboard.js#showUpgrading when /api/upgrade/status
 * reports an in-flight canary. Sits in the Pentest Environment card
 * (which is a normal app card, not a dark modal), so all colours
 * derive from CSS custom properties so the panel reads correctly in
 * both light and dark themes.
 * =========================================================== */
.dashboard-upgrading {
    padding: 2.5rem 1.75rem 1.75rem;
    text-align: center;
}
/* Compact ribbon under Running details - does not replace the env card. */
.dashboard-upgrading--ribbon {
    padding: 1rem 1.5rem 1.25rem;
    text-align: left;
    border-top: 1px solid var(--border, #e5e7eb);
    background: var(--bg-elevated, #f8fafc);
}
html.dark .dashboard-upgrading--ribbon {
    background: rgba(255, 255, 255, 0.03);
}
.dashboard-upgrading--ribbon .dashboard-upgrading__head {
    margin-bottom: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}
.dashboard-upgrading--ribbon .dashboard-upgrading__icon {
    width: 40px;
    height: 40px;
    margin: 0;
    flex-shrink: 0;
    animation: none;
}
.dashboard-upgrading--ribbon .dashboard-upgrading__title {
    font-size: 0.95rem;
    margin: 0;
    flex: 1 1 auto;
}
.dashboard-upgrading--ribbon .dashboard-upgrading__subtitle {
    flex: 1 1 100%;
    font-size: 0.82rem;
    margin: 0;
}
.dashboard-upgrading__head {
    margin-bottom: 1.75rem;
}
.dashboard-upgrading__icon {
    /* v3.5.82: enlarged 56 -> 112px so the brand mark reads clearly during a
     * rollout (operator feedback: "rollout logo not visible"). The element
     * carries inline background:none, so the mark sits directly on the card --
     * the theme-aware light/dark PNG keeps it readable in both modes. */
    width: 112px;
    height: 112px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Scale-only pulse for "activity" -- NO opacity dip, so the mark never
     * fades out and stays fully visible. */
    animation: dashboardUpgradingPulse 2.4s ease-in-out infinite;
}
@keyframes dashboardUpgradingPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}
.dashboard-upgrading__title {
    margin: 0 0 0.4rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.dashboard-upgrading__subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.dashboard-upgrading__progress {
    max-width: 460px;
    margin: 0 auto;
    text-align: left;
}
.dashboard-upgrading__progress-track {
    height: 6px;
    background: var(--glass-bg, rgba(0, 0, 0, 0.08));
    border: 1px solid var(--glass-border, rgba(0, 0, 0, 0.08));
    border-radius: 9999px;
    overflow: hidden;
}
.dashboard-upgrading__progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--secondary, #00B4D8), var(--primary-light, #3d83f6));
    border-radius: 9999px;
    transition: width 0.6s ease;
}
.dashboard-upgrading__progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.55rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono, monospace);
}
.dashboard-upgrading__stuck {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    max-width: 460px;
    margin: 1.25rem auto 0;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: left;
    line-height: 1.45;
}
.dashboard-upgrading__stuck[hidden] {
    display: none;
}
.dashboard-upgrading__stuck > i {
    color: var(--warning, #f59e0b);
    font-size: 1rem;
    margin-top: 0.15rem;
}
.dashboard-upgrading__stuck-detail {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.dashboard-upgrading__approve {
    margin: 1.25rem auto 0;
    max-width: 460px;
    text-align: center;
}
.dashboard-upgrading__approve[hidden] {
    display: none;
}
.dashboard-upgrading__approve-hint {
    margin: 0.5rem 0 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ==================================================================
   v3.5.25 - Shared verdict card. Originally lived in
   templates/history/ai_operator.html as .aiop-verdict-card; lifted
   here so Strategy Engine + AI Remediation use the same component.
   The classes intentionally drop the page-specific prefix and live
   under .verdict-card / .confidence-ring so any feature can opt in.

   Layout: a 96px conic-gradient confidence ring on the left + a
   verdict body (chip + headline + sub-line) on the right. Optional
   "hint" line below the body. Sized to span the full content width
   of any host page; consumers wrap in their own container if needed.

   State is data-driven via the renderVerdictCard(state) helper in
   /static/js/verdict-card.js; this stylesheet only owns the look.
   ================================================================== */
.verdict-card {
    display: flex; align-items: center; gap: 1.25rem; padding: 1.25rem;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    margin-bottom: 1rem;
    animation: verdict-card-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes verdict-card-in {
    from { opacity: 0; transform: translateY(6px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.confidence-ring {
    --ring-pct: 50;
    --ring-color: var(--secondary);
    position: relative; flex-shrink: 0;
    width: 96px; height: 96px; border-radius: 50%;
    background: conic-gradient(var(--ring-color) calc(var(--ring-pct) * 1%), rgba(15,43,91,0.08) 0);
    display: flex; align-items: center; justify-content: center;
    animation: confidence-ring-spin 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.confidence-ring::after {
    content: ''; position: absolute; inset: 8px; border-radius: 50%;
    background: var(--bg-elevated, #fff);
}
html.dark .confidence-ring::after { background: var(--bg-base); }
.confidence-ring .ring-label { position: relative; z-index: 1; text-align: center; }
.confidence-ring .ring-pct {
    font-size: 1.4rem; font-weight: 800; color: var(--text-primary);
    line-height: 1; font-family: var(--font-mono);
}
.confidence-ring .ring-sub {
    font-size: max(0.6rem, var(--fit-text-min, 0px)); color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
    margin-top: 0.2rem;
}
/* A count ratio is wider than a percentage and must not be clipped by the
   96px ring: "12/40" is five characters where "87%" is three. The ring is a
   fixed circle, so the type gives way rather than the circle. */
.confidence-ring .ring-pct.ring-ratio { font-size: 1.15rem; letter-spacing: -0.5px; }
/* No ring is drawn when there is no number for it, and the body then has the
   card to itself rather than sitting against a 96px gap where a circle was. */
.verdict-card--no-ring { gap: 0; }
@keyframes confidence-ring-spin {
    from { --ring-pct: 0; }
    to   { --ring-pct: var(--ring-target, 50); }
}
@property --ring-pct {
    syntax: '<number>';
    initial-value: 0;
    inherits: false;
}

.verdict-body { flex: 1; min-width: 0; }
.verdict-chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.3rem 0.7rem; border-radius: 999px;
    font-size: max(0.7rem, var(--fit-text-min, 0px)); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.6px;
    margin-bottom: 0.45rem;
}
.verdict-chip.success { background: rgba(16,185,129,0.12); color: var(--success); border: 1px solid rgba(16,185,129,0.35); }
.verdict-chip.warning { background: rgba(245,158,11,0.12); color: var(--warning); border: 1px solid rgba(245,158,11,0.35); }
.verdict-chip.danger  { background: rgba(239,68,68,0.12);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.35); }
.verdict-chip.info    { background: rgba(59,130,246,0.12); color: var(--info);    border: 1px solid rgba(59,130,246,0.35); }

.verdict-headline {
    font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.25rem;
}
.verdict-sub { font-size: 0.82rem; color: var(--text-secondary); }
.verdict-hint {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.82rem; line-height: 1.55; color: var(--text-primary);
}
.verdict-hint i { color: var(--warning); margin-right: 0.4rem; }
.verdict-meta {
    font-size: max(0.72rem, var(--fit-text-min, 0px)); color: var(--text-muted);
    margin-top: 0.4rem; font-family: var(--font-mono);
}

@media (prefers-reduced-motion: reduce) {
    .verdict-card, .confidence-ring { animation: none !important; }
}

/* ========================================
   Safety-badge tier consistency (shared 4-tier language)
   Base .safety-badge / .safety-badge-sm rules + their safe / moderate /
   aggressive variants are defined alongside the normal exploitation flow.
   The 'critical' variant below completes the four-tier scale
   (safe / moderate / aggressive / critical) so both flows share one
   visual language. Existing variants are intentionally left untouched.
   ======================================== */
.safety-badge.critical { background: rgba(220, 38, 38, 0.12); color: var(--critical); }
.safety-badge-sm.critical { background: rgba(220, 38, 38, 0.15); color: var(--critical); }

/* ========================================
   Global keyboard focus ring (:focus-visible only - never on mouse click).
   Gives keyboard users a consistent, subtle accessible focus outline across
   interactive elements without affecting pointer interactions.
   ======================================== */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
    border-radius: var(--radius-sm, 4px);
}


/* ── Evidence state: one component, four products ──────────────────────
   SEVERITY OWNS COLOUR, so state must not. State is carried by GLYPH,
   LABEL and POSITION. Colour here is a muted tint only, and removing every
   colour rule below leaves the component fully readable - which is the
   greyscale test, because reports get printed.

   The glyphs differ in SHAPE at a 1px stroke: filled, hollow, dot, slashed,
   dash. That is what survives a monochrome printer. */
.es-row { display: inline-flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* State LEADS. Fixed width so a scan down a list sorts by state without
   reading, and severity follows in its own column. */
.es-badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    min-width: 7.5rem; flex-shrink: 0;
    font-size: max(0.72rem, var(--fit-text-min, 0px)); font-weight: 700; letter-spacing: 0.03em;
}
.es-glyph { font-size: 0.95rem; line-height: 1; width: 1rem; text-align: center; }
.es-label { white-space: nowrap; }

.es-proven   { color: var(--critical, #ef4444); }
.es-stands   { color: var(--text-secondary, #64748b); }
.es-untested { color: var(--text-muted, #94a3b8); }
.es-refused  { color: var(--warning, #f59e0b); }
.es-norecord { color: var(--text-muted, #94a3b8); }

/* The two ages, always both, always separate. A proof is not a detection. */
.es-age { display: inline-flex; gap: 0.25rem; font-size: max(0.7rem, var(--fit-text-min, 0px)); white-space: nowrap; }
.es-age-k { color: var(--text-muted, #94a3b8); }
.es-age-v { color: var(--text-secondary, #64748b); font-variant-numeric: tabular-nums; }
/* Unknown renders as unknown. Dotted underline marks it as carrying a
   tooltip that says what would make it known - never a 0 standing in. */
.es-age-unknown .es-age-v { border-bottom: 1px dotted currentColor; cursor: help; }

/* The artefact, ONE CLICK from the claim. A link, not a modal trigger. */
.es-artifact {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font-size: max(0.7rem, var(--fit-text-min, 0px)); text-decoration: none;
    color: var(--primary-light, #00b4d8);
}
.es-artifact:hover { text-decoration: underline; }
.es-ev-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
/* The fingerprint is what makes the citation checkable rather than an
   identifier. Truncated for width; the full value is the title attribute. */
.es-hash {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-muted, #94a3b8); cursor: help;
}

.es-panel { display: flex; flex-direction: column; gap: 0.5rem; }
.es-panel-head { display: flex; align-items: center; gap: 0.5rem; }
.es-line { margin: 0; font-size: 0.8rem; line-height: 1.45; color: var(--text-secondary, #64748b); }
.es-remedy { display: block; margin-top: 0.25rem; color: var(--primary-light, #00b4d8); }
.es-ages { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.es-proof { margin-top: 0.15rem; }
.es-noproof { margin: 0; font-size: max(0.7rem, var(--fit-text-min, 0px)); color: var(--text-muted, #94a3b8); }

/* Correct at 1440, fluid to 3840: the component never sets a width of its
   own, so it inherits the host column and wraps rather than overflowing. */
@media (max-width: 900px) {
    .es-badge { min-width: 0; }
    .es-row { gap: 0.5rem; }
}

/* ------------------------------------------------------------------
   THE HOST ROW - the Strategy Engine's unit.

   THE GREYSCALE TEST: delete every colour declaration in this block and the
   row still says which of the four states it is, because the state is carried
   by GLYPH, by LABEL and by POSITION - always the leading column. Severity owns
   colour, so state cannot; and reports get printed.

   A FIXED ROW HEIGHT is load-bearing rather than cosmetic. The list is
   virtualised, so the scroller has to know where row N sits without measuring
   it, and a row whose height depends on how much text it happens to carry
   makes that impossible. Two lines, always: the facts on the first, the one
   sentence of what was established on the second.
   ------------------------------------------------------------------ */
:root { --es-host-row-h: 4.5rem; }

.es-host {
    display: grid;
    grid-template-columns:
        minmax(8.5rem, max-content)   /* state: FIRST, always */
        minmax(9rem, 14rem)           /* host */
        minmax(11rem, 1fr)            /* counts by state */
        minmax(13.5rem, max-content)  /* severity: bar + callout */
        minmax(6.5rem, max-content)   /* freshness */
        minmax(4.5rem, max-content);  /* location */
    align-items: center;
    column-gap: 1rem;
    row-gap: 0.15rem;
    width: 100%;
    min-height: var(--es-host-row-h);
    padding: 0.55rem 0.9rem;
    box-sizing: border-box;
}
.es-host-name {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    color: var(--text-primary, #0f172a);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.es-host-counts { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: max(0.72rem, var(--fit-text-min, 0px)); }
.es-count { color: var(--text-secondary, #475569); white-space: nowrap; }
.es-count b { font-variant-numeric: tabular-nums; color: var(--text-primary, #0f172a); }
.es-count-sep { color: var(--text-muted, #94a3b8); opacity: 0.6; }
/* The absence reads as an absence even before the words are read. */
.es-count-predates { font-style: italic; }

.es-fresh { font-size: max(0.72rem, var(--fit-text-min, 0px)); white-space: nowrap; color: var(--text-secondary, #475569); }
/* NEVER TESTED IS NOT STALE, and it is not a missing value either: it is a
   fact, so it is written as words rather than as a dash. */
.es-fresh-never { font-style: italic; border-bottom: 1px dotted currentColor; cursor: help; }

.es-loc {
    font-size: max(0.65rem, var(--fit-text-min, 0px));
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 1px 0.45rem;
    border-radius: 10px;
    border: 1px solid currentColor;
    white-space: nowrap;
    color: var(--text-secondary, #475569);
}
.es-loc-external { color: var(--warning, #f59e0b); }
.es-loc-internal { color: var(--success, #10b981); }
/* An unknown is dotted, not coloured, and it carries its hint on hover. */
.es-loc-unknown { color: var(--text-muted, #94a3b8); border-style: dotted; cursor: help; }

.es-host-line {
    grid-column: 1 / -1;
    font-size: max(0.74rem, var(--fit-text-min, 0px));
    line-height: 1.35;
    color: var(--text-secondary, #475569);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* At 1440 every column still has room. Below about 1100 the freshness and
   location wrap under rather than squeezing the host address to nothing -
   the address is the row's identity and must never be the thing that
   truncates first. */
/* THE OVERRIDE HAS TO LAND WHERE THE VIRTUALISER READS IT.
   It set --es-host-row-h on `.es-host`, which is a DESCENDANT of the mount
   element. host-list.js reads the property off the mount element itself
   (`getComputedStyle(root).getPropertyValue('--es-host-row-h')`), and a custom
   property set on a child does not inherit upwards - so below 1100px the CSS
   painted 6.5rem rows while the virtualiser laid them out 4.5rem apart, and
   every row overlapped the one above it by two thirds of a line. Declared on
   the list container, which IS the element the JS measures, so one value
   drives both. */
@media (max-width: 1100px) {
    /* 8.75rem = 140px, which is what the stacked content MEASURES at this
       width (severity, counts, freshness and location each take a full row
       under the state and host). Not a guess: the geometry probe compares
       painted height against the offset step at 1440/1920/2560/3840 and
       here, and a value that is short shows up as an overlap immediately. */
    .es-hostlist, #hostList { --es-host-row-h: 8.75rem; }
    .es-host {
        grid-template-columns: minmax(8.5rem, max-content) minmax(9rem, 1fr);
    }
    .es-host-counts, .es-sev, .es-fresh, .es-loc { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------------
   PER-HOST SEVERITY. Three carriers, and only one of them is colour.

     the edge     3px down the row, critical or high or neither. The scan
                  aid: an eye runs down the column and stops on red.
     the bar      what this host's findings are MADE OF, in fixed band
                  order so it reads with no colour at all.
     the callout  the numbers, in text. This is the one that survives a
                  greyscale print, a colour-blind reader and a screenshot.

   NEVER COLOUR ALONE is the rule the glyph column above already follows,
   and it is why the callout is text rather than a tooltip.
   ------------------------------------------------------------------ */
.es-hostrow[data-severity="critical"] { box-shadow: inset 3px 0 0 0 var(--sev-stroke-critical); }
.es-hostrow[data-severity="high"]     { box-shadow: inset 3px 0 0 0 var(--sev-stroke-high); }
.es-hostrow[data-severity="none"]     { box-shadow: inset 3px 0 0 0 var(--es-sev-edge-none); }

.es-sev { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.es-sev-bar {
    display: flex;
    width: 132px;
    height: 9px;
    border-radius: 5px;
    overflow: hidden;
    flex: 0 0 auto;
    background: var(--es-sev-track);
    box-shadow: var(--es-sev-track-inset);
}
/* flex-grow carries the proportion, so the widths are the counts and nothing
   computes a percentage. A band with no findings emits no element at all --
   see renderHostSeverity -- so there is no zero-width sliver to guard here. */
.es-sev-seg { height: 100%; min-width: 3px; flex-shrink: 1; }
.es-sev-critical { background: var(--critical); }
.es-sev-high     { background: var(--high); }
.es-sev-medium   { background: var(--medium); }
.es-sev-low      { background: var(--low); }
.es-sev-info     { background: var(--informational); }

.es-sev-callout {
    font-size: max(0.72rem, var(--fit-text-min, 0px));
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.es-sev-callout b { color: var(--text-primary); font-weight: 700; }
.es-sev-dot { margin: 0 0.3rem; color: var(--text-muted); }
/* The worst band's count takes that band's STROKE variant, not the ramp: this
   is text on the page background, which is the case the stroke tokens exist
   for. --medium on #F0F4F8 is about 1.9:1 and unreadable as type. */
.es-sev-worst { font-weight: 600; }
.es-sev-worst-critical { color: var(--sev-stroke-critical); }
.es-sev-worst-high     { color: var(--sev-stroke-high); }
.es-sev-worst-medium   { color: var(--sev-stroke-medium); }
.es-sev-worst-low      { color: var(--sev-stroke-low); }
.es-sev-worst-info     { color: var(--sev-stroke-info); }

@media (prefers-contrast: more) {
    .es-sev-bar { box-shadow: none; outline: 1px solid var(--text-muted); }
}

/* The list itself. Fluid to any width; the rows stretch rather than centring
   in a fixed column, because at 3840 a 900px column of rows with an ocean
   either side is not a use of the screen. */
.es-hostlist { position: relative; width: 100%; }
.es-hostlist-viewport { overflow-y: auto; overflow-x: hidden; position: relative; }
.es-hostlist-spacer { position: relative; width: 100%; }
.es-hostrow {
    position: absolute;
    left: 0;
    right: 0;
    cursor: pointer;
    background: transparent;
}
/* THE SEPARATOR TAKES NO LAYOUT. It was `border-bottom: 1px`, and a row with
   no height of its own is content-height plus that border: [MEASURED
   2026-09-16] every row painted 73px while the virtualiser stepped its offsets
   72px, from --es-host-row-h. One pixel of overlap per row, invisible until the
   severity edge started running the full height of the row and drew a seam at
   every boundary. An absolutely positioned rule is outside flow, so the painted
   height is exactly the height the offsets assume. */
.es-hostrow::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--glass-border-subtle);
}
/* THE ROW RESPONDS: a step lighter and a brighter rule under it. Background
   and border only -- the severity edge above is a box-shadow on the same
   element at the same specificity, and setting box-shadow here would win on
   source order and erase it.

   Hover and expanded were the same computed colour: both read --glass-hover
   and differed only in a hex FALLBACK that never fires, because the token is
   always defined. Expanded now has its own value, so opening a row is visible
   after the pointer leaves it. */
.es-hostrow:hover { background: var(--glass-hover); }
.es-hostrow:hover::after { background: var(--glass-border); }
.es-hostrow[aria-expanded="true"] { background: var(--bg-card-hover); }
.es-hostrow[aria-expanded="true"]::after { background: var(--glass-border); }
.es-hostrow-body { padding: 0 0.9rem 0.9rem 0.9rem; }

/* THE SKELETON. A shape that says how many rows are coming and what shape they
   are beats a spinner that says nothing, and it beats a zero outright: a zero
   is an answer and we do not have one yet. */
.es-skel-row { min-height: var(--es-host-row-h); padding: 0.55rem 0.9rem; display: grid; gap: 0.4rem; align-content: center; }
.es-skel-bar {
    height: 0.62rem;
    border-radius: 3px;
    background: var(--glass-border, rgba(15, 23, 42, 0.08));
    animation: es-skel-pulse 1.6s ease-in-out infinite;
}
@keyframes es-skel-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.85; } }
@media (prefers-reduced-motion: reduce) {
    .es-skel-bar { animation: none; opacity: 0.6; }
}

.es-problem { padding: 2rem 1rem; text-align: center; }
.es-problem-h { font-weight: 600; margin-bottom: 0.35rem; }
.es-problem-d { font-size: 0.8rem; color: var(--text-secondary, #475569); max-width: 46ch; margin: 0 auto; }

/* The AI Operator picker tile leads with the state, the same way the host row
   does. Sized down because a tile is denser than a row, and the glyph carries
   the state at this size too - that is why it was chosen for shape rather than
   for colour. */
.fp-state { margin-bottom: 0.25rem; }
.fp-state .es-badge { font-size: max(0.62rem, var(--fit-text-min, 0px)); }
.fp-state .es-glyph { font-size: 0.8rem; width: 0.85rem; }
.fp-state .es-age { font-size: max(0.62rem, var(--fit-text-min, 0px)); }

/* ------------------------------------------------------------------
   FLOATING RUN WINDOWS AND THE DOCK.

   Fixed rather than absolute: a window follows the viewport, because the
   operator is triaging the host list underneath it and scrolling that list
   must not carry the window away.

   No gradients and no drop shadow beyond the one that separates a floating
   surface from the page - a window that is decorated competes with the run it
   is showing.
   ------------------------------------------------------------------ */
.run-win {
    position: fixed;
    width: 420px;
    min-width: 380px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
    /* A FLOATING WINDOW MUST READ AS A LAYER, NOT A PANE.
       This was --glass-bg-strong with backdrop-filter: blur(12px). Seen on the
       live page over the severity legend, the legend showed through and the
       two surfaces merged: the window looked like part of the page rather than
       something above it. The z-index band was never the problem (1400, above
       panel at 1000) - the SURFACE was.
       Opaque ground, a real elevation shadow, and a hairline ring so the edge
       is visible against a card of the same colour. */
    /* --bg-card is itself translucent (0.8 alpha), so naming it alone leaves the
       page showing through and the window still reads as a pane. Compositing it
       over --bg-base makes the result opaque while keeping the card's tint and
       both themes. Measured: without this the computed background stayed
       rgba(255,255,255,0.8) and the severity legend was visible underneath. */
    background: linear-gradient(var(--bg-card), var(--bg-card)), var(--bg-base);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        0 12px 28px rgba(15, 23, 42, 0.18),
        0 32px 64px rgba(15, 23, 42, 0.22);
    z-index: var(--z-run-window);
    overflow: hidden;
}
.run-win.expanded { width: 720px; max-height: calc(100vh - 80px); }
.run-win.dragging { user-select: none; cursor: grabbing; }

.run-win-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--glass-border-subtle);
    cursor: grab;
    touch-action: none;
}
.run-win.dragging .run-win-head { cursor: grabbing; }
.run-win-target { font-size: 0.8rem; color: var(--text-primary); font-weight: 600; }
.run-win-cap { font-size: max(0.72rem, var(--fit-text-min, 0px)); color: var(--text-secondary); }
.run-win-lane { font-size: max(0.68rem, var(--fit-text-min, 0px)); color: var(--text-muted); }
.run-win-clock { margin-left: auto; font-size: max(0.72rem, var(--fit-text-min, 0px)); color: var(--text-secondary); }
.run-win-controls { display: flex; gap: 0.15rem; }
.run-win-btn {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
}
.run-win-btn:hover { background: var(--glass-hover); color: var(--text-primary); }
.run-win-status {
    padding: 0.3rem 0.7rem;
    font-size: max(0.66rem, var(--fit-text-min, 0px));
    letter-spacing: 0.6px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--glass-border-subtle);
}
.run-win-body { padding: 0.7rem; overflow-y: auto; flex: 1 1 auto; }

/* THE DOT CARRIES THE STATE AND IS NEVER THE ONLY THING THAT DOES. The word
   sits beside it in .run-win-status and in the dock item, because the five
   states have to survive a greyscale print and a colour-blind reader. */
.run-dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex: 0 0 auto;
    background: var(--text-muted);
    display: inline-block;
}
.run-dot-running, .run-dot-connecting { background: var(--info); }
.run-dot-reconnecting { background: var(--warning); }
.run-dot-succeeded { background: var(--success); }
.run-dot-failed, .run-dot-cancelled { background: var(--danger); }
.run-dot-blocked { background: var(--warning); }
.run-dot-notlistening { background: var(--text-muted); }
.run-status-reconnecting { color: var(--warning); }
.run-status-notlistening { color: var(--text-muted); }
.run-status-succeeded { color: var(--success); }
.run-status-failed, .run-status-cancelled { color: var(--danger); }

/* The dock sits BELOW the windows it belongs to and above the page they float
   over - see the --z-* scale at the top of this file. */
.run-dock {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: var(--z-run-dock);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--glass-bg-strong);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.run-dock-items { display: flex; gap: 0.4rem; overflow-x: auto; flex: 1 1 auto; }
.run-dock-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: var(--bg-card);
    cursor: pointer;
    font-size: max(0.72rem, var(--fit-text-min, 0px));
    color: var(--text-primary);
    white-space: nowrap;
}
.run-dock-item:hover { background: var(--bg-card-hover); }
.run-dock-target { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.run-dock-right { color: var(--text-secondary); font-size: max(0.68rem, var(--fit-text-min, 0px)); }
.run-dock-count { color: var(--text-secondary); font-size: max(0.7rem, var(--fit-text-min, 0px)); white-space: nowrap; }

@media (max-width: 700px) {
    .run-win { width: calc(100vw - 16px); left: 8px !important; right: 8px; }
    .run-win.expanded { width: calc(100vw - 16px); }
}
@media (prefers-reduced-motion: reduce) {
    .run-win { transition: none !important; }
}

/* ------------------------------------------------- run window body */
/* The window IS the run view. Everything here reads the same RunState record
   the page reads: a second rendering, never a second source. */

.run-win-body { overflow-y: auto; padding: 0 0 0.5rem; }

/* A FLOW, NOT THREE STACKED BOXES.
   Seen live in a 420px window: three cells at min-width 7rem plus two
   connectors is ~376px before borders, so flex-wrap stacked them - and the
   connectors are HORIZONTAL 1px lines, which are invisible once wrapped. The
   result read as a list, and the question it drew was "where is the flow
   chart".
   In the window the flow is explicitly VERTICAL, with connectors that run the
   right way. The page keeps the horizontal arrangement it has room for. */
/* renderOutcome appends the cells DIRECTLY to whatever container it is given.
   On the page that container carries .exr-outcome and picks up the horizontal
   flex rules; in the window it is .run-win-flow, which had no such class - so a
   `.run-win-flow .exr-outcome` rule matched nothing. The cells stacked anyway,
   by ordinary block layout, and the connectors were empty inline spans that a
   height cannot apply to: measured 0x0. The flow looked like a list because it
   WAS one. So the container itself is the column flow here. */
.run-win-flow { padding: 0.625rem 0.75rem 0; display: flex; flex-direction: column; }
.run-win-flow > .exr-out { width: 100%; min-width: 0; flex: 0 0 auto; }
.run-win-flow > .exr-out-link {
    display: block; width: 1px; height: 0.75rem; flex: 0 0 0.75rem;
    align-self: flex-start; margin-left: 1.05rem;
    background: var(--glass-border, rgba(255, 255, 255, 0.24));
}

/* Stage bar. A segment is done only when the record says so; nothing infers
   progress from elapsed time or from the segment after it. */
.run-win-stages {
    display: flex; gap: 0.25rem; align-items: center;
    padding: 0.625rem 0.75rem; flex-wrap: wrap;
}
.run-win-stage { display: flex; align-items: center; gap: 0.3rem; flex: 1 1 auto; min-width: 0; }
.run-win-stage-dot {
    width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto;
    background: var(--border);
}
.run-win-stage-name {
    font-size: max(0.5625rem, var(--fit-text-min, 0px)); text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.run-win-stage[data-state="done"] .run-win-stage-dot { background: var(--success, #16a34a); }
.run-win-stage[data-state="done"] .run-win-stage-name { color: var(--text-secondary); }
.run-win-stage[data-state="current"] .run-win-stage-dot {
    background: var(--primary-light, #3b6bb5);
    box-shadow: 0 0 0 3px rgba(59, 107, 181, 0.18);
}
.run-win-stage[data-state="current"] .run-win-stage-name { color: var(--text-primary); font-weight: 600; }

/* Activity log: expanded while live, collapsed when terminal. Collapsed,
   never emptied - what a finished run did is why anyone opens it. */
.run-win-log { border-top: 1px solid var(--glass-border-subtle, rgba(0,0,0,0.05)); margin-top: 0.25rem; }
.run-win-log-head {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    font-size: max(0.5625rem, var(--fit-text-min, 0px)); font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
}
.run-win-log-count {
    font-size: max(0.5625rem, var(--fit-text-min, 0px)); padding: 0 5px; border-radius: 999px;
    background: var(--glass-hover, rgba(0,0,0,0.05)); color: var(--text-secondary);
}
.run-win-log[data-open="false"] .run-win-log-body { display: none; }
.run-win-log-body {
    max-height: 190px; overflow-y: auto; padding: 0 0.75rem 0.5rem;
    font-family: var(--font-mono, monospace); font-size: max(0.625rem, var(--fit-text-min, 0px)); line-height: 1.65;
}
.run-win-log-line { display: flex; gap: 0.5rem; color: var(--text-secondary); }
.run-win-log-ts { color: var(--text-muted); flex: 0 0 auto; }
.run-win-log-text { word-break: break-word; }
/* One log, two speakers. The gutter rule is a SHAPE, so it survives greyscale. */
.run-win-log-line[data-source="dispatcher"] {
    border-left: 2px solid var(--exr-log-dispatcher, rgba(100,116,139,0.55));
    margin-left: -0.75rem; padding-left: calc(0.75rem - 2px);
    color: var(--text-primary);
}
.run-win-empty { color: var(--text-muted); font-style: italic; }

.run-win-actions {
    display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
    padding: 0.5rem 0.75rem 0; border-top: 1px solid var(--glass-border-subtle, rgba(0,0,0,0.05));
}
.run-win-act {
    font-size: max(0.6875rem, var(--fit-text-min, 0px)); padding: 0.25rem 0.5rem; border-radius: var(--radius-md, 6px);
    border: 1px solid var(--glass-border); background: transparent;
    color: var(--text-secondary); cursor: pointer;
}
.run-win-act:hover:not([disabled]) { background: var(--glass-hover, rgba(0,0,0,0.04)); }
.run-win-act[disabled] { opacity: 0.45; cursor: default; }
.run-win-act[data-state="unknown"] { border-style: dashed; cursor: default; font-style: italic; }
.run-win-danger { color: var(--danger, #dc2626); border-color: currentColor; }
.run-win-count { font-weight: 700; color: var(--text-primary); }
.run-win-runid { margin-left: auto; font-size: max(0.625rem, var(--fit-text-min, 0px)); color: var(--text-muted); }

html.dark .run-win {
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.4),
        0 12px 28px rgba(0, 0, 0, 0.5),
        0 32px 64px rgba(0, 0, 0, 0.55);
}

.report-multiselect {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color, #d8dee6);
    border-radius: 6px;
    background: var(--surface, #fff);
}

.report-multiselect-option {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-weight: 400;
    cursor: pointer;
    white-space: nowrap;
}

.report-multiselect-option input {
    margin: 0;
    cursor: pointer;
}

/* sidebar-component:begin Floating sidebar card, promo, Support, theme switch, icon rail */
:root {
    --sb-inset: 0.75rem;
    --sb-radius: var(--radius-xl);
    --sb-item-radius: var(--radius-md);
    --sb-gap: 0.5rem;
    --sb-width: 12.5rem;
    --sb-width-collapsed: 4.5rem;
    --sb-toggle-size: 1.5rem;
    --sb-go-size: 1.625rem;
    --sb-tile: 1.5rem;
    --sb-art-w: 6rem;
    --sb-art-w-rail: 2.75rem;
    --sb-mark-size: 2rem;
    --sb-ring-w: 2px;
    --sb-motion: 0.25s;
    --tb-inset: var(--sb-inset);
    --tb-radius: var(--sb-radius);
    --sb-accent: var(--secondary);
    --sb-link: var(--primary);
    --sb-shadow: var(--shadow-lg);
    --sb-tint: var(--bg-card-hover);
    --sb-tint-strong: var(--bg-card-hover);
    --sb-edge: var(--border);
    --sb-ring: var(--secondary);
    --sb-active-shadow: inset 0 0 0 1px var(--sb-accent);
    --sb-btn-bg: var(--primary);
    --sb-btn-fg: #fff;
    --sb-btn-shadow: var(--shadow-md);
    --sb-icon-tile: var(--bg-card-hover);
}
@supports (color: oklch(from red l c h)) {
    :root { --sb-btn-fg: oklch(from var(--sb-btn-bg) clamp(0, calc((0.62 - l) * 1000), 1) 0 0); }
}
@supports (color: color-mix(in srgb, red, blue)) {
    :root {
        --sb-tint: color-mix(in srgb, var(--sb-accent) 8%, transparent);
        --sb-tint-strong: color-mix(in srgb, var(--sb-accent) 15%, transparent);
        --sb-edge: color-mix(in srgb, var(--sb-accent) 35%, transparent);
        --sb-icon-tile: color-mix(in srgb, var(--sb-accent) 22%, transparent);
    }
}
html.dark {
    --sb-link: var(--secondary);
    --sb-btn-shadow: inset 0 0 0 1px var(--sb-accent);
}
@media (min-width: 1600px) { :root { --sb-width: 13.125rem; } }
@media (min-width: 769px) and (max-width: 1199px) { :root { --sb-width: 11.25rem; } }
@media (min-width: 769px) and (max-width: 991px) { :root { --sb-width: 10rem; } }
html.sb-collapsed { --sb-width: var(--sb-width-collapsed); }

@media (min-width: 769px) {
    html:root .sidebar { top: var(--sb-inset); bottom: var(--sb-inset); left: var(--sb-inset); width: var(--sb-width); border: 1px solid var(--border); border-radius: var(--sb-radius); box-shadow: var(--sb-shadow); overflow: visible; transition: width var(--sb-motion) ease; }
    .main-content { margin-left: calc(var(--sb-width) + 2 * var(--sb-inset)); }
    .sidebar .sidebar-header, .sidebar .sidebar-footer { border: 0; }
    html:root .sidebar .nav-item, html:root .sidebar .nav-item.active { border-left: 0; border-radius: var(--sb-item-radius); }
    html:root .sidebar .nav-item.active { box-shadow: var(--sb-active-shadow); }
    .sidebar .sidebar-header { position: static; }
    .sidebar .sidebar-logo { max-width: none; justify-content: safe center; }
    html:root .sidebar button.sidebar-toggle { top: 1.1rem; right: calc(var(--sb-toggle-size) / -2 - 1px); z-index: 2; }
    html:root .sidebar .nav-item .nav-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: var(--sb-tile); height: var(--sb-tile); border-radius: var(--sb-item-radius); }
    html:root .sidebar .nav-item.active .nav-icon { background: var(--sb-icon-tile); }
    html.sb-collapsed:root .sidebar .nav-item.active .nav-icon { background: none; }
}

.sidebar-header { position: relative; }
.sidebar-logo { max-width: calc(100% - var(--sb-toggle-size) - var(--sb-gap)); }
.sidebar button.sidebar-toggle { position: absolute; top: 0.9rem; right: 0.6rem; width: var(--sb-toggle-size); height: var(--sb-toggle-size); display: flex; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--bg-card); color: var(--text-secondary); font-size: max(0.65rem, var(--fit-text-min, 0px)); cursor: pointer; }
.sidebar button.sidebar-toggle:hover { color: var(--sb-accent); border-color: var(--sb-accent); }
@media (max-width: 768px) { .sidebar button.sidebar-toggle { display: none; } }

.sb-mark { display: none; }
.sb-promo { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: var(--sb-gap); margin-bottom: 0.6rem; padding: 0.75rem; border-radius: var(--radius-lg); background: var(--sb-tint); border: 1px solid var(--sb-edge); font-size: 0.78rem; line-height: 1.35; color: var(--text-secondary); }
.sb-promo strong { color: var(--sb-link); }
.sb-promo-text { grid-column: 1 / -1; }
.sb-art { grid-column: 2; grid-row: 2; justify-self: end; width: var(--sb-art-w); height: auto; }
.sb-art-screen { fill: var(--sb-tint-strong); stroke: var(--sb-accent); stroke-width: 1.5; }
.sb-art-base { fill: var(--text-muted); }
.sb-art-bar { fill: var(--sb-accent); }
.sb-art-coin { fill: var(--sb-tint-strong); stroke: var(--sb-accent); stroke-width: 1.5; }
.sidebar a.sb-promo-go { flex-shrink: 0; width: var(--sb-go-size); height: var(--sb-go-size); border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--sb-btn-bg); color: var(--sb-btn-fg); font-size: max(0.7rem, var(--fit-text-min, 0px)); text-decoration: none; }
.sidebar-toggle:focus-visible, .sb-promo-go:focus-visible, .tb-support:focus-visible { outline: var(--sb-ring-w) solid var(--sb-ring); outline-offset: var(--sb-ring-w); }
@media (max-height: 760px) { .sb-promo { display: none; } }

@media (min-width: 769px) {
    html.sb-collapsed .sidebar-header { display: flex; flex-direction: column; align-items: center; padding: 0.75rem 0; }
    html.sb-collapsed .sidebar button.sidebar-toggle { transform: rotate(180deg); }
    html.sb-collapsed .sidebar-logo h1, html.sb-collapsed .tenant-badge,
    html.sb-collapsed .nav-section-title, html.sb-collapsed .sidebar .nav-item > span:not(.nav-icon),
    html.sb-collapsed .nav-group-toggle, html.sb-collapsed .nav-group-items,
    html.sb-collapsed .user-info, html.sb-collapsed .sidebar-version-badge,
    html.sb-collapsed .sb-promo-text { display: none; }
    html.sb-collapsed .sidebar .sidebar-wordmark { display: none !important; }
    html.sb-collapsed .sb-mark--light { display: block; width: var(--sb-mark-size); height: var(--sb-mark-size); object-fit: contain; }
    html.dark.sb-collapsed .sb-mark--light { display: none; }
    html.dark.sb-collapsed .sb-mark--dark { display: block; width: var(--sb-mark-size); height: var(--sb-mark-size); object-fit: contain; }
    html.sb-collapsed .sidebar .nav-item, html.sb-collapsed .sidebar .nav-group-link { justify-content: center; padding: 0.6rem 0; }
    html.sb-collapsed .user-profile { flex-direction: column; padding: 0.4rem 0; }
    html.sb-collapsed .sb-promo { grid-template-columns: minmax(0, 1fr); justify-items: center; padding: var(--sb-gap) 0.35rem; }
    html.sb-collapsed .sb-art { order: -1; grid-column: 1; grid-row: auto; justify-self: center; width: min(100%, var(--sb-art-w-rail)); }
}
@media (forced-colors: active) {
    html:root .sidebar .nav-item.active { outline: var(--sb-ring-w) solid Highlight; }
}
@media (prefers-reduced-motion: reduce) {
    html:root .sidebar { transition: none; }
}

/* Top header as a floating card, matching the sidebar; Support lives here */
.tb-support { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.45rem 1rem; border-radius: 999px; background: var(--sb-btn-bg); color: var(--sb-btn-fg); font-size: 0.85rem; font-weight: 600; text-decoration: none; white-space: nowrap; box-shadow: var(--sb-btn-shadow); }
.tb-support:hover { filter: brightness(1.08); }
@media (min-width: 769px) {
    html:root .top-header { margin: 0 var(--tb-inset) 0 0; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--tb-radius) var(--tb-radius); box-shadow: var(--sb-shadow); }
}
@media (max-width: 480px) { .tb-support span { display: none; } .tb-support { padding: 0.45rem 0.6rem; } }
/* sidebar-component:end */

/* screen-fit:begin  Every size that adapts to the screen, phone to 4K TV, is a
   token here. Screen tiers above only point their rules at these tokens.
   Shell sizes are rem, so the root size below scales the whole interface. */
:root {
    --fit-root-min: 100%;           /* the browser default, 16px unless the user changed it */
    --fit-root-max: 150%;
    --fit-root-grow: 0.39vw;        /* growth with screen width; starts near 2300px */
    --fit-root-base: 0.4375rem;
    --fit-text-floor: 0.75rem;      /* no text renders smaller on a small screen */
    --fit-text-min: 0px;            /* every small size reads max(size, this): 0 on desktop */
    --fit-text-body: 0.8125rem;
    --fit-text-title: 1.125rem;
    --fit-text-stat: 1.1rem;
    --fit-text-touch: 1rem;         /* iOS Safari zooms the page into a smaller field */
    --fit-field-min: 0px;           /* every field size reads max(size, this): 0 off touch */
    --fit-space-sm: 0.5rem;
    --fit-space-md: 1rem;
    --fit-page-max: 137.5rem;       /* widest the page content grows before it centres */
}

/* Small and touch screens: every small size floors at --fit-text-floor */
@media (max-width: 991px), (pointer: coarse) {
    :root {
        --fit-text-min: var(--fit-text-floor);
    }
}

html {
    font-size: clamp(var(--fit-root-min), calc(var(--fit-root-grow) + var(--fit-root-base)), var(--fit-root-max));
}

/* A table wider than its card scrolls inside the card instead of being cut off */
.page-content div:has(> table) {
    overflow-x: auto;
}

/* Touch screens: iOS Safari zooms the page into any field under 16px. A field
   with its own size reads max(size, var(--fit-field-min)); one without gets 16px. */
@media (pointer: coarse) {
    :root {
        --fit-field-min: var(--fit-text-touch);
    }

    :where(input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea) {
        font-size: var(--fit-text-touch);
    }
}

/* Layouts a page opts into: columns come from --fit-cols, the side pane width
   from --fit-side; both stack into one column on a small screen. */
.fit-cols {
    display: grid;
    grid-template-columns: var(--fit-cols);
    gap: var(--fit-cols-gap, var(--fit-space-md));
}

.fit-cols > * {
    min-width: 0;
}

.fit-split {
    display: flex;
}

.fit-split > .fit-split-main {
    flex: 1;
    min-width: 0;
}

.fit-split > .fit-split-side {
    flex: 0 0 var(--fit-side);
    border-left: 1px solid var(--border);
}

@media (max-width: 991px) {
    .fit-cols {
        grid-template-columns: minmax(0, 1fr);
    }

    .fit-split {
        flex-direction: column;
    }

    .fit-split > .fit-split-side {
        flex-basis: auto;
        border-left: 0;
        border-top: 1px solid var(--border);
    }
}
/* screen-fit:end */
