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

:root {
    --bg: #0d0f12;
    --bg-2: #12161b;
    --panel: #171c22;
    --panel-2: #101419;
    --surface: #1d232a;
    --surface-2: #242b33;
    --line: #303945;
    --line-soft: rgba(174, 190, 204, 0.13);
    --text: #eef3f7;
    --muted: #a6b3be;
    --subtle: #717f8b;
    --teal: #2dd4bf;
    --blue: #60a5fa;
    --green: #7ddf8d;
    --amber: #f2c94c;
    --red: #ff7a7a;
    --focus: rgba(96, 165, 250, 0.28);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

body {
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(180deg, rgba(22, 28, 34, 0.98) 0%, rgba(13, 15, 18, 1) 32%),
        var(--bg);
    color: var(--text);
    line-height: 1.5;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
select,
input,
textarea {
    min-width: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.container {
    width: min(100%, 1760px);
    margin: 0 auto;
    padding: calc(14px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 76px;
    padding: 16px 18px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(29, 35, 42, 0.94), rgba(18, 22, 27, 0.94));
    box-shadow: var(--shadow);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.eyebrow,
.tile-label {
    color: var(--teal);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

header h1 {
    color: var(--text);
    font-size: clamp(1.45rem, 2vw, 1.95rem);
    font-weight: 760;
    letter-spacing: 0;
}

.version {
    align-self: center;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.73rem;
    font-weight: 700;
}

.meta-text {
    color: var(--subtle);
    font-size: 0.78rem;
    white-space: nowrap;
}

.status-badge,
.mini-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-badge.healthy,
.mini-pill.ok { border-color: rgba(125, 223, 141, 0.35); background: rgba(125, 223, 141, 0.12); color: var(--green); }
.status-badge.degraded,
.mini-pill.warn { border-color: rgba(242, 201, 76, 0.35); background: rgba(242, 201, 76, 0.12); color: var(--amber); }
.status-badge.error,
.mini-pill.err { border-color: rgba(255, 122, 122, 0.35); background: rgba(255, 122, 122, 0.12); color: var(--red); }
.status-badge.unavailable { color: var(--muted); }

.status-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(18, 22, 27, 0.88);
}

.status-banner.healthy { border-color: rgba(125, 223, 141, 0.25); }
.status-banner.degraded { border-color: rgba(242, 201, 76, 0.25); }
.status-banner.error { border-color: rgba(255, 122, 122, 0.25); }

.status-banner strong {
    display: block;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 820;
}

.status-banner span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.78rem;
}

.status-banner-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}

.command-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.command-tile {
    min-height: 92px;
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(18, 22, 27, 0.82);
}

.command-tile strong {
    display: block;
    margin-top: 8px;
    color: var(--text);
    font-size: clamp(1rem, 1.4vw, 1.28rem);
    font-weight: 780;
    overflow-wrap: anywhere;
}

.command-tile small {
    display: block;
    margin-top: 2px;
    color: var(--subtle);
    font-size: 0.76rem;
}

nav.tabs {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    padding: 6px;
    overflow-x: auto;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(13, 15, 18, 0.92);
    backdrop-filter: blur(12px);
    scrollbar-width: none;
}

nav.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 720;
    white-space: nowrap;
}

.tab-btn:hover {
    border-color: var(--line-soft);
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    border-color: rgba(45, 212, 191, 0.34);
    background: rgba(45, 212, 191, 0.1);
    color: #d7fffa;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel {
    margin-bottom: 14px;
    padding: 15px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(23, 28, 34, 0.92);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
    min-width: 0;
}

.panel .panel {
    background: rgba(16, 20, 25, 0.74);
    box-shadow: none;
}

.panel h2 {
    margin-bottom: 12px;
    color: #d9e3ea;
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.panel h3 {
    margin-bottom: 8px;
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 760;
}

.panel-subtitle {
    margin-top: 3px;
    color: var(--subtle);
    font-size: 0.78rem;
}

.grid-2,
.grid-3 {
    display: grid;
    gap: 14px;
    align-items: start;
}

.grid-2 > *,
.grid-3 > *,
.cards-grid > *,
.controls-grid > *,
.controls-list > * {
    min-width: 0;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-main-grid { align-items: stretch; }

.cards-grid,
.controls-list,
.controls-grid {
    display: grid;
    gap: 10px;
}

.cards-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.controls-list { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.controls-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.card,
.control-card,
.control-discovery-card,
.ops-note,
.gpu-item {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(16, 20, 25, 0.82);
}

.card,
.control-card,
.control-discovery-card {
    padding: 12px;
}

.card:hover,
.control-discovery-card:hover {
    border-color: rgba(166, 179, 190, 0.26);
    background: rgba(29, 35, 42, 0.92);
}

.card .card-title,
.control-discovery-card .cd-title {
    margin-bottom: 5px;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 780;
    overflow-wrap: anywhere;
}

.card .card-status,
.control-discovery-card .cd-method {
    color: var(--muted);
    font-size: 0.73rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.card .card-meta,
.control-discovery-card .cd-desc {
    margin-top: 7px;
    color: var(--subtle);
    font-size: 0.74rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.card-status.healthy,
.card-status.online { color: var(--green); }
.card-status.degraded { color: var(--amber); }
.card-status.error,
.card-status.offline { color: var(--red); }
.card-status.unavailable { color: var(--subtle); }

.lens-card {
    min-height: 104px;
}

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

.timeline-item {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(16, 20, 25, 0.72);
}

.timeline-item > span {
    width: 9px;
    height: 9px;
    margin-top: 6px;
    border-radius: 999px;
    background: var(--teal);
    box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.11);
}

.timeline-item strong {
    display: block;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 820;
}

.timeline-item small {
    display: block;
    margin-top: 1px;
    color: var(--subtle);
    font-size: 0.72rem;
}

.timeline-item p {
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.76rem;
    overflow-wrap: anywhere;
}

.resource-row {
    display: grid;
    grid-template-columns: minmax(64px, 0.3fr) minmax(120px, 1fr) minmax(70px, 0.35fr);
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.8rem;
}

.resource-row span:first-child {
    color: var(--muted);
    font-weight: 720;
}

.resource-row span:last-child {
    color: var(--text);
    text-align: right;
}

.bar-bg {
    height: 9px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 999px;
    background: #0b0e12;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--teal), var(--blue));
    transition: width 0.3s ease;
}

.bar-fill.warn { background: var(--amber); }
.bar-fill.crit { background: var(--red); }

.gpu-list { margin-top: 10px; }
.gpu-item {
    margin-bottom: 7px;
    padding: 9px;
    color: var(--muted);
    font-size: 0.76rem;
}
.gpu-item .gpu-name {
    margin-bottom: 3px;
    color: var(--text);
    font-weight: 780;
}

.filter-row,
.chat-input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0f1318;
    color: var(--text);
    font-size: 0.82rem;
}

input,
select {
    min-height: 40px;
    padding: 8px 10px;
}

textarea {
    width: 100%;
    min-height: 92px;
    padding: 10px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #65727e;
}

button {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid rgba(96, 165, 250, 0.28);
    border-radius: 6px;
    background: #1e3a4b;
    color: #e7faff;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 780;
}

button:hover {
    background: #24516a;
    border-color: rgba(96, 165, 250, 0.44);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.control-card input,
.control-card select,
.control-card textarea {
    width: 100%;
    margin-bottom: 8px;
}

.control-card label,
.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.78rem;
}

.control-card button {
    width: 100%;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-head h2 { margin-bottom: 0; }

.ops-note-list {
    display: grid;
    gap: 9px;
}

.ops-note {
    display: grid;
    grid-template-columns: minmax(108px, 0.32fr) minmax(0, 1fr);
    gap: 10px;
    padding: 10px 11px;
    font-size: 0.8rem;
}

.ops-note strong {
    color: var(--text);
    font-weight: 780;
}

.ops-note span {
    min-width: 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.panel-mini { margin-top: 14px; }
.compact-table .data-table td { max-width: 260px; }

.route-diagnostics-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 14px;
    margin: 12px 0;
}

.route-diagnostics-grid h3,
.panel-mini h3 {
    margin-bottom: 8px;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 820;
}

.route-plan-card {
    cursor: pointer;
}

.route-plan-card:focus,
.route-plan-card:hover {
    border-color: rgba(45, 212, 191, 0.38);
}

.compact-head {
    align-items: center;
    margin-bottom: 8px;
}

.compact-head h3 {
    margin: 0;
}

.action-buttons {
    margin-top: 8px;
    gap: 8px;
}

.action-buttons button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.json-view {
    max-height: 420px;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0b0e12;
    color: #cad6df;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
    font-size: 0.76rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

@media (max-width: 820px) {
    .route-diagnostics-grid {
        grid-template-columns: 1fr;
    }
}

.table-wrap {
    max-width: 100%;
    overflow: auto;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(13, 15, 18, 0.38);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    background: #14191f;
    color: var(--muted);
    font-weight: 800;
    text-align: left;
    white-space: nowrap;
}

.data-table td {
    max-width: 420px;
    padding: 9px 10px;
    border-bottom: 1px solid rgba(174, 190, 204, 0.08);
    color: #d4dee6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tr:hover td {
    background: rgba(45, 212, 191, 0.055);
}

.data-table .empty {
    padding: 22px;
    color: var(--subtle);
    text-align: center;
}

.data-table td pre {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-messages {
    min-height: 320px;
    max-height: 520px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0b0e12;
}

.ops-chat { min-height: 430px; }

.session-chat-panel .panel-subtitle {
    max-width: 68ch;
}

.session-telemetry {
    display: grid;
    gap: 10px;
}

.session-telemetry-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.session-telemetry-card {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    padding: 10px;
    background: rgba(15, 23, 42, 0.34);
}

.session-telemetry-label {
    font-size: 0.72rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.session-telemetry-value {
    margin-top: 4px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #e2e8f0;
}

.session-telemetry-meta {
    font-size: 0.78rem;
    color: #94a3b8;
}

.session-telemetry-chart {
    width: 100%;
    height: 100px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.14);
    overflow: hidden;
}

.session-telemetry-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: #94a3b8;
}

.session-telemetry-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-right: 6px;
}

.chat-input-row select,
.chat-input-row input {
    flex: 1 1 160px;
}

.chat-input-row button {
    flex: 0 0 auto;
}

.message {
    max-width: min(82%, 780px);
    margin-bottom: 9px;
    padding: 9px 11px;
    border-radius: 8px;
    font-size: 0.84rem;
    overflow-wrap: anywhere;
}

.message.user {
    margin-left: auto;
    border: 1px solid rgba(45, 212, 191, 0.28);
    background: rgba(45, 212, 191, 0.16);
    color: #e8fffb;
}

.message.agent {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
}

.message.system {
    max-width: 100%;
    color: var(--subtle);
    text-align: center;
    font-size: 0.75rem;
}

.message.agent {
    white-space: pre-wrap;
}

.message.user {
    white-space: pre-wrap;
}

.dropzone {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 148px;
    margin-bottom: 14px;
    border: 1px dashed rgba(45, 212, 191, 0.52);
    border-radius: 8px;
    background: rgba(45, 212, 191, 0.055);
    cursor: pointer;
}

.dropzone:hover,
.dropzone.is-dragging {
    border-color: var(--teal);
    background: rgba(45, 212, 191, 0.095);
}

.dropzone input { display: none; }
.dropzone-title {
    color: var(--text);
    font-size: 1rem;
    font-weight: 820;
}
.dropzone-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.78rem;
}

#tasks-stats .card {
    min-width: 120px;
    text-align: center;
}
#tasks-stats .card-title {
    color: var(--blue);
    font-size: 1.05rem;
}
#task-detail { min-height: 90px; }
#probe-status,
#live-indicator {
    color: var(--subtle);
    font-size: 0.78rem;
}
#live-indicator.live-on { color: var(--green); font-weight: 800; }
#live-indicator.live-off { color: var(--subtle); }
#models-body td { max-width: 300px; }
#connectors-grid .card { min-height: 82px; }

.command-palette {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: calc(70px + env(safe-area-inset-top)) 14px 14px;
}

.command-palette.open {
    display: flex;
}

.command-palette-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(10px);
}

