:root {
    color-scheme: dark;
    --bg: #020617;
    --panel: rgba(15, 23, 42, 0.88);
    --panel-strong: rgba(15, 23, 42, 0.96);
    --border: #334155;
    --border-soft: rgba(148, 163, 184, 0.2);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --accent-soft: #7dd3fc;
    --success: #22c55e;
    --warning: #f59e0b;
    --theme-glow-a: rgba(14, 165, 233, 0.18);
    --theme-glow-b: rgba(34, 197, 94, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #0ea5e9, #38bdf8);
    --theme-grad-btn: linear-gradient(135deg, #22c55e, #4ade80);
    --theme-btn-text: #052e16;
    --theme-accent-text: #082f49;
    --theme-active-pill: rgba(14, 165, 233, 0.16);
    --theme-active-pill-border: rgba(56, 189, 248, 0.55);
    /* logo filter: tints the grayscale transparent PNG to accent color */
    --theme-logo-filter: invert(1) sepia(1) saturate(3) hue-rotate(175deg) brightness(1.2);
}

/* ─── Theme overrides ─────────────────────────────────────────────────────── */

[data-theme="ember"] {
    --bg: #1c1408;
    --accent: #fbbf24;
    --accent-strong: #f59e0b;
    --accent-soft: #fcd34d;
    --theme-glow-a: rgba(251, 191, 36, 0.18);
    --theme-glow-b: rgba(234, 88, 12, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #ea580c, #fbbf24);
    --theme-grad-btn: linear-gradient(135deg, #ea580c, #f97316);
    --theme-btn-text: #431407;
    --theme-accent-text: #431407;
    --theme-active-pill: rgb(251, 190, 36);
    --theme-active-pill-border: rgba(251, 191, 36, 0.55);
    --theme-logo-filter: invert(1) sepia(1) saturate(4) hue-rotate(5deg) brightness(1.1);
}

[data-theme="violet"] {
    --bg: #150d30;
    --accent: #e879f9;
    --accent-strong: #d946ef;
    --accent-soft: #f0abfc;
    --theme-glow-a: rgba(232, 121, 249, 0.18);
    --theme-glow-b: rgba(124, 58, 237, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #7c3aed, #e879f9);
    --theme-grad-btn: linear-gradient(135deg, #7c3aed, #a855f7);
    --theme-btn-text: #2e1065;
    --theme-accent-text: #2e1065;
    --theme-active-pill: rgb(232, 121, 249);
    --theme-active-pill-border: rgba(232, 121, 249, 0.55);
    --theme-logo-filter: invert(1) sepia(1) saturate(5) hue-rotate(245deg) brightness(1.1);
}

[data-theme="emerald"] {
    --bg: #0a1f12;
    --accent: #6ee7b7;
    --accent-strong: #10b981;
    --accent-soft: #a7f3d0;
    --theme-glow-a: rgba(110, 231, 183, 0.18);
    --theme-glow-b: rgba(5, 150, 105, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #059669, #6ee7b7);
    --theme-grad-btn: linear-gradient(135deg, #059669, #34d399);
    --theme-btn-text: #022c22;
    --theme-accent-text: #022c22;
    --theme-active-pill: rgb(110, 231, 183);
    --theme-active-pill-border: rgba(110, 231, 183, 0.55);
    --theme-logo-filter: invert(1) sepia(1) saturate(3) hue-rotate(115deg) brightness(1.1);
}

[data-theme="rose"] {
    --bg: #1f0d14;
    --accent: #fda4af;
    --accent-strong: #f43f5e;
    --accent-soft: #fecdd3;
    --theme-glow-a: rgba(253, 164, 175, 0.18);
    --theme-glow-b: rgba(225, 29, 72, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #e11d48, #fda4af);
    --theme-grad-btn: linear-gradient(135deg, #e11d48, #fb7185);
    --theme-btn-text: #4c0519;
    --theme-accent-text: #4c0519;
    --theme-active-pill: rgb(253, 164, 174);
    --theme-active-pill-border: rgba(253, 164, 175, 0.55);
    --theme-logo-filter: invert(1) sepia(1) saturate(3) hue-rotate(310deg) brightness(1.1);
}

[data-theme="glacial"] {
    --bg: #0a1f30;
    --accent: #a5f3fc;
    --accent-strong: #06b6d4;
    --accent-soft: #cffafe;
    --theme-glow-a: rgba(165, 243, 252, 0.18);
    --theme-glow-b: rgba(6, 182, 212, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #0891b2, #a5f3fc);
    --theme-grad-btn: linear-gradient(135deg, #0891b2, #22d3ee);
    --theme-btn-text: #083344;
    --theme-accent-text: #083344;
    --theme-active-pill: rgb(165, 243, 252);
    --theme-active-pill-border: rgba(165, 243, 252, 0.55);
    --theme-logo-filter: invert(1) sepia(1) saturate(3) hue-rotate(165deg) brightness(1.2);
}

/* ─── Soft white variants ─────────────────────────────────────────────────── */

[data-theme="soft-midnight"] {
    color-scheme: light;
    --bg: #dbeafe;
    --panel: rgba(219, 234, 254, 0.82);
    --panel-strong: rgba(219, 234, 254, 0.96);
    --border: #93c5fd;
    --border-soft: rgba(37, 99, 235, 0.22);
    --text: #1e3a5f;
    --muted: #2563eb;
    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-soft: #93c5fd;
    --theme-glow-a: rgba(37, 99, 235, 0.22);
    --theme-glow-b: rgba(14, 165, 233, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #1d4ed8, #2563eb);
    --theme-grad-btn: linear-gradient(135deg, #1d4ed8, #3b82f6);
    --theme-btn-text: #ffffff;
    --theme-accent-text: #ffffff;
    --theme-active-pill: rgb(37, 100, 235);
    --theme-active-pill-border: rgba(37, 99, 235, 0.55);
    --theme-logo-filter: sepia(1) saturate(4) hue-rotate(175deg) brightness(0.85);
}

[data-theme="soft-ember"] {
    color-scheme: light;
    --bg: #fef3c7;
    --panel: rgba(254, 243, 199, 0.82);
    --panel-strong: rgba(254, 243, 199, 0.96);
    --border: #fcd34d;
    --border-soft: rgba(217, 119, 6, 0.25);
    --text: #78350f;
    --muted: #b45309;
    --accent: #d97706;
    --accent-strong: #b45309;
    --accent-soft: #fcd34d;
    --theme-glow-a: rgba(217, 119, 6, 0.22);
    --theme-glow-b: rgba(234, 88, 12, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #b45309, #d97706);
    --theme-grad-btn: linear-gradient(135deg, #b45309, #f59e0b);
    --theme-btn-text: #ffffff;
    --theme-accent-text: #ffffff;
    --theme-active-pill: rgb(217, 119, 6);
    --theme-active-pill-border: rgba(217, 119, 6, 0.55);
    --theme-logo-filter: sepia(1) saturate(5) hue-rotate(5deg) brightness(0.85);
}

[data-theme="soft-violet"] {
    color-scheme: light;
    --bg: #ede9fe;
    --panel: rgba(237, 233, 254, 0.82);
    --panel-strong: rgba(237, 233, 254, 0.96);
    --border: #c4b5fd;
    --border-soft: rgba(124, 58, 237, 0.25);
    --text: #3b0764;
    --muted: #6d28d9;
    --accent: #7c3aed;
    --accent-strong: #6d28d9;
    --accent-soft: #c4b5fd;
    --theme-glow-a: rgba(124, 58, 237, 0.22);
    --theme-glow-b: rgba(109, 40, 217, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #6d28d9, #7c3aed);
    --theme-grad-btn: linear-gradient(135deg, #6d28d9, #a855f7);
    --theme-btn-text: #ffffff;
    --theme-accent-text: #ffffff;
    --theme-active-pill: rgb(124, 58, 237);
    --theme-active-pill-border: rgba(124, 58, 237, 0.55);
    --theme-logo-filter: sepia(1) saturate(5) hue-rotate(245deg) brightness(0.85);
}

[data-theme="soft-emerald"] {
    color-scheme: light;
    --bg: #d1fae5;
    --panel: rgba(209, 250, 229, 0.82);
    --panel-strong: rgba(209, 250, 229, 0.96);
    --border: #6ee7b7;
    --border-soft: rgba(5, 150, 105, 0.25);
    --text: #064e3b;
    --muted: #047857;
    --accent: #059669;
    --accent-strong: #047857;
    --accent-soft: #6ee7b7;
    --theme-glow-a: rgba(5, 150, 105, 0.22);
    --theme-glow-b: rgba(4, 120, 87, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #047857, #059669);
    --theme-grad-btn: linear-gradient(135deg, #047857, #10b981);
    --theme-btn-text: #ffffff;
    --theme-accent-text: #ffffff;
    --theme-active-pill: rgb(5, 150, 104);
    --theme-active-pill-border: rgba(5, 150, 105, 0.55);
    --theme-logo-filter: sepia(1) saturate(4) hue-rotate(115deg) brightness(0.85);
}

[data-theme="soft-rose"] {
    color-scheme: light;
    --bg: #ffe4e6;
    --panel: rgba(255, 228, 230, 0.82);
    --panel-strong: rgba(255, 228, 230, 0.96);
    --border: #fda4af;
    --border-soft: rgba(225, 29, 72, 0.25);
    --text: #881337;
    --muted: #be123c;
    --accent: #e11d48;
    --accent-strong: #be123c;
    --accent-soft: #fda4af;
    --theme-glow-a: rgba(225, 29, 72, 0.22);
    --theme-glow-b: rgba(190, 18, 60, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #be123c, #e11d48);
    --theme-grad-btn: linear-gradient(135deg, #be123c, #f43f5e);
    --theme-btn-text: #ffffff;
    --theme-accent-text: #ffffff;
    --theme-active-pill: rgb(225, 29, 71);
    --theme-active-pill-border: rgba(225, 29, 72, 0.55);
    --theme-logo-filter: sepia(1) saturate(4) hue-rotate(310deg) brightness(0.85);
}

[data-theme="soft-glacial"] {
    color-scheme: light;
    --bg: #cffafe;
    --panel: rgba(207, 250, 254, 0.82);
    --panel-strong: rgba(207, 250, 254, 0.96);
    --border: #67e8f9;
    --border-soft: rgba(8, 145, 178, 0.25);
    --text: #164e63;
    --muted: #0e7490;
    --accent: #0891b2;
    --accent-strong: #0e7490;
    --accent-soft: #67e8f9;
    --theme-glow-a: rgba(8, 145, 178, 0.22);
    --theme-glow-b: rgba(14, 116, 144, 0.14);
    --theme-grad-badge: linear-gradient(135deg, #0e7490, #0891b2);
    --theme-grad-btn: linear-gradient(135deg, #0e7490, #06b6d4);
    --theme-btn-text: #ffffff;
    --theme-accent-text: #ffffff;
    --theme-active-pill: rgb(8, 144, 178);
    --theme-active-pill-border: rgba(8, 145, 178, 0.55);
    --theme-logo-filter: sepia(1) saturate(4) hue-rotate(165deg) brightness(0.85);
}

.theme-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 10px 14px;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .1s, box-shadow .15s;
    color: var(--muted);
    font-size: .75rem;
    font-family: inherit;
}

.theme-swatch:hover {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(148, 163, 184, 0.35);
    transform: translateY(-2px);
    color: var(--text);
}

.theme-swatch.active {
    background: var(--theme-active-pill);
    border-color: var(--theme-active-pill-border);
    color: var(--text);
    box-shadow: 0 0 0 1px var(--theme-active-pill-border), 0 4px 16px rgba(0, 0, 0, 0.3);
}

.theme-swatch-preview {
    width: 52px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-swatch-name {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
}


* {
    box-sizing: border-box;
}

body {
    font-family: Inter, system-ui, sans-serif;
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, var(--theme-glow-a), transparent 28%),
        radial-gradient(circle at top right, var(--theme-glow-b), transparent 22%),
        var(--bg);
    color: var(--text);
}

.wrap,
.container-fluid {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    min-height: 75vh;
    position: static;
}

.panel {
    background: rgba(15, 23, 42, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    padding: 20px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 -1px 0 rgba(0, 0, 0, 0.18) inset,
        0 10px 36px rgba(2, 6, 23, 0.35),
        0 2px 8px rgba(2, 6, 23, 0.2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.stack {
    display: grid;
    gap: 16px;
}

.tabs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tab {
    border: 1px solid #475569;
    border-radius: 999px;
    padding: 10px 16px;
    background: #1e293b;
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
}

.tab.active {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: var(--theme-accent-text);
}

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

.code {
    font-family: ui-monospace, monospace;
    background: #020617;
    padding: 2px 6px;
    border-radius: 6px;
}

.button {
    background: var(--theme-grad-btn);
    color: var(--theme-btn-text);
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
}

.shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.shell-sidebar {
    position: sticky;
    top: 24px;
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 22px;
    display: grid;
    gap: 20px;
}

.shell-brand {
    display: grid;
    gap: 10px;
}

.brand-badge {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-grad-badge);
    color: var(--theme-accent-text);
    font-size: 24px;
    font-weight: 900;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent-soft);
    font-weight: 800;
}

.nav-list,
.metric-list,
.signal-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-pill,
.metric-card,
.signal-item {
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.58);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.05) inset,
        0 4px 16px rgba(2, 6, 23, 0.22);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.nav-pill.active {
    border-color: var(--theme-active-pill-border);
    background: var(--theme-active-pill);
}

.shell-main {
    display: grid;
    gap: 18px;
}

.shell-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.72);
}

.chip-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    padding: 8px 12px;
    color: var(--muted);
    background: rgba(15, 23, 42, 0.7);
    font-size: 13px;
    font-weight: 700;
}

.chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    flex-wrap: wrap;
}

.hero-copy {
    display: grid;
    gap: 10px;
    max-width: 720px;
}

.hero-copy h2,
.section-title {
    margin: 0;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.05;
}

.overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.9fr);
    gap: 16px;
}

.subgrid {
    display: grid;
    gap: 16px;
}

.list-clean {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 10px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 800;
    margin: 6px 0 2px;
}

.rail-note {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
}

.app-shell {
    height: 100vh;
    overflow: hidden;
    display: grid;
    grid-template-columns: clamp(280px, 32vw, 375px) minmax(0, 1fr);
    background: transparent;
    min-height: 0;
}

.app-sidebar {
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    border-right: 1px solid rgba(51, 65, 85, 0.65);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    min-height: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.app-sidebar::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.sidebar-block {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.45);
}

.sidebar-title-row,
.sidebar-section-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-title-row {
    color: #e2e8f0;
    width: 100%;
    cursor: pointer;
    list-style: none;
}

.sidebar-title-row::-webkit-details-marker {
    display: none;
}

.sidebar-accordion {
    display: grid;
    gap: 0;
}

.sidebar-accordion-body {
    display: grid;
    gap: 10px;
    overflow: hidden;
    max-height: none;
    opacity: 1;
    margin-top: 10px;
    transform-origin: top center;
    transition:
        max-height 280ms cubic-bezier(0.16, 1, 0.3, 1),
        opacity 180ms ease,
        margin-top 180ms ease;
}

.sidebar-accordion-body .sidebar-tier-list>* {
    transform-origin: top center;
}

.sidebar-accordion-body.is-opening .sidebar-tier-list>* {
    animation: tier-row-fade-slide 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.sidebar-accordion-body.is-opening .sidebar-tier-list>*:nth-child(1) {
    animation-delay: 0ms;
}

.sidebar-accordion-body.is-opening .sidebar-tier-list>*:nth-child(2) {
    animation-delay: 28ms;
}

.sidebar-accordion-body.is-opening .sidebar-tier-list>*:nth-child(3) {
    animation-delay: 56ms;
}

.sidebar-accordion-body.is-opening .sidebar-tier-list>*:nth-child(4) {
    animation-delay: 84ms;
}

.sidebar-accordion-body.is-opening .sidebar-tier-list>*:nth-child(5) {
    animation-delay: 112ms;
}

.sidebar-accordion-body.is-opening .sidebar-tier-list>*:nth-child(n+6) {
    animation-delay: 140ms;
}

.sidebar-accordion-body.is-opening .sidebar-empty,
.sidebar-accordion-body.is-opening .sidebar-muted {
    animation: tier-row-fade-slide 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes tier-row-fade-slide {
    0% {
        opacity: 0;
        transform: translateY(-6px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.sidebar-enabled-strip {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.sidebar-title-row .sidebar-enabled-strip {
    width: 100%;
    margin-top: 6px;
}

.sidebar-summary-meta {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sidebar-enabled-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.92);
    border: 1px solid rgba(71, 85, 105, 0.4);
    color: #cbd5e1;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sidebar-enabled-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
    flex-shrink: 0;
}

.sidebar-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #cbd5e1;
    flex: 1;
}

.sidebar-count,
.sidebar-caret,
.sidebar-plus {
    font-size: 11px;
    color: #64748b;
}

.sidebar-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), color 160ms ease;
    transform-origin: center;
}

.sidebar-accordion[open] .sidebar-caret {
    transform: rotate(180deg);
    color: #cbd5e1;
}

.sidebar-title-row:hover .sidebar-caret {
    color: #cbd5e1;
}

.sidebar-empty,
.sidebar-muted {
    font-size: 11px;
    color: #475569;
    margin: 10px 0 0;
}

.sidebar-tier-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.tier-switch-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(107, 114, 128, 0.3) !important;
    border: 1px solid rgba(107, 114, 128, 0.2) !important;
    opacity: 1 !important;
    text-align: left;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease;
}

.tier-switch-row--moving {
    will-change: transform;
}

.tier-switch-row:hover {
    background: rgba(107, 114, 128, 0.46) !important;
    border-color: rgba(107, 114, 128, 0.38) !important;
}

.tier-switch-row.active {
    background: var(--theme-active-pill) !important;
    border-color: var(--theme-active-pill-border) !important;
}

.tier-switch-box {
    width: 28px;
    height: 16px;
    border-radius: 999px;
    background: rgba(71, 85, 105, 0.4);
    border: 1px solid rgba(71, 85, 105, 0.7);
    display: inline-flex;
    align-items: center;
    padding: 2px;
    flex-shrink: 0;
    transition: background 160ms ease, border-color 160ms ease;
}

.tier-switch-box.live {
    justify-content: flex-end;
    background: var(--accent-strong);
    border-color: var(--accent);
}

.tier-toggle-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.5);
    display: inline-block;
    transition: background 160ms ease;
}

.tier-toggle-dot.live {
    background: #fff;
}

.tier-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.tier-name {
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
}

.tier-sub {
    font-size: 11px;
    color: #64748b;
}

.sidebar-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    flex: 1;
}

.session-button,
.menu-button,
.ghost-button,
.menu-link,
.chip-button,
.sidebar-control,
.menu-action {
    appearance: none;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.session-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.session-card {
    position: relative;
}

.session-card--incoming {
    animation: session-card-slide-down 320ms cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top center;
}

@keyframes session-card-slide-down {
    0% {
        opacity: 0;
        transform: translateY(-10px) scaleY(0.92);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scaleY(1);
    }
}

.session-card .tier-switch-row {
    padding-right: 22px;
}

.session-active-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--accent-strong, #3b82f6);
    flex-shrink: 0;
    margin: 0 3px;
}

.session-x {
    position: absolute;
    top: 5px;
    right: 7px;
    font-size: 10px;
    line-height: 1;
    color: #475569;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
    z-index: 1;
}

.session-x:hover {
    color: #f87171;
}

.sidebar-control:hover,
.sidebar-plus:hover {
    color: #cbd5e1;
}

.sidebar-status {
    margin-top: auto;
    padding: 10px 12px;
    border-top: 1px solid rgba(51, 65, 85, 0.45);
    font-size: 11px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: #334155;
}

.status-dot.live {
    background: #22c55e;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
    min-height: 0;
}

.app-topbar {
    height: 46px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(12px);
    position: relative;
    z-index: 10;
    overflow: visible;
}

.app-topbar-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #f8fafc;
}

.app-topbar-title-button {
    appearance: none;
    border: 1px solid rgba(71, 85, 105, 0.28);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.52), rgba(15, 23, 42, 0.24));
    padding: 6px 12px 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    text-align: left;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.04) inset,
        0 8px 20px rgba(2, 6, 23, 0.18);
    transition: color 160ms ease, opacity 160ms ease, background 180ms ease, border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.app-topbar-title-button:hover {
    color: #ffffff;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.38));
    border-color: rgba(96, 165, 250, 0.3);
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.05) inset,
        0 10px 24px rgba(2, 6, 23, 0.24);
}

.app-topbar-title-button:focus-visible {
    outline: 2px solid rgba(56, 189, 248, 0.55);
    outline-offset: 4px;
    border-radius: 999px;
}

.app-topbar-title-mark {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.12);
    flex-shrink: 0;
}

.app-topbar-title-text {
    letter-spacing: 0.01em;
}

.app-topbar-title-button:hover .app-topbar-title-mark {
    background: var(--accent-soft);
}

/* ── Menu trigger (chevron) ─────────────────────────────────────────── */
.menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background-image: url('/static/img/logo2.png') !important;
    border: 1px solid rgba(71, 85, 105, 0.4);
    background: rgba(30, 41, 59, 0.7);
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease;
    flex-shrink: 0;
    padding: 0;
}

.menu-trigger:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: rgba(100, 116, 139, 0.55);
}

.menu-chevron {
    width: 9px;
    height: 9px;
    border-right: 2px solid #94a3b8;
    border-bottom: 2px solid #94a3b8;
    border-radius: 1px;
    transform: rotate(45deg) translate(-1px, -1px);
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1), border-color 160ms ease;
}

.menu-wrap.open .menu-chevron {
    transform: rotate(225deg) translate(-1px, -1px);
    border-color: #e2e8f0;
}

/* ── Menu panel — slides from behind the topbar ─────────────────────── */
.menu-wrap {
    position: relative;
}

.menu-panel {
    position: fixed;
    top: 46px;
    right: 14px;
    width: 196px;
    background: rgba(10, 15, 30, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    overflow: hidden;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.05) inset,
        0 16px 40px rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    /* closed */
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition:
        transform 220ms cubic-bezier(0.16, 1, 0.3, 1),
        opacity 180ms ease;
}

.menu-panel.opened {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.menu-trigger:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: rgba(100, 116, 139, 0.55);
}

.menu-trigger-bar {
    width: 14px;
    height: 1.5px;
    border-radius: 99px;
    background: #94a3b8;
    transition: width 160ms ease;
}

.menu-trigger:hover .menu-trigger-bar:nth-child(2) {
    width: 10px;
}

/* ── Backdrop ────────────────────────────────────────────────────────── */
.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 280ms ease;
}

.menu-backdrop.open {
    opacity: 1;
    pointer-events: all;
}

/* ── Drawer panel ────────────────────────────────────────────────────── */
.menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 260px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background: rgba(10, 15, 30, 0.96);
    border-left: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow:
        -1px 0 0 rgba(255, 255, 255, 0.04) inset,
        -24px 0 72px rgba(2, 6, 23, 0.65);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    transform: translateX(100%);
    transition: transform 340ms cubic-bezier(0.16, 1, 0.3, 1);
}

.menu-drawer.open {
    transform: translateX(0);
}

.menu-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.menu-drawer-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #475569;
}

.menu-drawer-close {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(71, 85, 105, 0.4);
    background: rgba(30, 41, 59, 0.6);
    color: #64748b;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    transition: background 150ms ease, color 150ms ease;
}

.menu-drawer-close:hover {
    background: rgba(71, 85, 105, 0.8);
    color: #f1f5f9;
}

.menu-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0 24px;
    overscroll-behavior: contain;
}

/* ── Nav items inside drawer ─────────────────────────────────────────── */
.menu-item {
    width: 100%;
    padding: 11px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 150ms ease, background 150ms ease, padding-left 180ms ease;
    position: relative;
}

.menu-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
    transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.menu-item:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.04);
    padding-left: 26px;
}

.menu-item.active {
    color: var(--accent);
    background: var(--theme-active-pill);
    padding-left: 26px;
}

.menu-item.active::before {
    transform: translateY(-50%) scaleY(1);
}

.menu-item.signout {
    color: #f87171;
    margin-top: 8px;
    border-top: 1px solid rgba(248, 113, 113, 0.12);
}

.menu-item.signout:hover {
    color: #fca5a5;
    background: rgba(248, 113, 113, 0.07);
}

.menu-icon {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.7;
    flex-shrink: 0;
}

.app-content {
    flex: 1;
    overflow: auto;
    min-height: 0;
    padding: 48px 24px 32px;
}

.app-legal-footer {
    flex-shrink: 0;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 8px 18px 10px;
    border-top: 1px solid rgba(51, 65, 85, 0.45);
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(12px);
}

.app-legal-link {
    appearance: none;
    border: 0;
    background: none;
    color: #94a3b8;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 2px 0;
    transition: color 160ms ease, opacity 160ms ease;
}

.app-legal-link:hover,
.app-legal-link.active {
    color: #e2e8f0;
}

.app-legal-copy {
    margin-left: auto;
    font-size: 11px;
    color: #64748b;
}

.legal-shell {
    display: grid;
    gap: 18px;
}

.legal-heading {
    margin-bottom: 0;
}

.legal-surface {
    min-height: calc(100vh - 190px);
}

.legal-body {
    padding: 24px 28px;
}

.legal-body p {
    margin: 0 0 14px;
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.75;
}

.legal-body h1,
.legal-body h2,
.legal-body h3,
.legal-body h4,
.legal-body h5,
.legal-body h6,
.legal-body strong {
    color: #f8fafc;
}

.content-shell,
.content-shell.container-fluid {
    width: 100%;
    max-width: none;
    margin: 0;
}

.page-heading {
    margin-bottom: 22px;
}

.page-title {
    margin: 0;
    font-size: 34px;
    font-weight: 700;
    color: #f8fafc;
}

.page-subtitle {
    margin-top: 6px;
    font-size: 14px;
    color: #64748b;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    border-radius: 18px;
    padding: 18px 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(15, 23, 42, 0.55);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 6px 24px rgba(2, 6, 23, 0.28);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.08) inset,
        0 12px 36px rgba(2, 6, 23, 0.38);
}

