@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.2;
    }
}

@keyframes dialog-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* ----------------------
        LAYOUT
----------------------- */

html,
body,
.wrapper {
    width: 100%;
    height: 100%;

}

.wrapper {
    background: var(--bg);
}


/* ----------------------
        TABLE
----------------------- */

table {
    min-width: 800px;
    --row-hover: var(--surface-2);
    --row-alt: var(--surface-3);
}

table.data-table,
table.data-table thead,
table.data-table tbody {
    display: block;
}

table.data-table thead {
    text-align: left;
}

table.data-table thead th {
    font-family: var(--text-font);
    font-weight: 700;
    font-size: var(--font-small);
    text-transform: uppercase;
    letter-spacing: .08rem;
    color: var(--accent-text);
    padding-top: var(--p3);
    padding-bottom: var(--p3);
}

table.data-table thead th.selection-checkbox {
    flex: 0 0 auto;
}

table.data-table tbody tr td.selection-checkbox {
    flex: 0 0 auto;
}

.data-table thead tr {
    background: var(--surface-2);
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--accent);
}

.data-table tr {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
}

/* Row selection (table-selection.js) uses shift+click for range-select,
   which is also a native browser text-selection modifier - without this,
   shift-clicking a row highlights all the text between the two clicks
   instead of (or in addition to) selecting the rows. */
.data-table tbody tr {
    user-select: none;
}

.data-table tr>td,
.data-table tr>th {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: var(--p1) var(--p2);
}

.data-table tbody tr:nth-child(even) {
    background: var(--row-alt);
}

.data-table.selection tbody tr:hover {
    background: var(--row-hover);
    box-shadow: inset 3px 0 0 var(--accent);
}

.data-table tbody tr:not(:last-of-type) {
    border-bottom: 1px solid var(--border-strong);
}

.data-table tbody tr.selected {
    background: var(--accent-hover);
    box-shadow: inset 2px 0 0 var(--accent);
}

.data-table thead th[data-head-id="id"],
.data-table tbody td[data-cell-id="id"] {
    flex: 0.25 1 0;
}

.row-actions-head {
    text-align: right;
}

/* InfoCard::fieldGroups() - labelled bands of fields on a detail page. */
.info-groups {
    display: flex;
    flex-direction: column;
    gap: var(--g3);
}

.info-group {
    display: flex;
    flex-direction: column;
    gap: var(--g2);
}

/* Quieter than the card header above it: this labels a band *within* a
   section, so it must not compete with the section's own title. Uppercase by
   class, which is the whole point of the tag no longer implying it. */
.info-group-title {
    margin: 0;
    font-size: var(--font-xs);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-3);
}

/* The section chips summarising a snippet in the list. Wraps rather than
   truncating: a snippet covering five areas should say so on two lines
   instead of hiding the last three behind an ellipsis. */
.snippet-coverage {
    display: flex;
    flex-wrap: wrap;
    gap: var(--g1);
}

/* Right-aligned: the actions column is last and its buttons are the only
   thing in it, so left-aligning them stranded a run of icons in the middle of
   the widest gap on the row. Against the table's right edge they form a
   single column the eye can travel down. */
.row-actions {
    display: flex;
    gap: var(--g1);
    justify-content: flex-end;
    opacity: 0.55;
    transition: opacity 120ms;
}

/* Table::render() columns marked 'visible' => false still emit a
   data-cell-id/data-value <td> (so JS - e.g. the Hide confirmation's
   dynamic warnings - can read it via getRowValues()), just with nothing
   rendered and no header cell to line up with. */
.cell-data-only {
    display: none;
}

.data-table tbody tr:hover .row-actions,
.data-table tbody tr.selected .row-actions {
    opacity: 1;
}

/* ── Grouped tables (Table::render($group_by)) ── */

.data-table-grouped tbody tr.table-group-header {
    cursor: pointer;
    background: var(--surface-2);
    user-select: none;
}

.data-table-grouped tbody tr.table-group-header:hover {
    background: var(--surface-3);
}

/* Taller and a step up the type scale. The header names the thing all the
   rows beneath it belong to, and it used to be set *smaller* than them - so
   the group read as a caption interrupting the list rather than as the list's
   own heading. */
.data-table-grouped tr.table-group-header td {
    font-weight: 700;
    font-size: var(--font-size-2);
    padding-top: var(--p3);
    padding-bottom: var(--p3);
    color: var(--text);
    text-overflow: clip;
}

/* The rows of a group are bracketed by a rule down their left edge, so a port
   row is visibly *inside* the switch named above it. This is what lets the
   per-row switch name go without being missed: the membership was carried by
   repeating that name in every row, and a border says the same thing once.
   The header carries the accent segment; its rows continue it in the quiet
   border colour, so the group reads as one block that starts at the title. */
.data-table-grouped tbody tr.table-group-header > td:first-child {
    box-shadow: inset 3px 0 0 0 var(--accent);
}

.data-table-grouped tbody tr[data-group] > td:first-child {
    box-shadow: inset 3px 0 0 0 var(--border-strong);
}

.table-group-chevron {
    display: inline-block;
    width: 1em;
    font-size: .85em;
    color: var(--text-3);
    transition: transform 150ms ease;
}

.table-group-header.collapsed .table-group-chevron {
    transform: rotate(-90deg);
}

.table-group-count {
    font-weight: 400;
}


/* ----------------------
        STATES
----------------------- */

button:disabled,
.inactive,
.disabled {
    color: var(--text-disabled);
}

.inactive:hover,
.disabled:hover,
button:disabled:hover {
    cursor: not-allowed;
}

.success {
    color: var(--success);
    --status: var(--success);
}

.warning {
    color: var(--warn);
    --status: var(--warn);
}

.error {
    color: var(--error);
    --status: var(--error);
}

.unknown {
    color: var(--unknown);
    --status: var(--unknown);
}

.info {
    color: var(--info);
    --status: var(--info);
}

.accent {
    color: var(--accent-text);
    --status: var(--accent-text);
}

.status-dot::before {
    content: '';
    align-self: center;
    width: var(--p2);
    height: var(--p2);
    margin: 0 var(--m2);
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
    background: var(--status);
}

.bold {
    font-weight: 900;
}

.muted {
    color: var(--text-3);
}

/* One step lighter than default text, one step darker than .muted - for
   descriptive/secondary body copy that shouldn't read as fully de-emphasized
   hint text. Was referenced as class="text-2" in ssh-credentials.php with no
   matching rule (a no-op, silently falling back to default text color) -
   added to actually back that reference. */
.text-2 {
    color: var(--text-2);
}

.label {
    text-transform: uppercase;
    text-wrap: nowrap;
    letter-spacing: .08rem;
    font-size: var(--font-xs);
    font-weight: 600;
    margin-bottom: var(--m1);
}

.upper {
    text-transform: uppercase;
}


/* ----------------------
        BADGES
----------------------- */

.tag,
.badge {
    display: inline-flex;
    padding: var(--p1) var(--p2);
    border-width: 1px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: var(--font-small);
}

.tag {
    border-style: dotted;
    border-radius: var(--rad-3);
}

.badge {
    border-style: solid;
    /* --rad-1 is 2px, which reads as a square with soft corners rather than a
       tag. --rad-2 matches the buttons and field tiles beside it. */
    border-radius: var(--rad-2);
}

/* Aurora addition: the ported base .badge is a bare thin-bordered pill
   with no fill - too subtle for the identifying columns (Zone/VLAN/Role/
   Modell/etc. names) it's used for across every list page here. Bolder
   default look (filled + bold), closer in weight to Counter's own
   semantic badges (.badge.success etc. below) rather than the unstyled
   default; those semantic variants still win via their extra class. */
.badge {
    background: var(--accent-soft);
    color: var(--accent-text);
    border-color: var(--accent-border);
    font-weight: 700;
}

.tag.unknown,
.badge.unknown {
    background: var(--unknown-soft);
    border-color: var(--unknown);
    color: var(--unknown-text);
}

.badge[data-role="globaladmin"] {
    background: var(--role-globaladmin-bg);
    color: var(--role-globaladmin-fg);
    border-color: var(--role-globaladmin-bd);
}

.badge[data-role="admin"] {
    background: var(--role-admin-bg);
    color: var(--role-admin-fg);
    border-color: var(--role-admin-bd);
}

.badge[data-role="user"] {
    background: var(--role-user-bg);
    color: var(--role-user-fg);
    border-color: var(--role-user-bd);
}


/* ----------------------
        GHOST BACKGROUND
----------------------- */

.ghost-background {
    position: fixed;
    display: flex;
    z-index: -1;
    align-items: center;
    justify-content: center;
    font-family: 'Anton';
    inset: 0;
    opacity: 0.3;
    font-size: calc(8 * var(--font-size-6));
    color: transparent;
    -webkit-text-stroke: 1px var(--status);
}


/* ----------------------
        LAYOUT HELPERS
----------------------- */

.divider {
    border: 5px solid var(--status);
    width: 8rem;
}


/* ----------------------
        MODALS
----------------------- */

.overlay-modal {
    background: none;
    border: none;
    outline: none;
}

dialog.overlay-modal {
    border-radius: var(--rad-4);
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    color: var(--text);
    padding: 0;
    box-shadow:
        var(--shadow-lg),
        0 0 1px var(--surface-3),
        inset 0 0 0 4px var(--surface-2);
    animation: dialog-in .2s ease-out;
    width: fit-content;
    min-width: 480px;
    max-width: min(1200px, 90vw);
}

dialog.overlay-modal::backdrop {
    backdrop-filter: blur(4px) saturate(.7);
    background: hsl(var(--hue), 10%, 30%, .35);
}

dialog .overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-strong);
}

dialog .overlay-title {
    font-family: var(--text-font);
    font-weight: 700;
    font-size: var(--font-size-2);
    letter-spacing: .04rem;
    color: var(--accent-text);
}

dialog .overlay-close {
    background: transparent;
    border: none;
    font-size: var(--font-size-4);
    color: var(--text);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-width: unset;
    cursor: pointer;
    flex-shrink: 0;
}

dialog .overlay-close:hover {
    color: var(--error);
}

dialog .card-body {
    padding: var(--p3) var(--p4);
}

dialog .form-row {
    display: flex;
    flex-direction: column;
    gap: var(--g1);
    padding: var(--p2) 0;
}

dialog .form-row label {
    font-size: var(--font-small);
    font-weight: 600;
    color: var(--text);
    letter-spacing: .03rem;
}

dialog .form-row input:focus,
dialog .form-row select:focus,
dialog .form-row textarea:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px hsl(var(--hue), var(--sat), 65%, .15);
    outline: none;
}

dialog .form-row input[type="checkbox"] {
    appearance: none;
    position: relative;
    width: 2.5rem;
    height: 1.3rem;
    background: var(--surface-2);
    border: none;
    border-radius: var(--rad-full);
    cursor: pointer;
    transition: background .2s ease;
}

dialog .form-row textarea {
    background: var(--surface-2);
    border-radius: var(--rad-2);
    transition: background .2s ease;
}

dialog .form-row input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.3rem - 4px);
    height: calc(1.3rem - 4px);
    background: var(--surface);
    border-radius: 50%;
    box-shadow: 0 1px 3px var(--opaque-200);
    transition: transform .2s ease;
}

dialog .form-row input[type="checkbox"]:checked {
    background: var(--accent);
}

dialog .form-row input[type="checkbox"]:checked::after {
    transform: translateX(1.2rem);
}

dialog .form-row input[type="checkbox"]:hover {
    background: var(--surface-3);
}

dialog .form-row input[type="checkbox"]:checked:hover {
    background: var(--accent);
}

.dialog-delete-selection {
    margin-bottom: var(--p3);
}

.dialog-delete-selection .dialog-form-label {
    font-size: var(--font-small);
    color: var(--text);
    font-weight: 600;
    margin-bottom: var(--p1);
}

.dialog-delete-selection .table-wrapper {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
}

.dialog-delete-selection .data-table {
    font-size: var(--font-small);
}

.dialog-delete-selection .data-table td,
.dialog-delete-selection .data-table th {
    padding: var(--p1) var(--p2);
}

/* Conditional warning/info banners appended to a dialog body (see
   EntityForm's $extraBody, e.g. InterfaceHideWarnings) - same semantic
   colors as .badge.warning/.badge.info, just block-level and built for a
   full sentence rather than an inline chip. */
.dialog-warning,
.dialog-info {
    display: flex;
    align-items: center;
    gap: var(--g2);
    padding: var(--p2) var(--p3);
    border-radius: var(--rad-2);
    font-size: var(--font-small);
    margin-top: var(--p2);
}

dialog#overlay-dialog-delete .overlay-title {
    color: var(--error-text);
}

dialog#overlay-dialog-delete .button.primary {
    background: linear-gradient(0deg, hsl(0, 55%, 45%), hsl(0, 55%, 55%));
    border-color: hsl(0, 60%, 40%);
    color: var(--white);
}

dialog#overlay-dialog-delete .button.primary:hover {
    background: linear-gradient(0deg, hsl(0, 65%, 40%), hsl(0, 65%, 50%));
    box-shadow: 0 2px 8px hsl(0, 60%, 50%, .3);
}

dialog.confirm-overlay {
    max-width: min(420px, 85vw);
    z-index: 100;
}

dialog.confirm-overlay::backdrop {
    background: hsl(0, 10%, 20%, .4);
    backdrop-filter: blur(2px);
}

dialog.confirm-overlay .overlay-title.error {
    color: var(--error-text);
}

.confirm-hint {
    font-size: var(--font-small);
    color: var(--text);
    margin: 0 0 var(--p2) 0;
}

.confirm-entries {
    display: flex;
    flex-direction: column;
    gap: var(--p2);
    max-height: 240px;
    overflow-y: auto;
}

.confirm-entry {
    display: flex;
    flex-wrap: wrap;
    gap: var(--p1) var(--p3);
    padding: var(--p2) var(--p3);
    border-radius: var(--rad-2);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: var(--font-small);
}

.confirm-field {
    display: inline-flex;
    align-items: center;
    gap: var(--p1);
}

.confirm-field-label {
    color: var(--text-3);
    font-weight: 600;
    text-transform: uppercase;
    font-size: .7em;
    letter-spacing: .04rem;
}

.confirm-field-label::after {
    content: ':';
}

.confirm-field-value {
    color: var(--text);
    font-family: var(--monospace-font);
}

dialog.confirm-overlay .button.primary.destructive {
    background: linear-gradient(0deg, hsl(0, 55%, 45%), hsl(0, 55%, 55%));
    border-color: hsl(0, 60%, 40%);
    color: var(--white);
}

dialog.confirm-overlay .button.primary.destructive:hover {
    background: linear-gradient(0deg, hsl(0, 65%, 40%), hsl(0, 65%, 50%));
    box-shadow: 0 2px 8px hsl(0, 60%, 50%, .3);
}

dialog .overlay-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--g2);
    padding: var(--p3) var(--p4);
    border-top: 1px solid var(--border);
}

