/*
 * Tokens: the light and dark palettes, radii and type scale of the React app's theme
 * (themes.ts), so a page moved over lands on the same ground. The document's `data-theme`
 * picks the palette; everything below reads the tokens, never a colour of its own. Two rules come with them: saturated
 * colour means status, and chrome is the brand navy or a neutral. Each status has an ink
 * (small marks, text) and a fill (areas).
 */
@font-face {
    font-family: "Instrument Sans Variable";
    font-style: normal;
    font-display: swap;
    font-weight: 400 700;
    src: url("../vendors/instrument-sans/instrument-sans-latin-ext-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
        U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Instrument Sans Variable";
    font-style: normal;
    font-display: swap;
    font-weight: 400 700;
    src: url("../vendors/instrument-sans/instrument-sans-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
        U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --primary: #002C6B;
    --primary-dark: #001B45;
    --secondary: #2563EB;
    --secondary-dark: #1D4FBF;

    --success: #0F7A46;
    --success-fill: #86D6A7;
    --warning: #9A5B00;
    --warning-fill: #DBA15A;
    --warning-strong: #9A5B00;  /* the chart's warning mark */
    --error: #C0272D;
    --error-fill: #D97872;

    --ground: #F4F6F9;
    --paper: #FFFFFF;
    --text: #1A2430;
    --text-secondary: #5D6A7A;
    --divider: #E1E5EA;
    --grey-50: #F4F6F8;
    --grey-100: #EAEDF1;
    --grey-200: #DBE1E7;
    --grey-300: #C9D0D8;
    --grey-400: #A9B2BC;
    --text-disabled: #8995A2;
    --sunk: #EDF0F4;
    --hover: rgb(0 44 107 / 6%);
    --selected: rgb(0 44 107 / 10%);

    /* Text on a saturated ground: navy, blue or a status. */
    --contrast-text: #FFFFFF;
    --error-dark: #991F24;
    --info: #0B5FD0;
    --info-ground: #E8F1FC;
    --info-text: #0A3A7A;
    --error-text: #8A1C21;
    --error-ground: #FBF1F1;
    --error-ground-text: #57302D;
    /* A tooltip sits off the surface: near-black in light, a raised grey in dark. */
    --tooltip: #1F2933;
    --tooltip-text: #FFFFFF;
    /* The side bar's flat navy, and the navy its menus open on - in both modes. */
    --bar-ground: #002C6B;
    --bar-paper: #0B1A33;
    color-scheme: light;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 16px;

    --font: "Instrument Sans Variable", "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* The React app's dark palette: the navy lifted to carry on a dark ground, the status inks
   brighter and their fills deeper, text dark on anything saturated. */
:root[data-theme="dark"] {
    --primary: #8FB6F0;
    --primary-dark: #6E9BE0;
    --secondary: #93B4FB;
    --secondary-dark: #7098E8;

    --success: #4ADE80;
    --success-fill: #146741;
    --warning: #F0B23C;
    --warning-fill: #916721;
    --warning-strong: #F0B23C;
    --error: #FF7A75;
    --error-fill: #C26B65;

    --ground: #11161D;
    --paper: #171D26;
    --text: #E8EDF3;
    --text-secondary: #8B97A6;
    --divider: #353E48;
    --grey-50: #282E37;
    --grey-100: #2D353E;
    --grey-200: #3E4753;
    --grey-300: #495460;
    --grey-400: #5D6A7A;
    --text-disabled: #6B7786;
    --sunk: #1D2430;
    --hover: rgb(143 182 240 / 9%);
    --selected: rgb(143 182 240 / 15%);

    --contrast-text: #191F25;
    --error-dark: #E86560;
    --info: #8FB6F0;
    --info-ground: rgb(143 182 240 / 12%);
    --info-text: #CFE0F8;
    --error-text: #FFB3AF;
    --error-ground: rgb(255 122 117 / 10%);
    --error-ground-text: #F4C7C7;
    --tooltip: #3E4753;
    --tooltip-text: #E8EDF3;
    --bar-ground: #071B3A;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
    margin: 0;
    min-height: 100%;
    background: var(--ground);
    color: var(--text);
    font: 400 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}

p, h1, h2, h3 { margin: 0; }

/* --- Buttons --------------------------------------------------------------------- */

.button {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 6px 14px;
    border: 1px solid transparent; border-radius: var(--radius-md);
    font: 500 14px/1.4 var(--font); text-decoration: none;
    cursor: pointer;
    transition: background-color 250ms, border-color 250ms;
}
.button-contained { background: var(--secondary); color: var(--contrast-text); }
/* The default filled button wears the brand navy. */
.button-primary { background: var(--primary); color: var(--contrast-text); }
.button-primary:hover { background: var(--primary-dark); }
/* On the dark ground React's contained button stayed navy with light text; the lifted
   primary is for text and marks, and as a fill it glared. */
:root[data-theme="dark"] .button-primary { background: #17386B; color: #E3EAF5; }
:root[data-theme="dark"] .button-primary:hover { background: #1F4788; }
:root[data-theme="dark"] .button-primary.disabled:hover, :root[data-theme="dark"] .button-primary:disabled:hover { background: #17386B; }
.button-contained:hover { background: var(--secondary-dark); }
.button-outlined { border-color: color-mix(in srgb, var(--secondary) 50%, transparent); color: var(--secondary); background: transparent; }
.button-outlined:hover { border-color: var(--secondary); background: color-mix(in srgb, var(--secondary) 4%, transparent); }
/* React's outlined button in the text's own colour: "Restore defaults", "Add pair". */
.button-outlined-neutral { border-color: var(--divider); color: var(--text); background: transparent; }
.button-outlined-neutral:hover { background: var(--hover); }
.button:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
.button .icon { flex: none; width: 18px; height: 18px; margin: 0 8px 0 -2px; }
/* A button that is only its words: a dialog's Cancel, a form's "add another". */
.button-text { color: var(--text); background: transparent; }
.button-text:hover { background: var(--hover); }
/* The quiet way back above a page's title. */
.button-quiet { padding: 4px 8px; margin-left: -8px; color: var(--text-secondary); font-size: 13px; }
.button-quiet:hover { color: var(--text); background: var(--hover); }
.button-error { background: var(--error); color: var(--contrast-text); }
.button-error:hover { background: var(--error-dark); }
.button-neutral { background: var(--grey-200); color: var(--text); }
.button-text-error { color: var(--error); }
/* A failed inspection task's error in its own column: the first line, the whole on a click. */
.data-grid td.task-error { max-width: 360px; }
.task-error-summary {
    display: block; max-width: 100%; padding: 0; border: 0; background: none; color: var(--error); font: inherit; cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; vertical-align: middle;
}
.task-error-summary:hover { text-decoration: underline; }
.button-text-error:hover { background: color-mix(in srgb, var(--error) 6%, transparent); }
.button-neutral:hover { background: var(--grey-300); }
/* An action the caller's role does not allow, shown with why on hover. */
.button.disabled, .button:disabled { opacity: 0.5; cursor: default; }
.button-primary.disabled:hover { background: var(--primary); }
/* While its request runs a button cannot start a second one. */
.button.htmx-request, .icon-button.htmx-request, .button.pending, .icon-button.pending { opacity: 0.5; pointer-events: none; }
/* The full-width call to action of a public page. */
.button-large { width: 100%; padding: 12px 14px; font-weight: 600; text-transform: uppercase; }
.button-contained.button-large { font-size: 16px; }

/* --- Text field --------------------------------------------------------------------
 * 40px high with its label inside: centred at rest, raised to 85% once the field has
 * focus or a value. The input's placeholder is a single space, which is what lets
 * :placeholder-shown tell an empty field from a filled one.
 */
.text-field {
    position: relative; display: block;
    border: 1px solid var(--divider); border-radius: var(--radius-lg);
    background: var(--grey-50);
    transition: border-color 120ms ease, background-color 120ms ease;
}
.text-field:hover { border-color: var(--grey-400); }
.text-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--paper); }
/* On a white panel the field needs no well of its own. */
.text-field-clear, .text-field-clear:focus-within { background: transparent; }
.text-field input {
    display: block; width: 100%; height: 39px;
    padding: 17px 12px 3px;
    border: 0; border-radius: inherit; outline: 0; background: transparent;
    color: var(--text); font: 400 13px/1.4375 var(--font);
}
.text-field > span {
    position: absolute; top: 0; left: 0;
    transform: translate(12px, 11px) scale(1); transform-origin: top left;
    color: var(--text-secondary); font-size: 13px; line-height: 1.4375;
    pointer-events: none;
    transition: transform 200ms cubic-bezier(0, 0, 0.2, 1);
}
.text-field input:focus + span,
.text-field input:not(:placeholder-shown) + span,
.text-field input:-webkit-autofill + span { transform: translate(12px, 4px) scale(0.85); }

.text-field.disabled { border-style: dashed; background: transparent; }
.text-field.disabled:hover { border-color: var(--divider); }
.text-field.disabled input, .text-field.disabled > span { color: var(--text-disabled); }
.text-field input[readonly] { cursor: default; }
/* A number is typed, not stepped: the browser's arrows are left out. */
.text-field input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.text-field input[type="number"]::-webkit-outer-spin-button,
.text-field input[type="number"]::-webkit-inner-spin-button { display: none; }

.field { min-width: 0; }

/* A few lines of text: the label stays raised, since an empty area has no middle to rest in. */
.text-area textarea {
    display: block; width: 100%; min-height: 100px; padding: 19px 12px 6px;
    border: 0; border-radius: inherit; outline: 0; background: transparent; resize: vertical;
    color: var(--text); font: 400 13px/1.5 var(--font);
}
.text-area > span { transform: translate(12px, 4px) scale(0.85); }
/* A field with a button at its end, e.g. to copy what it shows. */
.text-field-with-action { display: flex; align-items: center; padding-right: 6px; }
.text-field-with-action input { flex: 1; min-width: 0; }
.text-field-with-action .icon-button span { display: inline-flex; }
.text-field-with-action .icon-button .icon { width: 18px; height: 18px; }
.monospace { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; }
.field-helper { margin: 3px 12px 0; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.field-helper.field-error { color: var(--error-text); }
.field-helper-error { color: var(--error); }

/* --- Dropdown ------------------------------------------------------------------------
 * The control looks like a text field of its kind; the list opens over the page, placed
 * by select.js, on a paper of its own.
 */
.select { position: relative; }
.select-control {
    position: relative; display: flex; align-items: center; width: 100%; height: 41px;
    padding: 0 36px 0 12px;
    border: 1px solid var(--divider); border-radius: var(--radius-lg);
    background: var(--grey-50); color: var(--text);
    font: 400 13px/1.4375 var(--font); text-align: left;
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease;
}
.select-control:hover { border-color: var(--grey-400); }
.select-control:focus-visible, .select-control[aria-expanded="true"] {
    outline: 0; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--paper);
}
.select-control > .icon { position: absolute; right: 10px; width: 18px; height: 18px; color: var(--text-secondary); transition: transform 150ms; }
.select-control[aria-expanded="true"] > .icon { transform: rotate(180deg); }
.select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-labeled .select-value { padding-top: 14px; }
/* The label rests in the middle of an empty control and is raised over a chosen value. */
.select-label {
    position: absolute; top: 0; left: 0;
    transform: translate(12px, 4px) scale(0.85); transform-origin: top left;
    color: var(--text-secondary); line-height: 1.4375; pointer-events: none;
    transition: transform 200ms cubic-bezier(0, 0, 0.2, 1);
}
.select-labeled .select-control:has(.select-value:empty):not([aria-expanded="true"]) .select-label { transform: translate(12px, 11px) scale(1); }
.select.read-only .select-control { cursor: default; }
.select.read-only .select-control:hover { border-color: var(--divider); }
.select.read-only .select-control > .icon { display: none; }
.select.disabled .select-control { border-style: dashed; background: transparent; color: var(--text-disabled); cursor: default; }
.select.disabled .select-control:hover { border-color: var(--divider); }
.select.disabled .select-label, .select.disabled .select-control > .icon { color: var(--text-disabled); }

/* Choosing several: the chosen stand in the control as chips, which makes it as tall as
   they need, and the list ticks them. */
.multi-select .select-control { height: auto; min-height: 41px; padding-top: 16px; padding-bottom: 4px; cursor: pointer; }
.multi-select .select-control:focus-visible { outline: 0; }
.multi-select .select-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 19px; }
.multi-select .select-control:not(.filled):not([aria-expanded="true"]) .select-label { transform: translate(12px, 11px) scale(1); }
.multi-select.read-only .select-control { cursor: default; }
.chip-remove {
    display: inline-flex; margin: 0 -4px 0 0; padding: 1px;
    border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); cursor: pointer;
}
.chip-remove:hover { background: var(--hover); color: var(--text); }
.chip-remove .icon { width: 12px; height: 12px; }
.select-tick { display: inline-flex; width: 16px; margin-right: 8px; color: var(--primary); visibility: hidden; }
.select-tick .icon { width: 16px; height: 16px; }
.select-paper li[aria-selected="true"] .select-tick { visibility: visible; }

.select-backdrop { position: fixed; inset: 0; z-index: 1300; }

/* A period's field and its calendar: two months side by side, the days of the range shaded. */
.date-range-field { min-width: 230px; }
.date-range .select-control[aria-expanded="true"] > .icon { transform: none; }
.date-range-paper {
    position: fixed; z-index: 1301; display: flex; align-items: flex-start; gap: 8px; padding: 12px;
    border: 1px solid var(--divider); border-radius: var(--radius-lg); background: var(--paper); color: var(--text);
    box-shadow: 0 5px 5px -3px rgb(0 0 0 / 20%), 0 8px 10px 1px rgb(0 0 0 / 14%), 0 3px 14px 2px rgb(0 0 0 / 12%);
    outline: 0; font-size: 13px;
}
.date-range-month { display: grid; gap: 8px; justify-items: center; }
.date-range-month strong { line-height: 32px; font-weight: 600; }
.date-range-grid { display: grid; grid-template-columns: repeat(7, 34px); row-gap: 2px; }
.date-range-weekday { height: 28px; line-height: 28px; text-align: center; color: var(--text-secondary); font-size: 12px; }
.date-range-day {
    height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text);
    font: inherit; font-variant-numeric: tabular-nums; cursor: pointer;
}
.date-range-day.blank { visibility: hidden; }
.date-range-day:hover { background: var(--hover); }
.date-range-day.today { box-shadow: inset 0 0 0 1px var(--grey-400); }
.date-range-day.in-range { border-radius: 0; background: var(--selected); }
.date-range-day.range-start, .date-range-day.range-end { background: var(--primary); color: var(--contrast-text); box-shadow: none; }
.date-range-day.range-start:not(.range-end) { border-radius: 50% 0 0 50%; }
.date-range-day.range-end:not(.range-start) { border-radius: 0 50% 50% 0; }
/* A single day (`components/pickers.rs`): the period's calendar, one month, the day marked. */
.date-field { min-width: 170px; }
/* A time of day: an hour and a minute column, as MUI's desktop time picker had them. */
.time-field { min-width: 130px; }
.time-field .select-control[aria-expanded="true"] > .icon { transform: none; }
.time-paper {
    position: fixed; z-index: 1301; display: flex; gap: 4px; padding: 8px;
    border: 1px solid var(--divider); border-radius: var(--radius-lg); background: var(--paper); color: var(--text);
    box-shadow: 0 5px 5px -3px rgb(0 0 0 / 20%), 0 8px 10px 1px rgb(0 0 0 / 14%), 0 3px 14px 2px rgb(0 0 0 / 12%);
    outline: 0; font-size: 13px;
}
.time-column { width: 56px; max-height: 232px; margin: 0; padding: 0; overflow-y: auto; list-style: none; scrollbar-width: thin; }
.time-column + .time-column { border-left: 1px solid var(--divider); padding-left: 4px; }
.time-column li {
    height: 32px; margin: 2px 0; border-radius: var(--radius-sm); line-height: 32px; text-align: center;
    font-variant-numeric: tabular-nums; cursor: pointer;
}
.time-column li:hover { background: var(--hover); }
.time-column li.selected { background: var(--primary); color: var(--contrast-text); }
/* "All" in a list for choosing several: over the others, which it covers while it is chosen. */
.multi-select li.select-all { margin-bottom: 4px; border-bottom: 1px solid var(--divider); border-radius: var(--radius-sm) var(--radius-sm) 0 0; font-weight: 500; }
.multi-select li.covered { opacity: 0.55; cursor: default; }
.select-paper {
    position: fixed; z-index: 1301;
    display: flex; flex-direction: column;
    max-width: min(360px, calc(100vw - 16px));
    border: 1px solid var(--divider); border-radius: var(--radius-lg);
    background: var(--paper); color: var(--text);
    box-shadow: 0 5px 5px -3px rgb(0 0 0 / 20%), 0 8px 10px 1px rgb(0 0 0 / 14%), 0 3px 14px 2px rgb(0 0 0 / 12%);
    overflow: hidden;
}
.select-paper ul { flex: 1; min-height: 0; margin: 0; padding: 4px 0; overflow-y: auto; list-style: none; outline: 0; }
.select-paper li {
    display: flex; align-items: center; min-height: 32px; margin: 0 4px; padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    cursor: pointer;
}
.select-paper li.active { background: var(--hover); }
.select-paper li[aria-selected="true"] { background: var(--selected); font-weight: 500; }
.select-search {
    display: flex; align-items: center; gap: 8px; padding: 0 12px;
    border-bottom: 1px solid var(--divider); color: var(--text-secondary);
}
.select-search .icon { flex: none; width: 14px; height: 14px; }
.select-search input {
    flex: 1; min-width: 0; height: 36px; padding: 0;
    border: 0; outline: 0; background: transparent; color: var(--text); font: 400 13px/1.5 var(--font);
}
.select-search input::-webkit-search-cancel-button { display: none; }

/* --- Switch -----------------------------------------------------------------------------
 * A checkbox drawn as a track with a thumb; the input itself stays, for the keyboard and
 * for the form.
 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.switch input { position: absolute; width: 34px; height: 20px; margin: 0; opacity: 0; cursor: inherit; }
.switch-track { flex: none; position: relative; width: 34px; height: 20px; border-radius: 10px; background: var(--grey-400); transition: background-color 150ms; }
.switch-track::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 2px rgb(0 0 0 / 30%);
    transition: transform 150ms;
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--secondary); outline-offset: 2px; }
.switch:has(input:disabled) { cursor: default; }

/* --- Checkbox ------------------------------------------------------------------------ */

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.checkbox input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: inherit; }
.checkbox:has(input:disabled) { color: var(--text-disabled); cursor: default; }

