:root {
    --ink: #172033;
    --muted: #667085;
    --line: #d9e0ea;
    --surface: #f6f8fb;
    --panel: #ffffff;
    --brand: #0f766e;
    --accent: #f59e0b;
    --danger: #b42318;
    --ok: #027a48;
    --info: #175cd3;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--surface);
    font-family: Arial, sans-serif;
    line-height: 1.45;
}

.ops-shell {
    min-height: 100vh;
}

.ops-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
}

.ops-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}

.ops-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: #fff;
    background: var(--brand);
}

.ops-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ops-nav a {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.ops-nav a.active {
    color: #fff;
    border-color: var(--brand);
    background: var(--brand);
}

.ops-main {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.ops-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.ops-heading h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: 0;
}

.ops-heading p {
    max-width: 760px;
    margin: 8px 0 0;
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 rgba(2, 122, 72, 0.45);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 8px rgba(2, 122, 72, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(2, 122, 72, 0);
    }
}

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

.metric,
.panel,
.agent-card,
.task-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.metric {
    padding: 16px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    line-height: 1;
}

.ops-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
    gap: 16px;
}

.ops-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 16px;
}

.ops-sidebar {
    position: sticky;
    top: 84px;
    align-self: start;
}

.panel {
    min-width: 0;
    padding: 16px;
}

.panel h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

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

.agent-card {
    min-height: 180px;
    padding: 14px;
}

.empty-state {
    border: 1px dashed rgba(148, 163, 184, 0.45);
    border-radius: 8px;
    color: var(--muted);
    padding: 18px;
}

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

.workspace-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
}

.workspace-card h3 {
    margin: 0 0 10px;
    font-size: 15px;
}

.workspace-stats,
.agent-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.workspace-stats span,
.agent-meta span {
    padding: 5px 7px;
    border-radius: 999px;
    background: #f2f4f7;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.agent-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.agent-head h3 {
    margin: 0;
    font-size: 16px;
}

.agent-role,
.small-muted {
    color: var(--muted);
    font-size: 13px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.tag {
    padding: 4px 7px;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--info);
    font-size: 12px;
    font-weight: 700;
}

.mini-list {
    display: grid;
    gap: 4px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 12px;
}

.badge {
    align-self: start;
    padding: 4px 7px;
    border-radius: 999px;
    color: #fff;
    background: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.badge.completed,
.badge.healthy,
.badge.online {
    background: var(--ok);
}

.badge.running,
.badge.waiting,
.badge.busy {
    background: var(--info);
}

.badge.failed,
.badge.error {
    background: var(--danger);
}

.workflow-graph {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 14px;
    align-items: center;
    padding: 18px 0;
}

.node {
    position: relative;
    min-height: 92px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.node.completed {
    border-color: rgba(2, 122, 72, 0.28);
}

.node.running,
.node.waiting {
    border-color: rgba(23, 92, 211, 0.32);
    animation: nodeGlow 1.8s ease-in-out infinite;
}

@keyframes nodeGlow {
    50% {
        box-shadow: 0 0 0 4px rgba(23, 92, 211, 0.08);
    }
}

.progress-track {
    height: 6px;
    margin: 10px 0;
    overflow: hidden;
    border-radius: 999px;
    background: #eef2f6;
}

.progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
    transition: width 280ms ease;
}

.node::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -15px;
    width: 15px;
    height: 2px;
    background: var(--accent);
}

.node:last-child::after {
    display: none;
}

.node strong {
    display: block;
    margin-bottom: 6px;
}

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

.task-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 12px;
    width: 100%;
    text-align: left;
}

.task-row h3 {
    margin: 0 0 4px;
    font-size: 15px;
}

.task-button {
    cursor: pointer;
    font: inherit;
}

.task-button:hover {
    border-color: var(--brand);
}

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

.inspector-head h2 {
    margin-bottom: 4px;
}

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

.detail-grid div {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.detail-grid dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.detail-grid dd {
    margin: 4px 0 0;
    font-weight: 700;
}

.timeline {
    display: grid;
    gap: 10px;
    max-height: 560px;
    overflow: auto;
}

.timeline-item {
    display: grid;
    grid-template-columns: 94px 1fr;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.timeline-item time {
    color: var(--muted);
    font-size: 12px;
}

.message-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.message-row strong {
    display: block;
    font-size: 13px;
}

.counter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.counter-row:last-child {
    border-bottom: 0;
}

.counter-row span {
    color: var(--muted);
    font-size: 13px;
}

.counter-row strong {
    font-size: 14px;
}

.error-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid rgba(180, 35, 24, 0.22);
    border-radius: 8px;
    background: #fff6f5;
}

.error-banner[hidden] {
    display: none;
}

.offline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.retry-btn {
    border: 1px solid var(--danger);
    border-radius: 6px;
    background: #fff;
    color: var(--danger);
    padding: 8px 10px;
    font-weight: 800;
}

.skeleton-row {
    height: 48px;
    border-radius: 8px;
    background: linear-gradient(90deg, #eef2f6, #f8fafc, #eef2f6);
    background-size: 220% 100%;
    animation: skeleton 1.3s ease-in-out infinite;
}

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

@media (max-width: 980px) {
    .metrics-grid,
    .agent-grid,
    .ops-grid,
    .workflow-graph,
    .workspace-grid,
    .ops-layout {
        grid-template-columns: 1fr;
    }

    .node::after {
        display: none;
    }

    .ops-sidebar {
        position: static;
    }
}

@media (max-width: 680px) {
    .ops-topbar,
    .ops-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .ops-main {
        width: min(100% - 24px, 1280px);
    }
}
