/* ==========================================================================
   Operations console — layered on admin.css (same ink, Inter, indigo accent).
   Denser and quieter than the marketplace pages: this is where an admin
   debugs, so data leads and chrome recedes. Scoped under .ops.
   ========================================================================== */

.ops {
    --ops-ink: #0f172a;
    --ops-ink-2: #334155;
    --ops-muted: #64748b;
    --ops-line: #e2e8f0;
    --ops-line-soft: #eef2f7;
    --ops-surface: #ffffff;
    --ops-plane: #f8fafc;
    --ops-accent: #4f46e5;
    --ops-accent-wash: rgba(79, 70, 229, 0.07);
    /* Reserved status palette (never reused for a series). */
    --st-good: #0ca30c;      --st-good-ink: #0a6b0a;   --st-good-bg: #ecf8ec;
    --st-warn: #fab219;      --st-warn-ink: #8a5a00;   --st-warn-bg: #fff7e3;
    --st-crit: #d03b3b;      --st-crit-ink: #a52828;   --st-crit-bg: #fdeeee;
    --st-info: #4f46e5;      --st-info-ink: #3730a3;   --st-info-bg: #eef0ff;
    --st-neutral-ink: #475569; --st-neutral-bg: #f1f5f9;
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 6px;
    color: var(--ops-ink);
    font-feature-settings: "cv11", "ss01";
}

/* ---------- Page header ---------- */
.ops-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.ops-head h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}
.ops-head p {
    color: var(--ops-muted);
    margin: 0.25rem 0 0;
    max-width: 68ch;
}
.ops-crumbs {
    font-size: 0.85rem;
    color: var(--ops-muted);
    margin-bottom: 0.35rem;
}
.ops-crumbs a { color: var(--ops-muted); text-decoration: none; }
.ops-crumbs a:hover { color: var(--ops-accent); text-decoration: underline; }

/* ---------- Panels ---------- */
.ops-panel {
    background: var(--ops-surface);
    border: 1px solid var(--ops-line);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}
.ops-panel + .ops-panel { margin-top: 1rem; }
.ops-panel__title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}
.ops-panel__title h2 {
    font-size: 1rem;
    font-weight: 650;
    margin: 0;
}
.ops-panel__title .ops-hint { font-size: 0.82rem; color: var(--ops-muted); }
.ops-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(12, minmax(0, 1fr));
}
.ops-col-12 { grid-column: span 12; }
.ops-col-8 { grid-column: span 8; }
.ops-col-7 { grid-column: span 7; }
.ops-col-6 { grid-column: span 6; }
.ops-col-5 { grid-column: span 5; }
.ops-col-4 { grid-column: span 4; }
@media (max-width: 1100px) {
    .ops-col-8, .ops-col-7, .ops-col-6, .ops-col-5, .ops-col-4 { grid-column: span 12; }
}

/* ---------- KPI strip (compact — the data, not the tile, is the point) ---------- */
.ops-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    border: 1px solid var(--ops-line);
    border-radius: var(--radius-lg);
    background: var(--ops-surface);
    overflow: hidden;
}
.ops-kpi {
    padding: 0.95rem 1.1rem;
    border-right: 1px solid var(--ops-line-soft);
    min-width: 0;
}
.ops-kpi:last-child { border-right: 0; }
.ops-kpi__label { font-size: 0.8rem; color: var(--ops-muted); font-weight: 500; }
.ops-kpi__value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-top: 0.15rem;
}
.ops-kpi__sub { font-size: 0.78rem; color: var(--ops-muted); margin-top: 0.1rem; }
.ops-kpi__delta--up-bad, .ops-kpi__delta--down-good { color: var(--st-crit-ink); }
.ops-kpi__delta--up-good { color: var(--st-good-ink); }
.ops-kpi--alert .ops-kpi__value { color: var(--st-crit-ink); }

/* ---------- Status + service chips ---------- */
.ops-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}
.ops-status i { font-size: 0.8rem; }
.ops-status--good { color: var(--st-good-ink); background: var(--st-good-bg); }
.ops-status--good i { color: var(--st-good); }
.ops-status--warning { color: var(--st-warn-ink); background: var(--st-warn-bg); }
.ops-status--warning i { color: #c98500; }
.ops-status--critical { color: var(--st-crit-ink); background: var(--st-crit-bg); }
.ops-status--critical i { color: var(--st-crit); }
.ops-status--info { color: var(--st-info-ink); background: var(--st-info-bg); }
.ops-status--neutral { color: var(--st-neutral-ink); background: var(--st-neutral-bg); }

.ops-service {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 550;
    color: var(--ops-ink-2);
    white-space: nowrap;
}
.ops-service__dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 2px;
    background: var(--svc);
    flex: none;
}
.ops-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 550;
    color: var(--ops-ink-2);
    background: var(--ops-plane);
    border: 1px solid var(--ops-line);
    border-radius: var(--radius-sm);
    padding: 0.05rem 0.45rem;
}

