/* Theme variables - pattern ported from iks-lifecycle-management's
   index.html inline <style>. :root is light; [data-theme="dark"] overrides. */
:root {
    color-scheme: light;
    --bg: #eef1f5;
    --surface: #ffffff;
    --surface-hover: #fafafa;
    --border: #d4d4d4;
    --border-strong: #e0e0e0;
    --border-input: #b8b8b8;
    --text: #333333;
    --text-muted: #888888;
    --text-faint: #bbbbbb;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --accent: #2563eb;
    --surface-selected: #bfdbfe;
    --header-bg: #1a1a2e;
    --badge-running-bg: #dcfce7; --badge-running-text: #166534;
    --badge-shutoff-bg: #f3f4f6; --badge-shutoff-text: #6b7280;
    --badge-paused-bg: #fef3c7;  --badge-paused-text: #92400e;
    --badge-error-bg: #fee2e2;   --badge-error-text: #b91c1c;
    --badge-transitional-bg: #dbeafe; --badge-transitional-text: #1e40af;
    --btn-success: #16a34a; --btn-success-hover: #128038;
    --btn-danger:  #dc2626; --btn-danger-hover:  #b91c1c;
    --btn-warning: #d97706; --btn-warning-hover: #b45f04;
    --btn-dark:    #4b5563; --btn-dark-hover:    #374151;
    /* The console's button, slate blue; and the muted tones that tell the
       quieter actions apart at a glance - background, text, edge. */
    --btn-console: #4a5878; --btn-console-hover: #3c4862;
    --tone-indigo-bg: #eef0fb; --tone-indigo-fg: #4a4f9c; --tone-indigo-bd: #d3d7f2;
    --tone-teal-bg: #e9f5f3;   --tone-teal-fg: #2d7369;   --tone-teal-bd: #c6e3de;
    --tone-violet-bg: #f3eefb; --tone-violet-fg: #6a4c9c; --tone-violet-bd: #ded3f0;
    --tone-steel-bg: #ebf2f7;  --tone-steel-fg: #3b6584;  --tone-steel-bd: #cddde9;
    --tone-sand-bg: #f6f1e8;   --tone-sand-fg: #7a6038;   --tone-sand-bd: #e6dac4;
    --tone-sage-bg: #eef4ea;   --tone-sage-fg: #4f6b3d;   --tone-sage-bd: #d5e3cb;
    --tone-slate-bg: #edf1f7;  --tone-slate-fg: #475a7a;  --tone-slate-bd: #d2dbe8;
    --tone-rose-bg: #f8eef0;   --tone-rose-fg: #8a4b5a;   --tone-rose-bd: #ecd3d9;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b22;
    --surface-hover: #1c2128;
    --border: #2e3640;
    --border-strong: #30363d;
    --border-input: #444c56;
    --text: #e6edf3;
    --text-muted: #7d8590;
    --text-faint: #484f58;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --accent: #58a6ff;
    --surface-selected: #1f3358;
    --header-bg: #10101c;
    --badge-running-bg: #1a4731; --badge-running-text: #3fb950;
    --badge-shutoff-bg: #21262d; --badge-shutoff-text: #7d8590;
    --badge-paused-bg: #432910;  --badge-paused-text: #ffab70;
    --badge-error-bg: #450a0a;   --badge-error-text: #fca5a5;
    --badge-transitional-bg: #1d3557; --badge-transitional-text: #79b8ff;
    --btn-success: #238636; --btn-success-hover: #2ea043;
    --btn-danger:  #da3633; --btn-danger-hover:  #f85149;
    --btn-warning: #9e6a03; --btn-warning-hover: #bb8009;
    --btn-dark:    #30363d; --btn-dark-hover:    #3d444d;
    --btn-console: #3a4660; --btn-console-hover: #46546f;
    --tone-indigo-bg: #1e2033; --tone-indigo-fg: #a3a8e6; --tone-indigo-bd: #343858;
    --tone-teal-bg: #16282a;   --tone-teal-fg: #7cc7bb;   --tone-teal-bd: #27484a;
    --tone-violet-bg: #241d33; --tone-violet-fg: #bba3e6; --tone-violet-bd: #3f345a;
    --tone-steel-bg: #19242d;  --tone-steel-fg: #8fb6d3;  --tone-steel-bd: #2c4050;
    --tone-sand-bg: #2a241a;   --tone-sand-fg: #d1b88c;   --tone-sand-bd: #4a3f2c;
    --tone-sage-bg: #1d261a;   --tone-sage-fg: #a8c796;   --tone-sage-bd: #34452d;
    --tone-slate-bg: #1c222c;  --tone-slate-fg: #a3b4cf;  --tone-slate-bd: #323c4d;
    --tone-rose-bg: #2b1c20;   --tone-rose-fg: #dba3b0;   --tone-rose-bd: #4d3238;
}

* { box-sizing: border-box; }

/* The hidden attribute is how the JS hides things; a display rule further
   down would otherwise quietly beat it (the memory list did exactly that). */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ── Header - always dark, regardless of theme ────────────────────────── */
header {
    background: var(--header-bg);
    color: #fff;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative; /* positioning context for #toast-container */
}
.header-title { display: flex; align-items: center; gap: 5px; text-decoration: none; }
.header-mark { height: 20px; width: auto; }
.header-wordmark {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.01em;
    color: #fff;
}
.header-right { display: flex; align-items: center; gap: 10px; }
/* Role chip, ported from iks-lifecycle-management's .header-admin. Sits on
   the dark header, so its colors are fixed rather than themed. */
.header-role {
    font-size: 11px;
    font-weight: 600;
    background: rgba(255,255,255,0.15);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
/* Read-only is a restriction, not a rank - worth saying more loudly. */
.header-role.restricted { background: var(--btn-warning); }

.theme-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    opacity: 0.75;
    line-height: 1;
}
.theme-btn:hover { opacity: 1; }

/* ── User dropdown ─────────────────────────────────────────────────────── */
.user-menu { position: relative; }
.user-menu-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 7px;
}
.user-menu-btn:hover { background: rgba(255,255,255,0.1); }
.user-menu-chevron { font-size: 9px; opacity: 0.7; transition: transform 0.15s; }
.user-menu.open .user-menu-chevron { transform: rotate(180deg); }
.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
    min-width: 160px;
    z-index: 500;
    overflow: hidden;
}
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
}
.user-menu-item:hover { background: var(--surface-hover); }
.user-menu-icon { flex: none; opacity: 0.65; }
.user-menu-item:hover .user-menu-icon { opacity: 1; }
.user-menu-item.danger { color: #dc2626; }
/* Switching accounts - as Stabile's menu: the accounts you may act as, the
   one you are acting as ticked. */
.user-menu-accounts { border-bottom: 1px solid var(--border-strong); padding: 4px 0; }
.user-menu-heading {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.user-menu-account .user-menu-check { flex: none; width: 15px; color: var(--accent); visibility: hidden; }
.user-menu-account.current .user-menu-check { visibility: visible; }
.user-menu-account.current { font-weight: 600; cursor: default; }
.user-menu-account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-account-role { margin-left: auto; padding-left: 12px; font-size: 11px; color: var(--text-muted); }
.user-menu-account:disabled { opacity: 0.6; }

/* ── Toast history panel - ported from iks-lifecycle-management's
   notif-wrap/notif-btn/notif-panel/etc (utils.js's _notifHistory). ────── */
.notif-wrap { position: relative; }
.notif-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.65);
    padding: 5px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    position: relative;
    line-height: 1;
}
.notif-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.notif-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 9px;
    min-width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    pointer-events: none;
}
.notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-height: 420px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.notif-panel-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-strong);
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}
.notif-panel-hdr button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-muted);
    padding: 2px 7px;
    border-radius: 4px;
}
.notif-panel-hdr button:hover { background: var(--surface-hover); color: var(--text); }
.notif-list { overflow-y: auto; flex: 1; }
.notif-empty { padding: 24px 16px; text-align: center; font-size: 13px; color: var(--text-faint); }
.notif-item {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-hover); }
.notif-item-success { border-left: 3px solid #22c55e; }
.notif-item-info    { border-left: 3px solid #3b82f6; }
.notif-item-warn    { border-left: 3px solid #f59e0b; }
.notif-item-error   { border-left: 3px solid #ef4444; }
.notif-msg  { font-size: 12px; line-height: 1.45; flex: 1; }
.notif-time { font-size: 12px; color: var(--text-faint); white-space: nowrap; padding-top: 2px; }

/* ── Layout ────────────────────────────────────────────────────────────── */
main { padding: 12px 32px 24px; }
.card { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--border-strong); }

/* ── Secondary nav (tab bar) ──────────────────────────────────────────── */
.tab-bar { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border-strong); }
.tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-btn-icon { padding: 10px 16px; display: flex; align-items: center; }
.tab-btn-icon svg { display: block; }

/* Reference tabs (Docs, API) sit apart from the resource tabs, each with a
   small ↗ beside it that opens the same page standalone. */
.tab-bar-right { margin-left: auto; display: flex; align-items: center; }
.tab-btn-popout {
    display: inline-flex;
    align-items: center;
    padding: 10px 12px 10px 0;
    opacity: 0.5;
    text-decoration: none;
    line-height: 1;
}
/* Snug against the tab it opens, and apart from the next one. */
.tab-bar-right .tab-btn:has(+ .tab-btn-popout) { padding-right: 4px; }
.tab-btn-popout:hover { opacity: 1; color: var(--accent); }

/* Docs and API are rendered elsewhere and framed here - see reference.js. */
.embed-frame {
    width: 100%;
    height: calc(100vh - 150px);
    min-height: 420px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    display: block;
}

/* ── Narrow screens: the tab bar collapses behind a hamburger ──────────────
   Ported from iks-lifecycle-management. Below 700px the tabs no longer fit
   on one line, and wrapping them made the bar a ragged block that pushed
   the content down. The bar becomes a dropdown instead, and a slim strip
   says which tab you're on. */
.tab-mobile-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 6px 0 10px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--border-strong);
}
.hamburger-btn {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    padding: 5px 8px;
    line-height: 1;
    display: flex;
}
.hamburger-btn:hover { background: var(--surface-hover); }
.tab-mobile-label { font-size: 15px; font-weight: 600; color: var(--text); }
/* The Home tab is an icon on a wide screen; in the vertical menu a bare icon
   reads as a stray glyph, so it gets its name there. */
