:root {
    --bg-dark: #090d16;
    --bg-card: rgba(15, 23, 42, 0.75);
    --bg-card-hover: rgba(26, 36, 61, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #38bdf8;
    
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.25);
    --accent: #818cf8;
    --emerald: #34d399;
    --purple: #818cf8;
    --orange: #f97316;
    --yellow: #facc15;
    --red: #f43f5e;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Fira Code', monospace;
    
    --sidebar-width: 260px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(56, 189, 248, 0.06) 0%, transparent 40%),
        radial-gradient(circle at 90% 90%, rgba(249, 115, 22, 0.06) 0%, transparent 40%);
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(11, 15, 25, 0.95);
    backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
    margin-top: 4px;
}

.airgap-badge {
    background: rgba(52, 211, 153, 0.15);
    color: var(--emerald);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

/* Document Store row: personal vs org-wide doc_profile badges, and the
   per-row delete button (only rendered when the viewer is permitted to
   delete - admins, or the owner of their own non-org-wide document). */
.doc-profile-personal {
    background: rgba(129, 140, 248, 0.15);
    color: var(--accent);
    border: 1px solid rgba(129, 140, 248, 0.3);
}

.doc-profile-org {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.btn-delete-doc {
    background: rgba(244, 63, 94, 0.12);
    color: var(--red);
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 0.8rem;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.15s ease;
}

.btn-delete-doc:hover {
    background: rgba(244, 63, 94, 0.25);
}

.btn-delete-doc:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.15) 0%, rgba(249, 115, 22, 0.05) 100%);
    color: var(--primary);
    border-left: 3px solid var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

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

.cluster-status-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background: var(--emerald);
    box-shadow: 0 0 8px var(--emerald);
}