.stat-icon {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 14px;
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.16);
    color: #93c5fd;
}

.stat-icon.cyan {
    background: rgba(6, 182, 212, 0.16);
    color: #67e8f9;
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.16);
    color: #6ee7b7;
}

.stat-icon.amber {
    background: rgba(245, 158, 11, 0.16);
    color: #fcd34d;
}

.stat-icon.teal {
    background: rgba(20, 184, 166, 0.16);
    color: #5eead4;
}

.stat-icon.rose {
    background: rgba(244, 63, 94, 0.16);
    color: #fda4af;
}

.stat-value {
    font-size: 34px;
    font-weight: 700;
    line-height: 1;
    color: #f8fafc;
}

.stat-label {
    margin-top: 8px;
    font-size: 12px;
    color: #94a3b8;
}

.stat-subtitle {
    margin-top: 4px;
    font-size: 10px;
    color: #475569;
}

.two-col-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.surface-card {
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.52);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 -1px 0 rgba(0, 0, 0, 0.16) inset,
        0 8px 32px rgba(2, 6, 23, 0.32),
        0 2px 6px rgba(2, 6, 23, 0.18);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: box-shadow 220ms ease, border-color 220ms ease;
}

.surface-card:hover {
    border-color: rgba(255, 255, 255, 0.11);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.09) inset,
        0 -1px 0 rgba(0, 0, 0, 0.16) inset,
        0 14px 44px rgba(2, 6, 23, 0.42),
        0 4px 12px rgba(2, 6, 23, 0.22);
}

