/* Tessergate console, styled after X: near-black, white text, one blue, pill buttons, thin borders.
   Dark is the default; html[data-theme="light"] switches to a business look: a cool grey page, white cards with a
   soft shadow, a tinted menu and slate text. */
:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --surface-2: #16181c;
  --hover: rgba(231, 233, 234, 0.08);
  --inset: #000000;
  --fg: #e7e9ea;
  --fg-2: #c4c7ca;
  --muted: #71767b;
  --line: #2f3336;
  --line-strong: #3e4144;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --accent-soft: rgba(29, 155, 240, 0.12);
  --accent-fg: #ffffff;
  --ok: #00ba7c;
  --ok-soft: rgba(0, 186, 124, 0.14);
  --warn: #ffd400;
  --warn-soft: rgba(255, 212, 0, 0.12);
  --danger: #f4212e;
  --danger-soft: rgba(244, 33, 46, 0.12);
  --stage: #000000;
  --header: rgba(0, 0, 0, 0.72);
  --shadow: none;
  --nav-bg: transparent;
  --thead: transparent;
  --ring: rgba(29, 155, 240, 0.4);
  --radius: 16px;
  --radius-sm: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #dfe4ea;
  --surface: #f3f5f8;
  --surface-2: #e9edf2;
  --hover: rgba(30, 41, 59, 0.05);
  --inset: #fafbfc;
  --fg: #1e293b;
  --fg-2: #334155;
  --muted: #64748b;
  --line: #d5dce4;
  --line-strong: #bcc6d2;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --ok: #15803d;
  --ok-soft: rgba(22, 163, 74, 0.11);
  --warn: #a16207;
  --warn-soft: rgba(234, 179, 8, 0.16);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --stage: #d5dce4;
  --header: rgba(236, 240, 244, 0.94);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.05);
  --nav-bg: #e8ecf1;
  --thead: #e9edf2;
  --ring: rgba(37, 99, 235, 0.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--fg); background: var(--bg); }