.command-palette-panel {
    position: relative;
    width: min(100%, 680px);
    padding: 15px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(18, 22, 27, 0.98);
    box-shadow: var(--shadow);
}

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

.quick-action-grid button {
    min-height: 52px;
    text-align: left;
}

footer {
    margin-top: 14px;
    padding-bottom: 10px;
    color: var(--subtle);
    font-size: 0.75rem;
    text-align: center;
}

@media (max-width: 1120px) {
    .grid-3,
    .command-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
    header {
        align-items: flex-start;
        flex-direction: column;
    }
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 640px) {
    body { background: #0d0f12; }
    .container {
        padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
    }
    header {
        min-height: auto;
        padding: 14px;
    }
    .header-left {
        width: 100%;
        align-items: flex-start;
        justify-content: space-between;
    }
    .header-right {
        align-items: stretch;
        gap: 8px;
    }
    .status-banner {
        align-items: stretch;
        flex-direction: column;
    }
    .status-banner-actions {
        width: 100%;
    }
    .status-banner-actions button {
        flex: 1 1 0;
    }
    .status-badge,
    .mini-pill {
        min-height: 36px;
        padding: 7px 10px;
    }
    .meta-text {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        min-height: 36px;
        font-size: 0.72rem;
    }
    .command-tile {
        min-height: 84px;
        padding: 12px;
    }
    nav.tabs {
        top: 0;
        margin-left: -10px;
        margin-right: -10px;
        padding: 7px 10px;
        border-left: none;
        border-right: none;
        border-radius: 0;
        scroll-snap-type: x proximity;
    }
    .tab-btn {
        min-height: 44px;
        padding: 9px 13px;
        scroll-snap-align: start;
        font-size: 0.84rem;
    }
    .grid-3 { grid-template-columns: 1fr; }
    .panel { padding: 12px; }
    .ops-note { grid-template-columns: 1fr; }
    .resource-row { grid-template-columns: 1fr; }
    .resource-row span:last-child { text-align: left; }
    .filter-row,
    .chat-input-row {
        gap: 9px;
    }
    .filter-row > *,
    .chat-input-row > *,
    .control-card button,
    .section-head button {
        flex: 1 1 100%;
        width: 100%;
    }
    input,
    select,
    textarea,
    button {
        min-height: 44px;
        font-size: 16px;
    }
    textarea {
        min-height: 120px;
    }
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }
    .chat-messages,
    .ops-chat {
        min-height: 360px;
        max-height: 54vh;
    }
    .data-table {
        min-width: 640px;
    }
    .table-wrap {
        -webkit-overflow-scrolling: touch;
    }
    .dropzone {
        min-height: 132px;
        text-align: center;
    }
    .quick-action-grid {
        grid-template-columns: 1fr;
    }
    .command-palette {
        align-items: stretch;
        padding: calc(18px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
    }
    .command-palette-panel {
        max-height: calc(100vh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        overflow: auto;
    }
    .message { max-width: 100%; }
}

@media (max-width: 380px) {
    .command-strip { grid-template-columns: 1fr; }
}

/* Level 5 operator finish: clearer hierarchy, mobile-first density, premium control-room polish. */
:root {
    --bg: #07090c;
    --bg-2: #0c1116;
    --panel: #111820;
    --panel-2: #0b1117;
    --surface: #151e27;
    --surface-2: #1b2632;
    --line: #293544;
    --line-soft: rgba(177, 194, 209, 0.14);
    --text: #f2f6f9;
    --muted: #a8b5c1;
    --subtle: #718191;
    --teal: #28d6c3;
    --blue: #69a7ff;
    --green: #86e38d;
    --amber: #f0c95b;
    --red: #ff7777;
    --violet: #b9a1ff;
    --focus: rgba(105, 167, 255, 0.36);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

body {
    background:
        linear-gradient(180deg, rgba(7, 9, 12, 0.86), rgba(7, 9, 12, 1) 34%),
        linear-gradient(120deg, rgba(40, 214, 195, 0.08), transparent 30%),
        linear-gradient(240deg, rgba(185, 161, 255, 0.08), transparent 36%),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 72px),
        #07090c;
}

.container {
    width: min(100%, 1640px);
}

header {
    position: relative;
    overflow: hidden;
    border-color: rgba(177, 194, 209, 0.18);
    background:
        linear-gradient(180deg, rgba(21, 30, 39, 0.96), rgba(10, 15, 21, 0.96)),
        var(--panel);
}

header::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--teal), var(--blue), var(--violet));
}