dialog .overlay-actions button {
    border-radius: var(--rad-3);
    padding: var(--p2) var(--p4);
    font-weight: 500;
    letter-spacing: .03rem;
    transition:
        background .15s ease,
        border-color .15s ease,
        box-shadow .15s ease;
}

.dialog-return-message {
    padding: 0 var(--p4);
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease, padding .3s ease;
}

.dialog-return-message.visible {
    max-height: 200px;
    padding: var(--p2) var(--p4);
}

.dialog-return-row.tag {
    padding: var(--p2) var(--p3);
    border-radius: var(--rad-2);
    margin-bottom: var(--p1);
    font-size: var(--font-small);
    font-family: var(--monospace-font);
}


/* ----------------------
        BUTTONS
----------------------- */

/* .action-menu > summary is a <summary>, so it matches neither `button` nor
   `a.action-button` and would otherwise render as bare text between two real
   buttons. Listed here rather than restyled in the ACTION MENU block so the
   toggle can never drift from the buttons it sits beside. */
button,
a.action-button,
.action-menu > summary {
    box-sizing: border-box;
    padding: var(--p2);
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-3);
    background: var(--surface-2);
    color: var(--text);
    letter-spacing: .05rem;
    min-width: fit-content;
}

button:not(:disabled):not(.destructive):hover,
a.action-button:hover,
.action-menu > summary:hover {
    cursor: pointer;
    background: var(--button-bg);
    /*border: 1px solid var(--accent);*/
    color: var(--surface-3);
}

a:active,
button:not(:disabled):active {
    /* */
}

.status-button {
    background: color-mix(in srgb, var(--status) 10%, var(--surface));
    color: var(--status);
    border: 1px solid color-mix(in srgb, var(--status) 30%, var(--surface));
}

.status-button:hover {
    background: color-mix(in srgb, var(--status) 25%, var(--surface));
    border-color: color-mix(in srgb, var(--status) 50%, var(--surface));
}

button[data-action="delete"]:hover {
    background: var(--error);
    border: 1px solid var(--error-soft);
}

/* The generic hover above excludes .destructive so the dialog buttons can
   keep their own red styling - but that left every `.action-button
   destructive` (the switch page's key revocation, the snippet editor's
   delete) with no hover state at all: not disabled, not obviously clickable,
   just inert. They get the same red treatment data-action="delete" already
   has, which is what they are. */
button.action-button.destructive:not(:disabled):hover {
    cursor: pointer;
    background: var(--error);
    border-color: var(--error-soft);
}

a.action-button,
.action-menu > summary {
    text-align: center;
    /* A <button> gets `line-height: normal` from the UA, an <a> and a <summary>
       inherit the body's 1.45 - so an anchor-styled button standing next to a
       real one was 36px against 33px. Matching the UA value here shrinks the
       handful of anchor buttons rather than growing every <button> in the app,
       including the icon-only ones in dense table rows. */
    line-height: normal;
}

.action-button {
    font-family: 'Lato';
    font-weight: 500;
    white-space: nowrap;
}

/* Aurora addition: the ported design system special-cased a primary/
   destructive look only inside specific dialogs (#overlay-dialog-delete,
   .confirm-overlay) - this generalizes a plain accent-colored "primary"
   look to any .button.primary (e.g. a dialog's main submit button),
   otherwise every button looked identical to Cancel. */
.button.primary {
    background: var(--accent);
    border-color: var(--accent-strong);
    color: var(--accent-fg);
}

.button.primary:hover {
    background: var(--accent-strong);
    color: var(--accent-fg);
}

.button.primary.destructive {
    background: var(--error);
    border-color: var(--error-strong);
    color: #fff;
}

.button.primary.destructive:hover {
    background: var(--error-strong);
}

/* Same specificity trap as .action-button.primary, and it had been sitting
   here unguarded: `button:disabled { color: var(--text-disabled) }` is (0,1,1)
   against this rule's (0,2,0), so a disabled primary kept the full accent fill
   AND full-contrast foreground - pixel-identical to an enabled one, measured
   in both themes.

   Not cosmetic. modal.js disables the submit for the duration of a slow device
   action (the _pending re-entry guard), so a 15s config push showed a button
   that still looked entirely clickable - inviting the second click that guard
   exists to prevent. Kept filled rather than tinted like .action-button
   .primary: a dialog has exactly one action to offer and can afford its
   strongest form, where a toolbar's primary sits among several. */
.button.primary:disabled {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-disabled);
}

/* The one emphasised action per toolbar or page head - "the thing you came here
   to do" among several outline ones. Use it once; a second cancels the first.

   Tinted rather than filled, and that is a theme-symmetry fix, not a taste
   call. A filled `background: var(--accent)` is not the same weight in the two
   palettes: --accent is oklch L=0.38 in light against a #FFFFFF page, and
   L=0.72 in dark against #15191F. Light mode therefore pops downward by a
   0.62 lightness gap while dark pops upward by ~0.6 from the other side, so
   the identical rule produced a heavy navy slab on light and a gentle
   highlight on dark. (--accent-fg does flip correctly - #ffffff light,
   oklch(0.12) dark - so the foreground was never the problem.)

   --accent-soft / --accent-text are defined as a matched pair in both
   palettes and stay one step from the surface in whichever direction that
   theme's "away from the background" is, which is what makes this read the
   same in both. It is also the treatment .stat's state variants now use, so
   emphasis means one thing across the app.

   The disabled rule is not optional: the global `button:disabled { color:
   var(--text-disabled) }` is one class less specific than `.action-button
   .primary`, so without it a disabled primary keeps full accent colouring and
   reads as the most clickable thing on the page. */
.action-button.primary {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

/* --accent-hover is the "one step further from the surface" token - lighter
   again in dark, deeper in light - so the hover moves the same perceived
   distance in both themes rather than darkening in one and lightening in the
   other. */
.action-button.primary:not(:disabled):hover {
    background: var(--accent-hover);
    border-color: var(--accent-strong);
    color: var(--accent-text);
}

.action-button.primary:disabled {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-disabled);
}

/* Aurora addition: VLAN-inventory indicator (Buildings page) + the
   inline error box its armed-confirm button reports failures into -
   ported from the original Aurora's buildings.css/main.css, rewritten
   against this project's token names. */
/* Column, not row: the add-to-inventory button sits on its own line under
   the derived id/name text rather than inline beside it - these cells
   (Buildings' STREAM/CTRL VLAN/Netz columns) carry the most text of any
   column on their page, and a flexbox .data-table gives every column
   equal width by default (see Table::widthStyle()'s 'width' column
   config, used to fix the equal-width side of this same problem), so
   keeping the button inline was forcing these columns even wider just to
   avoid wrapping. */
.vlan-cell {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: calc(var(--p1) / 2);
    word-break: keep-all;
}

.vlan-status-ok {
    color: var(--success-strong);
}

.vlan-add-btn,
.network-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--p1);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--warn-strong);
    font-size: var(--font-xs);
    white-space: nowrap;
}

.vlan-add-btn.armed,
.network-add-btn.armed {
    color: var(--error-strong);
    font-weight: 600;
}

.vlan-add-btn:disabled,
.network-add-btn:disabled {
    opacity: .6;
    cursor: default;
}

.dialog-error-message {
    margin: var(--m2) var(--m4) 0;
    padding: var(--p2) var(--p3);
    border-radius: var(--rad-2);
    background: var(--error-soft);
    border: 1px solid var(--error);
    color: var(--error-text);
    font-size: var(--font-size-1);
}

.dialog-error-message[hidden] {
    display: none;
}


/* ----------------------
        INPUTS
----------------------- */

input[type="text"],
input[type="password"],
input[type="datetime-local"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="button"],
input[type="url"],
select,
textarea {
    padding: var(--p2);
    border-radius: var(--rad-2);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

input:focus,
input:active {
    outline: none;
    border-color: var(--accent);
}

input:focus+i {
    outline: none;
    color: var(--accent);
    border-color: var(--accent);
    border-right: 1px solid transparent;
    background: var(--surface-3);
    transition: all .2s ease-out;
}

input.muted {
    color: var(--text-disabled);
    filter: brightness(0.9);
}

.password-view-icon {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    padding: 0 var(--p3);
    cursor: pointer;
    color: var(--text-2);
    transition: color .15s ease;
}

.password-view-icon:hover {
    color: var(--accent);
}


/* ----------------------
        ELEMENTS
----------------------- */

/* CONTENT */

#content {
    display: flex;
    flex-direction: column;
    gap: var(--g2);
    padding: var(--p2);
}

/* CARD */

.card,
.card-floating {
    display: flex;
    flex-direction: column;
    border-radius: var(--rad-3);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    /* The query container for table column priorities (media.css). The card is
       the box that actually bounds a table's width, which the viewport is not:
       the sidebar and the page padding sit between them, and the sidebar can
       be collapsed. Named, so a query cannot accidentally resolve against some
       other ancestor that happens to be a container.

       inline-size only: block-size containment would stop the card growing to
       fit its own rows. */
    container: table-card / inline-size;
    /*box-shadow: var(--shadow-md);
    transition: box-shadow .1s ease-out;*/
}

/* min-height keeps every card-header the same total height regardless of
   whether it holds plain h4 text (~1.7rem line-height) or also an
   .action-button (~2.6rem including its own padding/border) - before this,
   pages with a header action button (switch-ports.php, switch-detail.php,
   template-variables.php, ...) rendered a visibly taller header than every
   plain one, despite both using the same padding: var(--p3). */
.card-header {
    display: flex;
    align-items: center;
    gap: var(--g2);
    min-height: 3.75rem;
    padding: var(--p2) var(--p3);
    border-bottom: 1px solid var(--border-strong);
}

.card-header>i,
.card-header>h4 {
    color: var(--accent-text);
}

.card-body {
    padding: var(--p2);
}

/* Section-title label for header-like rows that aren't a real .card-header
   (e.g. a sub-panel inside a card body) - was used with no matching rule in
   template-editor.php/switchsetup.php, rendering as plain unstyled text. */
.card-title {
    font-weight: 600;
}

/* Standalone filter control between a page description and its toolbar
   (e.g. switch-ports.php's "Switch" select) - a single label+input pair,
   not a full multi-row form, so .form-row's column layout doesn't fit; own
   label size matches .form-row label's instead of falling back to
   .muted.text-xs (illegibly small for a filter someone actually needs to
   read). */
.filter-row {
    padding: 0 var(--p4) var(--p3);
    gap: var(--g2);
    align-items: center;
}

.filter-row label {
    font-size: var(--font-small);
    font-weight: 600;
    color: var(--text);
}

/* Intro/description text between a card's header and its toolbar/body
   (e.g. ssh-credentials.php, switch-ports.php) - was flush against the
   card's edges before (no horizontal padding), unlike every other piece of
   card content. */
.page-description {
    padding: var(--p3) var(--p4);
    color: var(--text-2);
}

/* COLLECTION */

.collection {
    display: flex;
    font-family: var(--root-font);
}

.collection.row .collection-item {
    border-right: 1px solid var(--border-strong);
}

.collection.row {
    border-bottom: 1px solid var(--border-strong);
}

.collection-item .collection-item-link.selected {
    background: var(--surface-3);
    box-shadow: inset 0 0 3px 1px var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.collection-item .collection-item-link.selected::before {
    content: '';
    position: absolute;
    width: 4px;
    background: var(--accent);
    left: 2px;
    height: var(--p6);
    border-radius: var(--rad-2);
}

/* COLLAPSIBLE */
/*
details.collapsible .collapsible-header:hover {
    background-color: var(--accent-hover);
    color: var(--text);

}*/

details.collapsible:open .collapsible-header {
    color: var(--text);
}

details.collapsible:open .collapsible-item {
    border-left: 2px solid var(--accent);
    margin-left: var(--m4);
}

/* sidebar-group replaces details.collapsible */

.sidebar-group {
    margin-left: var(--m1);
}

.sidebar-group.open .collapsible-item {
    border-left: 2px solid var(--accent);
    margin-left: var(--m4);
}

.collapsible-header i.fa-chevron-down {
    margin-right: var(--m2);
}

/* CHEVRON */

.fa-chevron-down,
.fa-chevron-right {
    transform: rotate(0);
    transition: transform .2s;
}

details[open=""]>summary>.collection-item-link>.fa-chevron-right {
    transform: rotate(90deg);
}

/* ─────────────────────── SIDEBAR ─────────────────────────────── */

#sidebar {
    min-height: 100%;
    min-width: var(--sidebar-w);
    padding-top: var(--p3);
    background: linear-gradient(270deg, var(--surface), var(--surface-2));
    border-right: 1px solid var(--border);
    overflow: hidden;
    transition: min-width 200ms ease, max-width 200ms ease;
    display: flex;
    flex-direction: column;
    gap: var(--g1);
}

#sidebar.collapsed {
    min-width: var(--sidebar-collapsed-w);
    max-width: var(--sidebar-collapsed-w);
}

#sidebar.collapsed .collection-item-label,
#sidebar.collapsed #brandname,
#sidebar.collapsed .logo {
    display: none;
}

#sidebar.collapsed .collection-divider {
    overflow: hidden;
    max-width: var(--sidebar-collapsed-w);
    font-size: 0;
    /* hide text; keep the item for spacing */
}

/* ── Sidebar tooltip on collapsed hover ── */

#sidebar.collapsed .collection-item-link[data-tooltip],
#sidebar.collapsed .sidebar-group-toggle[data-tooltip] {
    position: relative;
}

#sidebar.collapsed .collection-item-link[data-tooltip]:hover::after,
#sidebar.collapsed .sidebar-group-toggle[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-2);
    padding: var(--p1) var(--p3);
    white-space: nowrap;
    z-index: 200;
    font-size: var(--font-small);
    font-family: var(--root-font);
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

#sidebar.collapsed .nav-count {
    display: none;
}

#sidebar.collapsed .sidebar-countpoints-wrap {
    display: none;
}

.sidebar-group.open>.sidebar-group-toggle .sidebar-group-chevron {
    transform: rotate(90deg);
}

.sidebar-group.open>.sidebar-group-items {
    display: block;
}

#sidebar.collapsed .sidebar-group-items {
    display: none !important;
}

#sidebar.collapsed .sidebar-group-chevron {
    display: none;
}

.sidebar-indicator.ok {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
    animation: blink 2.4s ease-in-out infinite;
}

.sidebar-indicator.error {
    background: var(--error);
    box-shadow: 0 0 0 3px var(--error-soft);
}

/* The topbar's search button and the Ctrl+K palette: command-palette.css. */

/* ─────────────────────── TOPBAR ───────────────────────────────── */

#topbar {
    padding: var(--p2) var(--p4);
    border-bottom: 1px solid var(--border-strong);
    background: var(--surface);
    min-height: var(--topbar-h);
    max-height: 80px;
    height: 10vh;
}

#brandlogo {
    max-height: 32px;
    width: auto;
    object-fit: contain;
}