.tab-btn-menu-text { display: none; }

@media (max-width: 700px) {
    main { padding: 8px 14px 24px; }

    .tab-mobile-bar { display: flex; }
    .tab-bar {
        display: none;
        flex-direction: column;
        position: absolute;
        left: 0;
        right: 0;
        z-index: 200;
        margin: 0;
        padding: 6px 0;
        background: var(--surface);
        border-bottom: 2px solid var(--border-strong);
        box-shadow: 0 6px 18px rgba(0,0,0,0.18);
        max-height: 80vh;
        overflow-y: auto;
    }
    .tab-bar.open { display: flex; }
    .tab-bar .tab-btn {
        width: 100%;
        text-align: left;
        padding: 12px 18px;
        font-size: 15px;
        margin: 0;
        border-bottom: none;
        border-left: 3px solid transparent;
        justify-content: flex-start;
    }
    .tab-bar .tab-btn.active { border-bottom: none; border-left-color: var(--accent); }
    .tab-btn-icon { gap: 10px; }
    .tab-btn-menu-text { display: inline; }
    /* The ↗ pop-outs are a wide-screen nicety; in a menu they're just
       unlabelled arrows. The standalone pages stay a link away from the
       Docs tab itself. */
    .tab-bar .tab-btn-popout { display: none; }
    .tab-bar-right { flex-direction: column; margin-left: 0; width: 100%; }
}

/* ── Filter / toolbar bar ─────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 0 14px;
}
.filter-bar input[type=text] {
    flex: 1;
    min-width: 200px;
    padding: 6px 10px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    background: var(--surface);
    color: var(--text);
}
.filter-bar input[type=text]:focus { border-color: var(--accent); }
.filter-bar select, .detail-backup-row select {
    padding: 6px 10px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}
.filter-bar select:focus, .detail-backup-row select:focus { border-color: var(--accent); }
.filter-count { font-size: 12px; color: var(--text-faint); white-space: nowrap; }

/* Totals line under a table - ported from iks-lifecycle-management's
   #table-totals. Hidden while a detail pane is open, same as there: the
   table is collapsed to a few rows then, so a total under it would be
   describing rows that are mostly scrolled out of sight. */
/* Two-sided: sums on the left, any status note pulled right. With a
   single child it just sits left, so tabs with only totals are unaffected. */
.table-totals {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    padding: 8px 2px 2px;
    min-height: 20px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}
.tab-panel.detail-visible .table-totals { display: none; }