/* --- Links, dividers, forms -------------------------------------------------------- */

.link-quiet { color: var(--text-secondary); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }

.form-stack { display: flex; flex-direction: column; gap: 24px; width: 100%; }
.form-note { text-align: center; }
/* Under a form rather than inside its stack. */
.form-note-after { margin-top: 24px; }

/* A form in a dialog: its fields one under the other, a step apart. */
.form-fields { display: flex; flex-direction: column; gap: 8px; }
.form-fields .labeled-divider { margin: 8px 0; }
.form-row-end { display: flex; justify-content: flex-end; }
/* A roomier form, and fields side by side in it. */
.form-fields-spaced { gap: 16px; padding-top: 8px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sql-field textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.key-value-row { display: grid; grid-template-columns: 1fr 1fr auto auto; align-items: center; gap: 16px; }
.key-value-row .icon-button { margin-left: -8px; }

/* A rule with a word in the middle of it. */
.labeled-divider { position: relative; text-align: center; line-height: 1.5; }
.labeled-divider::before { content: ""; position: absolute; top: 50%; left: 0; width: 100%; border-bottom: 1px solid var(--divider); }
.labeled-divider span {
    position: relative; padding: 0 16px; background: var(--paper);
    color: var(--text-secondary); font-size: 12px; font-weight: 500; letter-spacing: 1px;
}

/* --- Snackbar ---------------------------------------------------------------------- */

/* A popover, to be drawn over an open dialog: the browser's own frame around one is undone. */
.snackbar { position: fixed; inset: auto auto 24px 24px; z-index: 1400; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; }
.alert {
    display: flex; align-items: center; gap: 12px;
    padding: 6px 16px; border-radius: var(--radius-md);
    font-size: 14px; font-weight: 500; line-height: 1.43;
    box-shadow: 0 3px 5px -1px rgb(0 0 0 / 20%), 0 6px 10px 0 rgb(0 0 0 / 14%), 0 1px 18px 0 rgb(0 0 0 / 12%);
}
.alert-error { background: var(--error); color: var(--contrast-text); }
.alert-success { background: var(--success); color: var(--contrast-text); }
/* A note in the page rather than over it. */
.alert-info { background: var(--info-ground); color: var(--info-text); box-shadow: none; }
.alert-info .icon { flex: none; width: 20px; height: 20px; color: var(--info); }
.alert-soft-error { background: color-mix(in srgb, var(--error) 8%, transparent); color: var(--error-text); box-shadow: none; overflow-wrap: anywhere; }
.alert-soft-error .icon { flex: none; width: 20px; height: 20px; color: var(--error); }
.alert-icon { width: 22px; height: 22px; fill: currentColor; flex: none; opacity: 0.9; }
.alert-message { padding: 8px 0; }
.alert-close {
    display: inline-flex; padding: 5px; margin: 0 -8px 0 4px;
    border: 0; border-radius: var(--radius-md); background: transparent; color: inherit; cursor: pointer;
}
.alert-close:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.alert-close svg { width: 20px; height: 20px; fill: currentColor; }

/* --- Split page: the login page and the pages a user is sent to from it -------------
 * Branding and a customer's words on the navy left half, a white panel on the right.
 */
.split-page { display: flex; min-height: 100vh; }

.reference-panel {
    flex: 1; display: flex; flex-direction: column; justify-content: space-between;
    padding: 64px; background: var(--primary); color: #FFFFFF;
}
.reference-logo { display: block; height: 60px; }
.reference-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 48px; }
.reference-quote { max-width: 500px; font-size: 24px; font-weight: 500; line-height: 1.2; letter-spacing: -0.02em; }
.reference-author { display: flex; align-items: center; gap: 16px; }
.reference-author img { height: 40px; border-radius: 4px; }
.reference-author-name { font-weight: 600; }
.reference-author-role { font-size: 0.9rem; opacity: 0.7; }
.reference-footer { padding-top: 32px; border-top: 1px solid rgb(255 255 255 / 10%); font-size: 12px; line-height: 1.4; }
.reference-footer p { opacity: 0.6; }
.reference-footer .reference-read-more { margin-top: 8px; font-weight: 600; opacity: 1; }
.reference-footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.split-page-content {
    flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 32px; background: var(--paper);
}
.split-page-inner { width: 100%; max-width: 500px; }
.split-page-title { margin-bottom: 8px; font-size: 24px; font-weight: 500; line-height: 1.25; letter-spacing: -0.02em; }
.split-page-subtitle { margin-bottom: 48px; color: var(--text-secondary); font-size: 16px; line-height: 1.4; letter-spacing: -0.01em; }

@media (max-width: 900px) {
    .reference-panel { display: none; }
}

/* --- Public message page: a card on the navy ground ---------------------------------- */

.public-page {
    display: flex; flex-direction: column; justify-content: space-between;
    min-height: 100vh; padding: 64px;
    background: var(--primary); color: #FFFFFF;
}
.public-page-body { flex: 1; display: flex; justify-content: center; align-items: center; padding: 32px 0; }
.message-panel {
    display: flex; flex-direction: column; gap: 12px;
    width: 440px; max-width: 100%; padding: 40px 32px;
    border-radius: var(--radius-xl); background: var(--paper); color: var(--text);
}
.message-panel h1 { font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -0.014em; }
.message-panel-body { color: var(--text-secondary); }
.message-panel-detail {
    padding: 8px 12px; border: 1px solid var(--divider); border-radius: var(--radius-md);
    background: var(--grey-100); color: var(--text-secondary);
    font-size: 12px; line-height: 1.4; word-break: break-word;
}
.message-panel-action { padding-top: 16px; }

/* --- App shell: the side bar and the page beside it ----------------------------------
 * The bar sits on the brand navy whatever the page looks like, so it carries the dark
 * palette's inks, with rules and wells as white-alpha: the dark greys read muddy over a
 * saturated blue.
 */
[x-cloak] { display: none !important; }

.app-shell { display: flex; height: 100vh; }
.app-content { flex: 1; min-width: 0; overflow: auto; padding: 16px 20px; }

.side-bar {
    --bar-text: #E8EDF3;
    /* A row or button that is not selected: plainly readable, a step below the selected
       one's white - the headings' grey made every other row look disabled. */
    --bar-text-row: #C9D2DE;
    --bar-text-secondary: #8B97A6;
    --bar-rule: rgb(255 255 255 / 12%);
    --bar-well: rgb(255 255 255 / 6%);
    --bar-hover: rgb(255 255 255 / 8%);
    --bar-selected: rgb(143 182 240 / 16%);

    position: relative; flex: none; width: var(--side-bar-width, 260px);
    display: flex; flex-direction: column;
    background: var(--bar-ground); color: var(--bar-text);
    font-size: 13px;
}
/* Its right edge, dragged to set its width (`app.js`). */
.side-bar-resize { position: absolute; top: 0; bottom: 0; right: -3px; width: 6px; cursor: col-resize; z-index: 5; }
.side-bar-resize:hover, body.column-resizing .side-bar-resize { background: color-mix(in srgb, var(--secondary) 35%, transparent); }
body.column-resizing { cursor: col-resize; user-select: none; }
.side-bar-head { padding: 16px 12px 8px; }
.side-bar-logo { display: flex; align-items: center; height: 28px; margin: 0 0 20px 4px; border-radius: 4px; }
.side-bar-logo img { height: 100%; width: auto; }
.side-bar-rule { width: 100%; margin: 0; border: 0; border-bottom: 1px solid var(--bar-rule); }
/* A thin bar on a transparent track: the default light track would run down the navy. */
.side-bar-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--bar-rule) transparent; }