/* Machine identifiers (job / run ids) — the one place monospace is used. */
.ops-id {
    font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 0.8rem;
    color: var(--ops-ink-2);
    word-break: break-all;
}

/* ---------- Filter bar ---------- */
.ops-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 1rem;
}
.ops-filters .form-control, .ops-filters .form-select {
    padding: 0.45rem 0.75rem;
    font-size: 0.875rem;
    width: auto;
    min-width: 150px;
}
.ops-filters .ops-search { min-width: 240px; flex: 1 1 240px; max-width: 360px; }
.ops-segmented {
    display: inline-flex;
    border: 1px solid var(--ops-line);
    border-radius: var(--radius-md);
    background: var(--ops-surface);
    padding: 3px;
    gap: 2px;
}
.ops-segmented a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 550;
    color: var(--ops-muted);
    text-decoration: none;
}
.ops-segmented a:hover { color: var(--ops-ink); background: var(--ops-plane); }
.ops-segmented a[aria-current="true"] { color: var(--ops-ink); background: var(--ops-accent-wash); }
.ops-check { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; color: var(--ops-ink-2); }

/* ---------- Tables (dense, no hover jump) ---------- */
.ops-table-wrap { overflow-x: auto; }
.ops-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}
.ops-table th {
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ops-muted);
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--ops-line);
    white-space: nowrap;
}
.ops-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--ops-line-soft);
    vertical-align: middle;
}
.ops-table tr:last-child td { border-bottom: 0; }
.ops-table .num { text-align: right; }
.ops-table tbody tr.is-link { cursor: pointer; }
.ops-table tbody tr.is-link:hover td { background: var(--ops-plane); }
.ops-table tbody tr.is-failed td:first-child { box-shadow: inset 3px 0 0 var(--st-crit); }
.ops-table a { color: var(--ops-ink); text-decoration: none; font-weight: 550; }
.ops-table a:hover { color: var(--ops-accent); text-decoration: underline; }
.ops-sub { display: block; font-size: 0.78rem; color: var(--ops-muted); font-weight: 400; }
.ops-clip { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ops-pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 0.9rem;
    font-size: 0.85rem;
    color: var(--ops-muted);
}
.ops-pager .btn { padding: 0.3rem 0.75rem; font-size: 0.85rem; }

.ops-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--ops-muted);
}
.ops-empty strong { display: block; color: var(--ops-ink); margin-bottom: 0.25rem; }

/* ---------- Definition list (facts panel) ---------- */
.ops-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1rem; margin: 0; font-size: 0.875rem; }
.ops-facts dt { color: var(--ops-muted); font-weight: 500; }
.ops-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Run timeline (the signature element) ----------
   A waterfall of the run's real steps: each row's bar is placed by when the
   step started and sized by how long it took, like a request trace. */