.btn { padding: 7px 14px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
/* One size for every button icon, set here rather than on each SVG's own
   width/height, so the icons stay consistent as new ones are added. 16
   rather than 14 because fine detail (the umbrella's scalloped canopy)
   fills in and disappears at 14. */
.btn svg { flex-shrink: 0; display: block; width: 16px; height: 16px; }
.btn svg.spin { animation: btn-spin 0.7s linear infinite; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-outline { background: var(--surface-hover); color: var(--text-muted); border: 1px solid var(--border-strong); }
.btn-outline:hover { color: var(--text); }
.btn-success { background: var(--btn-success); color: #fff; }
.btn-success:hover { background: var(--btn-success-hover); }
.btn-danger { background: var(--btn-danger); color: #fff; }
.btn-danger:hover { background: var(--btn-danger-hover); }
.btn-warning { background: var(--btn-warning); color: #fff; }
.btn-warning:hover { background: var(--btn-warning-hover); }
.btn-dark { background: var(--btn-dark); color: #fff; }
.btn-dark:hover { background: var(--btn-dark-hover); }
/* The quieter actions each have a muted tone of their own, by what they do,
   so they can be told apart at a glance; green, amber and red stay for
   starting, stopping and losing things. */
.btn-outline[data-action] {
    background: var(--tone-bg, var(--surface-hover)); color: var(--tone-fg, var(--text-muted));
    border-color: var(--tone-bd, var(--border-strong));
}
.btn-outline[data-action]:hover { filter: brightness(0.97); color: var(--tone-fg, var(--text)); }
.btn-outline[data-action="suspend"], .btn-outline[data-action="sleep"] {
    --tone-bg: var(--tone-indigo-bg); --tone-fg: var(--tone-indigo-fg); --tone-bd: var(--tone-indigo-bd); }
.btn-outline[data-action="backup"] {
    --tone-bg: var(--tone-teal-bg); --tone-fg: var(--tone-teal-fg); --tone-bd: var(--tone-teal-bd); }
.btn-outline[data-action="snapshot"], .btn-outline[data-action="unsnap"] {
    --tone-bg: var(--tone-violet-bg); --tone-fg: var(--tone-violet-fg); --tone-bd: var(--tone-violet-bd); }
.btn-outline[data-action="clone"], .btn-outline[data-action="master"], .btn-outline[data-action="unmaster"],
.btn-outline[data-action="rebase"], .btn-outline[data-action="convert"], .btn-outline[data-action="inject"] {
    --tone-bg: var(--tone-steel-bg); --tone-fg: var(--tone-steel-fg); --tone-bd: var(--tone-steel-bd); }
.btn-outline[data-action="ungroup"], .btn-outline[data-action="unjoin"] {
    --tone-bg: var(--tone-sand-bg); --tone-fg: var(--tone-sand-fg); --tone-bd: var(--tone-sand-bd); }
.btn-outline[data-action="terminal"], .btn-outline[data-action="reload"] {
    --tone-bg: var(--tone-sage-bg); --tone-fg: var(--tone-sage-fg); --tone-bd: var(--tone-sage-bd); }
.btn-outline[data-action="manage"] {
    --tone-bg: var(--tone-slate-bg); --tone-fg: var(--tone-slate-fg); --tone-bd: var(--tone-slate-bd); }
.btn-outline[data-action="resetpassword"] {
    --tone-bg: var(--tone-rose-bg); --tone-fg: var(--tone-rose-fg); --tone-bd: var(--tone-rose-bd); }
/* The console, slate blue rather than plain dark grey. */
.btn-pair .btn-dark { background: var(--btn-console); }
.btn-pair .btn-dark:hover { background: var(--btn-console-hover); }

/* ── Table ─────────────────────────────────────────────────────────────── */
/* Opening the detail pane shrinks the table to a few rows instead of
   pushing it further down the page - ported from
   iks-lifecycle-management's .detail-visible .table-scroll. Unconstrained
   height (natural, whole table on screen) until a row is selected. */
.tab-panel.detail-visible .table-scroll { max-height: min(215px, 30vh); overflow-y: auto; }
.table-scroll table { border-collapse: separate; border-spacing: 0; }
.table-scroll thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; box-shadow: 0 1px 0 var(--border-strong); border-bottom: none; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-strong);
}
/* Sortable column headers - ported from iks-lifecycle-management's
   .sortable/.sorted/.sort-icon. */
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--text); }
.data-table th.sorted { color: var(--accent); }
.sort-icon { margin-left: 4px; font-style: normal; opacity: 0.5; }
.data-table th.sorted .sort-icon { opacity: 1; }
/* A column not sorted by: up and down arrows, drawn rather than typed -
   U+2195 is not in every font, and where it is not it shows as a box. */
.sort-icon:empty {
    display: inline-block;
    width: 0.6em;
    height: 0.95em;
    vertical-align: -0.12em;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 19' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 1.5v16M2 5.5l4-4 4 4M2 13.5l4 4 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 19' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 1.5v16M2 5.5l4-4 4 4M2 13.5l4 4 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.data-table td { padding: 9px 14px; border-bottom: 1px solid var(--border-strong); font-size: 13px; }
.data-table td.name-strong { font-weight: 600; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.data-row:hover { background: var(--surface-hover); }
.data-table tbody tr.data-row { cursor: pointer; }
.data-table tbody tr.data-row.selected { background: var(--surface-selected); box-shadow: inset 3px 0 0 var(--accent); }
.data-table td.empty { text-align: center; color: var(--text-muted); padding: 28px; }
.data-table td.indent { padding-left: 28px; }

/* Progressive column hiding on narrow screens - pattern and breakpoints
   ported from iks-lifecycle-management's clusters table (.col-eksa/
   .col-kube/.col-type/.col-user/.col-endpoint+.col-ping @ 1050/900/800/
   650/520px). Name and Status always stay - everything else is one click
   away in the detail pane, so least-essential-for-a-glance drops first. */
@media (max-width: 950px) { .col-vms-os     { display: none; } }
@media (max-width: 850px) { .col-vms-memory { display: none; } }
@media (max-width: 750px) { .col-vms-vcpu   { display: none; } }
@media (max-width: 650px) { .col-vms-owner  { display: none; } }
@media (max-width: 550px) { .col-vms-ip     { display: none; } }

@media (max-width: 850px) { .col-images-domains { display: none; } }
@media (max-width: 700px) { .col-images-owner   { display: none; } }
@media (max-width: 550px) { .col-images-type    { display: none; } }

@media (max-width: 950px) { .col-net-owner { display: none; } }
@media (max-width: 820px) { .col-net-inuse { display: none; } }
@media (max-width: 700px) { .col-net-vlan  { display: none; } }
@media (max-width: 1100px) { .col-net-traffic { display: none; } }
@media (max-width: 640px) { .col-net-extip { display: none; } }
@media (max-width: 560px) { .col-net-ip    { display: none; } }

@media (max-width: 1000px) { .col-nodes-identity { display: none; } }
@media (max-width: 880px)  { .col-nodes-stor     { display: none; } }
@media (max-width: 760px)  { .col-nodes-load     { display: none; } }
@media (max-width: 640px)  { .col-nodes-mem      { display: none; } }
@media (max-width: 520px)  { .col-nodes-ip, .col-nodes-vms { display: none; } }

@media (max-width: 950px) { .col-users-login    { display: none; } }
@media (max-width: 820px) { .col-users-role     { display: none; } }
@media (max-width: 680px) { .col-users-fullname { display: none; } }
@media (max-width: 540px) { .col-users-email    { display: none; } }

/* A transfer in flight, under the name of the image it belongs to (see
   transferBar in images.js) - the bar shape is ported from
   iks-lifecycle-management's scan bars above its vms table. */
.row-progress { display: flex; align-items: center; gap: 8px; margin-top: 5px; max-width: 260px; }
/* A transfer running elsewhere that has not reported a figure yet: the
   bar sweeps rather than sits at nothing. */
.row-progress-unknown .row-progress-bar { position: relative; animation: row-progress-sweep 1.4s ease-in-out infinite; }
@keyframes row-progress-sweep {
    0%   { left: -35%; }
    100% { left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .row-progress-unknown .row-progress-bar { animation: none; left: 0; }
}
.row-progress-track { flex: 1; height: 5px; border-radius: 3px; background: var(--border-strong); overflow: hidden; }
.row-progress-bar { display: block; height: 5px; border-radius: 3px; background: var(--accent); transition: width 0.35s ease-out; }
/* A download reports about once a second (see _PROGRESS_INTERVAL in the
   images router), so its bar glides from one figure to the next instead of
   stepping: a linear transition slightly longer than the gap between
   reports is still moving when the next one lands. An upload is reported
   by the browser many times a second and needs no such help. */
.row-progress-download .row-progress-bar { transition: width 1.15s linear; }
/* A backup's, in the Backup button's own tone. */
.row-progress-backup .row-progress-bar { background: var(--tone-teal-fg); transition: width 1.15s linear; }
@media (prefers-reduced-motion: reduce) {
    .row-progress-bar { transition: none; }
}
.row-progress-pct {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 30px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.row-progress-cancel {
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 15px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}
.row-progress-cancel:hover { color: var(--btn-danger); }

/* Usage meters (see meter()/bytesMeter() in common.js) - a figure over a
   thin bar, ported from iks-lifecycle-management's vms table. */
.meter { display: inline-block; min-width: 96px; max-width: 160px; width: 100%; }
.meter-text { display: block; font-size: 12px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter-pct { color: var(--text-muted); }
.meter-track { display: block; height: 4px; margin-top: 3px; border-radius: 3px; background: var(--border-strong); overflow: hidden; }
.meter-fill { display: block; height: 4px; border-radius: 3px; }
.meter-low { background: var(--btn-success); }
.meter-mid { background: var(--btn-warning); }
.meter-high { background: var(--btn-danger); }
/* In a detail pane the value sits under a label, so it may take the width. */
.detail-field .meter { max-width: none; }

/* A table whose rows nest - the Systems tab, where a system's VMs sit
   under it (see systems.js). The chevron is part of the name cell so the
   name stays the leftmost thing the eye lands on. */
.tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    border-radius: 4px;
    padding: 0;
    margin: 0 4px 0 -4px;
    vertical-align: middle;
    color: var(--text-muted);
    cursor: pointer;
}
.tree-toggle svg { display: block; transition: transform 0.15s; }
.tree-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.tree-toggle:hover { color: var(--text); background: var(--surface-hover); }
/* Where a row has no chevron: as wide, so the names line up. */
.tree-toggle-spacer { display: inline-block; width: 20px; vertical-align: middle; }
.tree-indent { display: inline-block; width: 16px; }
.tree-name-system { font-weight: 600; }
.tree-child > td:first-child { color: var(--text-muted); }
.tree-child { background: var(--surface-hover); }
.tree-note { font-size: 11px; color: var(--text-muted); }
.tree-mgmt { color: var(--text-faint); line-height: 0; display: inline-block; vertical-align: middle; }
.tree-mgmt:hover { color: var(--accent); }

@media (max-width: 950px) { .col-systems-owner   { display: none; } }
@media (max-width: 850px) { .col-systems-storage { display: none; } }
@media (max-width: 700px) { .col-systems-vcpu    { display: none; } }
@media (max-width: 560px) { .col-systems-memory  { display: none; } }

/* Figures meant to be compared down a column. */
.data-table td.num { font-variant-numeric: tabular-nums; }

/* ── Detail pane (below the table, e.g. VMs tab row click) ────────────── */
.detail-panel { margin-top: 20px; display: none; }
.detail-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.detail-header h2 { font-size: 16px; font-weight: 600; margin: 0; }
/* A qualifier on the detail heading ("master image") - present tense about
   what the thing is, so it reads as part of the title, not as a value. */
.detail-tag { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-left: 8px; }
.detail-header-right { display: flex; align-items: center; gap: 10px; }
.detail-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
/* Every disabled button, not just the ones in .detail-actions - a button
   that is disabled but still looks clickable (the backup Restore button
   was) is worse than no affordance at all. */
.btn:disabled, .btn-disabled { opacity: 0.6; cursor: default; }
/* An <a> styled as a button (the images tab's Download) - anchors don't
   take :disabled, and one without href must not look clickable. */
a.btn { text-decoration: none; }
a.btn-disabled { pointer-events: none; }
/* Around a disabled action, carrying why on hover. */
.btn-why { display: inline-flex; cursor: not-allowed; }
.btn-why > .btn:disabled { pointer-events: none; }
.detail-close-btn {
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    padding: 4px 8px;
    line-height: 1;
    border: none;
    cursor: pointer;
}
.detail-close-btn:hover { color: var(--text); }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
    padding: 20px;
}
.detail-field label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}
.detail-field span { font-size: 14px; color: var(--text); }
.detail-field .detail-sub { font-size: 12px; color: var(--text-muted); }
.dns-records { display: block; }
.dns-record { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; }
.dns-zone-link { display: inline-block; margin-top: 4px; font-size: 12px; }
/* A value that stands for another record - the VMs on a network, the
   images a VM boots (see linkList in common.js). */
.detail-link { color: var(--accent); text-decoration: none; cursor: pointer; }
.detail-link:hover { text-decoration: underline; }
/* Values like image paths and UUIDs are long runs with nowhere a browser will
   break by default, so they pushed past the edge of the pane. "anywhere"
   rather than "break-word" because only it lowers the min-content width -
   which is what a grid column sizes itself from. */
.detail-field { min-width: 0; overflow-wrap: anywhere; }
.detail-field.full-width { grid-column: 1 / -1; }
/* Ends a row of a detail grid early, so what follows starts a new one. */
.detail-break { grid-column: 1 / -1; height: 0; margin-bottom: -18px; }
/* Tabs inside a detail pane (detailTabs in common.js) - as in
   iks-lifecycle-management. */
.detail-tabs {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
}
.detail-tab-btn {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-muted);
}
.detail-tab-btn:hover { color: var(--text); }
.detail-tab-btn.active { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Fields that can be changed in place (see editableField in common.js).
   The pencil sits by the label and stays faint until the field is hovered,
   so a pane of them doesn't read as a row of buttons. */
.detail-field.editable > label { display: flex; align-items: center; gap: 5px; }
.field-edit-btn {
    background: none;
    border: none;
    padding: 0;
    line-height: 0;
    color: var(--text-faint);
    cursor: pointer;
    opacity: 0.7;
}
.detail-field.editable:hover .field-edit-btn { color: var(--accent); opacity: 1; }
.detail-field.editable .field-value { cursor: text; }
.detail-field.editable:hover .field-value { text-decoration: underline dotted var(--border-input); }

.field-editor { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field-editor textarea {
    flex-basis: 100%;
    padding: 6px 8px;
    border: 1px solid var(--accent);
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.45;
    resize: vertical;
    background: var(--surface);
    color: var(--text);
    outline: none;
}
/* A note is written as several lines, so it is shown as several lines. */
.detail-field .field-note { white-space: pre-wrap; }
.field-editor input, .field-editor select {
    flex: 1;
    min-width: 60px;
    padding: 4px 8px;
    border: 1px solid var(--accent);
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
}
.field-prefix { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 14px; color: var(--text-muted); }
.field-btn {
    background: none;
    border: none;
    padding: 2px;
    line-height: 0;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
}
.field-btn:hover { background: var(--surface-hover); color: var(--text); }
.field-save:hover { color: var(--btn-success); }
.field-cancel:hover { color: var(--btn-danger); }
.field-btn:disabled { opacity: 0.5; cursor: default; }
.field-hint { flex-basis: 100%; font-size: 12px; color: var(--text-muted); }

/* The accounts a user may switch to (users.js): one chip each, with the
   access it gives, and a picker for adding one more at the end. */
.detail-field .label-note { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-faint); margin-left: 4px; }
.account-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.account-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 3px 4px 3px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface-hover);
    font-size: 13px;
}
.account-chip:not([data-account]) { padding-right: 10px; }
.account-chip-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chip-role { font-size: 12px; color: var(--text-muted); }
.account-chip-access, .account-add {
    font: inherit;
    font-size: 12px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-input);
    border-radius: 999px;
    padding: 2px 8px;
    cursor: pointer;
}
.account-add { border-style: dashed; color: var(--text-muted); padding: 4px 10px; }
.account-add:hover, .account-add:focus { color: var(--text); border-color: var(--accent); }
.account-chip-access:focus, .account-add:focus { outline: none; border-color: var(--accent); }
.account-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}
.account-chip-remove:hover { background: var(--border-strong); color: var(--text); }
.accounts-field select:disabled, .accounts-field button:disabled { opacity: 0.6; cursor: default; }

