/* ── Platform-operator area (/ops) ─────────────────────────────────────────────
   Standalone dark "mission control" chrome for OpsLayout + the four ops pages.
   Deliberately darker and techier than the tenant app: this area is only ever
   seen by the operator. Primary usage is iPhone/iPad — the ≤640px block at the
   bottom restyles tables as stacked cards. Global CSS (bootstrap, cx-widgets)
   still loads, so bootstrap form/table/button pieces are re-tinted here under
   the .cx-ops-shell scope. */

.cx-ops-shell {
    /* Warm charcoal palette; copper stays the brand accent. */
    --ops-bg: #12100c;
    --ops-panel: #1b1813;
    --ops-panel-2: #211d17;
    --ops-ink: #ece7e0;
    --ops-muted: #a39c92;
    --ops-faint: #6f6960;
    --ops-hairline: rgba(255, 255, 255, .07);
    --ops-hairline-strong: rgba(255, 255, 255, .14);
    --ops-accent: #d98b4f;
    --ops-ok: #57c785;
    --ops-warn: #e8b04b;
    --ops-danger: #ef6a5e;
    --ops-info: #5bc8dc;

    color-scheme: dark;
    color: var(--ops-ink);
}

/* app.css sets `html, body { overflow: clip }` (the main app scrolls inside
   .erp-content), so the ops shell must be its own scroll container — otherwise
   nothing under /ops can scroll at all. The sticky nav sticks to this scroller. */
.cx-ops-shell {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: clip;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(1100px 420px at 85% -10%, rgba(217, 139, 79, .09), transparent 60%),
        radial-gradient(900px 380px at -10% 20%, rgba(91, 200, 220, .05), transparent 55%),
        var(--ops-bg);
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.cx-ops-shell ::selection { background: rgba(217, 139, 79, .35); }

/* Entry animation for cards and tiles — a short staggered rise. */
@keyframes ops-rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* ── Nav ─────────────────────────────────────────────────────────────────────── */

.cx-ops-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    background: rgba(14, 12, 9, .82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--ops-hairline);
    color: var(--ops-ink);
    flex-wrap: wrap;
}

.cx-ops-brand {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -.01em;
    white-space: nowrap;
}

.cx-ops-brand i {
    color: var(--ops-accent);
    margin-right: 4px;
    filter: drop-shadow(0 0 6px rgba(217, 139, 79, .55));
}

.cx-ops-nav-links {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}

.cx-ops-nav-links a {
    color: var(--ops-muted);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-md, 10px);
    font-size: .9rem;
    transition: color .15s ease, background-color .15s ease;
}

.cx-ops-nav-links a:hover { color: var(--ops-ink); background: rgba(255, 255, 255, .06); }

.cx-ops-nav-links a.active {
    color: #fff;
    background: linear-gradient(180deg, rgba(217, 139, 79, .38), rgba(217, 139, 79, .26));
    box-shadow: inset 0 0 0 1px rgba(217, 139, 79, .35);
}

.cx-ops-back {
    color: var(--ops-faint);
    text-decoration: none;
    font-size: .85rem;
    white-space: nowrap;
}
.cx-ops-back:hover { color: var(--ops-ink); }

.cx-ops-main {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 20px 48px;
}

/* .cx-ops-main already provides the horizontal gutter — align the shared
   PageHeader with the cards instead of double-indenting it, and re-ink it
   for the dark ground. */
.cx-ops-main .cx-page-header { padding-left: 0; padding-right: 0; background: transparent; border: 0; box-shadow: none; }
.cx-ops-main .cx-page-header h1 { color: var(--ops-ink); }
.cx-ops-main .cx-page-header h1 i { color: var(--ops-accent); }
.cx-ops-main .cx-header-subtitle { color: var(--ops-muted); }

/* ── Bootstrap re-tint (scoped) ──────────────────────────────────────────────── */

.cx-ops-shell .text-muted { color: var(--ops-muted) !important; }
.cx-ops-shell .spinner-border { color: var(--ops-accent); }

.cx-ops-shell .form-label { color: var(--ops-muted); }

