/*
 * Mars stylesheet: the Apollo style guide (docs/STYLE_GUIDE.md) written as plain CSS.
 * Values are Tailwind v3 defaults: gray/blue steps, a 4 px spacing scale, 4/6/8/12 px radii.
 * Dark mode follows the guide's remap table: html.dark recolors the same roles, it is not a second palette.
 */

/* ---------- Tokens ---------- */
:root {
  --font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --brand: #2563eb;          /* blue-600 */
  --brand-hover: #1d4ed8;    /* blue-700 */
  --brand-bright: #3b82f6;   /* blue-500 */
  --brand-muted: #60a5fa;    /* blue-400 */
  --sidebar: #111827;        /* gray-900, both themes */
  --ring: #3b82f6;

  --canvas: #ffffff;         /* bg-white */
  --canvas-subtle: #f9fafb;  /* bg-gray-50 */
  --muted: #f3f4f6;          /* bg-gray-100 */
  --raised: #e5e7eb;         /* bg-gray-200 */
  --hover: #f9fafb;          /* hover:bg-gray-50 */
  --hover-strong: #f3f4f6;   /* hover:bg-gray-100 */

  --text: #111827;           /* gray-900 */
  --text-800: #1f2937;
  --text-700: #374151;
  --text-600: #4b5563;
  --text-500: #6b7280;
  --text-400: #9ca3af;

  --border: #e5e7eb;         /* gray-200 */
  --border-strong: #d1d5db;  /* gray-300 */
  --link: #2563eb;
  --link-hover: #1e40af;
  --error: #dc2626;

  --input-bg: #ffffff;
  --input-text: #111827;
  --placeholder: #9ca3af;

  --wash-blue: #eff6ff;      /* blue-50 */
  --toggle-border: #93c5fd;
  --toggle-text: #1d4ed8;

  /* status pills: background / text */
  --pill-neutral-bg: #f3f4f6; --pill-neutral-fg: #374151;
  --pill-info-bg: #dbeafe;    --pill-info-fg: #1d4ed8;
  --pill-success-bg: #d1fae5; --pill-success-fg: #047857;
  --pill-warning-bg: #fef3c7; --pill-warning-fg: #b45309;
  --pill-danger-bg: #fee2e2;  --pill-danger-fg: #b91c1c;
  --pill-high-bg: #ffedd5;    --pill-high-fg: #c2410c;

  --amber-wash: #fffbeb; --amber-border: #fcd34d; --amber-text: #78350f; --amber-icon: #b45309;
  --emerald-wash: #ecfdf5; --emerald-border: #d1fae5; --emerald-text: #065f46;
  --red-wash: #fef2f2; --red-border: #fecaca; --red-text: #b91c1c;
  --info-wash: #eff6ff; --info-border: #dbeafe; --info-text: #1e40af;

  --danger-border: #fca5a5; --danger-text: #b91c1c; --danger-hover: #fee2e2;

  --code-bg: #f1f5f9; --code-text: #0f172a;

  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  color-scheme: light;
}