.surface-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
    color: #f1f5f9;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.surface-meta {
    color: #60a5fa;
    font-size: 11px;
}

.surface-body {
    padding: 18px 20px;
}

.settings-overview-body {
    display: grid;
    gap: 16px;
}

.settings-inline-note {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(71, 85, 105, 0.35);
    background: rgba(15, 23, 42, 0.4);
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.55;
}

.settings-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.settings-overview-card {
    display: grid;
    gap: 6px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(71, 85, 105, 0.35);
    background: rgba(30, 41, 59, 0.42);
}

.settings-overview-kicker {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
}

.settings-overview-title {
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
}

.settings-overview-copy {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.5;
}

.settings-section-stack {
    display: grid;
    gap: 16px;
}

.settings-control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.chat-settings-rows {
    display: grid;
    gap: 12px;
}

.chat-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(71, 85, 105, 0.38);
    background: rgba(30, 41, 59, 0.38);
}

.chat-setting-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 600;
}

.chat-setting-ctrl {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 180px;
}

.chat-setting-ctrl input[type="range"] {
    width: 150px;
    accent-color: var(--accent);
}

.chat-setting-ctrl select {
    border-radius: 10px;
    border: 1px solid rgba(71, 85, 105, 0.48);
    background: rgba(15, 23, 42, 0.92);
    color: #e2e8f0;
    padding: 8px 10px;
}

