/* DG RMM console.
   One idea carries the look: a dark rack-rail of client prefixes on the left (dg, apm, jmb), mirroring how
   the MSP names its gear, with status LEDs as the only saturated color. Everything else stays quiet. */

:root {
  --paper: #eef1f4;
  --panel: #ffffff;
  --ink: #18212c;
  --muted: #5b6775;
  --line: #d5dbe2;
  --line-soft: #e6eaee;
  --teal: #0e6b70;
  --teal-ink: #ffffff;
  --teal-soft: #e3f0f0;
  --amber: #b9741a;
  --red: #b8352d;
  --led-on: #22a35a;
  --led-off: #a3adb8;
  --rail: #1c2733;
  --rail-ink: #c9d3dc;
  --rail-dim: #7f8d9b;
  --rail-strong: #ffffff;
  --rail-hi: #2a3846;
  --code-bg: #0f1720;
  --code-ink: #dbe3ea;
  --radius: 6px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", "DejaVu Sans Mono", monospace;
  color-scheme: light;
}

/* Dark theme: follows the computer unless the user picked Light or Dark (html[data-theme]). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121820;
    --panel: #1a222c;
    --ink: #e6ebf0;
    --muted: #93a0ae;
    --line: #2c3743;
    --line-soft: #232d38;
    --teal: #3fa9ae;
    --teal-ink: #0c1a1c;
    --teal-soft: #1b3236;
    --amber: #e3a54a;
    --red: #ec6b62;
    --rail: #0d131a;
    --rail-hi: #1c2733;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121820;
  --panel: #1a222c;
  --ink: #e6ebf0;
  --muted: #93a0ae;
  --line: #2c3743;
  --line-soft: #232d38;
  --teal: #3fa9ae;
  --teal-ink: #0c1a1c;
  --teal-soft: #1b3236;
  --amber: #e3a54a;
  --red: #ec6b62;
  --rail: #0d131a;
  --rail-hi: #1c2733;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; font-weight: 650; }
code, pre, .data, .host { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
/* Headings receive focus after navigation for screen readers; no ring needed. */
h1:focus, h1:focus-visible { outline: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }

/* ---------- buttons and inputs ---------- */

button, .button {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: default; }
.primary { background: var(--teal); border-color: var(--teal); color: var(--teal-ink); }
.primary:hover { filter: brightness(1.08); border-color: var(--teal); }
.secondary { background: var(--panel); }
.link { border: none; background: none; padding: 0.2rem 0.3rem; color: var(--teal); font-weight: 600; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--red); }
.wide { width: 100%; justify-content: center; padding: 0.65rem; margin-top: 0.6rem; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-soft); }
label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }
label.check { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; }
.hint { font-weight: 400; color: var(--muted); }
.form-error { color: var(--red); margin: 0.4rem 0; }
.form-ok { color: var(--led-on); margin: 0.4rem 0; }
.validation-message { color: var(--red); font-size: 0.85rem; margin: -0.2rem 0 0.4rem; }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 0.9rem 0.6rem 1.2rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  font-size: 0.92rem;
  border-right: 1px solid color-mix(in srgb, var(--rail) 88%, black);
}
.brand-logo { width: 26px; height: 26px; object-fit: contain; border-radius: 5px; flex: none; }
.brand-logo.large { width: 36px; height: 36px; }
.brand {
  display: flex; align-items: center; gap: 0.55rem;
  color: var(--rail-strong); text-decoration: none; font-weight: 700; font-size: 1.02rem;
  padding: 0.1rem 0.55rem 0.9rem;
}