/* The filter: a 32px well without a floating label. */
.side-bar-filter {
    position: relative; display: flex; align-items: center;
    min-height: 33px; border: 1px solid var(--bar-rule); border-radius: var(--radius-lg);
    background: var(--bar-well);
    transition: border-color 120ms ease;
}
.side-bar-filter:hover { border-color: rgb(255 255 255 / 30%); }
.side-bar-filter:focus-within { border-color: #8FB6F0; box-shadow: 0 0 0 1px #8FB6F0; }
/* The project picker is the dropdown of every form, on the bar's navy: the same well as
   the filter, and a list that stays on a navy of its own. */
.side-bar-picker { margin: 0; }
.side-bar-picker .select-control {
    height: 33px; border-color: var(--bar-rule); background: var(--bar-well); color: var(--bar-text);
}
.side-bar-picker .select-control:hover { border-color: rgb(255 255 255 / 30%); }
.side-bar-picker .select-control:focus-visible, .side-bar-picker .select-control[aria-expanded="true"] {
    border-color: #8FB6F0; box-shadow: 0 0 0 1px #8FB6F0; background: var(--bar-well);
}
.side-bar-picker .select-control > .icon { width: 16px; height: 16px; color: var(--bar-text); }
.side-bar-picker .select-paper { border-color: var(--bar-rule); background: var(--bar-paper); color: var(--bar-text); }
.side-bar-picker .select-paper li.active { background: var(--bar-hover); }
.side-bar-picker .select-paper li[aria-selected="true"] { background: var(--bar-selected); }
.side-bar-picker .select-search { border-color: var(--bar-rule); color: var(--bar-text-secondary); }
.side-bar-picker .select-search input { color: var(--bar-text); }
.side-bar-filter { padding-left: 12px; gap: 8px; color: var(--bar-text-secondary); }
.side-bar-filter .icon { flex: none; width: 14px; height: 14px; }
.side-bar-filter input {
    flex: 1; min-width: 0; padding: 6px 12px 6px 0;
    border: 0; outline: 0; background: transparent;
    color: var(--bar-text); font: 400 13px/1.5 var(--font);
}
.side-bar-filter input::placeholder { color: var(--bar-text-secondary); opacity: 1; }
.side-bar-filter input::-webkit-search-cancel-button { display: none; }

.side-bar-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; }

/* A 28px row, shared by the sections and the data sources so the two keep one rhythm.
   The selected row is marked by its fill and a heavier, brighter label. */