#brandname {
    font-weight: 700;
    font-size: var(--s2, 1.2rem);
    letter-spacing: .05em;
    font-family: 'IBM Plex Sans', sans-serif;
}

#user-info {
    gap: var(--g3);
}

#user-message {
    display: flex;
    align-items: center;
    gap: var(--g2);
}

/* TOOLBAR */

.toolbar {
    padding: var(--p2);
    background: var(--surface);
    gap: var(--g2);
}

/* SEARCHBAR */

.data-search-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent);
    padding: var(--p2) var(--p4);
    border: 1px solid var(--border-strong);
    border-top-left-radius: var(--rad-2);
    border-bottom-left-radius: var(--rad-2);
}

input.data-search-input {
    border-left: none;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* FOOTER */

.footer {
    display: flex;
    gap: var(--g4);
    padding: var(--p4);
    border-top: 1px solid var(--border);
}

.footer-item {
    gap: var(--g4);
}

.footer-item .column {
    gap: var(--g1) var(--g2);
}

td.cell-action-link a.cell-link {
    color: inherit;
    text-decoration: none;
}

td.cell-action-link:hover a.cell-link {
    text-decoration: underline;
}

.cell-toast.visible {
    opacity: 1;
}

.checkbox-group-item {
    display: flex;
    align-items: center;
    gap: var(--p2);
    padding: var(--p1) 0;
}

.checkbox-group-item:nth-child(odd) {
    background-color: var(--surface-3);
}

/* Themed checkbox for checkbox-group items (CountPoint members, User groups)
   and the data-table row-selection checkboxes - both were plain unstyled
   browser checkboxes before. Checkmark drawn with a clip-path rather than an
   image/font glyph so it always matches --accent-fg with no extra asset. */
.checkbox-group-item input[type="checkbox"],
table.data-table input[type="checkbox"] {
    appearance: none;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin: 0;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--rad-2);
    background: var(--surface);
    cursor: pointer;
    display: inline-grid;
    place-content: center;
    transition: background 120ms ease, border-color 120ms ease;
}

.checkbox-group-item input[type="checkbox"]::after,
table.data-table input[type="checkbox"]::after {
    content: '';
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: transform 100ms ease-in-out;
    box-shadow: inset 1em 1em var(--accent-fg, #fff);
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.checkbox-group-item input[type="checkbox"]:checked,
table.data-table input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-group-item input[type="checkbox"]:checked::after,
table.data-table input[type="checkbox"]:checked::after {
    transform: scale(1);
}

.checkbox-group-item input[type="checkbox"]:hover,
table.data-table input[type="checkbox"]:hover {
    border-color: var(--accent);
}

.checkbox-group-item input[type="checkbox"]:focus-visible,
table.data-table input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Segmented 2-way toggle (Style: Line/Bar, Scale: Linear/Logarithmic) -
   replaces a <select> for genuinely binary chart-control choices. Styled as
   a rounded slider track: a pill-shaped groove holding two pill buttons,
   the active one filled solid. Buttons keep their own content-based width
   (rather than a shared sliding thumb) so a long label like
   "Logarithmisch" never gets squeezed into a fixed 50% share and clipped.
   The underlying form value lives in a same-named hidden text input next
   to it (see chart-toggle.js); this is purely the visual control. */
.toggle-group {
    display: inline-flex;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
    width: fit-content;
}

.toggle-group button {
    appearance: none;
    background: transparent;
    color: var(--text-2);
    border: none;
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.toggle-group button:hover:not([data-active="true"]) {
    color: var(--text);
    background: var(--surface-2);
}

.toggle-group button[data-active="true"] {
    background: var(--accent);
    color: var(--accent-fg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.toggle-group button:disabled {
    cursor: not-allowed;
}

/* Checkbox-driven chart controls (Serien, Gestapelt, Kapazität) styled as
   chips so they read as the same family of control as the .toggle-group
   segmented buttons next to them, rather than bare checkboxes. */
.chip-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12.5px;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.checkbox-group-filter {
    width: 100%;
}

.checkbox-group-heading {
    position: sticky;
    top: 0;
    padding: var(--p1) 0;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-3);
    background: var(--surface);
}


/* ----------------------
        SCROLLBAR
----------------------- */

.table-wrapper {
    overflow-x: auto;
}

.table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: var(--rad-2);
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: var(--rad-2);
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}


/* ----------------------
        MESSAGES
----------------------- */

#error-message {
    font-family: 'Lato';
    font-size: var(--font-size-1);
    text-align: center;
}

#error-message.success,
#error-message.error,
#error-message.warning,
#error-message.unknown,
#error-message.info,
#error-message.accent {
    margin: var(--m2) 0 var(--m4) 0;
    transition: all .2s;
}


/* ----------------------
        UTILITIES
----------------------- */

/* !important because this rule is only specificity 0,1,0 and therefore loses
   to *any* later same-specificity `display:` declaration - `.data-table tr`,
   `.column`, `.derivation-none`, and so on. That has now silently broken
   visibility toggling three separate times in this file (the type-filter
   rows, the Playground container, and the editor's three derivation states),
   each time presenting as "the JS isn't running" rather than as a CSS
   problem. Retiring the bug class outright is cheaper than debugging a
   fourth instance.

   Verified safe before adding: every [hidden] rule in the codebase
   (.dialog-error-message, .tooltip-popup img, #command-palette,
   #theming-panel-overlay, .settings-overlay, .variable-formula-test-result)
   sets display:none too - i.e. they are all workarounds for this same
   problem, and none of them tries to keep a hidden element visible. They're
   now redundant and can be dropped opportunistically. */
.hidden,
[hidden] {
    display: none !important;
}

/* ----------------------
    FORM ROW (non-dialog)
----------------------- */

/* Same layout/label language as `dialog .form-row` (see above), extended to
   plain in-page forms like the template editor - dialog's own rule has
   higher specificity so this is purely additive, no change to any dialog. */
.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--g1);
    padding: var(--p2) 0;
}

.form-row label {
    font-size: var(--font-small);
    font-weight: 600;
    color: var(--text);
    letter-spacing: .03rem;
}

/* Collapsed-by-default OoBM Port/VLAN/Maske fields on switchsetup.php - real
   device configs (Aurora_initial/infos/conf/*.conf) show these are fixed
   convention almost everywhere, so they're pre-filled and rarely need
   opening at all. Same treatment as .template-editor-more summary. */
.switchsetup-oobm-advanced summary {
    cursor: pointer;
    color: var(--text-2);
    font-size: .9em;
    font-weight: 500;
}

.switchsetup-oobm-advanced[open] summary {
    margin-bottom: var(--g2);
}

/* Inline sub-field note (e.g. ip-addresses.js's live network-match hint,
   switch-name-hints.js's building/role suggestion) - muted by default,
   switches to accent + a check icon once .detected is added. */
.field-hint {
    display: flex;
    align-items: center;
    gap: var(--g1);
    font-size: var(--font-xs);
    color: var(--text-3);
}

.field-hint.detected {
    color: var(--accent-text);
}

.field-hint.detected::before {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
}

/* The "Gebäude anlegen" offer shown when a typed name's ensemble
   letter+number don't match an existing building yet - the Switches create
   dialog's own inline hint style (switch-name-hints.js,
   .switch-name-suggest-toggle labels) and Switchsetup's own three toggles
   (plain .form-rows, laid out in a row instead of that pair's stacked
   column) both use this same box for the surrounding highlight/grouping. */
.switch-name-suggest {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--g2);
    padding: var(--p3);
    margin-bottom: var(--g2);
    background: var(--surface-2);
    border-radius: var(--rad-3);
}

.switch-name-suggest-toggle {
    display: flex;
    align-items: center;
    gap: var(--g1);
    font-size: var(--font-small);
    color: var(--text-2);
    cursor: pointer;
}

/* Same sliding-switch look every dialog's own `dialog .form-row
   input[type="checkbox"]` rule (above) already gives a checkbox - repeated
   here because that selector is scoped to <dialog>, and this box sits on a
   plain page. Track color bumped a step from that rule's (--surface-2,
   which is this box's own background - an unchecked switch would
   disappear into it) and a border added for the same reason. */
.switch-name-suggest input[type="checkbox"] {
    appearance: none;
    position: relative;
    width: 2.5rem;
    height: 1.3rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--rad-full);
    cursor: pointer;
    transition: background .2s ease;
}

.switch-name-suggest input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: calc(1.3rem - 4px);
    height: calc(1.3rem - 4px);
    background: var(--surface);
    border-radius: 50%;
    box-shadow: 0 1px 3px var(--opaque-200);
    transition: transform .2s ease;
}

.switch-name-suggest input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.switch-name-suggest input[type="checkbox"]:checked::after {
    transform: translateX(1.2rem);
}

.switch-name-suggest input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: .5;
}

/* Switchsetup's 2nd/3rd toggles (VLANs/Netzwerke) start disabled until the
   1st (Gebäude anlegen) is checked - dims the whole label, not just the
   switch, so "these two don't apply yet" reads at a glance. */
.switch-name-suggest .form-row:has(input:disabled) label {
    color: var(--text-3);
    cursor: not-allowed;
}

/* ----------------------
    MODEL IMAGE TOOLTIP
----------------------- */

/* Ported from the original Aurora's switches.php/switch.php hover
   tooltip, re-themed onto Aurora's surface/shadow tokens instead of the
   original's hardcoded rgba(0,0,0,.7) box (theme-aware in both directions,
   not just a dark-mode-only floating panel). */
.tooltip {
    position: relative;
    display: inline-block;
}

/*
 * .tooltip-popup starts out nested inside .tooltip (Views\ModelImage::
 * tooltip()'s markup) but model-tooltip.js moves it to a direct child of
 * <body> on first hover - position: fixed + JS-computed top/left, not a
 * plain `.tooltip:hover` CSS reveal. That's not a style preference: this
 * popup is used inside .data-table cells (Switches/Models list), and
 * main.css's `.data-table tr>td { overflow: hidden }` (needed for ellipsis
 * truncation) plus `.table-wrapper { overflow-x: auto }` (needed for
 * horizontal scroll on narrow viewports) combine, per the CSS overflow
 * spec, to force the table-wrapper's vertical overflow to clip too -
 * there's no CSS-only way for an absolutely-positioned descendant to
 * escape that and still be visible. Selector is a plain class rather than
 * `.tooltip [role="tooltip"]` for exactly that reason: it must still be
 * styled correctly after JS has relocated it out from under `.tooltip`.
 */
.tooltip-popup {
    position: fixed;
    display: none;
    flex-direction: column;
    gap: var(--g1);
    padding: var(--p2);
    background: var(--surface-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-3);
    box-shadow: var(--shadow-md);
    z-index: 50;
    width: max-content;
    max-width: clamp(180px, 40vw, 320px);
}

.tooltip-popup.visible {
    display: flex;
}

.tooltip-popup img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--rad-2);
}

.tooltip-popup img[hidden] {
    display: none;
}

.tooltip-caption {
    font-size: var(--font-small);
    color: var(--text-2);
    text-align: center;
}

/* Live preview in the Models create/update dialog (models.js) */
.model-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--rad-2);
    border: 1px solid var(--border);
}

/* Inline thumbnail (ModelImage::thumbnail()) - Models list column, small
   fixed max-height so a wide device photo never blows out row height. */
.model-thumb {
    max-height: 2.5rem;
    max-width: 100%;
    width: auto;
    border-radius: var(--rad-1);
}

/* Same helper, bigger variant for the model detail page's header card. */
/* One upload slot per view (Front/Rückansicht) on /models/{id}. The <input
   type="file"> is [hidden] and driven by the adjacent .action-button, so the
   picker is opened by a control that looks like every other button in the
   app instead of the browser's default "Durchsuchen" widget. */
.model-image-slot {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--g1);
}

.model-image-actions {
    display: flex;
    gap: var(--g2);
    flex-wrap: wrap;
}

.model-thumb-lg {
    max-height: 12rem;
    max-width: 100%;
    width: auto;
    border-radius: var(--rad-2);
    border: 1px solid var(--border);
}

/* ----------------------------------------
    SHARED - ENTITY DETAIL PAGES (InfoCard::fieldGrid() etc.)
    Originally built for switch-detail.php, now reused by every
    entity detail page (buildings, zones, ip-addresses, ...).
----------------------------------------- */

/* InfoCard::fieldGrid() emits .info-grid > .info-field > .label + .info-field-value.
   Both now *are* the shared stat primitive - see the STAT / FIELD block - so
   the two stop drifting. Kept as separate selectors rather than renaming the
   markup, because 16 templates and several JS selectors reference these names. */
/* One panel of facts divided by hairlines, not a scatter of separate tiles:
   twelve individually-bordered boxes with gaps between them draw twelve
   outlines competing for attention, when the thing worth seeing is the values.

   The dividers are a box-shadow ring on each field rather than .action-groups'
   1px-gap-shows-the-container trick. That trick needs every cell filled, and a
   fact grid's last row is nearly always short - the empty cells rendered as a
   slab of divider colour. `grid-column: auto / -1` on the last child does not
   rescue it either: a definite end line stops auto-placement from spanning
   backwards, so the field lands in the final column and widens the hole.

   A shadow ring costs no layout, and adjacent rings coincide exactly, so
   neighbours share one hairline and a short row simply ends. */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    /* Clips the outermost ring, which would otherwise double the border. */
    overflow: hidden;
}

.info-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--p2) var(--p3);
    box-shadow: 0 0 0 1px var(--border);
    background: var(--glass);
    min-width: 0;
}

/* The global .label is uppercase, letter-spaced, semibold and nowrap - a
   form-label look. Inside a field tile it has to match .stat-label instead,
   so those four are reset here rather than the global rule being weakened
   (it is still what form rows want). */
.info-field > .label {
    font-size: var(--font-size-1);
    font-weight: 400;
    color: var(--text-2);
    text-transform: none;
    letter-spacing: normal;
    text-wrap: wrap;
    margin-bottom: 0;
    overflow-wrap: anywhere;
}

.entity-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--g3);
}

.entity-card {
    display: flex;
    flex-direction: column;
    gap: var(--g1);
    padding: var(--p3);
    border-radius: var(--rad-2);
    border: 1px solid var(--border);
    background: var(--surface-2);
    text-decoration: none;
    color: inherit;
}

.entity-card:hover {
    border-color: var(--accent);
}

.entity-card-title {
    font-weight: 600;
}

/* Home dashboard's fleet-count tiles - same .entity-card shell, just a big
   number instead of a subtitle. */
.dashboard-tile-value {
    font-size: var(--font-size-6);
    font-weight: 700;
    color: var(--accent-text);
}

/* ----------------------
    SWITCH DETAIL PAGE
----------------------- */