header h1 {
    font-weight: 820;
}

.version {
    border-radius: 7px;
    background: rgba(105, 167, 255, 0.08);
}

.status-badge::before,
.mini-pill::before {
    content: "";
    width: 7px;
    height: 7px;
    margin-right: 7px;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 12px currentColor;
}

.command-strip {
    gap: 12px;
}

.command-tile {
    position: relative;
    overflow: hidden;
    border-color: rgba(177, 194, 209, 0.16);
    background:
        linear-gradient(180deg, rgba(23, 33, 43, 0.9), rgba(11, 17, 23, 0.92));
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.command-tile::after {
    content: "";
    position: absolute;
    inset: auto 12px 0;
    height: 2px;
    background: linear-gradient(90deg, var(--teal), var(--blue), transparent);
    opacity: 0.74;
}

.tile-label,
.eyebrow {
    letter-spacing: 0.07em;
}

nav.tabs {
    top: 8px;
    border-color: rgba(177, 194, 209, 0.14);
    background: rgba(8, 12, 17, 0.88);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.tab-btn {
    border-radius: 7px;
}

.tab-btn.active {
    border-color: rgba(40, 214, 195, 0.42);
    background:
        linear-gradient(180deg, rgba(40, 214, 195, 0.16), rgba(105, 167, 255, 0.08));
    color: #effffc;
}

.panel {
    border-color: rgba(177, 194, 209, 0.14);
    background:
        linear-gradient(180deg, rgba(17, 24, 32, 0.94), rgba(10, 16, 22, 0.94));
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.panel h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #e8f0f5;
}

.panel h2::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: linear-gradient(135deg, var(--teal), var(--blue));
}

.card,
.control-card,
.control-discovery-card,
.ops-note,
.gpu-item,
.session-telemetry-card,
.timeline-item {
    border-color: rgba(177, 194, 209, 0.13);
    background: rgba(11, 17, 23, 0.78);
}

.card {
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
    background: rgba(113, 129, 145, 0.5);
}

.card:has(.card-status.healthy)::before,
.card:has(.card-status.online)::before {
    background: var(--green);
}

.card:has(.card-status.degraded)::before {
    background: var(--amber);
}

.card:has(.card-status.error),
.card:has(.card-status.offline) {
    border-color: rgba(255, 119, 119, 0.18);
}

.card:has(.card-status.error)::before,
.card:has(.card-status.offline)::before {
    background: var(--red);
}

.card:hover,
.control-discovery-card:hover {
    transform: translateY(-1px);
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button {
    border-color: rgba(105, 167, 255, 0.36);
    background:
        linear-gradient(180deg, rgba(38, 73, 94, 0.95), rgba(27, 53, 70, 0.95));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

button:hover {
    background:
        linear-gradient(180deg, rgba(45, 89, 116, 0.98), rgba(32, 67, 88, 0.98));
}

input,
select,
textarea {
    border-color: rgba(177, 194, 209, 0.2);
    background: rgba(7, 11, 15, 0.92);
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(105, 167, 255, 0.58);
}

.json-view,
.chat-messages,
.table-wrap {
    border-color: rgba(177, 194, 209, 0.13);
    background: rgba(5, 8, 12, 0.78);
}

.data-table th {
    background: rgba(16, 23, 31, 0.96);
}

.data-table tr:hover td {
    background: rgba(105, 167, 255, 0.055);
}

.message.user {
    background: rgba(40, 214, 195, 0.15);
}

.message.agent {
    background: rgba(21, 30, 39, 0.92);
}

.dropzone {
    background:
        linear-gradient(180deg, rgba(40, 214, 195, 0.08), rgba(105, 167, 255, 0.05));
}

.command-palette-panel {
    background: rgba(11, 17, 23, 0.98);
}

@media (max-width: 900px) {
    nav.tabs {
        top: 0;
    }

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

@media (max-width: 640px) {
    .container {
        padding-bottom: calc(78px + env(safe-area-inset-bottom));
    }

    header {
        border-radius: 10px;
    }

    .command-strip {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .command-tile {
        min-height: 88px;
    }

    nav.tabs {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 40;
        margin: 0;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
        border-right: none;
        border-bottom: none;
        border-left: none;
        border-radius: 0;
        background: rgba(7, 10, 14, 0.96);
    }

    .tab-btn {
        min-width: 96px;
        min-height: 46px;
    }

    .panel {
        border-radius: 10px;
    }

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

    .status-banner-actions button,
    .filter-row > button,
    .chat-input-row > button {
        min-height: 48px;
    }
}

/* Product surface pass: stronger operator hierarchy, better iOS ergonomics, less demo-console feel. */
.operator-shell {
    --steel: #8fa1b3;
    --graphite: #0a0d11;
    --plum: #a98df3;
    --cyan-soft: rgba(40, 214, 195, 0.14);
    --blue-soft: rgba(105, 167, 255, 0.12);
    --plum-soft: rgba(169, 141, 243, 0.1);
    background:
        linear-gradient(180deg, rgba(6, 8, 11, 0.96), rgba(8, 12, 16, 1) 42%),
        linear-gradient(90deg, rgba(40, 214, 195, 0.06), transparent 28%, rgba(169, 141, 243, 0.055) 72%, transparent),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 80px),
        #07090c;
}

.operator-shell .container {
    padding-top: calc(18px + env(safe-area-inset-top));
}

.operator-shell header,
.operator-shell .status-banner,
.operator-shell nav.tabs,
.operator-shell .panel,
.operator-shell .command-tile {
    backdrop-filter: blur(18px);
}

.operator-shell header {
    min-height: 86px;
    padding: 18px 20px;
    border-color: rgba(190, 207, 220, 0.18);
    background:
        linear-gradient(180deg, rgba(19, 27, 36, 0.98), rgba(8, 12, 17, 0.98)),
        linear-gradient(90deg, var(--cyan-soft), transparent 45%, var(--plum-soft));
}

.operator-shell header::after {
    content: "";
    position: absolute;
    inset: auto 18px 0 18px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(40, 214, 195, 0.5), rgba(105, 167, 255, 0.45), transparent);
}

.operator-shell .eyebrow {
    color: #9deee5;
}

.operator-shell header h1 {
    line-height: 1.05;
}

.operator-shell .header-right {
    align-items: flex-end;
    flex-direction: column;
    gap: 8px;
}

.operator-shell .command-strip {
    grid-template-columns: 1.15fr 1fr 1fr 0.9fr;
    margin: 14px 0;
}

.operator-shell .command-tile {
    min-height: 104px;
    padding: 15px 16px;
}

.operator-shell .command-tile strong {
    margin-top: 10px;
    font-size: clamp(1.08rem, 1.55vw, 1.42rem);
}

.operator-shell .command-tile small {
    color: #8998a7;
}

.operator-shell .status-banner {
    min-height: 66px;
    margin-bottom: 14px;
    padding: 13px 15px;
    border-color: rgba(190, 207, 220, 0.16);
    background:
        linear-gradient(90deg, rgba(40, 214, 195, 0.08), rgba(105, 167, 255, 0.05), rgba(169, 141, 243, 0.05)),
        rgba(9, 14, 19, 0.9);
}

.operator-shell .status-banner-actions button,
.operator-shell .section-head button,
.operator-shell .filter-row button,
.operator-shell .chat-input-row button {
    flex: 0 0 auto;
}

.operator-shell nav.tabs {
    gap: 6px;
    padding: 7px;
}

.operator-shell .tab-btn {
    min-height: 42px;
    padding-inline: 13px;
}

.operator-shell .tab-btn.active {
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.035), 0 8px 24px rgba(40, 214, 195, 0.08);
}

.operator-shell main {
    display: block;
}

.operator-shell .panel {
    padding: 16px;
}

.operator-shell .panel h2 {
    font-size: 0.82rem;
    color: #eef5f8;
}

.operator-shell .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.operator-shell #agents-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.operator-shell .card,
.operator-shell .control-card,
.operator-shell .control-discovery-card,
.operator-shell .ops-note,
.operator-shell .timeline-item {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}

.operator-shell .card .card-title {
    font-size: 0.9rem;
}

.operator-shell .card .card-status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    margin-top: 4px;
}

.operator-shell .card .card-status::before {
    content: "";
    width: 7px;
    height: 7px;
    margin-right: 7px;
    border-radius: 999px;
    background: currentColor;
}

.operator-shell .resource-row {
    min-height: 34px;
}

.operator-shell .bar-bg {
    height: 10px;
    background: rgba(3, 6, 10, 0.92);
}

.operator-shell .chat-messages {
    min-height: 420px;
}

.operator-shell .message {
    line-height: 1.45;
}

.operator-shell .dropzone {
    min-height: 168px;
}

.operator-shell .dropzone-title {
    font-size: 1.08rem;
}

.operator-shell .json-view {
    max-height: 520px;
}

.operator-shell footer {
    color: #6f7f8e;
}

@media (min-width: 1260px) {
    .operator-shell #tab-overview > .panel:nth-of-type(2),
    .operator-shell #tab-overview > .panel:nth-of-type(3),
    .operator-shell #tab-overview > .panel:nth-of-type(4) {
        margin-bottom: 16px;
    }

    .operator-shell #tab-bifrost .grid-3 {
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 0.9fr) minmax(0, 1.15fr);
    }
}