/* Backup picker - sits below the detail grid rather than in it, since it
   holds live controls the grid's re-render must not discard. */
.detail-backup-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 20px 20px; }
.detail-backup-row:empty { display: none; }
.detail-backup-row label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.detail-backup-empty { font-size: 13px; color: var(--text-faint); }

.badge {
    display: inline-block;
    position: relative;
    overflow: hidden;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
    background: #eee;
    color: #555;
}
.badge-running { background: var(--badge-running-bg); color: var(--badge-running-text); }
.badge-shutoff { background: var(--badge-shutoff-bg); color: var(--badge-shutoff-text); }
.badge-paused  { background: var(--badge-paused-bg);  color: var(--badge-paused-text); }
.badge-crashed, .badge-error { background: var(--badge-error-bg); color: var(--badge-error-text); }
.badge-transitional { background: var(--badge-transitional-bg); color: var(--badge-transitional-text); }
/* Images tab statuses - same semantic colors as the VMs table's
   running/shutoff, reused rather than a separate palette. */
.badge-active { background: var(--badge-running-bg); color: var(--badge-running-text); }
.badge-used   { background: var(--badge-transitional-bg); color: var(--badge-transitional-text); }
.badge-unused, .badge-new { background: var(--badge-shutoff-bg); color: var(--badge-shutoff-text); }
/* Networks: up is fully routed, nat is up but behind NAT - a working state
   either way, so distinguished by hue rather than by one looking broken. */
.badge-up   { background: var(--badge-running-bg); color: var(--badge-running-text); }
.badge-nat  { background: var(--badge-transitional-bg); color: var(--badge-transitional-text); }
.badge-down { background: var(--badge-shutoff-bg); color: var(--badge-shutoff-text); }
/* Nodes: maintenance is up but deliberately not taking work - amber, like a
   paused VM. Asleep/shut down/inactive are simply off. */
.badge-maintenance { background: var(--badge-paused-bg); color: var(--badge-paused-text); }
.badge-asleep, .badge-shutdown, .badge-inactive, .badge-reboot { background: var(--badge-shutoff-bg); color: var(--badge-shutoff-text); }
/* Users. */
.badge-enabled  { background: var(--badge-running-bg); color: var(--badge-running-text); }
.badge-disabled { background: var(--badge-shutoff-bg); color: var(--badge-shutoff-text); }
/* Flex rather than vertical-align: an inline SVG has no text baseline, so
   it never lines up with the badge's text on its own. */
.icon-row { display: inline-flex; align-items: center; gap: 5px; }
.row-indicator { display: inline-flex; color: var(--text-faint); cursor: default; }
/* Indicators sit inline beside a status badge, so they stay smaller than
   the button icons above. */
.row-indicator svg { display: block; width: 14px; height: 14px; }

/* In-transit sweep, ported from iks-lifecycle-management's badge-progress -
   a discrete underline sweeping left to right, rather than a pulsing/
   blinking badge. currentColor so it matches whichever badge color it's
   nested in. */
.badge-progress::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -35%;
    height: 2px;
    width: 35%;
    background: currentColor;
    opacity: 0.5;
    border-radius: 0 1px 1px 0;
    animation: badge-progress 1.4s ease-in-out infinite;
}
@keyframes badge-progress {
    0%   { left: -35%; }
    100% { left: 100%; }
}

.empty-state { padding: 48px; text-align: center; color: var(--text-muted); }

/* ── Toasts ────────────────────────────────────────────────────────────── */
/* Anchored to the header (which is position:relative) rather than the
   viewport, so a toast reads as part of the top bar: vertically centred on
   the title's line, and starting just clear of the wordmark. Absolute, so
   showing one never changes the header's own layout. */
#toast-container {
    position: absolute;
    left: 130px;
    top: 7px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
.toast {
    background: #333;
    color: #fff;
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 13px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    max-width: 44vw;
    line-height: 1.5;
}
.toast-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toast.visible { opacity: 1; transform: translateY(0); }
/* A toast, or a notification, that leads somewhere when clicked. */
.toast-link { cursor: pointer; }
.toast-link .toast-text { text-decoration: underline; text-underline-offset: 2px; }
.notif-item-link { cursor: pointer; }
.notif-item-link .notif-msg { text-decoration: underline; text-underline-offset: 2px; }
/* Severity is carried by the bar, not the background - the same four
   colours the notification history uses, so a toast and its history entry
   read as the same thing. */
