/* MAGIX Platform admin UI: one stylesheet for every page.

   Rules this file lives by (the CSP is style-src 'self'):
   - No inline style attributes in the HTML. Layout and state are classes.
   - JS may still set a few values through CSSOM (el.style.width for progress bars and the
     console font size). That is allowed under the CSP; setting style="" in markup is not.
   - Colours are tokens on :root. Dark mode redefines them under prefers-color-scheme, guarded
     so that an explicit data-theme="light" wins (no theme switcher yet, but the hook is here).
   - Desktop tool: designed for 1024 px and up, and it stays usable (wraps, scrolls inside
     tables) below that. */

:root {
  /* surfaces and text: neutral greys, one blue accent */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e0e4eb;
  --text: #151a22;
  --text-muted: #5d6776;
  --link: #2563eb;
  --focus: #2563eb;
  --focus-ring: rgba(37, 99, 235, 0.28);
  --row-hover: #f7f9fc;

  /* accent: primary buttons, the active sidebar item and tab underline */
  --accent: #2563eb;
  --accent-hover: #1d4fd0;
  --accent-press: #1842b0;
  --accent-text: #ffffff;
  --accent-soft: #e8effd;

  /* danger buttons: red text on a red tint at rest, solid red on hover and press */
  --danger-bg: #fdecea;
  --danger-text: #b42318;
  --danger-border: #f0b3ad;
  --danger-solid: #c62d20;
  --danger-press: #a51f15;

  /* feedback */
  --err-bg: #fbe9e7;
  --err-text: #8a1c12;
  --warn-bg: #fff4d6;
  --warn-text: #6b4a00;
  --ok-bg: #e4f5e8;
  --ok-text: #1d5b2a;
  --info-bg: #e6f0fc;
  --info-text: #174b8f;

  /* server / job states (the state dot and badges use these) */
  --c-running: #2e9e4f;
  --c-degraded: #d9951a;
  --c-unreachable: #d0392b;
  --c-provisioning: #2f7de0;
  --c-stopped: #8a929e;
  --c-draft: #b3bac4;
  --c-destroying: #7b4fc4;

  /* charts (canvas reads these by name) */
  --chart-cpu: #2f7de0;
  --chart-disk: #2e9e4f;
  --chart-grid: #e2e6ec;
  --chart-axis: #8a929e;

  /* host disk donut (server page Status card): MAGIX image, other used, free. The used segments
     switch to --c-degraded (over 80 %) or --c-unreachable (over 90 %) in .disk-panel.warn / .bad. */
  --donut-image: #2f7de0;
  --donut-other: #7d8a9c;
  --donut-free: #e2e6ec;

  /* console (the emulated 80x25 screen) */
  --screen-bg: #0b0f14;
  --screen-fg: #d6dde6;
  --screen-cursor-bg: #d6dde6;
  --screen-cursor-fg: #0b0f14;

  --radius: 8px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.05);
  --scrim: rgba(15, 23, 42, 0.45);
  /* layout: the sidebar's width (the sidebar, the body's left padding and the app bar's left edge all use it), and
     the app bar's height. layout.js publishes the real bar height as --appbar-h; --nav-bar-h is the phone bar (0 on desktop). */
  --sidebar-w: 220px;
  --appbar-h: 64px;
  --nav-bar-h: 0px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232b;
    --border: #2b323c;
    --text: #e6e9ee;
    --text-muted: #98a2b1;
    --link: #6ea8ff;
    --focus: #6ea8ff;
    --focus-ring: rgba(110, 168, 255, 0.35);
    --row-hover: #1b2029;
    --accent: #2f6fdb;
    --accent-hover: #2a64c9;
    --accent-press: #2358b3;
    --accent-text: #ffffff;
    --accent-soft: #1a2c4d;
    --danger-bg: #3d1a17;
    --danger-text: #ffb4aa;
    --danger-border: #6e2d28;
    --danger-solid: #c0392b;
    --danger-press: #a02f23;
    --err-bg: #4a1f1b;
    --err-text: #ffb4aa;
    --warn-bg: #4a3b12;
    --warn-text: #ffe39a;
    --ok-bg: #173a22;
    --ok-text: #a6e6b8;
    --info-bg: #17324f;
    --info-text: #b7d6ff;
    --c-draft: #5b6470;
    --chart-grid: #2e353f;
    --chart-axis: #6f7a88;
    --donut-image: #7fb2ff;
    --donut-other: #6f7a88;
    --donut-free: #3a414c;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35);
    --scrim: rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1e232b;
  --border: #2b323c;
  --text: #e6e9ee;
  --text-muted: #98a2b1;
  --link: #6ea8ff;
  --focus: #6ea8ff;
  --focus-ring: rgba(110, 168, 255, 0.35);
  --row-hover: #1b2029;
  --accent: #2f6fdb;
  --accent-hover: #2a64c9;
  --accent-press: #2358b3;
  --accent-text: #ffffff;
  --accent-soft: #1a2c4d;
  --danger-bg: #3d1a17;
  --danger-text: #ffb4aa;
  --danger-border: #6e2d28;
  --danger-solid: #c0392b;
  --danger-press: #a02f23;
  --err-bg: #4a1f1b;
  --err-text: #ffb4aa;
  --warn-bg: #4a3b12;
  --warn-text: #ffe39a;
  --ok-bg: #173a22;
  --ok-text: #a6e6b8;
  --info-bg: #17324f;
  --info-text: #b7d6ff;
  --c-draft: #5b6470;
  --chart-grid: #2e353f;
  --chart-axis: #6f7a88;
  --donut-image: #7fb2ff;
  --donut-other: #6f7a88;
  --donut-free: #3a414c;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35);
  --scrim: rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
}

h1,
h2,
h3 {
  font-weight: 600;
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 16px;
  margin: 18px 0 8px;
}

h3 {
  font-size: 14px;
  margin: 14px 0 6px;
}