/* Side-by-side row for the narrow, non-table cards (Verbindung,
   Konfiguration) that otherwise each span the full page width for a few
   buttons' worth of content. auto-fit + a minmax floor rather than a media
   query, matching .reference-groups: the cards drop to one column on their
   own once they can't hold 22rem, so this stays correct inside the sidebar's
   varying content width without a second breakpoint to keep in sync.

   align-items: start rather than the default stretch. Equal-height cards
   looked tidier in the abstract, but measured against real content
   "Verbindung" filled 78px of a 315px card - three quarters of it empty
   frame - while "Konfiguration" next to it used 260px. A card that is
   mostly blank reads as something failing to load; a shorter card with
   background visible beneath it does not.

   min-width: 0 is not optional: without it a long <pre>/<code> or a wide
   select inside one card blows its track out past 1fr instead of staying
   within it, since grid items default to min-width: auto. */
/* --------------------------------------------------------------------------
   ACTION GROUPS - two (or more) related groups of controls inside ONE card.

   Used where a pair of panels would otherwise be two cards of different
   natural heights: that ragged pair is what makes whatever sits beneath it
   read as floating rather than anchored. One card with a divider is both
   steadier and more truthful when the groups are facets of one thing.

   The divider is the grid's own 1px gap letting the container background
   through, rather than a border on the second child. That way it runs
   vertically when the groups sit side by side and horizontally when they
   wrap - no media query, and never a border on the wrong edge.
   -------------------------------------------------------------------------- */
.action-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
    /* stretch (the default) is what equalises the groups - the divider then
       runs the full height of the taller one. */
    gap: 1px;
    background: var(--border);
    border-radius: inherit;
    overflow: hidden;
}

/* The container's background is what shows through the 1px gaps as the
   divider, so an empty trailing cell would render as a bare divider-coloured
   block. Letting the last group span whatever columns remain fills it, at any
   column count, without knowing the count. */
.action-groups > .action-group:last-child {
    grid-column: auto / -1;
}

.action-group {
    display: flex;
    flex-direction: column;
    gap: var(--g3);
    padding: var(--p4);
    background: var(--surface);
    min-width: 0;
}

.action-group-title {
    display: flex;
    align-items: center;
    gap: var(--g2);
    margin: 0;
    font-size: var(--font-size-1);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06rem;
    color: var(--text-2);
}

.action-group-title i {
    color: var(--accent);
}

/* Destructive actions sort last within a toolbar, so the dangerous one is
   never where the eye lands first. */
.toolbar-row .destructive {
    order: 1;
}

/* The groups close the detail card, so they carry its bottom rounding and
   need a divider from the fields above them. */
.card > .action-groups {
    border-top: 1px solid var(--border);
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

/* --------------------------------------------------------------------------
   PAGE HEAD - identity on the left, actions on the right.

   The identity block is title + a status line directly beneath it. Connection
   state is an *attribute* of a switch, not an operation on it, so it belongs
   next to the name rather than inside a panel of buttons - which is where it
   used to sit, giving a status line the same weight as the actions around it.

   Actions are right-aligned here, which the toolbar row deliberately is not
   (a right-aligned row reflows from the left, so every button shifts whenever
   a conditional one appears). That objection does not apply once the
   conditional ones live in the overflow menu: what is left is a fixed set that
   cannot change width between renders. When the head is too narrow, wrapping
   drops the cluster onto its own line, where space-between leaves it at the
   start - so it goes back to being left-aligned exactly when it would matter.
   -------------------------------------------------------------------------- */
.page-head {
    display: flex;
    /* Centred by default: on the 15 detail pages the identity block is a single
       line, and top-aligning a 33px button against it leaves the buttons
       visibly high. Only a head that carries a status line under the title is
       two lines tall, and there the actions belong level with the title rather
       than floating between the two. */
    align-items: center;
    justify-content: space-between;
    gap: var(--g3);
    flex-wrap: wrap;
}

.page-head:has(.page-head-status) {
    align-items: flex-start;
}

.page-head-main {
    display: flex;
    flex-direction: column;
    gap: var(--g1);
    min-width: 0;
}

.page-head-status {
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-size-2);
    color: var(--text-2);
}

/* .card-header>h4 paints every card title in --accent-text, which is right for
   a card *labelling* a section and wrong for the one word identifying the
   record this page is about: it reads as a link to somewhere else. Applies to
   all 16 detail pages, not just the ones inside a .page-head. */
.page-title-row h4,
.page-title {
    color: var(--text);
}

/* One step up the scale from a card header (h4 is --font-size-3): outside the
   card it has to hold the top of the page on its own rather than label a
   section within it. */
.page-title,
.page-title-row h4 {
    font-size: var(--font-size-4);
}