.nav { display: flex; flex-direction: column; padding-bottom: 0.6rem; border-bottom: 1px solid var(--rail-hi); }
.nav-section { display: flex; flex-direction: column; gap: 2px; padding: 0.55rem 0; }
.nav-section + .nav-section { border-top: 1px solid var(--rail-hi); }
.nav-section:first-child { padding-top: 0; }
.nav a {
  display: flex; align-items: center; gap: 0.7rem;
  color: var(--rail-ink); text-decoration: none; font-weight: 550;
  padding: 0.48rem 0.6rem; border-radius: 8px;
}
.nav-icon { width: 1.15rem; height: 1.15rem; flex: none; color: var(--rail-dim); }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a:hover { background: var(--rail-hi); color: var(--rail-strong); }
.nav a:hover .nav-icon { color: var(--rail-strong); }
.nav a.active { background: var(--rail-hi); color: var(--rail-strong); }
.nav a.active .nav-icon { color: #6ea8ff; }
/* Admin: a folding group of pages used now and then. */
.nav-fold {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left;
  background: none; border: none; color: var(--rail-ink); font: inherit; font-weight: 550;
  padding: 0.48rem 0.6rem; border-radius: 8px; cursor: pointer;
}
.nav-fold:hover { background: var(--rail-hi); color: var(--rail-strong); border: none; }
.nav-fold:hover .nav-icon { color: var(--rail-strong); }
.fold-mark::before {
  content: ""; display: block; width: 0; height: 0; margin-right: 0.2rem;
  border-left: 5px solid var(--rail-dim); border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform 120ms ease;
}
.nav-fold.open .fold-mark::before { transform: rotate(90deg); }
.nav-fold-body { display: flex; flex-direction: column; gap: 2px; padding-left: 0.7rem; }
.nav .badge { border-radius: 999px; padding: 0.05rem 0.5rem; min-width: 1.9rem; }
.nav .badge.crit { background: color-mix(in srgb, var(--red) 28%, transparent); color: #ffb3ad; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 70%, transparent); }
.nav .badge.warn { background: color-mix(in srgb, #f2b84b 22%, transparent); color: #f6cd7a; box-shadow: inset 0 0 0 1px color-mix(in srgb, #f2b84b 60%, transparent); }
.nav .badge.info { background: rgb(42 92 200 / 0.35); color: #9cc0ff; box-shadow: inset 0 0 0 1px rgb(78 132 240 / 0.7); }

.tree-head {
  display: flex; flex-direction: column; gap: 0.45rem;
  padding: 0.9rem 0.6rem 0.35rem; color: var(--rail-dim); font-size: 0.82rem; font-weight: 600;
}
.tree-filter { background: var(--rail-hi); border-color: var(--rail-hi); color: var(--rail-strong); font-size: 0.86rem; padding: 0.3rem 0.5rem; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 1.15rem; border-left: 1px solid var(--rail-hi); padding-left: 0.2rem; }
.node {
  display: grid; grid-template-columns: 1.15rem 1fr auto; align-items: center; gap: 0.15rem;
  border-radius: var(--radius); padding: 0.1rem 0.45rem 0.1rem 0.15rem;
}
.node.leaf { grid-template-columns: 1fr auto; padding-left: 0.5rem; }
.node:hover { background: var(--rail-hi); }
.node.active { background: var(--rail-hi); box-shadow: inset 3px 0 0 var(--led-on); }
.node a { color: var(--rail-ink); text-decoration: none; padding: 0.3rem 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node.active a, .node a:hover { color: var(--rail-strong); }
.twisty {
  width: 1.15rem; height: 1.6rem; padding: 0; border: none; background: none; color: var(--rail-dim);
  display: grid; place-items: center; border-radius: 4px;
}
.twisty::before {
  content: ""; width: 0; height: 0;
  border-left: 5px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform 120ms ease;
}
.twisty.open::before { transform: rotate(90deg); }
.twisty:hover { color: var(--rail-strong); border: none; }
.twisty-space { width: 1.15rem; }
.sidebar .count { font-family: var(--mono); font-size: 0.76rem; color: var(--rail-dim); }
.sidebar .count.warn { color: #f2b84b; }
.sidebar .count.partial { color: var(--rail-ink); }
/* Under a client: a small mark tells locations from groups. */
.node.leaf.kind { grid-template-columns: 1rem 1fr auto; gap: 0.4rem; padding-left: 0.4rem; }
.kind-icon { display: grid; place-items: center; color: var(--rail-dim); }
.kind-icon .nav-icon { width: 0.9rem; height: 0.9rem; color: inherit; }
.node.active .kind-icon { color: var(--rail-ink); }
.tree-empty { color: var(--rail-dim); padding: 0.4rem 0.6rem; }
.tree-empty a { color: var(--rail-ink); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.55rem 1.6rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar-spacer { flex: 1; }
.who { color: var(--ink); text-decoration: none; font-weight: 600; }
.topbar form { margin: 0; }
.global-search { width: min(420px, 50vw); }
/* Fills the window: no max width. Side padding grows a little on very wide screens. */
.content { padding: 1.6rem clamp(1rem, 2vw, 2.6rem); width: 100%; min-width: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head .sub { display: flex; align-items: center; gap: 0.5rem; }

.crumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; font-size: 0.88rem; color: var(--muted); margin-bottom: 0.35rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--teal); text-decoration: underline; }
.crumbs > * + *::before { content: "/"; margin-right: 0.35rem; color: var(--line); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.segmented button { border: none; border-radius: 0; font-weight: 600; color: var(--muted); padding: 0.4rem 0.85rem; background: none; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button span { font-family: var(--mono); font-size: 0.8rem; margin-left: 0.3rem; font-weight: 500; }
.segmented button.on { background: var(--teal-soft); color: var(--ink); box-shadow: inset 0 -2px 0 var(--teal); }

a.quiet { color: inherit; text-decoration: none; }
a.quiet:hover { color: var(--teal); text-decoration: underline; }
.under { display: block; font-size: 0.78rem; color: var(--muted); }
.hint { color: var(--muted); font-size: 0.86rem; margin: 0.5rem 0 0; }
.sub { margin: 0.25rem 0 0; color: var(--muted); }
.search { min-width: 280px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.2rem;
}
.panel h2 { margin-bottom: 0.8rem; }
.panel h2.spaced { margin-top: 1.4rem; }
.callout { border-color: var(--teal); box-shadow: inset 4px 0 0 var(--teal); }

.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty h1, .empty h2 { color: var(--ink); margin-bottom: 0.5rem; }

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

.grid { width: 100%; border-collapse: collapse; background: var(--panel); }
.content > .grid { border: 1px solid var(--line); border-radius: var(--radius); }
.grid th {
  text-align: left; font-size: 0.8rem; font-weight: 650; color: var(--muted);
  padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.grid td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.grid tr:last-child td { border-bottom: none; }
.grid .num { text-align: right; }
.grid td:first-child { white-space: nowrap; }
.grid .actions { text-align: right; white-space: nowrap; }
.grid .actions select { margin-right: 0.4rem; }
.grid .clip { max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.devices tbody tr { cursor: pointer; }
.devices tbody tr:hover { background: var(--teal-soft); }
.grid tr.dim td { color: var(--muted); }
.col-led { width: 28px; padding-right: 0 !important; }
.host { color: var(--ink); font-weight: 600; text-decoration: none; }
a.host:hover { color: var(--teal); }
.chip { font-family: var(--mono); font-size: 0.8rem; font-weight: 700; background: var(--line-soft); padding: 0.1rem 0.45rem; border-radius: 4px; }

/* ---------- status bits ---------- */

.led { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--led-off); flex: none; }
.led.on { background: var(--led-on); box-shadow: 0 0 0 3px color-mix(in srgb, var(--led-on) 22%, transparent); }

.meter { display: inline-flex; align-items: center; gap: 0.45rem; font-family: var(--mono); font-size: 0.82rem; }
.meter-bar { width: 56px; height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.meter-bar > span { display: block; height: 100%; background: var(--teal); }
.meter.warm .meter-bar > span { background: var(--amber); }
.meter.hot .meter-bar > span { background: var(--red); }
.meter-num { min-width: 2.6em; text-align: right; }

.status { font-size: 0.8rem; font-weight: 650; padding: 0.1rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.status.ok { background: color-mix(in srgb, var(--led-on) 16%, transparent); color: var(--led-on); }
.status.bad { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.status.busy { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.status.idle { background: var(--line-soft); color: var(--muted); }

/* ---------- device page ---------- */

.device-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.device-title { display: grid; grid-template-columns: auto 1fr; column-gap: 0.7rem; align-items: center; }
.device-title h1 { font-size: 1.9rem; letter-spacing: -0.02em; }
.device-title .where, .device-title .seen { grid-column: 2; color: var(--muted); }
.device-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.device-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 1.2rem; }
.device-grid .panel { margin-bottom: 0; }
.device-grid + .panel { margin-top: 1.2rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1.2rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.disk { display: grid; grid-template-columns: minmax(80px, 1fr) auto minmax(140px, auto); gap: 0.8rem; align-items: center; padding: 0.3rem 0; }

.chart svg { width: 100%; height: 120px; display: block; background: var(--paper); border-radius: 4px; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 3 4; }
.chart .line { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .line.cpu { stroke: var(--teal); }
.chart .line.mem { stroke: var(--amber); }
.chart figcaption { display: flex; gap: 1.2rem; margin-top: 0.5rem; font-size: 0.85rem; flex-wrap: wrap; }
.chart { margin: 0; }
.key::before { content: ""; display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 0.4rem; vertical-align: middle; }
.key.cpu::before { background: var(--teal); }
.key.mem::before { background: var(--amber); }

.script-form { display: flex; flex-direction: column; gap: 0.7rem; }
.script-opts { display: flex; gap: 1rem; flex-wrap: wrap; }
.script-run { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
textarea.code, .output {
  font-family: var(--mono);
  font-size: 0.86rem;
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--code-bg);
  border-radius: var(--radius);
}
textarea.code { width: 100%; padding: 0.8rem; resize: vertical; }
.output { padding: 0.8rem 1rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 480px; overflow: auto; margin: 0.5rem 0; }
.copyable { user-select: all; }

.jobs { display: grid; grid-template-columns: minmax(260px, 2fr) 3fr; gap: 1rem; }
.job-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); max-height: 560px; overflow: auto; }
.job-list li { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.6rem; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.job-list li:hover { background: var(--teal-soft); }
.job-list li.selected { background: var(--teal-soft); box-shadow: inset 3px 0 0 var(--teal); }
.job-list .job-first { font-family: var(--mono); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-list .muted { grid-column: 2; font-size: 0.8rem; }
.job-meta { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--muted); margin-top: 0.4rem; }

/* ---------- clients ---------- */

.inline-form { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; margin-top: 0.8rem; }
.inline-form input.short, .client-edit input.short { width: 7rem; }
.client { scroll-margin-top: 1rem; }
.client-head { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.client-title { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.client-title h2 { margin: 0; font-size: 1.15rem; }
.client-actions { display: flex; gap: 0.5rem; }
.client-edit { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; }
.consent { margin: 0.6rem 0 0.2rem; }
.grid.locations { margin-top: 0.8rem; border: 1px solid var(--line-soft); border-radius: var(--radius); }
.rename { display: inline-flex; gap: 0.4rem; align-items: center; }
.rename input { padding: 0.3rem 0.5rem; }
.callout.install { margin-top: 1rem; padding: 0.9rem 1rem; border: 1px solid var(--teal); border-radius: var(--radius); }
.callout.install h3 { margin: 0 0 0.4rem; font-size: 1rem; }

/* ---------- settings ---------- */

.banner { padding: 0.6rem 0.9rem; background: color-mix(in srgb, var(--led-on) 12%, var(--panel)); border-radius: var(--radius); }
.settings h3.spaced { margin: 1.4rem 0 0.6rem; font-size: 1rem; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 2rem; align-items: start; }
.settings-fields { display: flex; flex-direction: column; gap: 1.1rem; max-width: 560px; }
.settings-fields.addresses { max-width: 760px; }
.settings-fields .hint { font-weight: 400; margin: 0; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label { font-weight: 600; font-size: 0.9rem; }
.with-button { display: flex; gap: 0.5rem; }
.with-button input { flex: 1; }
.logo-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.logo-preview { width: 48px; height: 48px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: var(--paper); }
.file-button { position: relative; overflow: hidden; }
.file-button input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.color-fields { display: flex; flex-direction: column; gap: 1.1rem; }
.color-row { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.color-row input[type=color] { width: 42px; height: 34px; padding: 2px; cursor: pointer; }
.color-row input.hex { width: 6.5rem; font-family: var(--mono); }
.swatch { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.preview { display: grid; grid-template-columns: 130px 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; min-height: 190px; position: sticky; top: 1rem; }
.preview-side { padding: 0.7rem 0.45rem; font-size: 0.8rem; display: flex; flex-direction: column; gap: 2px; }
.preview-brand { display: flex; align-items: center; gap: 0.35rem; font-weight: 700; padding: 0 0.3rem 0.6rem; overflow: hidden; white-space: nowrap; }
.preview-brand img { width: 18px; height: 18px; object-fit: contain; }
.preview-item { padding: 0.3rem 0.4rem; border-radius: 4px; }
.preview-main { background: var(--paper); padding: 0.9rem; display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; font-size: 0.85rem; }
.preview-title { font-weight: 700; font-size: 1rem; }
.preview-link { font-family: var(--mono); font-weight: 600; text-decoration: underline; }
.preview-button { padding: 0.35rem 0.7rem; border-radius: var(--radius); font-weight: 600; }
.save-bar { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; margin-bottom: 2rem; }

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

.modal-backdrop { position: fixed; inset: 0; background: rgba(12, 18, 26, 0.55); z-index: 900; }
.modal {
  position: fixed; z-index: 901; left: 50%; top: min(14vh, 4.5rem); transform: translateX(-50%);
  width: min(540px, calc(100vw - 2rem)); max-height: calc(100vh - 2 * min(14vh, 4.5rem)); overflow: auto;
  background: var(--panel); border-radius: 10px; padding: 1.3rem 1.4rem 1.1rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.modal.danger { border-top: 4px solid var(--red); }
.modal h2 { font-size: 1.2rem; margin-bottom: 0.7rem; }
.modal-body p { margin: 0 0 0.7rem; }
.warning-line { font-weight: 600; color: var(--red); }
.device-list { columns: 2; margin: 0 0 0.8rem; padding: 0.6rem 0.8rem 0.6rem 1.8rem; background: var(--paper); border-radius: var(--radius); font-size: 0.88rem; }
.type-confirm { display: block; margin: 0.4rem 0 0.2rem; font-weight: 500; }
.type-confirm input { display: block; width: 100%; margin-top: 0.4rem; }
.type-confirm code { font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }
button.danger:not(.link) { background: var(--red); border-color: var(--red); color: #fff; }
button.danger:not(.link):hover { filter: brightness(1.08); border-color: var(--red); }
.danger-text { color: var(--red); }
.danger-text:hover { border-color: var(--red); }

/* ---------- account pages ---------- */

.account-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: var(--rail); }
.account-card {
  width: 100%; max-width: 440px;
  background: var(--panel); border-radius: 10px; padding: 2rem 2rem 1.6rem;
  display: flex; flex-direction: column; gap: 0.7rem;
}
.account-card h1 { font-size: 1.4rem; }
.account-card h2 { margin-top: 1rem; }
.account-card form { display: flex; flex-direction: column; gap: 0.7rem; margin: 0; }
.account-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.1rem; margin-bottom: 0.6rem; }
.lede { margin: 0; color: var(--muted); }
.aside { margin: 0.4rem 0 0; text-align: center; font-size: 0.9rem; }
.qr { align-self: center; background: #fff; padding: 8px; border-radius: 6px; line-height: 0; }
.qr svg { width: 220px; height: 220px; }
.secret { font-size: 0.9rem; color: var(--muted); margin: 0; }
.secret code { color: var(--ink); font-size: 0.95rem; }
.codes { columns: 2; list-style: none; padding: 0.8rem 1rem; margin: 0; background: var(--paper); border-radius: var(--radius); }
.codes li { padding: 0.15rem 0; }

/* ---------- remote sessions ---------- */

.remote-shell { height: 100vh; display: flex; flex-direction: column; background: var(--code-bg); color: var(--code-ink); }
.remote-head {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.5rem 1rem; background: var(--rail); border-bottom: 1px solid #263342; flex: none;
}
.remote-head .back { color: var(--rail-ink); font-size: 0.9rem; }
.remote-kind { font-weight: 700; color: var(--rail-strong); }
.remote-head .host { color: var(--rail-strong); font-size: 1.05rem; }
.remote-status { margin-left: auto; font-size: 0.88rem; color: var(--rail-ink); }
.remote-status:empty::before { content: attr(data-initial); }
.remote-status[data-kind="ok"]::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--led-on); margin-right: 0.45rem; }
.remote-status[data-kind="wait"] { color: #f2b84b; }
.remote-status[data-kind="error"] { color: #ff8a80; }
.remote-status[data-kind="ended"] { color: var(--rail-dim); }
.remote-error { padding: 0.6rem 1rem; margin: 0; color: #ff8a80; }

.term { flex: 1; min-height: 0; padding: 0.4rem 0 0 0.6rem; }

.file-manager { flex: 1; min-height: 0; overflow: auto; background: var(--paper); color: var(--ink); padding: 1rem; }
.file-bar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.8rem; flex-wrap: wrap; }
.file-bar .path { flex: 1; min-width: 240px; font-family: var(--mono); }
.grid.files { border: 1px solid var(--line); border-radius: var(--radius); }
.files a.dir { font-weight: 600; color: var(--ink); }
.files a.dir::before { content: "▸ "; color: var(--teal); }
.transfers { font-size: 0.88rem; color: var(--muted); margin-bottom: 0.6rem; }

.desktop { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.desktop { position: relative; }
.desk-bar { display: flex; gap: 0.35rem; align-items: center; padding: 0.4rem 0.75rem; background: #17222d; flex-wrap: wrap; border-bottom: 1px solid #22303d; }
.desk-group { position: relative; display: inline-flex; }
.desk-btn { display: inline-flex; align-items: center; gap: 0.35rem; height: 2rem; padding: 0 0.55rem; background: transparent; color: var(--code-ink);
  border: 1px solid transparent; border-radius: 6px; font-weight: 500; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
.desk-btn:hover, .desk-btn.open { background: #22303d; border-color: #2f3f4e; }
.desk-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.desk-btn.text { padding: 0 0.7rem; }
.desk-btn .ico { display: inline-flex; width: 1.15rem; height: 1.15rem; }
.desk-btn .ico svg { width: 100%; height: 100%; }
.desk-btn .ico:last-child:not(:first-child) { width: 0.9rem; height: 0.9rem; opacity: 0.75; }
.desk-group.split { border: 1px solid #2f3f4e; border-radius: 6px; }
.desk-group.split .desk-btn { border: 0; border-radius: 0; }
.desk-group.split .desk-btn:first-child { border-radius: 5px 0 0 5px; }
.desk-group.split .desk-btn.more { border-left: 1px solid #2f3f4e; border-radius: 0 5px 5px 0; padding: 0 0.3rem; }
.desk-group.split .desk-btn.more .ico { width: 0.9rem; height: 0.9rem; opacity: 0.75; }
.desk-sep { width: 1px; height: 1.4rem; background: #2f3f4e; margin: 0 0.25rem; }
.desk-spacer { flex: 1; }
.desk-bar.view-only .desk-group.split .desk-btn:first-child { opacity: 0.55; }
.desk-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; min-width: 14rem; padding: 0.3rem; background: #1d2a36; border: 1px solid #2f3f4e;
  border-radius: 8px; box-shadow: 0 10px 28px rgb(0 0 0 / 0.4); }
.desk-menu button { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.45rem 0.6rem; background: transparent; color: var(--code-ink);
  border: 0; border-radius: 5px; text-align: left; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
.desk-menu button:hover:not([disabled]), .desk-menu button:focus-visible { background: #2a3a48; outline: none; }
.desk-menu button[disabled] { opacity: 0.45; cursor: default; }
.desk-menu .mark { display: inline-flex; width: 1rem; height: 1rem; flex: none; }
.desk-menu .mark .ico, .desk-menu .mark svg { width: 1rem; height: 1rem; }
.desk-menu .label { flex: 1; }
.desk-menu.plain .mark { display: none; }
.desk-menu .sep { height: 1px; margin: 0.3rem 0.2rem; background: #2f3f4e; }
.keys { display: inline-flex; gap: 0.2rem; margin-left: 1.25rem; }
.clip-pop .keys { margin: 0 0.1rem; vertical-align: middle; }
.keys kbd { font: inherit; font-size: 0.75rem; padding: 0.05rem 0.35rem; border-radius: 4px; background: #2f3f4e; color: var(--code-ink); }
.clip-pop { position: absolute; top: 3.2rem; left: 50%; transform: translateX(-50%); z-index: 31; width: min(28rem, calc(100% - 2rem));
  display: flex; flex-direction: column; gap: 0.5rem; padding: 0.8rem; background: #1d2a36; color: var(--code-ink); border: 1px solid #2f3f4e;
  border-radius: 8px; box-shadow: 0 10px 28px rgb(0 0 0 / 0.45); }
.clip-pop[hidden], .desk-menu[hidden] { display: none; }
.clip-pop p { margin: 0; }
.clip-pop textarea { background: #0f1720; color: var(--code-ink); border: 1px solid #2f3f4e; border-radius: 6px; font: inherit; padding: 0.4rem; }
.clip-pop .link { align-self: flex-end; color: var(--code-ink); }
.stage { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: flex-start; justify-content: center; }
.stage.fit { overflow: hidden; align-items: center; }
.stage.fit .screen { max-width: 100%; max-height: 100%; }
.screen { display: block; cursor: default; outline: none; image-rendering: auto; }
.screen:focus-visible { outline: 2px solid var(--teal); }

/* ---------- tools: files, processes, services (Files page and the remote desktop drawer) ---------- */

.desk-body { flex: 1; min-height: 0; display: flex; background: var(--code-bg); }
.desk-body .stage { flex: 1; min-width: 0; }
.tools-drawer {
  /* Always dark, like the viewer around it. */
  --paper: #121820; --panel: #1a222c; --ink: #e6ebf0; --muted: #93a0ae; --line: #2c3743; --line-soft: #232d38;
  --teal: #3fa9ae; --teal-ink: #0c1a1c; --teal-soft: #1b3236; --amber: #e3a54a; --red: #ec6b62;
  color-scheme: dark; position: relative; flex: none; width: 0; overflow: hidden; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink); border-left: 1px solid #22303d; transition: width 0.18s ease;
}
.tools-drawer.open { width: min(var(--tools-w, 600px), 85%); }
.tools-drawer.resizing { transition: none; user-select: none; }
.tools-grip { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize; z-index: 2; }
.tools-grip:hover, .tools-drawer.resizing .tools-grip { background: color-mix(in srgb, var(--teal) 45%, transparent); }
.tools-head { display: flex; align-items: center; justify-content: space-between; padding: 0.35rem 0.5rem 0.35rem 0.9rem; border-bottom: 1px solid var(--line); flex: none; }
.tools-head .desk-btn { height: 1.8rem; padding: 0 0.35rem; }
.tools-host { flex: 1; min-height: 0; display: flex; flex-direction: column; min-width: 300px; }
.file-manager.tools-page { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.tools-top { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.9rem 0; border-bottom: 1px solid var(--line); flex: none; flex-wrap: wrap; }
.tools-page .tools-top { padding: 0.6rem 1rem 0; }
.tools-tabs { display: flex; gap: 0.2rem; }
.tools-tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 0.4rem 0.7rem 0.5rem; font-weight: 600; }
.tools-tab:hover { color: var(--ink); border-color: transparent; border-bottom-color: var(--line); }
.tools-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--teal); }
.tools-status { margin-left: auto; color: var(--muted); font-size: 0.85rem; padding-bottom: 0.35rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tools-status[data-kind="error"] { color: var(--red); white-space: normal; }
.tools-status[data-kind="wait"] { color: var(--amber); }
.tools-reconnect { margin-bottom: 0.35rem; padding: 0.2rem 0.7rem; }
.tools-reconnect[hidden] { display: none; }
.tools-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tool-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0.75rem 0.9rem 0; }
.tools-page .tool-pane { padding: 1rem 1rem 0; }
.tool-pane[hidden] { display: none; }
.tool-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tool-pane .file-bar, .tool-bar { flex: none; }
.tool-bar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.tool-filter { flex: 1; min-width: 160px; }
.tool-bar label.check { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.88rem; white-space: nowrap; }
.tool-count { font-size: 0.82rem; margin-left: auto; white-space: nowrap; }
.tool-scroll { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 0.8rem; }
.tool-scroll > .grid { border: 0; border-radius: 0; }
.tool-table td, .tool-scroll .grid.files td { padding: 0.32rem 0.6rem; font-size: 0.88rem; }
.tool-table th, .tool-scroll .grid th { position: sticky; top: 0; z-index: 1; background: var(--panel); }
.tool-table td.clip, .tool-scroll .grid td.clip { max-width: 16rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--ink); }
th.sortable[aria-sort="ascending"]::after { content: " ▲"; font-size: 0.7em; }
th.sortable[aria-sort="descending"]::after { content: " ▼"; font-size: 0.7em; }
.tool-table .actions .link { padding: 0.1rem 0.25rem; }
.tool-table .actions .link + .link { margin-left: 0.3rem; }
.tool-table tbody tr:hover td { background: color-mix(in srgb, var(--teal) 6%, transparent); }
/* With a mouse, a row's actions show when you point at it (or tab to them), so the list isn't a column of red. */
@media (hover: hover) {
  .tool-table .actions .link { opacity: 0; }
  .tool-table tr:hover .actions .link, .tool-table .actions .link:focus-visible { opacity: 1; }
}
.services .svc-name { white-space: normal; min-width: 12rem; }
.services .svc-name > span { display: block; }
.services .svc-id { font-size: 0.78rem; }
.services select.compact { padding: 0.15rem 0.3rem; font-size: 0.85rem; }
.tools-note { padding: 1rem 0; max-width: 34rem; }
.files-pane.dropping .tool-scroll { outline: 2px dashed var(--teal); outline-offset: -2px; }
.files-pane .transfers:empty { display: none; }
/* The drawer is a side panel: smaller type and tighter rows than the full-page Files view, so more fits across. */
.tools-drawer { font-size: 0.8rem; }
.tools-drawer button:not(.desk-btn), .tools-drawer input, .tools-drawer select { padding: 0.25rem 0.55rem; font-size: 0.8rem; }
.tools-drawer .link { padding: 0.1rem 0.2rem; }
.tools-drawer .tools-tab { padding: 0.35rem 0.55rem 0.4rem; font-size: 0.82rem; }
.tools-drawer .tools-status, .tools-drawer .tool-count, .tools-drawer .transfers { font-size: 0.75rem; }
.tools-drawer .tool-bar label.check { font-size: 0.8rem; font-weight: 500; }
.tools-drawer .grid th { font-size: 0.72rem; padding: 0.35rem 0.5rem; }
.tools-drawer .tool-table td, .tools-drawer .tool-scroll .grid td { font-size: 0.78rem; padding: 0.22rem 0.5rem; }
.tools-drawer .tool-table td.clip, .tools-drawer .tool-scroll .grid td.clip { max-width: 12rem; }
.tools-drawer .col-user { max-width: 8rem; }
.tools-drawer .services .svc-name { min-width: 9rem; }
.tools-drawer .services .svc-id { font-size: 0.7rem; }
.tools-drawer .services select.compact { padding: 0.1rem 0.25rem; font-size: 0.76rem; }
.tools-drawer .tool-pane { padding: 0.55rem 0.7rem 0; }
.tools-drawer .tools-top { padding: 0.35rem 0.7rem 0; }
.tools-drawer .file-bar { gap: 0.35rem; margin-bottom: 0.5rem; }
.tools-drawer .file-bar .path { min-width: 140px; }
.tools-drawer .tool-filter { min-width: 120px; }
.tools-drawer .pill { font-size: 0.7rem; }
.tools-drawer .tool-scroll { scrollbar-width: thin; }
.tools-drawer .tool-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.tools-drawer .tool-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
/* Narrow drawer: drop the less useful columns. */
.tools-drawer .col-mod { display: none; }
@media (max-width: 1100px) { .tools-drawer .col-user { display: none; } }

/* ---------- connection lost banner ---------- */

#blazor-error-ui {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--amber); color: #1b1300; padding: 0.6rem 1.2rem; z-index: 1000; font-weight: 600;
}
#blazor-error-ui a { color: inherit; }

/* ---------- small screens ---------- */

/* Sidebar toggle (top-left button) */
.nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: 2.2rem; height: 2.2rem; padding: 0;
  border: 1px solid transparent; background: none; color: var(--muted); border-radius: var(--radius); flex: none; }
.nav-toggle:hover { background: var(--line-soft); color: var(--ink); border-color: transparent; }
.nav-backdrop { display: none; }
html.nav-collapsed .shell { grid-template-columns: 0 minmax(0, 1fr); }
html.nav-collapsed .sidebar { visibility: hidden; padding: 0; border: 0; overflow: hidden; }

/* Medium screens: drop the least useful columns and tighten up. */
@media (max-width: 1280px) {
  .col-opt2 { display: none; }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
}

@media (max-width: 900px) {
  .shell, html.nav-collapsed .shell { grid-template-columns: minmax(0, 1fr); }
  /* The sidebar becomes a drawer over the page. */
  .sidebar, html.nav-collapsed .sidebar {
    position: fixed; z-index: 950; top: 0; left: 0; width: min(290px, 85vw); height: 100vh; visibility: visible;
    padding: 0.9rem 0.6rem 1.2rem; transform: translateX(-100%); transition: transform 160ms ease;
  }
  html.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 0.3); }
  html.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 940; background: rgba(12, 18, 26, 0.45); }
  .topbar { padding: 0.5rem 0.8rem; gap: 0.5rem; }
  .global-search { width: 100%; min-width: 0; flex: 1; }
  .topbar-spacer { display: none; }
  .who { display: none; }
  .content { padding: 1rem; }
  .jobs, .settings-grid { grid-template-columns: 1fr; }
  .col-opt { display: none; }
  .search { min-width: 0; width: 100%; }
  .toolbar > * { flex: 1 1 auto; }
  /* Wide tables scroll sideways instead of squashing. */
  .grid { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }
  .page-head { align-items: flex-start; }
  .device-actions { flex-wrap: wrap; }
  .bulk-bar { gap: 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- groups ---------- */

.tree-head.row { flex-direction: row; justify-content: space-between; align-items: baseline; }
.tree-manage { color: var(--rail-dim); font-weight: 500; text-decoration: none; font-size: 0.78rem; }
.tree-manage:hover { color: var(--rail-strong); text-decoration: underline; }
.tree.groups .node.leaf { padding-left: 0.6rem; }
.tag { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  padding: 0.1rem 0.4rem; border-radius: 4px; background: var(--line-soft); color: var(--muted); margin-right: 0.35rem; }
.tag.auto { background: var(--teal-soft); color: var(--teal); }
.grid.groups td { vertical-align: top; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .link + .link { margin-left: 0.8rem; }
.group-form { display: flex; flex-direction: column; gap: 0.8rem; }
.group-form input:not([type=checkbox]) { width: 100%; }
.rule { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.8rem 0.4rem; margin: 0; }
.rule legend { font-size: 0.85rem; color: var(--muted); padding: 0 0.3rem; }
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 0.8rem; }
.rule-grid .span { grid-column: 1 / -1; }
.rule .hint { font-size: 0.82rem; margin: 0.6rem 0 0.2rem; }
.group-form > .hint { margin: 0; font-size: 0.85rem; }

.col-check { width: 2.2rem; text-align: center; }
.col-check input { width: 1rem; height: 1rem; cursor: pointer; accent-color: var(--teal); }
.grid.devices tr.selected td { background: var(--teal-soft); }
.bulk-bar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.8rem; padding: 0.55rem 0.8rem;
  background: var(--panel); border: 1px solid var(--teal); border-radius: var(--radius); box-shadow: 0 0 0 3px var(--teal-soft); }
.bulk-sep { width: 1px; height: 1.4rem; background: var(--line); }
.bulk-spacer { flex: 1; }
.bulk-bar .form-ok, .bulk-bar .form-error { margin: 0; }

.group-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.group-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.25rem 0.1rem 0.55rem; border: 1px solid var(--line);
  border-radius: 999px; font-size: 0.85rem; background: var(--paper); }
.group-chip a { color: var(--ink); text-decoration: none; }
.group-chip a:hover { color: var(--teal); text-decoration: underline; }
.auto-mark { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--teal); padding-right: 0.35rem; }
.chip-x { border: 0; background: none; padding: 0 0.35rem; line-height: 1.3; color: var(--muted); border-radius: 999px; font-size: 1rem; }
.chip-x:hover { color: var(--red); background: var(--line-soft); border: 0; }
select.add-group { font-size: 0.85rem; padding: 0.15rem 0.4rem; border-style: dashed; color: var(--muted); }
.grid.devices a.host { white-space: nowrap; }
.modal .script-form .hint { margin: 0; }

/* ---------- patching, scripts, automations ---------- */

.status.wait { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.status:empty { display: none; }
.pill { display: inline-block; font-size: 0.76rem; font-weight: 650; padding: 0.08rem 0.45rem; border-radius: 999px; white-space: nowrap;
  background: var(--line-soft); color: var(--muted); }
.pill.ok { background: color-mix(in srgb, var(--led-on) 16%, transparent); color: var(--led-on); }
.pill.bad { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.pill.warn, .pill.wait { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.8rem; margin-bottom: 1.1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.9rem; display: flex; flex-direction: column; gap: 0.15rem; }
.stat-num { font-family: var(--mono); font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat.warn .stat-num { color: var(--amber); }
.stat.bad .stat-num { color: var(--red); }

.policy-pick { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
label.inline { flex-direction: row; align-items: center; gap: 0.4rem; font-weight: 500; }
input.short { width: 4.2rem; }
.rules-cell { max-width: 260px; }
.order-btns { display: inline-flex; flex-direction: column; line-height: 1; }
.order-btns .link { padding: 0.05rem 0.2rem; font-size: 0.7rem; }
.order-btns .link[disabled] { opacity: 0.25; }

.modal.wide-modal { width: min(820px, calc(100vw - 2rem)); }
.policy-form { display: flex; flex-direction: column; gap: 0.9rem; }
.policy-form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.9rem 0.7rem; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.policy-form legend { font-weight: 700; font-size: 0.9rem; padding: 0 0.3rem; }
.policy-form .hint { margin: 0; font-size: 0.84rem; }
.form-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 0.8rem; }
.form-row.narrow { grid-template-columns: 1fr 1fr; max-width: 420px; }
.form-row input, .form-row select { width: 100%; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.3rem 0.8rem; }
table.rules { border-collapse: collapse; }
table.rules td { padding: 0.15rem 0.8rem 0.15rem 0; }
.delay { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.88rem; }
.delay input { width: 4rem; padding: 0.2rem 0.4rem; }
.window-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.9rem; }
.radio-row { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.day-picker { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.day-picker button { border: 0; border-radius: 0; padding: 0.35rem 0.55rem; background: var(--panel); color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.day-picker button + button { border-left: 1px solid var(--line); }
.day-picker button.on { background: var(--teal); color: #fff; }

.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.panel-head h2 { margin: 0; }
.panel-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.patch-status { display: flex; flex-direction: column; gap: 0.2rem; margin: 0 0 0.7rem; font-size: 0.92rem; }
.notice { padding: 0.5rem 0.75rem; border-radius: var(--radius); margin: 0 0 0.7rem; font-size: 0.92rem; display: flex; align-items: center; gap: 0.5rem; }
.notice.warn { background: color-mix(in srgb, var(--amber) 13%, transparent); }
.notice.busy { background: var(--teal-soft); }
.spinner { width: 0.9rem; height: 0.9rem; border-radius: 50%; border: 2px solid var(--teal); border-right-color: transparent; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.grid.compact td, .grid.compact th { padding: 0.35rem 0.6rem; }
.grid.updates td:nth-child(2) { white-space: normal; }
.grid.updates td:first-child { white-space: normal; }
.panel .grid { border: 1px solid var(--line-soft); }
h3.spaced { margin: 1.1rem 0 0.4rem; font-size: 1rem; }
.run-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.run-list summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; padding: 0.35rem 0.2rem; }
.run-list details[open] > summary { border-bottom: 1px solid var(--line-soft); margin-bottom: 0.4rem; }
.run-items { list-style: none; margin: 0 0 0.5rem; padding: 0 0 0 0.4rem; display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.step-list { margin: 0 0 0.6rem; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.25rem; }
.step-log { margin: 0; padding-left: 1.1rem; font-size: 0.88rem; display: flex; flex-direction: column; gap: 0.15rem; }
.run-devices td { vertical-align: top; }
.step-editor { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: 0.6rem; }
.step-editor > li { padding: 0.5rem 0.6rem; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--paper); }
.step-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; }
.step-btns { display: inline-flex; gap: 0.5rem; }
.step-body { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.45rem; }
.step-body textarea { width: 100%; }
.add-steps { display: flex; flex-wrap: wrap; gap: 0.5rem; }
@media (max-width: 700px) { .form-row, .form-row.narrow { grid-template-columns: 1fr; } }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.9rem; margin-top: 0.8rem; }
.check-grid.indent { margin-left: 1.6rem; }
.plain-list { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.25rem; }
.notice.legacy { justify-content: space-between; flex-wrap: wrap; margin-top: 0.8rem; }

/* ---------- monitoring ---------- */
.sev { display: inline-block; min-width: 4.6rem; text-align: center; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  padding: 0.12rem 0.45rem; border-radius: 4px; }
.sev.critical { background: var(--red); color: #fff; }
.sev.warning { background: color-mix(in srgb, var(--amber) 22%, transparent); color: var(--amber); }
.sev.info { background: var(--line-soft); color: var(--muted); }
.badge { font-family: var(--mono); font-size: 0.74rem; font-weight: 700; min-width: 1.4rem; text-align: center; padding: 0.05rem 0.4rem; border-radius: 999px; }
.badge.crit { background: var(--red); color: #fff; }
.badge.warn { background: #f2b84b; color: #2a1d00; }
.alert-dot { display: inline-block; margin-left: 0.4rem; font-family: var(--mono); font-size: 0.72rem; font-weight: 700; padding: 0 0.38rem; border-radius: 999px; text-decoration: none; vertical-align: 0.1em; }
.alert-dot.crit { background: var(--red); color: #fff; }
.alert-dot.warn { background: color-mix(in srgb, var(--amber) 25%, transparent); color: var(--amber); }
.toolbar-right { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.grid.alerts td { vertical-align: top; }
.grid.alerts .alert-text { white-space: normal; }
.grid.alerts .col-sev { width: 1%; white-space: nowrap; }
.alert-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.alert-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 0.7rem; align-items: start; }
.alert-list.resolved li { grid-template-columns: auto 1fr; opacity: 0.8; }
.recent-alerts { margin-top: 0.8rem; }
.recent-alerts summary { cursor: pointer; color: var(--muted); margin-bottom: 0.5rem; }
.monitor-kind { font-weight: 700; font-size: 0.85rem; min-width: 9rem; }
.monitor-name { flex: 1; min-width: 10rem; }
.step-head:has(.monitor-name) { flex-wrap: wrap; justify-content: flex-start; }
.monitor-fields { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
input.medium { width: 11rem; }
.panel.dim { opacity: 0.7; }
.check-grid.wide-check { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Software */
button.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.grid td.col-actions { text-align: right; white-space: nowrap; }
.grid td.col-actions button + button { margin-left: 0.35rem; }
.grid tr.clickable { cursor: pointer; }
.grid tr.clickable:hover td { background: var(--teal-soft); }
.grid tr.detail-row td { background: var(--paper); }
.device-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.device-chips li { white-space: nowrap; }
.pick-list { list-style: none; margin: 0 0 0.5rem; padding: 0; max-height: 50vh; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.25rem 1rem; }
.software-all { margin-top: 1rem; }
.software-all > summary { cursor: pointer; font-weight: 600; padding: 0.3rem 0; }
.software-all .toolbar { margin: 0.5rem 0; }
.software-all table { max-height: none; }
@media (max-width: 900px) {
  .grid td.col-actions { white-space: normal; }
  .grid td.col-actions button { margin: 0.15rem 0 0.15rem 0.35rem; }
}

/* Chat */
.ok-text { color: var(--led-on); }
.small-text { font-size: 0.85rem; }
.head-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.form-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 1.2rem; flex-wrap: wrap; }
.dot-online { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--led-on); margin-left: 0.35rem; vertical-align: middle; }
.chat-pane { display: flex; flex-direction: column; min-height: 0; }
.chat-pane-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--line-soft); }
.chat-list { overflow-y: auto; max-height: 52vh; min-height: 220px; padding: 0.8rem 0.2rem; display: flex; flex-direction: column; gap: 0.2rem; }
.chat-empty { color: var(--muted); text-align: center; margin: auto; }
.chat-day { align-self: center; font-size: 0.75rem; color: var(--muted); background: var(--paper); border-radius: 999px; padding: 0.1rem 0.7rem; margin: 0.6rem 0 0.3rem; }
.chat-msg { display: flex; flex-direction: column; max-width: min(72%, 640px); }
.chat-msg.first { margin-top: 0.55rem; }
.chat-msg.user { align-self: flex-start; }
.chat-msg.tech { align-self: flex-end; align-items: flex-end; }
.chat-meta { font-size: 0.75rem; color: var(--muted); margin: 0 0.3rem 0.15rem; }
.chat-msg .bubble { padding: 0.5rem 0.8rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.chat-msg.user .bubble { background: var(--paper); border: 1px solid var(--line-soft); color: var(--ink); }
.chat-msg.tech .bubble { background: var(--teal); color: var(--teal-ink); }
.chat-msg.tech .bubble a { color: inherit; }
.chat-state { font-size: 0.72rem; color: var(--muted); margin: 0.15rem 0.3rem 0; }
.chat-compose { display: flex; gap: 0.6rem; align-items: flex-end; padding-top: 0.7rem; border-top: 1px solid var(--line-soft); }
.chat-compose textarea { flex: 1; resize: vertical; min-height: 2.6rem; max-height: 12rem; font: inherit; }
.chats { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.chat-threads { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem; position: sticky; top: 1rem; }
.chat-threads .search { width: 100%; margin-bottom: 0.5rem; }
.chat-threads ul { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
.chat-threads li a { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.5rem; padding: 0.55rem 0.6rem; border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.chat-threads li a:hover { background: var(--paper); }
.chat-threads li a.on { background: var(--teal-soft); }
.chat-threads .who { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.2rem; }
.chat-threads .who .chat-when { margin-left: auto; font-size: 0.75rem; color: var(--muted); }
.chat-threads .chat-where { font-size: 0.78rem; color: var(--muted); grid-column: 1; }
.chat-threads .chat-preview { font-size: 0.85rem; color: var(--muted); grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-threads .unread .chat-preview { color: var(--ink); font-weight: 600; }
.chat-threads .badge { grid-column: 2; grid-row: 2 / span 2; align-self: center; }
.chat-none { padding: 0.5rem; }
.chat-main { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; min-width: 0; }
.chat-main .empty { border: 0; }
.back-link { display: none; margin-bottom: 0.6rem; }
.panel .segmented .badge { margin-left: 0.3rem; }
@media (max-width: 900px) {
  .chats { grid-template-columns: minmax(0, 1fr); }
  .chats.has-open .chat-threads { display: none; }
  .chats:not(.has-open) .chat-main { display: none; }
  .chat-threads { position: static; }
  .back-link { display: inline-block; }
  .chat-msg { max-width: 88%; }
  .chat-list { max-height: 60vh; }
}

/* Tray icon settings */
.tray-layout { display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr) minmax(220px, 260px); gap: 1rem; align-items: start; }
.tray-menus { display: flex; flex-direction: column; gap: 0.2rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem; }
.tray-menus button { display: flex; flex-direction: column; align-items: flex-start; text-align: left; background: none; border: 0; padding: 0.5rem 0.6rem; border-radius: var(--radius); color: var(--ink); cursor: pointer; font: inherit; }
.tray-menus button:hover { background: var(--paper); }
.tray-menus button.on { background: var(--teal-soft); }
.tray-menus button .muted { font-size: 0.78rem; }
.tray-menus-head { font-size: 0.75rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 0.7rem 0.6rem 0.2rem; }
.tray-editor .panel { margin: 0; }
.tray-editor label:not(.check):not(.switch) { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.5rem 0; }
.tray-items { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); }
.tray-item { display: grid; grid-template-columns: 11rem minmax(9rem, 1.2fr) minmax(10rem, 1.4fr) auto; gap: 0.5rem; align-items: center; padding: 0.45rem 0.6rem; border-top: 1px solid var(--line-soft); }
.tray-item.head { border-top: 0; font-size: 0.8rem; font-weight: 650; color: var(--muted); padding-top: 0.5rem; padding-bottom: 0.3rem; }
.tray-item input, .tray-item select { width: 100%; min-width: 0; }
.tray-item .what { font-size: 0.85rem; }
.tray-item-actions { display: flex; gap: 0.3rem; align-items: center; justify-content: flex-end; white-space: nowrap; }
.tray-add { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.6rem 0; }
.check.switch { font-weight: 600; margin: 0; }
.tray-icon-row { display: flex; gap: 1rem; align-items: flex-start; }
.tray-icon-preview { width: 48px; height: 48px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1.6rem; flex: none; overflow: hidden; }
.tray-icon-preview img { width: 100%; height: 100%; object-fit: contain; background: var(--panel); }
.tray-preview { position: sticky; top: 1rem; }
.tray-preview h3 { margin-top: 0; }
.tray-mock { background: #f9f9f9; color: #1a1a1a; border: 1px solid #ccc; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 0.35rem 0; font-family: "Segoe UI", system-ui, sans-serif; font-size: 0.86rem; }
.tray-mock-title { font-weight: 700; padding: 0.35rem 1.1rem; }
.tray-mock-item { padding: 0.35rem 1.1rem; }
.tray-mock-item.text { color: #555; }
.tray-mock-sep { height: 1px; background: #ddd; margin: 0.3rem 0.5rem; }
@media (max-width: 1280px) {
  .tray-layout { grid-template-columns: minmax(180px, 220px) minmax(0, 1fr); }
  .tray-preview { grid-column: 2; position: static; max-width: 320px; }
}
@media (max-width: 900px) {
  .tray-item { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tray-item.head { display: none; }
  .tray-item-actions { grid-column: 1 / -1; }
  .tray-layout { grid-template-columns: minmax(0, 1fr); }
  .tray-preview { grid-column: 1; }
  .tray-menus { flex-direction: row; overflow-x: auto; }
  .tray-menus button { flex: none; }
  .tray-menus-head { display: none; }
}
.tray-editor, .tray-icon-row > div { min-width: 0; }
.tray-icon-row input[type=file] { max-width: 100%; }

/* ---------- device page (overview layout) ---------- */

.dv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin: 0.3rem 0 1.1rem; }
.dv-ident { display: flex; gap: 0.85rem; align-items: center; min-width: 0; }
.dv-icon { flex: none; width: 3rem; height: 3rem; border-radius: 10px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); border: 1px solid var(--line); }
.dv-icon.off { background: var(--line-soft); color: var(--muted); }
.dv-icon svg { width: 1.6rem; height: 1.6rem; }
.dv-title { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.dv-title h1 { font-size: 1.45rem; overflow-wrap: anywhere; }
.dv-status { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; font-weight: 650; padding: 0.1rem 0.55rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.dv-status .dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--led-off); }
.dv-status.on { color: var(--led-on); border-color: color-mix(in srgb, var(--led-on) 45%, transparent); }
.dv-status.on .dot { background: var(--led-on); box-shadow: 0 0 0 3px color-mix(in srgb, var(--led-on) 22%, transparent); }
.small-text { font-size: 0.82rem; }
.dv-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.dv-tag { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; padding: 0.12rem 0.5rem; border-radius: 4px; background: var(--line-soft); color: var(--muted); text-decoration: none; border: 1px solid var(--line); }
.dv-tag.av { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 40%, transparent); background: var(--teal-soft); }
.dv-tag.edr { color: #7b5bd6; border-color: color-mix(in srgb, #7b5bd6 40%, transparent); background: color-mix(in srgb, #7b5bd6 10%, transparent); }
.dv-tag.group { text-transform: uppercase; }
a.dv-tag.group:hover { color: var(--teal); }
.dv-actions { display: flex; gap: 0.5rem; align-items: center; }
.dv-message { margin: -0.4rem 0 0.9rem; }

details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 14rem; padding: 0.3rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 28px rgb(0 0 0 / 0.18); display: flex; flex-direction: column; }
details.menu .menu-list > a, details.menu .menu-list > button { display: block; text-align: left; width: 100%; padding: 0.45rem 0.65rem; border: 0; border-radius: 4px; background: none; color: var(--ink); text-decoration: none; font-weight: 500; }
details.menu .menu-list > a:hover, details.menu .menu-list > button:hover:not([disabled]) { background: var(--teal-soft); }
details.menu .menu-list > button[disabled] { opacity: 0.45; cursor: default; }
details.menu .menu-list hr { border: 0; border-top: 1px solid var(--line-soft); margin: 0.3rem 0.2rem; width: auto; }
.danger-text { color: var(--red) !important; }

.dv-body { display: grid; grid-template-columns: 11.5rem minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.dv-nav { display: flex; flex-direction: column; gap: 0.1rem; position: sticky; top: 1rem; }
.dv-nav a { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.45rem 0.7rem; border-radius: var(--radius); color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.dv-nav a:hover { color: var(--ink); background: var(--line-soft); }
.dv-nav a.on { color: var(--ink); background: var(--panel); box-shadow: inset 3px 0 0 var(--teal); border: 1px solid var(--line); }
.badge.count { background: var(--teal-soft); color: var(--teal); }
.dv-content { min-width: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.15rem; }
.card.flush { padding: 0; overflow: hidden; }
.card h2 { font-size: 0.95rem; }
.dv-overview { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr); gap: 1.1rem; align-items: start; }
.dv-col { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.dv-stack { display: flex; flex-direction: column; gap: 1.1rem; }
.dv-stack > .panel { margin: 0; }

.dv-score-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.8rem; }
.dv-score-num { display: flex; align-items: baseline; gap: 0.3rem; margin: 0.5rem 0 0.35rem; }
.dv-score-num strong { font-size: 2.3rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.dv-score-num span { color: var(--muted); font-weight: 600; }
.gauge { width: 9.5rem; height: auto; flex: none; }
.gauge path { fill: none; stroke-width: 18; stroke-linecap: round; }
.gauge-track { stroke: var(--line-soft); }
.gauge-value.good { stroke: var(--led-on); }
.gauge-value.warn { stroke: var(--amber); }
.gauge-value.bad { stroke: var(--red); }
.gauge-needle { fill: var(--ink); }
.gauge-hub { fill: var(--ink); }
.gauge-dot { fill: var(--panel); }
.dv-checks { list-style: none; margin: 0.9rem 0 0; padding: 0; border-top: 1px solid var(--line-soft); }
.dv-checks li { display: grid; grid-template-columns: 1.4rem max-content minmax(0, 1fr); gap: 0.55rem; align-items: center; padding: 0.55rem 0; border-bottom: 1px solid var(--line-soft); font-size: 0.9rem; }
.dv-checks li:last-child { border-bottom: 0; padding-bottom: 0; }
.dv-check-icon { width: 1.25rem; height: 1.25rem; border-radius: 50%; display: grid; place-items: center; font-size: 0.72rem; font-weight: 800; color: #fff; background: var(--led-off); }
.dv-checks .good .dv-check-icon { background: var(--led-on); }
.dv-checks .warn .dv-check-icon { background: var(--amber); }
.dv-checks .bad .dv-check-icon { background: var(--red); }
.dv-checks .unknown { color: var(--muted); }
.dv-check-name { white-space: nowrap; }
.dv-check-detail { color: var(--muted); text-align: right; font-size: 0.84rem; overflow-wrap: anywhere; }
.dv-checks .bad .dv-check-detail { color: var(--red); }
.dv-checks .warn .dv-check-detail { color: var(--amber); }
.help { display: inline-grid; place-items: center; width: 1rem; height: 1rem; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); font-size: 0.66rem; font-weight: 700; cursor: help; margin-left: 0.2rem; vertical-align: 1px; }

.dv-ip { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.dv-ip-big { font-family: var(--mono); font-size: 1.3rem; font-weight: 650; }
.dv-mini { display: grid; grid-template-columns: max-content auto; gap: 0.2rem 0.8rem; margin: 0; font-size: 0.86rem; }
.dv-mini dt { color: var(--muted); }
.dv-mini dd { margin: 0; font-family: var(--mono); }

.dv-details h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; margin: 1.1rem 0 0.45rem; }
.dv-details h3:first-child { margin-top: 0; }
.dv-details dl { display: grid; grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr); gap: 0.4rem 1rem; margin: 0; font-size: 0.9rem; }
.dv-details dt { color: var(--muted); }
.dv-details dd { margin: 0; overflow-wrap: anywhere; }
.dv-notes-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 1.1rem; }
.dv-notes-head h3 { margin: 0 0 0.45rem; }
.dv-notes { white-space: pre-wrap; margin: 0 0 0.3rem; }
.dv-notes-edit { width: 100%; font: inherit; padding: 0.5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); resize: vertical; }

.dv-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
.dv-kpi { display: flex; flex-direction: column; min-height: 11.5rem; }
.dv-kpi h2 { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.86rem; font-weight: 650; }
.dv-kpi-icon { color: var(--teal); }
.dv-kpi-num { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 0.4rem; line-height: 1.1; }
.spark { width: 100%; height: 4.2rem; margin-top: auto; padding-top: 0.6rem; overflow: visible; }
.spark-guide { stroke: var(--line); stroke-width: 1; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; }
.spark-line { fill: none; stroke: var(--teal); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-fill { fill: color-mix(in srgb, var(--teal) 16%, transparent); }
.spark.steps .spark-line { stroke: var(--led-on); }
.spark.steps .spark-fill { fill: color-mix(in srgb, var(--led-on) 16%, transparent); }
.dv-disk { margin-top: 0.7rem; }
.dv-disk-row { display: flex; justify-content: space-between; gap: 0.5rem; font-weight: 600; font-size: 0.88rem; margin-bottom: 0.25rem; }
.dv-disk .meter { display: flex; width: 100%; }
.dv-disk .meter-bar { flex: 1; width: auto; height: 8px; border-radius: 4px; }

.dv-section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: -0.5rem; }
.dv-section-head h2 { font-size: 1rem; }
.dv-section-head a { font-size: 0.86rem; }
.dv-table { border: 0; }
.dv-table td { vertical-align: top; }
.dv-empty { margin: 0; padding: 1.4rem 1.15rem; color: var(--muted); }
.avatar { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--teal); color: var(--teal-ink); font-size: 0.68rem; font-weight: 700; margin-right: 0.35rem; vertical-align: middle; }

@media (max-width: 1280px) {
  .dv-overview { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .dv-body { grid-template-columns: minmax(0, 1fr); gap: 0.9rem; }
  .dv-nav { flex-direction: row; overflow-x: auto; position: static; border-bottom: 1px solid var(--line); gap: 0; scrollbar-width: none; }
  .dv-nav a { flex: none; border-radius: 0; padding: 0.55rem 0.75rem; }
  .dv-nav a.on { border: 0; background: none; box-shadow: inset 0 -2px 0 var(--teal); }
  .dv-head { flex-direction: column; }
  .dv-actions { width: 100%; }
  .dv-actions > * { flex: 1; text-align: center; }
  .dv-actions details.menu > summary { display: block; }
  .dv-kpis { grid-template-columns: minmax(0, 1fr); }
  .dv-details dl { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr); }
  .gauge { width: 7.5rem; }
}

/* ---------- notifications ---------- */
.nf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.9rem 1.2rem; max-width: 980px; }
.nf-grid label { display: flex; flex-direction: column; gap: 0.3rem; }
.nf-grid .nf-wide { grid-column: 1 / -1; max-width: 640px; }
.nf-grid label.nf-check { flex-direction: row; align-self: end; padding-bottom: 0.5rem; }
.nf-test { margin-top: 1.1rem; max-width: 640px; }
.nf-test label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; }
.nf-tight { margin-top: -0.6rem !important; }
.nf-save { display: flex; align-items: center; gap: 0.8rem; margin: -0.2rem 0 1.4rem; }
.nf-map { max-width: 760px; }
.nf-map select { width: 100%; max-width: 360px; }
.nf-kind { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin-right: 0.3rem; }
.nf-to { max-width: 16rem; overflow-wrap: anywhere; font-size: 0.88rem; }
.nf-log .under.form-error { margin: 0.15rem 0 0; max-width: 26rem; }
.ticket-link { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
@media (max-width: 700px) { .nf-log th:nth-child(3), .nf-log td:nth-child(3) { display: none; } }

.step-notify label:not(.check) { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; font-size: 0.9rem; }
.step-notify input:not([type=checkbox]), .step-notify textarea { width: 100%; font-weight: 400; }
.step-notify { display: flex; flex-direction: column; gap: 0.6rem; }
.settings > .hint { margin: 0 0 1rem; max-width: 820px; }
.settings .addresses select:not(.nf-map select) { max-width: 360px; }

.audit-tabs { margin-bottom: 0.9rem; }
.audit-bad { color: var(--red); font-weight: 600; }
.audit-tabs + .grid td.data { white-space: nowrap; }

.guard .hint { max-width: 860px; }
.guard-tried { font-size: 0.86rem; overflow-wrap: anywhere; max-width: 22rem; }
.guard-trusted textarea { width: 100%; max-width: 520px; font-family: var(--mono); }

/* ---------- dashboard / overview ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.9rem; margin-bottom: 1.1rem; }
.kpi { display: flex; flex-direction: column; gap: 0.2rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.85rem 1rem; color: var(--ink); text-decoration: none; transition: border-color 120ms; }
.kpi:hover { border-color: var(--teal); }
.kpi-label { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.kpi-label .nav-icon { width: 1rem; height: 1rem; color: var(--teal); }
.kpi-num { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.kpi-num small { font-size: 0.95rem; font-weight: 600; color: var(--muted); margin-left: 0.3rem; }
.kpi-sub { color: var(--muted); font-size: 0.8rem; }
.kpi.warn .kpi-num { color: var(--amber); }
.kpi.bad .kpi-num { color: var(--red); }
.ov-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.1rem; margin-bottom: 1.4rem; align-items: start; }
.ov-attention ul { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.ov-attention li { display: grid; grid-template-columns: 0.9rem minmax(0, 1fr); column-gap: 0.4rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line-soft); }
.ov-attention li:last-child { border-bottom: 0; }
.ov-attention li .under { grid-column: 2; }
.ov-attention li a { color: var(--ink); text-decoration: none; font-weight: 550; }
.ov-attention li a:hover { color: var(--teal); text-decoration: underline; }
.ov-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-top: 0.45rem; background: var(--muted); }
.ov-attention .bad .ov-dot { background: var(--red); }
.ov-attention .warn .ov-dot { background: var(--amber); }
.ov-attention .info .ov-dot { background: var(--teal); }
.ov-allclear { color: var(--led-on); font-weight: 600; margin: 0.8rem 0 0.2rem; }
.ov-posture h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.ov-bar { margin-top: 0.85rem; }
.ov-bar-row { display: flex; justify-content: space-between; font-size: 0.88rem; margin-bottom: 0.25rem; }
.ov-track { height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.ov-track span { display: block; height: 100%; background: var(--muted); }
.ov-track .good { background: var(--led-on); }
.ov-track .warn { background: var(--amber); }
.ov-track .bad { background: var(--red); }
.ov-head { margin: 0 0 0.5rem; }
.dash-clients td { vertical-align: middle; }
.dash-when { white-space: nowrap; color: var(--muted); width: 7rem; }
.score-pill { display: inline-block; min-width: 2.2rem; text-align: center; font-weight: 700; font-size: 0.82rem; padding: 0.1rem 0.45rem; border-radius: 999px; }
.score-pill.good { background: color-mix(in srgb, var(--led-on) 16%, transparent); color: var(--led-on); }
.score-pill.warn { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.score-pill.bad { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
@media (max-width: 1000px) { .ov-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- device list ---------- */
.dl-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.8rem; }
.dl-select { width: auto; padding: 0.4rem 0.6rem; font-size: 0.88rem; }
.dl-select.set, .dl-chip.on { border-color: var(--teal); background: var(--teal-soft); color: var(--ink); }
.dl-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.38rem 0.65rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-size: 0.88rem; font-weight: 500; cursor: pointer; }
.dl-chip input { margin: 0; }
.dl-spacer { flex: 1; }
.dl-filters .search { min-width: 240px; }
.dl-columns .menu-list label.check { padding: 0.35rem 0.6rem; font-weight: 500; }
.dl-viewbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; margin: -0.2rem 0 0.8rem; font-size: 0.9rem; }
.dl-viewname { width: 16rem; padding: 0.3rem 0.5rem; }
.dl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.dl-wrap .grid { border: 0; }
.dl-sortable { padding: 0 !important; }
.dl-sort { all: unset; display: flex; align-items: center; gap: 0.25rem; width: 100%; box-sizing: border-box; padding: 0.55rem 0.6rem; cursor: pointer; font: inherit; color: inherit; white-space: nowrap; }
th.num .dl-sort { justify-content: flex-end; }
.dl-sort:hover { color: var(--teal); }
.dl-sort:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.dl-arrow { font-size: 0.6rem; color: var(--teal); min-width: 0.6rem; }
.dl-name { white-space: nowrap; }
.dl-name > * { vertical-align: middle; }
.dl-type { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 6px; background: var(--line-soft); color: var(--muted); margin-right: 0.45rem; }
.dl-type .nav-icon { width: 1rem; height: 1rem; color: inherit; }
.dl-name-text { display: inline-flex; align-items: center; gap: 0.35rem; }
.dl-flag { font-size: 0.72rem; font-weight: 700; color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 50%, transparent); border-radius: 4px; padding: 0 0.3rem; white-space: nowrap; }
.dl-c-tags { max-width: 16rem; }
.dl-c-tags .dv-tag { display: inline-block; margin: 0.1rem 0.25rem 0.1rem 0; font-size: 0.66rem; padding: 0.05rem 0.35rem; }
.dl-agent-pill { margin-left: 0.35rem; font-size: 0.7rem; }
@media (max-width: 900px) { .dl-spacer { display: none; } .dl-filters .search { min-width: 0; flex: 1 1 100%; } }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--paper); }
.spaced-top { margin-top: 1rem; }
.danger-zone { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.install-form { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: flex-end; }
.install-form label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }

/* ---------- top bar ---------- */
.tb-install { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.75rem; }
.tb-install .nav-icon { width: 1rem; height: 1rem; color: var(--teal); }
.tb-user > summary { list-style: none; }
.tb-user-btn { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.5rem 0.25rem 0.25rem; border-radius: 999px; cursor: pointer; border: 1px solid transparent; }
.tb-user-btn:hover, .tb-user[open] .tb-user-btn { border-color: var(--line); background: var(--panel); }
.tb-user-btn .avatar { margin: 0; width: 2rem; height: 2rem; font-size: 0.75rem; }
.tb-name { font-weight: 600; }
.tb-caret { font-size: 0.7rem; color: var(--muted); }
.tb-user .menu-list { min-width: 16rem; }
.tb-who { display: flex; flex-direction: column; padding: 0.45rem 0.65rem; }
.tb-theme { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.35rem 0.65rem 0.45rem; }
.tb-theme .segmented { align-self: flex-start; }
.tb-theme .segmented button { padding: 0.3rem 0.7rem; }
.tb-user form { margin: 0; }
.tb-user form button { display: block; width: 100%; text-align: left; padding: 0.45rem 0.65rem; border: 0; background: none; font-weight: 500; border-radius: 4px; }
.tb-user form button:hover { background: var(--teal-soft); }
@media (max-width: 900px) { .tb-name, .tb-caret { display: none; } .tb-install span { display: none; } }
.kpis { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
label.dl-chip { flex-direction: row; }
.card.flush + .dv-section-head, section.card.flush { margin-bottom: 1.3rem; }
.dl td { white-space: nowrap; }
.panel > .hint { margin: 0 0 0.9rem; }

/* Idle sign-out countdown */
.idle-warning { position: fixed; right: 20px; bottom: 20px; z-index: 1000; max-width: 360px; display: flex; flex-direction: column; gap: 8px;
  padding: 16px 18px; background: var(--panel, #fff); color: var(--ink, #14202b); border: 1px solid var(--line, #d9e0e6);
  border-left: 4px solid var(--warn, #b7791f); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.idle-warning button { align-self: flex-start; }

.audit-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 6px; }
.audit-range { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.audit-range label { display: flex; flex-direction: column; gap: 2px; font-size: .85rem; }

.retention-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 24px; margin: 10px 0; }
.retention-grid label { display: flex; flex-direction: column; gap: 4px; }
.retention-grid .days { display: flex; align-items: center; gap: 6px; }
.retention-grid input[type=number] { width: 7em; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 10px; }
.plain-steps { margin: 8px 0 0 1.2em; display: grid; gap: 6px; }
.short-select { max-width: 320px; }
.backup-when { display: flex; flex-wrap: wrap; gap: 20px; margin: 8px 0 12px; }
.backup-when label { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.backup-when input[type=number] { width: 5em; }
.row-actions > span { overflow-wrap: anywhere; min-width: 0; }

.cf-key { display: flex; align-items: center; gap: 4px; }
.cf-key input { max-width: 240px; }
.cf-table td { vertical-align: top; }
.cf-name { width: 34%; }
.cf-value { overflow-wrap: anywhere; }
.cf-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cf-edit input { flex: 1 1 220px; min-width: 0; }
.cf-panel .panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.script-vars { margin-top: 4px; }

/* Settings on phones: the address field's button drops below it; tables scroll inside their panel. */
@media (max-width: 600px) {
  .with-button { flex-wrap: wrap; }
  .with-button > input { flex: 1 1 100%; min-width: 0; }
  .panel.settings table.grid { display: block; overflow-x: auto; }
}
.hint.spaced { margin-top: 12px; }

/* Groups page: one section per client. */
.grid.groups tr.group-section th { background: var(--paper); font-weight: 650; padding-top: 0.8rem; }
.group-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.group-section-head a { color: inherit; }
.group-section-head .link { font-weight: 500; }
.card-note { padding: 0.75rem 1rem; margin: 0; }
.card-note.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; border-top: 1px solid var(--line-soft); }
.card-note.row-actions .hint { margin: 0; }

/* Windows Update errors in plain words */
.wu-advice { display: block; color: var(--muted); font-size: 0.86rem; margin-top: 0.15rem; font-weight: normal; }
.wu-source { color: var(--amber); }

/* Patching → Results: one card per client */
.patch-results { margin-top: 0.75rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 1rem; align-items: start; }
.result-card { margin: 0; }
.result-card.attention { border-left: 3px solid var(--red); }
.result-card.good { border-left: 3px solid var(--led-on); }
.rc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
.rc-head h2 { margin: 0; }
.rc-summary { margin: 0.3rem 0 0.6rem; color: var(--muted); }
.rc-title { font-size: 0.9rem; margin: 0.8rem 0 0.3rem; }
.rc-title.bad { color: var(--red); }
.rc-title.warn { color: var(--amber); }
.rc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.rc-list li { display: flex; flex-direction: column; }
.rc-detail { color: var(--muted); font-size: 0.86rem; }
.rc-patched { margin-top: 0.8rem; }
.rc-patched summary { cursor: pointer; color: var(--muted); }
.bad-count { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); border-radius: 999px; padding: 0 0.45rem; margin-left: 0.3rem; font-size: 0.78rem; }

/* Dashboard posture bars: "3 not" links to those devices */
.ov-bar-row .ov-bar-gap { margin-left: auto; margin-right: 0.6rem; font-size: 0.85rem; }

/* Notifications → AlgaPSA assets */
.nf-asset-lines { margin-top: 0.6rem; }
.nf-asset-lines summary { cursor: pointer; color: var(--muted); margin-bottom: 0.4rem; }
.nf-asset-lines tr.bad td { color: var(--red); }

input.short.version { width: 5.4rem; text-transform: uppercase; }
label.check.indent { margin-left: 1.6rem; }