p {
  margin: 0 0 10px;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

code,
pre,
.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

code {
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 3px;
  word-break: break-all;
}

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

.small {
  font-size: 12px;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.spacer {
  flex: 1 1 auto;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ------------------------------------------------------------------ sidebar (layout.js renderNav)

   renderNav draws into #topbar, which carries the class "sidebar". On a signed-in page the sidebar
   is fixed to the left edge (220 px wide, full height, scrolls itself if it is ever taller than the
   window) and body has a 220 px left padding, so the maintenance banner, #main and the version
   footer lay out as the normal full-width column to its right. Pages without a sidebar (login,
   enrol) have no padding and keep the plain layout.

   Below 900 px the sidebar is a drawer: off-canvas on the left, opened from a slim sticky top bar
   (.nav-bar, brand and burger button) that renderNav adds above it. body has no padding there, so
   the page is the full width. owner 2026-11-21: burger menu on phones (the horizontal bar of every
   link wrapped onto several lines). The sidebar used to be a CSS grid column; that made its 100vh
   height stretch the first grid row (the banner grew to fill the window). */

body:has(> .sidebar) {
  padding-left: var(--sidebar-w);
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.sidebar .brand-mark {
  display: block;
  width: 26px;
  height: 26px;
  flex: none;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar .nav-group + .nav-group {
  margin-top: 14px;
}

.sidebar .nav-label {
  padding: 0 10px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.sidebar nav a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
}

.sidebar nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.sidebar nav a.active {
  background: var(--accent-soft);
  color: var(--link);
  font-weight: 600;
}

/* The user box sits at the bottom of the sidebar: the account link, then Sign out. */
.userbox {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.userbox a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.userbox a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.userbox a.active {
  background: var(--accent-soft);
  color: var(--link);
  font-weight: 600;
}

.userbox button {
  width: 100%;
}

/* ------------------------------------------------------------------ page scaffold */

.page {
  --page-gutter: 18px; /* the side padding of the page body */
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px var(--page-gutter) 40px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.page-head .sub {
  color: var(--text-muted);
  margin-top: 3px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.card h2:first-child {
  margin-top: 0;
}

/* A card's own heading is a section header: smaller, with a rule under it. */
.card > h2 {
  font-size: 15px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Breadcrumbs (layout.js crumbNav / setCrumbs): one small line above the h1. The group and the page are
   links or muted text, the current crumb is the normal text colour. The separators are CSS, not text. */
.crumbs {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
  margin-bottom: 4px;
  min-width: 0;
}

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.crumbs li {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
}

.crumbs li + li::before {
  content: "/";
  padding: 0 8px;
  color: var(--text-muted);
  opacity: 0.6;
}

.crumbs a {
  color: var(--link);
}

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

.crumbs .crumb-current {
  color: var(--text);
  font-weight: 500;
}

/* ------------------------------------------------------------------ app bar (layout.js mountAppBar, fillAppBar)

   One fixed bar across the top of every signed-in page, from the sidebar's right edge (--sidebar-w) to the window's
   right edge. It never scrolls. The left part is the breadcrumb trail above the title (the h1 and its badges); the
   right part is the page's action buttons, at the right end, in one row that does not wrap on desktop. Below 900 px
   the bar sits under the phone bar (.nav-bar, --nav-bar-h) and its actions form a second row that scrolls sideways.

   z 25: above the page content and the server tab bar (20), below the drawer (61) and the date popover (40) and the
   toast (50). The Actions menu is inside this bar, so it stacks with the bar: it is above the content and the tab bar.
   No overflow:hidden on the bar itself, so nothing inside it is clipped. The page content starts below the bar because
   #appbar-spacer (below) takes the bar's height in the page flow; --appbar-h is that height, measured by layout.js. */
.appbar {
  position: fixed;
  top: var(--nav-bar-h, 0px);
  left: var(--sidebar-w);
  right: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 16px;
  box-sizing: border-box;
  min-height: 64px;
  padding: 8px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 6px -4px rgba(15, 23, 42, 0.22);
}

/* Holds the bar's height in the page flow (layout.js mountAppBar). The page content and the maintenance banner come after it. */
#appbar-spacer {
  height: var(--appbar-h, 64px);
}

/* Left part: the crumbs above the title. One line each: long names end in an ellipsis, never wrap. */
.appbar-main {
  /* Basis 0 (not auto): the title side takes only the room the buttons leave, so a long server name ellipsises
     instead of pushing the buttons off the right edge (seen with harbour-motors-production-east-01). */
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.appbar .crumbs {
  margin: 0;
  font-size: 13px;
  line-height: 18px;
}

.appbar .crumbs ol {
  flex-wrap: nowrap;
}

.appbar .crumbs li {
  flex: none;
  overflow-wrap: normal;
}

/* The last crumb (the current place, e.g. a job's name) takes the room that is left and ends in an ellipsis. */
.appbar .crumbs li:last-child {
  flex: 0 1 auto;
}

.appbar .crumbs li > * {
  min-width: 0;
  white-space: nowrap;
}

.appbar .crumbs li:last-child > * {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The title row: the h1 (shrinks and ends in an ellipsis) and the badges after it (never shrink). */
.appbar-title {
  display: flex;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
}

.appbar-title > h1 {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
  line-height: 26px;
}

.appbar-title > :not(h1) {
  flex: none;
}

/* Right part: the page's action buttons, in order, at the right end. */
.appbar-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.appbar-actions:empty {
  display: none;
}

.appbar-actions > * {
  flex: none;
}

.appbar-actions button,
.appbar-actions .button {
  white-space: nowrap;
}

/* The descriptive text under the app bar, in the page body. It scrolls with the page, so it may be as long as it needs. */
.page-sub {
  margin: 10px 0 14px;
}

/* The server page's facts under its app bar (the client, the DNS name and the dealer lines, and the status pills). */
.server-facts {
  margin-bottom: 12px;
}

.server-facts .server-pills {
  margin-top: 8px;
}

/* Below 900 px the sidebar is the drawer, so the bar is the full width and sits under the phone bar. It takes two
   rows: the crumbs and title, then the actions in a row that scrolls sideways when the buttons do not fit (the server
   page has five or six). The buttons are a little smaller so the row stays one line. The bar's height is measured
   by layout.js (--appbar-h), so the page content still starts below it when the bar is taller. */
@media (max-width: 899px) {
  .appbar {
    left: 0;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 8px 12px;
  }

  .appbar-main {
    flex: 1 1 100%;
  }

  .appbar-title > h1 {
    font-size: 18px;
    line-height: 24px;
  }

  .appbar-actions {
    flex: 1 1 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 2px 4px;
    margin: -2px -2px -4px;
  }

  .appbar-actions::-webkit-scrollbar {
    display: none;
  }

  .appbar-actions button,
  .appbar-actions .button {
    padding: 5px 10px;
    font-size: 13px;
  }
}

/* ------------------------------------------------------------------ messages */

.notice {
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  margin: 0 0 12px;
}

.notice.error {
  background: var(--err-bg);
  color: var(--err-text);
}

.notice.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.notice.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.notice.info {
  background: var(--info-bg);
  color: var(--info-text);
}

.notice ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.empty {
  color: var(--text-muted);
  padding: 18px 4px;
  font-style: italic;
}

/* ------------------------------------------------------------------ buttons and fields */

button,
.button {
  font: inherit;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 34px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-card);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

/* Default (secondary) button. These generic hover and press rules have specificity 0,2,1, so the
   variants below repeat their hover and press rules with a higher specificity (0,3,1). */
button:hover:not(:disabled),
.button:hover {
  background: var(--surface-2);
  text-decoration: none;
}

button:active:not(:disabled),
.button:active {
  background: var(--border);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: none;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-text);
}

button.primary:active:not(:disabled) {
  background: var(--accent-press);
  border-color: var(--accent-press);
}

/* Danger: red text on a red tint at rest. On hover it fills solid red with white text. */
button.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
  box-shadow: none;
}

button.danger:hover:not(:disabled) {
  background: var(--danger-solid);
  border-color: var(--danger-solid);
  color: #ffffff;
}

button.danger:active:not(:disabled) {
  background: var(--danger-press);
  border-color: var(--danger-press);
  color: #ffffff;
}

/* Ghost: no border or fill at rest, the accent colour as text. */
button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--link);
  box-shadow: none;
  padding: 0 6px;
}

button.ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

/* Disabled: greyed, and no hover or press change (the :not(:disabled) rules above skip it). This
   comes after the variants so it wins over them at the same specificity. */
button:disabled {
  opacity: 0.55;
  cursor: default;
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-muted);
  box-shadow: none;
}

button.ghost:disabled {
  background: transparent;
  border-color: transparent;
}

/* Small: 28 px high, for table rows and inline actions. */
button.small,
.button.small {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

/* Keyboard focus: a soft ring in the focus colour (the browser outline is kept for links). */
button:focus-visible,
.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  min-width: 0;
}

label.field.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field-label {
  font-weight: 600;
  font-size: 13px;
}

.field-label .req {
  color: var(--c-unreachable);
  margin-left: 2px;
}

.field-hint {
  color: var(--text-muted);
  font-size: 12px;
}

.field-error {
  color: var(--err-text);
  font-size: 12px;
  margin: 0;
}

/* "Suggestion: agritek-server  use this" under the name field (createcheck.js). */
.field-suggest {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
}

.field-suggest code {
  font-weight: 600;
  color: var(--text);
}

/* A button that reads as a link, for small inline actions like "use this". */
.link-button {
  background: none;
  border: 0;
  padding: 0;
  min-height: 0;
  box-shadow: none;
  font: inherit;
  color: var(--link, var(--accent, #0b62d6));
  text-decoration: underline;
  cursor: pointer;
}

/* The generic button hover and press fills do not apply to a link. */
.link-button:hover:not(:disabled),
.link-button:active:not(:disabled) {
  background: none;
}

.banner-actions {
  margin-top: 8px;
  gap: 12px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="email"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input:not([type]),
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 34px;
  padding: 0 10px;
  width: 100%;
  min-width: 0;
}

textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

input.code-input {
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.25em;
  text-align: center;
}

textarea.yaml,
textarea.log-input {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.4;
  min-height: 420px;
  white-space: pre;
  tab-size: 2;
}

textarea.secret {
  font-family: var(--mono);
  font-size: 12px;
  min-height: 90px;
  white-space: pre-wrap;
  word-break: break-all;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 14px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ login and enrol */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 4px;
}

.auth-card .sub {
  color: var(--text-muted);
  margin-bottom: 14px;
}

.auth-wide {
  max-width: 560px;
}

.secret-line {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0;
}

/* ------------------------------------------------------------------ tables */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 14px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.data th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

table.data tbody tr.clickable {
  cursor: pointer;
}

table.data tbody tr.clickable:hover {
  background: var(--surface-2);
}

/* Every data row highlights on hover (the detail row under a row keeps its own tint). */
table.data tbody tr:not(.detail):hover > td {
  background: var(--row-hover);
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data td.nowrap {
  white-space: nowrap;
}

table.data td.wrap {
  word-break: break-word;
}

table.data tr.detail td {
  background: var(--surface-2);
}

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.filters select {
  width: auto;
}

/*
 * Search boxes (type="search") in a filter row and in the servers list toolbar. The base input
 * rule gives every input width:100%, which in a flex row would squash its neighbours (the status
 * select, the Type select, the buttons), so here the box takes its own width instead: at least
 * 260px, growing into the spare room, and shrinking back to the full width on a phone (see the
 * max-width rule below).
 *
 * The magnifier is a background image: an SVG data URI in a neutral grey (#8a929e, the same grey as
 * the "stopped" state dot). A data URI cannot read a CSS token, and this grey is readable on both
 * the light and the dark --surface. The text starts at 28px so it does not sit on the icon.
 * "%23" is an encoded "#" (the SVG is inside a CSS url()).
 */
.filters input[type="search"],
.page-head .row input[type="search"] {
  width: auto;
  min-width: 260px;
  padding-left: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a929e' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 8px center;
  background-size: 14px 14px;
}

/* Phone: the search box takes the whole line, as the other inputs do, and the minimum goes. */
@media (max-width: 640px) {
  .filters input[type="search"],
  .page-head .row input[type="search"] {
    width: 100%;
    min-width: 0;
  }
}

/* ------------------------------------------------------------------ date picker (datepicker.js)

   A date field is a button that looks like the other inputs (same border, radius, 34px height, font), with
   the date written out ("19 Nov 2026") and a calendar glyph. The calendar is a popover: position:fixed,
   placed by JS from the field's rect, and above the sticky tab bar (z 20) and the actions menu (z 30), but
   below the toast (z 50). A popover inside a native <dialog> is moved into that dialog by JS (the top layer),
   so it is not hidden under it. Colours are the existing tokens, so light and dark themes both work. */

.dp {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

.dp-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.dp-field:hover {
  border-color: var(--text-muted);
}

.dp-field:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.dp-field[aria-expanded="true"] {
  border-color: var(--accent);
}

.dp-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.dp-icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* In a filter row the field takes its own width (like the search box), not the full line. */
.filters .dp {
  width: auto;
}

.filters .dp-field {
  min-width: 150px;
}

.dp-pop {
  position: fixed;
  z-index: 40;
  box-sizing: border-box;
  width: 292px;
  padding: 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.dp-head {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 8px;
}

.dp-title {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

.dp-nav {
  min-width: 30px;
  min-height: 30px;
  padding: 0 6px;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.dp-nav:hover {
  background: var(--surface-2);
}

.dp-nav:focus-visible,
.dp-today:focus-visible,
.dp-clear:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.dp-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.dp-dowc {
  padding: 4px 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
}

.dp-day {
  min-height: 34px;
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.dp-day:hover:not(:disabled):not(.selected) {
  background: var(--surface-2);
}

.dp-day.other {
  color: var(--text-muted);
}

/* Today: a ring, so it reads even when another day is selected. */
.dp-day.today {
  border-color: var(--accent);
}

.dp-day.selected {
  color: var(--accent-text);
  background: var(--accent);
  font-weight: 600;
}

.dp-day:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.dp-day:disabled {
  color: var(--text-muted);
  opacity: 0.4;
  cursor: default;
}

.dp-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.dp-foot button {
  min-height: 32px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.dp-foot .dp-today {
  color: var(--accent);
}

/* Phone: a full-width sheet at the top or bottom of the screen, with larger day cells to tap. */
/* On a phone the calendar is a bottom sheet (datepicker.js places it at the foot of the window, where the thumb is).
   The huge spread shadow dims the page behind it, like a modal backdrop, without an extra element; a tap on the
   dimmed area is a click outside, which closes the picker. */
.dp-pop.sheet {
  box-sizing: border-box; /* the width datepicker.js sets is the whole sheet, padding included */
  padding: 14px;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.4);
}

.dp-pop.sheet .dp-day {
  min-height: 44px;
  font-size: 15px;
}

.dp-pop.sheet .dp-nav {
  min-width: 40px;
  min-height: 40px;
}

.dp-pop.sheet .dp-foot button {
  min-height: 44px;
  padding: 0 16px;
}

@media (max-width: 640px) {
  .filters .dp {
    width: 100%;
  }

  .filters .dp-field {
    min-width: 0;
  }
}

/* Jobs page: a date range label ("From" text with its picker), the pager row and the note under History. */
.jobs-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.jobs-range .dp {
  width: auto;
}

.jobs-pager {
  align-items: center;
  margin-top: 10px;
}

.jobs-retention {
  margin: 10px 0 0;
}

/* ------------------------------------------------------------------ badges and state dots */

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  text-transform: lowercase;
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-color: transparent;
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: transparent;
}

.badge.bad {
  background: var(--err-bg);
  color: var(--err-text);
  border-color: transparent;
}

.badge.info {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: transparent;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--c-stopped);
}

/* D-122: the host check-in dot of the server page and the servers list: green fresh, amber stale or paused, grey none. */
.dot.checkin-dot.ok {
  background: var(--c-running);
}

.dot.checkin-dot.warn {
  background: var(--c-degraded);
}

.dot.checkin-dot.none {
  background: var(--c-stopped);
}

.checkin-block .checkin-head {
  align-items: center;
  gap: 4px 8px;
}

.checkin-line.warn {
  color: var(--warn-text);
}

.state-running {
  background: var(--c-running);
}

.state-degraded {
  background: var(--c-degraded);
}

.state-unreachable {
  background: var(--c-unreachable);
}

.state-provisioning {
  background: var(--c-provisioning);
}

.state-stopped {
  background: var(--c-stopped);
}

.state-draft {
  background: var(--c-draft);
}

.state-create_failed {
  background: var(--c-unreachable);
}

.state-destroying {
  background: var(--c-destroying);
}

.state-destroyed {
  background: var(--c-draft);
}

.state-unknown {
  background: var(--c-draft);
}

.sev-critical {
  color: var(--err-text);
  font-weight: 600;
}

.sev-warning {
  color: var(--warn-text);
  font-weight: 600;
}

/* F1: "No backup schedule" under a production server's name (servers.js backupLine). Amber, so it reads as a to-do. */
.backup-none-warn {
  color: var(--warn-text);
  font-weight: 600;
}

/* ------------------------------------------------------------------ tiles and bars */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-width: 0;
}

.tile-label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tile-value {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.tile-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

/* A big number, used for the licence seats. */
.big-number {
  font-size: 44px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.bar {
  height: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--c-running);
  transition: width 0.4s ease;
}

.bar-fill.warn {
  background: var(--c-degraded);
}

.bar-fill.bad {
  background: var(--c-unreachable);
}

/* ------------------------------------------------------------------ tabs */

nav.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  overflow-x: auto;
}

nav.tabs a {
  color: var(--text-muted);
  padding: 10px 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

nav.tabs a:hover {
  text-decoration: none;
  color: var(--text);
}

nav.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--link);
  font-weight: 600;
}

/* ------------------------------------------------------------------ segmented chips

   A row of buttons that pick one value (the Backups list's Daily / Monthly quick filter). One
   outlined box, the buttons joined with a divider. The pressed one (aria-pressed="true", set by
   backupsview.js) is filled with the link colour. --surface is the text colour on it: it is white
   in light mode and the dark surface in dark mode, so the contrast holds in both. */

.seg {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.seg button {
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 28px;
  padding: 0 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  box-shadow: none;
}

.seg button + button {
  border-left: 1px solid var(--border);
}

.seg button:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.seg button[aria-pressed="true"],
.seg button[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

/* ------------------------------------------------------------------ charts */

.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.chart-toolbar button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}

canvas.chart {
  display: block;
  width: 100%;
  height: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ------------------------------------------------------------------ host disk donut */

/* The panel sits under the Host tiles. Its body is the donut and the legend side by side; on a
   narrow screen the legend wraps under the donut, so nothing overflows sideways. */
.disk-panel {
  margin: 0 0 14px;
  min-width: 0;
}

.disk-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

/* The SVG keeps its 160 px size but shrinks on a very narrow card (height follows the viewBox). */
svg.donut {
  display: block;
  flex: 0 0 auto;
  width: 160px;
  max-width: 100%;
  height: auto;
}

/* The ring: each segment is a circle drawn as a dashed arc (see buildDonut in chart.js). */
.donut-seg {
  fill: none;
  stroke-width: 20;
}

.donut-centre {
  fill: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.donut-centre-sub {
  fill: var(--text-muted);
  font-size: 11px;
}

/* One class per segment colours both the ring (stroke) and the legend swatch (background). */
.seg-image {
  stroke: var(--donut-image);
  background-color: var(--donut-image);
}

.seg-other {
  stroke: var(--donut-other);
  background-color: var(--donut-other);
}

.seg-free {
  stroke: var(--donut-free);
  background-color: var(--donut-free);
}

/* Over 80 % used: both used segments take the warn colour. Over 90 %: the bad colour. The other
   used segment is dimmed so it stays distinct from the MAGIX image segment in the same colour. */
.disk-panel.warn .seg-image,
.disk-panel.warn .seg-other {
  stroke: var(--c-degraded);
  background-color: var(--c-degraded);
}

.disk-panel.bad .seg-image,
.disk-panel.bad .seg-other {
  stroke: var(--c-unreachable);
  background-color: var(--c-unreachable);
}

.disk-panel.warn .seg-other,
.disk-panel.bad .seg-other {
  opacity: 0.55;
}

/* The legend takes up to 340 px beside the donut, so its values sit close to their names on a wide
   screen; it shrinks (and the row wraps) on a narrow one. */
.disk-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 0 1 340px;
  min-width: 0;
}

.disk-legend li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 4px 0;
}

.swatch {
  display: inline-block;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.disk-legend-name {
  flex: 1 1 120px;
  min-width: 0;
}

.disk-legend-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.disk-legend-pct {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}

.disk-history-toggle {
  margin-top: 10px;
}

.disk-history {
  margin-top: 8px;
}

/* ------------------------------------------------------------------ dialogs */

dialog.dlg {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(640px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}

dialog.dlg.wide {
  width: min(900px, calc(100vw - 32px));
}

dialog.dlg::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.dlg-head {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.dlg-head h2 {
  margin: 0;
  flex: 1;
}

.dlg-body {
  padding: 14px 16px;
  max-height: 70vh;
  overflow-y: auto;
}

.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ console (80x25 screen) */

/* Colour themes. The console panel (and, in the popped-out window, the body) carries
   data-console-theme, set by console.js from the picker in the bar. Each theme sets two groups of
   custom properties, which inherit from there:
   - the four --screen-* properties: the 80x25 screen itself (frame, grid, cursor cell);
   - the page tokens --surface, --surface-2, --border, --text, --text-muted: the "chrome" around
     the screen (the panel card, the bar, its buttons, the picker, the status badge, the hint).
     Buttons, selects and badges are drawn from these tokens everywhere (see button, select,
     .badge above), so redefining them inside the panel recolours them with no extra rules, and
     the whole console reads as one piece in the theme's colours.
   The attribute is only ever on the console panel and the popout body, so the rest of the page
   (and job logs, pre.log / pre.screen, which use the :root --screen-* values) is unchanged.
   "blue" is the default and matches the QEMU/VGA text screen of MAGIX: white (#FFFFFF) on VGA
   blue (#0000AA), the standard VGA text-mode palette values; its chrome is a darker navy with
   VGA light-blue (#5555FF) borders. */
[data-console-theme="blue"] {
  --screen-bg: #0000AA;
  --screen-fg: #FFFFFF;
  --screen-cursor-bg: #AAAAAA;
  --screen-cursor-fg: #0000AA;
  --surface: #000080;
  --surface-2: #0000C8;
  --border: #5555FF;
  --text: #FFFFFF;
  --text-muted: #AAAAFF;
}

[data-console-theme="grey"] {
  --screen-bg: #0000AA;
  --screen-fg: #AAAAAA;
  --screen-cursor-bg: #AAAAAA;
  --screen-cursor-fg: #0000AA;
  --surface: #000080;
  --surface-2: #0000C8;
  --border: #5555AA;
  --text: #CCCCCC;
  --text-muted: #8888BB;
}

[data-console-theme="black"] {
  --screen-bg: #0b0f14;
  --screen-fg: #d6dde6;
  --screen-cursor-bg: #d6dde6;
  --screen-cursor-fg: #0b0f14;
  --surface: #151b23;
  --surface-2: #202833;
  --border: #303b49;
  --text: #d6dde6;
  --text-muted: #8b97a6;
}

[data-console-theme="light"] {
  --screen-bg: #FFFFFF;
  --screen-fg: #111111;
  --screen-cursor-bg: #111111;
  --screen-cursor-fg: #FFFFFF;
  --surface: #eef0f3;
  --surface-2: #e2e5ea;
  --border: #c3c9d2;
  --text: #111111;
  --text-muted: #5b6573;
}

[data-console-theme="green"] {
  --screen-bg: #000000;
  --screen-fg: #33FF66;
  --screen-cursor-bg: #33FF66;
  --screen-cursor-fg: #000000;
  --surface: #04110a;
  --surface-2: #0b2614;
  --border: #1f6b33;
  --text: #33FF66;
  --text-muted: #22a845;
}

[data-console-theme="amber"] {
  --screen-bg: #000000;
  --screen-fg: #FFB000;
  --screen-cursor-bg: #FFB000;
  --screen-cursor-fg: #000000;
  --surface: #120c00;
  --surface-2: #2a1c00;
  --border: #7a5500;
  --text: #FFB000;
  --text-muted: #b07a00;
}

/* A themed panel and its text take the chrome colours (the card rule only sets the background). */
.console-panel[data-console-theme] {
  color: var(--text);
}

/* The popped-out window's body is the chrome colour of the theme, so the bar sits on it and the
   screen stands out as in the inline panel. */
body.console-popout[data-console-theme] {
  background: var(--surface);
  color: var(--text);
}

/* The theme picker in the console bar: a small palette button that opens a menu below it. The menu
   is drawn from the page tokens, so it takes the current theme's chrome colours like the bar.
   It sits outside the frame, so keys used in it never reach MAGIX. */
.console-theme-picker {
  position: relative;
  display: inline-flex;
}

.console-theme-btn {
  padding: 0 8px;
  font-size: 14px;
}

.console-theme-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 190px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.console-theme-menu[hidden] {
  display: none;
}

/* A menu item: sample, name, and a tick on the current theme. Flat, like a menu row. */
.console-theme-menu .console-theme-item {
  justify-content: flex-start;
  gap: 8px;
  min-height: 30px;
  padding: 0 8px;
  font-size: 12.5px;
  font-weight: 500;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.console-theme-menu .console-theme-item:hover:not(:disabled),
.console-theme-menu .console-theme-item:focus-visible {
  background: var(--surface-2);
}

.console-theme-item[aria-checked="true"]::after {
  content: "\2713";
  margin-left: auto;
  font-weight: 700;
}

/* The sample is a tiny screen in its own theme's colours (it carries data-console-theme). */
.console-theme-sample {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 20px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--screen-bg);
  color: var(--screen-fg);
  border: 1px solid var(--border);
}

.console-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.console-frame {
  background: var(--screen-bg);
  color: var(--screen-fg);
  border-radius: var(--radius);
  padding: 10px;
  /* 80 x 25 cells: the grid is sized by JS (ResizeObserver) to fit this box. */
  width: 100%;
  overflow: hidden;
  outline-offset: 2px;
}

.console-grid {
  font-family: var(--mono);
  font-size: 14px; /* JS overrides this to fit the frame */
  line-height: 1.2;
  white-space: pre;
  color: var(--screen-fg);
  user-select: text;
}

.console-grid .row {
  display: block;
  height: 1.2em;
  overflow: hidden;
  margin: 0;
}

.console-grid .cur {
  background: var(--screen-cursor-bg);
  color: var(--screen-cursor-fg);
}

/* The panel that wraps the console bar, screen and hint. */
.console-panel {
  margin-bottom: 0;
}

.console-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin: 6px 0 0;
}

.console-hint.blocked {
  color: var(--warn-text);
  font-weight: 600;
}

/* Popped-out console (console.html and the Picture-in-Picture window). The window holds one console
   that fills it: the body is the console's dark screen colour, with no page margins or scrollbars.
   JS sizes the 80x25 grid to the window's width and height (console.js, fill mode). */
body.console-popout {
  margin: 0;
  padding: 8px;
  box-sizing: border-box;
  height: 100vh;
  overflow: hidden;
  background: var(--screen-bg);
  color: var(--screen-fg);
}

/* The element that holds the console: <main> on console.html, a plain <div> in the Picture-in-Picture window. */
body.console-popout > main,
body.console-popout > div {
  height: 100%;
}

/* The panel is the console itself: no card look, no margins, the full height of the window.
   Column flex lets the screen take what the bar and hint leave. */
.console-panel.console-fill {
  margin: 0;
  padding: 0;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.console-panel.console-fill .console-bar {
  padding: 0 0 6px;
}

.console-panel.console-fill .console-frame {
  flex: 1 1 auto;
  min-height: 0;
}

/* Hints are light text on the dark screen colour in the popped-out window. */
body.console-popout .console-hint {
  color: var(--screen-fg);
  opacity: 0.75;
}

body.console-popout .console-hint.blocked {
  color: var(--warn-text);
  opacity: 1;
}

/* Buttons keep their own look; the bar wraps when the window is narrow (760 px is the default). */
body.console-popout .console-bar {
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ job pipeline */

.job-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
  margin-bottom: 4px;
}

.job-meta .k {
  color: var(--text-muted);
  font-size: 12px;
}

.pipeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
}

.step.is-running {
  border-color: var(--c-provisioning);
}

.step.is-failed {
  border-color: var(--c-unreachable);
}

.step-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  flex-wrap: wrap;
}

.step-seq {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  min-width: 2.2em;
}

.step-name {
  font-weight: 600;
}

.step-action {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
}

.step-dur {
  margin-left: auto;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.step-body {
  border-top: 1px solid var(--border);
  padding: 8px 10px 10px;
}

.step-body > details > summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12.5px;
  margin-bottom: 6px;
}

pre.log {
  background: var(--screen-bg);
  color: var(--screen-fg);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

pre.log .line.err {
  color: #ff9d8f;
}

pre.log .line.eng {
  color: #9fc3ff;
}

pre.screen {
  background: var(--screen-bg);
  color: var(--screen-fg);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 6px 0 0;
  overflow-x: auto;
  line-height: 1.2;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(0, 2fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 4px 0;
  font-size: 12.5px;
}

.file-row .file-name {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

.file-row .file-stat {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.file-row .sha {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.progress {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--c-provisioning);
  transition: width 0.3s linear;
}

.group-title {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 14px 0 6px;
}

/* ------------------------------------------------------------------ playbook editor */

.yaml-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.yaml-meta select {
  width: auto;
}

/* ------------------------------------------------------------------ responsive */

/* owner 2026-11-21: burger menu on phones. The phone chrome (the slim top bar, the burger, the ✕ in the
   drawer and the overlay) is hidden on desktop, so the sidebar above is the same as before at 900 px and up.
   renderNav (layout.js mountMobileNav) adds .nav-bar and .nav-overlay as siblings of #topbar. */
.nav-bar,
.nav-overlay,
.nav-close,
.nav-burger {
  display: none;
}

/* Below 900 px: the sidebar is an off-canvas drawer on the left (the same nav links and user box as on
   desktop), opened from the .nav-bar at the top of the page. The drawer is hidden with transform AND
   visibility, so its links cannot be reached by Tab or a screen reader while it is closed; the slide
   is a transform, so it does not change the layout. body has no left padding here. */
@media (max-width: 899px) {
  body:has(> .sidebar) {
    padding-left: 0;
  }

  /* The slim sticky bar: the brand on the left, the burger button on the right. */
  .nav-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .nav-bar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text);
  }

  .nav-bar .brand-mark {
    display: block;
    width: 22px;
    height: 22px;
    flex: none;
  }

  /* 40 px square, a comfortable touch target. The glyph is ☰ (set in layout.js). */
  .nav-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
  }

  /* Dims the page behind the open drawer. z 60 is above the page, the sticky server tabs (20), the
     actions menu (30) and the date popover (40). The toast (50) is drawn under the dim, which is fine:
     it is short-lived. Real dialogs are in the top layer (showModal), so they stay above the dim. */
  .nav-overlay {
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    background: var(--scrim);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }

  .nav-overlay.open {
    opacity: 1;
    visibility: visible;
  }

  /* The drawer: full height, 300 px or 85% of the screen, whichever is smaller, so a sliver of the page
     is always visible to tap and close. It scrolls itself if the links are taller than the screen; the
     user box stays at the bottom (margin-top: auto from the desktop rule). Its brand is in the bar, so
     the drawer does not show it again. Shadow only while open, so none peeks in from the edge. */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 85vw);
    z-index: 61;
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    visibility: hidden;
    /* Closing: the slide runs first, and visibility only switches to hidden after it (the 0.22 s delay).
       Opening: visibility is visible at once (the .open rule below has no delay). A visibility transition
       that starts from hidden stays hidden for its first instant, so the ✕ could not take focus in the
       same frame as the drawer opens (the focus call in layout.js setOpen is refused; found by the browser
       check at 390 px). */
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
    overscroll-behavior: contain;
  }

  .sidebar.open {
    transform: none;
    visibility: visible;
    transition: transform 0.22s ease, visibility 0s;
    box-shadow: var(--shadow);
  }

  .sidebar .brand {
    display: none;
  }

  /* The ✕ at the top right of the drawer. */
  .nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    flex: none;
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
  }

  /* While the drawer is open the page behind it must not scroll (layout.js sets html.nav-open). */
  html.nav-open,
  html.nav-open body {
    overflow: hidden;
  }
}

/* Reduced motion: the drawer and the overlay change at once, with no slide or fade. The .open
   selectors are listed too: .sidebar.open carries its own transition (above), and a rule with only
   .sidebar would lose to it on opening. */
@media (max-width: 899px) and (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar.open,
  .nav-overlay,
  .nav-overlay.open {
    transition: none;
  }
}

@media (max-width: 1024px) {
  .tiles {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

@media (max-width: 720px) {
  .page {
    --page-gutter: 16px;
    padding: 12px 16px 30px;
  }

  .card {
    padding: 14px;
  }

  .file-row {
    grid-template-columns: 1fr;
  }

  .big-number {
    font-size: 34px;
  }
}

/* ------------------------------------------------------------------ scheduled jobs (licence tab, jobs list) */

/* The "When" radios group: a fieldset without the default frame. */
fieldset.when-picker {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
fieldset.when-picker legend {
  padding: 0;
  margin-bottom: 0.25rem;
}

/* One group of scheduled jobs that share a minute ("Scheduled for <NZ time>"). */
.sched-group + .sched-group {
  margin-top: 1.25rem;
}
.sched-group h3 {
  margin: 0 0 0.25rem;
}

/* A badge that is a link (the "licence change scheduled" badge in the server header). */
a.badge {
  text-decoration: none;
}

/* ================================================================== playbook editor (form) ==
   Used by playbook.html / js/pbform.js. Colours come from the tokens above, so light and dark
   both work. The bars between steps reuse the server state colours. */

.pb-fs {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.pb-fs:disabled {
  opacity: 0.8;
}

.pb-card h2 {
  margin: 0 0 8px;
}

.pb-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0 14px;
}

.pb-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
}

.pb-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.pb-issues {
  margin: 8px 0 0;
  padding: 8px 10px 8px 26px;
  border-radius: var(--radius);
  background: var(--err-bg);
  color: var(--err-text);
  font-size: 13px;
}

.pb-issues[hidden] {
  display: none;
}

/* Questions */
.pb-q {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 12px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pb-q > .field {
  flex: 1 1 150px;
  margin-bottom: 4px;
}

.pb-q > .pb-wide {
  flex: 2 1 240px;
}

.pb-q > .pb-narrow {
  flex: 0 1 120px;
}

.pb-req {
  margin-bottom: 10px;
}

/* Steps */
.pb-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pb-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px 6px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.pb-step.has-issue {
  border-color: var(--c-unreachable);
}

.pb-step-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.pb-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  background: var(--info-bg);
  color: var(--info-text);
  font-weight: 700;
  font-size: 12.5px;
}

.pb-desc {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: -2px 0 10px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.pb-fields {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pb-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 0 10px;
  align-items: end;
}

.pb-field .pb-insert {
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.pb-templated {
  font-family: var(--mono);
  background: var(--info-bg);
  color: var(--info-text);
}

.pb-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: flex-end;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

.pb-opts .pb-narrow {
  flex: 0 1 190px;
}

.pb-opts .pb-check {
  margin-bottom: 14px;
}

.pb-add select {
  max-width: 420px;
}

/* The bars between steps: what state MAGIX is in */
.pb-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.pb-strip[hidden] {
  display: none;
}

.pb-strip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c-stopped);
}

.pb-strip.running {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.pb-strip.running .pb-strip-dot {
  background: var(--c-running);
}

.pb-strip.stopped {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.pb-strip.stopped .pb-strip-dot {
  background: var(--c-degraded);
}

.pb-strip.host {
  background: var(--info-bg);
  color: var(--info-text);
}

.pb-strip.host .pb-strip-dot {
  background: var(--c-provisioning);
}

.pb-strip.absent .pb-strip-dot {
  background: var(--c-draft);
}

.pb-strip.error {
  background: var(--err-bg);
  color: var(--err-text);
}

.pb-strip.error .pb-strip-dot {
  background: var(--c-unreachable);
}

/* Recovery */
.pb-fail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.pb-fail-row select {
  max-width: 420px;
}

/* Status bar above the form */
.pb-status {
  padding: 9px 12px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.pb-status.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.pb-status.error {
  background: var(--err-bg);
  color: var(--err-text);
}

.pb-status ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

details.pb-adv summary {
  cursor: pointer;
  font-weight: 600;
}

details.pb-adv textarea.yaml {
  margin: 10px 0;
  min-height: 260px;
}

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

.pb-desc .badge {
  text-transform: none;
  letter-spacing: 0;
}

.pb-adv {
  margin-top: 14px;
}

/* ---------------------------------------------------------------- load a project (server.js)
   The dialog: a drop zone, then one row per chosen file. Each row carries its own name checks
   and its progress bar, and the overall bar sits under the list. */

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 16px 14px;
  margin: 12px 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.drop-zone p {
  margin: 0;
  flex: 1 1 260px;
  color: var(--text-muted);
}

.drop-zone.is-over {
  border-color: var(--focus);
  background: var(--info-bg);
}

.drop-zone.is-busy {
  opacity: 0.6;
}

.file-list {
  display: grid;
  gap: 6px;
}

.file-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 6px 10px;
}

.file-issues {
  display: grid;
  gap: 2px;
}

.file-issue {
  font-size: 12.5px;
}

.file-issue.error {
  color: var(--err-text);
}

.file-issue.warn {
  color: var(--warn-text);
}

.file-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  margin-top: 6px;
}

.file-progress[hidden] {
  display: none;
}

.file-progress .progress {
  min-width: 0;
}

.file-progress .small {
  white-space: nowrap;
}

#load-code {
  width: 10ch;
  font-family: var(--mono);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- job screens (job.js)
   A step's MAGIX screens: the last one shows, earlier ones fold away behind a toggle. */

.screen-entry {
  margin-top: 6px;
}

/* ---------------------------------------------------------------- maintenance windows (maintenance.js)
   Timeline of windows and single jobs, the window detail, and the three-phase plan preview. */

.mw-timeline tr.mw-window td:first-child {
  border-left: 3px solid var(--link);
}

.mw-timeline tr.mw-window.selected {
  background: var(--info-bg);
}

.mw-timeline tr.mw-job td:first-child {
  border-left: 3px solid var(--border);
}

.mw-detail {
  margin-top: 16px;
}

.mw-head h2 {
  margin: 0;
}

.mw-items,
.mw-plan {
  margin-top: 16px;
}

.mw-est {
  margin: 8px 0 12px;
}

.mw-phases,
.mw-seq {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mw-seq {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.mw-phase {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.mw-phase.mw-stopped {
  border-color: var(--warn-text);
}

.mw-phase h4 {
  margin: 0 0 6px;
  font-size: 0.95em;
}

.mw-phase ol {
  margin: 0;
  padding-left: 20px;
}

.mw-phase li + li {
  margin-top: 4px;
}

.mw-offer {
  margin-top: 10px;
}

@media (max-width: 900px) {
  .mw-phases {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- maintenance mode banner (layout.js) and rollouts page (rollouts.js) ---- */

.maintenance-banner {
  background: #ffd84d;
  color: #3a2c00;
  border-bottom: 2px solid #c79a00;
  padding: 8px 16px;
  font-size: 14px;
}
.maintenance-banner a {
  color: #3a2c00;
  text-decoration: underline;
  margin-left: 6px;
}

.rollout-form {
  display: grid;
  gap: 12px;
}
.rollout-form .row {
  align-items: flex-start;
}
.rollout-servers {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  background: var(--surface);
}
.rollout-servers label {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 2px 0;
}
.rollout-batch {
  margin: 12px 0 4px;
  font-weight: 600;
}
.rollout-progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  margin: 6px 0 10px;
}
.rollout-progress > span {
  display: block;
  height: 100%;
  background: var(--c-running);
}
.drain-list {
  margin: 8px 0 0;
  padding-left: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .maintenance-banner {
    background: #6b5300;
    color: #fff3c4;
    border-bottom-color: #a37c00;
  }
  :root:not([data-theme="light"]) .maintenance-banner a {
    color: #fff3c4;
  }
}
:root[data-theme="dark"] .maintenance-banner {
  background: #6b5300;
  color: #fff3c4;
  border-bottom-color: #a37c00;
}
:root[data-theme="dark"] .maintenance-banner a {
  color: #fff3c4;
}

/* ---- provider-aware machine fields (js/machine.js) ---- */

/* A field whose control is not a single input (a select plus tools), so it cannot be a <label>. */
div.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  min-width: 0;
}

div.field > label.field-label {
  display: block;
}

.chooser select,
.chooser input {
  width: 100%;
}

.machine-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.machine-tools .inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.machine-note > div:empty {
  display: none;
}

details.advanced {
  margin: 4px 0 12px;
}

details.advanced > summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Two wide columns for the machine selects: a size line such as
   "cpx22 -- 2 vCPU, 4 GB, 80 GB -- EUR 7.69/mo (recommended)" must not be cut off. */
.machine-fields > .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
}

/* settings.html: label/value list of the storage statistics. */
dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 8px 0 16px;
}

dl.kv dt {
  color: var(--text-muted);
}

dl.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ server page: Network tab (network.js) */

.net-head {
  align-items: baseline;
  margin-bottom: 8px;
}

.net-head h2 {
  margin: 0;
}

/* Address cards: the value is one click from being selected, and has a Copy button. */
.net-tiles {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.selectable {
  user-select: all;
}

.tile-actions {
  margin-top: 8px;
}

/* An address followed by its Copy button, e.g. in the server header. */
.ip-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Source ranges as small code chips. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

code.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12.5px;
}

.cidr-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cidr-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cidr-add {
  max-width: 460px;
  margin-bottom: 4px;
}

.cidr-add input {
  flex: 1 1 auto;
}

/* The "Copied" message. Fixed at the bottom, announced by aria-live, hidden until .show. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 50;
}

.toast.show {
  opacity: 1;
}

/* Off-screen textarea used by the clipboard fallback. */
.copy-fallback {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
}

/* Network tab refinements: the TxS address must not break inside the port, the add field and its
   button share a line, and the card titles sit at the top of their card. */
.net-tiles .tile-value {
  font-size: 17px;
  overflow-wrap: normal;
  white-space: nowrap;
}

.cidr-add input {
  width: auto;
  min-width: 0;
}

#panel-network .card > h3:first-child {
  margin-top: 0;
}

/* Firewall rule editor (network.js ruleRow / editForm / addRuleForm): the add form wraps on a
   phone, the inline edit row spans the table, and the sources field takes the free width. */
.rule-add {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.rule-add h4 {
  margin: 0 0 4px;
}

.rule-add-row {
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.rule-add-row label.field {
  margin-bottom: 0;
}

.rule-add-row label.field.grow {
  flex: 1 1 260px;
}

.rule-edit td {
  background: var(--surface-2);
}

.rule-edit .row {
  flex-wrap: wrap;
  align-items: center;
}

.rule-sources {
  flex: 1 1 260px;
  min-width: 0;
}

/* Daily MAGIX login code page (daily-code.html, js/dailycode.js). The code is the one thing on the
   page: large, monospace, with no wrapping, and selectable so it can also be copied by hand. */
.dc-today {
  text-align: center;
  padding: 24px 16px;
}

.dc-date {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.dc-code {
  font-family: var(--mono);
  font-size: clamp(2.75rem, 12vw, 5.5rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.1;
  white-space: nowrap;
  user-select: all;
}

.dc-actions {
  margin: 16px 0 12px;
}

.dc-copy {
  min-width: 9rem;
  min-height: 44px;
  font-size: 16px;
}

.dc-countdown {
  font-size: 14px;
  margin-bottom: 8px;
}

.dc-note {
  margin: 8px 0 0;
  font-size: 14px;
}

/* Hidden until "Reveal code" is pressed: the mask dots are not selectable and are dimmed. */
.dc-code.dc-hidden {
  color: var(--text-muted);
  user-select: none;
}

.dc-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ backups catalogue (backupsview.js) */

/* Environment badges: production is the plain one (most servers), staging amber, development blue. */
.badge.env { text-transform: none; }
.badge.env-production { background: var(--surface-2); color: var(--text); }
.badge.env-staging { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.badge.env-development { background: var(--info-bg); color: var(--info-text); border-color: transparent; }
/* "DEV · MDL" on a developer machine (dom.js machineBadge): amber, because it opens NetBIOS to the internet. */
.badge.env-mdl { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
/* "kept forever" */
.badge.kept { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; text-transform: none; }

.bk-filters { flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.bk-table th .sort, .link-button {
  background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 600;
  color: inherit; cursor: pointer; text-align: left;
}
.bk-table th .sort:hover { text-decoration: underline; }
.bk-expand { width: 28px; }
.bk-toggle { font-size: 14px; color: var(--text-muted); }
.bk-detail > td { background: var(--surface-2); padding: 12px 16px; }
.bk-panel { display: flex; flex-direction: column; gap: 12px; }
.bk-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.bk-facts dt { color: var(--text-muted); font-size: 12.5px; }
.bk-facts dd { margin: 0; overflow-wrap: anywhere; }
.bk-pager { margin-top: 8px; align-items: center; }
.prefill-note { margin-bottom: 8px; }
.bk-table th .sort { text-transform: inherit; letter-spacing: inherit; font-size: inherit; }
.bk-pager select, .bk-filters select { width: auto; }
.bk-facts input[type="text"] { max-width: 520px; }

/* ------------------------------------------------------------------ DNS names (js/dns.js, dnscard.js, dnssettings.js) */

/* Under the form grid: the name block takes the full width, its two fields stack. */
.dns-block {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* The subdomain box with its live ".<zone>" suffix after it. The box shrinks; the suffix never wraps. */
.dns-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.dns-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.dns-suffix {
  font-family: var(--mono, ui-monospace, monospace);
  color: var(--text-muted);
  white-space: nowrap;
}

/* A plain note under a field (why the box is off). */
.field-note {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
}

/* A confirmation under a field (the name is free). Same colours as the success banner. */
.field-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
  font-size: 12px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 4px;
}

/* A warning under a field (a name held by another server). Same colours as the warning banner. */
.field-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 12px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 4px;
}

/* The DNS card on the server page (Network tab). */
.dns-name {
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.dns-tiles {
  margin-top: 10px;
}

.dns-actions {
  margin-top: 12px;
  flex-wrap: wrap;
}

.dns-assign {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/*
 * The DNS name and IPv4 under a server name in the servers list (servers.js, serverRow). One line:
 * each value (mono) followed by its copy button, wrapping on a narrow screen. The line sits in the
 * name cell but outside the server's link, so a click on a copy button never navigates.
 */
.addr-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  margin-top: 2px;
}

.addr-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  overflow-wrap: anywhere;
}

/*
 * The small copy button next to a value: no border or fill until hovered, so it reads as an
 * icon. button.copy-mini (not .copy-mini) so it beats the "button.small" size from copyButton.
 */
button.copy-mini {
  min-height: 0;
  box-shadow: none;
  padding: 0 5px;
  margin-left: 2px;
  font-size: 14px;
  line-height: 1.3;
  border-color: transparent;
  background: transparent;
  color: var(--link);
  cursor: pointer;
}

button.copy-mini:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

/* Servers list status filter (servers.js): as wide as its longest option, not the whole header. */
#servers-status {
  width: auto;
}

/* Daily backup card (js/backupdaily.js, Backups tab of a server): the project boxes in a grid that wraps on a
   phone. The [hidden] rule is needed because the grid would otherwise show a hidden list. */
.bkd-projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.25rem 1rem;
  margin: 0.25rem 0 0.5rem;
}
.bkd-projects[hidden] {
  display: none;
}
#daily-backup-card fieldset {
  border: 0;
  margin: 0 0 0.75rem;
  padding: 0;
}

/* Force stop dialog (server.js openForceStop): the choice of what to stop is a fieldset. Drop the browser frame so it
   reads like the other fields, and keep the legend in the field-label style. */
fieldset.field {
  border: 0;
  margin: 0 0 12px;
  padding: 0;
  min-width: 0;
}
fieldset.field > legend {
  padding: 0;
  margin-bottom: 6px;
}

/* ---------------------------------------------------------------- dialogs, busy buttons, actions menu (worker C) */

/* Busy button (dom.js withBusy): a spinner before the label while the request runs. The button is disabled
   by withBusy, so the spinner is also the only sign that something is happening. */
button.busy::before {
  content: '';
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.45em;
  vertical-align: -0.12em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: busy-spin 0.8s linear infinite;
}
@keyframes busy-spin {
  to { transform: rotate(360deg); }
}

/* Determinate progress bar (backupsview.js openDelete): the fill's width is set from JS to done / total.
   The fill slides a little between the one-second polls; reduced motion makes it jump. */
.dlg-progress {
  margin: 12px 0;
}
.dlg-progress-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-2);
}
.dlg-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--link);
  transition: width 0.4s linear;
}
.dlg-progress-text {
  margin: 6px 0 0;
}
@media (prefers-reduced-motion: reduce) {
  button.busy::before {
    animation: none;
  }
  .dlg-progress-fill {
    transition: none;
  }
}

/* Server tabs (nav.tabs): scroll sideways only when the tabs do not fit. overflow-x:auto alone turns
   overflow-y into auto too, which drew a vertical scrollbar for the 2 px of the active underline; hidden
   vertically fixes that. The 1 px bottom padding keeps the underline inside the clipped box. */
nav.tabs {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding-bottom: 1px;
}

/* Actions menu (server.js buildActionsMenu): a popover under the "Actions" button in the server header.
   The panel floats over the page. Its items are plain text rows: no border, no fill, a soft grey wash on hover
   and focus. Red is for destructive items only; the disruptive ones are normal text under their label.
   The delete protection block is a footer (deleteprotection.js) with its own tinted background. */
.actions-wrap {
  position: relative;
  display: inline-block;
}
/* The Actions menu is a fixed popover, so it does not move when the page scrolls (the button is in the fixed app bar,
   which does not scroll either). It is placed below the app bar: top is the bar's bottom edge plus 6 px, and its
   height is capped to the rest of the window, so the whole menu can be reached (the items scroll inside the cap,
   the flex rule below keeps them from being squeezed). The horizontal place (right of the button, or inside the
   window on a phone) is set by server.js placePanel. z-index 30 is inside the app bar's stacking context (25), so it
   is above the page content and the server tab bar (20); the date popover (40) and toast (50) are above the bar. */
.actions-menu {
  position: fixed;
  top: calc(var(--nav-bar-h, 0px) + var(--appbar-h, 64px) + 6px);
  right: 0;
  max-height: calc(100vh - var(--nav-bar-h, 0px) - var(--appbar-h, 64px) - 22px);
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-sizing: border-box;
  min-width: 280px;
  max-width: min(340px, calc(100vw - 32px));
  padding: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.actions-menu[hidden] {
  display: none;
}
/* The panel is a flex column. Without flex-shrink: 0 the browser squeezed the items to fit a height cap (the buttons
   have min-height: 0), so their padding vanished and the menu looked congested. Kept so no future cap can do that again. */
.actions-menu > * {
  flex-shrink: 0;
}
/* On a phone the panel spans the window (left and right are set by server.js placePanel); it may not be wider than the window. */
@media (max-width: 899px) {
  .actions-menu {
    min-width: 0;
    max-width: calc(100vw - 16px);
  }
}
/* The horizontal place of the panel (its right edge under the button, kept inside the window and clear of the sidebar)
   is set by server.js placePanel. On a phone the panel is nearly the full width (set there as left and right). */
/* A group label: small, uppercase, muted. It has room above it so it reads as the start of a group. */
.actions-menu .actions-menu-label {
  padding: 12px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.actions-menu hr.actions-menu-sep {
  height: 0;
  margin: 6px 6px;
  border: 0;
  border-top: 1px solid var(--border);
}
/* The item rule is written with two classes plus the element so it beats the generic button, button.primary
   and button.danger rules. */
.actions-menu button.menu-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 7px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  /* A long label ("Roll back project to previous release") wraps onto a second line. The item grows with its text
     (no fixed height), so the second line never runs into the next item. */
  white-space: normal;
  height: auto;
  min-height: 0;
  line-height: 1.35;
  cursor: pointer;
}
.actions-menu button.menu-item:hover:not(:disabled),
.actions-menu button.menu-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}
.actions-menu button.menu-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--link);
}
/* magix-start, the first item while MAGIX is shut: the link colour and bold, nothing else. */
.actions-menu button.menu-item.primary {
  color: var(--link);
  font-weight: 600;
}
/* Destructive playbooks only (destroy, destroy-failed-server): red text, a red tint on hover. */
.actions-menu button.menu-item.danger {
  color: var(--err-text);
}
.actions-menu button.menu-item.danger:hover:not(:disabled),
.actions-menu button.menu-item.danger:focus-visible {
  background: var(--err-bg);
}
/* A disabled item is muted and does not react to hover or focus. */
.actions-menu button.menu-item:disabled {
  background: transparent;
  color: var(--text-muted);
  cursor: not-allowed;
}
.actions-menu .actions-menu-empty {
  margin: 6px 12px;
}
/* Delete protection (deleteprotection.js): a footer under the destructive items. It bleeds to the panel edges
   (the negative margins cancel the panel padding), so it reads as a separate section, not as more items. */
.actions-menu .actions-protection {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px -6px -6px;
  padding: 10px 12px 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 13px;
  line-height: 1.35;
}
/* The padlock and the status text share one line. The status may wrap, but the padlock stays beside its first line. */
.actions-menu .actions-protection-state {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--text-muted);
}
.actions-menu .actions-protection-state strong {
  color: var(--text);
  font-weight: 600;
}
/* The padlock drawn in deleteprotection.js (lockIcon). It takes the text colour and sits on the first text line. */
.lock-icon {
  flex: none;
  margin-top: 1px;
}
/* The Lock / Unlock button is a real small button (button.small), full width under the state line. */
.actions-menu .actions-protection button.small {
  width: 100%;
}

/* D-121: the flyout menu. The groups are the top level; a group's items open beside the panel (flyout) or replace the
   panel on a narrow or touch screen (drill-down, with a "‹ Back" row). The flyout is the same panel style: it is fixed,
   and server.js placeFlyout sets its left and top through CSSOM. Its own right and top come from here, not from .actions-menu. */
.actions-flyout {
  right: auto;
  top: 0;
  z-index: 31;
  /* A fixed width: without it the flyout shrinks to its longest summary and fills the window on a narrow desktop. */
  width: 320px;
  max-height: calc(100vh - 16px);
}
/* A group row: the name with ▸ on the right, and the one-line description under it. */
.actions-menu button.menu-group {
  padding: 9px 12px;
}
.actions-menu .menu-group-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.actions-menu .menu-group-name {
  font-weight: 600;
}
.actions-menu button.menu-item.danger .menu-group-name {
  color: var(--err-text);
}
.actions-menu .menu-arrow {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
}
/* The group whose flyout (or drill-down) is open keeps a soft wash, so the top level shows where the flyout comes from. */
.actions-menu button.menu-item[aria-expanded="true"] {
  background: var(--surface-2);
}
/* An item: the title, then the summary under it, the Stops MAGIX tag and the disabled reason as small visible text. */
.actions-menu .menu-item-title {
  display: block;
}
.actions-menu .menu-item-summary {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.actions-menu .menu-item-reason {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}
.actions-menu .menu-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  vertical-align: 1px;
  color: var(--warn-text);
  background: var(--warn-bg);
}
/* "‹ Back" on a drill-down: the first row, a link colour, so it reads as a control and not as an action. */
.actions-menu button.menu-item.menu-back {
  color: var(--link);
  font-weight: 600;
}
/* On a narrow or touch screen the drill-down label is the group's name, above its items. */
.actions-menu .actions-menu-label {
  padding-top: 6px;
}
/* The reinstall dialog's summary (reinstall.js): three plain lines in a bordered box. */
.reinstall-summary {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1.4;
}
.reinstall-summary p {
  margin: 4px 0;
}

/* Merge polish: the page does not shift sideways when one tab scrolls and the next does not, and on a phone the
   server tabs scroll sideways without showing a scrollbar track under them. */
html {
  scrollbar-gutter: stable;
}

@media (max-width: 720px) {
  nav.tabs {
    scrollbar-width: none;
  }
}

/* ---------------------------------------------------------------- sticky server tabs, date inputs */

/* Server page: the tab bar stays directly under the app bar while the page scrolls (its top is the app bar's
   bottom edge: the phone bar's height plus --appbar-h). It carries its own page background so content scrolls
   under it. The crumbs and the server's name are in the app bar, so the tab bar needs no trail of its own.
   Below 900 px the tabs scroll with the page instead (the phone bar and the app bar already take the top of the
   window there, and a third sticky row would leave too little room for the page). */
.server-bar {
  position: sticky;
  top: calc(var(--nav-bar-h, 0px) + var(--appbar-h, 64px));
  z-index: 20;
  background: var(--bg);
  margin: 0 -2px 14px;
  padding: 0 2px;
}

.server-bar nav.tabs {
  margin-bottom: 0;
}

@media (max-width: 899px) {
  .server-bar {
    position: static;
  }
}

/* The Backups filter row: the From and To date filters wrap as one group. */
.date-range {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

/* Date and time inputs: the same box as the other inputs, but only as wide as their content (a filter row
   holds two of them side by side). color-scheme makes the browser draw the calendar and clock icons and the
   picker in the page's theme, so they stay visible in dark mode. */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  width: auto;
  padding: 0 8px;
  color-scheme: light;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.7;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input[type="date"],
  :root:not([data-theme="light"]) input[type="time"],
  :root:not([data-theme="light"]) input[type="datetime-local"] {
    color-scheme: dark;
  }
}

:root[data-theme="dark"] input[type="date"],
:root[data-theme="dark"] input[type="time"],
:root[data-theme="dark"] input[type="datetime-local"] {
  color-scheme: dark;
}

/*
 * Releases page (D-104, releases.html, js/releases.js). Only what the page needs beyond the shared classes: the
 * rows of the deploy dialog, the step lists of the confirmations, and the action buttons of the matrix. The
 * upload card reuses .form-grid, .field, .file-progress, .progress and .notice.
 */

.deploy-rows {
  display: grid;
  gap: 10px;
  margin: 8px 0;
}

.deploy-row {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.deploy-row-head {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.deploy-row-head select {
  width: auto;
  flex: 1 1 180px;
  min-width: 0;
}

.deploy-row-head input[type="text"] {
  width: auto;
  flex: 0 1 160px;
  min-width: 0;
}

.deploy-row fieldset.when-picker {
  margin: 0;
}

.confirm-group {
  margin: 12px 0;
}

.confirm-group h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.confirm-steps {
  margin: 0;
  padding-left: 1.4em;
  display: grid;
  gap: 3px;
  font-size: 13px;
  color: var(--text-muted);
}

.matrix-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 640px) {
  .deploy-row-head select,
  .deploy-row-head input[type="text"] {
    flex: 1 1 100%;
  }
}

/* ------------------------------------------------------------------ zip backups (D-110: backupsview.js, restorefiles.js) */

/* The "zip" chip on a backup run stored as one zip per project. */
.badge.format-zip { background: var(--info-bg); color: var(--info-text); border-color: transparent; }

/* The project zips of a run: one row each, its files under it. */
table.bk-zips td.num, table.bk-zips th.num { white-space: nowrap; }
table.bk-zips .bk-zip-actions { white-space: nowrap; }
table.bk-entries td.num, table.bk-entries th.num { white-space: nowrap; }

/* Restore files dialog: the quick buttons, the file list (scrolls inside the dialog) and the warnings. */
.rf-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.rf-table-wrap { max-height: 300px; overflow: auto; }
table.rf-table td.num, table.rf-table th.num { white-space: nowrap; }
table.rf-table tr.is-chosen > td { background: var(--info-bg); }
.rf-warn-title { margin-top: 12px; }

/* The project zip checkboxes of Restore to new server. */
.rf-projects { margin: 8px 0 12px; }
.rf-projects-list { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.rf-projects .field-label { display: block; margin-bottom: 4px; }

/* A long "contains damaged files: ..." badge wraps inside the Status cell instead of widening the backups table. */
table.bk-table td .badge { white-space: normal; max-width: 280px; }

/* D-113 backup schedules */
/* Styles of backupschedules.js: the Backup schedules and Schedule log cards of a server (Backups tab). */

/* The card head: the title on the left, the Add schedule button on the right; it wraps on a phone. */
.bs-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.bs-head > h2 { margin: 0 0 14px; }

/* The table scrolls sideways inside the card on a narrow screen instead of pushing the page wide. */
.bs-table-wrap { overflow-x: auto; }
table.bs-table td.bs-actions, table.bs-table th:last-child { white-space: nowrap; }
table.bs-table td.mono { word-break: break-word; }
table.bs-log td:nth-child(1), table.bs-log td:nth-child(3) { white-space: nowrap; }

/* The empty state: one line and the button, centred in the card. */
.bs-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 8px 0; }

/* The dialog: the quick presets, the weekday boxes, the project boxes, the live preview. */
.bs-form { display: flex; flex-direction: column; gap: 4px; }
.bs-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.bs-days, .bs-projects { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.bs-monthly, .bs-once { display: flex; flex-direction: column; gap: 4px; }
.bs-form fieldset.field { border: 0; padding: 0; margin: 0; }
.bs-form fieldset.field > legend { padding: 0; }
/* The rule and scope switches set the hidden attribute; the display rules above would override it, so it is forced here. */
.bs-form [hidden] { display: none !important; }
.bs-form input[type="month"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 34px;
  padding: 0 10px;
  width: 100%;
  min-width: 0;
}
/* A field the validator refused: the border turns to the danger colour (aria-invalid is set too). */
.bs-form [aria-invalid="true"] { border-color: var(--danger-solid); }
.bs-form fieldset[aria-invalid="true"] { outline: 1px solid var(--danger-solid); outline-offset: 4px; border-radius: var(--radius); }

/* The preview box: a quiet panel under the form that says what the schedule will do. */
.bs-preview-box {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 10px; padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.bs-preview { margin: 0; }

/* The log's footer: Older on the left, the link to the monitor on the right. */
.bs-log-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }

/* ------------------------------------------------------------------ D-113: dealers (dealers.js), servers by dealer (servers.js), dealer pickers */

/* The row above one dealer's servers on the Servers page: sentence case, not the table's upper-case headings. */
table.data tr.dealer-group th {
  text-transform: none;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--text);
  padding-top: 12px;
}

/* A Dealers page detail card: one environment (Production, Staging, Development) and its servers. */
.dealer-env h2 { margin-top: 0; }

/* D-113 backup monitor and the backup row chips */

/* Backup row chips: a schedule's label is not upper-cased like the kind badges; the copy line sits under the chip. */
.badge.sched { text-transform: none; background: var(--info-bg); color: var(--info-text); border-color: transparent; }
.bk-copy { margin-top: 3px; }
.bk-dealer-row { margin-top: 10px; }

/* Backup monitor page */
.bk-monitor-banner { margin-bottom: 12px; }
.bk-monitor-counts { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.bk-count { display: flex; flex-direction: column; gap: 2px; min-width: 150px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.bk-count-value { font-size: 20px; font-weight: 600; }
.bk-count.ok .bk-count-value { color: var(--ok-text); }
.bk-count.bad .bk-count-value { color: var(--danger-text); }
.bk-monitor-section { margin-top: 22px; }
.bk-monitor-section h2 { font-size: 16px; margin: 0; }
.bk-monitor-head { align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.bk-sched-label { font-weight: 600; }
.mon-reason { max-width: 360px; overflow-wrap: anywhere; }
.bk-monitor-table td, .bk-log-table td { vertical-align: top; }

/* The Dealer and Environment filters of the Servers list (servers.js): as wide as their text, like the status filter. */
#servers-dealer,
#servers-env {
  width: auto;
}

/* ------------------------------------------------------------------ MAGIX memory plan (D-114, memorybar.js, machine.js) */

/* The bar: one part per use of the machine's RAM, widths set from JS. The parts differ in colour AND in the legend
   text beside the bar, so the colours are never the only carrier. Theme variables only: light and dark both work. */
.mem-bar {
  display: flex;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 8px 0;
}
.mem-bar.compact { height: 8px; margin: 6px 0 2px; }
.mem-seg { display: block; height: 100%; min-width: 2px; }
.mem-seg + .mem-seg { border-left: 1px solid var(--surface); }
.mem-cache { background: var(--accent); }
.mem-magix { background: var(--link); opacity: 0.55; }
.mem-system { background: var(--c-stopped); }
.mem-spare { background: var(--c-running); }

.mem-legend {
  list-style: none;
  margin: 4px 0 8px;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 13px;
}
.mem-legend li { display: flex; gap: 8px; align-items: baseline; }
.mem-swatch {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
  position: relative;
  top: 1px;
}
.mem-legend-text { min-width: 0; }

/* The suggested-machine card and the "Change machine" list. */
.machine-suggest {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  margin: 4px 0 8px;
}
.machine-suggest-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.machine-suggest-name { font-size: 16px; font-weight: 700; }
.machine-suggest-spec { color: var(--text-muted); }
.machine-suggest-price { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.machine-suggest-empty { color: var(--text-muted); margin: 0; }

.size-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}
.size-row {
  display: block;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
.size-row:hover { background: var(--row-hover); }
.size-row.selected { border-color: var(--accent); background: var(--accent-soft); }
.size-row.dim { color: var(--text-muted); }
.size-row.dim .mem-bar { opacity: 0.45; }
.size-row.disabled { cursor: not-allowed; }
.size-row-top { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.size-row-top input { margin: 0 2px 0 0; }
.size-row-price { margin-left: auto; font-variant-numeric: tabular-nums; }
.size-row-note { font-size: 12.5px; color: var(--text-muted); }
.size-row-reason { font-size: 12.5px; }

.form-section {
  margin: 14px 0 6px;
  font-size: 15px;
}
.restore-hint { margin: 4px 0 8px; }

/* Recover from journal dialog (journalrecover.js): one column, one choice per line, so the long radio labels stay readable. */
.jr-stack { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.jr-group { border: 1px solid var(--border, #ddd); border-radius: 6px; padding: 10px 12px; margin: 0; }
.jr-group > .inline-check { display: flex; gap: 6px; align-items: baseline; margin: 4px 0; }
.jr-sub { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 0 22px; }
.jr-sub > .field { min-width: 240px; flex: 1; }
