/* TrailerWatch UI styles. Chart colors are categorical slots in fixed order (see TimeSeriesChart.razor). */

/*
 * Theme tokens. The MudBlazor palette (--mud-palette-*) comes from /theme.css for both modes; these tokens map onto it
 * where it has a role and add the rest (chart chrome, chart series, account-page notices). Light values are the default;
 * dark values apply for html[data-theme="dark"] (explicit choice, rendered from the tw-theme cookie) and, when there is no
 * data-theme ("System"), under prefers-color-scheme: dark. Never hard-code a colour below this block.
 * Chart series: categorical slots in fixed order, the dark column stepped for the dark surface (both validated sets).
 */
:root {
    --tw-text: var(--mud-palette-text-primary);
    --tw-text-muted: var(--mud-palette-text-secondary);
    --tw-surface: var(--mud-palette-surface);
    --tw-background: var(--mud-palette-background);
    --tw-critical: var(--mud-palette-error);
    --tw-accent: var(--mud-palette-primary);
    --tw-accent-text: var(--mud-palette-primary-text);
    --tw-accent-hover: var(--mud-palette-primary-darken);
    --tw-accent-wash: rgba(var(--mud-palette-primary-rgb), 0.08);

    --tw-grid: #e6e5e0;
    --tw-axis: #6b6a65;
    --tw-border: #e6e5e0;
    --tw-input-border: #8f8e88;
    --tw-code-bg: #f3f2ee;
    --tw-shadow: rgba(0, 0, 0, 0.12);
    --tw-error-bg: #fdecea;
    --tw-error-text: #8c1d18;
    --tw-success-bg: #e8f5e9;
    --tw-success-text: #1b5e20;
    --tw-warning-bg: #fff4e5;
    --tw-warning-text: #663c00;

    --tw-series-1: #2a78d6;
    --tw-series-2: #eb6834;
    --tw-series-3: #1baf7a;
    --tw-series-4: #eda100;
    --tw-series-5: #e87ba4;
    --tw-series-6: #008300;
    --tw-series-7: #6250d6;
    --tw-series-8: #e34948;
}

html[data-theme="dark"] {
    --tw-grid: #353533;
    --tw-axis: #a3a29b;
    --tw-border: #383836;
    --tw-input-border: #7a7973;
    --tw-code-bg: #2a2a28;
    --tw-shadow: rgba(0, 0, 0, 0.5);
    --tw-error-bg: #3b1d1a;
    --tw-error-text: #ffb4ab;
    --tw-success-bg: #15301d;
    --tw-success-text: #a6e3b5;
    --tw-warning-bg: #382a12;
    --tw-warning-text: #ffd59a;

    --tw-series-1: #3987e5;
    --tw-series-2: #d95926;
    --tw-series-3: #199e70;
    --tw-series-4: #c98500;
    --tw-series-5: #d55181;
    --tw-series-6: #008300;
    --tw-series-7: #9085e9;
    --tw-series-8: #e66767;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        --tw-grid: #353533;
        --tw-axis: #a3a29b;
        --tw-border: #383836;
        --tw-input-border: #7a7973;
        --tw-code-bg: #2a2a28;
        --tw-shadow: rgba(0, 0, 0, 0.5);
        --tw-error-bg: #3b1d1a;
        --tw-error-text: #ffb4ab;
        --tw-success-bg: #15301d;
        --tw-success-text: #a6e3b5;
        --tw-warning-bg: #382a12;
        --tw-warning-text: #ffd59a;

        --tw-series-1: #3987e5;
        --tw-series-2: #d95926;
        --tw-series-3: #199e70;
        --tw-series-4: #c98500;
        --tw-series-5: #d55181;
        --tw-series-6: #008300;
        --tw-series-7: #9085e9;
        --tw-series-8: #e66767;
    }
}

html, body {
    margin: 0;
    background: var(--tw-background);
    color: var(--tw-text);
}

/* FocusOnNavigate focuses the page <h1> (tabindex=-1) for screen readers; no visible ring for programmatic focus. */
h1[tabindex="-1"]:focus { outline: none; }