.chat-setting-val {
    min-width: 34px;
    text-align: right;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 700;
}

.settings-role-field {
    display: grid;
    gap: 8px;
}

.settings-role-label {
    display: grid;
    gap: 4px;
    color: #f8fafc;
    font-size: 13px;
    font-weight: 700;
}

.settings-role-hint {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.5;
}

.settings-role-textarea {
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(71, 85, 105, 0.45);
    background: rgba(15, 23, 42, 0.88);
    color: #e2e8f0;
    padding: 12px 14px;
    font: inherit;
    line-height: 1.55;
    resize: vertical;
}

.settings-role-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
}

.settings-save-btn {
    border: 0;
    border-radius: 10px;
    background: var(--theme-grad-btn);
    color: var(--theme-btn-text);
    font-size: 12px;
    font-weight: 800;
    padding: 10px 14px;
    cursor: pointer;
}

.settings-meta-list {
    display: grid;
    gap: 10px;
}

.settings-value-pair {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(71, 85, 105, 0.32);
    background: rgba(15, 23, 42, 0.36);
}

.settings-mono {
    font-family: ui-monospace, monospace;
    font-size: 12px;
    color: #94a3b8;
}

.empty-panel {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #475569;
    gap: 8px;
    font-size: 12px;
}

.empty-panel.tall {
    min-height: 260px;
}

.empty-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    border: 1px solid rgba(71, 85, 105, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #334155;
    font-size: 15px;
}

.empty-copy {
    color: #64748b;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.quick-button {
    width: 100%;
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.42);
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #cbd5e1;
    font-size: 12px;
}

.quick-button:hover {
    background: rgba(51, 65, 85, 0.42);
}

.quick-icon {
    width: 16px;
    height: 16px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.16);
    color: #93c5fd;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
}

.quick-icon.green {
    background: rgba(16, 185, 129, 0.16);
    color: #6ee7b7;
}

.quick-icon.teal {
    background: rgba(20, 184, 166, 0.16);
    color: #5eead4;
}

.quick-icon.amber {
    background: rgba(245, 158, 11, 0.16);
    color: #fcd34d;
}

.pipeline-result {
    margin-top: 12px;
    white-space: pre-wrap;
    font-size: 11px;
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.68);
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 12px;
    padding: 12px;
}

.chat-layout {
    height: calc(100vh - 126px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: stretch;
}

.chat-layout--single {
    grid-template-columns: minmax(0, 1fr);
}

.chat-thread {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    background: rgba(15, 23, 42, 0.32);
    overscroll-behavior: contain;
}

.chat-chip-row {
    /* display: flex; */
    gap: 8px;
    flex-wrap: wrap;
    padding: 5px;
}

.chat-scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(71, 85, 105, 0.45);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
}

.chat-message {
    display: flex;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: min(720px, 88%);
}

.chat-message.user .chat-message-body {
    align-items: flex-end;
}

.chat-bubble {
    padding: 14px 16px;
    border-radius: 18px;
    font-size: 13px;
    line-height: 1.6;
    color: #dbeafe;
    background: rgba(30, 41, 59, 0.94);
    border: 1px solid rgba(71, 85, 105, 0.4);
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.24);
}

.chat-message.user .chat-bubble {
    color: #eff6ff;
    background: rgba(37, 99, 235, 0.28);
    border-color: rgba(96, 165, 250, 0.36);
}

.chat-citations-details {
    font-size: 11px;
    color: #64748b;
}

.chat-citations-summary {
    cursor: pointer;
    color: #94a3b8;
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 6px;
    user-select: none;
    list-style: none;
}

.chat-citations-summary::-webkit-details-marker {
    display: none;
}

.chat-citations-summary::before {
    content: '▶ ';
    font-size: 9px;
}

details[open] .chat-citations-summary::before {
    content: '▼ ';
}

.chat-citations-list {
    margin: 6px 0 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    list-style: none;
}

.chat-citation-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(51, 65, 85, 0.4);
    border-radius: 8px;
    padding: 6px 10px;
}

.citation-index {
    font-size: 10px;
    color: #475569;
    min-width: 16px;
    padding-top: 1px;
}

.citation-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.citation-chunk {
    font-size: 10px;
    color: #60a5fa;
    font-family: monospace;
}

.citation-snippet {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.5;
}

.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 18px;
    border-top: 1px solid rgba(51, 65, 85, 0.45);
    background: rgba(15, 23, 42, 0.4);
}

.chat-composer textarea {
    flex: 1;
    min-height: 104px;
    resize: vertical;
    border-radius: 14px;
    border: 1px solid rgba(71, 85, 105, 0.48);
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    padding: 14px 16px;
    font: inherit;
    outline: none;
}

.chat-composer textarea::placeholder {
    color: #475569;
}

.chat-composer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.chat-composer-note {
    font-size: 11px;
    color: #64748b;
    text-align: center;
    padding: 4px;
}

.chat-scope-list {
    display: grid;
    gap: 12px;
    align-content: start;
}

.chat-scope-card {
    font-size: smaller;
    border-radius: 14px;
    border: 1px solid rgba(51, 65, 85, 0.45);
    background: rgba(15, 23, 42, 0.58);
    padding: 14px;
    display: grid;
    gap: 10px;
}

.chat-scope-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 0;
}

.chat-scope-title {
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
}

.chat-scope-meta {
    font-size: 11px;
    color: #64748b;
    padding: 5px;
}