.status-title {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-sub {
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 30px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(9, 13, 22, 0.8);
    backdrop-filter: blur(10px);
}

.header-title h2 {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.header-subtitle {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

.domain-tag {
    background: rgba(129, 140, 248, 0.12);
    color: var(--accent);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid rgba(129, 140, 248, 0.3);
    font-family: monospace;
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Tab Contents */
.tab-content {
    display: none;
    padding: 24px 30px;
    flex: 1;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   AGENT OBSERVATORY STYLES (SPEEDOMETER GAUGE & ENHANCED FILTERS)
   ========================================================================== */

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

.obs-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.obs-diamond {
    color: var(--orange);
    font-size: 1.2rem;
}

.obs-main-heading {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #fff;
}

.obs-sub-heading {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-left: 8px;
}

.obs-timerange-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.time-btn-group {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.time-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.time-btn.active, .time-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.live-status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--emerald);
    background: rgba(52, 211, 153, 0.08);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 8px var(--emerald);
    animation: pulse 1.5s infinite;
}

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

/* Custom Date Range Picker Bar */
.date-range-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.date-range-bar label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.date-range-bar input[type="date"] {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

.btn-apply-date {
    background: var(--primary);
    color: #000;
    border: none;
    padding: 5px 14px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-weight: 600;
    cursor: pointer;
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
}

.orange-border::before { background: var(--orange); }
.yellow-border::before { background: var(--yellow); }
.purple-border::before { background: var(--purple); }
.cyan-border::before { background: var(--primary); }
.red-border::before { background: var(--red); }
.green-border::before { background: var(--emerald); }

.kpi-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 4px;
}

.orange-text { color: var(--orange); }
.yellow-text { color: var(--yellow); }
.purple-text { color: var(--purple); }
.cyan-text { color: var(--primary); }
.red-text { color: var(--red); }
.green-text { color: var(--emerald); }

.kpi-sub {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* Speedometer Gauge Styling */
.speedo-card {
    padding: 12px 16px 8px 16px;
}

.speedo-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.speedo-svg {
    width: 100%;
    max-height: 90px;
    overflow: visible;
}

#speedo-needle-group {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: 80px 80px;
}

#speedo-arc {
    transition: stroke-dashoffset 0.6s ease;
}

.speedo-readout {
    margin-top: -8px;
    width: 100%;
    max-width: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.speedo-readout .kpi-value {
    font-size: 1.5rem;
}

/* Mini donut widgets embedded inside small kpi-cards (Backend Split,
   Host CPU, Host Memory) - same idea as .speedo-card above but a ring
   instead of an arc gauge, and reused for both single-value gauges
   (CPU/Memory: filled % vs remaining) and 2-segment splits (Backend
   Split: RAG vs SQL), driven entirely by real /api/observatory data. */
.donut-kpi-card {
    padding: 12px 16px 10px 16px;
    align-items: center;
}

.donut-mini-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 2px auto 6px auto;
}

.donut-mini-svg {
    width: 80px;
    height: 80px;
}

.donut-mini-svg circle {
    transition: stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease;
}

.donut-mini-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.donut-mini-center .kpi-value {
    font-size: 1.15rem;
    margin-bottom: 0;
    line-height: 1;
}

.donut-kpi-card .kpi-title {
    text-align: center;
    margin-bottom: 4px;
}

.donut-kpi-card .kpi-sub {
    text-align: center;
}

.donut-mini-legend {
    display: flex;
    gap: 10px;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.donut-mini-legend .legend-box {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    margin-right: 3px;
}

/* Hourly Backend Split bar chart (bars generated dynamically in app.js,
   one per real hourly bucket from the server - see backend_split_hourly) */
.bs-bar-rag { fill: var(--yellow); }
.bs-bar-sql { fill: #38bdf8; }

/* Observatory Charts Grid (2x2) */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 18px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(8px);
}

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

.chart-title {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.chart-unit {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-dim);
}

.chart-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-box {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.green-box { background: var(--emerald); }
.cyan-box { background: var(--primary); }
.orange-box { background: var(--orange); }
.yellow-box { background: var(--yellow); }
.purple-box { background: var(--purple); }

.chart-body {
    width: 100%;
    height: 180px;
    position: relative;
}

.chart-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Chat Layout & Components */
.chat-container {
    display: flex;
    flex-direction: row;
    gap: 16px;
    height: calc(100vh - 120px);
}

.chat-sidebar {
    width: 25%;
    max-width: 280px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px;
    overflow: hidden;
}

.new-chat-btn {
    background: var(--primary);
    border: none;
    color: #000;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.new-chat-btn:hover {
    opacity: 0.85;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.72rem;
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.chat-history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.chat-history-item.active {
    background: rgba(56, 189, 248, 0.12);
    border-color: var(--primary);
    color: var(--text-main);
}

.chat-history-item .history-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.chat-history-item .history-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
}

.chat-history-item .history-delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.chat-history-empty {
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 8px 10px;
    text-align: center;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-right: 10px;
    margin-bottom: 20px;
}

.message {
    display: flex;
    gap: 14px;
    max-width: 85%;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    color: #fff;
    box-shadow: 0 0 10px var(--primary-glow);
}

.message.user .avatar {
    background: linear-gradient(135deg, var(--purple) 0%, #ec4899 100%);
}

.message-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    line-height: 1.5;
    backdrop-filter: blur(10px);
}

.suggested-queries {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.chip-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    border-color: var(--primary);
}

.chat-input-area {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-wrapper {
    display: flex;
    gap: 10px;
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 0.78rem;
}

.send-btn {
    background: var(--primary);
    border: none;
    color: #000;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.send-btn:hover {
    transform: scale(1.05);
}

.input-options {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* File-attach button + chip (RAG Assistant chat) & Document Store upload */
.attach-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

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

.chat-attachment-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.8rem;
    color: var(--text-main);
    width: fit-content;
}

.chat-attachment-chip .attach-icon {
    font-size: 0.9rem;
}

.attach-status {
    color: var(--text-dim);
    font-size: 0.72rem;
}

.attach-status.attach-error {
    color: var(--red);
}

.attach-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 2px;
    line-height: 1;
}

.attach-remove:hover {
    color: var(--red);
}

p.attach-error {
    color: var(--red);
    font-size: 0.85rem;
}

.latency-indicator {
    margin-left: auto;
    color: var(--emerald);
    font-weight: 500;
}

/* Cards & Layout Grid */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    backdrop-filter: blur(12px);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.card h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group input, .form-group select, .form-group textarea {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
}

.btn {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
}

.btn-accent {
    background: linear-gradient(135deg, var(--emerald) 0%, var(--primary) 100%);
    color: #000;
}

/* GPU Grid */
.gpu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.gpu-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
}

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

.gpu-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.bar-container {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--emerald) 100%);
    transition: width 0.4s ease;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-value {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

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

.margin-top {
    margin-top: 24px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-top: 16px;
}

.res-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 16px;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border-color);
}

.res-num {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--emerald);
}

.res-lbl {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.placeholder-box {
    padding: 40px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.hidden {
    /* !important is intentional here: .hidden is a utility class meant to
       unconditionally hide an element regardless of what other display
       rules exist elsewhere in the stylesheet (e.g. .login-page sets
       display:flex with equal specificity - without !important, whichever
       rule appears later in file source order silently wins the cascade,
       which is exactly the bug this fixes: 2026-08-08 login-page redesign
       shipped a .login-page{display:flex} rule *after* this one in file
       order, so "hidden" was applied in the DOM but never actually hid
       the element - it kept covering the loaded dashboard underneath). */
    display: none !important;
}

/* --- Model Auto-Fitting & Host Setup CSS Additions --- */
.autofit-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.select-row {
    display: flex;
    gap: 12px;
}

.select-row select {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
}

.autofit-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.autofit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    font-family: var(--font-mono);
}

.autofit-table th, .autofit-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.autofit-table th {
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}

.fit-pass {
    background: rgba(52, 211, 153, 0.04);
}

.fit-fail {
    background: rgba(248, 113, 113, 0.04);
    opacity: 0.65;
}

.badge-pass {
    background: rgba(52, 211, 153, 0.2);
    color: #34d399;
    border: 1px solid #34d399;
    padding: 2px 6px;
    border-radius: 3px;
}

.badge-fail {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
    border: 1px solid #f87171;
    padding: 2px 6px;
    border-radius: 3px;
}

.quant-pill {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.reason-cell {
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* Local Auth Credentials Box */
.local-auth-card {
    background: rgba(129, 140, 248, 0.06);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.auth-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.auth-badge {
    background: rgba(129, 140, 248, 0.2);
    color: #818cf8;
    border: 1px solid #818cf8;
}

.auth-status-text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--emerald);
}

.auth-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.admin-credentials-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.cred-row {
    margin-bottom: 6px;
    color: var(--text-main);
}

.cred-row:last-child {
    margin-bottom: 0;
}

.highlight-pwd {
    color: #f97316;
    font-weight: 700;
    background: rgba(249, 115, 22, 0.15);
    padding: 2px 6px;
    border-radius: 3px;
}

.admin-tag {
    color: #34d399;
    font-weight: 600;
}

.pwd-toggle-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 2px;
    opacity: 0.7;
    vertical-align: middle;
}

.pwd-toggle-btn:hover {
    opacity: 1;
}

/* Host details list */
.host-details-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.detail-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.slot-item {
    background: rgba(56, 189, 248, 0.04);
    padding: 6px 12px;
    border-radius: 4px;
    border-left: 3px solid var(--primary);
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.slot-badge {
    background: rgba(56, 189, 248, 0.2);
    color: var(--primary);
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}



/* ============================================================
   Login Page (modern split-pane redesign)
   ============================================================ */

.login-page {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 12% 15%, rgba(56, 189, 248, 0.10) 0%, transparent 45%),
        radial-gradient(circle at 88% 85%, rgba(249, 115, 22, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 85% 15%, rgba(129, 140, 248, 0.08) 0%, transparent 40%);
    z-index: 100;
}

.login-shell {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    width: 100%;
    max-width: 960px;
    min-height: 600px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

/* Hero pane */
.login-hero {
    position: relative;
    display: flex;
    align-items: center;
    padding: 48px 40px;
    background:
        radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.16) 0%, transparent 55%),
        radial-gradient(circle at 85% 80%, rgba(129, 140, 248, 0.14) 0%, transparent 50%),
        linear-gradient(160deg, #0b1220 0%, #090d16 100%);
    border-right: 1px solid var(--border-color);
}

.login-hero-inner {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
}

.hero-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: var(--primary);
}

.hero-headline {
    font-family: var(--font-heading);
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-main);
}

.hero-sub {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text-muted);
    max-width: 34ch;
}