body { display: flex; flex-direction: column; min-height: 100vh; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { outline: none; }
.icon { display: block; flex: none; width: 18px; height: 18px; }
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace; font-size: 0.85em; }
[hidden] { display: none !important; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 56px; padding: 0 20px;
  background: var(--header);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark { display: block; flex: none; color: var(--accent); }
.brand-name { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.01em; }
.brand-sub { padding-left: 10px; border-left: 1px solid var(--line-strong); color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.who { display: inline-flex; align-items: center; gap: 8px; margin-right: 6px; color: var(--fg); font-size: 0.9rem; font-weight: 700; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who::before {
  content: attr(data-initial);
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 0.8rem; font-weight: 800; text-transform: uppercase;
}
.top .ghost {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--fg);
  font-size: 0.9rem; font-weight: 700;
}
.top .ghost:hover { background: var(--hover); }
#theme { width: 36px; padding: 0; justify-content: center; }
#theme .sun { display: none; }
html[data-theme="light"] #theme .sun { display: block; }
html[data-theme="light"] #theme .moon { display: none; }

/* Page */
.panel {
  width: min(440px, calc(100% - 32px));
  margin: 56px auto 40px; padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel.wide { width: min(1080px, calc(100% - 32px)); margin-top: 28px; padding: 0; background: transparent; border: 0; box-shadow: none; }
/* Admin pages use the whole width. */
.panel.wide.admin { width: 100%; max-width: none; margin: 0; }
.foot { margin-top: auto; padding: 20px 16px 24px; color: var(--muted); font-size: 0.8rem; text-align: center; }

h1 { margin: 0 0 6px; font-size: 1.45rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.25; }
h2 { margin: 0; font-size: 1.1rem; font-weight: 800; }
.lede { margin: 0 0 24px; color: var(--muted); font-size: 0.95rem; max-width: 72ch; }
.section-desc { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; max-width: 72ch; }
.sub-head { margin: 26px 0 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: 0.95rem; font-weight: 800; }

/* Admin shell: menu on the left, one section on the right. */
/* The menu's column is painted on the shell, so its colour and divider run the full height of long pages. */
.x-shell {
  --nav-w: 260px;
  display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: calc(100vh - 56px);
  background: linear-gradient(to right, var(--nav-bg) calc(var(--nav-w) - 1px), var(--line) calc(var(--nav-w) - 1px), var(--line) var(--nav-w), transparent var(--nav-w));
}
/* Admin pages fill the window; the page footer would only sit under the menu. */
body.admin-page .foot { display: none; }
.x-nav {
  position: sticky; top: 56px; align-self: start;
  display: flex; flex-direction: column; gap: 2px;
  height: calc(100vh - 56px); padding: 14px 12px;
}
.x-nav-item {
  display: inline-flex; align-items: center; gap: 18px; width: fit-content; max-width: 100%;
  padding: 12px 22px 12px 14px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--fg);
  font-size: 1.15rem; font-weight: 400; text-align: left;
  transition: background 0.15s ease;
}
.x-nav-item .icon { width: 26px; height: 26px; }
.x-nav-item:hover { background: var(--hover); }
.x-nav-item.active { font-weight: 800; }
.x-nav-item.active .icon { stroke-width: 2.6; color: var(--accent); }
.x-nav-item.back { margin-top: auto; color: var(--muted); font-size: 1rem; }
.x-main { min-width: 0; padding: 0 28px 40px; }
.x-head {
  position: sticky; top: 56px; z-index: 2;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 -28px; padding: 18px 28px 14px;
  background: var(--header); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.x-head .lede { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Sign-in card */
.card-head { display: flex; align-items: center; gap: 12px; margin: 0 0 24px; }
.card-head .mark { width: 38px; height: 38px; }
.card-head strong { display: block; font-size: 1.05rem; font-weight: 800; }
.card-head span { display: block; color: var(--muted); font-size: 0.85rem; }
.trust {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 24px -32px -32px; padding: 12px 16px;
  border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  color: var(--muted); font-size: 0.8rem;
}
.trust .icon { width: 14px; height: 14px; }

/* Sections */
.block { margin-top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.block > .block-head, .block > h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.block > .block-head > h2 { flex: none; }
.block > .block-head .section-desc { flex: 1 1 100%; }
.block > form, .block > .block-body, .block > .sheet-scroll, .block > .note, .block > .logo, .block > .users, .block > table, .block > .day,
.block > div:not(.block-head), .block > p, .block > dl { margin-left: 20px; margin-right: 20px; }
.block > form { padding-bottom: 20px; }
.block > .sheet-scroll { margin: 0; border: 0; border-radius: 0; }
.block > div > .sheet-scroll { margin: 0 -20px; border: 0; border-radius: 0; }
.block > .note { margin-top: 14px; }
.block > .note:last-child { margin-bottom: 20px; }
.block > .users:last-child { margin-bottom: 16px; }
.block > .logo { margin: 16px 20px 0; }
.block > div:last-child { margin-bottom: 20px; }
.block > div:has(> .sheet-scroll):last-child { margin-bottom: 0; }
/* section() wraps its content in .block-body: padded on every side, tables edge to edge. */
.block > .block-body { padding-top: 16px; }
.block > .block-body > :first-child { margin-top: 0; }
.block > .block-body:has(> .sheet-scroll:first-child) { padding-top: 0; }
.block-body > .sheet-scroll { margin: 0 -20px; border: 0; border-radius: 0; }
.block-body > .switch-row:first-child { padding-top: 0; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 0.8rem; font-weight: 700; }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.banner {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0 0; padding: 14px 18px;
  border: 1px solid var(--warn); border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--fg); font-size: 0.9rem;
}
.banner .icon { color: var(--warn); }

/* Lists */
.users { list-style: none; margin: 14px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.users:empty { display: none; }
.users li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 10px 12px 10px 16px; border-top: 1px solid var(--line); font-size: 0.95rem; }
.users li:first-child { border-top: 0; }
.users li:hover { background: var(--hover); }
.users li span { min-width: 0; overflow-wrap: anywhere; }
.users li .sub, .sub { color: var(--muted); font-size: 0.85rem; }
.users li.empty { color: var(--muted); }
.users .row-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.avatar { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; text-transform: uppercase; }
.users li .who-cell { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; }
.users li .who-cell .sub { flex-basis: 100%; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; margin-left: 8px; padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.75rem; font-weight: 700; white-space: nowrap; vertical-align: 1px;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { margin-left: 0; background: var(--danger-soft); color: var(--danger); }
.badge.off { margin-left: 0; background: var(--hover); color: var(--muted); }
.badge.off::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box; }
.status-cell .badge { margin-left: 0; }
.status-cell .when { display: block; margin-top: 4px; color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.badge.plain { margin-left: 0; background: transparent; color: var(--fg-2); border: 1px solid var(--line-strong); }
.cert-line .badge, .service-line .badge { margin-left: 0; }

/* Forms */
label { display: block; margin: 18px 0 6px; color: var(--fg-2); font-size: 0.85rem; font-weight: 700; }
input, select, textarea {
  width: 100%; height: 44px; padding: 0 14px;
  border-radius: 6px; border: 1px solid var(--line-strong);
  background: var(--inset);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
textarea { height: auto; padding: 10px 14px; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.8rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
input[type="number"] { appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }
input[type="file"] { height: auto; padding: 10px 12px; border-style: dashed; color: var(--muted); font-size: 0.9rem; }
input[type="file"]::file-selector-button {
  margin-right: 12px; height: 32px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: transparent; color: var(--fg); font: inherit; font-weight: 700; cursor: pointer;
}
label.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; color: var(--fg); font-size: 0.95rem; font-weight: 500; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; padding: 0; flex: none; accent-color: var(--accent); }
fieldset { margin: 20px 0 0; padding: 0; border: 0; min-width: 0; }
fieldset + fieldset { margin-top: 26px; }
legend { display: block; width: 100%; padding: 0 0 8px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 12px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.find { display: grid; grid-template-columns: minmax(0, 1fr) 200px auto; gap: 12px; align-items: end; margin: 20px 0 0; padding: 16px 20px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.find label { margin-top: 0; }
.find button { height: 44px; }
#record-find { grid-template-columns: minmax(0, 1fr) 180px 140px auto; }

/* Switches */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin: 0; padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--fg); font-weight: 400; cursor: pointer;
}
form > .switch-row:first-child, .block-head + form > .switch-row:first-child { padding-top: 18px; }
.switch-text { display: grid; gap: 2px; min-width: 0; }
.switch-label { font-size: 0.98rem; font-weight: 700; }
.switch-desc { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
input.switch { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch-ui {
  position: relative; flex: none;
  width: 42px; height: 24px; border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.15s ease;
}
.switch-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease;
}
input.switch:checked + .switch-ui { background: var(--accent); }
input.switch:checked + .switch-ui::after { transform: translateX(18px); }
input.switch:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
input.switch:disabled + .switch-ui { opacity: 0.5; }
.mini-switch { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--fg-2); font-size: 0.85rem; font-weight: 700; cursor: pointer; }
.mini-switch .switch-ui { width: 36px; height: 20px; }
.mini-switch .switch-ui::after { width: 14px; height: 14px; }
.mini-switch input.switch:checked + .switch-ui::after { transform: translateX(16px); }

.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented label { margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span {
  display: inline-flex; align-items: center; height: 38px; padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--fg); font-size: 0.9rem; font-weight: 700;
}
.segmented span:hover { background: var(--hover); }
.segmented input:checked + span { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons: pills, as on X. Primary is the blue one. */
.ghost, .secondary, .primary, .pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 20px;
  border-radius: 999px;
  font-size: 0.95rem; font-weight: 700; white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.primary .icon, .secondary .icon, .pill .icon { width: 16px; height: 16px; }
.primary { border: 0; background: var(--accent); color: var(--accent-fg); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary, .ghost { border: 1px solid var(--line-strong); background: transparent; color: var(--fg); }
.secondary:hover, .ghost:hover { background: var(--hover); }
.pill { height: 32px; padding: 0 14px; border: 1px solid var(--line-strong); background: transparent; color: var(--fg); font-size: 0.85rem; }
.pill:hover { background: var(--hover); }
.pill.danger, .users .pill:hover { border-color: rgba(244, 33, 46, 0.5); color: var(--danger); }
.pill.danger:hover { background: var(--danger-soft); }
.primary[data-armed="1"] { background: var(--danger); }
form > .primary, form > .secondary { margin-top: 22px; }
.panel:not(.wide) form > .primary { width: 100%; height: 46px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px; }
.panel:not(.wide) .button-row .primary { flex: 1 1 auto; height: 46px; }
.panel:not(.wide) .button-row .secondary { height: 46px; }
.inline-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.inline-add > .secondary { height: 44px; margin: 0; }
.inline-add.three { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; }
.crumbs { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 0.85rem; color: var(--muted); }
.crumbs button, button.link, .linkish { padding: 0; border: 0; background: none; color: var(--accent); font-weight: 700; }
.crumbs button:hover, button.link:hover, .linkish:hover { text-decoration: underline; }
.linkish { display: inline-flex; margin-top: 14px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .lede { margin-bottom: 0; }

/* Messages */
.error { color: var(--danger); margin: 10px 0 0; font-size: 0.9rem; }
.error:empty, .note:empty { display: none; }
.note { color: var(--muted); margin: 8px 0 0; font-size: 0.85rem; }
.note.saved { color: var(--ok); }
.warn-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 20px; color: var(--fg-2); }
.warn-note .icon { color: var(--warn); margin-top: 1px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 14px 0 4px; }
.loading::before { content: ""; width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.output { margin-top: 12px; }
.output summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; font-weight: 700; }
pre, .output pre {
  max-height: 420px; overflow: auto; margin: 10px 0 0; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--fg-2);
  font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.78rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}

/* The upgrade's pop-up: the installer's output as it runs. */
.upgrade-window {
  width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 22px 24px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--fg);
}
.upgrade-window::backdrop { background: rgba(0, 0, 0, 0.6); }
.upgrade-window h2 { margin: 0; font-size: 1.1rem; }
.upgrade-window pre { height: min(52vh, 460px); max-height: none; }
.upgrade-window pre:empty { display: none; }

/* Facts (service and certificate) */
.service-line, .cert-line { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.cert-line strong { font-size: 1rem; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 16px 0 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.cert-card { margin-top: 4px; }

/* Authenticator setup. The QR code stays black on white in both themes so cameras read it. */
.qr { display: flex; justify-content: center; margin: 4px 0 8px; }
.qr img { display: block; max-width: 100%; height: auto; border-radius: var(--radius-sm); background: #fff; border: 1px solid var(--line); image-rendering: pixelated; }
.qr-link { margin: 0 0 12px; text-align: center; font-size: 0.85rem; }
.qr-link a { color: var(--accent); font-weight: 700; }
@media (hover: hover) and (pointer: fine) { .qr-link { display: none; } }
.manual { margin: 0 0 8px; }
.manual summary { cursor: pointer; color: var(--fg-2); font-size: 0.85rem; font-weight: 700; text-align: center; }
.manual[open] summary { margin-bottom: 10px; }
.manual .note { text-align: center; }
.secret { margin: 0 0 4px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--line-strong); font-family: ui-monospace, Consolas, monospace; font-size: 0.95rem; letter-spacing: 0.1em; text-align: center; word-break: break-all; }

/* Recent computers */
.recents { display: flex; flex-wrap: wrap; gap: 8px; margin: 28px -32px -32px; padding: 18px 32px 24px; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.recents-label { flex: 1 0 100%; margin: 0 0 2px; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.recents button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; font-size: 0.85rem; font-weight: 700; }
.recents button:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.recents .icon { width: 14px; height: 14px; color: var(--muted); }

/* Stats and tables */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 20px 0 0; }
.stat { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 12px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-icon { grid-row: span 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.stat-icon .icon { width: 20px; height: 20px; }
.stat-label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.stat strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat.live .stat-icon, .stat.ok .stat-icon { background: var(--ok-soft); color: var(--ok); }
.stat.ok strong { color: var(--ok); font-size: 1.25rem; }
.stat.alert .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat.alert strong { color: var(--danger); }
/* CPU, memory and storage on the Overview. */
.usages { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 14px 0 0; }
.usage { display: grid; gap: 10px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.usage-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.usage-head .stat-icon { grid-row: auto; width: 34px; height: 34px; }
.usage-head .stat-icon .icon { width: 18px; height: 18px; }
.usage-head strong { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.usage-bar { height: 8px; border-radius: 999px; background: var(--surface-2, rgba(127, 127, 127, 0.15)); overflow: hidden; }
.usage-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.4s ease; }
.usage.warn .usage-bar i { background: var(--warn); }
.usage.alert .usage-bar i { background: var(--danger); }
.usage.alert strong { color: var(--danger); }
.usage-detail { color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* Network */
.net-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.net-card .facts { margin-top: 10px; }
.net-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.net-line .badge { margin-left: 0; }
.net-manager { color: var(--muted); font-size: 0.85rem; }
.net-line .net-edit { margin-left: auto; }
button.small { padding: 6px 12px; font-size: 0.85rem; }
.net-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.net-pending { flex-wrap: wrap; }
.net-pending .button-row { margin: 0 0 0 auto; }
#net-countdown { font-variant-numeric: tabular-nums; }
.sheet-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.sheet { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { text-align: left; padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.sheet tr:last-child td { border-bottom: 0; }
.sheet th { color: var(--muted); background: var(--thead); font-weight: 700; font-size: 0.8rem; }
html[data-theme="light"] .sheet th { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.72rem; }
html[data-theme="light"] .x-nav-item.active { background: var(--surface); box-shadow: var(--shadow); color: var(--accent); }
html[data-theme="light"] .x-nav-item { font-size: 1.05rem; }
.sheet td:first-child { font-weight: 700; }
.sheet tbody tr:hover td { background: var(--hover); }
.sheet td.empty { color: var(--muted); font-weight: 400; text-align: center; padding: 26px 14px; }
.day { margin: 0; padding: 12px 20px; font-size: 0.85rem; font-weight: 800; color: var(--fg); background: var(--surface-2); border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); }

/* Admin hub (older layout kept for safety) */
.admin-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

/* Branding */
.brand-lockup { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0 0 24px; padding: 0 0 20px; border-bottom: 1px solid var(--line); }
.logo { display: block; max-width: 220px; max-height: 72px; margin: 0 auto; object-fit: contain; }
.block > .logo { margin-left: 20px; max-height: 56px; }
.logo-text { margin: 0; text-align: center; font-weight: 700; color: var(--fg-2); }

/* Desktop session */
.stage { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--stage); }
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; min-height: 54px; padding: 8px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
.stage-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stage-name .icon { color: var(--accent); }
#stage-title { font-size: 0.95rem; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-tools button { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--fg); font-size: 0.85rem; font-weight: 700; }
.stage-tools button:hover { background: var(--hover); }
.stage-tools .sep { width: 1px; margin: 4px; background: var(--line-strong); }
#close-session { color: #fff; border-color: transparent; background: var(--danger); }
#close-session:hover { filter: brightness(1.1); }
.stage-frame { flex: 1; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
canvas { background: #000; outline: none; touch-action: none; cursor: default; box-shadow: 0 0 0 1px var(--line); }
#stage-note, #stage-error { margin: 8px 14px 0; }

/* Open a computer, with My computers beside it. */
.panel.duo {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start;
  width: min(920px, calc(100% - 32px)); padding: 0; background: transparent; border: 0; box-shadow: none;
}
.panel.duo > .ready-main, .panel.duo > .profile {
  min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel.duo > .ready-main { padding: 32px; }
.profile { padding: 20px; }
.profile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.profile-head strong { display: block; font-size: 1.05rem; }
.profile-head .sub { display: block; overflow-wrap: anywhere; }
.pcs { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; max-height: 420px; overflow-y: auto; }
.pcs li { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.pcs li:first-child { border-top: 0; }
.pcs li.empty { padding: 16px; color: var(--muted); font-size: 0.9rem; }
.pc { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 0; background: transparent; color: var(--fg); text-align: left; cursor: pointer; }
.pc:hover, .pc:focus-visible { background: var(--accent-soft); }
.pc > .icon { flex: none; width: 18px; height: 18px; color: var(--muted); }
.pc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pc-text strong, .pc-text .mono, .pc-text .sub { overflow-wrap: anywhere; }
.pc-text .mono { color: var(--fg-2); }
.pc .badge { flex: none; }
.pc-remove { flex: none; width: 40px; display: grid; place-items: center; padding: 0; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--muted); cursor: pointer; }
.pc-remove:hover { color: var(--danger); background: var(--hover); }
.pc-remove .icon { width: 16px; height: 16px; }
#profile-message:empty { display: none; }
#pc-add { margin-top: 14px; }
#pc-add > summary { display: inline-flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; }
#pc-add > summary::-webkit-details-marker { display: none; }
#pc-add[open] > summary { margin-bottom: 4px; }
#pc-form .row { grid-template-columns: minmax(0, 1fr) 90px; }
@media (max-width: 860px) {
  .panel.duo { grid-template-columns: 1fr; width: min(560px, calc(100% - 32px)); }
}

/* Activity lists wrap long text and page through older rows. */
.sheet.wrap td { white-space: normal; overflow-wrap: anywhere; min-width: 80px; }
.sheet.wrap td .badge, .sheet.wrap td .when { white-space: nowrap; }
.pager { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.pill:disabled { opacity: 0.45; cursor: default; background: transparent; }

@media (max-width: 1000px) {
  .x-shell { --nav-w: 76px; }
  .x-nav { padding: 12px 8px; align-items: center; }
  .x-nav-item { padding: 12px; }
  .x-nav-item span { display: none; }
}

@media (max-width: 720px) {
  .x-shell { grid-template-columns: 1fr; background: none; }
  .x-nav { position: sticky; top: 56px; z-index: 3; flex-direction: row; height: auto; padding: 6px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--nav-bg); }
  .x-nav-item.back { margin-top: 0; }
  .x-main { padding: 0 14px 32px; }
  .x-head { position: static; margin: 0 -14px; padding: 14px; }
  .row, .find, .pair, .inline-add, .inline-add.three { grid-template-columns: 1fr; }
  .panel { margin-top: 16px; padding: 24px 18px; }
  .trust { margin: 24px -18px -24px; }
  .recents { margin: 24px -18px -24px; padding: 16px 18px 20px; }
  .panel.duo { padding: 0; }
  .panel.duo > .ready-main { padding: 24px 18px; }
  #record-find { grid-template-columns: 1fr; }
  .top { padding: 0 12px; }
  .brand-sub, .who { display: none; }
  .top .ghost .label { display: none; }
  .block > .block-head, .block > h2 { padding: 14px 16px; }
  .block > form, .block > .block-body, .block > .note, .block > .users, .block > div:not(.block-head), .block > p, .block > dl { margin-left: 16px; margin-right: 16px; }
  .stage-tools button .label { display: none; }
  .users li { flex-wrap: wrap; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.error-text { color: var(--danger); font-weight: 600; }

/* Sign-in page laid out by the designer: five regions, the sign-in box is one block among them. */
body.branded { background: var(--signin-bg); }
.signin-page { width: min(1280px, calc(100% - 32px)); margin: 32px auto 40px; }
.signin-layout { display: flex; flex-direction: column; gap: 28px; }
.signin-row { display: flex; gap: 40px; align-items: center; justify-content: center; }
.region { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.region-left, .region-right { flex: 1 1 0; }
.region-center { flex: 0 1 460px; }
.signin-row > .region:only-child { flex: 0 1 460px; }
.signin-row.three { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px) minmax(0, 1fr); }
.signin-card { width: 100%; max-width: 440px; margin: 0 auto; }
.b-block { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.b-block.align-left { text-align: left; }
.b-block.align-center { text-align: center; }
.b-block.align-right { text-align: right; }
.b-logo img { display: inline-block; max-width: 100%; height: 80px; object-fit: contain; }
.b-logo.size-s img { height: 48px; }
.b-logo.size-l img { height: 140px; }
.b-heading { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.b-heading.size-s { font-size: 1.2rem; }
.b-heading.size-l { font-size: 2.2rem; }
.b-text { color: var(--fg-2); font-size: 1rem; line-height: 1.55; }
.b-text.size-s { font-size: 0.88rem; }
.b-text.size-l { font-size: 1.2rem; }
body.on-dark .signin-layout > .region .b-block, body.on-dark .signin-row > .region .b-block { color: #f1f5f9; }
body.on-light .signin-layout > .region .b-block, body.on-light .signin-row > .region .b-block { color: #0f172a; }
@media (max-width: 760px) {
  .signin-row, .signin-row.three { display: flex; flex-direction: column; align-items: stretch; gap: 24px; }
  .signin-row > .region:empty { display: none; }
  .region-left, .region-right, .region-center { flex: none; }
  .signin-row > .has-signin { order: -1; }
}

/* The designer on Admin → Sign-in page. */
a.secondary, a.primary { text-decoration: none; }
.designer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.designer-spacer { flex: 1; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; cursor: pointer; }
.inline-field input[type="checkbox"] { width: 18px; height: 18px; padding: 0; margin: 0; accent-color: var(--accent); }
#layout-bg { width: 44px; height: 36px; padding: 2px; border-radius: 8px; }
.designer { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.designer-row { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 10px; }
.zone { position: relative; min-height: 84px; padding: 26px 10px 10px; border: 2px dashed var(--line-strong); border-radius: 12px; transition: border-color 0.15s ease, background 0.15s ease; }
.zone.over { border-color: var(--accent); background: var(--accent-soft); }
.zone-label { position: absolute; top: 6px; left: 10px; color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.designer.on-dark .zone-label { color: #cbd5e1; }
.zone-items { display: flex; flex-direction: column; gap: 8px; }
.zone-empty { padding: 14px 6px; color: var(--muted); font-size: 0.85rem; text-align: center; }
.d-item { display: flex; align-items: flex-start; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: grab; }
.d-item:hover { border-color: var(--line-strong); }
.d-item.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.d-item.dragging { opacity: 0.35; }
.d-grip { flex: none; color: var(--muted); padding-top: 2px; }
.d-preview { flex: 1; min-width: 0; pointer-events: none; }
.d-preview .b-heading { font-size: 1.05rem; }
.d-preview .b-heading.size-l { font-size: 1.3rem; }
.d-preview .b-text { font-size: 0.85rem; max-height: 6.5em; overflow: hidden; }
.d-preview .b-logo img { height: 36px; }
.d-preview .b-logo.size-l img { height: 52px; }
.d-signin { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 4px; }
.d-signin span { flex-basis: 100%; color: var(--muted); font-size: 0.8rem; }
.d-empty { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.85rem; }
.block-editor { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.block-editor:empty { display: none; }
.editor-head { display: flex; align-items: baseline; gap: 8px; }
.editor-move { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.editor-move select { width: auto; min-width: 140px; }
.secondary.danger { color: var(--danger); border-color: rgba(244, 33, 46, 0.5); }
.segmented.compact span { padding: 6px 12px; font-size: 0.85rem; }
.image-current { display: flex; align-items: center; justify-content: center; min-height: 88px; padding: 10px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.image-current .logo { max-height: 64px; margin: 0; }
.favicon-preview { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; }
@media (max-width: 760px) {
  .designer-row { grid-template-columns: 1fr; }
}

/* Admin → Updates */
.install-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 8px; }
.install-grid .sub-head.first { margin-top: 0; padding-top: 0; border-top: 0; }
.install-grid input[type="datetime-local"] { max-width: 280px; }
.install-grid button { margin-top: 14px; }
.banner .secondary { margin-left: 10px; height: 32px; }
@media (max-width: 760px) { .install-grid { grid-template-columns: 1fr; } }

/* Overview: network traffic graph. Two validated series colours per theme (received blue, sent orange). */
.net-graph { --net-rx: #3987e5; --net-tx: #d95926; }
html[data-theme="light"] .net-graph { --net-rx: #2a78d6; --net-tx: #eb6834; }
.net-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 4px 0 8px; font-size: 0.88rem; color: var(--muted); }
.net-legend span { display: inline-flex; align-items: center; gap: 8px; }
.net-legend strong { color: var(--fg); font-variant-numeric: tabular-nums; }
.net-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.net-key.rx { background: var(--net-rx); }
.net-key.tx { background: var(--net-tx); }
.net-plot { position: relative; }
.net-plot svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.net-grid { stroke: var(--line); stroke-width: 1; }
.net-grid.base { stroke: var(--line-strong); }
.net-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.net-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.net-line.rx, .net-dot.rx { stroke: var(--net-rx); }
.net-line.tx, .net-dot.tx { stroke: var(--net-tx); }
.net-dot { fill: var(--surface); stroke-width: 2; }
.net-cross-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.net-hit { fill: transparent; cursor: crosshair; }
.net-tip { position: absolute; top: 0; display: grid; gap: 4px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: var(--shadow); font-size: 0.82rem; pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.net-tip span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.net-graph .output { margin-top: 10px; }

/* Services: the firewall and nginx */
textarea.code { width: 100%; min-height: 260px; line-height: 1.5; white-space: pre; overflow: auto; tab-size: 4; }
.rule-form { display: grid; grid-template-columns: 110px 150px 110px minmax(0, 1fr) auto; gap: 12px; align-items: end; margin-top: 14px; }
.rule-form label { margin-top: 0; }
.rule-form .primary { height: 44px; }
#sec-firewall .sheet td .pill { height: 28px; padding: 0 10px; }
#sec-nginx .facts pre { margin-top: 8px; }
@media (max-width: 720px) { .rule-form { grid-template-columns: 1fr 1fr; } .rule-form .rule-from, .rule-form .primary { grid-column: 1 / -1; } }