/* ── Inline tooltip badge (?) ────────────────────────────────────────── */
.sv-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: rgba(71, 85, 105, 0.5);
    border: 1px solid rgba(100, 116, 139, 0.4);
    color: #94a3b8;
    font-size: 9px;
    font-weight: 700;
    font-style: normal;
    cursor: default;
    vertical-align: middle;
    margin-left: 4px;
    flex-shrink: 0;
    user-select: none;
}

.sv-tip-bubble {
    position: fixed;
    z-index: 9999;
    background: rgba(10, 15, 30, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.5;
    padding: 8px 11px;
    border-radius: 10px;
    max-width: 210px;
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.55);
    pointer-events: none;
    opacity: 0;
    transition: opacity 160ms ease;
}

.sv-tip-bubble.visible {
    opacity: 1;
}

.manage-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);
    border: 1px solid rgba(51, 65, 85, 0.42);
    border-radius: 18px;
    overflow: hidden;
    min-height: calc(100vh - 170px);
    background: rgba(15, 23, 42, 0.45);
}

.manage-left,
.manage-right {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

.manage-right {
    border-left: 1px solid rgba(51, 65, 85, 0.42);
    position: relative;
    background: rgba(2, 6, 23, 0.2);
}

.manage-right-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.manage-right-stage.has-selection .manage-rearrangement-board {
    animation: manage-board-nudge-left 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes manage-board-nudge-left {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-10px);
    }
}

.manage-head {
    height: 56px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(51, 65, 85, 0.42);
}

.section-title-sm {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #f8fafc;
}

.section-desc {
    margin-top: 6px;
    font-size: 12px;
    color: #64748b;
}

.primary-button {
    border: 0;
    border-radius: 10px;
    background: #2563eb;
    color: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    padding: 9px 14px;
    cursor: pointer;
}

.primary-button:hover {
    background: #3b82f6;
}

.secondary-button {
    border: 1px solid #334155;
    border-radius: 10px;
    background: transparent;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    padding: 9px 14px;
    cursor: pointer;
}

.secondary-button:hover {
    background: #1e293b;
    color: #f8fafc;
    border-color: #475569;
}

.manage-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    color: #64748b;
    padding: 32px;
}

.manage-empty.tight {
    justify-content: flex-start;
    padding-top: 56px;
}

.manage-empty .empty-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.tier-collection {
    display: grid;
    gap: 12px;
    padding: 16px;
}

.tier-card {
    border-radius: 14px;
    border: 1px solid rgba(51, 65, 85, 0.5);
    background: rgba(15, 23, 42, 0.52);
    padding: 14px;
    display: grid;
    gap: 12px;
    transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.tier-card:hover {
    border-color: rgba(96, 165, 250, 0.28);
    transform: translateY(-1px);
}

.tier-card.is-drag-over {
    border-color: rgba(56, 189, 248, 0.58);
    background: rgba(14, 165, 233, 0.1);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.2), 0 16px 30px rgba(2, 6, 23, 0.22);
}

.tier-card.is-uploading {
    opacity: 0.9;
}

.tier-upload-feedback {
    display: grid;
    gap: 8px;
}

.tier-upload-status {
    margin-top: 2px;
    font-size: 11px;
    color: #94a3b8;
}

.tier-upload-feedback .upload-result {
    margin-top: 2px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(71, 85, 105, 0.35);
    background: rgba(15, 23, 42, 0.72);
    font-size: 11px;
}

.tier-upload-feedback .upload-result-detail {
    display: inline-block;
    margin-left: 6px;
    color: #94a3b8;
}

.tier-card--active {
    border-color: var(--theme-active-pill-border);
    background: rgba(15, 23, 42, 0.72);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12), 0 16px 30px rgba(2, 6, 23, 0.22);
}

.tier-card-head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 10px;
}

.tier-card-trigger {
    appearance: none;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.tier-card-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.tier-card-arrow {
    color: #64748b;
    font-size: 16px;
    transition: transform 180ms ease, color 180ms ease;
}

.tier-card:hover .tier-card-arrow,
.tier-card--active .tier-card-arrow {
    color: #cbd5e1;
    transform: translateX(2px);
}

.tier-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    color: #475569;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
    user-select: none;
}

.tier-delete:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.tier-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(71, 85, 105, 0.45);
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.corpus-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.corpus-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.88);
    border: 1px solid rgba(71, 85, 105, 0.4);
    color: #cbd5e1;
    font-size: 11px;
}

.manage-right-board-head {
    border-bottom: 1px solid rgba(51, 65, 85, 0.42);
}

.manage-right-board-title {
    font-size: 20px;
    font-weight: 700;
    color: #f8fafc;
}

.manage-rearrangement-board {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.rearrangement-columns {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    padding: 16px;
    align-content: start;
}

.tier-drop-column {
    display: flex;
    flex-direction: column;
    min-height: 240px;
    border: 1px solid rgba(51, 65, 85, 0.45);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.52);
    overflow: hidden;
}

.tier-drop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.38);
}

.tier-drop-title {
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
}

.tier-drop-sub {
    margin-top: 4px;
    font-size: 11px;
    color: #64748b;
}

.tier-drop-list {
    flex: 1;
    min-height: 170px;
    display: grid;
    gap: 10px;
    align-content: start;
    padding: 12px;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.tier-drop-list.is-drag-over {
    background: rgba(14, 165, 233, 0.08);
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.28);
}

.tier-drop-empty {
    min-height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px dashed rgba(71, 85, 105, 0.45);
    border-radius: 12px;
    color: #64748b;
    font-size: 12px;
    padding: 12px;
}

.tier-doc-card {
    display: grid;
    gap: 6px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(71, 85, 105, 0.4);
    background: rgba(30, 41, 59, 0.78);
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.16);
    cursor: grab;
    user-select: none;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.tier-doc-card:hover {
    transform: translateY(-1px);
    border-color: rgba(96, 165, 250, 0.34);
}

.tier-doc-card:active {
    cursor: grabbing;
}

.tier-doc-card--compact {
    padding: 10px 11px;
}

.tier-doc-card.is-dragging {
    opacity: 0.42;
    transform: rotate(-1deg) scale(0.99);
}

.tier-doc-title {
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
    line-height: 1.45;
    word-break: break-word;
}

.tier-doc-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 10px;
    color: #64748b;
}

.tier-documents-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-left: 1px solid rgba(51, 65, 85, 0.52);
    background: rgba(10, 15, 30, 0.96);
    box-shadow: -18px 0 42px rgba(2, 6, 23, 0.42);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow: hidden;
    will-change: transform, opacity;
    z-index: 2;
}

.tier-documents-panel.is-open {
    animation: manage-panel-slide-in 760ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tier-documents-panel.is-closing {
    animation: manage-panel-slide-out 760ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

@keyframes manage-panel-slide-in {
    0% {
        opacity: 0.88;
        transform: translateX(100%);
    }

    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes manage-panel-slide-out {
    0% {
        opacity: 1;
        transform: translateX(0);
    }

    100% {
        opacity: 0.88;
        transform: translateX(100%);
    }
}

.tier-documents-panel-shell {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.manage-tier-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.42);
}

.manage-tier-panel-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
}

.manage-tier-panel-title {
    margin: 6px 0 0;
    font-size: 22px;
    color: #f8fafc;
}

.manage-tier-close {
    flex-shrink: 0;
}

.manage-tier-panel-body {
    flex: 1;
    overflow: auto;
    padding: 16px 18px 18px;
    display: grid;
    gap: 12px;
    align-content: start;
}

.manage-tier-panel-body--with-footer {
    padding-bottom: 12px;
}

.manage-tier-upload-queue-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid rgba(71, 85, 105, 0.38);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.34);
}

.manage-tier-upload-queue-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.manage-tier-upload-queue-title {
    margin: 6px 0 0;
    font-size: 15px;
    font-weight: 700;
    color: #f8fafc;
}

.manage-tier-panel-footer {
    flex-shrink: 0;
    padding: 14px 18px 18px;
    border-top: 1px solid rgba(51, 65, 85, 0.42);
    background: rgba(10, 15, 30, 0.98);
}

.manage-tier-upload-dropzone {
    min-height: 132px;
    width: 100%;
    box-sizing: border-box;
    border: 1px dashed rgba(71, 85, 105, 0.45);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.32);
    cursor: pointer;
}

.manage-tier-upload-dropzone.is-drag-over {
    border-color: rgba(56, 189, 248, 0.6);
    background: rgba(14, 165, 233, 0.08);
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.22);
}

.manage-tier-document-list {
    display: grid;
    gap: 10px;
}

.manage-tier-banner {
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 12px;
    border: 1px solid rgba(71, 85, 105, 0.45);
}

.manage-tier-banner--ok {
    background: rgba(34, 197, 94, 0.08);
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.25);
}