.toast { border-left: 4px solid #3b82f6; }
.toast.success { border-left-color: #22c55e; }
.toast.warn    { border-left-color: #f59e0b; }
.toast.error   { border-left-color: #ef4444; }

/* ── Form dialogs (the "+ Add" buttons, see openFormModal in common.js) ──
   Ported from iks-lifecycle-management's .modal-overlay/.modal-box. */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 16px 16px;
    overflow-y: auto;
    z-index: 1000;
}
/* A tall dialog - Install stack - starts near the top instead. */
.modal-overlay.modal-overlay-top { padding-top: 24px; }
.modal-box {
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    padding: 24px 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
.modal-box.modal-wide { max-width: 900px; }
/* Two fields to a row where there is room for them, one where there is
   not - and never a field stretched the whole width of a wide dialog. */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    column-gap: 28px;
}
.field-grid > .modal-field { min-width: 0; }
.modal-wide .modal-field input,
.modal-wide .modal-field select,
.modal-wide .modal-field .modal-input-unit { max-width: 420px; }
/* What a stack says about itself, above the settings it comes with. */
/* The logo on top, so what the stack says has the card's whole width. */
.stack-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    padding: 14px 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-hover);
    min-height:300px;
}
.stack-thumb { width: 96px; height: auto; flex: none; align-self: center; border-radius: 6px; }
.stack-about { min-width: 0; width: 100%; }
.stack-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.stack-version { color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.stack-title .detail-link { font-size: 12px; font-weight: 400; margin-left: 8px; }
.stack-desc {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
    max-height: 320px;
    overflow-y: auto;
}
.stack-desc a { color: var(--accent); text-decoration: none; }
.stack-desc a:hover { text-decoration: underline; }
.stack-desc p:first-child { margin-top: 0; }
.stack-desc ul, .stack-desc ol { padding-left: 20px; margin: 8px 0; }
.stack-desc img { max-width: 100%; }
.stack-desc h1, .stack-desc h2, .stack-desc h3, .stack-desc h4 { font-size: 13px; color: var(--text); margin: 10px 0 4px; }
/* Engine settings, from the user menu. */
.settings-heading {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 22px 0 12px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.modal-body > .settings-heading:first-child,
.settings-intro + .settings-heading { margin-top: 0; padding-top: 0; border-top: none; }
.settings-intro { margin: -6px 0 18px; }
/* The filter at the top of the settings, and what it leaves out. */
.settings-filter {
    width: 100%; box-sizing: border-box; padding: 7px 12px; margin: 0 0 14px;
    border: 1px solid var(--border-input); border-radius: 6px; font-size: 14px; font-family: inherit;
    background: var(--surface); color: var(--text); outline: none;
}
.settings-filter:focus { border-color: var(--accent); }
/* The install dialog's stack picker: a select that can show a stack's tags. */
.stack-pick { position: relative; max-width: 560px; }
.stack-pick-button {
    display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box;
    padding: 6px 10px 6px 12px; min-height: 37px; text-align: left; cursor: pointer;
    border: 1px solid var(--border-input); border-radius: 6px; font-size: 14px; font-family: inherit;
    background: var(--surface); color: var(--text); outline: none;
}
.stack-pick-button:focus, .stack-pick.open .stack-pick-button { border-color: var(--accent); }
.stack-pick-current { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; flex: 1; min-width: 0; }
.stack-pick-chevron { color: var(--text-muted); font-size: 11px; }
.stack-pick-list {
    position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 1100;
    display: flex; flex-direction: column; max-height: 360px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}
.stack-pick-list[hidden] { display: none; }
/* The search stays put at the top; the stacks scroll under it. */
.modal-field .stack-pick-search {
    flex: none; margin: 8px; width: auto; padding: 6px 10px; font-size: 13px;
}
.stack-pick-options { overflow-y: auto; padding: 0 0 4px; }
.stack-pick-none { padding: 10px 12px 12px; font-size: 13px; color: var(--text-muted); }
.stack-pick-group {
    padding: 6px 12px 3px; font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-muted);
}
.stack-pick-option {
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px;
    padding: 6px 12px 6px 20px; font-size: 14px; cursor: pointer;
}
.stack-pick-option.active { background: var(--surface-hover); }
.stack-pick-option[aria-selected=true] { background: var(--surface-selected); }
.stack-pick-name { white-space: nowrap; }
.stack-pick .stack-tags { display: inline-flex; margin: 0; gap: 4px; }
.stack-pick .stack-tag { font-size: 11px; padding: 2px 7px; }
.stack-pick-where { margin-left: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
/* A stack's tags, under its name on its card. */
.stack-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 10px; }
.stack-tags:empty { display: none; }
.stack-tag {
    font-size: 12px; line-height: 1; padding: 4px 9px; border-radius: 999px;
    background: var(--tone-slate-bg); color: var(--tone-slate-fg); border: 1px solid var(--tone-slate-bd);
}
.settings-filtered { display: none !important; }
.settings-note { margin: -6px 0 14px; }
.settings-check-hint { margin: -10px 0 14px 24px; }
.settings-static {
    font-size: 14px;
    padding: 8px 0;
    color: var(--text-muted);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    overflow-wrap: anywhere;
}
.settings-link-state { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.settings-link-state .badge { margin-right: 6px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.settings-link-form { margin-bottom: 4px; }
/* The warning above the restore fields needs room of its own. */
#settings-restore-fold > .modal-hint { margin: 0 0 18px; max-width: 70ch; }
#settings-backups .data-table { margin-bottom: 18px; }
#settings-backups .cell-actions { text-align: right; white-space: nowrap; }
.settings-restore-row > td { padding-top: 14px; }

/* About, from the user menu. */
.modal-box.modal-about { max-width: 840px; }
.about { text-align: center; }
.about-mark { height: 40px; width: auto; margin-bottom: 14px; }
.about-lead { font-size: 13px; line-height: 1.6; color: var(--text-muted); margin: 0 0 12px; }
.about-facts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 18px 0 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.about-facts span { display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.about-facts strong {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
}
.about-section { text-align: left; border-top: 1px solid var(--border-strong); margin-top: 20px; padding-top: 16px; }
/* The command line's install command: one line to copy, scrolled sideways
   rather than wrapped, since a wrapped command reads as two. */
.about-cli { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; }
.about-cli code {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    padding: 8px 10px;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 12px;
    background: var(--bg-subtle, rgba(127,127,127,0.12));
    border: 1px solid var(--border-strong);
    border-radius: 6px;
}
.about-cli .btn { flex-shrink: 0; }
.about-section code { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; }
.about-section h3 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 12px;
}
.about-kind { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 12px 0 6px; }
.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 5px 20px;
    font-size: 12.5px;
    color: var(--text-muted);
}
.about-grid strong { color: var(--text); font-weight: 600; }
.about-note { font-size: 12px; line-height: 1.6; color: var(--text-faint); margin: 16px 0 0; }
.about-note a, .about-lead a { color: var(--accent); text-decoration: none; }
.about-warn { color: var(--badge-error-text); }
.about-note a:hover, .about-lead a:hover { text-decoration: underline; }

/* A page of a VM's own - a stack's management interface, its terminal -
   framed here rather than taken to a tab of its own (openFrameModal). */
.frame-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.55);
    display: flex;
    padding: 4vh 4vw;
}
.frame-modal {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4);
}
.frame-modal-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    /* The theme's own surface, light or dark, not the page header's. */
    background: var(--surface-hover);
    color: var(--text);
    border-bottom: 1px solid var(--border-strong);
    flex-shrink: 0;
}
.frame-modal-title { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frame-modal-popout, .frame-modal-close {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    padding: 2px 4px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.frame-modal-close { font-size: 20px; }
.frame-modal-popout:hover, .frame-modal-close:hover { color: var(--text); }
.frame-modal-body { flex: 1; width: 100%; border: 0; background: #fff; }
/* The pop-out beside a link that frames: same icon as the stacks table. */
.detail-popout { color: var(--text-faint); display: inline-flex; vertical-align: -2px; margin-left: 4px; }
.detail-popout:hover { color: var(--accent); }
@media (max-width: 700px) {
    .frame-overlay { padding: 0; }
    .frame-modal { border-radius: 0; }
}

/* A label with something to say: marked quietly, explained on hover or
   focus (see helpMark in common.js). */
.has-help {
    border-bottom: 1px dotted var(--text-faint);
    cursor: help;
    outline-offset: 3px;
}
.has-help:hover, .has-help:focus { border-bottom-color: var(--accent); color: var(--text); }
.help-tip {
    position: fixed;
    z-index: 1300;
    max-width: 340px;
    padding: 12px 14px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.22);
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    transition: opacity 0.12s ease-out;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}
.help-tip.visible { opacity: 1; }
.help-tip-title { font-weight: 600; margin-bottom: 4px; }
.help-tip-text { color: var(--text-muted); }
.help-tip-more { display: inline-block; margin-top: 8px; color: var(--accent); text-decoration: none; font-size: 12px; }
.help-tip-more:hover { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) {
    .help-tip { transition: none; }
}

/* Why a stack cannot be installed yet - it is still arriving, or what it
   is built on is. */
#stack-download-note {
    margin: 0 0 20px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-left: 3px solid #f59e0b;
    border-radius: 6px;
    background: var(--surface-hover);
    color: var(--text);
    line-height: 1.5;
}

/* Where a field sits when it is not folded away - see applySettings. */
.field-slot { display: none; }
.modal-box h2 { font-size: 16px; font-weight: 600; margin: 0 0 20px; }
.modal-field { margin-bottom: 16px; }
/* While the dialog waits for the API to say what it can offer: the
   fields' shape, so the dialog is already the size it will be. */
.modal-loading .placeholder-label {
    display: block;
    width: 84px;
    height: 11px;
    margin-bottom: 7px;
    border-radius: 3px;
    background: var(--surface-hover);
}
.modal-loading .placeholder-control {
    display: flex;
    align-items: center;
    height: 37px;
    padding: 0 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    background: var(--surface-hover);
    color: var(--text-muted);
    font-size: 14px;
}

.modal-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.modal-field input, .modal-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
}
.modal-field input:focus, .modal-field select:focus { border-color: var(--accent); }
/* An input with its unit alongside ("20  GB"). */
.modal-input-unit { display: flex; align-items: center; gap: 8px; }
/* A number field with the usual values behind a chevron (see sizeCombo in
   common.js) - what Stabile's ComboBox did, and what a datalist cannot:
   a browser filters those against what is already typed. */