/* Engine map SVG */
.engine-map {
    width: 100%;
    max-width: 300px;
    margin: 8px 0 4px;
}

.engine-path {
    stroke-width: 2;
    stroke-dasharray: 4 5;
    opacity: 0.65;
    animation: dash-flow 2.4s linear infinite;
}
.path-gen    { stroke: var(--primary); }
.path-sql    { stroke: var(--accent); }
.path-rerank { stroke: var(--emerald); }

@keyframes dash-flow {
    to { stroke-dashoffset: -18; }
}

.engine-node rect, .engine-node circle {
    fill: rgba(255, 255, 255, 0.04);
    stroke-width: 1.5;
}
.node-gen rect    { stroke: var(--primary); }
.node-sql rect    { stroke: var(--accent); }
.node-rerank rect { stroke: var(--emerald); }
.node-answer circle {
    fill: rgba(52, 211, 153, 0.12);
    stroke: var(--emerald);
    stroke-width: 2;
    animation: node-pulse 2.4s ease-in-out infinite;
}

@keyframes node-pulse {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(52, 211, 153, 0)); }
    50%      { filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.55)); }
}

.engine-node text {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    fill: var(--text-muted);
}

.answer-check {
    stroke: var(--emerald);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 26;
    stroke-dashoffset: 26;
    animation: draw-check 0.7s ease-out 0.6s forwards;
}
@keyframes draw-check {
    to { stroke-dashoffset: 0; }
}