.manage-tier-banner--error {
    background: rgba(248, 113, 113, 0.08);
    color: #fda4af;
    border-color: rgba(248, 113, 113, 0.24);
}

.manage-empty-panel-shell {
    height: 100%;
}

.manage-empty-panel {
    min-height: 220px;
}

.manage-tier-dragging .tier-drop-list {
    border-radius: 12px;
}

@media (max-width: 1180px) {
    .manage-layout {
        grid-template-columns: 1fr;
    }

    .manage-right {
        border-left: 0;
        border-top: 1px solid rgba(51, 65, 85, 0.42);
        min-height: 540px;
    }

    .tier-documents-panel {
        width: 100%;
    }
}

.search-shell {
    min-height: calc(100vh - 170px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 26px;
}

.search-hero {
    width: min(620px, 100%);
    margin-bottom: 58px;
}

.search-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.search-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 14px;
    border: 1px solid rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fbbf24;
    font-size: 16px;
}

.search-title {
    margin: 0;
    font-size: 30px;
    color: #f8fafc;
}

.search-subtitle {
    margin-top: 3px;
    font-size: 13px;
    color: #64748b;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.55);
    background: rgba(30, 41, 59, 0.75);
    color: #f8fafc;
    font-size: 13px;
    padding: 12px 42px 12px 34px;
    outline: none;
}

.search-box input::placeholder {
    color: #475569;
}

.search-box .search-left,
.search-box .search-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 14px;
}

.search-box .search-left {
    left: 12px;
}

.search-box .search-right {
    right: 12px;
}

.search-empty {
    text-align: center;
    color: #475569;
    font-size: 12px;
}