.cx-ops-shell .form-control,
.cx-ops-shell .form-select {
    background-color: var(--ops-panel-2);
    color: var(--ops-ink);
    border-color: var(--ops-hairline-strong);
}

.cx-ops-shell .form-control::placeholder { color: var(--ops-faint); }

.cx-ops-shell .form-select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23a39c92' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
}

.cx-ops-shell .form-control:focus,
.cx-ops-shell .form-select:focus {
    background-color: var(--ops-panel-2);
    color: var(--ops-ink);
    border-color: var(--ops-accent);
    box-shadow: 0 0 0 .2rem rgba(217, 139, 79, .18);
}

.cx-ops-shell .btn-outline-secondary {
    color: var(--ops-muted);
    border-color: var(--ops-hairline-strong);
}

.cx-ops-shell .btn-outline-secondary:hover,
.cx-ops-shell .btn-outline-secondary:focus {
    color: var(--ops-ink);
    background: rgba(255, 255, 255, .07);
    border-color: var(--ops-hairline-strong);
}

.cx-ops-shell .btn-primary {
    background: var(--ops-accent);
    border-color: var(--ops-accent);
    color: #191410;
    font-weight: 600;
}

.cx-ops-shell .btn-primary:hover,
.cx-ops-shell .btn-primary:focus {
    background: #e59d63;
    border-color: #e59d63;
    color: #191410;
}

.cx-ops-shell .alert-danger {
    background: rgba(239, 106, 94, .12);
    color: #f1a49c;
    border-color: rgba(239, 106, 94, .35);
}

.cx-ops-shell .table {
    color: var(--ops-ink);
    border-color: var(--ops-hairline);
    margin-bottom: 0;
}

.cx-ops-shell .table > :not(caption) > * > * {
    background: transparent;
    color: inherit;
    border-bottom-color: var(--ops-hairline);
    box-shadow: none;
}

/* ── Section cards ───────────────────────────────────────────────────────────── */

.cx-ops-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, .02), rgba(255, 255, 255, 0) 42%), var(--ops-panel);
    border: 1px solid var(--ops-hairline);
    border-radius: var(--radius-md, 12px);
    padding: 18px 20px;
    margin-top: 18px;
    animation: ops-rise .45s ease-out backwards;
}

.cx-ops-card:nth-of-type(2) { animation-delay: .06s; }
.cx-ops-card:nth-of-type(3) { animation-delay: .12s; }
.cx-ops-card:nth-of-type(4) { animation-delay: .18s; }
.cx-ops-card:nth-of-type(5) { animation-delay: .24s; }

.cx-ops-card h3 {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ops-ink);
}

.cx-ops-card h3 i { color: var(--ops-accent); }

.cx-ops-h3-meta {
    font-size: .78rem;
    font-weight: 500;
    color: var(--ops-faint);
    margin-left: 2px;
}

.cx-ops-empty-note { color: var(--ops-faint); font-size: .88rem; }

/* ── KPI tiles ───────────────────────────────────────────────────────────────── */

.cx-ops-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.cx-ops-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, 0) 55%), var(--ops-panel);
    border: 1px solid var(--ops-hairline);
    border-radius: var(--radius-md, 12px);
    animation: ops-rise .4s ease-out backwards;
    transition: transform .18s ease, border-color .18s ease;
}

.cx-ops-tile:hover { transform: translateY(-2px); border-color: var(--ops-hairline-strong); z-index: 5; }

.cx-ops-tile:nth-child(2) { animation-delay: .04s; }
.cx-ops-tile:nth-child(3) { animation-delay: .08s; }
.cx-ops-tile:nth-child(4) { animation-delay: .12s; }
.cx-ops-tile:nth-child(5) { animation-delay: .16s; }
.cx-ops-tile:nth-child(6) { animation-delay: .2s; }
.cx-ops-tile:nth-child(7) { animation-delay: .24s; }
.cx-ops-tile:nth-child(8) { animation-delay: .28s; }