.hero-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
}
.hero-features li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.feature-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot-cyan    { background: var(--primary); box-shadow: 0 0 6px var(--primary-glow); }
.dot-indigo  { background: var(--accent); box-shadow: 0 0 6px rgba(129, 140, 248, 0.4); }
.dot-emerald { background: var(--emerald); box-shadow: 0 0 6px rgba(52, 211, 153, 0.4); }
.dot-orange  { background: var(--orange); box-shadow: 0 0 6px rgba(249, 115, 22, 0.4); }

/* Form pane */
.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 44px;
    background: var(--bg-card);
}

.login-card {
    width: 100%;
    max-width: 340px;
}

.login-card .brand {
    margin-bottom: 28px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(56, 189, 248, 0.10);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.login-heading {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.btn-block {
    width: 100%;
    display: block;
    text-align: center;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}
.btn-primary:hover {
    filter: brightness(1.08);
}

.sso-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-dim);
    font-size: 0.75rem;
}
.sso-divider::before, .sso-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}
/* Only show the divider when the SSO link right after it is actually visible */
.sso-divider:has(+ #sso-login-btn.hidden) {
    display: none;
}

.login-error {
    margin-top: 16px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.35);
    color: #fda4af;
    font-size: 0.82rem;
}

.login-footnote {
    margin-top: 24px;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
}

@media (max-width: 760px) {
    .login-shell { grid-template-columns: 1fr; max-width: 420px; min-height: 0; }
    .login-hero { display: none; }
    .login-form-panel { padding: 40px 28px; }
}

/* GPU / Resource Allocation - bar-list widget (Allocated vs Used per
   service). Styled to match the rest of the Observatory chart-cards. */
.gpu-alloc-card {
    gap: 0;
}

.gpu-alloc-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 3px 10px;
}

.barlist-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.barlist-group {
    padding: 10px 0;
}

.barlist-group-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-main);
    margin-bottom: 8px;
}

.barlist-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.barlist-row {
    display: grid;
    grid-template-columns: 68px 1fr auto;
    align-items: center;
    gap: 10px;
}

.barlist-row-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
}