.placeholder-shell {
    min-height: calc(100vh - 170px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-card {
    max-width: 520px;
    text-align: center;
    border: 1px solid rgba(51, 65, 85, 0.55);
    border-radius: 18px;
    padding: 32px;
    background: rgba(15, 23, 42, 0.55);
    color: #94a3b8;
}

@media (max-width: 980px) {

    .shell,
    .overview-grid,
    .two-col-grid,
    .stats-grid,
    .manage-layout,
    .chat-layout {
        grid-template-columns: 1fr;
    }

    .shell-sidebar {
        position: static;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        height: auto;
        overflow-y: visible;
    }

    .app-content {
        padding: 18px 14px 24px;
    }

    .manage-right {
        border-left: 0;
        border-top: 1px solid rgba(51, 65, 85, 0.42);
    }

    .settings-control-grid,
    .chat-setting-row,
    .settings-value-pair {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .chat-setting-ctrl {
        min-width: 0;
        justify-content: space-between;
    }

    .chat-setting-ctrl input[type="range"] {
        width: 100%;
    }
}

/* ── Upload History SPA ───────────────────────────────────────────── */
.upload-history-spa {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.upload-history-totals {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.upload-filter-strip {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    align-items: center;
}

.upload-filter-btn {
    padding: .25rem .75rem;
    border-radius: 999px;
    border: 1px solid rgba(71, 85, 105, .5);
    background: rgba(30, 41, 59, .6);
    color: #94a3b8;
    font-size: .75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .35rem;
    transition: background .15s, color .15s;
}

.upload-filter-btn:hover {
    background: rgba(51, 65, 85, .8);
    color: #e2e8f0;
}

.upload-filter-btn.active {
    background: rgba(99, 102, 241, .25);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, .5);
}

.upload-filter-count {
    font-size: .65rem;
    background: rgba(255, 255, 255, .1);
    border-radius: 999px;
    padding: 0 .4rem;
}

.upload-spinner {
    font-size: .8rem;
    margin-left: .5rem;
}

.upload-table-scroll {
    overflow-x: auto;
}

.upload-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

.upload-table th {
    text-align: left;
    padding: .5rem .75rem;
    color: #64748b;
    font-weight: 600;
    border-bottom: 1px solid rgba(71, 85, 105, .4);
    white-space: nowrap;
}

.upload-table td {
    padding: .45rem .75rem;
    border-bottom: 1px solid rgba(71, 85, 105, .2);
    vertical-align: middle;
}

.upload-row:hover td {
    background: rgba(51, 65, 85, .3);
}

.upload-filename {
    font-family: monospace;
    font-size: .75rem;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-uuid {
    font-family: monospace;
    font-size: .7rem;
    color: #64748b;
}

.upload-date {
    white-space: nowrap;
    color: #94a3b8;
    font-size: .75rem;
}

.upload-note {
    font-size: .7rem;
    color: #f87171;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.upload-badge--indexed {
    background: rgba(16, 185, 129, .15);
    color: #34d399;
}

.upload-badge--duplicate {
    background: rgba(245, 158, 11, .15);
    color: #fbbf24;
}

.upload-badge--failed {
    background: rgba(239, 68, 68, .15);
    color: #f87171;
}

.upload-badge--queued {
    background: rgba(99, 102, 241, .15);
    color: #a5b4fc;
}

.upload-badge--processing {
    background: rgba(14, 165, 233, .15);
    color: #38bdf8;
}

.upload-pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    padding: .75rem 0;
}

.upload-page-btn {
    padding: .3rem .9rem;
    border-radius: 6px;
    border: 1px solid rgba(71, 85, 105, .5);
    background: rgba(30, 41, 59, .7);
    color: #94a3b8;
    font-size: .78rem;
    cursor: pointer;
}

.upload-page-btn:hover {
    background: rgba(51, 65, 85, .8);
    color: #e2e8f0;
}

.upload-page-info {
    font-size: .75rem;
    color: #64748b;
}

.upload-empty {
    padding: 2rem;
    text-align: center;
    color: #64748b;
    font-size: .85rem;
}


/* ── Upload History SPA ───────────────────────────────────────────── */
.upload-history-spa {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.upload-history-totals {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.upload-filter-strip {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    align-items: center;
}

.upload-filter-btn {
    padding: .25rem .75rem;
    border-radius: 999px;
    border: 1px solid rgba(71, 85, 105, .5);
    background: rgba(30, 41, 59, .6);
    color: #94a3b8;
    font-size: .75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .35rem;
    transition: background .15s, color .15s;
}

.upload-filter-btn:hover {
    background: rgba(51, 65, 85, .8);
    color: #e2e8f0;
}

.upload-filter-btn.active {
    background: rgba(99, 102, 241, .25);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, .5);
}

.upload-filter-count {
    font-size: .65rem;
    background: rgba(255, 255, 255, .1);
    border-radius: 999px;
    padding: 0 .4rem;
}

.upload-spinner {
    font-size: .8rem;
    margin-left: .5rem;
}

.upload-table-scroll {
    overflow-x: auto;
}

.upload-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

.upload-table th {
    text-align: left;
    padding: .5rem .75rem;
    color: #64748b;
    font-weight: 600;
    border-bottom: 1px solid rgba(71, 85, 105, .4);
    white-space: nowrap;
}

.upload-table td {
    padding: .45rem .75rem;
    border-bottom: 1px solid rgba(71, 85, 105, .2);
    vertical-align: middle;
}

.upload-row:hover td {
    background: rgba(51, 65, 85, .3);
}

.upload-filename {
    font-family: monospace;
    font-size: .75rem;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-uuid {
    font-family: monospace;
    font-size: .7rem;
    color: #64748b;
}

.upload-date {
    white-space: nowrap;
    color: #94a3b8;
    font-size: .75rem;
}

.upload-note {
    font-size: .7rem;
    color: #f87171;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.upload-badge--indexed {
    background: rgba(16, 185, 129, .15);
    color: #34d399;
}

.upload-badge--duplicate {
    background: rgba(245, 158, 11, .15);
    color: #fbbf24;
}

.upload-badge--failed {
    background: rgba(239, 68, 68, .15);
    color: #f87171;
}

.upload-badge--queued {
    background: rgba(99, 102, 241, .15);
    color: #a5b4fc;
}

.upload-badge--processing {
    background: rgba(14, 165, 233, .15);
    color: #38bdf8;
}

.upload-pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    padding: .75rem 0;
}

.upload-page-btn {
    padding: .3rem .9rem;
    border-radius: 6px;
    border: 1px solid rgba(71, 85, 105, .5);
    background: rgba(30, 41, 59, .7);
    color: #94a3b8;
    font-size: .78rem;
    cursor: pointer;
}

.upload-page-btn:hover {
    background: rgba(51, 65, 85, .8);
    color: #e2e8f0;
}

.upload-page-info {
    font-size: .75rem;
    color: #64748b;
}

.upload-empty {
    padding: 2rem;
    text-align: center;
    color: #64748b;
    font-size: .85rem;
}


/* ── Upload tier dropdown ────────────────────────────────────────────── */
.upload-tier-cell {
    min-width: 140px;
}

.upload-tier-select {
    width: 100%;
    padding: .2rem .4rem;
    border-radius: 6px;
    background: rgba(30, 41, 59, .8);
    color: #cbd5e1;
    border: 1px solid rgba(71, 85, 105, .5);
    font-size: .75rem;
    cursor: pointer;
}

.upload-tier-select:hover {
    border-color: rgba(99, 102, 241, .5);
}

.upload-tier-select--saved {
    border-color: rgba(16, 185, 129, .6);
    color: #34d399;
}

.upload-tier-saved {
    font-size: .7rem;
    color: #34d399;
    margin-left: .3rem;
}


/* ── Upload error tooltip (fixed — escapes overflow containers) ─────── */
.upload-error-tip {
    position: relative;
    cursor: help;
    color: #f87171;
    font-size: .7rem;
    border-bottom: 1px dashed rgba(248, 113, 113, .4);
}

.upload-error-tip::after {
    content: attr(data-tip);
    position: fixed !important;
    left: var(--tip-x, 0px) !important;
    top: var(--tip-y, 0px) !important;
    transform: translateX(-50%) translateY(-100%) !important;
    min-width: 260px !important;
    max-width: 480px !important;
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border: 1px solid rgba(248, 113, 113, .35) !important;
    border-radius: 6px !important;
    padding: .5rem .65rem !important;
    font-size: .72rem !important;
    line-height: 1.45 !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .45) !important;
    z-index: 9999 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity .15s ease !important;
}

.upload-error-tip:hover::after {
    opacity: 1 !important;
}


/* ── Upload pagination size picker ──────────────────────────────────── */
.upload-page-size-label {
    font-size: .72rem;
    color: #64748b;
    margin-left: auto;
}

.upload-page-size-btn {
    padding: .2rem .6rem;
    border-radius: 6px;
    border: 1px solid rgba(71, 85, 105, .5);
    background: rgba(30, 41, 59, .7);
    color: #94a3b8;
    font-size: .75rem;
    cursor: pointer;
}

.upload-page-size-btn:hover {
    background: rgba(51, 65, 85, .8);
    color: #e2e8f0;
}

.upload-page-size-btn.active {
    background: rgba(99, 102, 241, .25);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, .5);
}

/* ── Document management expandable rows ───────────────────────────── */
.upload-table-scroll {
    overflow-x: visible;
}

.upload-table {
    table-layout: fixed;
}

.upload-row {
    cursor: pointer;
    outline: none;
}

.upload-row:focus-visible td {
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, .38);
}

.upload-item.is-open .upload-row td {
    background: rgba(51, 65, 85, .34);
    border-bottom-color: transparent;
}

.upload-summary-cell {
    width: 42%;
}

.upload-doc-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.upload-row-caret {
    color: #64748b;
    transition: transform .2s ease, color .2s ease;
    transform-origin: center;
    margin-top: 2px;
}

.upload-item.is-open .upload-row-caret {
    transform: rotate(180deg);
    color: #cbd5e1;
}

.upload-doc-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.upload-doc-title {
    font-family: ui-monospace, monospace;
    font-size: .78rem;
    color: #e2e8f0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-doc-subline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: .68rem;
    color: #64748b;
}

.upload-doc-subsep {
    opacity: .55;
}

.upload-table-actions-head {
    text-align: right;
}

.upload-actions-cell {
    text-align: right;
    white-space: nowrap;
}

.upload-detail-row td {
    padding: 0;
    border-bottom: 1px solid rgba(71, 85, 105, .2);
    background: rgba(8, 12, 24, .34);
}

.upload-detail-cell {
    padding: 0 !important;
}

.upload-detail-inner {
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s ease, opacity .22s ease, padding .24s ease;
    opacity: 0;
    padding: 0 16px;
}

.upload-item.is-open .upload-detail-inner {
    max-height: 280px;
    opacity: 1;
    padding: 14px 16px 16px;
}

.upload-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.upload-detail-card {
    display: grid;
    gap: 6px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(71, 85, 105, .32);
    background: rgba(15, 23, 42, .44);
}

.upload-detail-card--wide {
    grid-column: span 2;
}

.upload-detail-card--full {
    grid-column: 1 / -1;
}

.upload-detail-label {
    font-size: .65rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 700;
}

.upload-detail-value {
    color: #dbeafe;
    font-size: .78rem;
    line-height: 1.5;
}

.upload-detail-mono {
    font-family: ui-monospace, monospace;
    word-break: break-all;
}

.upload-detail-note {
    color: #cbd5e1;
}

@media (max-width: 980px) {
    .upload-table {
        table-layout: auto;
    }

    .upload-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .upload-detail-card--wide,
    .upload-detail-card--full {
        grid-column: span 2;
    }
}

/* ─── Opal Admin ─────────────────────────────────────────────────────────── */
.opal-panel {
    padding: 1.5rem;
    max-width: 860px;
}

.opal-panel-header h2 {
    margin: 0 0 0.25rem;
    font-size: 1.3rem;
}

.opal-subtitle {
    color: var(--text-muted, #888);
    margin: 0 0 1.5rem;
    font-size: 0.9rem;
}

.opal-tenant-card {
    border: 1px solid var(--border, #dee2e6);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--card-bg, #fff);
}

.opal-tenant-uuid {
    font-family: monospace;
    font-size: 0.78rem;
    color: var(--text-muted, #888);
    margin-bottom: 0.75rem;
}

.opal-field {
    margin-bottom: 0.75rem;
}

.opal-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.opal-textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border, #dee2e6);
    border-radius: 5px;
    font-size: 0.88rem;
    resize: vertical;
    background: var(--input-bg, #f8f9fa);
}

.opal-field-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.opal-save-btn {
    padding: 0.4rem 1.1rem;
    background: var(--accent, #5865f2);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.88rem;
}

.opal-save-btn:hover {
    opacity: 0.88;
}

.opal-save-msg {
    font-size: 0.85rem;
}

.opal-save-msg--ok {
    color: #28a745;
}

.opal-save-msg--error {
    color: #dc3545;
}

.opal-empty {
    color: var(--text-muted, #888);
    font-size: 0.9rem;
    padding: 1rem 0;
}

.opal-search-row {
    margin-bottom: 1rem;
}

.opal-search-input {
    width: 100%;
    max-width: 360px;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border, #dee2e6);
    border-radius: 5px;
    font-size: 0.9rem;
}

.opal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.opal-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: var(--table-head-bg, #f1f3f5);
    border-bottom: 2px solid var(--border, #dee2e6);
}

.opal-table td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border, #dee2e6);
}

.opal-uuid {
    font-family: monospace;
    font-size: 0.78rem;
    color: var(--text-muted, #888);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SOFT-THEME OVERRIDES
   Every hardcoded dark color in the base styles is overridden here for all
   [data-theme^="soft-"] variants so text is always legible on light bg.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Structural surfaces ─────────────────────────────────────────────────── */
[data-theme^="soft-"] .panel {
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
}

[data-theme^="soft-"] .tab {
    background: var(--panel);
    border-color: var(--border);
    color: var(--text);
}

[data-theme^="soft-"] .code {
    background: var(--panel-strong);
    color: var(--text);
}

[data-theme^="soft-"] .nav-pill,
[data-theme^="soft-"] .metric-card,
[data-theme^="soft-"] .signal-item {
    background: var(--panel);
}

[data-theme^="soft-"] .shell-topbar {
    background: var(--panel);
    border-color: var(--border);
}

[data-theme^="soft-"] .chip {
    background: var(--panel);
    color: var(--muted);
}

/* ── Theme swatches ──────────────────────────────────────────────────────── */
[data-theme^="soft-"] .theme-swatch {
    background: var(--panel);
    color: var(--muted);
}

[data-theme^="soft-"] .theme-swatch:hover {
    background: var(--panel-strong);
    border-color: var(--border);
    color: var(--text);
}

[data-theme^="soft-"] .theme-swatch-preview {
    border-color: var(--border-soft);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
[data-theme^="soft-"] .app-sidebar {
    border-right-color: var(--border);
}

[data-theme^="soft-"] .sidebar-block {
    border-bottom-color: var(--border-soft);
}

[data-theme^="soft-"] .sidebar-title-row {
    color: var(--text);
}

[data-theme^="soft-"] .sidebar-kicker {
    color: var(--text);
}

[data-theme^="soft-"] .sidebar-count,
[data-theme^="soft-"] .sidebar-caret,
[data-theme^="soft-"] .sidebar-plus {
    color: var(--muted);
}

[data-theme^="soft-"] .sidebar-empty,
[data-theme^="soft-"] .sidebar-muted {
    color: var(--muted);
}

[data-theme^="soft-"] .sidebar-enabled-pill {
    background: var(--panel-strong);
    border-color: var(--border);
    color: var(--text);
}

[data-theme^="soft-"] .sidebar-section-label {
    color: var(--muted);
}

[data-theme^="soft-"] .sidebar-status {
    color: var(--muted);
    border-top-color: var(--border-soft);
}

[data-theme^="soft-"] .sidebar-control:hover,
[data-theme^="soft-"] .sidebar-plus:hover {
    color: var(--text);
}

[data-theme^="soft-"] .status-dot {
    background: var(--border);
}

/* ── Tier switches ───────────────────────────────────────────────────────── */
[data-theme^="soft-"] .tier-switch-row {
    background: var(--panel);
    border-color: var(--border-soft);
}

[data-theme^="soft-"] .tier-switch-row:hover {
    background: var(--panel-strong);
}

[data-theme^="soft-"] .tier-switch-box {
    background: var(--panel-strong);
    border-color: var(--border);
}

[data-theme^="soft-"] .tier-toggle-dot {
    background: var(--muted);
    opacity: 0.35;
}

[data-theme^="soft-"] .tier-name {
    color: var(--text);
}

[data-theme^="soft-"] .tier-sub {
    color: var(--muted);
}

/* ── Session buttons ─────────────────────────────────────────────────────── */
[data-theme^="soft-"] .session-button {
    background: var(--panel);
    color: var(--text);
    border-color: var(--border-soft);
}

[data-theme^="soft-"] .session-button:hover {
    background: var(--panel-strong);
}

[data-theme^="soft-"] .session-button.primary {
    background: var(--panel-strong);
}

[data-theme^="soft-"] .session-title {
    color: var(--text);
}

[data-theme^="soft-"] .session-sub {
    color: var(--muted);
}

/* ── App topbar & menus ──────────────────────────────────────────────────── */
[data-theme^="soft-"] .app-topbar {
    background: var(--panel);
    border-bottom-color: var(--border);
}

[data-theme^="soft-"] .app-topbar-title {
    color: var(--text);
}

[data-theme^="soft-"] .menu-wrap summary {
    background: var(--panel);
    color: var(--muted);
    border-color: var(--border);
}

[data-theme^="soft-"] .menu-panel.opened {
    background: var(--panel-strong);
    border-color: var(--border);
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.12);
}

[data-theme^="soft-"] .menu-panel {
    background: var(--panel-strong);
    border-color: var(--border);
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.12);
}




[data-theme^="soft-"] .menu-item {
    color: var(--text);
    border-bottom-color: var(--border-soft);
}

[data-theme^="soft-"] .menu-item:hover {
    background: var(--panel);
}

/* ── Page headings & stat cards ──────────────────────────────────────────── */
[data-theme^="soft-"] .page-title {
    color: var(--text);
}

[data-theme^="soft-"] .page-subtitle {
    color: var(--muted);
}

[data-theme^="soft-"] .section-title-sm {
    color: var(--text);
}

[data-theme^="soft-"] .section-desc {
    color: var(--muted);
}

[data-theme^="soft-"] .stat-card {
    background: var(--panel);
    border-color: var(--border-soft);
}

[data-theme^="soft-"] .stat-value {
    color: var(--text);
}

[data-theme^="soft-"] .stat-label {
    color: var(--muted);
}

[data-theme^="soft-"] .stat-subtitle {
    color: var(--muted);
}

/* ── Surface cards & empty states ────────────────────────────────────────── */
[data-theme^="soft-"] .surface-card {
    background: var(--panel);
    border-color: var(--border-soft);
}

[data-theme^="soft-"] .surface-head {
    color: var(--text);
    border-bottom-color: var(--border-soft);
}

[data-theme^="soft-"] .empty-panel {
    color: var(--muted);
}

[data-theme^="soft-"] .empty-icon {
    color: var(--muted);
    border-color: var(--border-soft);
}

[data-theme^="soft-"] .empty-copy {
    color: var(--muted);
}

[data-theme^="soft-"] .quick-button {
    background: var(--panel);
    border-color: var(--border-soft);
    color: var(--text);
}

[data-theme^="soft-"] .quick-button:hover {
    background: var(--panel-strong);
}

/* ── Chat ────────────────────────────────────────────────────────────────── */
[data-theme^="soft-"] .chat-thread {
    background: var(--panel);
}

[data-theme^="soft-"] .chat-bubble {
    background: var(--panel-strong);
    border-color: var(--border);
    color: var(--text);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

[data-theme^="soft-"] .chat-message.user .chat-bubble {
    background: var(--theme-active-pill);
    border-color: var(--theme-active-pill-border);
    color: var(--text);
}

[data-theme^="soft-"] .chat-scope-chip {
    background: var(--panel);
    border-color: var(--border-soft);
    color: var(--text);
}

[data-theme^="soft-"] .chat-scope-card {
    background: var(--panel);
    border-color: var(--border-soft);
}

[data-theme^="soft-"] .chat-scope-title {
    color: var(--text);
}

[data-theme^="soft-"] .chat-scope-meta {
    color: var(--muted);
}

[data-theme^="soft-"] .chat-composer {
    background: var(--panel);
    border-top-color: var(--border);
}

[data-theme^="soft-"] .chat-composer textarea {
    background: var(--panel-strong);
    border-color: var(--border);
    color: var(--text);
}

[data-theme^="soft-"] .chat-composer textarea::placeholder {
    color: var(--muted);
}

[data-theme^="soft-"] .chat-composer-note {
    color: var(--muted);
}

[data-theme^="soft-"] .chat-citations-details {
    color: var(--muted);
}

[data-theme^="soft-"] .chat-citations-summary {
    color: var(--muted);
}

[data-theme^="soft-"] .chat-citation-item {
    background: var(--panel-strong);
    border-color: var(--border-soft);
}

[data-theme^="soft-"] .citation-index {
    color: var(--muted);
}

[data-theme^="soft-"] .citation-snippet {
    color: var(--muted);
}

[data-theme^="soft-"] .pipeline-result {
    background: var(--panel);
    border-color: var(--border-soft);
    color: var(--text);
}

/* ── Manage / tier cards ─────────────────────────────────────────────────── */
[data-theme^="soft-"] .manage-layout {
    background: var(--panel);
    border-color: var(--border-soft);
}

[data-theme^="soft-"] .manage-right {
    border-left-color: var(--border);
}

[data-theme^="soft-"] .manage-head {
    border-bottom-color: var(--border);
}

[data-theme^="soft-"] .manage-empty {
    color: var(--muted);
}

[data-theme^="soft-"] .tier-card {
    background: var(--panel);
    border-color: var(--border-soft);
}

[data-theme^="soft-"] .tier-badge {
    background: var(--panel-strong);
    border-color: var(--border);
    color: var(--muted);
}

[data-theme^="soft-"] .corpus-pill {
    background: var(--panel-strong);
    border-color: var(--border);
    color: var(--text);
}

/* ── Search ──────────────────────────────────────────────────────────────── */
[data-theme^="soft-"] .search-title {
    color: var(--text);
}

[data-theme^="soft-"] .search-subtitle {
    color: var(--muted);
}

[data-theme^="soft-"] .search-box input {
    background: var(--panel-strong);
    border-color: var(--border);
    color: var(--text);
}

[data-theme^="soft-"] .search-box input::placeholder {
    color: var(--muted);
}

[data-theme^="soft-"] .search-box .search-left,
[data-theme^="soft-"] .search-box .search-right {
    color: var(--muted);
}

/* ── Chat message settings audit stamp ─────────────────────────────────────── */
.chat-msg-settings {
    font-size: 10px;
    color: #475569;
    text-align: right;
    padding: 2px 6px 0;
    letter-spacing: 0.04em;
    font-family: monospace;
    opacity: 0.75;
}

/* ── sv-toast (confirm / info dialogs) ─────────────────────────────────────── */
.sv-toast-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: sv-toast-fade-in 0.15s ease;
}

@keyframes sv-toast-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.sv-toast-box {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 4px 12px rgba(0, 0, 0, .3);
    padding: 1.5rem 1.75rem;
    min-width: 300px;
    max-width: min(440px, calc(100vw - 2rem));
    animation: sv-toast-slide-up 0.18s ease;
}

@keyframes sv-toast-slide-up {
    from {
        transform: translateY(12px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.sv-toast-msg {
    font-size: .9rem;
    color: #e2e8f0;
    line-height: 1.55;
    margin-bottom: 1.25rem;
}

.sv-toast-actions {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
}

.sv-toast-btn {
    border: 0;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 600;
    padding: .5rem 1.1rem;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}

.sv-toast-btn--cancel {
    background: #334155;
    color: #94a3b8;
}

.sv-toast-btn--cancel:hover {
    background: #475569;
    color: #f1f5f9;
}

.sv-toast-btn--confirm {
    background: #dc2626;
    color: #fff;
}

.sv-toast-btn--confirm:hover {
    background: #ef4444;
}