.side-row {
    display: flex; align-items: center;
    min-height: 28px; padding: 4px 8px;
    border: 0; border-radius: var(--radius-md); background: transparent;
    color: var(--bar-text-row); font: 400 13px/1.5 var(--font);
    text-align: left; text-decoration: none; white-space: nowrap;
    cursor: pointer;
    transition: background-color 150ms, color 150ms;
}
.side-row:hover { background: var(--bar-hover); color: var(--bar-text); }
.side-row.selected { background: var(--bar-selected); color: var(--bar-text); font-weight: 600; }
.side-row .icon { flex: none; width: 16px; height: 16px; margin-right: 10px; }
.side-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.side-row:focus-visible, .icon-button:focus-visible { outline: 2px solid #8FB6F0; outline-offset: -2px; }

.side-bar-data-sources { display: flex; flex-direction: column; gap: 6px; padding: 12px 8px 16px; }
.side-bar-data-sources h2 { margin: 0; padding: 0 8px; color: var(--bar-text-secondary); font-size: 12px; font-weight: 400; line-height: 1.4; }
.side-bar-list { display: flex; flex-direction: column; gap: 2px; }
/* A chosen data source is no section: a bar at its start and a bold name, as React told the
   two apart, where the same filled row made them read as siblings. */
.side-bar-list .side-row.selected { background: transparent; border-radius: 0; box-shadow: inset 2px 0 0 var(--bar-text); }
.side-bar-list .side-row.selected:hover { background: var(--bar-hover); }

.side-bar-foot { display: flex; align-items: center; gap: 4px; padding: 4px 8px; }
.profile { position: relative; flex: 1; min-width: 0; }
.profile-button { width: 100%; min-height: 32px; gap: 8px; color: var(--bar-text); }
.avatar {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: var(--radius-md);
    background: #8FB6F0; color: #191F25; font-size: 11px; font-weight: 600;
}
.icon-button {
    flex: none; display: inline-flex; padding: 5px;
    border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 150ms, color 150ms;
}
.icon-button:hover { background: var(--hover); color: var(--text); }
.side-bar .icon-button { color: var(--bar-text-row); }
.icon-button.disabled { cursor: default; }
.icon-button .icon { width: 20px; height: 20px; }
.side-bar a.icon-button:hover { background: var(--bar-hover); color: var(--bar-text); }
.icon-button.disabled { opacity: 0.4; }

/* A menu opening out of the bar stays on a navy of its own. */
.menu-backdrop { position: fixed; inset: 0; z-index: 1299; }
.menu {
    position: absolute; left: 0; bottom: calc(100% + 4px); z-index: 1300;
    min-width: 100%; max-width: 280px; padding: 8px 0;
    border: 1px solid var(--bar-rule); border-radius: var(--radius-lg);
    background: var(--bar-paper); color: var(--bar-text);
    box-shadow: 0 5px 5px -3px rgb(0 0 0 / 20%), 0 8px 10px 1px rgb(0 0 0 / 14%), 0 3px 14px 2px rgb(0 0 0 / 12%);
}
.menu hr { margin: 8px 0; border: 0; border-bottom: 1px solid var(--bar-rule); }
.menu-head { padding: 4px 16px 0; }
.menu-head p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head-name { font-size: 13px; font-weight: 600; line-height: 1.45; }
.menu-head-detail { color: var(--bar-text-secondary); font-size: 12px; line-height: 1.4; }
.menu form { margin: 0; }
.menu-item {
    display: flex; align-items: center; gap: 12px;
    width: calc(100% - 8px); min-height: 32px; margin: 0 4px; padding: 4px 12px;
    border: 0; border-radius: var(--radius-sm); background: transparent;
    color: var(--bar-text); font: 400 13px/1.5 var(--font); text-align: left; text-decoration: none;
    cursor: pointer;
}
.menu-item:hover { background: var(--bar-hover); }
.menu-item .icon { flex: none; width: 20px; height: 20px; color: var(--bar-text-secondary); }

/* --- Load bar: a request is running ---------------------------------------------------- */

.load-bar { position: fixed; top: 0; left: 0; z-index: 2000; width: 100%; height: 3px; overflow: hidden; opacity: 0; pointer-events: none; transition: opacity 200ms 150ms; }
.load-bar::before { content: ""; position: absolute; inset: 0; width: 40%; background: var(--secondary); animation: load-bar 1.2s ease-in-out infinite; }
.load-bar.htmx-request { opacity: 1; }
@keyframes load-bar { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* --- Dialog --------------------------------------------------------------------------- */

.dialog {
    width: calc(100% - 64px); max-width: 444px; max-height: calc(100% - 64px);
    padding: 0; overflow: hidden;
    border: 1px solid var(--divider); border-radius: var(--radius-xl);
    background: var(--paper); color: var(--text);
    box-shadow: 0 11px 15px -7px rgb(0 0 0 / 20%), 0 24px 38px 3px rgb(0 0 0 / 14%), 0 9px 46px 8px rgb(0 0 0 / 12%);
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: rgb(0 0 0 / 50%); }
.dialog-medium { max-width: 600px; }
.dialog-wide { max-width: 900px; }
.dialog-full { max-width: 1536px; }
.dialog-title { flex: none; margin: 0; padding: 14px 20px 10px; font-size: 16px; font-weight: 600; line-height: 1.6; letter-spacing: -0.01em; }
.dialog-title-row { display: flex; align-items: center; gap: 8px; }
.dialog-content { flex: 1; min-height: 0; padding: 4px 20px 16px; overflow-y: auto; }
.dialog-actions { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding: 8px 12px 12px; }
/* A button that stands apart from the ones that leave the dialog. */
.dialog-action-start { margin-right: auto; }
.dialog-close { position: absolute; top: 8px; right: 8px; }
.dialog-text { color: var(--text-secondary); }
/* The side bar's "About": a line per build. */
.about-lines { display: flex; flex-direction: column; gap: 8px; }
.dialog-text-breaking { word-break: break-word; white-space: pre-wrap; }
.dialog-text-spaced { margin-bottom: 16px; }
.status-icon { display: inline-flex; }
.status-icon .icon { width: 24px; height: 24px; }
.status-icon-success { color: var(--success); }
.status-icon-error { color: var(--error); }

/* --- Sectioned page: a header band, the sections down the left, the open one beside ---- */

.sectioned-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.sectioned-page-header {
    flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--divider); background: var(--paper);
}
.sectioned-page-header { position: relative; }
.sectioned-page-header .button-quiet { margin-bottom: 12px; }
.sectioned-page-header:has(.sectioned-page-actions) { padding-right: 128px; }
.sectioned-page-actions { position: absolute; top: 16px; right: 16px; display: flex; align-items: center; gap: 4px; }
/* A project's sectioned page beside the side bar: it takes the content area whole. */
.app-content:has(> .sectioned-page), .app-content:has(> .content-page) { padding: 0; overflow: hidden; }
.app-content > .sectioned-page, .app-content > .content-page { height: 100%; }
/* A page beside the side bar that is one view: the header band, then the view, scrolling. */
.content-page { display: flex; flex-direction: column; }
.content-page-header {
    flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    padding: 20px 16px 12px; border-bottom: 1px solid var(--divider); background: var(--paper);
}
.content-page-header h1 { font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -0.014em; }
.content-page-header p { color: var(--text-secondary); font-size: 13px; }
.content-page-actions { display: flex; align-items: center; gap: 8px; }
.content-page-body { flex: 1; min-height: 0; overflow: auto; }
/* The way back from a data source to its section, over the page's header band. */
.app-content:has(> .shell-crumbs) { display: flex; flex-direction: column; }
.shell-crumbs {
    flex: none; display: flex; align-items: center; gap: 6px; min-width: 0;
    padding: 12px 16px 0; background: var(--paper); color: var(--text-secondary); font-size: 12px; line-height: 1.4;
}
.shell-crumbs a { color: inherit; text-decoration: none; }
.shell-crumbs a:hover { text-decoration: underline; }
.shell-crumbs-here { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-content > .shell-crumbs + .content-page, .app-content > .shell-crumbs + .sectioned-page { flex: 1; min-height: 0; height: auto; }
.shell-crumbs + .content-page > .content-page-header { padding-top: 6px; }
.sectioned-page-header .button-quiet .icon { margin-right: 4px; }
.sectioned-page-header h1 { font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -0.014em; }
.sectioned-page-header p { color: var(--text-secondary); font-size: 13px; }
.sectioned-page-header .sectioned-page-note { white-space: pre-line; font-size: 12px; }
.sectioned-page-body { flex: 1; min-height: 0; display: flex; }
.sectioned-page-nav {
    flex: none; width: 208px; padding: 12px 8px; overflow-y: auto;
    border-right: 1px solid var(--divider); background: var(--paper);
}
.sectioned-page-section { flex: 1; min-width: 0; overflow: auto; }
.nav-group { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.nav-group h2 { margin: 0; padding: 0 8px; color: var(--text-secondary); font-size: 12px; font-weight: 400; line-height: 28px; }
/* The side bar's 28px row, on a white ground. One that can be opened is in the text's own
   colour, its icon a step lighter; the groups' headings are grey and a row that cannot be
   opened is faded - in grey too, every row read as a heading or as disabled. */
.nav-row {
    display: flex; align-items: center; min-height: 28px; padding: 4px 8px;
    border-radius: var(--radius-md); color: var(--text);
    font-size: 13px; line-height: 1.5; text-decoration: none; white-space: nowrap;
    transition: background-color 150ms;
}
.nav-row:hover { background: var(--hover); }
.nav-row.selected { background: var(--selected); color: var(--text); font-weight: 600; }
.nav-row.disabled, .nav-row.disabled .icon { color: var(--text-disabled); cursor: default; }
.nav-row.disabled:hover { background: transparent; }
.nav-row .icon { flex: none; width: 16px; height: 16px; margin-right: 10px; color: var(--text-secondary); }
.nav-row.selected .icon { color: var(--text); }
.nav-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.section { display: flex; flex-direction: column; max-height: 800px; padding: 32px 16px; }
.section-toolbar { display: flex; justify-content: flex-end; margin-bottom: 16px; }
/* A section that shows rather than lists: held to a reading width, its parts a step apart. */
.section-narrow { max-width: 800px; max-height: none; gap: 32px; }
.section-stack { max-height: none; gap: 24px; }
/* A section of settings, saved as they change: held to a form's width. */
.section-settings { max-width: 640px; max-height: none; gap: 32px; }
.form-section h2 { margin: 0 0 12px; font-size: 13px; font-weight: 600; line-height: 1.45; }
.form-section .form-fields { gap: 16px; }
.form-section-text { color: var(--text-secondary); font-size: 13px; }
/* A section whose grid takes what height there is and scrolls inside it. */
.section-fill { height: 100%; max-height: 800px; gap: 16px; }

/* --- Filter bar: what a grid shows, chosen over it --------------------------------------- */

/* A form around a grid whose headings hold its filters: no box of its own. */
.filter-form { display: contents; }
/* A column's heading with its filter: the name, then a funnel that opens the choices. An idle
   funnel stays faint - a dozen at full strength crowd a header - and comes up with its column;
   one that narrows the grid is navy with a dot. */
.data-grid th.column-filter { overflow: visible; }
.column-filter-heading { display: flex; align-items: center; gap: 2px; min-width: 0; }
.column-filter-heading > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.column-filter-heading .field { flex: none; width: auto; }
.select-funnel {
    position: relative; display: inline-flex; padding: 4px; border: 0; border-radius: 50%;
    background: transparent; color: var(--text-secondary); opacity: 0.35; cursor: pointer;
    transition: opacity 120ms ease;
}
.select-funnel .icon { width: 15px; height: 15px; }
th:hover .select-funnel, .select-funnel:focus-visible, .select-funnel[aria-expanded="true"] { opacity: 1; }
.select-funnel:hover { background: var(--hover); }
.select-funnel.filtered { opacity: 1; background: var(--selected); color: var(--primary); }
.select-funnel.filtered::after {
    content: ""; position: absolute; top: 2px; right: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
}
/* The list is as wide as a list, not as the funnel; and its heading stands over the other
   headings while it is open, or theirs - sticky, each a layer of its own - would cover it. */
.column-filter-heading .select-paper { min-width: 200px !important; font-weight: 400; }
.data-grid th.column-filter:has([aria-expanded="true"]) { z-index: 3; }

.filter-bar { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px; margin: 0; }
.filter-bar > .field { width: 170px; }
.filter-bar .select-control, .filter-bar .text-field { background: var(--paper); }
.filter-bar-gap { flex: 1; }
.filter-bar .time-range .select-control { height: 41px; }
.filter-bar .time-range input[type="date"] { height: 41px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.section-heading h2 { margin: 0 0 4px; font-size: 13px; font-weight: 600; line-height: 1.45; }
.section-heading p { color: var(--text-secondary); font-size: 13px; }
.section-heading .button { flex: none; }

/* --- Panel: a titled card, and the label-and-value rows in one ------------------------- */

.panel h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; line-height: 1.45; }
.panel-card { padding: 16px 24px; border: 1px solid var(--divider); border-radius: var(--radius-xl); font-size: 13px; }
.panel-card-paper { background: var(--paper); }
.panel-strong { font-weight: 600; }
.panel-muted { color: var(--text-secondary); }
.pre-line { white-space: pre-line; }
.wrap-anywhere { overflow-wrap: anywhere; }
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; }
.detail-row + .detail-row { border-top: 1px solid var(--divider); }
.detail-row-label { flex: none; color: var(--text-secondary); }
.detail-row-value { text-align: right; font-variant-numeric: tabular-nums; }
.panel-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.panel-actions-gap { flex: 1; }
.plain-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.plain-table th { padding: 6px 16px; border-bottom: 1px solid var(--divider); font-weight: 600; text-align: left; }
.plain-table td { padding: 6px 16px; border-bottom: 1px solid var(--divider); }
.plain-table tr:last-child td { border-bottom: 0; }
.plain-table th:first-child, .plain-table td:first-child { padding-left: 0; }
.plain-table th:last-child, .plain-table td:last-child { padding-right: 0; }
.numeric { text-align: right !important; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-secondary); }

/* --- Time range ------------------------------------------------------------------------- */

.time-range { display: flex; align-items: center; gap: 8px; margin: 0; }
.time-range .select { min-width: 170px; }
.time-range .select-control { height: 36px; background: var(--paper); }
.time-range input[type="date"] {
    height: 36px; padding: 0 10px;
    border: 1px solid var(--divider); border-radius: var(--radius-lg); background: var(--paper);
    color: var(--text); font: 400 13px/1.5 var(--font);
}
.time-range input[type="date"]:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.time-range-dash { color: var(--text-secondary); }

/* --- Data grid -------------------------------------------------------------------------- */

.data-grid {
    min-height: 0; display: flex; flex-direction: column;
    border: 1px solid var(--divider); border-radius: var(--radius-xl);
    background: var(--paper); overflow: hidden;
    font-size: 13px; font-variant-numeric: tabular-nums;
}
.data-grid table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-grid th {
    height: 36px; padding: 0 10px;
    background: var(--sunk); border-bottom: 1px solid var(--divider);
    font-weight: 600; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* A heading's right edge, dragged to set the column's width (`grid.js`): a hair's line
   that shows where to take hold. */
.data-grid th { position: relative; }
.column-resize { position: absolute; top: 0; bottom: 0; right: 0; width: 9px; cursor: col-resize; z-index: 1; }
.column-resize::after { content: ""; position: absolute; top: 9px; bottom: 9px; right: 0; width: 1px; background: var(--divider); }
.column-resize:hover::after, body.column-resizing .column-resize:hover::after { top: 0; bottom: 0; width: 2px; background: var(--secondary); }
.data-grid td {
    height: 32px; padding: 4px 10px;
    border-bottom: 1px solid var(--divider);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-grid tbody tr { position: relative; }
.data-grid tbody tr:hover { background: var(--hover); }
.data-grid td.muted { color: var(--text-disabled); }
.data-grid-actions { width: 1px; padding: 0 !important; overflow: visible !important; }
.grid-checkbox { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); vertical-align: middle; }
.data-grid-scroll { flex: 1; min-height: 0; }
.data-grid-body { flex: 1; min-height: 0; overflow: auto; }
.data-grid-scroll thead th { position: sticky; top: 0; z-index: 2; }
.data-grid-scroll table { table-layout: auto; }
.data-grid-dialog { height: 600px; max-height: calc(100vh - 200px); }
.data-grid-pager { gap: 8px; }
.data-grid-pager span { margin-right: 8px; }
.data-grid-pager .icon-button .icon { width: 18px; height: 18px; }
/* A heading that orders the grid by its column; the arrow shows on the one it is ordered by. */
.sort-header { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
button.sort-header { max-width: 100%; padding: 0; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.sort-header .icon { width: 14px; height: 14px; opacity: 0; transition: opacity 120ms, transform 120ms; }
.sort-header:hover .icon { opacity: 0.4; }
.sort-header.sorted .icon { opacity: 1; }
.sort-header.ascending .icon { transform: rotate(180deg); }
/* A cell that opens the whole of what it shows the start of. */
.cell-button {
    display: block; width: 100%; max-width: 420px; padding: 0;
    border: 0; background: transparent; color: inherit; font-size: 12px; text-align: left;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.cell-button:hover { color: var(--secondary); }
.code-block-head { display: flex; align-items: center; justify-content: space-between; }
.code-block-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.code-block-head .icon-button span { display: inline-flex; }
.code-block-head .icon-button .icon { width: 18px; height: 18px; }
.code-block {
    margin: 0; padding: 12px; max-height: 320px; overflow: auto;
    border-radius: 4px; background: var(--hover);
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap; word-break: break-word;
}

/* --- Status chip ------------------------------------------------------------------------ */

.status-chip {
    display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
    border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.status-chip .icon { width: 14px; height: 14px; }
.status-chip-neutral { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text-secondary); }
.status-chip-success { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); }
.status-chip-error { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); }
.status-chip-warning { background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); }
.status-chip-hollow { background: transparent; border: 1px solid var(--divider); color: var(--text-secondary); }
.status-mark { display: inline-flex; width: 14px; justify-content: center; font-weight: 700; }
.spinner {
    width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.data-grid-empty { padding: 32px 16px; color: var(--text-secondary); text-align: center; }
/* Rows of two lines: a name over a detail. */
.data-grid-tall td { height: 56px; }
.data-grid-tall table { table-layout: auto; }
.column-wide { width: 24%; }
.two-line { display: flex; flex-direction: column; line-height: 1.3; }
.two-line .muted { font-size: 12px; }
.status-icon-small .icon { width: 18px; height: 18px; }
.data-grid-footer { display: flex; align-items: center; justify-content: flex-end; min-height: 40px; padding: 0 16px; }
/* A footer with the grid's row limit: how many rows came back at its start, how many were
   asked for at its end. */
.data-grid-limited { justify-content: space-between; }
/* The CSV download `grid.js` adds at the footer's end. */
.data-grid-footer .grid-csv { margin-left: 8px; padding: 4px; color: var(--text-secondary); }
.data-grid-footer .grid-csv .icon { width: 18px; height: 18px; }
.data-grid-limited .grid-limit { margin-left: auto; }
.grid-limit { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.grid-limit input {
    width: 96px; height: 28px; padding: 0 8px; border: 1px solid var(--divider); border-radius: var(--radius-sm);
    background: var(--paper); color: var(--text); font: inherit; font-variant-numeric: tabular-nums; text-align: right;
}
.grid-limit input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.data-grid-empty td { padding: 24px 8px; color: var(--text-secondary); text-align: center; }
/* A row's actions wait at its end and show while it is hovered or one of them has focus. */
.actions-bar {
    position: absolute; top: 50%; right: 4px; z-index: 1; transform: translateY(-50%);
    display: none; align-items: center; gap: 8px; padding: 0 4px;
    border: 1px solid var(--divider); border-radius: var(--radius-md); background: var(--paper);
}
.data-grid tr:hover .actions-bar, .actions-bar:focus-within { display: flex; }
.actions-bar .icon-button { padding: 4px; }

.chip {
    display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 4px;
    border: 1px solid var(--grey-300); border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.chip-plain { padding: 0 8px; }
.chip-warning { border-color: var(--warning); color: var(--warning); }
.chip-row { display: inline-flex; align-items: center; gap: 8px; }
/* A chip that opens what it names. */
.chip-button { background: transparent; color: inherit; font-family: var(--font); cursor: pointer; }
.chip-button:hover { background: var(--hover); }
.multi-select .chip { padding: 0 8px; }
.chip-logo { flex: none; width: 16px; height: 16px; border-radius: 2px; object-fit: contain; }
.chip-monogram {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--grey-100); color: var(--text-secondary);
    font-size: 8px; font-weight: 600; letter-spacing: -0.02em; user-select: none;
}

/* --- Rule builder ---------------------------------------------------------------------
 * The expression as nested groups: a group's frame shows while the pointer is in it, or
 * always when it is in parentheses, and a part's buttons show while the pointer is on it.
 */
.rule-builder { display: flex; flex-direction: column; }
.rule-group {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    width: 100%; padding: 8px;
    border: 1px solid transparent; border-radius: var(--radius-xl);
    transition: border-color 120ms;
}
.rule-group:hover, .rule-group.parenthesised { border-color: var(--divider); }
.rule-expression { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.rule-kind { flex: none; width: 120px; }
.rule-value { flex: 1 1 200px; min-width: 120px; }
.rule-operator { display: flex; align-items: center; gap: 8px; }
.rule-buttons { display: flex; gap: 8px; }
.rule-builder .icon-button { padding: 4px; visibility: hidden; }
.rule-builder .icon-button .icon { width: 18px; height: 18px; }
.rule-expression:hover > .rule-buttons .icon-button,
.rule-group:hover > .rule-operator > .icon-button,
.rule-group:hover > .rule-buttons .icon-button,
.rule-group.parenthesised > .rule-operator > .icon-button,
.rule-builder .icon-button:focus-visible { visibility: visible; }

/* --- Tabs ------------------------------------------------------------------------------ */

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--divider); }
.tab {
    min-height: 36px; padding: 6px 12px; margin-bottom: -1px;
    border: 0; border-bottom: 2px solid transparent; background: transparent;
    color: var(--text-secondary); font: 500 13px/1.5 var(--font); cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.selected { border-bottom-color: var(--primary); color: var(--primary); }
a.tab { display: inline-flex; align-items: center; text-decoration: none; }

/* --- Page furniture ------------------------------------------------------------------ */

.page-header { display: flex; align-items: center; min-height: 44px; margin-bottom: 16px; }
.page-header h1 { font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -0.014em; }
.placeholder-panel {
    display: grid; gap: 8px; padding: 32px;
    border: 1px solid var(--divider); border-radius: var(--radius-xl);
    background: var(--paper); color: var(--text-secondary);
}
.placeholder-panel strong { color: var(--text); font-weight: 600; }

/* --- The anomaly chart proof of concept --------------------------------------------- */

.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 20px; }
.tag { color: var(--text-secondary); font-size: 12px; }

.poc-page { padding: 24px; }
.poc-page main { max-width: 1200px; }

.controls {
    display: flex; align-items: end; gap: 16px; flex-wrap: wrap;
    padding: 12px 16px; margin-bottom: 16px;
    background: var(--paper); border: 1px solid var(--divider); border-radius: 8px;
}
.controls label { display: grid; gap: 4px; color: var(--text-secondary); font-size: 12px; }
.controls input {
    padding: 6px 8px; font: inherit; color: var(--text);
    border: 1px solid var(--divider); border-radius: 6px; background: var(--paper);
}
.controls input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.htmx-indicator { color: var(--text-secondary); opacity: 0; transition: opacity 150ms; padding-bottom: 6px; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

.message {
    padding: 48px 16px; text-align: center; color: var(--text-secondary);
    background: var(--paper); border: 1px solid var(--divider); border-radius: 8px;
}

.chart-panel {
    display: flex; align-items: center; gap: 16px;
    padding: 16px; background: var(--paper); border: 1px solid var(--divider); border-radius: 8px;
}
/* min-width 0, or the chart keeps its width when the summary beside it changes. */
.chart { flex: 1; min-width: 0; aspect-ratio: 5 / 2; }

.summary { width: 220px; flex: none; display: grid; gap: 12px; }
.summary-date { display: grid; }
.summary-date span { color: var(--text-secondary); font-size: 12px; }
.summary dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.summary dt { color: var(--text-secondary); }
.summary dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.status { justify-self: start; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--divider); }
.status-0 { background: color-mix(in srgb, var(--success-fill) 30%, white); }
.status-1 { background: color-mix(in srgb, var(--warning-fill) 45%, white); }
.status-2 { background: var(--error); color: var(--contrast-text); }

.chart-tooltip span { color: var(--text-secondary); font-size: 12px; }
.chart-tooltip strong { display: block; }
.chart-tooltip .value { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--divider); text-align: right; font-weight: 600; }

@media (max-width: 800px) {
    .chart-panel { flex-direction: column; align-items: stretch; }
    .summary { width: auto; }
}

/* --- Inspection hub --------------------------------------------------------------------- */

/* The section's own buttons stand at its start, over the filters. */
.section-toolbar-start { justify-content: flex-start; gap: 8px; margin-bottom: 0; }
.button-outlined-error { border: 1px solid color-mix(in srgb, var(--error) 50%, transparent); background: transparent; color: var(--error); }
.button-outlined-error:hover { border-color: var(--error); background: color-mix(in srgb, var(--error) 6%, transparent); }

.invoker { display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.invoker .icon { width: 18px; height: 18px; flex: none; }
.status-cell { display: inline-flex; align-items: center; gap: 4px; }
/* A failed request's way to its error, beside its status and there without a hover. */
.status-cell-error { width: 24px; height: 24px; padding: 0; color: var(--error); }
.status-cell-error:hover { color: var(--error); }
.status-cell-error .icon { width: 16px; height: 16px; }
/* A note over a dialog's grid. */
.dialog-note { margin-bottom: 12px; }

/* A note that shows while its owner is hovered; what it says may arrive only then. */
/* A field's help (`components/help.rs`), as React's: a question mark beside the field or label,
   faint until wanted - so a form full of them reads as fields - and plain on focus or hover. */
.help-button { flex: none; padding: 2px; color: var(--text-secondary); opacity: 0.4; transition: opacity 150ms; }
.help-button:hover, .help-button:focus-visible { opacity: 1; }
.help-button .icon { width: 18px; height: 18px; }
/* Centred on the field's box, not on the helper line under it. */
.field-with-help { display: flex; align-items: flex-start; gap: 4px; min-width: 0; }
.field-with-help > :first-child { flex: 1; min-width: 0; }
.field-with-help > .help-button { margin-top: 9px; }
.label-with-help { display: inline-flex; align-items: center; gap: 4px; }
.labeled-divider .label-with-help .help-button { padding: 0; }
/* A help text: Markdown, its tables bordered as React drew them. */
.help-text { font-size: 14px; line-height: 1.6; }
.help-text > :first-child { margin-top: 0; }
.help-text > :last-child { margin-bottom: 0; }
.help-text p, .help-text ul, .help-text ol { margin: 0 0 12px; }
.help-text ul, .help-text ol { padding-left: 22px; }
.help-text h1, .help-text h2, .help-text h3, .help-text h4 { margin: 16px 0 8px; font-size: 15px; font-weight: 600; }
.help-text code { padding: 1px 4px; border-radius: var(--radius-sm); background: var(--grey-100); font-size: 13px; }
.help-text pre { padding: 8px 12px; border-radius: var(--radius-md); background: var(--grey-100); overflow-x: auto; }
.help-text pre code { padding: 0; background: none; }
.help-text table { width: 100%; margin: 0 0 12px; border-collapse: collapse; font-size: 13px; }
.help-text th, .help-text td { padding: 10px; border: 1px solid var(--divider); text-align: left; vertical-align: top; }
.help-text th { font-weight: 600; }

/* Every hint (`tooltip.js`), as React's theme drew it: off the surface, an arrow at what it
   is about, over it unless there is no room. A popover, so it is drawn over a dialog. */
.tooltip {
    position: fixed; inset: auto; margin: 0; max-width: 320px; padding: 6px 10px;
    border: 0; border-radius: var(--radius-md); background: var(--tooltip); color: var(--tooltip-text);
    font-size: 12.5px; font-weight: 500; line-height: 1.45; white-space: pre-line; overflow-wrap: break-word;
    overflow: visible; pointer-events: none; opacity: 0; transition: opacity 120ms;
}
.tooltip.tooltip-open { opacity: 1; }
.tooltip-arrow {
    position: absolute; bottom: -4px; width: 8px; height: 8px; margin-left: -4px;
    background: var(--tooltip); transform: rotate(45deg);
}
.tooltip-below .tooltip-arrow { top: -4px; bottom: auto; }
.tooltip-left .tooltip-arrow { right: -4px; bottom: auto; margin: -4px 0 0; }
.hover-note { position: relative; display: inline-flex; }
.hover-note-text {
    position: absolute; z-index: 5; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    display: none; padding: 6px 10px; border-radius: var(--radius-lg);
    background: var(--tooltip); color: var(--tooltip-text); font-size: 12px; line-height: 1.5; white-space: nowrap;
    pointer-events: none;
}
.hover-note:hover .hover-note-text { display: block; }

/* A long text held to one line of its column; its title has more. */
.cell-text { display: block; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

/* A module's toggles, three to a row. */
.toggle-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; }
.checkbox-with-help p { margin: 2px 0 0 24px; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.text-field input[type="date"] { font-family: var(--font); }
/* A chip in a crowded row gives way before the row does. */
.chip-clip { display: inline-block; max-width: 120px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

/* --- A project's configuration ----------------------------------------------------------- */

.toolbar-buttons { display: flex; align-items: center; gap: 8px; }
.toolbar-buttons .button { white-space: nowrap; }
.button-text.disabled:hover { background: transparent; }

/* A sample of a data source's rows: as wide as its columns, scrolled sideways. */
.records-controls { display: flex; gap: 16px; margin-bottom: 16px; }
.records-controls .field { width: 180px; }
/* The picker takes the row, as React's did beside the copy button: a check's name is long,
   and the limit's own width cut it to a few letters. */
.records-controls .records-picker-wide { flex: 1; width: auto; min-width: 0; }
.records-controls .records-picker-wide .field { width: 100%; }
/* The query's copy button ends the row, whatever stands before it. */
.records-controls .records-copy-query { align-self: center; margin-left: auto; flex: none; }
.records-copy-query span { display: inline-flex; }
#records-result { display: flex; flex-direction: column; gap: 12px; }
.records-grid { overflow-x: auto; max-height: 60vh; }
.records-grid table { width: max-content; min-width: 100%; }
.records-grid td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.records-null { color: var(--text-disabled); font-style: italic; }
.code-block-short { max-height: 120px; overflow: auto; }

/* The data sources to export, one tick box each. */
.export-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.export-list .export-all { padding-bottom: 6px; border-bottom: 1px solid var(--divider); }

/* An import's three steps, and what it plans or did, part by part. */
.stepper { display: flex; gap: 24px; margin: 0 0 24px; padding: 0; list-style: none; }
.stepper li { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 13px; }
.stepper li.active { color: var(--text); font-weight: 600; }
.stepper-mark {
    display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
    border-radius: 50%; background: var(--grey-300); color: #FFFFFF; font-size: 12px; font-weight: 600;
}
.stepper li.active .stepper-mark, .stepper li.done .stepper-mark { background: var(--primary); }
.stepper-mark .icon { width: 14px; height: 14px; }
.import-upload { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 40px 0; }
.import-upload .button { cursor: pointer; }
.import-heading { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.import-list { max-height: 400px; overflow: auto; margin: 0; padding: 8px 0; list-style: none; border: 1px solid var(--divider); border-radius: var(--radius-md); }
.import-list > li + li { border-top: 1px solid var(--divider); }
.import-list ul { margin: 0; padding: 0 0 4px 32px; list-style: none; }
.import-item { display: flex; align-items: flex-start; gap: 12px; padding: 6px 16px; }
.import-item .status-icon { margin-top: 2px; }
.import-label { color: var(--text-secondary); font-weight: 600; }
.import-detail { color: var(--text-secondary); font-size: 12px; }
.import-icon-primary { color: var(--secondary); }
.import-icon-quiet { color: var(--text-disabled); }

/* --- A data source's page ---------------------------------------------------------------- */

.chip-row-clipped { flex-wrap: nowrap; overflow: hidden; max-width: 100%; }
.chip-more { cursor: default; }
.form-row-wide-first { grid-template-columns: 2fr 1fr; }
.page-reloader { display: none; }

/* A dataset definition's relevance rules: check, operator, value, and the cross. */
.rules { display: flex; flex-direction: column; gap: 8px; }
.rules-head { display: flex; align-items: center; justify-content: space-between; }
.rules-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.rules-empty { padding: 8px 0; color: var(--text-secondary); font-size: 13px; text-align: center; }
.rules-and { color: var(--text-secondary); font-size: 12px; text-align: center; }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) 88px 160px auto; gap: 8px; align-items: start; }
.rule .icon-button { margin-top: 8px; }
.records-picker { max-width: 360px; margin-bottom: 12px; }
.records-result { display: flex; flex-direction: column; gap: 12px; }

/* An attribute's profile. */
.profile { display: flex; flex-direction: column; gap: 24px; }
.profile-section h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.profile-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.profile-table td, .profile-table th { padding: 6px 8px; border-bottom: 1px solid var(--divider); text-align: left; }
.profile-table td:first-child { width: 40%; }
.profile-table .numeric { text-align: right; }
.profile-table th { color: var(--text-secondary); font-weight: 500; }
.profile-values { max-height: 320px; overflow: auto; }
.profile-unavailable, .profile-note, .profile-data-type { color: var(--text-secondary); font-size: 13px; font-style: italic; }
.profile-data-type { align-self: center; font-style: normal; }

/* A module's settings panel: what it is about beside its buttons, then its values. */
.config-panel { display: flex; flex-direction: column; gap: 24px; max-width: 880px; }
.config-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.config-panel-head p { max-width: 720px; color: var(--text-secondary); font-size: 13px; }
.check-identity { display: flex; gap: 16px; }
.check-identity-label { margin: 0 0 2px; color: var(--text-secondary); font-size: 12px; }
.data-grid td.numeric { text-align: right; }
.form-joiner { color: var(--text-secondary); font-size: 13px; text-align: center; }

/* A reconciliation rule as a card; a pair's two checks either side of the arrow. */
.rule-cards { display: flex; flex-direction: column; gap: 16px; }
.rule-card { display: flex; flex-direction: column; gap: 8px; padding: 16px 20px; border: 1px solid var(--divider); border-radius: var(--radius-xl); background: var(--paper); }
.rule-card-head { display: flex; align-items: center; gap: 8px; }
.rule-card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.rule-card-gap { flex: 1; }
.rule-card-description, .rule-card-label, .rule-card-none { color: var(--text-secondary); font-size: 13px; }
.rule-card-direction { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.rule-card-direction .icon { width: 16px; height: 16px; color: var(--text-secondary); }
.profile-table .rule-card-arrow { width: 20px; padding-left: 0; padding-right: 0; color: var(--text-secondary); }
.rule-card-arrow .icon { width: 16px; height: 16px; vertical-align: middle; }
.rule-card-settings { display: flex; flex-wrap: wrap; gap: 4px 24px; color: var(--text-secondary); font-size: 12px; }
.rule-card-settings strong { color: var(--text); font-weight: 500; }
.chip-row-wrap { flex-wrap: wrap; }
.form-hint { color: var(--text-secondary); font-size: 13px; }
.pair { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--divider); }
.pair-checks { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.pair-arrow { display: flex; justify-content: center; padding-top: 10px; color: var(--text-secondary); }
.pair-arrow .icon { width: 16px; height: 16px; }
.pair-checks .icon-button { margin-top: 6px; }

/* A cell's value with a note beside it, the note on hover. */
.cell-with-note { display: inline-flex; align-items: center; gap: 4px; }
.cell-with-note .hover-note { display: inline-flex; color: var(--text-secondary); }
.cell-with-note .icon { width: 14px; height: 14px; }
.change-list { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.change-list li + li { margin-top: 2px; }

/* --- Dashboard ------------------------------------------------------------------------- */

:root {
    --verdict-passed: var(--success-fill);
    --verdict-uncertain: var(--warning-fill);
    --verdict-failed: var(--error-fill);
    --verdict-untested: #DDE2E8;
    --verdict-passed-faded: color-mix(in srgb, var(--verdict-passed) 30%, transparent);
    --verdict-uncertain-faded: color-mix(in srgb, var(--verdict-uncertain) 30%, transparent);
    --verdict-failed-faded: color-mix(in srgb, var(--verdict-failed) 30%, transparent);
    --verdict-untested-faded: color-mix(in srgb, var(--verdict-untested) 40%, transparent);
}
:root[data-theme="dark"] { --verdict-untested: #3E4753; }
.verdict-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.verdict-dot.verdict-passed { background: var(--success); }
.verdict-dot.verdict-uncertain { background: var(--warning); }
.verdict-dot.verdict-failed { background: var(--error); }
.verdict-dot.verdict-untested { background: var(--grey-400); }

.dashboard-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; padding: 16px; }
.content-page-body:has(> .dashboard-details) { display: flex; overflow: hidden; }
.dashboard-details { flex: 1; display: flex; min-height: 0; }
.dashboard-details > .dashboard-body { flex: 1; overflow: auto; }
/* A dashboard grid is as long as its rows and scrolls with the page, so its headings stick to
   the page's top. `clip` rounds the corners as `hidden` does without making the grid a scroll
   container of its own, which the headings would stick to instead - and never move in. */
.dashboard-body .data-grid:not(.data-grid-scroll) { overflow: clip; }
.dashboard-body .data-grid:not(.data-grid-scroll) thead th { position: sticky; top: var(--grid-sticky-top, 0px); z-index: 2; box-shadow: inset 0 -1px var(--divider); }
/* Where the body itself scrolls, sticking is measured from inside its padding: up by that much,
   or the rows would show through the strip above the headings. */
.dashboard-details > .dashboard-body { --grid-sticky-top: -16px; }
.dashboard-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-title { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.4; }
.back-link { align-self: flex-start; color: var(--text-secondary); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--text); }

/* The date: stepping a day and picking one in one outline. */
.date-control {
    display: flex; align-items: stretch; height: 36px; overflow: hidden;
    border: 1px solid var(--divider); border-radius: var(--radius-lg); background: var(--grey-50);
    transition: border-color 120ms;
}
.date-control:hover { border-color: var(--grey-400); }
.date-control-step { display: flex; align-items: center; padding: 0 8px; color: var(--text-secondary); }
.date-control-step:hover { background: var(--hover); color: var(--text); }
.date-control-step .icon { width: 18px; height: 18px; }
.date-control-day {
    display: flex; align-items: center; gap: 8px; padding: 0 14px 0 10px;
    border-left: 1px solid var(--divider); border-right: 1px solid var(--divider); cursor: pointer;
}
.date-control-day:hover { background: var(--hover); }
.date-control-day .icon { width: 18px; height: 18px; color: var(--text-secondary); }
.date-control-day input {
    width: 104px; padding: 0; border: 0; background: transparent; color: var(--text);
    font: 600 13px var(--font); font-variant-numeric: tabular-nums; cursor: pointer;
}
.date-control-day input::-webkit-calendar-picker-indicator { display: none; }
.date-control-weekday { color: var(--text-secondary); font-size: 13px; }

/* The two marks on a date, pressed or not. */
.toggle-group { display: inline-flex; height: 36px; border: 1px solid var(--divider); border-radius: var(--radius-lg); overflow: hidden; }
.toggle-button {
    display: inline-flex; align-items: center; justify-content: center; width: 38px; padding: 0;
    border: 0; background: var(--paper); color: var(--text-secondary); cursor: pointer;
}
.toggle-button + .toggle-button { border-left: 1px solid var(--divider); }
.toggle-button:hover { background: var(--hover); color: var(--text); }
.toggle-button.pressed { background: var(--selected); color: var(--primary); }
.toggle-button.disabled { opacity: 0.5; cursor: default; }
.toggle-button.disabled:hover { background: var(--paper); color: var(--text-secondary); }
.toggle-button .icon { width: 18px; height: 18px; }
/* A toggle with its word, around the checkbox that holds it: the invalid records' statuses. */
.toggle-button-text { position: relative; width: auto; gap: 6px; padding: 0 12px; font-size: 13px; }
.toggle-button-text input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.toggle-button-text:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: -2px; }
.toggle-button-text .icon { width: 16px; height: 16px; }
.records-status-filter { margin-bottom: 16px; }

/* The summary: the overall verdicts beside a tile per module, each verdict a filter. */
.summary-box { container: summary / inline-size; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: stretch; }
/* The tiles go by the room the summary has, not the window's: the chat panel and the side
   bar take from it. React's steps - two, three from 480px of tiles, all of them from 150px
   each - counted here from the box, which holds the verdicts' card (about 300px) as well. */
.summary-tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.summary-tiles > * { min-width: 0; }
@container summary (min-width: 792px) { .summary-tiles { grid-template-columns: repeat(min(var(--tiles), 3), minmax(0, 1fr)); } }
@container summary (min-width: 912px) { .summary-tiles[style*="--tiles: 4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@container summary (min-width: 1062px) { .summary-tiles[style*="--tiles: 5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@container summary (max-width: 640px) { .summary-box > * { grid-column: 1 / -1; } }
.summary-card {
    position: relative; min-width: 0; padding: 10px 12px;
    border: 1px solid var(--divider); border-radius: var(--radius-xl); background: var(--paper);
    transition: border-color 120ms, box-shadow 120ms;
}
.summary-card-tab:hover { border-color: var(--grey-400); }
.summary-card.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.summary-card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.summary-card-label { min-width: 0; overflow: hidden; color: var(--text); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.summary-card.active .summary-card-label { color: var(--primary); }
/* The tab's link covers its card; what filters inside sits above it. */
.summary-card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.summary-card-link:focus-visible { outline: none; }
.summary-card:has(.summary-card-link:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.summary-total { margin-left: auto; flex: none; color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.summary-total strong { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.summary-inspection { display: flex; align-items: center; gap: 16px; height: 100%; }
.summary-inspection-body { flex: 1; min-width: 0; }
/* Over the card's own link, but only where the ring is drawn: its hole still opens the tab. */
.summary-donut { position: relative; z-index: 1; flex: none; width: 64px; height: 64px; pointer-events: none; }
.summary-donut circle { fill: none; stroke-width: 9; pointer-events: stroke; transition: opacity 150ms; }
.summary-donut .summary-donut-track { stroke: var(--grey-100); pointer-events: none; }
.summary-donut a { cursor: pointer; }
.summary-donut .verdict-passed { stroke: var(--verdict-passed); }
.summary-donut .verdict-uncertain { stroke: var(--verdict-uncertain); }
.summary-donut .verdict-failed { stroke: var(--verdict-failed); }
.summary-donut .verdict-untested { stroke: var(--verdict-untested); }
.summary-donut .dimmed { opacity: 0.3; }
.summary-donut a:hover .dimmed { opacity: 1; }
.summary-legend-grid { display: grid; grid-template-columns: repeat(2, minmax(104px, 1fr)); column-gap: 4px; }
.summary-legend-item {
    position: relative; z-index: 1; display: flex; align-items: center; gap: 6px; padding: 2px 6px;
    border-radius: var(--radius-md); color: var(--text-secondary); font-size: 12px; text-decoration: none;
}
.summary-legend-item:hover { background: var(--hover); }
.summary-legend-item.selected { background: var(--selected); }
.summary-legend-item.dimmed { opacity: 0.5; }
.summary-legend-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-legend-value { color: var(--text); font-variant-numeric: tabular-nums; }
.summary-bar { display: flex; gap: 2px; height: 6px; border-radius: 4px; background: var(--grey-100); }
.summary-bar-segment {
    position: relative; z-index: 1; flex-basis: 0; min-width: 4px; border-radius: 4px;
    transition: opacity 150ms;
}
.summary-bar-segment.verdict-passed { background: var(--verdict-passed); }
.summary-bar-segment.verdict-uncertain { background: var(--verdict-uncertain); }
.summary-bar-segment.verdict-failed { background: var(--verdict-failed); }
.summary-bar-segment.verdict-untested { background: var(--verdict-untested); }
.summary-bar-segment.dimmed { opacity: 0.4; }
.summary-bar-segment:hover { opacity: 1; }
.summary-bar-segment.selected { outline: 2px solid var(--grey-400); outline-offset: 1px; }
.summary-bar-segment.verdict-passed.selected { outline-color: var(--success); }
.summary-bar-segment.verdict-uncertain.selected { outline-color: var(--warning); }
.summary-bar-segment.verdict-failed.selected { outline-color: var(--error); }
.summary-card-foot { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 12px; margin-top: 6px; }
.summary-legend { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; column-gap: 12px; row-gap: 2px; }
.summary-legend-entry { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); font-size: 12px; }
.summary-legend-entry .verdict-dot { width: 6px; height: 6px; }
.summary-legend-entry strong { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.summary-legend-empty { color: var(--text-disabled); font-size: 12px; }

/* A grid cell that leads into a panel. */
/* The dashboard's two status grids: a column is as wide as the wider of its heading (with
   its sort arrow and filter) and its widest chip, and the name takes what is left - React
   measured the texts to the same end. Shared weights cut "Inspection status" short and
   clipped the inspected chip's timestamp. */
#dashboard-overview table, #dashboard-datasets table { table-layout: auto; }
#dashboard-overview col, #dashboard-datasets col { width: auto !important; }
#dashboard-overview :is(th, td):first-child, #dashboard-datasets :is(th, td):first-child { width: 100%; min-width: 200px; max-width: 0; }
#dashboard-overview .column-filter-heading > span, #dashboard-datasets .column-filter-heading > span { overflow: visible; }
/* Eight headings side by side have no room to keep a place for an arrow that is not shown:
   here it takes its place only on the column the grid is sorted by. A window too narrow for
   all of them scrolls the grid sideways, as MUI's did. */
#dashboard-overview, #dashboard-datasets { overflow-x: auto; }
:is(#dashboard-overview, #dashboard-datasets) .sort-header:not(.sorted) .icon { display: none; }
.cell-link { color: inherit; text-decoration: none; }
.cell-link:hover .status-chip { filter: brightness(0.95); text-decoration: underline; }
.cell-link.cell-name:hover { text-decoration: underline; }
.cell-link.not-tested { padding: 0 8px; color: var(--text-secondary); font-size: 12px; }
.cell-hint { display: inline-flex; cursor: help; }
.filter-chip { align-self: center; gap: 4px; padding-right: 4px; }

/* The rail beside a data source's details. */
.action-rail {
    flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
    width: 48px; padding: 16px 0; border-left: 1px solid var(--divider); background: var(--paper);
}
.rail-button { position: relative; width: 32px; height: 32px; }
.rail-button .icon { width: 18px; height: 18px; }
.rail-rule { width: 24px; margin: 4px 0; border: 0; border-top: 1px solid var(--divider); }
.rail-badge {
    position: absolute; top: -2px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--primary); color: var(--contrast-text); font-size: 10px; line-height: 16px; text-align: center;
}
.data-grid tr.clickable-row { cursor: pointer; }
.data-grid td .chip-plain { max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.rail-badge-slot { display: contents; }
.records-picker-wide { width: 420px; }
/* Comments: the day's conversation. */
.comments { display: flex; flex-direction: column; gap: 12px; min-height: 360px; }
.comment-list { flex: 1; display: flex; flex-direction: column; max-height: 55vh; overflow-y: auto; }
.comment { padding: 10px 0; border-bottom: 1px solid var(--divider); }
.comment:last-child { border-bottom: 0; }
.comment-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.comment-meta { color: var(--text-secondary); font-size: 13px; }
.comment-actions { display: flex; align-items: center; gap: 4px; opacity: 0.4; transition: opacity 150ms; }
.comment-actions .icon-button { padding: 4px; }
.comment:hover .comment-actions, .comment-actions:focus-within { opacity: 1; }
.comment-actions .icon-button .icon { width: 16px; height: 16px; }
.comment-message { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }
.comment-empty { margin: auto; color: var(--text-secondary); }
.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-field {
    width: 100%; padding: 8px 10px; resize: vertical;
    border: 1px solid var(--grey-300); border-radius: var(--radius-md); font: 14px/1.5 var(--font);
}
.comment-field:focus { outline: 2px solid var(--secondary); outline-offset: -1px; border-color: transparent; }
.comment-form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.comment-confirm { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; }
.comment-confirm span { flex: 1; color: var(--text-secondary); }
/* The dashboard's chart dialogs. */
:root { --fit-1: #2563EB; --fit-2: #9333EA; --fit-3: #0D9488; --fit-4: #DB2777; }
:root[data-theme="dark"] { --fit-1: #93B4FB; --fit-2: #C084FC; --fit-3: #2DD4BF; --fit-4: #F472B6; }
.chart-dialog { display: flex; flex-direction: column; gap: 16px; min-height: 420px; }
.chart-form { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.chart-controls { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin: 0; }
.chart-controls .field { width: 160px; }
.chart-controls .date-range-field { width: 230px; }
.chart-controls-picker { flex: 1 1 360px; min-width: 260px; }
.chart-controls-picker .field { width: 100%; }
.chart-controls-status .field { width: 170px; }
.chart-empty { margin: 48px auto; color: var(--text-secondary); }
.chart-panel { display: flex; align-items: center; gap: 16px; }
.chart-panel .chart { flex: 1; min-width: 0; aspect-ratio: auto; height: 380px; }
/* The period's slider: two range inputs laid over one track, only their thumbs taking the
   pointer, so either can be caught wherever the other is. */
.period-slider { padding: 0 48px; }
.period-slider-track { position: relative; height: 24px; }
.period-slider-track::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 4px; border-radius: 2px; background: var(--grey-300); }
.period-slider-fill { position: absolute; top: 10px; height: 4px; background: var(--primary); }
.period-slider input {
    position: absolute; inset: 0; width: 100%; height: 24px; margin: 0; padding: 0;
    background: none; pointer-events: none; -webkit-appearance: none; appearance: none; outline: none;
}
.period-slider input::-webkit-slider-runnable-track { height: 24px; background: transparent; }
.period-slider input::-moz-range-track { height: 24px; background: transparent; }
.period-slider input::-webkit-slider-thumb {
    -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; margin-top: 4px;
    border: 0; border-radius: 50%; background: var(--primary); cursor: pointer;
}
.period-slider input::-moz-range-thumb {
    pointer-events: auto; width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--primary); cursor: pointer;
}
.period-slider input:hover::-webkit-slider-thumb, .period-slider input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px var(--selected); }
.period-slider input:hover::-moz-range-thumb, .period-slider input:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 6px var(--selected); }
.period-slider-value {
    position: absolute; bottom: 26px; transform: translateX(-50%); padding: 2px 8px; border-radius: var(--radius-sm);
    background: var(--text); color: var(--paper); font-size: 12px; white-space: nowrap; pointer-events: none;
}
.period-slider-ends { display: flex; justify-content: space-between; color: var(--text-secondary); font-size: 12px; font-variant-numeric: tabular-nums; }

/* At least as wide as the gauge's usual figures, so a simulated value a digit longer or
   shorter does not change the chart's width beside it. */
.chart-gauge {
    flex: none; min-width: 194px; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px;
    border: 1px solid var(--divider); border-radius: var(--radius-xl);
}
.chart-gauge .summary-date { text-align: center; }
.chart-gauge-status { font-size: 12px; font-weight: 600; }
.verdict-text-0 { color: var(--success); }
.verdict-text-1 { color: var(--warning); }
.verdict-text-2 { color: var(--error); }
.verdict-text--1 { color: var(--text-secondary); }
.chart-stats { flex: none; min-width: 220px; padding: 16px; border: 1px solid var(--divider); border-radius: var(--radius-xl); }
.chart-stats dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.chart-stats dl + dl { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--divider); }
.chart-stats dt { color: var(--text-secondary); }
.chart-stats dd { margin: 0; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.fit-rows { display: flex; flex-direction: column; gap: 8px; }
.fit-row { display: flex; align-items: center; gap: 8px; }
.fit-swatch { flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--swatch); }
.fit-kind .field { width: 190px; }
.fit-parameter .field { width: 150px; }
.fit-rows-foot { display: flex; align-items: center; gap: 16px; }
/* The reconciliation check's day. */
.segmented { display: inline-flex; align-self: center; height: 36px; border: 1px solid var(--divider); border-radius: var(--radius-lg); overflow: hidden; }
.segmented-button { padding: 0 14px; border: 0; background: var(--paper); color: var(--text-secondary); font: 500 13px var(--font); cursor: pointer; }
.segmented-button + .segmented-button { border-left: 1px solid var(--divider); }
.segmented-button:hover { background: var(--hover); color: var(--text); }
.segmented-button.pressed { background: var(--selected); color: var(--primary); }
.reconciliation-day { display: flex; flex-direction: column; gap: 12px; padding: 12px 0; border-top: 1px solid var(--divider); }
.reconciliation-check-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.reconciliation-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.reconciliation-sides h3, .reconciliation-ai h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.reconciliation-sides p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reconciliation-figures { padding-top: 12px; border-top: 1px solid var(--divider); }
.reconciliation-figures > div, .figure { display: flex; flex-direction: column; }
.figure-label { color: var(--text-secondary); font-size: 12px; }
.figure-value { font-variant-numeric: tabular-nums; }
.figure-missing { color: var(--text-secondary); cursor: help; }
.reconciliation-ai { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 32px; }
.reconciliation-ai p.muted { margin: 0 0 8px; font-size: 12px; }
.input-list { margin: 0; padding: 0; list-style: none; max-height: 50vh; overflow-y: auto; }
.input-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--divider); }
.input-name { display: flex; flex-direction: column; min-width: 0; }
.input-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.input-name .muted { font-size: 12px; }
.input-value { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.importance-meter { display: inline-flex; gap: 2px; cursor: help; }
.importance-bar { width: 6px; height: 10px; border-radius: 1px; background: var(--grey-100); }
.importance-bar.filled { background: var(--text-secondary); }
.range-bar { position: relative; height: 62px; margin: 0 24px; }
.range-bar-track, .range-bar-outer, .range-bar-inner { position: absolute; top: 26px; height: 8px; }
.range-bar-track { left: 0; right: 0; border-radius: 4px; background: var(--grey-100); }
.range-bar-outer { border-radius: 4px; background: var(--verdict-uncertain); opacity: 0.8; }
.range-bar-inner { background: var(--verdict-passed); }
.range-bar-dot { position: absolute; top: 24px; width: 12px; height: 12px; border: 2px solid var(--paper); border-radius: 50%; background: currentColor; transform: translateX(-50%); }
.range-bar-observed-value, .range-bar-threshold { position: absolute; transform: translateX(-50%); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.range-bar-observed-value { top: 0; font-weight: 600; }
.range-bar-threshold { top: 42px; color: var(--text-secondary); }
.range-bar-arrow { position: absolute; top: 20px; left: -22px; display: flex; }
.range-bar-arrow-right { left: auto; right: -22px; }
.range-bar-arrow .icon { width: 18px; height: 18px; }
/* A reconciliation check's timeline: its sources' chips, the chart with the panels under it
   on one time axis, and the marked day's gauge beside. */
.reconciliation-timeline { display: flex; flex-direction: column; gap: 12px; }
.source-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.source-chip { max-width: 100%; }
.source-chip.on { background: var(--selected); border-color: var(--primary); }
.source-chip-check { display: inline-flex; }
.source-chip-check .icon { width: 12px; height: 12px; }
.source-chip-label { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.source-chip-fold { border-style: dashed; }
.source-chips-note { margin: 0; font-size: 12px; }
.timeline-charts { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.timeline-charts .chart { flex: none; height: 320px; }
.timeline-panel { display: flex; flex-direction: column; min-width: 0; }
.timeline-panel-label { padding: 0 40px 0 78px; color: var(--text-secondary); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-difference { height: 150px; }
.chart-strip { height: 90px; }
.chart-tooltip-rows { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--divider); }
.chart-tooltip-row { display: flex; justify-content: space-between; gap: 16px; }
.chart-tooltip-row span { color: var(--text-secondary); font-size: 13px; }
.chart-tooltip-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tooltip-status { margin-top: 6px; font-size: 12px; font-weight: 600; }
@media (max-width: 900px) { .reconciliation-ai { grid-template-columns: 1fr; } }
.data-grid-dialog-body { display: flex; flex-direction: column; gap: 8px; }
.data-grid-dialog-body .data-grid { max-height: 55vh; overflow: auto; }
.sort-toggle { order: -1; align-self: flex-end; }
.sort-toggle .sort-header .icon { opacity: 0.4; margin: 0; }
.sort-toggle .sort-header.sorted .icon { opacity: 1; }
button.date-control-day { border-top: 0; border-bottom: 0; background: transparent; font: inherit; color: var(--text); }
.date-control-date { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
/* The inspection calendar. */
.calendar { display: flex; gap: 24px; min-height: 420px; }
.calendar-month { flex: none; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.calendar-head { align-self: stretch; display: flex; align-items: center; justify-content: space-between; padding-left: 8px; }
.calendar-steps { display: flex; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 44px); gap: 4px; }
.calendar-weekday { color: var(--text-secondary); font-size: 12px; text-align: center; line-height: 28px; }
.calendar-day {
    width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
    background: transparent; color: var(--text); font: 14px var(--font); font-variant-numeric: tabular-nums; cursor: pointer;
}
.calendar-day:hover { background: var(--hover); }
.calendar-day[class*="verdict-"]:hover { filter: brightness(0.93); }
.calendar-day.outside { color: var(--text-disabled); }
.calendar-day.verdict-passed { background: var(--verdict-passed); }
.calendar-day.verdict-uncertain { background: var(--verdict-uncertain); }
.calendar-day.verdict-failed { background: var(--verdict-failed); }
.calendar-day.selected { box-shadow: inset 0 0 0 2px var(--primary); font-weight: 600; }
.calendar-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; color: var(--text-secondary); font-size: 12px; }
.calendar-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.calendar-swatch { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--grey-400); }
.calendar-swatch.verdict-passed, .calendar-swatch.verdict-uncertain, .calendar-swatch.verdict-failed { border: 0; }
.calendar-swatch.verdict-passed { background: var(--verdict-passed); }
.calendar-swatch.verdict-uncertain { background: var(--verdict-uncertain); }
.calendar-swatch.verdict-failed { background: var(--verdict-failed); }
.calendar-hint { margin: 0; font-size: 12px; }
.calendar-list { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; padding-left: 24px; border-left: 1px solid var(--divider); }
.calendar-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.calendar-filter { background: var(--grey-50); color: var(--text); border: 1px solid var(--divider); }
.calendar-filter input { color: var(--text); }
.calendar-rows { flex: 1; margin: 0; padding: 0; list-style: none; max-height: 360px; overflow-y: auto; }
.calendar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px; border-bottom: 1px solid var(--divider); border-radius: var(--radius-md); color: inherit; font-size: 13px; text-decoration: none; }
.calendar-row:hover, .calendar-row:focus-visible { background: var(--hover); }
.calendar-row span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-controls-picker .chart-controls-status, .chart-controls-picker .chart-controls-status .field { width: 100%; }
/* What the license says on every page. */
.shell-notice {
    position: fixed; bottom: 24px; z-index: 50; max-width: 420px; padding: 10px 16px;
    border-radius: var(--radius-md); box-shadow: 0 6px 20px rgb(0 0 0 / 18%); color: var(--contrast-text); font-weight: 600; font-size: 14px;
}
.shell-notice p { margin: 0; }
.shell-notice-error { right: 24px; background: var(--error); }
.shell-notice-info { left: 50%; transform: translateX(-50%); background: var(--warning); }

/* --- Ask digna: the chat docked at the window's right edge ------------------------------ */
/* Measured off the React panel: body2 (13px) text, captions at 12px, the card frame of
   `chat-card.tsx`, the filled field of the theme's MuiFilledInput, MUI's small buttons. */

:root { --chat-width: 420px; }
body.chat-open { padding-right: var(--chat-width); }
body.chat-resizing { cursor: col-resize; user-select: none; }
.chat-entry { display: contents; }
.chat-slot { display: none; }
.side-bar .chat-button:hover { background: var(--bar-hover); color: var(--bar-text); }
.chat-button { position: relative; }
.chat-button[aria-pressed="true"] { color: var(--text); background: var(--selected); }
.side-bar .chat-button[aria-pressed="true"] { color: var(--bar-text); background: var(--bar-hover); }
.chat-button-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: none; }
.chat-button.attention .chat-button-dot { display: block; }
/* Faint while the reply is still being written with the panel closed. */
.chat-button.working .chat-button-dot { display: block; opacity: 0.45; }
.chat-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: var(--chat-width);
    display: flex; border-left: 1px solid var(--divider); background: var(--paper);
    color: var(--text); font-size: 13px; line-height: 1.5; text-align: left;
}
.chat-resize { position: absolute; top: 0; bottom: 0; left: -3px; width: 6px; cursor: col-resize; z-index: 1; }
.chat-resize:hover { background: color-mix(in srgb, var(--secondary) 25%, transparent); }
.chat-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* The header: what is on show, and the three buttons. */
.chat-head { flex: none; display: flex; align-items: center; gap: 4px; min-height: 52px; padding: 8px 16px; border-bottom: 1px solid var(--divider); }
.chat-head-icon { display: inline-flex; margin-right: 4px; }
.chat-head-icon .icon { width: 20px; height: 20px; color: var(--primary); }
.chat-head-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head-title strong { overflow: hidden; font-size: 13px; font-weight: 600; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-title span { overflow: hidden; color: var(--text-secondary); font-size: 12px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-button .icon { width: 20px; height: 20px; }

/* The thread. */
.chat-scroll-frame { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.chat-thread, #chat-live { display: flex; flex-direction: column; gap: 12px; }
#chat-live:not(:empty) { margin-top: 12px; }
.chat-jump {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    border: 1px solid var(--divider); background: var(--paper);
    box-shadow: 0 2px 1px -1px rgb(0 0 0 / 20%), 0 1px 1px 0 rgb(0 0 0 / 14%), 0 1px 3px 0 rgb(0 0 0 / 12%);
}
.chat-panel .chat-scroll-frame .icon-button.chat-jump:hover { background: var(--paper); }
.chat-jump[hidden] { display: none; }
.chat-user {
    align-self: flex-end; max-width: 85%; padding: 8px 12px; border-radius: 12px;
    background: var(--grey-100); white-space: pre-wrap; overflow-wrap: anywhere;
}
.chat-assistant { overflow-wrap: anywhere; }
.chat-draft, .chat-draft-final { white-space: pre-wrap; }
.chat-markdown { overflow-wrap: anywhere; }
.chat-markdown > :first-child { margin-top: 0; }
.chat-markdown > :last-child { margin-bottom: 0; }
.chat-markdown p { margin: 8px 0; }
.chat-markdown ul, .chat-markdown ol { margin: 8px 0; padding-left: 20px; }
.chat-markdown li { margin: 2px 0; }
.chat-markdown h1, .chat-markdown h2, .chat-markdown h3, .chat-markdown h4 { margin: 12px 0 4px; font-size: 13px; font-weight: 600; line-height: 1.45; }
.chat-markdown a { color: var(--primary); }
.chat-markdown code { padding: 0 4px; border-radius: 4px; background: var(--grey-100); font: 0.85em ui-monospace, SFMono-Regular, Menlo, monospace; }
.chat-markdown pre { margin: 8px 0; padding: 8px; border-radius: var(--radius-md); background: var(--grey-100); overflow-x: auto; }
.chat-markdown pre code { padding: 0; background: transparent; }
/* A code block as written and the button that copies it, shown on the pointer over the block or the keyboard in it. */
.chat-code { position: relative; margin: 8px 0; }
.chat-markdown .chat-code pre { margin: 0; }
.chat-panel .chat-code .icon-button.chat-copy { position: absolute; top: 4px; right: 4px; padding: 4px; background: var(--paper); opacity: 0; transition: opacity 120ms; }
.chat-panel .chat-code .icon-button.chat-copy:hover { background: var(--paper); }
.chat-panel .chat-code .icon-button.chat-copy .icon { width: 14px; height: 14px; }
.chat-code:hover .chat-copy, .chat-code:focus-within .chat-copy { opacity: 1; }
@media (hover: none) { .chat-code .chat-copy { opacity: 1; } }
.chat-markdown table { display: block; margin: 8px 0; overflow-x: auto; border-collapse: collapse; }
.chat-markdown th, .chat-markdown td { padding: 4px 8px; border: 1px solid var(--divider); text-align: left; vertical-align: top; }
.chat-markdown th { font-weight: 600; }
.chat-markdown blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--divider); color: var(--text-secondary); }

/* A run of tools, the working line, a stopped turn: one quiet line each. */
.chat-tools { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.chat-tools[hidden] { display: none; }
.chat-tools > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-tools .icon { flex: none; width: 12px; height: 12px; }
.chat-tools-mark { display: inline-flex; flex: none; }
.chat-tools.failed .icon { color: var(--error); }
.chat-tools .spinner { flex: none; width: 10px; height: 10px; border-width: 1.5px; }
.chat-working .spinner { width: 12px; height: 12px; }
.chat-stop-mark { flex: none; width: 9px; height: 9px; border-radius: 2px; background: currentColor; }

/* The frame of everything the user answers with a click - a question, a change waiting -
   and of a change once answered: a rule down its leading edge, in colour while it waits. */
.chat-card {
    display: flex; flex-direction: column; overflow: hidden; margin: 0;
    border: 1px solid var(--divider); border-left-width: 3px; border-radius: 12px; background: var(--paper);
}
.chat-card.active {
    border-color: var(--primary);
    box-shadow: 0 2px 1px -1px rgb(0 0 0 / 20%), 0 1px 1px 0 rgb(0 0 0 / 14%), 0 1px 3px 0 rgb(0 0 0 / 12%);
}
.chat-card.active.destructive { border-color: var(--error); }
.chat-card-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; }
.chat-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-card-head > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat-card-head strong { font-size: 13px; font-weight: 600; line-height: 1.45; }
.chat-card-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-card-caption { color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.chat-card-hint { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.chat-card p { margin: 0; }
.chat-card .chat-markdown p { margin: 8px 0; }
.chat-card .chat-markdown > :first-child { margin-top: 0; }
.chat-card .chat-markdown > :last-child { margin-bottom: 0; }
.chat-card-foot { padding: 8px 14px; border-top: 1px solid var(--divider); background: var(--grey-50); }
.chat-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.chat-panel .chat-card .button, .chat-panel .chat-starter, .chat-panel .chat-error .button {
    min-height: 30px; padding: 4px 14px; font-size: 13px; font-weight: 500; line-height: 1.4;
}
.chat-panel .button-outlined-primary, .chat-panel .button-outlined-error { padding-top: 3px; padding-bottom: 3px; }
.button-outlined-primary { border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent); background: transparent; color: var(--primary); }
.button-outlined-primary:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 4%, transparent); }
.button-text-primary { background: transparent; color: var(--primary); }
.button-text-primary:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.button-primary:disabled:hover { background: var(--primary); }
.chat-correction { display: flex; flex-direction: column; gap: 8px; }

/* The theme's filled field: a grey well at rest, white with a navy ring once it has focus. */
.chat-correction textarea, .chat-composer textarea, .chat-option-filter {
    display: block; width: 100%; margin: 0; padding: 8px 12px 9px; resize: none;
    border: 1px solid var(--divider); border-radius: var(--radius-lg); background: var(--grey-50);
    color: var(--text); font: 13px/1.4375 var(--font);
    transition: border-color 120ms ease, background-color 120ms ease;
}
.chat-correction textarea { background: var(--paper); }
.chat-correction textarea:hover, .chat-composer textarea:hover, .chat-option-filter:hover { border-color: var(--grey-400); }
.chat-correction textarea:focus, .chat-composer textarea:focus, .chat-option-filter:focus {
    outline: none; border-color: var(--primary); background: var(--paper); box-shadow: 0 0 0 1px var(--primary);
}
.chat-correction textarea::placeholder, .chat-composer textarea::placeholder, .chat-option-filter::placeholder { color: var(--text-secondary); opacity: 0.7; }

/* A question's answer. */
.chat-ask fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.chat-ask legend { padding: 0; color: var(--text-secondary); font-size: 12px; font-weight: 600; line-height: 1.4; }
.chat-choices { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.chat-panel .chat-choices .button { text-align: left; overflow-wrap: anywhere; }
.chat-options { display: flex; flex-wrap: wrap; column-gap: 12px; }
.chat-options-long { flex-direction: column; flex-wrap: nowrap; max-height: 180px; overflow-y: auto; margin-top: 6px; }
.chat-option-search { padding-top: 4px; }
.chat-option-choice { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; cursor: pointer; }
.chat-option-choice input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }

/* A new conversation: what the chat is for, and questions to start with. */
.chat-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 16px 0; color: var(--text-secondary); text-align: center; }
.chat-empty-icon { display: inline-flex; }
.chat-empty-icon .icon { width: 28px; height: 28px; }
.chat-empty strong { color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.45; }
.chat-empty p { margin: 0; }
.chat-starters { display: flex; flex-direction: column; gap: 6px; align-self: stretch; padding-top: 12px; }
.chat-panel .chat-starter {
    display: block; padding-top: 3px; padding-bottom: 3px; border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent); border-radius: var(--radius-md);
    background: transparent; color: var(--primary); font-family: var(--font); text-align: left; cursor: pointer;
    transition: background-color 250ms, border-color 250ms;
}
.chat-panel .chat-starter:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 4%, transparent); }

/* The composer: what the message is sent with, the field and the button beside it. */
.chat-composer { flex: none; padding: 12px 16px; border-top: 1px solid var(--divider); }
.chat-context { display: flex; align-items: center; gap: 6px; min-width: 0; padding-bottom: 8px; color: var(--text-secondary); font-size: 12px; line-height: 1.4; cursor: default; }
.chat-context .icon { flex: none; width: 14px; height: 14px; }
.chat-context span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-composer textarea { flex: 1; min-width: 0; max-height: 176px; overflow-y: auto; }
.chat-panel .chat-composer .icon-button.chat-send, .chat-panel .chat-composer .icon-button.chat-stop { padding: 8px; color: var(--primary); }
.chat-panel .chat-composer .icon-button.chat-send:hover, .chat-panel .chat-composer .icon-button.chat-stop:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); color: var(--primary); }
.chat-panel .chat-composer .icon-button.chat-send:disabled, .chat-panel .chat-composer .icon-button.chat-stop:disabled { background: transparent; color: var(--text-disabled); opacity: 0.6; cursor: default; }
.chat-stop .icon rect { fill: currentColor; }
.chat-composer [hidden] { display: none; }

/* A turn that failed: the theme's standard error alert. */
.chat-panel .chat-error {
    align-items: center; gap: 12px; margin-top: 12px; padding: 6px 8px 6px 16px;
    background: var(--error-ground); color: var(--error-ground-text); font-size: 13px; font-weight: 400;
}
.chat-error > .icon { width: 22px; height: 22px; }
.chat-error-text { flex: 1; padding: 8px 0; }
.chat-panel .chat-error .button { color: inherit; background: transparent; }
.chat-panel .chat-error .button:hover { background: color-mix(in srgb, currentColor 6%, transparent); }
.chat-panel .chat-error .icon-button.chat-error-close { color: inherit; }
.chat-panel .chat-error .icon-button.chat-error-close:hover { background: color-mix(in srgb, currentColor 6%, transparent); }
.chat-panel .chat-error .icon-button .icon { width: 20px; height: 20px; color: inherit; }

.chat-note { margin: 0; color: var(--text-secondary); font-size: 13px; font-style: italic; }
.chat-block { margin: 8px 0; }
/* A chart in an answer is the chart alone, two fifths as tall as it is wide, as in the React panel. */
.chart-panel.chat-chart { padding: 0; border: 0; border-radius: 0; }
.chat-chart .chart { height: auto; aspect-ratio: 5 / 2; }
.chat-records { padding: 8px; border: 1px solid var(--divider); border-radius: var(--radius-md); }
.chat-records-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.chat-records-body:not(:empty) { margin-top: 8px; }
.chat-records-body .records-grid { max-height: 300px; }

/* The history: a list of rows, the one on show marked down its leading edge. */
.chat-history-scroll { padding: 8px; }
.chat-history { margin: 0; padding: 0; list-style: none; }
.chat-history li { display: flex; align-items: center; }
.chat-history-open {
    flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 4px 16px; border: 0; border-radius: var(--radius-md);
    background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background-color 150ms;
}
.chat-history-open:hover { background: var(--hover); }
.chat-history-open.selected { background: var(--selected); box-shadow: inset 2px 0 0 var(--primary); }
.chat-history-title { margin-top: 4px; overflow: hidden; font-size: 13px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.chat-history-when { margin-bottom: 4px; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.chat-history li .icon-button .icon { width: 20px; height: 20px; }
.chat-history-confirm { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; font-size: 13px; }
.chat-history-confirm span { flex: 1 1 100%; }
.chat-history-empty { margin: 0; padding: 48px 16px 0; color: var(--text-secondary); text-align: center; }
/* The anomaly chart's simulation. */
.chart-toggle { align-self: center; }
.chart-toggle.pressed { background: var(--selected); color: var(--primary); }
.simulation { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid var(--divider); }
.simulation .alert-info { margin: 0; padding: 8px 12px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--secondary) 8%, transparent); color: var(--info-text); font-size: 13px; }
.simulation-hint { margin: 0; font-size: 13px; }
.simulation-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.simulation fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.simulation legend { margin-bottom: 8px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.simulation .form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.simulation-actions { display: flex; justify-content: flex-end; gap: 8px; }
.simulation-confirm { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--primary); border-radius: var(--radius-lg); }
.simulation-confirm p { margin: 0; font-size: 13px; }
@media (max-width: 1100px) { .simulation-groups { grid-template-columns: 1fr; } }
/* The panel sits in the side bar's subtree on the app's pages: its own buttons keep the page's colours. */
.chat-panel .icon-button, .side-bar .chat-panel .icon-button { color: var(--text-secondary); }
.chat-panel .icon-button:hover, .side-bar .chat-panel .icon-button:hover { background: var(--hover); color: var(--text); }
.chat-panel .chat-head-button.pressed, .side-bar .chat-panel .chat-head-button.pressed { color: var(--primary); }
/* While a turn streams, the panel cannot leave its conversation. */
.chat-panel .chat-head-button:disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.side-bar .chat-panel .chat-head-button.pressed:hover, .chat-panel .chat-head-button.pressed:hover { color: var(--primary); }
/* The license's notices stay clear of the open panel. */
body.chat-open .shell-notice-error { right: calc(var(--chat-width) + 24px); }
body.chat-open .shell-notice-info { left: calc((100% - var(--chat-width)) / 2); }