.page-head-actions {
    display: flex;
    align-items: center;
    gap: var(--g2);
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   ACTION MENU (Views/ActionMenu.php + action-menu.js)

   A <details> disclosure, positioned against its own trigger. Not the native
   `popover` attribute: that would give light-dismiss for free but places the
   panel in the top layer, out of reach of this `position: relative` parent,
   and anchoring it back is CSS anchor positioning - Chrome-only for now.
   -------------------------------------------------------------------------- */
.action-menu {
    position: relative;
}

/* Both are needed to suppress the disclosure triangle: Safari and older
   Chrome use the ::-webkit- pseudo-element, everything else `display`. */
.action-menu > summary {
    cursor: pointer;
    list-style: none;
}

.action-menu > summary::-webkit-details-marker {
    display: none;
}

.action-menu-panel {
    position: absolute;
    top: calc(100% + var(--p1));
    right: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    min-width: 15rem;
    padding: var(--p1);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.action-menu-item {
    padding: var(--p2);
    border: 0;
    border-radius: var(--rad-1);
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

/* .action-menu-panel is in the selector purely for specificity. A menu item is
   a <button>, so the global `button:not(:disabled):not(.destructive):hover`
   applies to it - and that rule is (0,3,1) against this one's (0,3,0), so it
   won. It paints --button-bg, which is --accent-text: oklch L=0.28 in light
   mode, i.e. near-black navy across a menu row. The prefix takes this to
   (0,4,0) so a menu row highlights the way a list row should. */
.action-menu-panel .action-menu-item:hover:not(:disabled),
.action-menu-panel .action-menu-item:focus-visible {
    background: var(--surface-3);
    color: var(--text);
}

.action-menu-panel .action-menu-item.destructive:hover:not(:disabled) {
    color: var(--error);
}

.action-menu-item.destructive {
    color: var(--error);
}

/* A disabled item stays listed rather than disappearing: "Geräte-Infos
   importieren" missing entirely reads as a feature that does not exist, while
   a greyed one with a title explaining why reads as a prerequisite. */
.action-menu-item:disabled {
    color: var(--text-3);
    cursor: not-allowed;
}

/* Title plus the badges that identify the record it names - renamed from
   .switch-detail-title, which was a class named after one page and used by
   sixteen. */
.page-title-row {
    display: flex;
    align-items: center;
    gap: var(--g2);
    flex-wrap: wrap;
}

.page-title-row h4 {
    display: flex;
    align-items: center;
    gap: var(--g2);
}

.info-field-value {
    font-size: var(--font-size-2);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.connectivity-row {
    display: flex;
    align-items: center;
    gap: var(--g2);
    flex-wrap: wrap;
}

.connectivity-dot {
    display: inline-block;
    width: .6rem;
    height: .6rem;
    border-radius: 50%;
    background: var(--text-3);
    flex-shrink: 0;
}

.connectivity-dot.up {
    background: var(--success);
}

.connectivity-dot.down {
    background: var(--error);
}

/* Reachable but not authenticated. Ranked below .up rather than coloured
   differently: both are good news, and .up (key login works) is the state
   every device action actually needs, so it keeps the full-strength green and
   this one is visibly the weaker of the two. A separate hue would read as a
   separate kind of thing instead of a lesser degree of the same one. */
.connectivity-dot.reachable {
    background: color-mix(in srgb, var(--success) 55%, var(--surface-3));
}

/* The table-cell form of a status line. .connectivity-row wraps on purpose -
   it lives in a page head where a long status sentence should reflow - but in
   a table column that put the dot on its own line above the word it labels. */
.status-cell {
    display: flex;
    align-items: center;
    gap: var(--g2);
    white-space: nowrap;
}

/* "Kein Zugang" - no management IP or no SSH credential, so there is nothing
   to probe. Amber rather than red: the switch is not reported broken, Aurora
   simply has no way to ask, and that is a gap in the record an operator fixes
   here rather than on the device. */
.connectivity-dot.warn {
    background: var(--warn);
}

/* The field a deep link sent you here to fix (entity-edit.js). Marks the whole
   form row, label included: an outline on the control alone reads as ordinary
   focus and says nothing about why you were sent. Fades rather than pulses -
   it has to survive long enough to be noticed and then stop competing with
   the field it is pointing at. */
.form-row.is-called-out {
    border-radius: var(--rad-2);
    box-shadow: 0 0 0 2px var(--accent);
    animation: called-out-fade 2.5s ease-out forwards;
}

@keyframes called-out-fade {
    0%, 60% { box-shadow: 0 0 0 2px var(--accent); }
    100%    { box-shadow: 0 0 0 2px transparent; }
}

/* Respect a reduced-motion preference: the callout still lands, it just
   arrives already at rest instead of animating. */
@media (prefers-reduced-motion: reduce) {
    .form-row.is-called-out {
        animation: none;
    }
}

/* A page head standing on its own rather than inside a card - the title and
   the headline numbers state what the page is about before the card starts,
   instead of competing with the table's own chrome inside its header. */
/* The page title sits outside the card now, so it needs no inset of its own -
   <main class="p-2"> already provides the page margin. */
.page-head-bare {
    padding: 0;
}

/* Vertical rhythm only: the stats align flush with the card below them, so
   any horizontal margin here would step them in from the card edge. */
.page-head-stats {
    margin: var(--p2) 0;
}

/* PageCard::note() - the one explanatory line a page gets, between the stats
   and the card. Reads as an aside to the title, not as content of the card. */
/* Two lines are reserved whether or not the second is used. This text sits
   between the title and the card, and its wrap changes with the column width -
   which changes while you work, since collapsing the sidebar widens every page
   by ~196px. Without the reserve the card below stepped up or down a line on
   every toggle. Two lines is also the cap the writing should respect: past
   that it is documentation, not a page description. */
.page-note {
    margin: 0 0 var(--p2);
    min-height: 2.8em;
    max-width: 90ch;
    color: var(--text-2);
    font-size: var(--font-size-1);
}

/* Views/FilterChips.php - a counting filter bar between the toolbar and the
   table, reading as a filter rather than as another row of page actions. The
   active one is filled the way a pressed segmented item is. */
.filter-chips {
    padding: var(--p2) var(--p2) 0;
}

/* The chip-bar switch, injected next to the search box by table-filter.js on
   pages that have chips. Square, because it is a state toggle rather than a
   labelled command like the toolbar buttons beside it. */
.quickfilter-toggle {
    padding-left: var(--p2);
    padding-right: var(--p2);
}

/* A search box holding a regular expression that does not compile. Marked,
   not emptied: every row stays visible, so this says "your pattern is not
   finished" rather than "nothing matched". */
.data-search-input.is-invalid {
    border-color: var(--warn);
}

.filter-chips .action-button {
    display: inline-flex;
    align-items: center;
    gap: var(--g2);
}

/* The count is context for the label, not a peer of it: the global .badge is
   filled, bold and --font-small, which inside a chip made the number compete
   with the word it counts. Smaller, lighter and unfilled leaves the label as
   the thing you read first and the number as the detail you check second. */
.filter-chips .badge {
    padding: 0 var(--p1);
    background: none;
    border-color: transparent;
    /* Full --text, not --text-2. Secondary here is carried by size and by
       dropping the fill, which is enough - stacking a dimmed colour on top of
       10.5px took it past "quieter" and into "unreadable". */
    color: inherit;
    font-size: var(--font-small);
    font-weight: 600;
}

/* A zero-count chip is still information - it says none of these exist - so it
   stays legible rather than fading to --text-disabled, which the global
   button:disabled rule would otherwise give it. --text-3 reads as inactive
   while still clearing contrast. */
.filter-chips .action-button:disabled {
    color: var(--text-3);
}

/* The chips sit directly above the table, so without this the first column
   header butts against them and the two read as one block. Table::render()
   wraps its <table> in .table-wrapper, so that is the sibling to space off -
   not .data-table, which is a child of it. */
.filter-chips + .table-wrapper {
    margin-top: var(--p3);
}

/* The "Config Template" / "Snippet" caption beside each apply row. A fixed
   floor rather than natural width, so the two rows' selects line up with each
   other instead of stepping in by the difference between the two words. */
.config-apply-label {
    display: flex;
    flex-direction: column;
    /* A fixed basis, not min-width: the two captions' hint lines are different
       lengths, so sizing to content stepped the second row's <select> in by
       the difference and the pair never lined up. */
    flex: 0 0 15rem;
}

/* ==========================================================================
   EXPORT DIALOG (Views/ExportDialog.php + export-dialog.js)
   Shared by the snippet editor and the config-template editor.
   ========================================================================== */

.export-dialog .card {
    min-width: min(92vw, 34rem);
}

.export-target-controls {
    /* "row justify-between center" is the sitewide idiom and is safe because
       atomics.css declares .justify-between after .center - see the comment
       there. Set here as its own class so this stays true if the markup is
       ever simplified. */
    gap: var(--g2);
}

.export-target-search {
    flex: 1;
    min-width: 0;
}

.export-select-all {
    white-space: nowrap;
    cursor: pointer;
}

.export-target-list {
    max-height: 18rem;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    padding: var(--p2);
}

.export-target-group {
    margin: var(--g2) 0 var(--g1);
    font-size: var(--font-small);
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.export-target-group:first-child {
    margin-top: 0;
}

.export-target {
    display: flex;
    align-items: center;
    gap: var(--g2);
    padding: var(--p1) var(--p2);
    border-radius: var(--rad-1);
    cursor: pointer;
}

.export-target:hover {
    background: var(--surface-2);
}

.export-target.is-disabled {
    /* A switch with no building cannot derive anything. Listed but not
       selectable, and labelled - the same call SimulationTarget makes. */
    opacity: 0.55;
    cursor: not-allowed;
}

.export-target-label {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.export-target-meta {
    font-size: var(--font-small);
    color: var(--text-3);
    white-space: nowrap;
}

.export-report {
    max-height: 12rem;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    padding-top: var(--p2);
}

.export-report-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--g2);
    padding: 2px 0;
    font-size: var(--font-small);
}

.export-report-label {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.export-report-note {
    text-align: right;
    overflow-wrap: anywhere;
}

/* Colour comes from the global .warning/.error/.muted utilities (main.css's
   STATUS block, which map to --warn/--error) - deliberately not redefined
   here. An earlier draft invented --warning-strong, which does not exist:
   the token in this design system is --warn. */

.export-count {
    margin-right: auto;
}

/* ==========================================================================
   STYLEGUIDE (/ui) - section headings only; everything else on that page is
   a real primitive rendered as-is, which is the point of it.
   ========================================================================== */

.ui-section-title {
    margin: 0;
    font-size: var(--font-size-1);
    font-weight: 600;
    color: var(--text-2);
}

.ui-section-note {
    margin: 0 0 var(--g1);
}

/* The one place this page overrides a real primitive, and only its outer box.
   The command palette is a fixed, viewport-centred overlay, so .cmdk sizes
   itself in vw and caps its height at 60vh. Rendered inline here it has to be
   parent-relative instead, and it has to show its full contents rather than
   scroll - the states below are the point of putting it on this page. Nothing
   inside the panel is touched, so a change to .cmdk-item, .cmdk-group-label or
   .cmdk-empty still shows up here exactly as it will in the real palette. */
.ui-cmdk {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: var(--g3);
    align-items: start;
}

.ui-cmdk > .cmdk {
    width: 100%;
    max-height: none;
    /* Grid items default to min-width: auto, so a long subtitle would push the
       track past 1fr instead of ellipsizing - the §7.5 trap this page exists
       to catch. */
    min-width: 0;
}

/* ==========================================================================
   STAT / FIELD  - the shared "labelled value in a bordered tile" primitive
   --------------------------------------------------------------------------
   One look for two things that were drifting apart: the fleet page's summary
   tiles and InfoCard::fieldGrid()'s label/value pairs (16 templates). They are
   the same object - a short label above a value - so they share a class and a
   modifier for the accent stripe rather than each page inventing its own.

   Modifiers follow the existing is-* convention (is-disabled, is-active).
   ========================================================================== */

.stat-grid {
    display: grid;
    /* --root-font-size is 14px, so 9rem is 126px - six tiles fit a wide card
       and wrap without a media query. */
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: var(--g2);
}

/* Denser variant for detail pages, where fields are many and short. */
.stat-grid.is-compact {
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}

/* Label above value, and tight. These sit in a row directly under the page
   title stating what the page is about, so they are read as a strip, not
   studied one at a time: the label comes first because it says which number
   this is, and the tile carries no internal gap so the pair reads as one
   object rather than two stacked lines. */
.stat {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* Values sit on the bottom edge, so a two-line label on one tile does not
       drop its number below the numbers either side of it. The strip is read
       across, and that only works if the figures line up. */
    justify-content: space-between;
    padding: var(--p1) var(--p2);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    background: var(--surface-2);
    /* Grid items default to min-width:auto, so a long value would otherwise
       push its track past 1fr. */
    min-width: 0;
}

/* State colours the whole tile - border, a tint of background, and the value -
   rather than a 3px stripe down one edge. A stripe is the weakest place on a
   card to put its status: at 3px, on the side furthest from the number it
   describes, it reads as decoration. This is the .entity-card treatment the
   dashboard tiles already use, which is the one people actually notice.

   --status is a local custom property so the three variants declare one token
   each and the shared rules below never repeat a colour. Same pattern the
   table's own status cells already use. */
.stat.is-good { --status: var(--success); }
.stat.is-warn { --status: var(--warn); }
.stat.is-bad  { --status: var(--error); }

.stat.is-good,
.stat.is-warn,
.stat.is-bad {
    border-color: var(--status);
    /* A tint, not the colour itself: these sit several to a row, and three
       saturated tiles side by side stop distinguishing anything. */
    background: color-mix(in srgb, var(--status) 12%, var(--surface-2));
}

.stat.is-good > .stat-value,
.stat.is-warn > .stat-value,
.stat.is-bad > .stat-value {
    color: var(--status);
}

/* Ordered by CSS, not by markup order, so every existing template keeps
   emitting value-then-label and no call site has to be touched. */
.stat-value {
    order: 2;
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

/* Readable, not whispered: this is the name of the thing next to it, so it
   keeps the body font size and only steps down in colour. */
.stat-label {
    order: 1;
    font-size: var(--font-size-1);
    color: var(--text-2);
    overflow-wrap: anywhere;
}

/* A field is a stat whose value is prose rather than a number, so it drops
   the display-size value and keeps everything else. */
.stat.is-field .stat-value {
    font-size: var(--font-size-2);
    font-weight: 400;
    line-height: 1.4;
}

/* ==========================================================================
   FIRMWARE FLEET (firmware-fleet.php)
   ========================================================================== */

/* The switch-name row belongs to the row above it, so it carries no top
   border and the pair reads as one block. */
.fleet-table .fleet-switches td {
    padding-top: 0;
    border-top: 0;
}

.fleet-switch {
    display: inline-block;
    margin: 0 var(--g2) 2px 0;
}

.fleet-reason {
    display: block;
}

/* Version and platform are one identity in one cell: the version leads, the
   platform follows a step down. Two columns made the eye join them. */
.fleet-version {
    display: block;
}

.fleet-platform {
    display: block;
    font-size: var(--font-xs);
    color: var(--text-2);
}

/* Lowest-priority column, hidden first when the table has to narrow - the
   staleness of a reading matters less than what the reading says. */
@media (max-width: 60rem) {
    .fleet-col-checked {
        display: none;
    }
}

/* The reason IS the call to action, so it has to look clickable. .cell-link
   is only styled inside td.cell-action-link, so an anchor here inherited
   nothing and read as the same dead text it replaced - which is the exact
   failure this change exists to fix. */
a.fleet-reason {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

a.fleet-reason:hover {
    color: var(--accent-strong);
}

.fleet-row-unmatched td:first-child { box-shadow: inset 3px 0 0 var(--error); }
.fleet-row-missing td:first-child   { box-shadow: inset 3px 0 0 var(--warn); }

/* ==========================================================================
   CONFIG DIFF (switch-config-diff.php)
   ========================================================================== */

.diff-view {
    /* Both axes scroll inside this box. Config lines run past the column
       width and the page body must never scroll sideways. */
    max-height: 70vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    min-width: 0;
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--monospace-font);
    font-size: var(--font-small);
    line-height: 1.45;
}

.diff-table td {
    padding: 0 var(--p2);
    vertical-align: top;
    white-space: pre;
}

/* The two line-number gutters. `user-select: none` so copying a diff yields
   the config text and not a column of numbers interleaved with it. */
.diff-lineno {
    width: 1%;
    text-align: right;
    color: var(--text-3);
    user-select: none;
    border-right: 1px solid var(--border);
    background: var(--surface-2);
    position: sticky;
    left: 0;
}

.diff-line {
    width: 100%;
}

.diff-marker {
    display: inline-block;
    width: 1.2em;
    user-select: none;
    font-weight: 600;
}

/* Tinted with the status colours already in the palette rather than new ones.
   The marker column means the rows stay distinguishable without relying on
   colour alone. */
.diff-add    { background: var(--success-soft); }
.diff-add .diff-marker { color: var(--success-strong); }
.diff-remove { background: var(--error-soft); }
.diff-remove .diff-marker { color: var(--error-strong); }

/* The "N unveränderte Zeilen" marker. Not italic: it inherits .diff-table's
   --monospace-font, and Source Code Pro has no italic face here, so this was
   a synthesised oblique - same issue as .tok-comment, see its comment. It is
   prose inside a code table, so it steps down in size and colour instead. */
.diff-gap td {
    text-align: center;
    color: var(--text-3);
    background: var(--surface-2);
    font-size: var(--font-small);
    padding: var(--p1) var(--p2);
}

.diff-picker {
    width: 100%;
    min-width: 0;
}

.diff-controls {
    flex-wrap: wrap;
}

.diff-summary {
    flex-wrap: wrap;
}

/* Full-page view of one stored config (switch-config-detail.php).
   Sibling of .config-preview-pre below, but sized for a page rather than a
   dialog, and deliberately `white-space: pre`: a device config is
   column-significant, so wrapping long lines makes it harder to read, not
   easier. It therefore has to scroll on BOTH axes inside its own box - the
   page body must never scroll sideways. */
.config-view {
    max-height: 70vh;
    overflow: auto;
    white-space: pre;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    padding: var(--p3);
    margin: 0;
    font-family: var(--monospace-font);
    font-size: var(--font-small);
    line-height: 1.5;
    /* Grid/flex children default to min-width:auto, so without this a long
       config line widens the card instead of scrolling inside it. */
    min-width: 0;
}

/* The export bar above the selectable table. It uses the sitewide
   "row justify-between center" idiom, which is safe here only because
   atomics.css declares .justify-between *after* .center for exactly this
   case - see the comment there before reordering either. */
.config-export-bar {
    border-bottom: 1px solid var(--border);
}

.config-preview-pre {
    max-width: min(70vw, 640px);
    max-height: 50vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    padding: var(--p3);
    font-family: var(--monospace-font);
    font-size: var(--font-small);
}

/* Same tok-derived/tok-unmapped color language as the template editor's own
   CHGn_XXX highlighting (main.css's TEMPLATE EDITOR section) - resolved
   (derived) tokens in success green, anything left unsubstituted for this
   switch's building in error red, since that's a real "this literal
   placeholder is about to be written to the switch" warning. */
.config-preview-pre mark {
    background: none;
    padding: 0;
    font: inherit;
}

.config-preview-pre mark.tok-derived {
    color: var(--success-strong);
    font-weight: 600;
}

.config-preview-pre mark.tok-unmapped {
    color: var(--error-strong);
    font-weight: 600;
}

/* ----------------------
    SNIPPET EDITOR
----------------------- */

/* The snippet editor now uses the template editor's textarea + highlight
   overlay pair (.template-content-highlight-wrap and friends, below) so
   CHGn_XXX tokens are colored the same way in both.

   Snippets used to get a flat 22rem box regardless of window size - fine on
   a laptop, a lot of dead space below a short snippet on a large monitor,
   and the opposite problem (constant scrolling inside a tiny box) on a long
   one. Viewport-relative instead: fills whatever room is left below the
   name/description fields and the tab toolbar down to the page footer,
   with 22rem kept only as the absolute floor for a very short viewport.
   resize:vertical (inherited from the base rule below) still lets it be
   dragged smaller/larger by hand on top of this.

   Qualified with the wrap's own class rather than left bare: this block sits
   *above* the TEMPLATE EDITOR section, so at equal specificity the 42rem rule
   would win on source order. */
.template-content-highlight-wrap.editor-content-compact {
    height: calc(100vh - 24rem);
    min-height: 22rem;
}

/* Tabs left, target right (see the toolbar comment in template-editor.php).
   The cap keeps a long "SW-NAME · A1" option from pushing the tabs around;
   the select truncates with an ellipsis instead. */
.simulation-target select {
    max-width: 20rem;
}

/* ----------------------
    TEMPLATE EDITOR
----------------------- */

/* Shared by the config-template editor and the snippet editor (both mount
   Views/VariablePanel.php). Editor left, catalog right, matching source
   order - the tab buttons stay on the left edge of the editor column. */
.template-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22rem;
    gap: var(--g3);
    align-items: start;
}

.template-editor-main {
    gap: var(--g2);
    min-width: 0;
}

.template-editor-fields {
    gap: var(--g2);
}

/* Both of these run long enough to sit on one line or two depending on how
   wide the editor column happens to be - and that width changes *while you
   are working*: collapsing the variable catalog widens it, switching to
   Vorschau widens it again. Every time the wrap changed, the editor below
   jumped a line up or down under the cursor.
 *
 * So the taller state is reserved rather than the shorter one being fought
   for. It costs one blank line at wide widths and keeps everything below
   where the eye left it. flex-start on the hint matters as much as the
   height: centred, its single line would sit in the middle of the reserved
   box and move down as soon as a second line appeared, which is the same
   jump one level smaller. */
.template-editor-intro,
.template-editor-fields .field-hint {
    min-height: 2.8em;
    align-items: flex-start;
}

.template-editor-more summary {
    cursor: pointer;
    color: var(--text-2);
    font-size: .9em;
    font-weight: 500;
}

.template-editor-more .template-editor-fields {
    margin-top: var(--g2);
}

.template-editor-content-wrapper {
    flex: 1 1 auto;
}

/* Textarea + a same-metrics <pre> overlay underneath it, classic
   "highlight-within-textarea" technique: the real textarea keeps its text
   fully editable/selectable but transparent (caret-color stays visible),
   while template-editor.js paints CHGn_XXX token spans onto the <pre>
   behind it, kept in exact registration via matching font/padding/border
   and a synced scroll listener. The wrapper (not the textarea) owns
   resize:vertical so both layers grow/shrink together. */
.template-content-highlight-wrap {
    position: relative;
    min-height: 42rem;
    resize: vertical;
    overflow: hidden;
    border-radius: var(--rad-2);
    /* Owns the box's background now (moved off .template-content-highlight -
       see that rule's own comment) so .template-content-current-line can sit
       between this and the highlight layer and actually show through. */
    background: var(--surface-2);
}

.template-content,
.template-content-highlight {
    position: absolute;
    inset: 0;
    margin: 0;
    box-sizing: border-box;
    /* Left padding cleared for the line-number gutter, which sits in that
       reserved strip rather than actually overlapping text. */
    padding: var(--p2) var(--p2) var(--p2) 3.25rem;
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-size-1);
    line-height: 1.5;
    white-space: pre;
    overflow: auto;
}

/* Line-number gutter: a third layer in the same stack, same font metrics so
   its numbers land on the exact line they label. Plain text content (set via
   textContent, never innerHTML) - not part of the textarea's own value, so
   it can never be selected or copied along with the snippet/template text,
   unlike a real editor's gutter-in-the-same-buffer trick. user-select:none
   is belt-and-suspenders for the same reason .template-content-highlight is
   already pointer-events:none. */
.template-content-gutter {
    position: absolute;
    inset: 0;
    right: auto;
    width: 3.25rem;
    margin: 0;
    box-sizing: border-box;
    padding: var(--p2) 0.6rem var(--p2) 0;
    border: 1px solid transparent;
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-size-1);
    line-height: 1.5;
    text-align: right;
    color: var(--text-3);
    background: var(--surface-3);
    border-right: 1px solid var(--border);
    white-space: pre;
    overflow: hidden;
    pointer-events: none;
    user-select: none;
    /* Must out-rank .template-content-highlight's z-index:0 despite coming
       first in source order, or that layer's own opaque background (needed
       to distinguish it from the page behind) paints over the gutter. */
    z-index: 1;
}

/* position stays absolute (inherited from the shared rule above), not
   relative. As `relative` the textarea fell back into normal flow, where its
   height:100% resolved against the wrapper's auto height and collapsed it to
   the default two-row box (~58px) while the <pre> beside it stretched to the
   wrapper's full 42rem - so the two layers were neither the same size nor in
   registration, and both showed a scrollbar. */
.template-content {
    width: 100%;
    height: 100%;
    background: transparent;
    color: transparent;
    caret-color: var(--text);
    resize: none;
    z-index: 1;
}

/* overflow: hidden, overriding the shared rule's `auto`. The textarea on top
   is the scroll driver; template-editor.js mirrors its scrollTop/scrollLeft
   onto this layer. Leaving it `auto` gave the overlay a second scrollbar
   that sat next to the textarea's own - visible, unusable (pointer-events:
   none) and permanently one paint behind.

   background is transparent (moved to .template-content-highlight-wrap) so
   .template-content-current-line, a sibling painted earlier in source order
   at the same z-index:0, can show through the empty space around this
   layer's <mark>-colored text instead of being fully covered by an opaque
   fill here. */
.template-content-highlight {
    background: transparent;
    color: var(--text);
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

/* Thin band tracking the caret's line (tokens.js syncCurrentLine()), same
   metrics/positioning family as the gutter/highlight layers above. Must come
   before .template-content-highlight in source order (both z-index:0, later
   wins) so the highlighted text paints on top of the band, not under it.
   Starts hidden - tokens.js only shows it while the textarea has focus. */
.template-content-current-line {
    position: absolute;
    left: 0;
    right: 0;
    background: color-mix(in oklab, var(--accent) 8%, transparent);
    pointer-events: none;
    z-index: 0;
}

/* Read-only rendered-config output (switchsetup.php's generated result) -
   same monospace/border look as .template-content-highlight, but standalone:
   no transparent-text-over-highlight-layer editor trick and no absolute
   positioning, since there's no editable textarea sibling to align with
   here. Reusing bare .template-content for this (as before) left the text
   fully transparent - it's styled for that editor overlay, not standalone
   display. */
.template-content-plain {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-height: 20rem;
    margin: 0;
    padding: var(--p2);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-size-1);
    line-height: 1.5;
    white-space: pre;
    overflow: auto;
}

/* The invariant this overlay lives or dies by: NOTHING inside it may change
   font metrics. The <pre> only stays registered with the <textarea> beneath
   because both lay text out on the same grid, so any descendant that picks up
   a different family, size or line-height shifts that line's highlight off the
   real characters.

   Stated as `*` rather than element by element because it kept being missed.
   reset.css applies `font-family: var(--root-font)` - Open Sans - to a long
   Meyer-style element list that includes both `span` and `mark`. `mark` had an
   override here; `span` did not, because .tok-comment was added later as a
   <span> (deliberately - a whole `! ...` line is not an inline "mark"). The
   result was every comment line painted in a proportional font on top of
   monospace text. The container's scrollWidth/scrollHeight still matched, so
   nothing looked wrong until you put a caret in a comment.

   The token rules below are (0,2,0) against this rule's (0,1,0), so their
   font-weight still wins despite the `font` shorthand resetting it. */
.template-content-highlight * {
    font: inherit;
}

.template-content-highlight mark {
    background: none;
    padding: 0;
    color: inherit;
}

.template-content-highlight mark.tok-derived {
    color: var(--success-strong);
    font-weight: 600;
}

.template-content-highlight mark.tok-manual {
    color: var(--warn-strong);
    font-weight: 600;
}

.template-content-highlight mark.tok-unmapped {
    color: var(--error-strong);
    font-weight: 600;
}

.template-content-highlight mark.tok-unknown {
    color: var(--text-3);
    text-decoration: underline dotted;
}

/* Declarative rule table lives in tokens.js SYNTAX_RULES; these are just the
   colors for it. .tok-comment is a <span>, not a <mark> (a whole `! ...`
   line isn't really an inline "mark" semantically), everything else keeps
   the existing mark reset above.

   Deliberately NOT italic, and the reason is structural rather than taste.
   Source Code Pro ships four faces here (400/500/700/900) and every one is
   font-style: normal - there is no italic face - so `font-style: italic`
   made the browser synthesise an oblique by shearing the upright glyphs.
   That is the wrong thing to do inside a highlight-within-textarea overlay:
   the <pre> only stays registered with the <textarea> beneath it because the
   two share exact metrics, and this rule applies to the overlay alone, so a
   comment line was slanted while the real text under it stayed upright.
   (Measured drift is 0.00px in this engine, which is luck, not a guarantee -
   synthesised obliques are free to alter advance widths.)

   The dimmed colour is the comment cue and is sufficient on its own. */
.template-content-highlight .tok-comment {
    color: var(--text-3);
}

.template-content-highlight mark.tok-keyword {
    color: var(--info-strong);
    font-weight: 600;
}

.template-content-highlight mark.tok-ip {
    color: var(--network-strong);
    font-weight: 600;
}

/* Deliberately var(--accent-text), not a fixed hue - "actions/rules ->
   accent color" was the literal ask, so this follows whichever of the app's
   accent themes the user has picked, same as every other accent-colored
   element. */
.template-content-highlight mark.tok-action {
    color: var(--accent-text);
    font-weight: 600;
}

.template-editor-variables {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--rad-3);
    padding: var(--g2);
    gap: var(--g1);
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
    position: sticky;
    top: var(--g2);
}

/* Collapsed catalog: folds to a rail on the layout's right edge, handing the
   22rem back to the editor column. Driven by :has() on the panel's own
   attribute rather than a class on the layout, so variable-explorer.js keeps
   its stated property of never reaching for a host-page element.

   .preview-active is excluded deliberately: it already collapses this column
   and hides the panel outright, and letting both rules set
   grid-template-columns would leave a gap's worth of gutter beside a
   display:none panel - the exact leftover this file's preview-active comment
   was written to avoid. */
.template-editor-layout:not(.preview-active):has(.template-editor-variables[data-collapsed]) {
    grid-template-columns: minmax(0, 1fr) auto;
}

/* Padding stays at the expanded panel's --g2: the collapse button keeps the
   same inset from the panel's top and right edges, so toggling moves the
   panel without moving the control under the cursor. */
.template-editor-variables[data-collapsed] {
    justify-self: end;
    max-height: none;
    overflow: visible;
}

/* Everything except the header row goes, and the header keeps only the
   collapse button - it is the only way back out, so it must never be part of
   what gets hidden. The list stays in the DOM (display:none, not removed), so
   expanding costs no re-render. */
.template-editor-variables[data-collapsed] > :not(.variable-panel-head),
.template-editor-variables[data-collapsed] #variable-add-toggle {
    display: none;
}

.template-editor-variables[data-collapsed] .variable-panel-head {
    flex-direction: column;
    gap: var(--g1);
}

/* The button sits at the top of the rail where the panel's header used to be,
   rather than under a rotated caption. The head has exactly two children, so
   this addresses the actions wrapper without needing a class of its own. */
.template-editor-variables[data-collapsed] .variable-panel-head > .row {
    order: -1;
}

/* Reads as the panel's title, just turned on its side - same size and weight
   as the expanded header's, not shrunk into a tick label. */
.template-editor-variables[data-collapsed] .card-title {
    writing-mode: vertical-rl;
    color: var(--text-2);
    letter-spacing: .04em;
    white-space: nowrap;
}

.variable-panel-hint {
    color: var(--text-3);
    font-size: .85em;
    margin: 0 0 var(--g1);
}

.variable-form {
    flex-direction: column;
    gap: var(--g1);
    padding: var(--g2);
    margin-bottom: var(--g2);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
}

.variable-form:not([hidden]) {
    display: flex;
}

.variable-form [data-field-wrap="formula"] {
    display: flex;
    flex-direction: column;
    gap: var(--g1);
}

.variable-formula-test-result {
    padding: var(--p1) var(--p2);
    border-radius: var(--rad-2);
    background: var(--success-soft);
    border: 1px solid var(--success);
    color: var(--success-text);
    font-size: var(--font-size-1);
}

.variable-category {
    margin: var(--g2) 0 var(--g1);
    color: var(--text-3);
    font-size: .8em;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.variable-category:first-child {
    margin-top: 0;
}

.variable-item {
    display: flex;
    padding: var(--g2);
    border-radius: var(--rad-2);
    border: 1px solid transparent;
    margin-bottom: var(--g1);
    background: var(--surface-2);
}

/* Not var(--surface-4): the surface scale runs *away* from --surface, so
   --surface-4 is a step lighter than the surrounding panel in dark themes
   but a step darker in light ones - on light it drops the row from L .98 to
   L .93, reading as a gray smudge rather than a highlight. Mixing the accent
   into the row's own resting colour keeps the lightness roughly put and lets
   hue carry the state, which reads the same way in both themes. Backs the
   Template Editor's side panel; the variable editor's explorer needs its own
   higher-specificity copy for an unrelated reason (see
   #variable-index-panel .variable-item:hover). */
.variable-item:hover {
    background: color-mix(in oklab, var(--accent) 12%, var(--surface-2));
}

/* Border color reflects whether this token will actually survive config
   generation, not just "is it typed in the textarea somewhere" - an
   in-use 'unmapped' token is a live bug (it'll leak the literal token text
   into the generated config), not a reassuring green checkmark. */
.variable-item.in-use-derived {
    border-color: var(--success-strong);
}

.variable-item.in-use-manual {
    border-color: var(--warn-strong);
}

.variable-item.in-use-unmapped {
    border-color: var(--error-strong);
}

.variable-panel-search {
    margin-bottom: var(--g2);
}

.variable-editor-meta {
    display: flex;
    justify-content: flex-end;
    color: var(--text-3);
    font-size: var(--font-xs);
    margin-top: var(--g1);
}

.variable-item-main {
    cursor: pointer;
    flex: 1 1 auto;
    min-width: 0;
}

.variable-token {
    font-family: var(--monospace-font), monospace;
    font-weight: bold;
    word-break: break-all;
}

/* Compact-list density (Option A from the redesign): a 35-entry catalog is
   heavy when every row always shows label+description+3 action buttons
   regardless of whether anything is selected. Default state below is just
   token + a colored dot; hovering, selecting or keyboard-focusing a row
   reveals the rest - the click-to-select/dblclick-to-insert interaction
   itself is unchanged, this only affects what's visible before that happens.
   Three separate triggers (:hover, :focus-within, .selected) so mouse,
   keyboard and "I already picked one" all work.

   Scoped to .template-editor-variables (the Template/Snippet Editor's own
   panel, Views/VariablePanel.php) rather than bare .variable-item - the
   Variable Management page's own catalog explorer
   (template-variable-editor.js renderIndex()) reuses the .variable-item/
   .variable-source-badge classes for an unrelated single-purpose insert
   list with no selection state, and must not be affected. */
/* Two kinds of reveal, split by whether they move anything.

   Hover used to trigger all of them, and the list jittered continuously as
   the pointer travelled down it: label and description sit *inside*
   .variable-item-main, stacked under the token, so un-hiding them grows the
   row and shoves every row below it. Reading a list while it reflows under
   the cursor is what made the panel feel unstable.

   So: anything that changes the row's HEIGHT now happens only on a
   deliberate .selected (click) or :focus-within (keyboard). A shift you
   caused by clicking is fine; one you caused by moving the mouse is not.
   Anything that does NOT move the layout may still respond to hover, which
   is what keeps "insert" one click away from the compact state - insert is
   the dominant action in this panel, and hiding it behind expand-first would
   have made the fix cost more than the bug. */
.template-editor-variables .variable-label,
.template-editor-variables .variable-description,
.template-editor-variables .variable-item .variable-source-badge {
    display: none;
}

.template-editor-variables .variable-item.selected .variable-label,
.template-editor-variables .variable-item.selected .variable-description,
.template-editor-variables .variable-item:focus-within .variable-label,
.template-editor-variables .variable-item:focus-within .variable-description {
    display: block;
}

/* Out of flow while compact, so hovering costs exactly zero layout.

   Toggling `display` here is not an option: .variable-item-actions is a flex
   sibling of .variable-item-main (flex: 1 1 auto), so revealing it resizes
   main - and .variable-token is word-break: break-all, so a long token
   re-wraps and the row grows anyway, reintroducing the jitter by the back
   door. Merely reserving the slot with `visibility` is no good either: these
   actions are ~276px wide against a ~300px panel, so the reserved space
   squeezed main until every token wrapped, taking all 36 compact rows from
   ~37px to 67px. Measured both, hence absolute.

   Overlaying the row's right edge is the standard list-hover-actions pattern,
   and it works here because the compact row holds only a token and a dot -
   there is nothing underneath worth reading. The backdrop matches the row's
   own hover colour so the buttons read as part of the row rather than as
   something floating over it. */
.template-editor-variables .variable-item {
    position: relative;
}

.template-editor-variables .variable-item-actions {
    position: absolute;
    top: var(--g1);
    right: var(--g1);
    margin-top: 0;
    padding: var(--p1);
    border-radius: var(--rad-2);
    background: color-mix(in oklab, var(--accent) 12%, var(--surface-2));
    visibility: hidden;
    opacity: 0;
}

.template-editor-variables .variable-item:hover .variable-item-actions {
    visibility: visible;
    opacity: 1;
}

/* The compact overlay carries insert ONLY, and icon-only at that. The full
   three-button bar is ~169px against a ~290px row, which covered the tail of
   the token underneath - and these tokens are distinguished by their suffixes
   (CHG4_CTRL_NWA vs CHG4_CTRL_NAME), so clipping the end is the one thing the
   overlay must not do. Icon-only insert is ~34px and clears every token in
   the catalog.

   Editing and deleting a variable stay behind selecting it, which is the
   right split anyway: insert is what the panel is for, managing the catalog
   entry is a different job and wants the details visible. The labelled button
   is still there the moment the row is expanded. */
.template-editor-variables .variable-item:not(.selected):not(:focus-within) .variable-action-btn:not(.variable-action-btn-insert),
.template-editor-variables .variable-item:not(.selected):not(:focus-within) .variable-action-label {
    display: none;
}

/* Expanded, the row has room for them, so they go back into normal flow
   beneath the description - exactly where they sat before any of this. */
.template-editor-variables .variable-item.selected .variable-item-actions,
.template-editor-variables .variable-item:focus-within .variable-item-actions {
    position: static;
    margin-top: var(--g2);
    padding: 0;
    background: none;
    visibility: visible;
    opacity: 1;
}

/* The badge replaces the dot, and both live in a `justify-between` top row
   with the token pinned left, so the swap costs no horizontal movement -
   but it is still part of "expanded", so it follows click, not hover. */
.template-editor-variables .variable-item.selected .variable-source-badge,
.template-editor-variables .variable-item:focus-within .variable-source-badge {
    display: inline-block;
}

/* The row is clickable, so it says so on hover - underline on the token
   only, which is the part that reads as the row's name. Costs no layout
   (text-decoration never reflows) and pairs with the insert button fading in
   opposite it, so both of the row's actions become visible at the same
   moment without anything moving. */
.template-editor-variables .variable-item:hover .variable-token {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* The dot is the inverse of the badge above - visible only in the compact
   default state, replaced by the full text badge once expanded. Only
   rendered at all inside the editor panel (variable-explorer.js), so no
   scoping needed for its base rule, just the hide-on-expand one. */
.variable-item-dot {
    display: inline-block;
    width: .55em;
    height: .55em;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.template-editor-variables .variable-item.selected .variable-item-dot,
.template-editor-variables .variable-item:focus-within .variable-item-dot {
    display: none;
}

.variable-item-dot.source-derived { color: var(--success-strong); }
.variable-item-dot.source-manual { color: var(--warn-strong); }
.variable-item-dot.source-static { color: var(--info-strong); }
.variable-item-dot.source-unmapped { color: var(--error-strong); }

.variable-label {
    font-size: .9em;
    color: var(--text-2);
}

.variable-description {
    font-size: .8em;
    color: var(--text-3);
    margin-top: 2px;
}

.variable-source-badge {
    font-size: .7em;
    padding: 1px 6px;
    border-radius: var(--rad-full);
    white-space: nowrap;
    border: 1px solid currentColor;
}

.variable-source-badge.source-derived {
    color: var(--success-strong);
}

.variable-source-badge.source-manual {
    color: var(--warn-strong);
}

.variable-source-badge.source-static {
    color: var(--info-strong);
}

.variable-source-badge.source-unmapped {
    color: var(--error-strong);
}

.variable-item-actions {
    display: flex;
    gap: var(--g1);
    margin-top: var(--g2);
}

.variable-action-btn {
    padding: var(--p1) var(--g2);
    font-size: .8em;
}

.variable-action-btn-insert {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--g1);
    color: var(--success-strong);
    border-color: var(--success-strong);
}

@media (max-width: 1100px) {
    .template-editor-layout {
        grid-template-columns: 1fr;
    }

    .template-editor-variables {
        position: static;
        max-height: none;
    }
}

/* ----------------------
    MULTI-SELECT (tag picker)
----------------------- */

.multi-select-wrapper {
    position: relative;
}

.multi-select-display {
    display: flex;
    flex-wrap: wrap;
    gap: var(--g1);
    min-height: 2.4rem;
    padding: var(--p2);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    background: var(--surface-2);
    cursor: pointer;
}

.multi-select-display:focus {
    outline: none;
    border-color: var(--accent);
}

.multi-select-placeholder {
    color: var(--text-3);
}

.multi-select-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px var(--p1) 2px var(--p2);
    background: var(--accent-soft);
    color: var(--accent-text);
    border-radius: var(--rad-full);
    font-size: var(--font-small);
}

.multi-select-tag-remove {
    cursor: pointer;
    font-weight: bold;
    padding: 0 4px;
}

.multi-select-tag-remove:hover {
    color: var(--error-strong);
}

.multi-select-options {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 16rem;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-2);
    box-shadow: 0 4px 12px var(--opaque-300);
    padding: var(--p1);
}

.multi-select-search {
    width: 100%;
    margin-bottom: var(--p1);
}

.multi-select-option {
    padding: var(--p2);
    border-radius: var(--rad-2);
    cursor: pointer;
}

.multi-select-option:hover {
    background: var(--surface-3);
}

.multi-select-option-empty {
    color: var(--text-3);
    cursor: default;
}

.multi-select-option-empty:hover {
    background: none;
}

/* ── Template editor: outline / tabs / preview / diagnostics / variable
   detail panel (feature 1, 3, 4, 5, 6) ── */

.template-outline {
    display: flex;
    flex-wrap: wrap;
    gap: var(--g1);
}

.template-outline-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--rad-full);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: .8em;
    cursor: pointer;
    color: var(--text);
}

