/* TTAP - the Bad Marine "Tactical Bridge" theme, the same tokens and shell as the Refinery and
   FARS Manifest (~/FARS Manifest/src/FarsManifest.Web/wwwroot/app.css), so an analyst moving between
   them is in one product family. TTAP's own screens follow below the shared part. */
:root {
    color-scheme: dark;
    --bg-matte-carbon: #0d0d0d;
    --bg-dark-armor: #1a1a1a;
    --bg-dark-armor-raised: #232323;
    --text-brushed-aluminum: #d1d5db;
    --text-dim: #8b93a1;
    --accent-cyan-glow: #00e5ff;
    --danger: #ef4444;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.18);

    --bg: var(--bg-matte-carbon);
    --surface: var(--bg-dark-armor);
    --surface-2: var(--bg-dark-armor-raised);
    --line: var(--border-strong);
    --text: var(--text-brushed-aluminum);
    --muted: var(--text-dim);
    --muted-2: #6b7280;
    --accent: var(--accent-cyan-glow);
    --accent-glow: #67f0ff;
    --accent-ink: #001a1f;
    --accent-dim: #0e4f58;
    --good: #34d399;
    --warn: #f59e0b;
    --radius: 8px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    background: var(--bg-matte-carbon);
    color: var(--text-brushed-aluminum);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent-cyan-glow); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: #f3f4f6; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
code { color: var(--accent-cyan-glow); background: rgba(0, 229, 255, 0.07); padding: 0 .25em; border-radius: 3px; }
code, .mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; }