.combo { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.combo input { width: 100%; padding-right: 26px; -moz-appearance: textfield; appearance: textfield; }
/* No native spinner: it steps by the field's step, not by the ladder. */
.combo input::-webkit-outer-spin-button,
.combo input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.combo-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 24px;
    background: none;
    border: none;
    border-radius: 0 6px 6px 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
}
.combo-toggle:hover { color: var(--text); background: var(--surface-hover); }
.combo-list {
    display: none;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    max-height: 210px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
    z-index: 1100;
    flex-direction: column;
    padding: 4px 0;
}
.combo.open .combo-list { display: flex; }
.combo-option {
    background: none;
    border: none;
    text-align: left;
    padding: 6px 12px;
    font-size: 13px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    cursor: pointer;
}
.combo-option:hover { background: var(--surface-hover); }
/* In a detail pane the editor is tighter than a dialog's field. */
.field-editor .combo { flex: 1; }
.modal-input-unit span { font-size: 13px; color: var(--text-muted); }
/* The fixed part of an address, ahead of the part you may change. */
.modal-input-unit .modal-prefix { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 14px; }
.modal-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.modal-error {
    font-size: 13px;
    color: var(--badge-error-text);
    background: var(--badge-error-bg);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 16px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
/* A yes/no choice in a dialog - the whole line is the label, so the words
   are part of the target. Ported from iks-lifecycle-management's
   .modal-check. */
.modal-check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 16px; cursor: pointer; }
/* The settings most people never change, folded away until wanted. The
   marker is our own chevron so it matches the tables' (see .tree-toggle). */
.modal-more { margin: 4px 0 18px; border-top: 1px solid var(--border-strong); padding-top: 12px; }
.modal-more > summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.modal-more > summary::-webkit-details-marker { display: none; }
.modal-more > summary::before { content: '\25B8'; font-size: 15px; line-height: 1; }
.modal-more[open] > summary::before { content: '\25BE'; }
.modal-more > summary:hover { color: var(--text); }
.modal-more[open] > summary { margin-bottom: 14px; }
.modal-check input { margin: 0; cursor: pointer; }
/* A sentence a dialog says before what it asks. */
.modal-text { font-size: 14px; line-height: 1.5; color: var(--text); margin: 0 0 16px; }
/* A checkbox row inside a field - a list of things to pick - is still a
   checkbox row: the field's own label and input rules are for its heading
   and its text box, not for these. */
.modal-field .modal-check {
    display: flex; font-size: 13px; font-weight: 400; text-transform: none;
    letter-spacing: normal; color: var(--text); margin-bottom: 0;
}
.modal-field .modal-check input {
    width: auto; flex: none; padding: 0; border: none; border-radius: 0; background: none;
}
/* Mode switch inside a dialog (the images tab's Add image: empty disk,
   upload, URL) - one form, three ways to fill it in. */
.modal-tabs {
    display: flex;
    gap: 4px;
    margin: -4px 0 18px;
    border-bottom: 1px solid var(--border-strong);
}
.modal-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-family: inherit;
    padding: 7px 10px;
    cursor: pointer;
}
.modal-tab:hover { color: var(--text); }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.modal-label-note { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-faint); }
.modal-field input[type=file] { padding: 7px 10px; font-size: 13px; }
.modal-progress { margin-bottom: 16px; }
.modal-progress-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--surface-hover);
    border: 1px solid var(--border-strong);
    overflow: hidden;
}
.modal-progress-bar span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 0.15s linear;
}
@media (max-width: 600px) {
    .modal-overlay { padding-top: 16px; }
    .modal-box { padding: 20px; }
}

/* ── VM console modal (noVNC) - always dark, like the header, regardless
   of theme: a VNC framebuffer has its own colors either way. ──────────── */
.console-modal {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: #000;
    display: flex;
    flex-direction: column;
}
.console-modal-bar {
    background: var(--header-bg);
    color: #fff;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.console-modal-title { font-size: 13px; font-weight: 600; }
.console-modal-status { font-size: 12px; color: rgba(255,255,255,0.6); flex: 1; }
.console-modal-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    padding: 2px 8px;
    cursor: pointer;
    opacity: 0.75;
}
.console-modal-close:hover { opacity: 1; }
.console-modal-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
.console-modal-body canvas { max-width: 100%; max-height: 100%; }

/* ── Node terminal (xterm.js) - the console's overlay and bar, with a
   terminal filling what is under it. Above the console in the stack only
   in that it comes later. ─────────────────────────────────────────────── */
.terminal-modal { background: #0d1117; }
.terminal-modal-body { flex: 1; min-height: 0; padding: 8px; overflow: hidden; }
.terminal-holder { width: 100%; height: 100%; }
.terminal-modal-btn { flex-shrink: 0; }
#nodes-detail-terminal { display: flex; gap: 6px; }
.terminal-modal .btn-outline { color: #fff; border-color: rgba(255,255,255,0.4); background: transparent; }
.terminal-modal .btn-outline:hover { background: rgba(255,255,255,0.12); }
.terminal-modal-popout {
    color: #fff;
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
    text-decoration: none;
    opacity: 0.75;
}
.terminal-modal-popout:hover { opacity: 1; }
/* The extra keys: one row under the terminal, scrolled sideways where it
   does not fit. */
.terminal-modal-keys {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
    opacity: 0.6;
}
.terminal-modal-keys:hover, .terminal-modal-keys.on { opacity: 1; }
.terminal-keys {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    background: #161b22;
    border-top: 1px solid #30363d;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.terminal-key {
    flex: 0 0 auto;
    min-width: 40px;
    padding: 8px 10px;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 13px;
    line-height: 1;
    color: #c9d1d9;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.terminal-key:active { background: #30363d; }
.terminal-key.on { background: #1f6feb; border-color: #1f6feb; color: #fff; }
/* In a tab of its own there is nothing behind it to cover. */
.terminal-standalone { z-index: auto; }
.console-standalone { z-index: auto; }
/* An action with its pop-out: the button, and beside it a small icon that
   opens the same in a window of its own - as Docs and API have in the
   tab bar. */
.btn-pair { display: inline-flex; align-items: center; gap: 3px; }
.action-popout {
    display: inline-flex; align-items: center; padding: 2px; color: var(--text-faint);
    opacity: 0.8; text-decoration: none; line-height: 1;
}
.action-popout:hover { color: var(--accent); opacity: 1; }

/* ════════════════════════════════════════════════════════════════════════
   Narrow screens
   Kept together, and last, so these win over the rules above without
   specificity games. The tab bar's own collapse lives with the tab bar.
   ════════════════════════════════════════════════════════════════════════ */

/* A detail pane replaces its table rather than sitting under it. On a wide
   screen the table collapses to a few rows beside the pane; on a phone
   that leaves a sliver of table and a pane pushed off the bottom of the
   screen. Closing the pane brings the table back. Ported from
   iks-lifecycle-management. */
@media (max-width: 750px) {
    .tab-panel.detail-visible .card:not(.detail-panel),
    .tab-panel.detail-visible .filter-bar { display: none; }
    .tab-panel.detail-visible .detail-panel { margin-top: 4px; }
}

@media (max-width: 700px) {
    header { padding: 10px 14px; }

    /* Toasts hang just below the header across the full width - at
       left:130px they started halfway across a phone and ran off it. */
    #toast-container {
        left: 12px;
        right: 12px;
        top: calc(100% + 8px);
        transform: none;
        align-items: stretch;
    }
    .toast { max-width: none; }

    /* No card around the embedded page here - on a phone the border and
       shadow just cost width and read as a box inside a box. */
    .embed-frame {
        height: calc(100vh - 130px);
        height: calc(100dvh - 130px);
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
}

@media (max-width: 600px) {
    /* An email address is most of a phone's width. Truncated rather than
       hidden, so the menu still says whose session it is. */
    #header-user {
        display: inline-block;
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: bottom;
    }

    /* Anchored to the viewport: anchored to the bell, a 340px panel ran off
       the left edge of the screen. */
    .notif-panel { position: fixed; top: 54px; left: 12px; right: 12px; width: auto; }

    /* Search gets a row to itself; the dropdowns share the next. */
    .filter-bar input[type=text] { flex-basis: 100%; min-width: 0; }
    .filter-bar select { flex: 1 1 0; min-width: 0; }

    .data-table th, .data-table td { padding-left: 10px; padding-right: 10px; }

    /* Detail header stacks: name and close button on one row, actions below.
       display:contents lifts the actions, console button and close button
       out of their wrapper so they can be ordered around the name. */
    .detail-header { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
    /* The wide-screen space-between would otherwise spread the stacked
       action row, pinning Console left and the rest right. */
    .detail-header { justify-content: flex-start; }
    .detail-header h2 { order: 0; flex: 1 1 calc(100% - 48px); min-width: 0; overflow-wrap: anywhere; }
    .detail-header-right { display: contents; }
    .detail-close-btn { order: 1; }
    .detail-header-right > :not(.detail-close-btn) { order: 2; }
    .detail-actions { justify-content: flex-start; }

    /* Two narrow columns of facts beat one wide one. */
    .detail-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; padding: 14px; }
    .detail-break { margin-bottom: -14px; }
    .detail-backup-row { padding: 0 14px 14px; }
    .detail-backup-row select { flex: 1 1 160px; min-width: 0; }
}

@media (max-width: 420px) {
    #header-user { max-width: 70px; }
    .header-wordmark { font-size: 20px; }
}

/* Home tab - as iks-lifecycle-management's: a greeting, then cards. */
.home-head { padding: 4px 0 18px; }
.home-greeting { font-size: 22px; font-weight: 700; color: var(--text); }
.home-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.home-card { margin-bottom: 16px; }
/* Home's tab bar sits on the page, above the card it switches. */
.home-tabs > .detail-tabs { padding: 0; margin-bottom: 14px; }
/* Status (home.js) - the cards of iks-lifecycle-management's home: a
   label, a figure, a line or two under it. Each leads to its tab. */
.home-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.home-stat-card {
    display: block;
    min-width: 0;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
}
a.home-stat-card:hover { border-color: var(--accent); }
.home-stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }
.home-stat-scope { text-transform: none; font-weight: 400; letter-spacing: 0; }
.home-stat-value { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.home-stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 5px; line-height: 1.4; }
/* Health is words rather than a figure, and takes the room of two cards
   - where there are two: one column has no second to span. */
.home-health-card { grid-column: 1 / 3; }
.home-health { display: flex; flex-direction: column; gap: 6px; }
.home-health-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    text-align: left;
}
.home-health-head:hover .home-health-name { color: var(--text); }
.home-health-chev { display: inline-block; width: 11px; font-size: 10px; }
.home-health-word { font-weight: 600; white-space: nowrap; }
.home-health-ok { color: var(--btn-success); }
.home-health-warn { color: var(--btn-warning); }
.home-health-bad { color: var(--btn-danger); }
.home-health-busy { color: var(--accent); }
.home-health-none { color: var(--text-muted); }
.home-health-detail { margin: 4px 0 4px 15px; font-size: 12px; color: var(--text); line-height: 1.55; overflow-wrap: anywhere; }
.home-health-note { margin-top: 4px; color: var(--text-muted); }
@media (max-width: 460px) { .home-health-card { grid-column: auto; } }

.home-panel-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 12px 6px;
}