.tw-muted { color: var(--tw-text-muted); }
.tw-small { font-size: 0.8rem; }
.tw-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tw-mono input, .tw-mono textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
/* Percentage columns (fleet CPU/Memory/Disk usage, the trailer's machine): left-aligned like every other column, header
   and value alike, with tabular figures so the digits line up; th/td.tw-num shrink to their content (width: 1%), so the
   spare width goes to the text columns instead of opening a gap before the numbers. Phone cards (MudBlazor's small-table
   layout below 961 px) keep their full-width label/value rows. */
.tw-num { text-align: start; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 961px) { th.tw-num, td.tw-num { width: 1%; } }
.tw-filter { min-width: 180px; max-width: 260px; }
.tw-lastseen { display: inline-flex; flex-direction: column; line-height: 1.25; }
.tw-facts { display: flex; flex-wrap: wrap; gap: 4px 24px; font-size: 0.9rem; }
.tw-facts .tw-muted { margin-right: 4px; }

/* Uninstall dialog: list of effects */
.tw-effects { padding-left: 1.25rem; margin: 0; font-size: 0.875rem; }
.tw-effects li { margin-bottom: 4px; }

/* Sparkline */
.tw-spark { display: block; overflow: visible; }
.tw-spark-line { fill: none; stroke: var(--tw-accent); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.tw-spark-dot { fill: var(--tw-accent); }
.tw-spark-end { fill: var(--tw-accent); stroke: var(--tw-surface); stroke-width: 1; }
.tw-spark-end.tw-critical { fill: var(--tw-critical); }
.tw-spark-limit { stroke: var(--tw-axis); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.5; }

/* Time-series chart (TimeSeriesChart.razor): fixed 160 px plot, text never scales with the width. */
.tw-chart { width: 100%; min-width: 0; }
.tw-chart-area { margin: 8px 8px 0 36px; container: tw-plot / inline-size; }
.tw-chart-plot { position: relative; height: 160px; }
.tw-chart-svg { display: block; width: 100%; height: 160px; overflow: visible; }
.tw-chart-svg * { vector-effect: non-scaling-stroke; }
/* Same height as a chart: 8 margin + 160 plot + 18 x axis + 24 legend line. */
.tw-chart-empty { display: flex; align-items: center; justify-content: center; min-height: 210px; }
.tw-grid { stroke: var(--tw-grid); stroke-width: 1; }
.tw-tick { stroke: var(--tw-axis); stroke-width: 1; }
.tw-axis {
    position: absolute; color: var(--tw-axis); font-size: 11px; line-height: 14px; white-space: nowrap;
    font-variant-numeric: tabular-nums; pointer-events: none;
}
.tw-axis-y .tw-axis { right: calc(100% + 6px); transform: translateY(-50%); }
.tw-axis-x { position: relative; height: 18px; }
/* Centred on its tick; near an edge it stays inside the plot (18 px is about half of the widest label, "Oct 14"). */
.tw-axis-x .tw-axis { top: 4px; left: clamp(18px, var(--tw-x), calc(100% - 18px)); transform: translateX(-50%); }
/* X ticks: shown only in their plot-width classes (ChartAxis.WidthClasses; a test keeps these in sync). */
.tw-xt { display: none; }
@container tw-plot (width < 240px) { .tw-xv0 { display: inline; } }
@container tw-plot (240px <= width < 320px) { .tw-xv1 { display: inline; } }
@container tw-plot (320px <= width < 400px) { .tw-xv2 { display: inline; } }
@container tw-plot (400px <= width < 520px) { .tw-xv3 { display: inline; } }
@container tw-plot (520px <= width < 640px) { .tw-xv4 { display: inline; } }
@container tw-plot (640px <= width < 800px) { .tw-xv5 { display: inline; } }
@container tw-plot (800px <= width < 1000px) { .tw-xv6 { display: inline; } }
@container tw-plot (1000px <= width < 1250px) { .tw-xv7 { display: inline; } }
@container tw-plot (1250px <= width < 1600px) { .tw-xv8 { display: inline; } }
@container tw-plot (1600px <= width < 2000px) { .tw-xv9 { display: inline; } }
@container tw-plot (width >= 2000px) { .tw-xv10 { display: inline; } }
/* Browsers without container queries (Safari < 16, Chrome < 105, Firefox < 110): the 400-519 px set, no overlap >= 400 px. */
@supports not (container-type: inline-size) { .tw-xt.tw-xv3 { display: inline; } }
/* Trailer page: chart cards in 1 column, 2 once the content is at least 1200 px wide. */
.tw-chart-grid-wrap { container: tw-charts / inline-size; }
.tw-chart-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@container tw-charts (width >= 1200px) {
    .tw-chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* An odd last chart (Disk: one series per drive) takes the full row instead of leaving half of it empty. */
    .tw-chart-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.tw-chart-card { min-width: 0; }
.tw-threshold { stroke: var(--tw-critical); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.6; }
.tw-series { fill: none; stroke: var(--tw-series); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.tw-dot, .tw-hover-dot { position: absolute; border-radius: 50%; background: var(--tw-series); transform: translate(-50%, -50%); pointer-events: none; }
.tw-dot { width: 5px; height: 5px; }
.tw-hover-dot { width: 8px; height: 8px; border: 2px solid var(--tw-surface); }
.tw-crosshair { stroke: var(--tw-axis); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.tw-band { fill: transparent; }
.tw-band-pick { cursor: pointer; }
.tw-tooltip {
    position: absolute; top: 4px; left: var(--tw-x); transform: translateX(12px); pointer-events: none; z-index: 2;
    background: var(--tw-surface); border: 1px solid var(--tw-border); border-radius: 6px; padding: 6px 10px;
    box-shadow: 0 2px 8px var(--tw-shadow); font-size: 0.75rem; color: var(--tw-text); box-sizing: border-box;
    /* Opens on the wider side of the cursor (the chart flips it at 50 %), so half the plot always fits. */
    min-width: min(180px, calc(50% - 16px)); max-width: calc(50% - 16px);
}
.tw-tooltip-left { transform: translateX(calc(-100% - 12px)); }
/* Narrow plots (phone): half is too small, so it is pinned to the plot corner away from the cursor. */
@container tw-plot (width < 480px) {
    .tw-tooltip { left: auto; right: 0; transform: none; min-width: 0; max-width: 100%; }
    .tw-tooltip-left { left: 0; right: auto; }
}
.tw-tooltip-time { color: var(--tw-text-muted); margin-bottom: 4px; }
.tw-tooltip-row { display: flex; align-items: center; gap: 6px; }
.tw-tooltip-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tw-tooltip-value { white-space: nowrap; }
.tw-tooltip-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.tw-legend { display: flex; flex-wrap: wrap; gap: 2px 16px; margin: 6px 8px 0 36px; font-size: 0.75rem; line-height: 1.5; color: var(--tw-text); }
.tw-legend-none { min-height: 1.5em; } /* one series: no legend, same chart height */
.tw-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.tw-swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--tw-series); }
.tw-swatch-dashed { background: repeating-linear-gradient(90deg, var(--tw-series) 0 4px, transparent 4px 7px); }

/* Account (static SSR) pages */
.tw-account { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; box-sizing: border-box; }
.tw-account-card {
    width: 100%; max-width: 440px; background: var(--tw-surface); border: 1px solid var(--tw-border); border-radius: 8px;
    padding: 28px 28px 20px; box-sizing: border-box; font-family: Roboto, Helvetica, Arial, sans-serif; color: var(--tw-text);
}
.tw-account-brand { display: block; font-weight: 700; font-size: 1.1rem; color: var(--tw-accent); text-decoration: none; margin-bottom: 16px; }
.tw-account-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tw-account-head .tw-account-brand { margin-bottom: 0; }
.tw-theme-button {
    display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 0.8rem; padding: 4px 10px; border-radius: 6px;
    border: 1px solid var(--tw-border); background: transparent; color: var(--tw-text-muted); cursor: pointer;
}
.tw-theme-button:hover { background: var(--tw-accent-wash); color: var(--tw-text); }
.tw-theme-button:focus-visible { outline: 2px solid var(--tw-accent); outline-offset: 1px; }
.tw-theme-icon { display: none; font-size: 1.1rem; }
.tw-theme-button[data-pref="system"] .tw-theme-icon-system,
.tw-theme-button[data-pref="light"] .tw-theme-icon-light,
.tw-theme-button[data-pref="dark"] .tw-theme-icon-dark { display: inline-block; }
.tw-account-card a:not(.tw-button):not(.tw-account-brand) { color: var(--tw-accent); }
.tw-account-title { font-size: 1.5rem; font-weight: 500; margin: 0 0 16px; }
.tw-account-note { font-size: 0.875rem; color: var(--tw-text-muted); margin-top: 16px; }
.tw-account-error, .tw-account-success, .tw-account-warning { border-radius: 6px; padding: 10px 12px; margin-bottom: 16px; font-size: 0.9rem; }
.tw-account-error { background: var(--tw-error-bg); color: var(--tw-error-text); }
.tw-account-success { background: var(--tw-success-bg); color: var(--tw-success-text); }
.tw-account-warning { background: var(--tw-warning-bg); color: var(--tw-warning-text); }
.tw-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: 0.875rem; }
.tw-field-error { color: var(--tw-critical); font-size: 0.8rem; }
.tw-input {
    font: inherit; font-size: 1rem; padding: 10px 12px; border: 1px solid var(--tw-input-border); border-radius: 6px; background: var(--tw-surface); color: var(--tw-text);
}
.tw-input:focus { outline: 2px solid var(--tw-accent); outline-offset: 0; border-color: var(--tw-accent); }
.tw-check { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; margin-bottom: 16px; }
.tw-button {
    display: inline-block; font: inherit; font-weight: 500; font-size: 0.95rem; padding: 10px 18px; border-radius: 6px; border: none;
    background: var(--tw-accent); color: var(--tw-accent-text); cursor: pointer; text-decoration: none;
}
.tw-button:hover { background: var(--tw-accent-hover); }
.tw-button-secondary { background: transparent; color: var(--tw-accent); border: 1px solid var(--tw-accent); }
.tw-button-secondary:hover { background: var(--tw-accent-wash); }
.tw-steps { padding-left: 20px; font-size: 0.9rem; line-height: 1.5; }
.tw-steps li { margin-bottom: 10px; }
.tw-key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.05rem; background: var(--tw-code-bg); padding: 8px 10px; border-radius: 6px; margin: 6px 0; letter-spacing: 0.04em; }
.tw-uri { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.75rem; word-break: break-all; color: var(--tw-text-muted); margin: 4px 0; }
.tw-codes { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--tw-code-bg); color: var(--tw-text); padding: 12px; border-radius: 6px; columns: 2; }