.barlist-track {
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.barlist-fill {
    height: 100%;
    border-radius: 999px;
    width: 0%;
    transition: width 0.5s ease;
}

.orange-fill { background: var(--orange); }
.green-fill { background: var(--emerald); }

.barlist-value {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
    min-width: 64px;
}

.barlist-divider {
    height: 1px;
    background: var(--border-color);
}


/* ============================================================
   Observatory redesign additions (2026-08-10)
   - Row 1: 7 KPI cards in a single line
   - Row 2: 3 enlarged donut cards filling the row
   - Row 3: redesigned speedometer + Response Time chart, 2-col
   - Row 4/5: Backend Split Over Time / GPU Allocation, full width
   ============================================================ */

.kpi-row-7 {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
.kpi-row-7 .kpi-card {
    padding: 12px 10px;
}
.kpi-row-7 .kpi-title {
    font-size: 0.6rem;
    margin-bottom: 6px;
}
.kpi-row-7 .kpi-value {
    font-size: 1.3rem;
}
.kpi-row-7 .kpi-sub {
    font-size: 0.6rem;
}

.kpi-donut-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.donut-kpi-card-lg .donut-mini-wrap {
    width: 140px;
    height: 140px;
    margin: 4px auto 10px auto;
}
.donut-kpi-card-lg .donut-mini-svg {
    width: 140px;
    height: 140px;
}
.donut-kpi-card-lg .donut-mini-center .kpi-value {
    font-size: 1.9rem;
}
.donut-kpi-card-lg .kpi-title {
    font-size: 0.78rem;
}
.donut-kpi-card-lg .donut-mini-legend {
    font-size: 0.72rem;
    gap: 14px;
    margin-top: 2px;
}

.speedo-response-row {
    display: grid;
    grid-template-columns: 0.55fr 1.7fr;
    gap: 20px;
    margin-bottom: 20px;
}
.speedo-card-v2 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.speedo-container-v2 {
    width: 100%;
    max-width: 170px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.speedo-container-v2 .speedo-svg {
    width: 100%;
    height: auto;
    max-height: none;
    display: block;
}

/* Redesigned gauge: single contrasting accent (green), never blue, plus
   graduated tick marks/labels like the reference speedometer. */
.speedo-tick-mark {
    stroke: rgba(255, 255, 255, 0.28);
    stroke-width: 2;
}
.speedo-tick-label {
    fill: #64748b;
    font-size: 8px;
    font-family: var(--font-mono);
}
#speedo-arc {
    stroke: var(--emerald);
    transition: stroke-dashoffset 0.6s ease;
}
#speedo-needle-group {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: 80px 80px;
}
#speedo-needle-group polygon {
    fill: var(--emerald);
}
#speedo-needle-group circle {
    stroke: var(--emerald);
}

/* Full-width chart-card spanning both columns of .charts-grid */
.chart-card-full {
    grid-column: 1 / -1;
}

/* Compact height variants for the full-width rows (Backend Split Over
   Time / GPU Allocation) so they read as a slim strip, not a full-size
   chart-card stretched wide. */
.chart-card-compact .chart-body {
    height: 130px;
}
.chart-card-compact .chart-svg {
    width: 100%;
    height: 100%;
}
/* Backend Split Over Time: legend rides the title line instead of
   wrapping to its own row below the header (the generic .chart-legend
   rule elsewhere still puts it on its own line - this override is
   scoped to chart-card-compact only). */
.chart-card-compact .chart-header {
    gap: 14px;
}
.chart-card-compact .chart-header .chart-legend {
    margin-bottom: 0;
    margin-right: auto;
}
.chart-card-compact-alloc .barlist-body {
    margin-top: 2px;
    gap: 0;
}
.chart-card-compact-alloc .barlist-group {
    padding: 6px 0;
}
.chart-card-compact-alloc .barlist-group-label {
    margin-bottom: 4px;
}
.chart-card-compact-alloc .barlist-rows {
    gap: 4px;
}
.chart-card-compact-alloc .barlist-track {
    height: 5px;
}

@media (max-width: 1400px) {
    .kpi-row-7 {
        grid-template-columns: repeat(4, 1fr);
    }
    .kpi-donut-row {
        grid-template-columns: repeat(3, 1fr);
    }
    .speedo-response-row {
        grid-template-columns: 1fr;
    }
}