@media (max-width: 900px) {
    .operator-shell .command-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .operator-shell .header-right {
        align-items: flex-start;
        flex-direction: row;
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .operator-shell {
        background:
            linear-gradient(180deg, #080b0f, #0a0e13 48%, #07090c),
            #07090c;
    }

    .operator-shell .container {
        padding-right: calc(12px + env(safe-area-inset-right));
        padding-left: calc(12px + env(safe-area-inset-left));
    }

    .operator-shell header {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        min-height: 0;
        padding: 15px;
    }

    .operator-shell header,
    .operator-shell .command-tile,
    .operator-shell .status-banner,
    .operator-shell .panel {
        max-width: calc(100vw - 24px);
    }

    .operator-shell .header-left {
        justify-content: space-between;
    }

    .operator-shell .version {
        display: none;
    }

    .operator-shell .header-right {
        align-items: flex-start;
        flex-direction: column;
        justify-content: flex-start;
        gap: 7px;
        width: 100%;
    }

    .operator-shell .command-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .operator-shell .command-tile {
        min-width: 0;
        min-height: 92px;
        padding: 12px;
    }

    .operator-shell .command-tile strong {
        font-size: 1rem;
    }

    .operator-shell .status-banner {
        align-items: stretch;
        flex-direction: column;
    }

    .operator-shell .status-banner-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        min-width: 0;
    }

    .operator-shell .status-banner-actions button {
        min-width: 0;
        width: 100%;
        padding-inline: 8px;
        overflow-wrap: anywhere;
    }

    .operator-shell nav.tabs {
        gap: 8px;
        box-shadow: 0 -14px 32px rgba(0, 0, 0, 0.42);
    }

    .operator-shell .tab-btn {
        min-width: 104px;
        min-height: 50px;
        padding: 8px 10px;
    }

    .operator-shell .panel {
        padding: 14px;
    }

    .operator-shell .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .operator-shell .section-head button {
        width: 100%;
    }

    .operator-shell .filter-row,
    .operator-shell .chat-input-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .operator-shell .filter-row > *,
    .operator-shell .chat-input-row > * {
        width: 100%;
        max-width: none !important;
    }

    .operator-shell .resource-row {
        grid-template-columns: 1fr;
        gap: 6px;
        align-items: stretch;
    }

    .operator-shell .resource-row span:last-child {
        text-align: left;
    }

    .operator-shell .data-table {
        font-size: 0.76rem;
    }

    .operator-shell .data-table th,
    .operator-shell .data-table td {
        padding: 10px 9px;
    }

    .operator-shell .message {
        max-width: 94%;
    }

    .operator-shell .chat-messages {
        min-height: 360px;
        max-height: 62vh;
    }
}

@media (max-width: 480px) {
    .operator-shell .command-strip {
        grid-template-columns: 1fr;
    }

    .operator-shell .status-banner-actions {
        grid-template-columns: 1fr;
    }
}

.work-state-list {
    display: grid;
    gap: 10px;
}

.work-state-card {
    padding: 13px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(16, 20, 25, 0.74);
}

.work-state-top,
.work-state-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.work-state-progress {
    margin: 10px 0;
    color: var(--text);
    font-size: 0.84rem;
    overflow-wrap: anywhere;
}

.work-state-foot {
    justify-content: flex-start;
    flex-wrap: wrap;
    color: var(--subtle);
    font-size: 0.72rem;
}

.mini-btn {
    border: 1px solid var(--line-soft);
    background: rgba(16, 20, 25, 0.72);
    color: var(--muted);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.68rem;
    line-height: 1;
    cursor: pointer;
}

.mini-btn:hover {
    border-color: rgba(45, 212, 191, 0.52);
    color: var(--text);
}

.filter-row.compact {
    flex-wrap: nowrap;
    gap: 8px;
}

.filter-row.compact select {
    min-width: 120px;
}

.work-detail-panel {
    display: grid;
    gap: 12px;
}

.work-detail-card {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(16, 20, 25, 0.68);
    padding: 14px;
}

.work-detail-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.work-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.work-detail-grid div {
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 7px;
    padding: 8px;
    background: rgba(2, 6, 23, 0.28);
    min-width: 0;
}

.work-detail-grid span {
    display: block;
    color: var(--subtle);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0;
    margin-bottom: 4px;
}

.work-detail-grid strong {
    display: block;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.work-detail-timeline {
    margin-top: 12px;
}

.timeline-item span.healthy {
    background: #22c55e;
}

.timeline-item span.degraded {
    background: #f59e0b;
}

.timeline-item span.error {
    background: #ef4444;
}

.timeline-item span.unavailable {
    background: #64748b;
}

@media (max-width: 640px) {
    .work-state-top {
        align-items: flex-start;
        flex-direction: column;
    }

    .work-state-top .card-status {
        align-self: flex-start;
    }

    .filter-row.compact {
        width: 100%;
    }

    .filter-row.compact select,
    .filter-row.compact button {
        flex: 1;
    }

    .work-detail-head {
        flex-direction: column;
    }

    .work-detail-grid {
        grid-template-columns: 1fr;
    }
}
