:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #1d4ed8;
  --ok: #16a34a;
  --warn: #b45309;
  --danger: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: #f1f5f9;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--bg); color: #e2e8f0;
  padding: 0 24px; height: 56px;
}
.topbar .brand { font-weight: 700; letter-spacing: .3px; }
.topbar nav { display: flex; gap: 18px; margin-right: auto; }
.topbar nav a { color: #cbd5e1; padding: 4px 2px; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav a.active { color: #fff; border-bottom: 2px solid var(--brand); }

/* Top-nav dropdown (Servers ▾) */
.nav-dd { position: relative; display: inline-block; }
.nav-dd > a::after { content: " ▾"; font-size: 11px; }
.nav-dd-menu {
  display: none; position: absolute; top: 100%; left: -10px; z-index: 30;
  min-width: 170px; padding: 6px 0; background: #1e293b;
  border: 1px solid #334155; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.nav-dd:hover .nav-dd-menu, .nav-dd:focus-within .nav-dd-menu { display: block; }
.nav-dd-menu a { display: block; padding: 8px 14px; color: #cbd5e1; }
.nav-dd-menu a:hover { background: #334155; color: #fff; text-decoration: none; }
.nav-dd-menu a.active { border-bottom: none; color: #fff; }
.logout { margin: 0; }
/* User menu (top right): email ▾ → My devices, Change password, Sign out */
.user-dd > a { color: #cbd5e1; padding: 4px 2px; }
.user-dd > a:hover { color: #fff; text-decoration: none; }
.user-dd > a.active { color: #fff; }
.user-dd .nav-dd-menu { left: auto; right: -10px; min-width: 190px; }
.user-dd .nav-dd-menu button.link {
  display: block; width: 100%; text-align: left; padding: 8px 14px;
}
.user-dd .nav-dd-menu button.link:hover { background: #334155; color: #fff; }
button.link {
  background: none; border: 0; color: #cbd5e1; cursor: pointer; font: inherit;
}
button.link:hover { color: #fff; }

main { max-width: 960px; margin: 32px auto; padding: 0 24px; }
/* Pages that are a working table (Devices) use the width they are given. */
main.wide { max-width: 1400px; }
main.centered {
  min-height: calc(100vh - 64px); display: flex; align-items: center;
  justify-content: center; flex-direction: column; max-width: 420px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; width: 100%;
}
.card + .card { margin-top: 18px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .n { font-size: 30px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
a.stat.link { display: block; color: inherit; text-decoration: none; }
a.stat.link:hover { border-color: var(--brand); }
.stat.bad .n { color: var(--danger); }
.stat .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #cbd5e1; }
.stat .dot.on { background: var(--ok); }
.stat .dot.off { background: var(--danger); }

label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 4px; }
/* Every text-like control, not just type=text: an email/number/date input left
   out of this list renders as the browser's bare default box. */
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=url], input[type=tel], input[type=search], input[type=date],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; color: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}
textarea { min-height: 80px; resize: vertical; }
td select, td input { width: auto; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > div { flex: 1 1 260px; }
.check-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 14px; margin-top: 4px;
}
label.check-item {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font-weight: 400; font-size: 14px; cursor: pointer;
}
label.check-item input { width: auto; margin: 0; }
.perm-grid th, .perm-grid td { text-align: center; }
.perm-grid th:first-child, .perm-grid td:first-child { text-align: left; }
.perm-grid .help { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.perm-grid input:disabled { cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.check input { width: auto; }
.check label { margin: 0; }

.btn {
  display: inline-block; background: var(--brand); color: #fff; border: 0;
  padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600;
  cursor: pointer; margin-top: 18px;
}
.btn:hover { background: var(--brand-ink); text-decoration: none; color: #fff; }
.btn.secondary { background: #e2e8f0; color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 5px 10px; margin: 0; font-size: 13px; }
.btn.small { padding: 6px 12px; margin: 0; font-size: 13px; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; }

table { width: 100%; border-collapse: collapse; margin-top: 6px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: #dcfce7; color: var(--ok); }
.pill.off { background: #fee2e2; color: var(--danger); }
.pill.svc { background: #ede9fe; color: #6d28d9; }
.pill.revoked { background: #f1f5f9; color: var(--muted); }
.pill.warn { background: #fef3c7; color: #92400e; }
/* Alert severity (Alerts page, dashboard's Open alerts). */
.pill.sev-info { background: #e2e8f0; color: #334155; }
.pill.sev-low { background: #dbeafe; color: #1e3a8a; }
.pill.sev-medium { background: #fef3c7; color: #78350f; }
.pill.sev-high { background: #fed7aa; color: #7c2d12; }
.pill.sev-critical { background: #fecaca; color: #7f1d1d; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.alert { padding: 11px 14px; border-radius: 8px; margin: 0 0 16px; font-size: 14px; }
.alert.err { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert.ok { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
.alert.warn { background: #fffbeb; color: var(--warn); border: 1px solid #fde68a; }

/* Section tabs inside a detail page (see portal/machines/show.hbs). Keeps a
   page navigable as sections are added, instead of one ever-growing scroll. */
.tabs {
  display: flex; flex-wrap: wrap; gap: 2px;
  border-bottom: 1px solid var(--line); margin: 0 0 18px;
}
.tabs button {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; margin: 0; padding: 9px 14px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted);
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--brand-ink); border-bottom-color: var(--brand); }
/* Count badge on a tab (e.g. "Shares 2") — a bare .pill has no fill. */
.tabs button .pill { margin-left: 7px; vertical-align: 1px; background: #e2e8f0; color: var(--muted); }
.tabs button[aria-selected="true"] .pill { background: #dbeafe; color: var(--brand-ink); }
/* The first card in a panel sits directly under the tab strip. */
.tabpanel > .card:first-child { margin-top: 0; }

.keybox {
  background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px;
  word-break: break-all; margin-top: 8px; display: flex; gap: 10px; align-items: center;
}
.keybox code { color: #bae6fd; flex: 1; }
.codeblock {
  background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px;
  margin-top: 8px; overflow-x: auto; font-size: 13px; line-height: 1.5;
  white-space: pre; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.muted { color: var(--muted); }
.right { text-align: right; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.mt0 { margin-top: 0; }

/* ── Sign-in pages: the watchtower scene (partials/login_scene.hbs) ──────────
   Dark in BOTH colour schemes, card pinned to the dark palette: the scene is a
   lit night scene and a light ground washes it out (package README). The
   scene's layout is fixed around a centred ~460x310 card, so keep this card
   at that size; a bigger one covers the logo and the tower. */
@font-face {
  font-family: "Oswald";
  src: url("/static/fonts/oswald-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 700;
  font-display: swap;
}
body.scene { background: #1d2023; color: #e7e2da; overflow: hidden; }
.scene-canvas {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 0;
}
body.scene main { position: relative; z-index: 1; }
body.scene main.centered { max-width: 508px; }
body.scene .card {
  width: 460px; max-width: 100%; padding: 20px 38px;
  background: rgba(20, 21, 24, 0.88); color: #d8dade;
  border: 1px solid rgba(255, 150, 60, 0.28); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.4) inset;
  backdrop-filter: blur(6px);
}
body.scene h1 { color: #f0ede6; font-size: 19px; letter-spacing: 0.04em; }
body.scene .subtitle {
  color: #d99a55; font-size: 11.5px; letter-spacing: 0.08em;
  text-transform: uppercase; margin-bottom: 14px;
}
body.scene label { color: #b4b7bd; margin-top: 10px; }
body.scene input[type=text], body.scene input[type=email],
body.scene input[type=password] {
  background: #1c1d20; border-color: #3a3d42; color: #dcdde0;
}
body.scene input:focus { border-color: #d97a2e; outline: none; }
body.scene .btn {
  width: 100%; padding: 11px; border-radius: 7px;
  background: linear-gradient(180deg, #f0954a, #d97a2e); color: #2a1608;
  font-weight: 700; letter-spacing: 0.03em;
}
body.scene .btn:hover { background: linear-gradient(180deg, #f5a462, #e0873d); color: #2a1608; }
body.scene a { color: #e3a563; }
body.scene .alert.err { background: rgba(127, 29, 29, 0.45); color: #fecaca; border-color: #7f1d1d; }
body.scene .alert.ok { background: rgba(20, 83, 45, 0.45); color: #bbf7d0; border-color: #14532d; }
body.scene .alert.warn { background: rgba(120, 53, 15, 0.45); color: #fde68a; border-color: #78350f; }
body.scene .alert { margin-bottom: 10px; padding: 8px 12px; }
/* Bottom-left: bare wall there. Centred, it sat on the tower's plinth. */
body.scene .legal-links {
  position: fixed; left: 16px; bottom: 10px; margin: 0; z-index: 1;
  text-align: left; font-size: 12px; color: #8a8f96;
}
@media (max-width: 520px) {
  body.scene .card { padding: 18px 20px; }
}
/* Narrower than 16:10 (phones, a Fold's inner screen, squarish monitors).
   The scene's camera has a fixed vertical FOV (package README, Known
   weaknesses), so a box narrower than 16:9 crops the plates and plaque off
   the sides, and a full-window canvas behind a 460px card buries both. Here
   the scene becomes a band across the top, never narrower than 16:9 (a wider
   band only adds bare wall), shortened so the card still fits below it on
   the scene's ground colour. The canvas renders with fit:'element'
   (login_scene.hbs), so this box is what it draws. 1599/1000, not 16/10:
   max-aspect-ratio is inclusive and 1440x900 must stay full-window. */
@media (max-aspect-ratio: 1599/1000) {
  body.scene {
    --iw-band: min(56.25vw, max(38vh, 100vh - 390px));
    overflow: auto;
  }
  @supports (height: 100dvh) {
    body.scene { --iw-band: min(56.25vw, max(38dvh, 100dvh - 390px)); }
  }
  body.scene .scene-canvas { inset: 0 0 auto 0; height: var(--iw-band); }
  body.scene main.centered {
    min-height: 0; justify-content: flex-start;
    margin: 0 auto; padding-top: calc(var(--iw-band) + 16px); padding-bottom: 16px;
  }
  body.scene .legal-links { position: static; text-align: center; margin: 12px 0; }
}

/* Installers (2026-09-27): a read-only command with a Copy button beside it. */
.copyrow { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.copyrow input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; margin: 0; }
.copyrow .btn { margin: 0; flex: 0 0 auto; }
.install-key + .install-key { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }

/* Dashboard "+ Add machine" dropdown (click, so it works on touch too). */
.btn-dd { position: relative; display: inline-block; }
.btn-dd > summary { list-style: none; margin: 0; cursor: pointer; }
.btn-dd > summary::-webkit-details-marker { display: none; }
.btn-dd > summary::after { content: " ▾"; font-size: 11px; }
.btn-dd-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 260px;
  padding: 6px 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15,23,42,.14);
}
.btn-dd-menu form { margin: 0; }
.btn-dd-menu a, .btn-dd-menu button {
  display: block; width: 100%; text-align: left; padding: 9px 14px; color: #0f172a;
  background: none; border: 0; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-dd-menu a:hover, .btn-dd-menu button:hover { background: #f1f5f9; text-decoration: none; }
.btn-dd-menu .muted { font-weight: 400; }
.btn-dd-menu .muted { display: block; font-size: 12px; }

/* Add machine → customer / location picker */
.place-list, .place-list ul { list-style: none; margin: 0; padding: 0; }
.place-list ul { padding-left: 18px; }
.place-list li { margin: 0; }
.place-btn {
  display: block; width: 100%; text-align: left; padding: 7px 10px; margin: 1px 0;
  background: none; border: 0; border-radius: 6px; color: inherit; font: inherit; cursor: pointer;
}
.place-btn:hover, .place-btn:focus { background: rgba(148,163,184,.15); }
.place-cust + .place-cust { border-top: 1px solid rgba(148,163,184,.15); }

/* Devices tab (portal/fleet_devices.hbs): menu + searchable tree left, table right. */
.dv { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; align-items: start; }
.dv-side .card + .card { margin-top: 12px; }
.dv .card + .card { margin-top: 0; }
.dv-side .card.dv-tree-card { margin-top: 12px; }
.dv-menu { padding: 6px; }
.dv-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 6px; padding: 9px 10px; font: inherit; color: inherit; cursor: pointer;
}
.dv-menu button:hover { background: #f1f5f9; }
.dv-menu button.sel { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand-ink); font-weight: 600; }
.dv .cnt { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.dv .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; flex: none; }
.dv .dot.on { background: var(--ok); }
.dv .dot.off { background: var(--danger); }
.dv-tree { max-height: 62vh; overflow: auto; margin-top: 10px; font-size: 14px; }
.dv-tree .node { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 6px; cursor: pointer; color: inherit; }
.dv-tree .node:hover { background: #f1f5f9; text-decoration: none; }
.dv-tree .node.sel { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.dv-tree .lvl1 { padding-left: 24px; }
.dv-tree .lvl2 { padding-left: 42px; }
.dv-tree .dev { font-size: 13px; }
.dv-tree .tw { width: 14px; flex: none; color: var(--muted); text-align: center; }
.dv-main { min-width: 0; }
.dv-main h2 { font-size: 17px; }
.table-wrap { overflow-x: auto; }
.dv-main td { white-space: nowrap; }
.dv-main td.nm { white-space: normal; }
.dv-main .ck { width: 28px; }
.dv-assign { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--brand) 8%, transparent); }
.dv-assign[hidden] { display: none; }
.dv-assign .dv-act { display: flex; align-items: center; gap: 6px; margin: 0; }
.dv-assign .dv-act label { margin: 0; font-size: 13px; font-weight: 600; }
.dv-main tr.grp td { background: #f8fafc; font-weight: 600; font-size: 13px; }
@media (max-width: 860px) {
  .dv { grid-template-columns: 1fr; }
  .dv-tree { max-height: 40vh; }
}