.template-outline-item:hover {
    background: var(--surface-3);
}

.template-outline-marker {
    font-weight: bold;
}

.template-outline-item-empty {
    border-style: dashed;
    color: var(--text-3);
}

.template-outline-item-empty .template-outline-marker {
    color: var(--warn-strong);
}

.template-editor-tabs {
    margin-bottom: var(--g1);
}

/* --------------------------------------------------------------------------
   SEGMENTED CONTROL (.segmented > .segmented-item)

   For switching a *mode of display* over the same content - Quelle/Vorschau
   in the editors, a compact/comfortable toggle, a filter. NOT for navigating
   between different panels of content: that is .tab-group below, and the two
   look different on purpose so the difference is legible without reading the
   labels.

   The well makes "these belong to one control" and the raised pill makes
   "this one is selected" obvious at a glance; before it, buttons sat on the
   page background and the selected one was easy to miss.

   .template-tab-* is the editors' original name for this, kept as an alias
   rather than migrated - it is the same control, and renaming it would touch
   two editors' JS for no behavioural gain.
   -------------------------------------------------------------------------- */
.segmented,
.template-tab-group {
    display: inline-flex;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    padding: 3px;
    gap: 3px;
}

.segmented-item,
.template-tab-button {
    padding: 5px 14px;
    border-radius: var(--rad-1);
    border: 1px solid transparent;
    background: none;
    color: var(--text-3);
    font-family: 'Lato';
    font-weight: 500;
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}