html.dark {
  --canvas: #111827;
  --canvas-subtle: #1f2937;
  --muted: #1f2937;
  --raised: #374151;
  --hover: #1f2937;
  --hover-strong: #374151;

  --text: #f3f4f6;
  --text-800: #e5e7eb;
  --text-700: #d1d5db;
  --text-600: #9ca3af;
  --text-500: #9ca3af;
  --text-400: #9ca3af;

  --border: #374151;
  --border-strong: #4b5563;
  --link: #60a5fa;
  --link-hover: #93c5fd;
  --error: #f87171;

  --input-bg: #111827;
  --input-text: #e5e7eb;
  --placeholder: #6b7280;

  --wash-blue: #1f2937;
  --toggle-border: #1e40af;
  --toggle-text: #60a5fa;

  --pill-neutral-bg: #374151;               --pill-neutral-fg: #d1d5db;
  --pill-info-bg: rgb(30 58 138 / 0.55);    --pill-info-fg: #93c5fd;
  --pill-success-bg: rgb(6 78 59 / 0.6);    --pill-success-fg: #6ee7b7;
  --pill-warning-bg: rgb(120 53 15 / 0.55); --pill-warning-fg: #fcd34d;
  --pill-danger-bg: rgb(127 29 29 / 0.55);  --pill-danger-fg: #fca5a5;
  --pill-high-bg: rgb(154 52 18 / 0.55);    --pill-high-fg: #fdba74;

  --amber-wash: rgb(120 53 15 / 0.35); --amber-border: #92400e; --amber-text: #fde68a; --amber-icon: #fbbf24;
  --emerald-wash: rgb(6 78 59 / 0.35); --emerald-border: #065f46; --emerald-text: #a7f3d0;
  --red-wash: rgb(127 29 29 / 0.35); --red-border: #7f1d1d; --red-text: #fca5a5;
  --info-wash: #1f2937; --info-border: #374151; --info-text: #93c5fd;

  --danger-border: #7f1d1d; --danger-text: #f87171; --danger-hover: rgb(127 29 29 / 0.35);

  --code-bg: #1f2937; --code-text: #e5e7eb;

  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: var(--border); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, ol, ul, pre, fieldset { margin: 0; }
ol, ul { padding: 0; list-style: none; }
fieldset { padding: 0; min-width: 0; }
legend { padding: 0; }
img, svg { display: block; }
.icon { flex-shrink: 0; display: inline-block; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { cursor: pointer; background: none; padding: 0; }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
a { color: var(--link); text-decoration: none; transition: color 150ms; }
a:hover { color: var(--link-hover); }
strong { font-weight: 600; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 60; background: var(--brand); color: #fff; padding: 6px 12px; border-radius: 6px; }
.skip-link:focus { top: 8px; color: #fff; }

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.grow { flex: 1 1 auto; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; }
.inline { display: inline; }
.center { text-align: center; }
.mb-3 { margin-bottom: 12px; }
.mt-3 { margin-top: 12px; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }
.wrap-anywhere { overflow-wrap: anywhere; word-break: break-all; }
.text-secondary { color: var(--text-500); }
.text-muted { color: var(--text-400); }
.text-meta { color: var(--text-400); font-size: 12px; line-height: 16px; }
/* What went wrong and why: as small as meta text, but dark enough to read (meta grey is for times and IDs). */
.text-detail { color: var(--text-500); font-size: 12px; line-height: 16px; }
.text-detail.text-danger { color: var(--danger-text); }
.narrow { max-width: 768px; }
.narrow-sm { max-width: 448px; }
.form-narrow { max-width: 384px; }

/* ---------- App shell ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: 256px; display: flex; flex-direction: column;
  background: var(--sidebar); color: #d1d5db;
  padding-left: env(safe-area-inset-left); padding-bottom: env(safe-area-inset-bottom);
  transition: width 200ms, transform 200ms;
}
.sidebar-head { height: 56px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid #374151; flex-shrink: 0; }
.wordmark { color: #fff; font-size: 18px; line-height: 28px; font-weight: 600; letter-spacing: -0.025em; }
.wordmark:hover { color: #fff; }
.wordmark-short { display: none; color: var(--brand-muted); }
.nav { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 6px;
  font-size: 14px; line-height: 20px; font-weight: 500;
  color: #d1d5db; white-space: nowrap;
  transition: background-color 150ms, color 150ms;
}
.nav-item:hover { background: #1f2937; color: #fff; }
.nav-item.is-active { background: var(--brand); color: #fff; }
.nav-label {
  display: flex; align-items: center; gap: 6px;
  margin: 16px 0 4px; padding: 0 12px;
  font-size: 11px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
  color: #6b7280;
}
.sidebar-foot { padding: 12px 20px; font-size: 12px; line-height: 16px; color: #6b7280; border-top: 1px solid #1f2937; white-space: nowrap; overflow: hidden; }
.nav-scope { margin-top: 16px; text-transform: none; letter-spacing: 0; font-size: 13px; color: #e5e7eb; }
.nav-scope span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav > .nav-label:first-child { margin-top: 4px; }
.nav-hint { margin: 0 0 4px; padding: 0 12px; font-size: 13px; line-height: 18px; color: #6b7280; white-space: normal; }

.column { margin-left: 256px; min-height: 100vh; display: flex; flex-direction: column; transition: margin-left 200ms; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0;
  display: flex; align-items: center; gap: 4px;
  background: var(--canvas); border-bottom: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }
.main {
  flex: 1; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  container-type: inline-size; min-width: 0;
}
.main > .alert { margin-bottom: 16px; }

/* collapsed rail (≥768 px) */
.sidebar-collapsed .sidebar { width: 64px; }
.sidebar-collapsed .column { margin-left: 64px; }
.sidebar-collapsed .sidebar-head { justify-content: center; padding: 0; }
.sidebar-collapsed .wordmark-full,
.sidebar-collapsed .nav-text,
.sidebar-collapsed .nav-label span { display: none; }
.sidebar-collapsed .wordmark-short { display: inline; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 8px; }
.sidebar-collapsed .nav-label { justify-content: center; padding: 0; }

.scrim { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 0.5); }

@media (min-width: 640px) {
  .topbar { padding-left: 16px; padding-right: 16px; }
  .main { padding: 16px; }
}
@media (min-width: 768px) {
  .main { padding: 24px; }
  .scrim { display: none !important; }
}
@media (max-width: 767.98px) {
  .sidebar { transform: translateX(-100%); width: 256px !important; }
  .sidebar-open .sidebar { transform: none; }
  .column, .sidebar-collapsed .column { margin-left: 0; }
  .sidebar-collapsed .wordmark-full, .sidebar-collapsed .nav-text, .sidebar-collapsed .nav-label span { display: revert; }
  .sidebar-collapsed .wordmark-short { display: none; }
  .sidebar-collapsed .nav-item { justify-content: flex-start; padding: 8px 12px; }
  .sidebar-collapsed .sidebar-head { justify-content: flex-start; padding: 0 16px; }
  .sidebar-collapsed .nav-label { justify-content: flex-start; padding: 0 12px; }
}

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.page-title { font-size: 24px; line-height: 32px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.count-badge { background: var(--brand-bright); color: #fff; font-size: 14px; line-height: 20px; font-weight: 600; padding: 2px 8px; border-radius: 9999px; font-variant-numeric: tabular-nums; }
.section-label {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.025em;
  color: var(--text-500);
}
.section-label .pill { text-transform: none; letter-spacing: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px; border: 1px solid transparent; border-radius: 6px;
  font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap;
  transition: background-color 150ms, color 150ms, border-color 150ms;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); color: #fff; }
.btn-primary:disabled:hover { background: var(--brand); }
.btn-secondary { padding: 6px 10px; border-color: var(--border); color: var(--text-600); background: transparent; }
.btn-secondary:hover { background: var(--hover); color: var(--text-600); }
.btn-secondary[aria-pressed="true"] { background: var(--wash-blue); border-color: var(--toggle-border); color: var(--toggle-text); }
.btn-danger { padding: 6px 10px; border-color: var(--danger-border); color: var(--danger-text); background: transparent; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-block { width: 100%; border-radius: 4px; padding-top: 8px; padding-bottom: 8px; }
.btn-text { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; line-height: 20px; color: var(--text-500); transition: color 150ms; }
.btn-text:hover { color: var(--text-700); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px; border-radius: 4px; color: var(--text-600);
  transition: background-color 150ms, color 150ms;
}
.icon-btn:hover { background: var(--hover-strong); color: var(--text-600); }
.icon-btn-danger:hover { color: var(--danger-text); background: var(--danger-hover); }
.btn.is-busy { opacity: 0.7; cursor: progress; }
.label-short { display: none; }
@media (max-width: 767.98px) {
  .label-long { display: none; }
  .label-short { display: inline; }
}
@media (max-width: 639.98px) {
  .btn, .btn-text, .icon-btn { min-height: 40px; }
}

/* theme button shows the current choice */
[data-theme-icon] { display: none; }
html[data-theme="light"] [data-theme-icon="light"],
html[data-theme="dark"] [data-theme-icon="dark"],
html[data-theme="system"] [data-theme-icon="system"] { display: inline-flex; }

/* ---------- Avatar & menus ---------- */
.avatar-btn { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 9999px; transition: background-color 150ms; }
.avatar-btn:hover { background: var(--hover-strong); }
.avatar { width: 32px; height: 32px; border-radius: 9999px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.avatar-name { font-size: 14px; font-weight: 500; color: var(--text-700); }
@media (max-width: 639.98px) { .avatar-name { display: none; } }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 100%; margin-top: 4px; z-index: 50;
  width: 160px; padding: 4px 0;
  background: var(--canvas); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg);
}
.menu-wide { width: 224px; }
.menu-head { padding: 8px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-head-name { font-weight: 500; color: var(--text-800); }
.menu-head-meta { font-size: 12px; line-height: 16px; color: var(--text-400); overflow-wrap: anywhere; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 12px; font-size: 14px; line-height: 20px; text-align: left;
  color: var(--text-700); transition: background-color 150ms;
}
.menu-item:hover { background: var(--hover); color: var(--text-700); }
.menu-item.is-current { color: var(--link); font-weight: 500; }

/* ---------- Cards, facts, lists ---------- */
.card { background: var(--canvas); border: 1px solid var(--border); border-radius: 8px; }
.card-pad { padding: 20px; }
.card-highlight { border-color: var(--toggle-border); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 24px; margin-bottom: 16px; }
.card > .facts:last-child { margin-bottom: 0; }
.facts dt { font-size: 12px; line-height: 16px; color: var(--text-500); margin-bottom: 2px; }
.facts dd { color: var(--text-800); overflow-wrap: anywhere; }
.action-list { display: flex; flex-direction: column; }
.action-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
.action-list .action-row:first-child { padding-top: 0; }
.action-list .action-row:last-child { padding-bottom: 0; }
.action-list .action-row + .action-row { border-top: 1px solid var(--border); }
.action-row > div:first-child { flex: 1 1 260px; }
.divider-line { border-top: 1px solid var(--border); margin: 20px 0 16px; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; font-size: 12px; line-height: 16px; font-weight: 500; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.pill-neutral { background: var(--pill-neutral-bg); color: var(--pill-neutral-fg); }
.pill-info { background: var(--pill-info-bg); color: var(--pill-info-fg); }
.pill-success { background: var(--pill-success-bg); color: var(--pill-success-fg); }
.pill-warning { background: var(--pill-warning-bg); color: var(--pill-warning-fg); }
.pill-danger { background: var(--pill-danger-bg); color: var(--pill-danger-fg); }
.pill-high { background: var(--pill-high-bg); color: var(--pill-high-fg); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, .field > legend, .field > .label { font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text); }
.field > legend { margin-bottom: 4px; }
.help { font-size: 12px; line-height: 16px; color: var(--text-500); }
.input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 14px; line-height: 20px; background: var(--input-bg); color: var(--input-text);
}
.input::placeholder { color: var(--placeholder); opacity: 1; }
.input:focus { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.input:disabled { opacity: 0.5; }
select.input { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.select-auto { width: auto; }
.input-code { font-family: var(--font-mono); font-size: 20px; line-height: 28px; text-align: center; letter-spacing: 0.1em; }
.input-recovery { font-size: 16px; text-transform: uppercase; }
.form-error { color: var(--error); font-size: 14px; line-height: 20px; }
.row-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.row-form + .form-error { margin-top: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; transition: background-color 150ms, border-color 150ms; }
.choice + .choice { margin-top: 8px; }
.choice input { margin-top: 3px; accent-color: var(--brand); }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice:has(input:checked) { background: var(--wash-blue); border-color: var(--toggle-border); }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-400); }
.search .input { padding-left: 32px; border-radius: 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
@media (max-width: 639.98px) {
  .input { font-size: 16px; }
  .input-code { font-size: 20px; }
}

/* ---------- Tables ---------- */
.table-wrap { background: var(--canvas); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; min-width: 560px; }
.table thead { background: var(--canvas-subtle); }
.table th { text-align: left; padding: 8px 12px; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-500); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.table td { padding: 8px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background-color 150ms; }
.table tbody tr:hover { background: var(--hover); }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table .col-actions form { display: inline-block; }
.table .col-actions .cell-actions { display: inline-flex; gap: 8px; justify-content: flex-end; }
.cell-title { color: var(--text-800); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.link-plain:hover { color: var(--link); }
.row-link { cursor: pointer; }
.res-progress { max-width: 420px; }
.pill-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.table-audit td:nth-child(3) { min-width: 280px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- Empty, alerts, banners ---------- */
.empty { border: 1px dashed var(--border-strong); border-radius: 12px; padding: 40px; text-align: center; font-size: 14px; color: var(--text-500); }
.empty-compact { padding: 24px; }
.empty-icon { display: flex; justify-content: center; color: var(--text-400); margin-bottom: 8px; }
.alert { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; border: 1px solid; border-radius: 8px; font-size: 12px; line-height: 16px; }
.alert .icon { margin-top: 0; width: 16px; height: 16px; }
.alert-success { background: var(--emerald-wash); border-color: var(--emerald-border); color: var(--emerald-text); }
.alert-info { background: var(--info-wash); border-color: var(--info-border); color: var(--info-text); }
.alert-warning { background: var(--amber-wash); border-color: var(--amber-border); color: var(--amber-text); }
.alert-error { background: var(--red-wash); border-color: var(--red-border); color: var(--red-text); }
.banner { display: flex; gap: 12px; padding: 12px 16px; border: 1px solid; border-radius: 8px; font-size: 14px; line-height: 20px; }
.banner-warning { background: var(--amber-wash); border-color: var(--amber-border); color: var(--amber-text); }
.banner-warning > .icon { color: var(--amber-icon); margin-top: 1px; }
.banner-success { background: var(--emerald-wash); border-color: var(--emerald-border); color: var(--emerald-text); }
.banner-danger { background: var(--red-wash); border-color: var(--red-border); color: var(--red-text); }
.banner > .icon { flex: none; margin-top: 1px; }
.banner-list { margin: 4px 0 0; padding-left: 18px; }
.banner strong { display: block; }

/* ---------- Code ---------- */
.code { font-family: var(--font-mono); font-size: 0.875em; background: var(--code-bg); color: var(--code-text); padding: 0.125em 0.35em; border-radius: 0.25em; }
.codeblock { position: relative; background: #1e293b; color: #e2e8f0; border-radius: 8px; padding: 16px; }
.codeblock pre { font-family: var(--font-mono); font-size: 0.875em; line-height: 1.6; overflow-x: auto; margin: 0; }
.codeblock-copy { position: absolute; top: 8px; right: 8px; font-size: 0.7rem; line-height: 1; padding: 6px 8px; border: 1px solid rgb(255 255 255 / 0.2); border-radius: 4px; color: #e2e8f0; transition: background-color 150ms; }
.codeblock-copy:hover { background: rgb(255 255 255 / 0.08); }
.codeblock-copy.is-copied { color: #86efac; background: rgb(34 197 94 / 0.2); border-color: rgb(134 239 172 / 0.4); }
.secret-row { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; }
.secret { font-size: 14px; padding: 6px 10px; letter-spacing: 0.05em; }
.icon-btn.is-copied, .btn.is-copied { color: #059669; }

/* ---------- Sign-in canvas ---------- */
body.auth { background: var(--canvas-subtle); }
.auth-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 16px; }
.auth-card { width: 100%; max-width: 384px; background: var(--canvas); border-radius: 8px; padding: 32px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 16px; }
html.dark .auth-card { border: 1px solid var(--border); }
.auth-logo { width: 48px; height: 48px; border-radius: 9px; }
.auth-title { font-size: 24px; line-height: 32px; font-weight: 700; }
.auth-step { font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.025em; color: var(--text-500); margin-bottom: -12px; }
.auth-text { color: var(--text-600); }
.auth-text strong { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.auth-links { text-align: center; }
.auth-help { font-size: 14px; }
.auth-help > div { margin-top: 8px; }
.auth-cancel { display: flex; justify-content: center; }
.auth-foot { font-size: 12px; color: var(--text-400); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-400); font-size: 12px; margin-bottom: 16px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.steps { list-style: decimal; padding-left: 20px; color: var(--text-600); display: flex; flex-direction: column; gap: 4px; }
/* QR codes stay on a white island so phones can scan them in dark mode */
.qr-wrap { display: flex; justify-content: center; }
.qr { width: 176px; height: 176px; background: #fff; padding: 8px; border-radius: 8px; border: 1px solid #e5e7eb; }
.card .qr-wrap { margin: 4px 0; }
.card .steps { margin-bottom: 4px; }
.card .secret-row { margin-bottom: 16px; }

/* ---------- Dashboard (follows content width, not viewport) ---------- */
.dash { display: flex; flex-direction: column; gap: 16px; }
.stat-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@container (min-width: 560px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { padding: 12px; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-500); }
.stat-label .icon { color: var(--text-400); }
.stat-value { font-size: 24px; line-height: 32px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; color: var(--text-400); }
.checklist { display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 8px; }
.checklist li .icon { color: var(--text-400); }
.checklist li.is-done { color: var(--text-500); text-decoration: line-through; text-decoration-color: var(--text-400); }
.checklist li.is-done .icon { color: #059669; }

/* ---------- Dialog ---------- */
.dialog { border: 0; padding: 0; border-radius: 8px; box-shadow: var(--shadow-xl); background: var(--canvas); color: var(--text); width: calc(100% - 32px); max-width: 384px; }
.dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.dialog-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dialog-title { font-size: 16px; line-height: 24px; font-weight: 600; }
.dialog-text { color: var(--text-600); }
.dialog-text:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog.is-danger .dialog-ok { background: transparent; border-color: var(--danger-border); color: var(--danger-text); }
.dialog.is-danger .dialog-ok:hover { background: var(--danger-hover); }
.dialog-wide { max-width: 720px; max-height: calc(100vh - 64px); }
.dialog-wide .dialog-form { max-height: calc(100vh - 64px); }
/* A Google / Microsoft source's failures: one row at the top of its list, and the dialog it opens. */
.res-failed-group td:first-child { box-shadow: inset 3px 0 0 var(--danger-text); }
.res-failed-open { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.res-failures-body { overflow-y: auto; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.res-failures-why { font-size: 14px; line-height: 20px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.res-failures-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.res-failures-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.res-failures-list li a { display: inline-flex; align-items: center; gap: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
.passkey-only .form-error { margin-top: 8px; }

/* ======================================================================
   Backups: customers, machines, schedules, jobs, restores
   ====================================================================== */
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; line-height: 16px; }
.text-strong { color: var(--text-800); font-weight: 500; }
.text-warning { color: var(--pill-warning-fg); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@container (min-width: 900px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid-2 > .card { min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.section-head .section-label { margin-bottom: 0; }
.section-label-flush { margin-bottom: 0; }
.card-pad-b0 { padding-bottom: 0; }
.subtle-box { background: var(--canvas-subtle); border: 1px solid var(--border); border-radius: 6px; padding: 12px; display: flex; flex-direction: column; gap: 12px; }

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

textarea.input { resize: vertical; min-height: 40px; }
.input-num { width: 88px; }
.time-list { display: flex; flex-wrap: wrap; gap: 8px; }
.time-row { display: inline-flex; align-items: center; gap: 2px; }
.input-time { width: auto; min-width: 9.5rem; }
.input-sm { padding-top: 6px; padding-bottom: 6px; }
.input-static { display: inline-block; padding: 8px 0; color: var(--text-700); }
.btn-sm { padding: 4px 10px; font-size: 12px; line-height: 16px; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-inline > label { font-weight: 500; }
.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); flex-shrink: 0; }
.check > span { display: flex; flex-direction: column; gap: 2px; }
.choice-inline { padding: 6px 10px; }
.choice-inline + .choice-inline { margin-top: 0; }
.choice-inline input { margin-top: 3px; }
.script-body { font-size: 13px; line-height: 20px; tab-size: 4; }

/* status dot */
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-600); white-space: nowrap; }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 9999px; background: #94a3b8; }
.status-dot.is-online { color: var(--pill-success-fg); }
.status-dot.is-online::before { background: #059669; }

/* alerts inside the warning banner */
.alert-line + .alert-line { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--amber-border); }
.alert-line .text-meta { display: block; margin-top: 2px; color: inherit; opacity: 0.75; }
.banner-link { color: inherit; text-decoration: underline; }
.banner-link:hover { color: inherit; }

/* stats */
.stat-link { display: block; color: inherit; transition: border-color 150ms; }
.stat-link:hover { color: inherit; border-color: var(--border-strong); }
.stat-value-sm { font-size: 16px; line-height: 24px; color: var(--text-800); }
.stat-of { font-size: 14px; color: var(--text-400); font-weight: 500; }
.stat-value.stat-ok { color: var(--pill-success-fg); }
.stat-value.stat-bad { color: var(--error); }
.stat-value.stat-warn { color: var(--pill-warning-fg); }
.stat-grid + .stat-grid { margin-top: 0; }
.count-badge-sm { font-size: 12px; line-height: 16px; padding: 0 6px; }

/* meters and progress */
.meter { height: 6px; border-radius: 9999px; background: var(--muted); overflow: hidden; }
.meter-lg { height: 8px; }
.meter-fill { display: block; height: 100%; border-radius: 9999px; transition: width 300ms; }
/* Live job progress: glides between 2-second updates; pulses while there's no percentage yet. */
.meter-live { transition: width 1.8s linear; }
.meter-indeterminate .meter-fill { width: 30%; animation: meter-slide 1.6s ease-in-out infinite; }
@keyframes meter-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .meter-live { transition: none; } .meter-indeterminate .meter-fill { animation: none; width: 100%; opacity: 0.35; } }
.meter-ok { background: var(--brand); }
.meter-warning { background: #f59e0b; }
.meter-danger { background: #dc2626; }
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; } .w-25 { width: 25%; }
.w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; } .w-50 { width: 50%; } .w-55 { width: 55%; }
.w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; } .w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; }
.w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }
.disks { display: flex; flex-direction: column; gap: 10px; }
.disk .row { margin-bottom: 4px; }

/* filter chips */
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 4px 10px; border-radius: 9999px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-600); background: var(--muted); transition: background-color 150ms; }
.chip:hover { color: var(--text-700); background: var(--hover-strong); }
.chip.is-on { background: var(--wash-blue); color: var(--toggle-text); box-shadow: inset 0 0 0 1px var(--toggle-border); }

/* schedule form */
.day-picker { display: flex; flex-wrap: wrap; gap: 4px; }
.day { position: relative; }
.day input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.day span { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-weight: 500; color: var(--text-600); transition: background-color 150ms, border-color 150ms, color 150ms; }
.day input:checked + span { background: var(--wash-blue); border-color: var(--toggle-border); color: var(--toggle-text); }
.day input:focus-visible + span { box-shadow: 0 0 0 2px var(--ring); }
.keep-row .field-inline { font-weight: 400; }
.ba-grid { display: grid; grid-template-columns: 1fr; gap: 8px 16px; align-items: center; }
.ba-label { font-weight: 500; }
@media (min-width: 640px) { .ba-grid { grid-template-columns: 120px minmax(0, 1fr); } .ba-grid > .form-error { grid-column: 2; } }
.db-list { display: flex; flex-direction: column; gap: 6px; padding: 8px 0 0 24px; }

/* restore browser */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-family: var(--font-mono); font-size: 13px; margin-bottom: 12px; }
.crumbs button { padding: 2px 6px; border-radius: 4px; color: var(--link); }
.crumbs button:hover { background: var(--hover-strong); }
.crumbs button[aria-current] { color: var(--text-800); font-weight: 500; }
.crumbs .sep { color: var(--text-400); }
.browser { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); max-height: 480px; overflow: auto; }
.browser-status { padding: 24px 20px; text-align: center; }
.table-browser { min-width: 520px; }
.table-browser td, .table-browser th { padding-top: 6px; padding-bottom: 6px; }
.table-browser tr:first-child td { border-top: 0; }
.table-browser .col-check { width: 36px; }
.table-browser input[type=checkbox] { accent-color: var(--brand); }
.table-browser tr.is-selected { background: var(--wash-blue); }
.entry { display: inline-flex; align-items: center; gap: 8px; color: var(--text-800); }
button.entry { color: var(--link); font-weight: 500; }
button.entry:hover { color: var(--link-hover); }
.selected-box { display: flex; flex-direction: column; gap: 8px; }
.selected-list { display: flex; flex-direction: column; gap: 2px; font-size: 12px; line-height: 18px; color: var(--text-600); max-height: 160px; overflow: auto; }
.selected-list li { display: flex; gap: 6px; align-items: center; overflow-wrap: anywhere; }
.selected-list:empty { display: none; }

/* job page */
.warning-list { display: flex; flex-direction: column; gap: 4px; font-size: 12px; line-height: 18px; color: var(--text-600); max-height: 320px; overflow: auto; }
.log { max-height: 480px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

/* top-bar customer menu */
.company-menu { margin-left: 4px; min-width: 0; flex: 0 1 auto; }
.company-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 320px; min-width: 200px;
  padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 14px; line-height: 20px; color: var(--text-700); background: var(--input-bg); transition: background-color 150ms;
}
.company-btn:hover { background: var(--hover); }
.company-btn:focus-visible { box-shadow: 0 0 0 2px var(--brand-muted); }
.company-btn-name { flex: 1 1 auto; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-menu .menu { left: 0; right: auto; width: 300px; max-width: calc(100vw - 16px); }
.company-items { max-height: min(360px, 60vh); overflow-y: auto; }
.company-items .menu-item { justify-content: space-between; }
.company-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-filter { position: relative; padding: 4px 8px 8px; }
.menu-filter > .icon { position: absolute; left: 18px; top: calc(50% - 2px); transform: translateY(-50%); color: var(--text-400); pointer-events: none; }
.menu-filter .input { padding: 6px 10px 6px 30px; }
.menu-empty { padding: 6px 12px; font-size: 13px; color: var(--text-400); }
.menu-sep { height: 1px; margin: 4px 0; background: var(--border); }
@media (max-width: 639.98px) {
  .company-btn { min-width: 0; max-width: 46vw; }
}
.secret-row-left { justify-content: flex-start; }

/* backup job form: folder browser */
.field-label { font-size: 14px; line-height: 20px; font-weight: 500; }
.fs { overflow: hidden; }
.fs-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--canvas-subtle); }
.crumbs-flush { margin-bottom: 0; }
.fs .browser { border: 0; max-height: 360px; }
.fs-foot { padding: 8px 12px; border-top: 1px solid var(--border); }

/* agent update tracker */
.update-card { border-left: 3px solid var(--brand); }
.update-success { border-left-color: #059669; }
.update-success > .row > .icon { color: #059669; }
.update-danger { border-left-color: #dc2626; }
.update-danger > .row > .icon { color: var(--error); }
.update-warning { border-left-color: #f59e0b; }
.update-warning > .row > .icon { color: var(--amber-icon); }
.text-link { color: var(--link); }
.update-steps { display: flex; flex-wrap: wrap; gap: 4px 0; margin-top: 12px; }
.update-steps li { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-400); }
.update-steps li + li::before { content: ""; width: 24px; height: 1px; background: var(--border-strong); margin: 0 8px; }
.update-dot { width: 20px; height: 20px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; background: var(--muted); color: var(--text-500); font-variant-numeric: tabular-nums; }
.update-steps li.is-done { color: var(--text-600); }
.update-steps li.is-done .update-dot { background: #059669; color: #fff; }
.update-steps li.is-current { color: var(--text-800); font-weight: 500; }
.update-steps li.is-current .update-dot { background: var(--brand); color: #fff; }
.update-steps li.is-failed .update-dot { background: #dc2626; color: #fff; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ======================================================================
   Redesign: navigation aids and guided flows (same Apollo tokens)
   ====================================================================== */

/* breadcrumbs above page titles */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; line-height: 16px; color: var(--text-500); margin-bottom: 4px; }
.breadcrumbs a { color: var(--text-500); }
.breadcrumbs a:hover { color: var(--link); }
.breadcrumbs [aria-current] { color: var(--text-700); font-weight: 500; }
.breadcrumbs-sep { display: inline-flex; color: var(--text-400); }
.page-head-stack { display: flex; flex-direction: column; min-width: 0; }
.title-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* tabs under a page head */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin: -4px 0 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 0; margin-bottom: -1px; border-bottom: 2px solid transparent; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text-600); white-space: nowrap; transition: color 150ms, border-color 150ms; }
.tab:hover { color: var(--text-800); }
.tab.is-active { color: var(--link); border-bottom-color: var(--brand); }
.tab-count { font-size: 11px; line-height: 16px; font-weight: 600; padding: 0 6px; border-radius: 9999px; background: var(--muted); color: var(--text-600); font-variant-numeric: tabular-nums; }
.tab.is-active .tab-count { background: var(--pill-info-bg); color: var(--pill-info-fg); }

/* pills with a status dot */
.pill-dot::before { content: ""; width: 6px; height: 6px; border-radius: 9999px; background: currentColor; margin-right: 6px; }

/* status hero on a machine's overview */
.hero { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.hero-icon { width: 44px; height: 44px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hero-icon.tone-success { background: var(--pill-success-bg); color: var(--pill-success-fg); }
.hero-icon.tone-danger { background: var(--pill-danger-bg); color: var(--pill-danger-fg); }
.hero-icon.tone-warning { background: var(--pill-warning-bg); color: var(--pill-warning-fg); }
.hero-icon.tone-info { background: var(--pill-info-bg); color: var(--pill-info-fg); }
.hero-icon.tone-neutral { background: var(--muted); color: var(--text-600); }
.hero-body { flex: 1 1 280px; min-width: 0; }
.hero-title { font-size: 18px; line-height: 28px; font-weight: 600; color: var(--text); }
.hero-text { color: var(--text-600); margin-top: 2px; overflow-wrap: anywhere; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; align-self: center; }
.hero-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px 24px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.hero-facts dt { font-size: 12px; line-height: 16px; color: var(--text-500); }
.hero-facts dd { color: var(--text-800); font-weight: 500; margin-top: 2px; }

/* status tiles (overview, customer, machines) */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@container (min-width: 720px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 12px; background: var(--canvas); border: 1px solid var(--border); border-radius: 8px; color: inherit; transition: border-color 150ms, background-color 150ms; }
a.tile:hover { color: inherit; border-color: var(--border-strong); background: var(--hover); }
.tile.is-on { border-color: var(--toggle-border); background: var(--wash-blue); }
.tile-label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-500); }
.tile-value { font-size: 24px; line-height: 32px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-800); }
.tile-value.tone-success { color: var(--pill-success-fg); }
.tile-value.tone-danger { color: var(--error); }
.tile-value.tone-warning { color: var(--pill-warning-fg); }
.tile-value.is-zero { color: var(--text-400); }
/* Mars Dashboard: live tiles with a line of the last hour, what's backing up now by customer, health checks. */
.sys-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 768px) { .sys-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .sys-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.sys-tile { min-width: 0; }
.sys-tile .tile-value { font-size: 20px; line-height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-tile .tile-value .text-meta { font-weight: 400; }
.sys-spark { display: block; width: 100%; height: 24px; margin-top: 2px; }
.sys-spark polyline { fill: none; stroke: var(--brand-bright); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sys-customer + .sys-customer { margin-top: 12px; }
.sys-customer-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 2px; }
.sys-job { align-items: center; }
.sys-job .cell-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.sys-job .cell-actions form { margin: 0; }
.sys-job .cell-actions .btn { min-width: 76px; height: 30px; padding-top: 0; padding-bottom: 0; font-family: inherit; }
.sys-progress { display: flex; align-items: center; gap: 8px; width: auto; max-width: 420px; margin-top: 6px; }
.sys-progress .meter { flex: 1; }
.sys-progress .tabular { min-width: 40px; text-align: right; }
.sys-queue { list-style: none; margin: 4px 0 0; padding: 0; }
.sys-queue li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.sys-queue-why { margin-left: auto; }
.sys-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sys-stat { display: flex; flex-direction: column; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; color: inherit; }
.sys-stat strong { font-size: 20px; line-height: 28px; }
.sys-stat .tone-warning { color: var(--pill-warning-fg); }
.sys-stat .tone-danger { color: var(--error); }
.sys-checks { display: flex; flex-direction: column; }
.sys-check { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.sys-check:first-child { border-top: 0; }
.sys-more > summary { cursor: pointer; }
details.card > summary { cursor: pointer; }

/* backup job cards */
.job-cards { display: flex; flex-direction: column; gap: 12px; }
.job-card { background: var(--canvas); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.job-card.is-paused { background: var(--canvas-subtle); }
.job-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-card-title { font-size: 16px; line-height: 24px; font-weight: 600; color: var(--text-800); }
.job-card-title:hover { color: var(--link); }
.job-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.job-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 24px; margin-top: 12px; }
.job-card-grid dt { font-size: 12px; line-height: 16px; color: var(--text-500); margin-bottom: 2px; }
.job-card-grid dd { color: var(--text-800); overflow-wrap: anywhere; }
.path-list { display: flex; flex-direction: column; gap: 2px; font-family: var(--font-mono); font-size: 12px; line-height: 18px; }

/* big call-to-action empty states */
.cta { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 40px 24px; border: 1px dashed var(--border-strong); border-radius: 12px; }
.cta-icon { width: 44px; height: 44px; border-radius: 9999px; background: var(--wash-blue); color: var(--link); display: inline-flex; align-items: center; justify-content: center; }
.cta-title { font-size: 16px; line-height: 24px; font-weight: 600; color: var(--text-800); }
.cta-text { color: var(--text-500); max-width: 460px; }

/* "New" menu in the top bar */
.new-menu .menu { width: 232px; }
.menu-item-desc { display: block; font-size: 12px; line-height: 16px; color: var(--text-400); }
.menu-item-stack { display: flex; flex-direction: column; }
.new-btn .label-long { display: inline; }
@media (max-width: 639.98px) { .new-btn .label-long { display: none; } }

/* segmented choice (Windows / Linux) */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segmented button { padding: 6px 14px; font-size: 14px; font-weight: 500; color: var(--text-600); border-right: 1px solid var(--border); transition: background-color 150ms, color 150ms; display: inline-flex; align-items: center; gap: 6px; }
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: var(--hover); }
.segmented button[aria-pressed="true"] { background: var(--wash-blue); color: var(--toggle-text); }

/* numbered instructions */
.how { list-style: none; counter-reset: how; display: flex; flex-direction: column; gap: 16px; }
.how > li { counter-increment: how; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; }
.how > li::before { content: counter(how); width: 24px; height: 24px; border-radius: 9999px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.how-title { font-weight: 500; color: var(--text-800); margin-bottom: 6px; }

/* live waiting box */
.waiting { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 8px; background: var(--canvas-subtle); border: 1px solid var(--border); }
.waiting.is-found { background: var(--emerald-wash); border-color: var(--emerald-border); color: var(--emerald-text); }

/* wizard (new backup job) */
.wizard-steps { display: flex; flex-wrap: wrap; gap: 4px 0; margin-bottom: 16px; }
.wizard-steps button, .wizard-steps a { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text-400); padding: 4px 0; }
.wizard-steps li + li::before { content: ""; display: inline-block; width: 28px; height: 1px; background: var(--border-strong); margin: 0 10px; vertical-align: middle; }
.wizard-steps li { display: inline-flex; align-items: center; }
.wizard-num { width: 24px; height: 24px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: var(--muted); color: var(--text-500); }
.wizard-steps .is-current { color: var(--text-800); }
.wizard-steps .is-current .wizard-num { background: var(--brand); color: #fff; }
.wizard-steps .is-done { color: var(--text-600); }
.wizard-steps .is-done .wizard-num { background: #059669; color: #fff; }
.wizard-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wizard-nav .grow { flex: 1; }
.step-title { font-size: 16px; line-height: 24px; font-weight: 600; color: var(--text-800); }
.step-intro { color: var(--text-500); margin-top: -8px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset { padding: 6px 12px; border: 1px solid var(--border); border-radius: 9999px; font-size: 14px; color: var(--text-600); transition: background-color 150ms, border-color 150ms, color 150ms; }
.preset:hover { background: var(--hover); }
.preset[aria-pressed="true"] { background: var(--wash-blue); border-color: var(--toggle-border); color: var(--toggle-text); }
.review { display: grid; grid-template-columns: 1fr; gap: 0; }
.review > div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.review > div:first-child { border-top: 0; padding-top: 0; }
.review dt { color: var(--text-500); }
.review dd { color: var(--text-800); overflow-wrap: anywhere; }
@media (max-width: 639.98px) { .review > div { grid-template-columns: 1fr; gap: 2px; } }
details.advanced > summary { cursor: pointer; color: var(--text-600); font-weight: 500; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before { content: "›"; display: inline-block; transition: transform 150ms; }
details.advanced[open] > summary::before { transform: rotate(90deg); }
details.advanced > div { margin-top: 12px; }

/* compact list rows (overview panels) */
.rows { display: flex; flex-direction: column; }
.rows > .row-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.rows > .row-item:first-child { border-top: 0; padding-top: 0; }
.rows > .row-item:last-child { padding-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { color: var(--text-800); font-weight: 500; }
a.row-title:hover { color: var(--link); }
.row-sub { font-size: 12px; line-height: 16px; color: var(--text-500); overflow-wrap: anywhere; }
.row-progress { width: 140px; flex-shrink: 0; }
@media (max-width: 639.98px) { .row-progress { display: none; } }
.panel-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@container (min-width: 900px) { .panel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.panel-grid > * { min-width: 0; }

/* ======================================================================
   Phones and small tablets
   ====================================================================== */
.show-sm { display: none; }
.pre-wrap { white-space: pre-wrap; word-break: break-all; }

@media (max-width: 1023.98px) {
  .hide-md { display: none; }
}

@media (max-width: 767.98px) {
  /* Tabs stay one swipeable row; keep the active one in view */
  .tabs { gap: 20px; margin-left: -12px; margin-right: -12px; padding: 0 12px; scroll-snap-type: x proximity; }
  .tab { scroll-snap-align: start; }
  /* Wizard: numbers only, except the current step */
  .wizard-steps li + li::before { width: 12px; margin: 0 6px; }
  .wizard-steps button:not(.is-current) { font-size: 0; gap: 0; }
  .wizard-steps button:not(.is-current) .wizard-num { font-size: 12px; }
}

@media (max-width: 639.98px) {
  .hide-sm { display: none; }
  .show-sm { display: initial; }
  a.show-sm.icon-btn { display: inline-flex; }

  /* Top bar: menu, customer menu, New, theme, avatar */
  .topbar { gap: 2px; }
  .new-btn { padding-left: 10px; padding-right: 10px; }

  /* Page heads: title on its own line, actions full width below */
  .page-head { align-items: stretch; }
  .page-head > .row, .page-head > .btn, .page-head > form, .page-head > .menu-wrap { width: 100%; }
  .page-head > .row > .btn, .page-head > .row > form, .page-head > .row > .menu-wrap { flex: 1 1 auto; }
  .page-head > .row > form > .btn, .page-head > .row > .menu-wrap > .btn, .page-head > form > .btn, .page-head > .btn { width: 100%; }
  .page-head .menu { left: 0; right: 0; width: auto; }
  .page-title { font-size: 20px; line-height: 28px; flex-wrap: wrap; }

  /* Tables fit the screen (secondary columns are hidden), text wraps */
  .table { min-width: 0; }
  .table td, .table th { padding-left: 10px; padding-right: 10px; }
  .table-audit td:nth-child(3) { min-width: 0; }
  .table-browser th:nth-child(3), .table-browser td:nth-child(3),
  .table-browser th:nth-child(4), .table-browser td:nth-child(4) { display: none; }
  .table-browser input[type=checkbox], .check input, .choice input, .day input { width: 20px; height: 20px; }
  .table .col-actions .btn-sm { min-height: 36px; }

  /* Cards and panels */
  .card-pad { padding: 16px; }
  .hero { gap: 12px; }
  .hero-actions, .hero-actions .btn { width: 100%; }
  .hero-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-card-actions { margin-left: 0; width: 100%; }
  .job-card-actions > form, .job-card-actions > a { flex: 1 1 auto; }
  .job-card-actions .btn { width: 100%; }
  .row-item { flex-wrap: wrap; }
  .row-item > .btn, .row-item > form { margin-left: 32px; }
  .action-row > form, .action-row > form .btn { width: 100%; }
  .section-head { flex-wrap: wrap; }
  .tiles { gap: 8px; }
  .tile { padding: 10px; }
  .tile-value { font-size: 20px; line-height: 28px; }

  /* Forms */
  .row-form > .btn, .row-form > .field { width: 100%; }
  .wizard-nav { position: sticky; bottom: 0; z-index: 10; margin: 0 -12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--canvas); border-top: 1px solid var(--border); }
  .wizard-nav .btn { flex: 1 1 auto; }
  .wizard-nav .grow { display: none; }
  .presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .presets::-webkit-scrollbar { display: none; }
  .preset { white-space: nowrap; flex-shrink: 0; }
  .review > div { grid-template-columns: 1fr; }
  .fs .browser, .browser { max-height: 60vh; }
  .fs-head { flex-wrap: wrap; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; justify-content: center; }
  .filters .search { max-width: none; flex-basis: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }
  .facts { grid-template-columns: 1fr 1fr; gap: 10px 16px; }
  .how > li { grid-template-columns: 24px minmax(0, 1fr); gap: 10px; }
  .codeblock { padding: 12px; padding-top: 32px; }
  .update-steps li + li::before { width: 10px; margin: 0 4px; }
  .update-steps li span:last-child { display: none; }
  .update-steps li.is-current span:last-child { display: inline; }
  .breadcrumbs { font-size: 12px; }
  .dialog-actions .btn { flex: 1; }
  .pager { flex-direction: column; align-items: stretch; }
}

/* ---------- Restore: pick a point in time (calendar + that day's restore points) ---------- */
.rp-picker { display: grid; grid-template-columns: minmax(170px, 220px) minmax(260px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.rp-source { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.rp-source .input { width: 100%; }
.rp-chosen { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 6px; background: var(--wash-blue); border: 1px solid var(--toggle-border); }
.rp-empty { grid-column: 2 / -1; }
.cal { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px 10px; background: var(--canvas); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.cal-month { font-size: 14px; line-height: 20px; color: var(--text-800); }
.cal-head .icon-btn:disabled { opacity: 0.35; cursor: default; }
.cal-head .icon-btn:disabled:hover { background: none; }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 11px; line-height: 24px; font-weight: 500; color: var(--text-400); text-transform: uppercase; letter-spacing: 0.02em; }
.cal-day {
  position: relative; height: 36px; border-radius: 6px; font-size: 13px; color: var(--text-700);
  font-variant-numeric: tabular-nums; transition: background-color 120ms, color 120ms;
}
.cal-day:hover:not(:disabled) { background: var(--hover-strong); }
.cal-day.is-other { color: var(--text-400); }
.cal-day:disabled { color: var(--text-400); cursor: default; }
.cal-day.is-other:disabled { color: var(--raised); }
.cal-day.has-points { font-weight: 600; color: var(--text); }
.cal-day.has-points::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 9999px; background: var(--brand); }
.cal-day.is-today { box-shadow: inset 0 0 0 1px var(--brand-muted); }
.cal-day.is-selected, .cal-day.is-selected:hover { background: var(--brand); color: #fff; }
.cal-day.is-selected::after { background: #fff; }
.cal-day:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.rp-list { border: 1px solid var(--toggle-border); border-radius: 8px; background: var(--canvas); min-width: 0; display: flex; flex-direction: column; max-height: 318px; }
.rp-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--wash-blue); border-radius: 8px 8px 0 0; }
.rp-items { overflow-y: auto; overscroll-behavior: contain; }
.rp-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.rp-item:last-child { border-bottom: 0; }
.rp-item.is-current { background: var(--wash-blue); }
.rp-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.rp-job { font-size: 14px; line-height: 20px; color: var(--text); }
.rp-paths { font-size: 12px; line-height: 16px; color: var(--text-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-time { font-size: 13px; line-height: 18px; color: var(--text-600); }
.rp-item .btn { flex-shrink: 0; }
.rp-none { padding: 24px 12px; text-align: center; color: var(--text-500); display: flex; flex-direction: column; align-items: center; gap: 10px; }
@media (max-width: 1099.98px) {
  .rp-picker { grid-template-columns: minmax(260px, 300px) minmax(0, 1fr); }
  .rp-source { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
  .rp-source .field { min-width: 220px; }
}
@media (max-width: 699.98px) {
  .rp-picker { grid-template-columns: minmax(0, 1fr); }
  .rp-list { max-height: 60vh; }
  .rp-item { flex-wrap: wrap; }
  .rp-item .btn { width: 100%; justify-content: center; }
  .cal-day { height: 40px; }
}
.choice.is-disabled { opacity: 0.65; cursor: default; }
/* A group of choices: even spacing, whatever is shown or hidden after it. */
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice-list > .choice + .choice { margin-top: 0; }

/* ---------- Apollo link ---------- */
.pill-icon { gap: 4px; }
.pill-after { margin-left: 6px; vertical-align: 1px; }
.apollo-picker-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.apollo-picker-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apollo-picker .menu { left: 0; right: 0; width: auto; }
.help .icon { vertical-align: -1px; }

/* ---------- Storage ---------- */
.plain-list { display: flex; flex-direction: column; gap: 4px; }
.text-danger { color: var(--danger-text); }
.text-success { color: var(--pill-success-fg); }

/* ---------- Machine list: live progress in the Status column ---------- */
.live-cell { min-width: 220px; }
.live-job { display: flex; flex-direction: column; gap: 2px; max-width: 360px; }
.live-job-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The customer picked in the top bar, next to page titles */
.scope-note { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border: 1px solid var(--border); border-radius: 9999px; font-size: 13px; line-height: 20px; color: var(--text-600); background: var(--canvas); white-space: nowrap; }
.scope-clear { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 9999px; color: var(--text-500); }
.scope-clear:hover { background: var(--hover); color: var(--text-800); }
/* A filter shown the same way (History filtered to one device): long names are cut short on a phone. */
.filters .scope-note { max-width: 100%; }
.scope-note .truncate { min-width: 0; }

/* Checkbox grids and long pick lists (Google/Microsoft backup jobs) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.pick-list-items { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; }

/* ---------- Seeding a backup from a drive: numbered steps ---------- */
.seed-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.seed-step { display: flex; gap: 14px; position: relative; padding-bottom: 20px; }
.seed-step:last-child { padding-bottom: 0; }
.seed-step:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: 4px; border-left: 2px solid var(--border); }
.seed-step-mark {
  flex: none; width: 28px; height: 28px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; background: var(--muted); color: var(--text-500); border: 1px solid var(--border);
}
.seed-step.is-current .seed-step-mark { background: var(--brand); border-color: var(--brand); color: #fff; }
.seed-step.is-done .seed-step-mark { background: var(--pill-success-bg); border-color: var(--pill-success-bg); color: var(--pill-success-fg); }
.seed-step-body { min-width: 0; flex: 1; padding-top: 3px; }
.seed-step-title { font-size: 15px; line-height: 22px; font-weight: 600; margin: 0 0 2px; }
.seed-step.is-waiting .seed-step-title { color: var(--text-500); }
.job-card-seed { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding: 10px 12px; border-radius: 6px; background: var(--info-wash); border: 1px solid var(--info-border); color: var(--info-text); font-size: 14px; }
.job-card-seed .grow { flex: 1; }

/* ---------- Restore: a mailbox shown like a mail app ---------- */
.mailview-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 8px 16px 12px; border-bottom: 1px solid var(--border); }
.mailview-folder { width: auto; max-width: 100%; min-width: 180px; }
.mailview-search { flex: 1 1 220px; max-width: 360px; }
.table-mail { table-layout: fixed; }
.table-mail th:nth-child(2), .table-mail td.mail-from { width: 26%; }
.table-mail th:nth-child(4), .table-mail td.mail-date { width: 92px; text-align: right; }
.mail-row { cursor: pointer; }
.mail-row td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row.is-unread .mail-from, .mail-row.is-unread .mail-subject-text { font-weight: 600; color: var(--text); }
.mail-snippet { color: var(--text-500); }
.mail-star { color: #f59e0b; margin-right: 4px; }
.mail-subject svg { vertical-align: -2px; }
.mailview-more { padding: 12px 16px; border-top: 1px solid var(--border); }
@media (max-width: 639.98px) {
  .table-mail th:nth-child(2), .table-mail td.mail-from { width: 34%; }
  .mail-snippet { display: none; }
}
.inline-form { display: inline-block; margin-left: 6px; vertical-align: middle; }
.list-plain { list-style: none; padding: 0; margin: 0; } .list-plain li { padding: 2px 0; }