button, input, select, textarea {
    font-family: inherit;
    font-size: 0.95em;
    background: var(--bg-dark-armor-raised);
    color: var(--text-brushed-aluminum);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 0.45em 0.8em;
}
button { cursor: pointer; transition: border-color .15s ease, background .15s ease, transform .05s ease; }
button:hover:not(:disabled) { border-color: var(--accent-cyan-glow); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: #6b7280; }

/* --- shell: the Refinery's top-row nav, full-width content --- */
.top-row {
    background: var(--bg-dark-armor);
    border-bottom: 1px solid var(--border-strong);
    padding: 0.55rem 1rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex: 0 0 auto;
}
.top-row .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: .04em; color: #fff; }
.top-row .brand:hover { text-decoration: none; }
.top-row .brand img { height: 30px; width: 30px; }
.top-row nav { display: inline-flex; gap: 1rem; }
.top-row nav a { color: var(--text-brushed-aluminum); }
.top-row nav a:hover { color: var(--accent-cyan-glow); text-decoration: none; }
.top-row nav a.active { color: var(--accent-cyan-glow); }

main {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    width: 100%;
}

/* The Refinery's two button shapes (.rf-btn-primary / .rf-btn-outline). .btn / .btn-secondary are
   kept as aliases so every existing screen follows along. */
.btn, .rf-btn-primary {
    display: inline-block;
    background: #475569; border: 1px solid #475569; color: #fff; font-weight: 600;
    border-radius: 8px; padding: .45em .9em; cursor: pointer; text-decoration: none; font-size: .95em;
}
.btn:hover:not(:disabled), .rf-btn-primary:hover:not(:disabled) { background: #64748b; border-color: #64748b; text-decoration: none; }
.btn:disabled, .rf-btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-secondary, .rf-btn-outline {
    background: transparent; color: var(--text-brushed-aluminum); border: 1px solid var(--border-strong); font-weight: 400;
}
.btn-secondary:hover:not(:disabled), .rf-btn-outline:hover:not(:disabled) { background: transparent; border-color: var(--accent-cyan-glow); color: var(--text-brushed-aluminum); }

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: .15rem .6rem;
    font-size: .8rem;
    font-weight: 600;
}
.rf-helptip { position: relative; display: inline-flex; align-items: center; }
.rf-helptip-btn {
    width: 1.15rem; height: 1.15rem; border-radius: 50%; padding: 0; line-height: 1;
    font-size: .7rem; display: inline-flex; align-items: center; justify-content: center;
    background: transparent; color: var(--text-dim); border: 1px solid var(--border-strong);
    cursor: help;
}
.rf-helptip-btn:hover, .rf-helptip-btn:focus-visible { border-color: var(--accent-cyan-glow); color: var(--accent-cyan-glow); }
.rf-helptip-text {
    display: none; position: absolute; z-index: 30; top: 140%; left: 0;
    background: var(--bg-dark-armor-raised); border: 1px solid var(--border-strong); border-radius: 6px;
    padding: .55rem .7rem; width: max-content; max-width: 22rem; font-size: .82em; font-weight: normal;
    color: var(--text-brushed-aluminum); box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
}
.rf-helptip:hover .rf-helptip-text, .rf-helptip:focus-within .rf-helptip-text { display: block; }
/* signed-in user, top-right (dev: Switch user) */
.top-user { margin-left: auto; display: inline-flex; align-items: center; gap: .5rem; font-size: .85em; color: var(--text-dim); }
.top-user-dev { font-size: .7em; text-transform: uppercase; letter-spacing: .05em; color: #f59e0b; border: 1px solid rgba(245,158,11,.45); border-radius: 4px; padding: 0 .3rem; }
.top-user-switch { font-size: .9em; padding: .2rem .4rem; }

/* ======================== TTAP ======================== */
:root {
    --chart-series: #0ea5c0;       /* validated (dataviz validator) for the dark surface */
    --chart-grid: rgba(255, 255, 255, 0.07);
    --driver: #c084fc;
}

.muted { color: var(--text-dim); }
h1:focus { outline: none; }   /* FocusOnNavigate puts focus on the heading for screen readers */
.small { font-size: .82em; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; }
.spacer { flex: 1 1 auto; }
.danger { color: var(--danger) !important; }
.check { display: inline-flex; align-items: center; gap: .35rem; }
.check input { margin: 0; }

.empty-state { max-width: 40rem; margin: 3rem auto; text-align: center; }
.empty-state p { color: var(--text-dim); }

.badge-ok { background: rgba(52, 211, 153, .15); color: var(--good); }
.badge-sim { background: rgba(245, 158, 11, .15); color: var(--warn); }
.badge-off { background: rgba(239, 68, 68, .15); color: var(--danger); }
.badge-driver { background: rgba(192, 132, 252, .15); color: var(--driver); }

/* status + honest-gap bars */
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; font-size: .85em; margin-bottom: .6rem; }
.bar { border-radius: 6px; padding: .45rem .75rem; margin: .4rem 0; font-size: .9em; border: 1px solid; }
.bar-info { border-color: var(--border-subtle); background: rgba(255, 255, 255, .03); color: var(--text-dim); }
.bar-partial { border-color: rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .08); color: #fcd34d; }
.bar-stale { border-color: rgba(239, 68, 68, .45); background: rgba(239, 68, 68, .08); color: #fca5a5; }
.bar-error { border-color: rgba(239, 68, 68, .55); background: rgba(239, 68, 68, .1); color: #fecaca; }

/* layout: left rail + builder */
.analyst { display: grid; grid-template-columns: 15rem 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .analyst { grid-template-columns: 1fr; } }
.rail { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: .6rem; position: sticky; top: 0; }
.rail-head { font-size: .72em; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); margin: .7rem .2rem .3rem; }
.rail-head:first-child { margin-top: .1rem; }
.rail-row { display: flex; align-items: center; }
.rail-item { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; padding: .3rem .45rem; font-size: .88em; border-radius: 6px; }
.rail-item:hover { border-color: var(--border-strong); }
.rail-item.active { border-color: var(--accent-dim); color: var(--accent); }
.rail-x { background: transparent; border: none; color: var(--muted-2); padding: 0 .4rem; }
.rail-x:hover { color: var(--danger); }

/* the sentence */
.sentence { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: .75rem .9rem; }
.line { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; padding: .3rem 0; }
.kw { color: var(--text-dim); font-weight: 600; }
.fixed { padding: .45em .8em; border: 1px dashed var(--border-strong); border-radius: 8px; }
.sentence select, .sentence input[type=date] { padding: .3em .55em; }
.group-pick { max-width: 22rem; }
.run { background: #0e6e80; border-color: #0e6e80; }
.run:hover:not(:disabled) { background: #12879c !important; border-color: #12879c !important; }
.save-row input:not([type]) { min-width: 18rem; }

.chips { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.chip { display: inline-flex; align-items: stretch; border: 1px solid var(--accent-dim); border-radius: 999px; background: rgba(0, 229, 255, .06); overflow: hidden; }
.chip-named { border-color: rgba(192, 132, 252, .5); background: rgba(192, 132, 252, .08); }
.chip-text { background: transparent; border: none; border-radius: 0; padding: .22rem .2rem .22rem .7rem; font-size: .88em; }
.chip-x { background: transparent; border: none; border-radius: 0; padding: .22rem .55rem .22rem .3rem; color: var(--text-dim); }
.chip-x:hover { color: var(--danger); }
.add-chip, .add-unit { background: transparent; border: 1px dashed var(--border-strong); border-radius: 999px; padding: .2rem .7rem; font-size: .85em; color: var(--text-dim); }
.add-chip:hover, .add-unit:hover { color: var(--accent); }
.add-unit.small { font-size: .78em; padding: .1rem .55rem; }

.box { margin: .25rem 0 .25rem .2rem; padding: .3rem .5rem; border-left: 2px solid var(--accent-dim); }
.box-child { margin-left: 1.4rem; border-left-color: rgba(192, 132, 252, .45); }
.box-line { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.box-lead { color: var(--text-dim); }
.box-lead strong { color: var(--text); }
.box-counted { font-size: .72em; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); border: 1px solid var(--accent-dim); border-radius: 4px; padding: 0 .3rem; }
.box-remove { background: transparent; border: none; color: var(--muted-2); margin-left: auto; }
.box-remove:hover { color: var(--danger); }
.box-add-child { padding: .2rem 0 0 1.4rem; display: flex; gap: .35rem; }

/* condition editor (opens in place) */
.cond-editor { flex-basis: 100%; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px; padding: .6rem; margin: .2rem 0; box-shadow: 0 8px 22px rgba(0, 0, 0, .45); }
.cond-search { width: 100%; margin-bottom: .4rem; }
.cond-fields, .cond-values { max-height: 18rem; overflow-y: auto; display: flex; flex-direction: column; }
.cond-group { font-size: .72em; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); margin: .5rem .2rem .15rem; }
.cond-field { text-align: left; background: transparent; border: 1px solid transparent; padding: .22rem .45rem; font-size: .9em; }
.cond-field:hover { border-color: var(--accent-dim); }
.cond-field.named { color: #e9d5ff; }
.cond-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.cond-op { padding: .25em .5em; }
.cond-row { display: flex; align-items: center; gap: .45rem; margin-bottom: .4rem; }
.cond-value { display: flex; align-items: center; gap: .45rem; padding: .15rem .3rem; font-size: .9em; cursor: pointer; }
.cond-value:hover { background: rgba(255, 255, 255, .04); }
.cond-value.retired { color: var(--muted-2); }
.cond-actions { display: flex; gap: .45rem; margin-top: .55rem; }

/* results */
.results { margin-top: 1rem; }
.summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; font-size: 1.05em; }
.summary .total { font-size: 2.2rem; font-weight: 600; color: #f3f4f6; }
.tabs { display: flex; align-items: center; gap: .3rem; margin: .8rem 0 .6rem; border-bottom: 1px solid var(--border-subtle); }
.tab { background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: .45rem .8rem; color: var(--text-dim); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.grid-table { width: 100%; border-collapse: collapse; font-size: .92em; }
.grid-table th { text-align: left; font-weight: 600; color: var(--text-dim); border-bottom: 1px solid var(--border-strong); padding: .4rem .55rem; }
.grid-table td { border-bottom: 1px solid var(--border-subtle); padding: .35rem .55rem; }
.grid-table tr:hover td { background: rgba(255, 255, 255, .025); }
.grid-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.chart-title { font-size: 1rem; margin: .4rem 0; color: var(--text); }

/* chart (dataviz spec: thin marks, hairline grid, text in text tokens) */
.chart { width: 100%; max-width: 980px; height: auto; display: block; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { fill: var(--text-dim); font-size: 11px; }
.chart .cat { fill: var(--text); font-size: 12px; }
.chart .value { fill: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--chart-series); }
.chart .line { fill: none; stroke: var(--chart-series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--chart-series); opacity: .1; }
.chart .dot { fill: var(--chart-series); stroke: var(--surface); stroke-width: 2; }
.chart .hit { cursor: pointer; }
.chart .hit:hover .bar, .chart .hit:hover .dot { filter: brightness(1.25); }
.chart .hit:hover .cat { fill: #fff; }

/* admin */
.admin-tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border-subtle); margin-bottom: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .9rem; }
.card h2 { margin: 0 0 .5rem; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.field-row { display: grid; grid-template-columns: 1fr 5rem 5rem 16rem; align-items: center; gap: .5rem; padding: .2rem 0; border-bottom: 1px solid var(--border-subtle); font-size: .9em; }
.field-row.head { color: var(--muted-2); font-size: .75em; text-transform: uppercase; letter-spacing: .05em; }
.field-row .path { color: var(--muted-2); font-size: .8em; }
.field-row input[type=text] { padding: .2em .45em; }
.group-head { display: flex; align-items: center; gap: .6rem; cursor: pointer; background: transparent; border: none; width: 100%; text-align: left; padding: .3rem 0; font-weight: 600; }
.kv { display: grid; grid-template-columns: 14rem 1fr; gap: .35rem .8rem; align-items: center; }
.perm-grid { width: 100%; border-collapse: collapse; }
.perm-grid th, .perm-grid td { padding: .35rem .5rem; border-bottom: 1px solid var(--border-subtle); text-align: center; }
.perm-grid th:first-child, .perm-grid td:first-child { text-align: left; }

/* ======================== Query Studio (Gemini layout brief, 2026-10-02) ========================
   A 100vh workspace locked under the top bar: the window never scrolls, each pane does on its own.
   22 / 78 split; the right side is builder (45%) over results (55%). */
html, body { height: 100%; }
body { height: 100vh; overflow: hidden; }
main { min-height: 0; }
main:has(> .query-studio) { padding: 0; overflow: hidden; }

.query-studio { display: grid; grid-template-columns: 22% 78%; height: 100%; min-height: 0; }
.query-sidebar { border-right: 1px solid var(--border-strong); background: var(--surface); overflow-y: auto; padding: .7rem .6rem; min-height: 0; }
.studio-main { display: grid; grid-template-rows: 45% 55%; min-height: 0; min-width: 0; }
.builder-pane { overflow-y: auto; padding: .7rem 1rem; border-bottom: 1px solid var(--border-strong); min-height: 0; }
.results-pane { display: flex; flex-direction: column; min-height: 0; }
.results-body { overflow-y: auto; padding: .6rem 1rem 1rem; flex: 1 1 auto; min-height: 0; }
.studio-loading { padding: 2rem; }
@media (max-width: 900px) {
    body { overflow: auto; height: auto; }
    main:has(> .query-studio) { overflow: visible; }
    .query-studio { grid-template-columns: 1fr; height: auto; }
    .studio-main { grid-template-rows: auto auto; }
}

/* library */
.lib-search { width: 100%; margin-bottom: .6rem; }
.lib-section { margin-bottom: .5rem; }
.lib-head { display: flex; justify-content: space-between; align-items: center; width: 100%; background: transparent; border: none; padding: .3rem .2rem; font-size: .8em; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); }
.lib-head:hover { color: var(--text); }
.lib-count { font-size: .9em; border: 1px solid var(--border-strong); border-radius: 999px; padding: 0 .45rem; color: var(--text-dim); }
.lib-item { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; padding: .25rem .45rem; font-size: .86em; border-radius: 6px; }
.lib-item:hover { border-color: var(--border-strong); }
.lib-item.active { border-color: var(--accent-dim); color: var(--accent); }
.lib-row { display: flex; align-items: center; }
.lib-x { background: transparent; border: none; color: var(--muted-2); padding: 0 .4rem; }
.lib-x:hover { color: var(--danger); }
.lib-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .3rem .5rem; color: var(--muted); }
.lib-empty { display: inline-block; margin: .2rem .45rem; font-size: .75em; color: var(--muted-2); border: 1px dashed var(--border-strong); border-radius: 999px; padding: .05rem .55rem; }

/* builder */
.pane-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.pane-head h1 { font-size: 1.05rem; margin: 0; letter-spacing: .02em; }
.sentence-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; width: fit-content; max-width: 100%; padding: .4rem .55rem; background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); }
.sentence-strip select, .sentence-strip input[type=date] { padding: .25em .5em; font-size: .9em; }
.query-tree { margin: .5rem 0 .3rem .3rem; padding-left: .8rem; border-left: 1px solid var(--border-strong); }
.tree-node { position: relative; padding: .2rem 0; }
.tree-node::before { content: ""; position: absolute; left: -.8rem; top: 1.05rem; width: .65rem; border-top: 1px solid var(--border-strong); }
.tree-root { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.tree-label { font-weight: 600; color: var(--text); font-size: .9em; }
.tree-node .box { margin: 0; padding: .1rem 0 .1rem .5rem; }
.entity-toolbar { display: flex; flex-wrap: wrap; gap: .35rem; margin: .35rem 0; }
.builder-footer { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; padding-top: .35rem; }
.btn-primary { background: #0e6e80; border: 1px solid #0e6e80; color: #fff; font-weight: 700; border-radius: 8px; padding: .45em 1em; }
.btn-primary:hover:not(:disabled) { background: #12879c; border-color: #12879c; }
.chip .code { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: .85em; color: var(--accent); }

/* data-set picker */
.ds-picker { position: relative; display: inline-block; }
.ds-button { padding: .25em .6em; font-size: .9em; }
.ds-menu { position: absolute; z-index: 40; top: 115%; left: 0; display: flex; flex-direction: column; min-width: 18rem; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px; padding: .4rem; box-shadow: 0 8px 22px rgba(0, 0, 0, .5); }
.ds-menu .cond-value { gap: .5rem; }
.ds-note { padding: .3rem .3rem 0; }

/* results */
.results-bar { position: sticky; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .6rem; padding: .45rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border-subtle); z-index: 5; }
.results-metric { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; font-size: .9em; }
.metric-badge { font-size: 1.25rem; font-weight: 700; color: #f3f4f6; background: rgba(14, 165, 192, .14); border: 1px solid rgba(14, 165, 192, .45); border-radius: 8px; padding: 0 .55rem; font-variant-numeric: tabular-nums; }
.results-tabs { display: flex; gap: .15rem; }
.results-actions { display: flex; justify-content: flex-end; }
.results-tabs .tab { border-bottom-width: 2px; padding: .35rem .7rem; }
.grid-table tfoot td { border-top: 1px solid var(--border-strong); font-weight: 600; padding: .4rem .55rem; }
.grid-table .center { text-align: center; }
.badge-set { background: rgba(255, 255, 255, .06); color: var(--text-dim); }
.zero-state { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 2.5rem 1rem; color: var(--text-dim); font-size: .92em; }
.zero-state svg { width: 140px; }
.zs-frame { fill: none; stroke: var(--border-strong); }
.zs-bar { fill: rgba(14, 165, 192, .25); }
.zs-line { stroke: var(--border-strong); stroke-width: 2; }

/* record cards */
.case-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); gap: .5rem; margin-top: .5rem; }
.case-card { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: 8px; padding: .5rem .65rem; font-size: .88em; }
.case-card:hover { border-color: var(--border-strong); }
.case-top { display: flex; align-items: center; gap: .45rem; }
.case-key { color: #f3f4f6; }
.case-fields { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin-top: .35rem; }
.case-jump { display: inline-block; margin-top: .35rem; font-size: .9em; }
.case-open { margin-left: .35rem; text-decoration: none; }
.ask-row { display: flex; gap: .5rem; align-items: center; margin: .4rem 0; max-width: 56rem; }   /* Fill in sits beside the box, not at the window's edge */
.ask-input { flex: 1; min-width: 0; }
.ask-off { opacity: .5; }                                    /* the demo: shown, switched off */
.ask-off .ask-input, .ask-off button { cursor: not-allowed; }
.ask-off-note { max-width: 56rem; margin-top: 0; }
.rule-example dl { display: grid; grid-template-columns: 12rem 1fr; gap: .5rem .9rem; margin: .4rem 0; }
.rule-example dt { color: var(--text-dim); font-weight: 600; }
.rule-example dd { margin: 0; }
.chip-op { color: var(--text-dim); }

/* Records: a table of rows, and the opened report beside it. */
.rec-note { margin-bottom: .4rem; }
.rec-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem; align-items: start; }
.rec-split.open { grid-template-columns: minmax(0, 1fr) minmax(20rem, 30rem); }
/* The table scrolls inside its own box, both ways, so the sideways scrollbar is always in view. */
.rec-scroll { overflow: auto; min-width: 0; max-height: calc((100vh - 3.2rem) * .55 - 7.2rem); border: 1px solid var(--border-subtle); border-radius: 6px; }
.rec-table td { white-space: nowrap; }
.rec-table th { position: sticky; top: 0; background: var(--bg); white-space: nowrap; }
.rec-row { cursor: pointer; }
.rec-row:hover td { background: rgba(14, 165, 192, .08); }
.rec-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rec-row.sel td { background: rgba(14, 165, 192, .2); }
.rec-row.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.nowrap { white-space: nowrap; }
.rec-detail { position: sticky; top: 0; max-height: calc((100vh - 3.2rem) * .55 - 7.2rem); overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: .7rem .8rem; font-size: .9em; }
.rec-detail-head { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: .5rem; }
.rec-section { border-top: 1px solid var(--border-subtle); padding: .45rem 0 .2rem .5rem; border-left: 2px solid transparent; }
.rec-section.picked { border-left-color: var(--accent); background: rgba(14, 165, 192, .06); }
.rec-section h4 { margin: 0 0 .3rem; font-size: 1em; color: #f3f4f6; }
.rec-section dl { display: grid; grid-template-columns: minmax(8rem, 40%) 1fr; gap: .15rem .7rem; margin: 0; }
.rec-section dt { color: var(--text-dim); }
.rec-section dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 1100px) { .rec-split.open { grid-template-columns: minmax(0, 1fr); } }
/* The crash key stays put while the rest scrolls sideways. */
.rec-table th:first-child, .rec-table td:first-child { position: sticky; left: 0; background: var(--bg); z-index: 1; }
.rec-table th:first-child { z-index: 2; }

/* "and" / "or" between top-level boxes: click to switch. Boxes joined by "or" share a bracket. */
.box-join { font-size: .78em; text-transform: uppercase; letter-spacing: .05em; padding: 0 .4rem; border-radius: 4px; border: 1px solid var(--border-strong); background: transparent; color: var(--text-dim); cursor: pointer; }
.box-join:hover { border-color: var(--accent); color: var(--text); }
.box-join.or { border-color: #c084fc; color: #c084fc; }
.tree-node.either > .box { border-left-color: #c084fc; background: rgba(192, 132, 252, .05); }

/* The public demo's "Sample data" strip (Ttap:Demo:Enabled), as FARS Manifest has it. */
.demo-banner { flex: 0 0 auto; padding: .35rem 1rem; font-size: .85em; color: #fcd34d; background: rgba(245, 158, 11, .1); border-bottom: 1px solid rgba(245, 158, 11, .35); }
.demo-banner strong { color: #fbbf24; }
.demo-reset { margin-left: .75rem; padding: .1rem .6rem; font-size: .95em; background: transparent; color: #fcd34d; border: 1px solid rgba(245,158,11,.5); border-radius: 6px; }
.demo-reset:hover:not(:disabled) { border-color: #fbbf24; }
.demo-manual { margin-left: .75rem; color: #fcd34d; }

/* Who you're signed in as on a test system or the demo: a strip on the left under the top bar, as the Refinery has it. */
.dev-bar { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; flex: 0 0 auto; padding: .35rem 1rem; font-size: .84em;
  color: var(--text-dim); background: rgba(217, 119, 6, .10); border-bottom: 1px solid rgba(245, 158, 11, .5); }
.dev-bar strong { color: #f3f4f6; }
.dev-bar .dev-bar-tag { color: #fbbf24; text-transform: uppercase; letter-spacing: .06em; }
.dev-bar-user { padding: .08rem .55rem; border: 1px solid var(--border-strong); border-radius: 4px; color: #e5e7eb; background: transparent; font-size: 1em; text-decoration: none; }
.dev-bar-user:hover { border-color: #fbbf24; }
.dev-bar-user.active { color: var(--accent, #22d3ee); border-color: var(--accent, #22d3ee); }
.dev-bar-manual { margin-left: auto; color: #fbbf24; font-weight: 600; }

.coverage { margin: .25rem 0 .1rem .2rem; }

/* ======================== Audit log as an event inspector (Gemini brief, 2026-10-03) ========================
   Locked to the window under the admin tabs: the event stream (65%) and the inspector (35%) scroll on their own. */
main:has(.audit-studio) { overflow: hidden; display: flex; flex-direction: column; }
main:has(.audit-studio) > h1, main:has(.audit-studio) > .admin-tabs { flex: 0 0 auto; }
.audit-studio { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: .6rem; }
.audit-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; flex: 0 0 auto; }
.audit-bar h2 { margin: 0 .4rem 0 0; display: flex; align-items: center; gap: .4rem; }
.audit-search { flex: 1 1 18rem; min-width: 12rem; max-width: 34rem; }
.audit-split { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 65% 35%; gap: 0; }
.audit-stream { overflow: auto; min-height: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius) 0 0 var(--radius); }
.audit-table { width: 100%; font-size: .86em; }
.audit-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.audit-table td { vertical-align: middle; }
.audit-preview { color: var(--text-dim); max-width: 32rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actor-badge { display: inline-block; padding: .05rem .5rem; border: 1px solid var(--border-strong); border-radius: 999px; font-size: .92em; }
.event-badge { display: inline-block; padding: .08rem .55rem; border-radius: 999px; font-size: .9em; white-space: nowrap; border: 1px solid; }
.event-badge.query { color: #34d399; border-color: rgba(52, 211, 153, .5); background: rgba(52, 211, 153, .08); }
.event-badge.record { color: #22d3ee; border-color: rgba(34, 211, 238, .5); background: rgba(34, 211, 238, .08); }
.event-badge.ask { color: #c084fc; border-color: rgba(192, 132, 252, .5); background: rgba(192, 132, 252, .08); }
.event-badge.config { color: #fbbf24; border-color: rgba(251, 191, 36, .5); background: rgba(251, 191, 36, .08); }
.event-badge.export { color: #93c5fd; border-color: rgba(147, 197, 253, .5); background: rgba(147, 197, 253, .08); }
.event-badge.other { color: var(--text-dim); border-color: var(--border-strong); }
.payload-inspector { overflow-y: auto; min-height: 0; padding: .6rem .7rem; background: var(--surface); border: 1px solid var(--border-subtle); border-left: none; border-radius: 0 var(--radius) var(--radius) 0; }
.payload-inspector .card { background: var(--bg-matte-carbon); }
.payload-inspector h3 { margin: 0 0 .4rem; font-size: .95rem; }
.audit-detail { white-space: pre-wrap; word-break: break-word; }
.json-tree { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: .82em; line-height: 1.5; overflow-x: auto; }
.json-tree details > :not(summary) { margin-left: 1.1rem; }
.json-tree summary { cursor: pointer; list-style: none; }
.json-tree summary::before { content: "▸ "; color: var(--text-dim); }
.json-tree details[open] > summary::before { content: "▾ "; }
.jt-key { color: #22d3ee; }
.jt-str { color: #34d399; }
.jt-num { color: #fbbf24; }
.jt-bool, .jt-null { color: #c084fc; }
.jt-punc { color: var(--text-dim); }
.jt-meta { color: var(--text-dim); font-style: italic; margin: 0 .3rem; font-size: .9em; }
@media (max-width: 900px) { main:has(.audit-studio) { overflow: auto; } .audit-split { grid-template-columns: 1fr; } }

/* ======================== Admin "Data" as a console (Gemini brief, 2026-10-03) ========================
   Locked to the window under the admin tabs: 55 / 45 columns of cards that scroll on their own, and a
   command bar along the bottom. */
main:has(.data-engine-studio) { overflow: hidden; display: flex; flex-direction: column; }
main:has(.data-engine-studio) > h1, main:has(.data-engine-studio) > .admin-tabs { flex: 0 0 auto; }
.data-engine-studio { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: .6rem; }
.data-engine-grid { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 55fr 45fr; gap: .8rem; }
.data-engine-col { display: flex; flex-direction: column; gap: .8rem; min-height: 0; overflow-y: auto; }
.telemetry-card { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: .7rem .9rem; }
.telemetry-card h2 { margin: 0 0 .45rem; font-size: 1.02rem; display: flex; align-items: center; gap: .45rem; }
.telemetry-rows > div { display: grid; grid-template-columns: 11.5rem 1fr; gap: .8rem; align-items: center; padding: .38rem 0; border-bottom: 1px solid var(--border-subtle); }
.telemetry-rows > div:last-child { border-bottom: none; }
.telemetry-rows > div > span:first-child { color: var(--text-dim); }
.telemetry-actions { margin-top: .6rem; }
.source-badge { color: var(--accent); background: rgba(0, 229, 255, .07); border: 1px solid var(--accent-dim); border-radius: 4px; padding: .05rem .45rem; font-size: .92em; }
.pill-row { display: flex; flex-wrap: wrap; gap: .3rem; }
.health-pill { display: inline-block; padding: .06rem .55rem; border-radius: 999px; font-size: .84em; font-weight: 600; border: 1px solid; white-space: nowrap; }
.health-pill.ok { color: #34d399; border-color: rgba(52, 211, 153, .5); background: rgba(52, 211, 153, .08); }
.health-pill.bad { color: #fca5a5; border-color: rgba(239, 68, 68, .55); background: rgba(239, 68, 68, .1); white-space: normal; }
.health-pill.warn { color: #fcd34d; border-color: rgba(245, 158, 11, .5); background: rgba(245, 158, 11, .08); }
.health-pill.off { color: var(--text-dim); border-color: var(--border-strong); }
.cap-input { width: 6rem; }
.doctor-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.doctor-list { overflow-y: auto; min-height: 0; border: 1px solid var(--border-subtle); border-radius: 6px; }
.doctor-row { display: grid; grid-template-columns: 4.6rem 8.5rem 1fr; gap: .6rem; align-items: baseline; padding: .42rem .6rem; border-bottom: 1px solid var(--border-subtle); font-size: .92em; }
.doctor-row:last-child { border-bottom: none; }
.doctor-row .health-pill { text-align: center; }
.switch { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { position: relative; width: 2.3rem; height: 1.25rem; border-radius: 999px; background: var(--border-strong); transition: background .15s; flex: 0 0 auto; }
.switch-track::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: .95rem; height: .95rem; border-radius: 50%; background: #e5e7eb; transition: transform .15s; }
.switch input:checked + .switch-track { background: #0e7490; }
.switch input:checked + .switch-track::after { transform: translateX(1.05rem); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.command-bar { flex: 0 0 auto; display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); }
@media (max-width: 900px) { main:has(.data-engine-studio) { overflow: auto; } .data-engine-grid { grid-template-columns: 1fr; } }
.telemetry-rows .mono + .health-pill { margin-left: .5rem; }