.cx-ops-tile-value {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.cx-ops-tile-dim { font-size: .95rem; font-weight: 600; color: var(--ops-faint); }
.cx-ops-tile-label { font-size: .8rem; color: var(--ops-muted); }
.cx-ops-tile-label a { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.cx-ops-tile-label a:hover { color: var(--ops-ink); }

.cx-ops-tile-warn { border-color: rgba(232, 176, 75, .5); background: linear-gradient(180deg, rgba(232, 176, 75, .08), rgba(232, 176, 75, .02)), var(--ops-panel); }
.cx-ops-tile-danger { border-color: rgba(239, 106, 94, .5); background: linear-gradient(180deg, rgba(239, 106, 94, .08), rgba(239, 106, 94, .02)), var(--ops-panel); }

/* Value + sparkline sharing one row inside a tile. */
.cx-ops-tile-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.cx-ops-tile-spark { flex: 1; min-width: 0; max-width: 130px; margin-left: auto; }
.cx-ops-tile-spark .cx-sparkline, .cx-ops-tile-spark .cx-sparkline__svg { height: 30px; }

/* ── Platform pulse ──────────────────────────────────────────────────────────── */

.cx-ops-pulse-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.cx-ops-pulse-meta { font-size: .78rem; color: var(--ops-faint); }

.cx-ops-live-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ops-ok);
    display: inline-block;
    animation: ops-ping 2.4s ease-out infinite;
}

@keyframes ops-ping {
    0% { box-shadow: 0 0 0 0 rgba(87, 199, 133, .55); }
    70% { box-shadow: 0 0 0 9px rgba(87, 199, 133, 0); }
    100% { box-shadow: 0 0 0 0 rgba(87, 199, 133, 0); }
}

.cx-ops-pulse-chart { margin-top: 6px; }
.cx-ops-pulse-chart .cx-sparkline, .cx-ops-pulse-chart .cx-sparkline__svg { height: 96px; }

/* The end/hover dots are drawn in viewBox units and would stretch into ovals at
   this height — the tooltip alone carries the hover affordance here. */
.cx-ops-pulse-chart .cx-sparkline__svg circle { display: none; }

/* Draw-in animation for every ops sparkline: CxSparkline normalizes the path
   length to 1 via pathLength, so dasharray/dashoffset animate in pure CSS. */
.cx-ops-shell .cx-sparkline__line {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: ops-draw 1.1s ease-out .2s forwards;
}

@keyframes ops-draw { to { stroke-dashoffset: 0; } }

/* ── Business trend cards (30-day sparklines) ────────────────────────────────── */

.cx-ops-trends {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
}

.cx-ops-trend {
    background: var(--ops-panel-2);
    border: 1px solid var(--ops-hairline);
    border-radius: var(--radius-md, 10px);
    padding: 12px 14px;
    transition: transform .18s ease, border-color .18s ease;
}

.cx-ops-trend:hover { transform: translateY(-2px); border-color: var(--ops-hairline-strong); z-index: 5; position: relative; }

.cx-ops-trend-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.cx-ops-trend-label { font-size: .8rem; color: var(--ops-muted); }
.cx-ops-trend-label i { color: var(--ops-accent); margin-right: 2px; }

.cx-ops-trend-value {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cx-ops-trend-spark { margin: 8px 0 6px; }
.cx-ops-trend-spark .cx-sparkline, .cx-ops-trend-spark .cx-sparkline__svg { height: 44px; }

.cx-ops-trend-sub { font-size: .78rem; color: var(--ops-faint); }

.cx-ops-totals {
    display: flex;
    gap: 8px 20px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--ops-hairline);
    color: var(--ops-faint);
    font-size: .8rem;
}

/* ── Status/level badges ─────────────────────────────────────────────────────── */

.cx-ops-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

.cx-ops-badge-ok { background: rgba(87, 199, 133, .16); color: var(--ops-ok); }
.cx-ops-badge-warn { background: rgba(232, 176, 75, .16); color: var(--ops-warn); }
.cx-ops-badge-danger { background: rgba(239, 106, 94, .16); color: var(--ops-danger); }
.cx-ops-badge-muted { background: rgba(255, 255, 255, .08); color: var(--ops-muted); }