.segmented-item:hover,
.template-tab-button:hover {
    color: var(--text);
}

.segmented-item.active,
.template-tab-button.active {
    background: var(--surface);
    border-color: var(--border);
    color: var(--accent-text);
    box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   FOLDER TABS (.tab-group > .tab-button)

   For navigating between panels of content. Left-aligned and sitting *on* a
   baseline rule, with the selected tab painting over that rule so it reads as
   physically attached to the panel below it - the classic folder metaphor.
   That attachment is the whole point: it says "this strip of content belongs
   to that tab", which a detached pill cannot.

   The active tab's background matches .card's own var(--surface), so tab and
   panel are one continuous surface.
   -------------------------------------------------------------------------- */
.tab-group {
    display: flex;
    /* stretch, not flex-end: every tab is then the height of the tallest, so
       one carrying a count badge cannot stand taller than its neighbours. */
    align-items: stretch;
    gap: 2px;
    /* The rule the tabs sit on. Full width of its container, so it reads as a
       divider between the tab strip and the content even where the tabs stop. */
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--g3);
}

.tab-button {
    /* inline-flex + centre so a badge or icon rides on the text baseline
       instead of growing the tab. min-height keeps a text-only tab the same
       size as one with a badge. */
    display: inline-flex;
    align-items: center;
    /* The label and its count are two different things - the gap is wider than
       the old --g1 so the number reads as a count *of* the tab rather than as
       part of its name. */
    gap: var(--g2);
    min-height: 2.5rem;
    /* Tokens, not a magic 16: this control now shares the scale with
       everything else, so a change to --p3 moves it too. */
    padding: 0 var(--p3);
    /* Bordered even when inactive: the strip has to read as a row of tabs at
       a glance, not as text that happens to sit above a rule. */
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--rad-2) var(--rad-2) 0 0;
    background: var(--surface-2);
    color: var(--text-2);
    font-family: 'Lato';
    /* Deliberately constant across states: bolding the active tab would
       change its width and nudge every tab after it sideways on each switch. */
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    /* Overlap the baseline so the active tab can paint over it. */
    margin-bottom: -1px;
    /* No transition. A tab strip is pointed at and scanned, and a 120ms fade
       under a moving cursor reads as lag rather than polish. */
}

.tab-button:hover:not(.active) {
    background: var(--surface-3);
    color: var(--text);
}

.tab-button.active {
    background: var(--surface);
    color: var(--accent-text);
    box-shadow:
        /* Paints over the 1px baseline directly beneath this tab - the join
           that makes it look attached to the panel below. */
        0 1px 0 0 var(--surface),
        /* Accent cap along the top edge: carries "this one is selected"
           without a weight change and so without any reflow. inset, so it
           costs no layout either. */
        inset 0 2px 0 0 var(--accent);
}

/* A per-panel toolbar: the explanatory line and the "see all" link that used
   to live in each folded card's header. Sits above the panel's table. */
.panel-toolbar {
    padding: 0 0 var(--g2);
    flex-wrap: wrap;
}

.panel-toolbar p,
.panel-toolbar span {
    margin: 0;
    min-width: 0;
}

/* A count or status pill riding along inside a tab. */
.tab-button .badge {
    /* gap on the button already spaces it; no margin, or it double-spaces. */
    margin: 0;
}

.template-preview-wrap {
    min-height: 28rem;
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    overflow: auto;
}

.template-preview-output {
    margin: 0;
    padding: var(--p2);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-size-1);
    line-height: 1.5;
    white-space: pre;
    /* white-space: pre with no overflow rule meant a long config line simply
       ran out of its grid column and slid under the variable panel beside
       it. Kept as `pre` rather than switched to pre-wrap on purpose: this is
       device config, and soft-wrapping it misrepresents where lines actually
       end. Same max-height/overflow pairing .config-preview-pre already
       uses for the switch detail page's config preview. */
    max-height: 50vh;
    overflow: auto;
}

/* Preview needs the width more than the catalog does: the panel only exists
   to insert variables into the editor, which the preview tab cannot do
   anyway. Collapsing rather than hiding the column keeps the grid honest -
   no leftover 22rem gutter. */
.template-editor-layout.preview-active {
    grid-template-columns: minmax(0, 1fr);
}

.template-editor-layout.preview-active .template-editor-variables {
    display: none;
}

.template-diagnostics summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--g1);
    font-weight: 500;
}

.template-diagnostics-list {
    list-style: none;
    margin: var(--g2) 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.template-diagnostics-item {
    padding: 4px var(--p2);
    border-radius: var(--rad-2);
    background: var(--surface-2);
    font-size: .9em;
    display: flex;
    align-items: center;
    gap: var(--g1);
}

.template-diagnostics-item.clickable {
    cursor: pointer;
}

.template-diagnostics-item.clickable:hover {
    background: var(--surface-3);
}

.template-diagnostics-unused i {
    color: var(--warn-strong);
}

.template-diagnostics-empty-section i {
    color: var(--warn-strong);
}

.template-diagnostics-missing i {
    color: var(--error-strong);
}

.template-diagnostics-empty {
    color: var(--text-3);
    font-size: .9em;
}

.tok-coverage-ok {
    color: var(--success);
}

.tok-coverage-unset {
    color: var(--warn-strong);
}

/* Feature 3 + 6: selected-variable detail/origin panel. */
.variable-detail {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    padding: var(--g2);
    margin-bottom: var(--g2);
}

.variable-detail-fields {
    margin: var(--g1) 0 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px var(--g2);
}

.variable-detail-fields dt {
    color: var(--text-3);
    font-size: .8em;
    white-space: nowrap;
}

.variable-detail-fields dd {
    margin: 0;
    font-size: .9em;
}

/* Feature 3: click-selected state, distinct from the in-use-* border colors
   (which reflect usage, not selection) - an accent background makes the
   currently-selected item unambiguous even when it also has an in-use border. */
.variable-item.selected {
    background: var(--surface-4);
}

/* Feature 2: per-item usage counter, and its shared "0 times" callout style
   also used inside the detail panel and the Variable Management page. */
/* .variable-usage (the old per-row "Used N times" line) is gone - see
   variable-explorer.js. .usage-zero survives on its own: the detail panel
   still marks a zero-usage variable as a removal candidate. */
.usage-zero {
    color: var(--warn-strong);
    font-weight: 500;
}

/* ── Variable Management page (feature 7) ── */

#variable-type-filter .action-button.active,
#switch-ports-mode-toggle .action-button.active {
    background: var(--accent);
    border-color: var(--accent-strong);
    color: var(--accent-fg);
}

/* .data-table tr's own display:flex (line ~90) has higher specificity
   (class+element) than a bare .variable-row-hidden-by-type class - without
   qualifying this selector the same way, display:flex silently wins and the
   type-filter buttons toggle the class with no visible effect. */
.data-table tbody tr.variable-row-hidden-by-type {
    display: none;
}

/* ── Variable editor page (/template-variables/new, /template-variables/{id}) ── */

/* Left: Definition / Playground / Nachschlagen sections stacked in their own
   flex column (.variable-editor-main) so their height is only ever their own
   natural content height. Right: catalog explorer, stretched by
   align-items: stretch (the flex default) to match that column's full
   height. */
.variable-editor-layout {
    display: flex;
    gap: var(--g3);
    align-items: flex-start;
}

.variable-editor-main {
    flex: 1 1 auto;
    min-width: 0;
}

.variable-editor-index {
    flex: 0 0 24rem;
}

/* Form controls default to the UA's 13.33px rather than inheriting - a
   half-point smaller than every label and hint sitting right next to them.
   Scoped to this page rather than fixed globally: the same mismatch exists
   app-wide, but re-typing every form on every page is a separate change with
   its own layout risk. */
.variable-editor-layout input,
.variable-editor-layout select,
.variable-editor-layout textarea {
    font-size: var(--font-size-1);
    font-family: inherit;
}

.variable-editor-layout .mono,
.variable-editor-layout code {
    font-family: var(--monospace-font), monospace;
}

.variable-editor-layout .form-row label {
    font-size: var(--font-size-1);
}

.variable-editor-layout .field-hint {
    font-size: var(--font-small);
    line-height: 1.4;
}

/* ── Editor sections ── */

.editor-section {
    display: flex;
    flex-direction: column;
    gap: var(--g2);
    padding: var(--p3) var(--p4);
    border: 1px solid var(--border);
    border-radius: var(--rad-3);
    background: var(--surface-2);
}

.editor-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--g2);
    flex-wrap: wrap;
    padding-bottom: var(--p2);
    border-bottom: 1px solid var(--border);
}

.editor-section-title {
    font-size: var(--font-size-2);
    font-weight: 600;
    letter-spacing: .02em;
    display: inline-flex;
    align-items: center;
    gap: var(--g2);
}

.editor-section-title i {
    color: var(--accent-text);
}

/* The persistence marker. This is the whole point of the section split -
   "does hitting Speichern keep this?" has to be answerable at a glance from
   anywhere on the page. */
.editor-section-note {
    display: inline-flex;
    align-items: center;
    gap: var(--g1);
    font-size: var(--font-small);
    color: var(--text-3);
    padding: 2px var(--p2);
    border-radius: var(--rad-full);
    border: 1px solid var(--border);
    white-space: nowrap;
}

/* Scratch space reads as scratch space: dashed edge, recessed surface. */
.playground-section {
    border-style: dashed;
    border-color: var(--warn);
    background: var(--surface);
}

/* ── Definition field grid ── */

/* Two columns so a 14-character token stops being rendered in a 2000px-wide
   input; the description spans both. */
.variable-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--g3);
}

.variable-field-grid .field-span-2 {
    grid-column: 1 / -1;
}

@media (max-width: 780px) {
    .variable-field-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ── Derivation block (formula / hardcoded / none) ── */

/* The per-selector `[hidden]` opt-outs that used to live here (one each for
   the three derivation states, plus the reference rows) are gone - the
   global `[hidden] { display: none !important }` in UTILITIES now covers
   them. */

.derivation-block {
    margin-top: var(--g2);
}

.derivation-warning,
.derivation-none {
    display: flex;
    align-items: flex-start;
    gap: var(--g2);
    margin: var(--g2) 0 0;
    padding: var(--p2) var(--p3);
    border-radius: var(--rad-2);
    font-size: var(--font-small);
    line-height: 1.5;
}

.derivation-warning {
    background: var(--warn-soft);
    border: 1px solid var(--warn);
    color: var(--warn-text);
}

.derivation-warning code {
    font-family: var(--monospace-font), monospace;
}

.derivation-none {
    background: var(--surface-3);
    border: 1px solid var(--border);
    color: var(--text-2);
}

.derivation-none i,
.derivation-warning i {
    margin-top: 2px;
}

.derivation-locked {
    display: flex;
    flex-direction: column;
    gap: var(--g2);
    padding: var(--p3);
    border: 1px solid var(--info);
    border-radius: var(--rad-3);
    background: var(--surface-3);
}

.derivation-locked-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--g2);
    flex-wrap: wrap;
}