.ops-timeline { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.ops-timeline li {
    display: grid;
    grid-template-columns: 1.4rem minmax(0, 16rem) minmax(0, 1fr) 5.5rem;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0;
    border-bottom: 1px dashed var(--ops-line-soft);
}
.ops-timeline li:last-child { border-bottom: 0; }
.ops-timeline__icon { text-align: center; }
.ops-timeline__icon.ok { color: var(--st-good); }
.ops-timeline__icon.error { color: var(--st-crit); }
.ops-timeline__name { font-weight: 550; min-width: 0; }
.ops-timeline__name small { display: block; font-weight: 400; color: var(--ops-muted); overflow-wrap: anywhere; }
.ops-timeline__track { position: relative; height: 10px; background: var(--ops-line-soft); border-radius: 3px; }
.ops-timeline__bar {
    position: absolute;
    top: 0;
    bottom: 0;
    min-width: 3px;
    border-radius: 3px;
    background: var(--svc, var(--ops-accent));
}
.ops-timeline__bar.error { background: var(--st-crit); }
.ops-timeline__ms { text-align: right; color: var(--ops-muted); font-variant-numeric: tabular-nums; }
.ops-timeline__err { grid-column: 2 / -1; color: var(--st-crit-ink); font-size: 0.8rem; overflow-wrap: anywhere; }
@media (max-width: 720px) {
    .ops-timeline li { grid-template-columns: 1.4rem 1fr 4.5rem; }
    .ops-timeline__track { display: none; }
}

/* ---------- Callouts ---------- */
.ops-callout {
    border-radius: var(--radius-md);
    padding: 0.75rem 0.9rem;
    font-size: 0.875rem;
    border: 1px solid;
}
.ops-callout--crit { background: var(--st-crit-bg); border-color: #f4c7c7; color: var(--st-crit-ink); }
.ops-callout--warn { background: var(--st-warn-bg); border-color: #f5dea4; color: var(--st-warn-ink); }
.ops-callout--info { background: var(--ops-plane); border-color: var(--ops-line); color: var(--ops-ink-2); }
.ops-callout strong { display: block; margin-bottom: 0.15rem; }

/* ---------- Code / JSON ---------- */
.ops-code {
    position: relative;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-md);
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.55;
}
.ops-code pre { margin: 0; padding: 0.9rem 1rem; max-height: 520px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: inherit; }
.ops-code__tools { position: absolute; top: 0.4rem; right: 0.4rem; display: flex; gap: 0.3rem; }
.ops-code__tools button {
    border: 1px solid rgba(226, 232, 240, 0.25);
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    font-size: 0.72rem;
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.5rem;
}
.ops-code__tools button:hover { background: #1e293b; }
details.ops-disclose { border: 1px solid var(--ops-line); border-radius: var(--radius-md); }
details.ops-disclose > summary {
    cursor: pointer;
    padding: 0.6rem 0.85rem;
    font-weight: 600;
    font-size: 0.875rem;
    list-style: none;
    display: flex;
    justify-content: space-between;
}
details.ops-disclose > summary::-webkit-details-marker { display: none; }
details.ops-disclose > summary::after { content: "Show"; color: var(--ops-accent); font-weight: 500; }
details.ops-disclose[open] > summary::after { content: "Hide"; }
details.ops-disclose > .ops-disclose__body { padding: 0 0.85rem 0.85rem; }

/* Rendered content (quiz questions, learning-path modules) */
.ops-question { border: 1px solid var(--ops-line); border-radius: var(--radius-md); padding: 0.85rem 1rem; }
.ops-question + .ops-question { margin-top: 0.6rem; }
.ops-question__q { font-weight: 600; margin-bottom: 0.45rem; }
.ops-question ol { margin: 0 0 0.4rem; padding-left: 1.4rem; }
.ops-question li.is-correct { color: var(--st-good-ink); font-weight: 600; }
.ops-question li.is-correct::marker { color: var(--st-good); }
.ops-question__why { font-size: 0.82rem; color: var(--ops-muted); }

.ops-email-frame {
    width: 100%;
    min-height: 520px;
    border: 1px solid var(--ops-line);
    border-radius: var(--radius-md);
    background: #fff;
}
.ops-prose { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.6; max-width: 75ch; }

/* ---------- Charts ---------- */
.ops-chart { position: relative; height: 260px; }
.ops-chart--short { height: 200px; }
.ops-legend { display: flex; flex-wrap: wrap; gap: 0.9rem; font-size: 0.8rem; color: var(--ops-ink-2); margin-bottom: 0.5rem; }
.ops-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.ops-legend i { width: 0.65rem; height: 0.65rem; border-radius: 2px; display: inline-block; }

/* Horizontal share bars (top users / operations) — direct-labelled */
.ops-bars { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
/* Proportional columns so the bar keeps real width in narrow side panels. */
.ops-bars li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(4rem, 38%) auto; gap: 0.75rem; align-items: center; padding: 0.3rem 0; }
/* display:block — these are <span>s, and inline boxes ignore width/height,
   which left every bar empty. */
.ops-bars__track { display: block; height: 8px; background: var(--ops-line-soft); border-radius: 4px; overflow: hidden; }
.ops-bars__fill { display: block; height: 100%; background: #2a78d6; border-radius: 4px; }
.ops-bars__val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ops-ink-2); }

/* ---------- Attention list (Overview hero) ---------- */
.ops-attention { list-style: none; margin: 0; padding: 0; }
.ops-attention li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.9rem;
    align-items: center;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--ops-line-soft);
}
.ops-attention li:last-child { border-bottom: 0; }
.ops-attention__what { min-width: 0; }
.ops-attention__what a { font-weight: 600; color: var(--ops-ink); text-decoration: none; }
.ops-attention__what a:hover { color: var(--ops-accent); text-decoration: underline; }
.ops-attention__err { display: block; font-size: 0.82rem; color: var(--st-crit-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tabs (server-driven, URL-backed) */
.ops-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--ops-line); margin-bottom: 1.1rem; flex-wrap: wrap; }
.ops-tabs a {
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 550;
    color: var(--ops-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.ops-tabs a:hover { color: var(--ops-ink); }
.ops-tabs a[aria-current="page"] { color: var(--ops-accent); border-bottom-color: var(--ops-accent); }
.ops-tabs .ops-count { font-size: 0.75rem; color: var(--ops-muted); margin-left: 0.3rem; }

/* Sidebar group label for the new section */
.sidebar-group-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.9rem 1rem 0.35rem;
}

/* Focus + motion */
.ops a:focus-visible, .ops button:focus-visible, .ops summary:focus-visible, .ops tr.is-link:focus-visible {
    outline: 2px solid var(--ops-accent);
    outline-offset: 2px;
    border-radius: 4px;
}
@media (prefers-reduced-motion: reduce) {
    .ops * { transition: none !important; animation: none !important; }
}

/* Sidebar count badge (e.g. curricula waiting for review) */
.menu-badge {
    margin-left: auto;
    min-width: 1.35rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: #4f46e5;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