/* Usage (usage.js) - the account's on Home, one stack's or VM's in its
   detail pane. */
.usage-pane { padding: 6px 0 0; }
.usage-table { width: 100%; }
.usage-table .meter { max-width: 260px; }
.usage-table tfoot td { font-weight: 600; border-bottom: none; }
.usage-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.usage-of { color: var(--text-muted); }
.usage-note { padding: 12px 18px 16px; font-size: 12px; color: var(--text-muted); }

/* Software (software.js) - on Home, and in a stack's or VM's pane. */
.software-tools { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 0; }
.software-tools:empty { display: none; }
.software-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 16px 18px 8px;
}
.software-csv { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--accent); text-decoration: none; }
.software-csv:hover { text-decoration: underline; }
.software-count { font-weight: 500; letter-spacing: 0; }
.software-heading-tools { margin-left: auto; display: flex; gap: 8px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.software-filter { width: 180px; font-size: 12px; padding: 4px 8px; }
.software-show { font-size: 12px; padding: 3px 6px; }
.software-tools { align-items: center; flex-wrap: wrap; }
.software-schedule { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; font-size: 13px; }
.software-schedule[hidden] { display: none; }
.software-schedule select { font-size: 13px; padding: 4px 6px; }
.software-schedule-note { padding-top: 8px; padding-bottom: 0; }
/* An update waiting, in the package list and the OS list. */
.software-new { color: var(--accent); white-space: nowrap; }
.software-sec { color: var(--btn-warning); font-weight: 600; }
.software-restart {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 9px;
    border: 1px solid var(--btn-warning);
    color: var(--btn-warning);
    white-space: nowrap;
}
.software-table { width: 100%; }
.software-table + .software-heading { margin-top: 22px; }

/* A stack's VMs in its pane (membersHtml in systems.js), each with a way
   out of the stack, and a picker for putting one in. */
.stack-members { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.stack-member { display: inline-flex; align-items: center; gap: 2px; }
.stack-member-remove {
    background: none;
    border: none;
    padding: 0 3px;
    font-size: 15px;
    line-height: 1;
    color: var(--text-faint);
    cursor: pointer;
}
.stack-member-remove:hover { color: var(--btn-danger); }
.stack-member-add { font-size: 12px; padding: 3px 6px; }
.newstack-vms { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.newstack-vms .modal-check { margin: 0; }

/* Metrics (metrics.js) - a stack's or VM's charts, in its pane. */
.metrics-tools { display: flex; flex-wrap: wrap; gap: 0; padding: 12px 18px 4px; }
.metrics-range {
    padding: 4px 12px;
    font-size: 12px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    margin-left: -1px;
    cursor: pointer;
}
.metrics-range:first-child { margin-left: 0; border-radius: 5px 0 0 5px; }
.metrics-range:last-child { border-radius: 0 5px 5px 0; }
.metrics-ranges { display: flex; flex-wrap: wrap; }
.metrics-range:hover { color: var(--text); }
.metrics-range.active { color: var(--accent); border-color: var(--accent); font-weight: 600; position: relative; z-index: 1; }
.metrics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; padding: 12px 18px 4px; }
@media (max-width: 900px) { .metrics-grid { grid-template-columns: minmax(0, 1fr); } }
.metrics-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.metrics-title { font-size: 13px; font-weight: 600; color: var(--text); }
.metrics-unit { font-size: 12px; color: var(--text-muted); }
.metrics-now { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.metrics-plot { position: relative; height: 180px; }
.metrics-tools { align-items: center; }
.metrics-refresh {
    margin-left: auto;
    padding: 5px 7px;
    line-height: 0;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    cursor: pointer;
}
.metrics-refresh:hover { color: var(--accent); border-color: var(--accent); }
.metrics-refresh:disabled { cursor: default; opacity: 0.7; }
.metrics-refresh svg.spin { animation: btn-spin 0.7s linear infinite; }
.metrics-live {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-family: inherit;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    cursor: pointer;
}
.metrics-live + .metrics-refresh { margin-left: 8px; }
.metrics-live:hover { color: var(--text); }
.metrics-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.metrics-live.active { color: var(--text); border-color: var(--btn-success); font-weight: 600; }
.metrics-live.active .metrics-live-dot { background: var(--btn-success); animation: metrics-live 1.6s ease-in-out infinite; }
@keyframes metrics-live { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .metrics-live.active .metrics-live-dot { animation: none; } }

/* Monitoring (monitors.js) - the checks on a VM, and how each stands. */
.mon-state { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.mon-up { color: var(--btn-success); }
.mon-down { color: var(--btn-danger); }
.mon-failing { color: var(--btn-warning); }
.mon-unknown, .mon-off { color: var(--text-muted); font-weight: 500; }
.mon-acked { font-size: 11px; padding: 1px 6px; border-radius: 9px; border: 1px solid var(--border-strong); color: var(--text-muted); }
.mon-where { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; overflow-wrap: anywhere; }
.mon-actions { white-space: nowrap; text-align: right; }
.mon-btn {
    background: none;
    border: none;
    padding: 3px 5px;
    line-height: 0;
    color: var(--text-faint);
    cursor: pointer;
    border-radius: 4px;
}
.mon-table tr:hover .mon-btn { color: var(--text-muted); }
.mon-btn:hover { color: var(--accent) !important; }
.mon-btn-danger:hover { color: var(--btn-danger) !important; }
.mon-history { margin: 16px 18px 12px; font-size: 13px; }
.mon-history summary { cursor: pointer; color: var(--text-muted); }
.mon-history .software-table { margin-top: 8px; }
.mon-when { white-space: nowrap; color: var(--text-muted); width: 1%; }
.mon-kind-hint { display: block; }
/* An uptime percentage: bold, and in the colour of how good it is. */
.mon-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.mon-pct-good { color: var(--btn-success); }
.mon-pct-fair { color: var(--btn-warning); }
.mon-pct-poor { color: var(--btn-danger); }
.mon-since { font-weight: 400; margin-left: 4px; white-space: nowrap; }
/* When it was last checked and what was found: the column that gives way
   as the table narrows. It may break anywhere - a device's name or an
   address has no spaces to break at - so it never holds the table wider
   than the pane. */
.mon-last { overflow-wrap: anywhere; word-break: break-word; }
/* A monitor's row opens to what its last check found. */
.mon-row { cursor: pointer; }
.mon-caret { display: inline-block; width: 12px; color: var(--text-faint); transition: transform 0.12s; }
.mon-row:hover .mon-caret { color: var(--accent); }
.mon-row.open .mon-caret { transform: rotate(90deg); color: var(--accent); }
.mon-row.open td { border-bottom-color: transparent; }
.mon-detail > td { padding: 0 14px 16px 26px; background: var(--surface); }
.mon-detail-body { border-left: 2px solid var(--border-strong); padding: 2px 0 2px 16px; }
.mon-detail-head { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.mon-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 18px; margin-bottom: 12px; }
.mon-fact label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 2px; }
.mon-fact span { font-size: 13px; }
.mon-phases { margin: 4px 0 14px; max-width: 720px; }
.mon-phase-bar { display: flex; height: 10px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--surface); }
.mon-phase-bar span { display: block; min-width: 2px; }
.mon-phase-key { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.mon-phase-key i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.mon-phase-key b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.mon-chart-title { font-size: 12px; font-weight: 600; color: var(--text); margin: 6px 0 4px; }
.mon-chart { position: relative; height: 150px; max-width: 720px; margin-bottom: 12px; }
.mon-disks { max-width: 560px; margin-bottom: 12px; }
.mon-headers { margin-top: 6px; }
.mon-headers-out { margin-top: 10px; }
.mon-step { margin-bottom: 12px; }
.mon-step-line { font-size: 13px; margin-bottom: 4px; }
.mon-header-table { border-collapse: collapse; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; }
.mon-header-table td { padding: 2px 14px 2px 0; vertical-align: top; overflow-wrap: anywhere; }
.mon-header-table td:first-child { color: var(--text-muted); white-space: nowrap; }
/* A certificate about to run out. A warning, with its sign, not a state. */
.mon-cert { font-size: 11px; font-weight: 600; color: var(--btn-warning); white-space: nowrap; margin-left: 4px; }

/* The audit log. */
.audit-scope { margin: -6px 0 10px; }
.audit-table .audit-row { cursor: pointer; }
/* The short columns keep to one line each, and the result - the one with
   prose in it - takes what is left and wraps there, rather than a long
   message squeezing the rest into wrapping. */
.audit-table .audit-row > td { white-space: nowrap; vertical-align: top; }
.audit-table .audit-row > td.audit-result { white-space: normal; width: 100%; min-width: 220px; }
.audit-table .audit-when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.audit-table .audit-message { color: var(--text-muted); font-size: 13px; vertical-align: top; }
.audit-table .audit-target-cell { white-space: nowrap; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; }
.audit-table .audit-detail > td { background: var(--surface-selected); }
.audit-request {
    margin: 0; padding: 8px 10px; border-radius: 6px; max-height: 260px; overflow: auto;
    background: var(--bg); border: 1px solid var(--border); font-size: 12px;
    font-family: 'IBM Plex Mono', ui-monospace, monospace; white-space: pre-wrap;
}
.audit-more { margin-top: 12px; }

/* Traffic: a sparkline and the figure beside it (common.js's
   trafficSparkline, after iks-lifecycle-management's). */
.traffic-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.traffic-figure { font-size: 13px; font-variant-numeric: tabular-nums; }
.sparkline { vertical-align: middle; }
.sparkline-line { fill: none; stroke: var(--accent); stroke-width: 1.25; stroke-linejoin: round; stroke-linecap: round; opacity: 0.85; }
.sparkline-flat { stroke: var(--border-strong); stroke-width: 1; }
.traffic-spark-big { margin-top: 4px; }
.traffic-none { color: var(--text-faint); }

/* ── Home: the fleet, and the busiest VMs (home.js) ─────────────────────── */
.home-fleet {
    margin-bottom: 18px; padding: 20px 22px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, var(--surface)) 0%, var(--surface) 60%);
    border-top: 3px solid var(--accent);
}
.home-fleet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.home-fleet-title { font-size: 17px; font-weight: 700; color: var(--text); }
.home-fleet-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; max-width: 760px; }
.home-fleet-more { white-space: nowrap; font-size: 13px; }