.derivation-locked-title {
    display: inline-flex;
    align-items: center;
    gap: var(--g2);
    font-weight: 600;
    font-size: var(--font-size-1);
}

.derivation-locked-title i {
    color: var(--warn-strong);
}

.derivation-locked-value {
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-small);
    padding: 2px var(--p2);
    border-radius: var(--rad-2);
    background: var(--success-soft);
    border: 1px solid var(--success);
    color: var(--success-text);
}

/* ── Code block (read-only PHP source view) ── */

.code-block {
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-2);
    overflow: hidden;
    background: var(--surface);
}

.code-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--g2);
    flex-wrap: wrap;
    padding: var(--p2) var(--p3);
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
}

.code-block-title {
    display: inline-flex;
    align-items: center;
    gap: var(--g2);
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-small);
    font-weight: 600;
}

.code-block-meta {
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-xs);
    color: var(--text-3);
}

.code-block-body {
    margin: 0;
    padding: var(--p3);
    overflow-x: auto;
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-small);
    line-height: 1.6;
    tab-size: 4;
    color: var(--text);
}

.code-block-body code {
    font-family: inherit;
    white-space: pre;
}

/* ── Playground ── */

.playground-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--g3);
    flex-wrap: wrap;
}

.playground-label {
    font-size: var(--font-size-1);
    font-weight: 600;
    color: var(--text);
}

.transfer-button {
    color: var(--text-2);
}

.variable-formula-test-result {
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-size-1);
}

/* ── Nachschlagen (reference) ── */

.reference-search {
    position: relative;
    display: flex;
    align-items: center;
}

.reference-search > i {
    position: absolute;
    left: var(--p2);
    color: var(--text-3);
    pointer-events: none;
}

.reference-search input {
    width: 100%;
    padding-left: calc(var(--p3) + 1rem);
}

.reference-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: var(--g3);
    align-items: start;
}

.reference-group {
    min-width: 0;
}

.reference-group-title {
    display: flex;
    align-items: center;
    gap: var(--g2);
    margin: 0 0 var(--g2);
    font-size: var(--font-small);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}

.reference-count {
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-xs);
    font-weight: 600;
    padding: 1px var(--p2);
    border-radius: var(--rad-full);
    background: var(--surface-3);
    color: var(--text-2);
    letter-spacing: 0;
}

.reference-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--g1);
    max-height: 22rem;
    overflow-y: auto;
}

.reference-item {
    display: grid;
    grid-template-columns: minmax(0, auto) 1fr;
    align-items: baseline;
    gap: 2px var(--g2);
    padding: var(--p2);
    border-radius: var(--rad-2);
    background: var(--surface-3);
    border: 1px solid transparent;
    cursor: pointer;
}

/* Same accent-mix reasoning as .explorer-list .variable-item:hover below -
   these rows rest on --surface-3, so they mix against that. */
.reference-item:hover {
    background: color-mix(in oklab, var(--accent) 12%, var(--surface-3));
    border-color: var(--accent-border);
}

/* Operators are documentation, not snippets - no hover affordance implying
   a click that does nothing. */
.reference-item.is-static {
    cursor: default;
}

.reference-item.is-static:hover {
    background: var(--surface-3);
    border-color: transparent;
}

/* The operator rows are the one place the reference list touches the shared
   .template-diagnostics styling's hover; keep them inert. */
.reference-item.is-static:focus-visible {
    outline: none;
}

/* A full example replaces the expression rather than inserting at the caret,
   so it gets the whole row to itself. */
.reference-item.is-example {
    grid-template-columns: minmax(0, 1fr);
}

.reference-item code {
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-small);
    font-weight: 600;
    color: var(--accent-text);
    word-break: break-word;
}

.reference-desc {
    font-size: var(--font-small);
    color: var(--text-2);
    line-height: 1.45;
}

.reference-example,
.reference-live {
    grid-column: 1 / -1;
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-small);
    color: var(--text-3);
}

.reference-live {
    grid-column: 2;
    justify-self: start;
    color: var(--success-text);
    font-size: var(--font-small);
    word-break: break-all;
}

.reference-empty {
    margin: 0;
    padding: var(--p2);
    font-size: var(--font-small);
    color: var(--text-3);
}

/* ── Catalog explorer (right panel) ── */

.variable-editor-index {
    padding: var(--p3);
    gap: var(--g2);
}

.explorer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--g2);
    padding-bottom: var(--p2);
    border-bottom: 1px solid var(--border);
}

.explorer-title {
    display: inline-flex;
    align-items: center;
    gap: var(--g2);
    font-size: var(--font-size-2);
    font-weight: 600;
}

.explorer-title i {
    color: var(--accent-text);
}

.explorer-count {
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-small);
    font-weight: 600;
    padding: 1px var(--p2);
    border-radius: var(--rad-full);
    background: var(--surface-4);
    color: var(--text-2);
}

.explorer-list {
    display: flex;
    flex-direction: column;
}

.explorer-list .variable-category {
    display: flex;
    align-items: center;
    gap: var(--g2);
    margin: var(--g3) 0 var(--g2);
    font-size: var(--font-small);
    font-weight: 700;
}

.variable-category-count {
    font-family: var(--monospace-font), monospace;
    font-size: var(--font-xs);
    font-weight: 600;
    padding: 0 var(--p2);
    border-radius: var(--rad-full);
    background: var(--surface-3);
    letter-spacing: 0;
}

/* <button>, not <div> - keyboard-reachable, and the reset below strips the
   UA button look the rest of the item styling would otherwise fight. */
.explorer-list .variable-item {
    appearance: none;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
    flex-direction: column;
    gap: var(--g1);
    padding: var(--p2) var(--p3);
    cursor: pointer;
}

/* Two things fought over this hover, hence the id selector.

   1. These rows are <button>s (keyboard reachability), which opts them into
      main.css's global `button:not(:disabled):not(.destructive):hover` -
      specificity 0,3,1, so it beats a plain `.explorer-list .variable-item
      :hover` (0,3,0) and paints the row solid --button-bg with inverted
      text. That, not the surface step below, was what read as "hover far
      too dark". `color: inherit` undoes its text inversion.
   2. The shared .variable-item:hover uses var(--surface-4), and the surface
      scale runs *away* from --surface - so --surface-4 is a step lighter
      than the panel in dark themes but a step darker in light ones. On
      light+amber it drops the row from L .98 to L .93: a gray smudge, not a
      highlight. Mixing the accent into the row's own resting colour keeps
      lightness roughly put and lets hue carry the state instead, which
      reads the same way in both themes (light L .98 -> .95 warm-tinted,
      dark L .25 -> .30 lifted). */
#variable-index-panel .variable-item:hover,
#variable-index-panel .variable-item:focus-visible {
    background: color-mix(in oklab, var(--accent) 12%, var(--surface-2));
    color: inherit;
    border-color: var(--accent-border);
    outline: none;
}

/* Wraps rather than compressing: the longest tokens (CHG4_CTRL_ACL_SUBNET)
   plus a badge don't fit one line at this font size, and the shared
   .variable-token's word-break: break-all splits them mid-identifier
   ("CHG4_CTRL_ACL_SUBN / ET"). Letting the badge drop to its own line keeps
   every token readable on one unbroken line instead. */
.variable-item-top {
    display: flex;
    align-items: center;
    gap: var(--g1) var(--g2);
    flex-wrap: wrap;
}

.explorer-list .variable-token {
    font-size: var(--font-size-2);
    word-break: normal;
    overflow-wrap: anywhere;
}

.explorer-list .variable-source-badge {
    flex: 0 0 auto;
    margin-left: auto;
}

.explorer-list .variable-label {
    font-size: var(--font-size-1);
    line-height: 1.4;
    color: var(--text-2);
}

/* Shared .variable-source-badge is .7em (~10px at this scale) - legible in
   the Template Editor's denser side panel, too small to read here. */
.explorer-list .variable-source-badge {
    font-size: var(--font-small);
    padding: 1px var(--p2);
}

@media (max-width: 1100px) {
    .variable-editor-layout {
        flex-direction: column;
    }

    .variable-editor-index {
        flex: none;
        width: 100%;
        max-height: 26rem;
        position: static;
    }
}

/* ── Toasts (toast.js) ── */

/* Top centre, not top right: a save confirmation now arrives *after* the
   dialog has closed, so it is the only thing on screen reporting what
   happened - it belongs where the eye already is (the dialog that just
   vanished from the middle), not in the far corner where it was easy to
   miss entirely. translateX on the stack, translateY on the .toast itself,
   so the entry animation and the centring never fight over one property. */
.toast-stack {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    top: var(--p4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--g2);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--g2);
    min-width: 15rem;
    max-width: min(28rem, 90vw);
    padding: var(--p3) var(--p3);
    border-radius: var(--rad-3);
    border: 1px solid var(--border-strong);
    background: var(--surface-3);
    color: var(--text);
    font-size: var(--font-size-1);
    box-shadow: 0 8px 24px var(--opaque-200);
    cursor: pointer;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-.5rem);
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: none;
    }
}

/* Unsaved-changes marker on the header save button - the beforeunload guard
   was previously the only signal that anything was pending. */
#variable-save-button.has-changes::after {
    content: '';
    width: 7px;
    height: 7px;
    margin-left: var(--g1);
    border-radius: 50%;
    background: var(--warn-strong);
}

@media (max-width: 900px) {
    .template-editor-tabs {
        flex-wrap: wrap;
    }
}

/* ----------------------
    WORKFLOW EDITOR
----------------------- */

/* Same shape as .template-editor-layout: the work happens in the left
   column, the catalogue you pick from sits in a fixed-width right one,
   matching source order. */
.workflow-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22rem;
    gap: var(--g3);
    align-items: start;
}

.workflow-step-list {
    display: flex;
    flex-direction: column;
    gap: var(--g2);
    margin: 0;
    padding: var(--g3);
    /* The step's own number is drawn by the counter below, so the marker
       would be a second one. */
    list-style: none;
    counter-reset: workflow-step;
}

.workflow-step {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--g2);
    padding: var(--g2) var(--g2) var(--g2) calc(var(--g3) + 1.4rem);
    border-radius: var(--rad-2);
    border: 1px solid var(--border);
    background: var(--surface-2);
    counter-increment: workflow-step;
}

.workflow-step::before {
    content: counter(workflow-step);
    position: absolute;
    left: var(--g2);
    top: var(--g2);
    width: 1.4rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-3);
}

/* A step whose action key no longer resolves in config/actions.php - the
   workflow really is broken, so it reads as an error rather than being
   quietly dropped from the list. */
.workflow-step-missing {
    border-color: var(--error-strong);
}

/* .variable-item is a *row* flex, which the template editor's own catalogue
   gets away with because its entries are one short token each. An action
   carries a label, a dotted key and a privilege, so as a row it runs off the
   22rem column - it stacks here instead. min-width:0 plus overflow-wrap are
   what actually stop a long key from widening the grid track. */
.workflow-action-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--g1);
    min-width: 0;
    width: 100%;
    text-align: left;
    overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
    .workflow-editor-layout {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   SOFT STATUS SURFACES

   One skin, six states. Twelve rules used to spell out the same three
   declarations - a soft fill, a matching border and a readable ink - each with
   a different token trio, so a thirteenth surface meant a thirteenth copy and
   a change to the recipe meant twelve edits.

   A surface now joins the list and names its state; the recipe is written
   once. Specificity is unchanged: a selector list gives every selector its own
   specificity, so `.filter-chips .action-button.active` still outranks a bare
   `.action-button` exactly as before, and the ID-qualified overrides further
   up still beat it.

   .toast-info deliberately keeps --accent-border where the other accent
   surfaces use --accent. It was the one of the twelve that differed;
   flattening it would have been a silent visual change dressed up as a
   refactor.
   ========================================================================== */

.tag.success, .badge.success, .editor-section-note.saved, .toast-success,
.tag.warning, .badge.warning, .editor-section-note.scratch,
.tag.error, .badge.error, .variable-formula-test-result.is-error, .toast-error,
.tag.info, .badge.info,
.tag.accent, .badge.accent, .filter-chips .action-button.active,
.toast-info {
    background: var(--status-soft);
    border-color: var(--status-line);
    color: var(--status-ink);
}

.tag.success, .badge.success, .editor-section-note.saved, .toast-success {
    --status-soft: var(--success-soft);
    --status-line: var(--success);
    --status-ink: var(--success-text);
}

.tag.warning, .badge.warning, .editor-section-note.scratch {
    --status-soft: var(--warn-soft);
    --status-line: var(--warn);
    --status-ink: var(--warn-text);
}

.tag.error, .badge.error, .variable-formula-test-result.is-error, .toast-error {
    --status-soft: var(--error-soft);
    --status-line: var(--error);
    --status-ink: var(--error-text);
}

.tag.info, .badge.info {
    --status-soft: var(--info-soft);
    --status-line: var(--info);
    --status-ink: var(--info-text);
}

.tag.accent, .badge.accent, .filter-chips .action-button.active {
    --status-soft: var(--accent-soft);
    --status-line: var(--accent);
    --status-ink: var(--accent-text);
}

.toast-info {
    --status-soft: var(--accent-soft);
    --status-line: var(--accent-border);
    --status-ink: var(--accent-text);
}

/* The placeholder legend for a firmware platform's expected image name. Sits
   above the fields rather than under the one it describes, because it is the
   reference you read *before* typing a pattern.

   A list, not prose: this is a lookup - which placeholders exist - and each
   entry doubles as feedback, marking itself once its placeholder is actually
   in use. That is what answers "did that register?" without reading a
   sentence. */
.filename-legend-box {
    margin-bottom: var(--p2);
    padding: var(--p2);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    background: var(--surface-2);
}

.filename-legend {
    margin: var(--g1) 0 0;
    padding-left: var(--p3);
    list-style: disc;
}

.filename-legend li + li {
    margin-top: 2px;
}

/* Marked, not merely coloured: colour alone would carry the whole signal, and
   this list is read at a glance next to a field somebody is typing into. */
.filename-legend li.is-used {
    color: var(--success-text);
    font-weight: 600;
    list-style-type: '✓ ';
}

/* A placeholder inside the echoed pattern, so `{version}` reads as a slot
   rather than as text that happens to have braces round it. */
/* .field-hint is a flex ROW (it exists to sit an icon beside a line of text),
   which put the echoed pattern next to the explanation in a narrow column and
   wrapped it mid-token. This one stacks: the pattern on its own line, the
   sentence under it. */
[data-filename-preview] {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.filename-token {
    font-weight: 700;
    color: var(--accent-text);
}

.filename-token.is-unknown {
    color: var(--warn-text);
    text-decoration: underline wavy;
}