#blazor-error-ui {
    background: var(--tw-warning-bg); color: var(--tw-warning-text); bottom: 0; box-shadow: 0 -1px 2px var(--tw-shadow); display: none; left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; box-sizing: border-box;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* Fleet filter bar: the filters wrap and shrink in their own row; the Columns button stays at the right of the first line
   (on a phone it wraps below them, still right-aligned). */
.tw-filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.tw-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; flex: 1 1 360px; min-width: 0; }
.tw-filters .tw-filter { flex: 1 1 160px; min-width: 160px; max-width: 260px; }
.tw-filterbar > .tw-columns-anchor { flex: none; }

/* Columns menu (Shared/ColumnsMenu.razor): an in-place panel under the button, above a transparent click-away layer. */
.tw-columns-anchor { position: relative; display: inline-flex; margin-left: auto; } /* right end of its line, wrapped or not */
.tw-columns-backdrop { position: fixed; inset: 0; z-index: calc(var(--mud-zindex-appbar) + 1); background: transparent; }
.tw-columns-panel {
    position: absolute; right: 0; top: calc(100% + 4px); z-index: calc(var(--mud-zindex-appbar) + 2);
    min-width: 280px; max-width: calc(100vw - 32px); padding: 8px 4px 4px;
    background: var(--tw-surface); color: var(--tw-text); border: 1px solid var(--tw-border); border-radius: 8px;
}
.tw-columns-panel:focus { outline: none; }
.tw-columns-panel:focus-visible { outline: 2px solid var(--tw-accent); outline-offset: 2px; }
.tw-columns-title { font-weight: 600; font-size: 0.875rem; padding: 0 12px 4px; }
.tw-columns-list { list-style: none; margin: 0; padding: 0; }
.tw-columns-item { display: flex; align-items: center; gap: 2px; padding-right: 4px; }
.tw-columns-item > :first-child, .tw-columns-check { flex: 1 1 auto; min-width: 0; }
.tw-columns-actions { display: flex; align-items: center; border-top: 1px solid var(--tw-border); margin-top: 4px; padding: 4px 4px 0; }
/* Phones: 44 px touch targets for the checkboxes and move buttons. */
@media (max-width: 600px) {
    .tw-columns-item { min-height: 44px; }
    .tw-columns-item .mud-icon-button { padding: 10px; }
    .tw-columns-actions .mud-button-root { min-height: 44px; }
}
/* A header with an explanation (tooltip): dotted underline, focusable. */
.tw-th-hint { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }

/* Trailer page: the trailer's machine (one per trailer) as a details panel. Facts sit in a row, each as wide as its
   content, wrapping on narrower screens; on a phone a 2-column grid. */
.tw-machine-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.tw-machine-name { font-size: 1.1rem; font-weight: 500; margin-right: 4px; overflow-wrap: anywhere; }
.tw-machine-actions { margin-left: auto; }
.tw-machine-facts { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 40px; margin: 12px 0 0; }
.tw-machine-facts > div { min-width: 0; max-width: 100%; }
.tw-machine-facts dt { font-size: 0.75rem; color: var(--tw-text-muted); margin: 0 0 2px; }
.tw-machine-facts dd { margin: 0; font-size: 0.875rem; overflow-wrap: anywhere; }
.tw-disk { white-space: nowrap; }
@media (max-width: 600px) {
    .tw-machine-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
    /* The tall Agent / update cell goes last, full width, so CPU, Memory and Disks stay together. */
    .tw-machine-facts > [data-fact="agent"] { order: 1; grid-column: 1 / -1; }
}
/* Fleet: the machine's hostname under the trailer name never breaks inside the name. */
.tw-host { white-space: nowrap; }

/* Network section (DESIGN.md 12.9): router card with one tile per modem; signal bars with the band as text. */
.tw-router-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.tw-router-name { font-size: 1.1rem; font-weight: 500; margin-right: 4px; }
.tw-net-facts, .tw-modem-facts { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 10px 0 0; }
.tw-net-facts > div, .tw-modem-facts > div { min-width: 0; max-width: 100%; }
.tw-net-facts dt, .tw-modem-facts dt { font-size: 0.75rem; color: var(--tw-text-muted); margin: 0 0 2px; }
.tw-net-facts dd, .tw-modem-facts dd { margin: 0; font-size: 0.875rem; overflow-wrap: anywhere; }
.tw-modems { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 12px; margin-top: 14px; }
.tw-modem { border: 1px solid var(--tw-border); border-radius: 8px; padding: 12px 14px; min-width: 0; background: var(--tw-surface); }
.tw-modem-active { border-color: var(--tw-accent); box-shadow: inset 3px 0 0 var(--tw-accent); }
/* Last known values (router not answering, or values older than ~10 min): greyed, with their age, never shown as current. */
.tw-modem-stale { border-style: dashed; background: var(--tw-code-bg); }
.tw-modem-stale .tw-modem-sub, .tw-modem-stale .tw-signal-values, .tw-modem-stale .tw-modem-facts:not(.tw-modem-staff), .tw-modem-stale .tw-signal-bars { opacity: 0.6; }
.tw-modem-age { font-size: 0.8rem; color: var(--tw-text-muted); margin-top: 2px; }
.tw-modem-head { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.tw-modem-name { font-weight: 600; }
.tw-modem-sub { font-size: 0.9rem; margin-top: 2px; }
.tw-modem-staff { border-top: 1px dashed var(--tw-border); padding-top: 8px; }
.tw-signal-values { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.tw-signal-values .tw-muted { margin-right: 2px; }
.tw-signal { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 0.85rem; }
.tw-signal-bars { display: block; flex: none; }
.tw-bar { fill: var(--tw-grid); }
.tw-signal-good .tw-bar-on { fill: var(--mud-palette-success); }
.tw-signal-fair .tw-bar-on { fill: var(--mud-palette-warning); }
.tw-signal-poor .tw-bar-on { fill: var(--mud-palette-error); }
.tw-signal-unknown .tw-bar-on { fill: var(--tw-axis); }
.tw-signal-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tw-ups-cell { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.tw-ups-battery { font-weight: 600; }
.tw-ups-stale { opacity: 0.6; }
.tw-nowrap { white-space: nowrap; }
.tw-net-events td { font-size: 0.85rem; vertical-align: top; }
/* Charts: which modem was active (background bands) and modem switches (dashed markers). */
.tw-shade { fill-opacity: 0.09; }
.tw-shade-0 { fill: var(--tw-series-1); }
.tw-shade-1 { fill: var(--tw-series-2); }
.tw-shade-2 { fill: var(--tw-series-3); }
.tw-shade-3 { fill: var(--tw-series-4); }
.tw-marker { stroke: var(--tw-text-muted); stroke-width: 1; stroke-dasharray: 5 3; opacity: 0.8; }
.tw-tooltip-event { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--tw-border); color: var(--tw-text-muted); }
/* Speed tests card (router script, DESIGN.md 12.17): status line, run table with active / won markers. */
.tw-speed-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font-size: 0.875rem; margin: 4px 0 8px; }
.tw-speed-table td, .tw-speed-table th { font-variant-numeric: tabular-nums; }
.tw-speed-table td.tw-num, .tw-speed-table th.tw-num { text-align: end; white-space: nowrap; }
.tw-speed-scan th[scope="row"] { font-weight: 400; }
.tw-speed-mark { display: inline-block; border: 1px solid var(--tw-border); border-radius: 10px; padding: 0 6px; margin-left: 6px; font-size: 0.75rem; white-space: nowrap; }
.tw-speed-mark-active { border-color: var(--tw-accent); color: var(--tw-accent); }
.tw-speed-mark-won { border-color: var(--mud-palette-success); color: var(--mud-palette-success); }
/* Admin › Network: the vendor allowlist as compact chips. */
.tw-oui-list { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.tw-oui { border: 1px solid var(--tw-border); border-radius: 6px; padding: 2px 8px; font-size: 0.85rem; }
@media (max-width: 600px) {
    .tw-net-facts, .tw-modem-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
    .tw-modem { padding: 10px 12px; }
}

/* Machine › network adapters and imaging queues (DESIGN.md 13.1-13.2). */
.tw-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 32px; }
.tw-card-title { font-size: 1.05rem; font-weight: 500; margin-right: 4px; }
.tw-nics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 12px; margin-top: 12px; }
.tw-nic { border: 1px solid var(--tw-border); border-radius: 8px; padding: 12px 14px; min-width: 0; background: var(--tw-surface); }
.tw-nic-default { border-color: var(--tw-accent); box-shadow: inset 3px 0 0 var(--tw-accent); }
.tw-nic-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-height: 32px; }
.tw-nic-name { font-weight: 600; overflow-wrap: anywhere; }
.tw-nic-sub { font-size: 0.85rem; color: var(--tw-text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.tw-nic-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tw-nic-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.tw-sql {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; line-height: 1.45;
    background: var(--tw-code-bg); color: var(--tw-text); padding: 10px 12px; border-radius: 6px; margin: 0;
    white-space: pre-wrap; overflow-wrap: anywhere; user-select: all;
}
/* Wide tables scroll inside their card on a phone, never the page. */
.tw-table-scroll { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.tw-queue-table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
.tw-queue-table th, .tw-queue-table td { padding: 6px 10px; border-bottom: 1px solid var(--tw-border); text-align: start; }
.tw-queue-table thead th { font-size: 0.75rem; font-weight: 500; color: var(--tw-text-muted); white-space: nowrap; }
.tw-queue-table tbody th { font-weight: 500; }
.tw-queue-name { min-width: 8rem; max-width: 18rem; overflow-wrap: anywhere; }
.tw-q-hot { font-weight: 600; }
.tw-q-overdue, .tw-q-paused { background: var(--tw-warning-bg); color: var(--tw-warning-text); }
.tw-q-failed { background: var(--tw-error-bg); color: var(--tw-error-text); }
.tw-inline-icon { vertical-align: text-bottom; font-size: 1rem !important; }
/* A spinning MudProgressCircular rotates its whole box: its corners poke out while it turns, and a scroll container (or the
   page) toggles its scrollbar on and off. The box clips it to its own square. */
.tw-spinner { display: inline-flex; flex: none; width: 24px; height: 24px; overflow: hidden; vertical-align: middle; }
.tw-linklike {
    background: none; border: 0; padding: 0; font: inherit; color: var(--tw-accent); cursor: pointer; text-align: start;
    overflow-wrap: anywhere;
}
.tw-linklike:hover { text-decoration: underline; }
.tw-linklike:focus-visible { outline: 2px solid var(--tw-accent); outline-offset: 1px; }
.tw-chart-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.tw-chart-select { flex: 0 1 200px; min-width: 140px; max-width: 220px; }

/* Alerts (DESIGN.md 13.3): app bar badge, fleet cell. */
.tw-alert-badge { display: inline-flex; align-items: center; color: inherit; padding: 6px 10px; border-radius: 50%; }
.tw-alert-badge:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.tw-alert-cell { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: inherit; text-decoration: none; }
.tw-alert-cell:hover { text-decoration: underline; }
.tw-switch-placeholder { border-style: dashed; }
@media (max-width: 600px) {
    .tw-nic { padding: 10px 12px; }
    .tw-chart-select { flex: 1 1 140px; max-width: none; }
}

/* Switch card (DESIGN.md 12.9 item 3, 12.15): server-rendered SVG front panel. Port fill by link and speed, admin-down and
   isolated ports hatched; the VLAN band uses the chart series tokens. Colours come from the tokens only. */
:root {
    --tw-port-up-fill: #17845c;
    --tw-port-up-text: #ffffff;
    --tw-port-slow-fill: #eda100;
    --tw-port-slow-text: #1f1a10;
}
html[data-theme="dark"] {
    --tw-port-up-fill: #1a8a61;
    --tw-port-slow-fill: #c98500;
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        --tw-port-up-fill: #1a8a61;
        --tw-port-slow-fill: #c98500;
    }
}
.tw-switch-outline { border-style: dashed; }
.tw-switch-panel { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0 6px; max-width: 100%; }
.tw-switch-block { max-width: 100%; height: auto; display: block; }
.tw-switch-body { fill: var(--tw-code-bg); stroke: var(--tw-border); }
.tw-port-link { cursor: pointer; }
.tw-port-link:focus-visible .tw-port-glyph { stroke: var(--tw-accent); stroke-width: 3; }
.tw-port .tw-port-glyph { stroke: var(--tw-axis); stroke-width: 1.5; fill: var(--tw-surface); }
.tw-port-up .tw-port-glyph { fill: var(--tw-port-up-fill); stroke: var(--tw-port-up-fill); }
.tw-port-slow .tw-port-glyph { fill: var(--tw-port-slow-fill); stroke: var(--tw-port-slow-fill); }
.tw-port-down .tw-port-glyph { fill: var(--tw-surface); }
.tw-port-admin .tw-port-glyph { fill: var(--tw-surface); stroke-dasharray: 3 2; }
.tw-port-nodata .tw-port-glyph { fill: none; stroke-dasharray: 2 3; opacity: 0.6; }
.tw-port-num { font-size: 11px; font-weight: 600; fill: var(--tw-text); pointer-events: none; }
.tw-port-speed { font-size: 9px; fill: var(--tw-text); pointer-events: none; }
.tw-port-up .tw-port-num, .tw-port-up .tw-port-speed { fill: var(--tw-port-up-text); }
.tw-port-slow .tw-port-num, .tw-port-slow .tw-port-speed { fill: var(--tw-port-slow-text); }
.tw-port-tag { font-size: 9px; font-weight: 700; fill: var(--tw-text); letter-spacing: 0.02em; }
.tw-port-overlay { pointer-events: none; }
.tw-hatch-line { stroke: var(--tw-axis); stroke-width: 1.5; }
.tw-vlan-band.tw-tone-1 { fill: var(--tw-series-1); background: var(--tw-series-1); }
.tw-vlan-band.tw-tone-2 { fill: var(--tw-series-2); background: var(--tw-series-2); }
.tw-vlan-band.tw-tone-3 { fill: var(--tw-series-3); background: var(--tw-series-3); }
.tw-vlan-band.tw-tone-4 { fill: var(--tw-series-4); background: var(--tw-series-4); }
.tw-vlan-band.tw-tone-5 { fill: var(--tw-series-5); background: var(--tw-series-5); }
.tw-vlan-band.tw-tone-6 { fill: var(--tw-series-6); background: var(--tw-series-6); }
.tw-vlan-band.tw-tone-7 { fill: var(--tw-series-7); background: var(--tw-series-7); }
.tw-vlan-band.tw-tone-8 { fill: var(--tw-series-8); background: var(--tw-series-8); }
.tw-switch-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.75rem; color: var(--tw-text-muted); margin-bottom: 10px; }
.tw-switch-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.tw-port-key { display: inline-block; width: 14px; height: 12px; border-radius: 2px; border: 1.5px solid var(--tw-axis); background: var(--tw-surface); }
.tw-port-key.tw-port-up { background: var(--tw-port-up-fill); border-color: var(--tw-port-up-fill); }
.tw-port-key.tw-port-slow { background: var(--tw-port-slow-fill); border-color: var(--tw-port-slow-fill); }
.tw-port-key.tw-port-admin { border-style: dashed; }
.tw-port-key.tw-port-iso { background: repeating-linear-gradient(45deg, var(--tw-axis) 0 1.5px, transparent 1.5px 5px); }
.tw-port-key.tw-vlan-band { height: 5px; border: 0; }
.tw-port-table td, .tw-port-table th { white-space: nowrap; }
.tw-port-table tr:target { background: var(--tw-accent-wash); }
/* Acknowledgement note (user text): wraps, never widens the table. */
.tw-ack-comment { font-size: 0.8rem; font-style: italic; color: var(--tw-text); overflow-wrap: anywhere; white-space: pre-line; max-width: 28rem; }
/* Alert comment thread (user text: wraps, keeps line breaks). */
.tw-comment-thread { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 50vh; overflow-y: auto; }
.tw-comment-thread li { border-inline-start: 3px solid var(--tw-border); padding-inline-start: 10px; }
.tw-comment-text { font-size: 0.875rem; white-space: pre-line; overflow-wrap: anywhere; }
/* Queue count → records table (staff, DESIGN.md 13.2). */
.tw-q-count { font: inherit; color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.tw-q-selected { text-decoration-style: solid; }
.tw-records-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.tw-records-table td { vertical-align: top; }
/* Selection checkboxes: the same box size in every row, centred on the first line of the row's text (cells are top-aligned
   because the descriptions wrap), instead of the browser's default margins and baseline. */
.tw-records-table .tw-select-cell { width: 2rem; padding-inline-end: 4px; text-align: center; }
.tw-records-table .tw-select-cell input { display: block; width: 1rem; height: 1rem; margin: calc((1lh - 1rem) / 2) 0 0; accent-color: var(--tw-accent); cursor: pointer; }
.tw-records-table thead .tw-select-cell { vertical-align: bottom; }
.tw-record-text { min-width: 12rem; max-width: 32rem; overflow-wrap: anywhere; white-space: pre-line; }
.tw-problem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tw-problem-count { font-variant-numeric: tabular-nums; font-weight: 600; margin-inline-end: 6px; }
.tw-problem-message { font-size: 0.85rem; overflow-wrap: anywhere; white-space: pre-line; }
/* Router GPS → Google Maps (staff). */
.tw-map-link { margin-inline-start: 8px; white-space: nowrap; color: var(--tw-accent); text-decoration: none; font-size: 0.85rem; }
.tw-map-link:hover, .tw-map-link:focus-visible { text-decoration: underline; }
/* Devices behind a switch port (staff). */
.tw-port-hosts { min-width: 14rem; font-size: 0.8rem; }
.tw-port-hosts > div + div { margin-top: 4px; }
/* Records: selection and the status change bar (staff and customer admins). */
/* (not .tw-check: that is the login page's checkbox label, display: flex, which breaks a table cell) */
.tw-change-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.tw-change-status { max-width: 12rem; }

/* Admin › Run command (DESIGN.md 13.6 point 13): a PC's captured output, scrolling inside its row. */
.tw-command-output {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; line-height: 1.45;
    background: var(--tw-code-bg); color: var(--tw-text); padding: 8px 10px; border-radius: 6px; margin: 0;
    white-space: pre-wrap; overflow-wrap: anywhere; max-height: 24rem; overflow: auto;
}
.tw-command-targets { max-height: 22rem; overflow: auto; border: 1px solid var(--tw-border); border-radius: 6px; }