.home-gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.home-gauge {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 12px 8px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
}
.home-gauge-ring { position: relative; width: 84px; height: 84px; }
.home-gauge-track { fill: none; stroke: var(--border-strong); stroke-width: 8; }
.home-gauge-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.home-gauge-value {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 19px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums;
}
.home-gauge-label { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: 0.5px; }
.home-gauge-caption { margin-top: 3px; font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* How full: green, amber, red - the same words as the health card's. */
.home-level-ok .home-gauge-fill { stroke: var(--btn-success); }
.home-level-warn .home-gauge-fill { stroke: var(--btn-warning); }
.home-level-bad .home-gauge-fill { stroke: var(--btn-danger); }
.home-level-none .home-gauge-fill { stroke: var(--border-strong); }

.home-node-list { display: flex; flex-direction: column; }
.home-node-row {
    display: grid; grid-template-columns: minmax(140px, 1.4fr) repeat(4, minmax(90px, 1fr)) minmax(110px, auto);
    align-items: center; gap: 14px; padding: 7px 8px; border-radius: 6px;
    color: var(--text); text-decoration: none; font-size: 13px;
}
a.home-node-row:hover { background: var(--surface-hover); }
.home-node-headrow { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding-bottom: 3px; }
.home-node-off { color: var(--text-muted); }
.home-node-more { display: block; color: var(--accent); font-size: 12px; }
.home-node-name { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-node-status { font-size: 11px; color: var(--text-muted); }
.home-node-meter { display: flex; align-items: center; gap: 8px; }
.home-node-vms { font-size: 12px; color: var(--text-muted); white-space: nowrap; text-align: right; }
.home-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.home-dot-on { background: var(--btn-success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn-success) 22%, transparent); }
.home-dot-off { background: var(--border-strong); }

.home-bar { position: relative; flex: 1; height: 6px; border-radius: 3px; background: var(--border-strong); overflow: hidden; }
.home-bar > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; transition: width 0.6s ease; }
.home-level-ok > span { background: var(--btn-success); }
.home-level-warn > span { background: var(--btn-warning); }
.home-level-bad > span { background: var(--btn-danger); }
.home-bar-figure { width: 36px; text-align: right; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.home-busy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 20px; }
.home-busy-card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow); }
.home-busy-row {
    display: grid; grid-template-columns: 1fr 84px 76px; align-items: center; gap: 12px;
    padding: 6px 6px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 13px;
}
.home-busy-row:hover { background: var(--surface-hover); }
.home-busy-row + .home-busy-row { border-top: 1px solid var(--border-strong); }
.home-busy-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.home-busy-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.home-busy-empty { font-size: 13px; color: var(--text-muted); padding: 6px 0; }

@media (max-width: 760px) {
    .home-node-row { grid-template-columns: minmax(110px, 1fr) repeat(4, minmax(64px, 1fr)); }
    .home-node-vms, .home-node-headrow span:last-child { display: none; }
    .home-fleet-head { flex-direction: column; }
}
@media (max-width: 460px) {
    .home-node-row { grid-template-columns: 1fr 1fr; }
    .home-node-row > .home-node-meter:nth-child(n+3), .home-node-headrow span:nth-child(n+3) { display: none; }
}
/* A busiest VM someone else owns: shown, not linked. */
.home-busy-other:hover { background: none; }
.home-busy-owner { font-weight: 400; font-size: 11px; color: var(--text-muted); margin-left: 4px; }

/* Home's Recommended reading: beside the health card, as wide. */
.home-reading-card { grid-column: span 2; display: flex; flex-direction: column; }
.home-reading { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.home-reading-item {
    display: flex; flex-direction: column; gap: 1px; padding: 6px 8px 6px 10px;
    border-left: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 0 6px 6px 0; text-decoration: none;
}
.home-reading-item:hover { background: var(--surface-hover); border-left-color: var(--accent); }
.home-reading-title { font-size: 13px; font-weight: 600; color: var(--accent); }
.home-reading-about { font-size: 12px; color: var(--text-muted); }
.home-reading-all { margin-top: 10px; font-size: 12px; align-self: flex-start; }
@media (max-width: 460px) { .home-reading-card { grid-column: auto; } }

/* Home's Free for new VMs (administrators). */
.home-room-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.15; font-variant-numeric: tabular-nums; }
.home-room-full { font-size: 22px; font-weight: 700; color: var(--btn-danger); line-height: 1.15; }
.home-room-list { margin-top: 10px; border-top: 1px solid var(--border-strong); padding-top: 6px; display: flex; flex-direction: column; }
.home-room-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-muted); text-decoration: none; padding: 2px 0; }
.home-room-row:hover { color: var(--accent); }
.home-room-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-room-gpu { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border-strong); }
.home-room-second { font-size: 17px; }
.home-room-others { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