/* ── Tables ──────────────────────────────────────────────────────────────────── */

.cx-ops-table th {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--ops-faint);
}

.cx-ops-table td { vertical-align: middle; }
.cx-ops-num { font-variant-numeric: tabular-nums; }
.cx-ops-id { font-size: .76rem; font-weight: 400; color: var(--ops-faint); }

/* ── Log browser ─────────────────────────────────────────────────────────────── */

.cx-ops-log-table { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: .82rem; }
.cx-ops-log-table td { padding: 4px 8px; }
.cx-ops-log-row { cursor: pointer; }
.cx-ops-log-row:hover td { background: rgba(255, 255, 255, .04); }

.cx-ops-log-detail pre {
    background: #0d0b08;
    color: #e8e4de;
    border: 1px solid var(--ops-hairline);
    border-radius: var(--radius-md, 10px);
    padding: 12px 14px;
    font-size: .78rem;
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.cx-ops-log-msg {
    max-width: 720px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Feedback detail ─────────────────────────────────────────────────────────── */

.cx-ops-screenshots { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.cx-ops-screenshots img {
    width: 140px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-md, 10px);
    border: 1px solid var(--ops-hairline-strong);
}

.cx-ops-detail-panel {
    background: var(--ops-panel-2);
    border: 1px solid var(--ops-hairline);
    border-radius: var(--radius-md, 10px);
    padding: 14px 16px;
}

/* ── App release (/ops/app-release) ──────────────────────────────────────────── */

.cx-ops-release-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.cx-ops-release-platform { font-size: .8rem; color: var(--ops-muted); }
.cx-ops-release-platform i { color: var(--ops-accent); margin-right: 2px; }

.cx-ops-release-build {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin: 2px 0 4px;
}

.cx-ops-shell .alert-success {
    background: rgba(87, 199, 133, .12);
    color: #9fe0b9;
    border-color: rgba(87, 199, 133, .35);
}

.cx-ops-shell .alert-info {
    background: rgba(91, 200, 220, .1);
    color: #a6e1ec;
    border-color: rgba(91, 200, 220, .3);
}

/* Preview of the app's update dialog (UpdateAvailableDialog.tsx) — the app's light
   palette on purpose, so the operator sees what the worker sees. */
.cx-ops-update-preview {
    background: rgba(28, 25, 21, .45);
    border-radius: var(--radius-md, 12px);
    padding: 18px;
    display: flex;
    justify-content: center;
}

.cx-ops-update-preview-card {
    width: 100%;
    max-width: 340px;
    background: #FAF7F2;
    color: #1C1915;
    border-radius: 22px;
    padding: 20px;
}

.cx-ops-update-preview-badge {
    display: inline-block;
    background: #FBEFE5;
    color: #B8601F;
    border-radius: 999px;
    padding: 3px 12px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.cx-ops-update-preview-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.cx-ops-update-preview-lead { margin-top: 6px; font-size: .85rem; line-height: 1.45; color: #8E8679; }

.cx-ops-update-preview-notes {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(28, 25, 21, .08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cx-ops-update-preview-note { display: flex; gap: 8px; font-size: .84rem; line-height: 1.4; color: #4A443C; overflow-wrap: anywhere; }
.cx-ops-update-preview-note span { flex: none; width: 6px; height: 6px; border-radius: 3px; background: #B8601F; margin-top: 6px; }

.cx-ops-update-preview-install {
    margin-top: 16px;
    background: #B8601F;
    color: #fff;
    border-radius: 14px;
    padding: 11px;
    text-align: center;
    font-weight: 600;
}

.cx-ops-update-preview-later { margin-top: 6px; padding: 8px; text-align: center; font-size: .85rem; color: #8E8679; }

/* Own confirmation dialog (scrim + modal, z-band 5040/5050 as in the tenant app). */
.cx-ops-scrim {
    position: fixed;
    inset: 0;
    z-index: 5040;
    background: rgba(8, 7, 5, .6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.cx-ops-modal {
    position: fixed;
    z-index: 5050;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    background: var(--ops-panel);
    color: var(--ops-ink);
    border: 1px solid var(--ops-hairline-strong);
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
    padding: 20px 22px;
}

.cx-ops-modal h4 { font-size: 1.05rem; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.cx-ops-modal h4 i { color: var(--ops-accent); }

/* ── Filter toolbar ──────────────────────────────────────────────────────────── */

.cx-ops-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-top: 16px;
}

.cx-ops-toolbar .cx-ops-field-wide { min-width: 220px; }
.cx-ops-toolbar .cx-ops-field-narrow { width: 110px; }

.cx-ops-toolbar .form-label { font-size: .78rem; margin-bottom: 2px; }

.cx-ops-pills { display: flex; gap: 6px; flex-wrap: wrap; }

.cx-ops-pill {
    border: 1px solid var(--ops-hairline-strong);
    background: transparent;
    color: var(--ops-muted);
    border-radius: 999px;
    padding: 4px 14px;
    font-size: .84rem;
    cursor: pointer;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}

.cx-ops-pill:hover { color: var(--ops-ink); border-color: var(--ops-accent); }

.cx-ops-pill.active {
    background: var(--ops-accent);
    border-color: var(--ops-accent);
    color: #191410;
    font-weight: 600;
}

/* ── Reduced motion ──────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .cx-ops-card,
    .cx-ops-tile,
    .cx-ops-shell .cx-sparkline__line,
    .cx-ops-live-dot { animation: none; }
    .cx-ops-shell .cx-sparkline__line { stroke-dashoffset: 0; }
    .cx-ops-tile:hover, .cx-ops-trend:hover { transform: none; }
}

/* ── Mobile (≤640px: iPhone portrait; iPad keeps the desktop layout) ──────────
   Data tables carry data-label attributes on their cells and the .cx-ops-stack
   class: below the breakpoint each row becomes a card. Cells opt into extras:
   .cx-ops-stack-title (card headline), .cx-ops-stack-status (badge pinned to
   the headline's right), .cx-ops-stack-half (two-per-row mini stats) and
   .cx-ops-cell-empty ("—" cells vanish instead of wasting a row). */

@media (max-width: 640px) {

    /* Nav: brand + back on the first line, page links as an edge-to-edge
       horizontally scrollable strip below (no scrollbar). */
    .cx-ops-nav {
        gap: 6px 12px;
        padding-top: 8px;
        padding-bottom: 0;
    }

    .cx-ops-brand { order: 0; }
    .cx-ops-back { order: 1; margin-left: auto; }

    .cx-ops-nav-links {
        order: 2;
        flex: 1 1 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 -20px;
        padding: 2px 14px 8px;
        scrollbar-width: none;
    }

    .cx-ops-nav-links::-webkit-scrollbar { display: none; }
    .cx-ops-nav-links a { padding: 8px 12px; white-space: nowrap; }

    .cx-ops-main {
        padding: 12px 12px 40px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .cx-ops-card { padding: 14px; margin-top: 14px; }

    .cx-ops-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
    .cx-ops-tile { padding: 12px; }
    .cx-ops-tile-value { font-size: 1.4rem; }
    .cx-ops-tile-spark { max-width: 110px; }
    .cx-ops-tile-spark .cx-sparkline, .cx-ops-tile-spark .cx-sparkline__svg { height: 26px; }

    .cx-ops-pulse-chart .cx-sparkline, .cx-ops-pulse-chart .cx-sparkline__svg { height: 68px; }

    .cx-ops-trends { grid-template-columns: 1fr 1fr; gap: 8px; }
    .cx-ops-trend { padding: 10px 12px; }
    .cx-ops-trend-spark .cx-sparkline, .cx-ops-trend-spark .cx-sparkline__svg { height: 36px; }

    /* Toolbar: fields share rows in pairs, wide fields take the full row.
       16px inputs stop iOS Safari from zooming in on focus. */
    .cx-ops-toolbar { gap: 8px; }
    .cx-ops-toolbar > div { flex: 1 1 45%; }
    .cx-ops-toolbar .cx-ops-field-wide { flex: 1 1 100%; min-width: 0; }
    .cx-ops-toolbar .cx-ops-field-narrow { width: auto; }
    .cx-ops-toolbar .form-select,
    .cx-ops-toolbar .form-control { font-size: 16px; }
    .cx-ops-toolbar button[type="submit"] { width: 100%; padding-top: 8px; padding-bottom: 8px; }

    .cx-ops-pill { padding: 7px 14px; }

    /* Stacked card tables: header row disappears, each data row becomes a
       card; cells show their data-label as a fixed left-hand column. The row
       is a wrapping flex so .cx-ops-stack-half cells can sit two per line. */
    .cx-ops-stack,
    .cx-ops-stack > thead,
    .cx-ops-stack > tbody { display: block; }

    .cx-ops-stack > thead { display: none; }

    .cx-ops-stack > tbody > tr {
        position: relative;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        border: 1px solid var(--ops-hairline);
        border-radius: var(--radius-md, 10px);
        padding: 10px 12px;
        margin-bottom: 10px;
        background: var(--ops-panel-2);
    }

    .cx-ops-stack > tbody > tr > td {
        display: flex;
        flex: 1 1 100%;
        align-items: baseline;
        gap: 10px;
        padding: 3px 0;
        border: 0;
        box-shadow: none;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .cx-ops-stack > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 40%;
        max-width: 150px;
        color: var(--ops-faint);
        font-size: .74rem;
        text-transform: uppercase;
        letter-spacing: .03em;
    }

    .cx-ops-stack > tbody > tr > .cx-ops-stack-title {
        order: -1;
        font-weight: 700;
        font-size: .95rem;
        padding-bottom: 6px;
        padding-right: 96px; /* keeps clear of the pinned status badge */
    }

    /* Status badge pinned next to the card headline instead of its own row. */
    .cx-ops-stack > tbody > tr > .cx-ops-stack-status {
        position: absolute;
        top: 10px;
        right: 12px;
        flex: none;
        width: auto;
        padding: 0;
    }

    .cx-ops-stack > tbody > tr > .cx-ops-stack-status::before { display: none; }

    /* Compact numeric stats: label above value, two cells per line. */
    .cx-ops-stack > tbody > tr > .cx-ops-stack-half {
        flex: 1 1 50%;
        max-width: 50%;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        text-align: left;
    }

    .cx-ops-stack > tbody > tr > .cx-ops-stack-half[data-label]::before { flex: none; max-width: none; }

    /* "—" cells carry no information on a card — drop them entirely. */
    .cx-ops-stack > tbody > tr > .cx-ops-cell-empty { display: none; }

    /* Log browser: one flex card per entry — time/level/source on top,
       the message wrapping below (clamped to two lines until opened). */
    .cx-ops-log-table,
    .cx-ops-log-table > tbody { display: block; }
    .cx-ops-log-table > thead { display: none; }
    .cx-ops-log-table > tbody > tr { display: block; }

    .cx-ops-log-table > tbody > tr.cx-ops-log-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 2px 10px;
        padding: 8px 2px;
        border-bottom: 1px solid var(--ops-hairline);
    }

    .cx-ops-log-table > tbody > tr > td {
        display: block;
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .cx-ops-log-table > tbody > tr.cx-ops-log-row > td:nth-child(4) { flex: 1 1 100%; }

    .cx-ops-log-msg {
        max-width: none;
        white-space: normal;
        overflow-wrap: anywhere;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .cx-ops-log-detail { padding: 8px 0; }
    .cx-ops-log-detail pre { max-height: 320px; }

    /* Feedback detail: comfortable touch targets, larger screenshot thumbs. */
    .cx-ops-detail-panel { padding: 12px; }
    .cx-ops-detail-panel .btn { flex: 1 1 auto; padding-top: 8px; padding-bottom: 8px; }

    .cx-ops-screenshots img { width: 44vw; max-width: 180px; height: auto; aspect-ratio: 7 / 5; }
}
