/*
 * Fleet dashboard theme.
 *
 * A control-room palette: one neutral ramp for surfaces and text, one blue
 * accent for anything interactive, and green / amber / red reserved for
 * state. Nothing glows, blurs or pulses unless it is in transition, so the
 * colours that do appear always mean something.
 *
 * Pages are laid out to fit one screen on a desktop monitor; feeds, tables
 * and the configuration sheet scroll inside their own box instead of the
 * page. Below the desktop breakpoints the page scrolls as usual.
 *
 * No rule here depends on inline styles, so the pages work under a strict
 * Content-Security-Policy.
 */

:root {
  --header-h: 48px;
  --page-pad: 16px;
  --gap: 12px;

  /* Neutrals (cool gray ramp) */
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #171b24;
  --surface-3: #1f2430;
  --border: #242a35;
  --border-strong: #353c4a;
  --text: #e6e8ec;
  --text-2: #a3aab7;
  --text-3: #6f7786;

  /* Interaction accent: links, primary buttons, focus, the active tab */
  --accent: #3d7eff;
  --accent-hover: #5a92ff;
  --accent-text: #8db4ff;
  --accent-soft: rgba(61, 126, 255, 0.14);
  --focus: rgba(61, 126, 255, 0.6);

  /* State colours: never used for decoration or chart series */
  --ok: #10b981;
  --ok-text: #34d399;
  --ok-soft: rgba(16, 185, 129, 0.12);
  --ok-line: rgba(16, 185, 129, 0.38);
  --warn: #f59e0b;
  --warn-text: #fbbf24;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --warn-line: rgba(245, 158, 11, 0.4);
  --bad: #ef4444;
  --bad-text: #f87171;
  --bad-soft: rgba(239, 68, 68, 0.13);
  --bad-line: rgba(239, 68, 68, 0.42);
  --off: #4b5361;

  /* Chart series: the key line in blue, the secondary one recessive */
  --series-1: #60a5fa;
  --series-2: #8b93a3;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;
  --r-lg: 10px;
  --r-md: 6px;
  --r-sm: 4px;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8125rem;
  line-height: 1.45;
  font-feature-settings: "cv11", "ss01";
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

::selection {
  background: var(--accent-soft);
}

/* Thin, quiet scrollbars for the boxes that scroll inside a page. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* --- Header and navigation --- */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  padding: 0 var(--page-pad);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-content {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.logo-mark {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
}
h1 {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
h1 .h1-sub {
  color: var(--text-3);
  font-weight: 500;
}
.app-version {
  font-size: 0.6875rem;
  color: var(--text-3);
  white-space: nowrap;
}
.main-nav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 4px;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav-link:hover {
  color: var(--text);
  text-decoration: none;
}
.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.nav-count {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}
.sys-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.role-label {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
}

/* --- Layout containers --- */

.container {
  width: 100%;
  margin: 0 auto;
  padding: var(--page-pad);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1 0 auto;
  min-width: 0;
}

.glass-panel,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.panel {
  padding: 8px 12px 10px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.panel-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 24px;
  margin-bottom: 4px;
}
.panel-header h2 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}
.panel-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.section-title-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.section-title-bar h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: var(--gap);
}
.panel-stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
}

.muted {
  color: var(--text-2);
}
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
.wrap-anywhere {
  overflow-wrap: anywhere;
}
.row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.spacer {
  flex: 1 1 auto;
}
.empty-msg {
  color: var(--text-3);
  text-align: center;
  padding: 16px 10px;
}

/* --- Forms --- */

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 12px 14px;
}
.form-section {
  min-width: 0;
}
.form-section > h3 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 10px;
}
.form-subsection {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.form-group > label,
.form-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
}
.form-group.dirty > label::after {
  content: " \2022 edited";
  color: var(--warn-text);
  font-weight: 500;
}
.form-group.invalid input,
.form-group.invalid select {
  border-color: var(--bad);
}
.field-desc {
  font-size: 0.75rem;
  color: var(--text-3);
  line-height: 1.4;
}
.field-error {
  font-size: 0.75rem;
  color: var(--bad-text);
}
/* What a change in this section costs on air. */
.cost-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  margin-bottom: 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.75rem;
}
.cost-note::before {
  content: "i";
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--text-3);
  color: var(--text-2);
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
  font-style: italic;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
}
.toggle-field .switch {
  flex-shrink: 0;
}
.toggle-field-text {
  font-size: 0.8125rem;
  color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  height: 32px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 0 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8125rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  min-width: 0;
}
textarea {
  height: auto;
  padding: 8px 10px;
}
select {
  padding-right: 28px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}
input:hover,
select:hover {
  border-color: #46506a;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
select option {
  background: var(--surface);
  color: var(--text);
}
/* Written with the element so they outrank the full-width input rule above. */
input.input-compact,
select.input-compact {
  width: auto;
  height: 28px;
  font-size: 0.75rem;
}
input.input-narrow {
  width: 72px;
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-secondary {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: #282e3b;
  border-color: #46506a;
}
.btn-danger {
  background: var(--bad-soft);
  border-color: var(--bad-line);
  color: var(--bad-text);
}
.btn-danger:hover:not(:disabled) {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.btn-small {
  height: 28px;
  padding: 0 10px;
  font-size: 0.75rem;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-link {
  background: none;
  border: none;
  color: var(--accent-text);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8125rem;
  padding: 2px 4px;
}
.btn-link:hover {
  text-decoration: underline;
}

/* --- Pull-down menus --- */

.dropdown {
  position: relative;
  display: inline-flex;
}
.dropdown-toggle::after,
.sheet-toggle::after {
  content: "";
  width: 6px;
  height: 6px;
  margin: -3px 0 0 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.8;
}
.dropdown-toggle[aria-expanded="true"]::after,
.sheet-toggle[aria-expanded="true"]::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 150;
  min-width: 200px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
}
.dropdown-menu.align-right {
  left: auto;
  right: 0;
}
.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8125rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.menu-item:hover:not(:disabled),
.menu-item:focus-visible {
  background: var(--surface-3);
  outline: none;
}
.menu-item:disabled {
  color: var(--text-3);
  cursor: not-allowed;
}
.menu-item.menu-danger {
  color: var(--bad-text);
}
.menu-item.menu-danger:hover:not(:disabled) {
  background: var(--bad-soft);
}
.menu-sep {
  height: 1px;
  margin: 4px 2px;
  background: var(--border);
}

/* A toggle button that carries a dot: amber for unsaved edits, red when
   those edits sit on an outdated revision. */
.has-dot {
  position: relative;
}
.has-dot::before {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--warn);
}
.has-dot.dot-red::before {
  background: var(--bad);
}

/* --- Status pills, chips and badges --- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-disconnected {
  background: var(--surface-3);
  color: var(--text-2);
}
.status-connecting {
  background: var(--warn-soft);
  color: var(--warn-text);
}
.status-connecting::before {
  animation: flash 1.2s infinite;
}
.status-warn {
  background: var(--warn-soft);
  color: var(--warn-text);
}
.status-active {
  background: var(--ok-soft);
  color: var(--ok-text);
}
.status-error {
  background: var(--bad-soft);
  color: var(--bad-text);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
}
a.chip:hover {
  text-decoration: none;
  filter: brightness(1.15);
}
.chip-ok {
  background: var(--ok-soft);
  color: var(--ok-text);
}
.chip-warn {
  background: var(--warn-soft);
  color: var(--warn-text);
}
.chip-bad {
  background: var(--bad-soft);
  color: var(--bad-text);
}

/* --- Toggle switch --- */

.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background-color 0.15s ease, border-color 0.15s ease;
  border-radius: 9px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  top: 2px;
  background: var(--text-2);
  transition: transform 0.15s ease, background-color 0.15s ease;
  border-radius: 50%;
}
input:checked + .slider {
  background: var(--accent);
  border-color: var(--accent);
}
input:checked + .slider:before {
  transform: translateX(14px);
  background: #fff;
}
input:focus-visible + .slider {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
input:disabled + .slider {
  cursor: not-allowed;
  opacity: 0.5;
}

/* --- Banners (warnings and errors) ---
   The severity word is drawn by CSS, so the banner's text stays exactly what
   the page wrote. */

.banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: 0.8125rem;
  line-height: 1.4;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left-width: 3px;
}
.banner-text {
  flex: 1 1 240px;
  min-width: 0;
}
.banner-warn,
.banner-error {
  color: var(--text);
}
.banner-warn {
  background: var(--warn-soft);
  border-color: var(--warn-line);
  border-left-color: var(--warn);
}
.banner-error {
  background: var(--bad-soft);
  border-color: var(--bad-line);
  border-left-color: var(--bad);
}
.issues .banner-warn::before,
.issues .banner-error::before {
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 1px;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.issues .banner-warn::before {
  content: "WARNING";
  background: var(--warn);
  color: #1a1204;
}
.issues .banner-error::before {
  content: "ERROR";
  background: var(--bad);
  color: #fff;
}
.issues .alert-firing::before {
  content: "FIRING";
}
.issues .alert-pending::before {
  content: "PENDING";
}
.issues,
.issues-alerts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.issues:not(:has(.banner:not([hidden]))),
.issues-alerts:empty {
  display: none;
}
.alert-line a {
  font-size: 0.75rem;
}
.error-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

/* --- Fleet page --- */

.fleet-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.fleet-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.fleet-toolbar input[type="search"] {
  width: 200px;
}
.fleet-toolbar select {
  width: auto;
  max-width: 200px;
}
.fleet-counts {
  font-size: 0.75rem;
  color: var(--text-3);
}

/* One chip per state; a click filters the grid to that state. */
.state-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.state-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.75rem;
  cursor: pointer;
}
.state-count b {
  color: var(--text);
  font-weight: 600;
}
.state-count::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--off);
}
.state-count.tone-ok::before {
  background: var(--ok);
}
.state-count.tone-warn::before {
  background: var(--warn);
}
.state-count.tone-bad::before {
  background: var(--bad);
  border-radius: 1px;
}
.state-count.tone-bad {
  border-color: var(--bad-line);
}
.state-count:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.state-count.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

/* Firing and pending alerts at the top of the fleet page. */
.attention {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}
.attention-row {
  display: grid;
  grid-template-columns: 76px minmax(90px, 160px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
}
.attention-row:first-child {
  border-top: none;
}
.attention-row .attention-subject {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attention-row .attention-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}
.attention-row .attention-since {
  color: var(--text-3);
  font-size: 0.75rem;
  white-space: nowrap;
}
.attention-more {
  padding: 5px 12px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-3);
}

.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 10px;
}

.node-card {
  padding: 10px 12px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  position: relative;
  transition: border-color 0.15s ease;
}
.node-card::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 3px;
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  background: var(--off);
}
.node-card:hover {
  border-color: var(--border-strong);
}
.node-card.state-connecting::before {
  background: var(--warn);
}
.node-card.state-active::before {
  background: var(--ok);
}
.node-card.state-error::before {
  background: var(--bad);
}
.node-card.state-error {
  border-color: var(--bad-line);
}
.node-card.state-offline {
  opacity: 0.65;
}
.node-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.conn-down .node-card {
  opacity: 0.55;
}

.node-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.node-select {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}
.node-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-card-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  min-height: 20px;
  font-size: 0.75rem;
  color: var(--text-2);
}
.lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  color: var(--text);
}
.lang-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--lang-color, var(--text-3));
}

.stage-dots {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stage-dot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.stage-dot .dot,
.stage-box-title::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--off);
  background: transparent;
  flex-shrink: 0;
}
/* State is carried by shape as well as colour: hollow = off, round = up,
   ringed = needs a look, square = error. */
.stage-dot.dot-ok .dot,
.stage-box.dot-ok .stage-box-title::before {
  background: var(--ok);
  border-color: var(--ok);
}
.stage-dot.dot-warn .dot,
.stage-box.dot-warn .stage-box-title::before {
  background: var(--warn);
  border-color: var(--warn);
  box-shadow: 0 0 0 2px var(--warn-soft);
}
.stage-dot.dot-bad .dot,
.stage-box.dot-bad .stage-box-title::before {
  background: var(--bad);
  border-color: var(--bad);
  border-radius: 1px;
}
.dot-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.node-card-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-2);
}
.node-card-stats .chip {
  text-transform: none;
  letter-spacing: 0;
}

/* --- Bulk bar --- */

.bulk-bar {
  position: sticky;
  bottom: 12px;
  z-index: 50;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  /* Pinned to the bottom, it must never cover most of a small screen. */
  max-height: 50vh;
  overflow-y: auto;
}
.bulk-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.bulk-group select {
  max-width: 180px;
}
.bulk-group label {
  font-size: 0.75rem;
  color: var(--text-2);
  white-space: nowrap;
}
.bulk-count {
  font-weight: 600;
}
/* Part of the selection is hidden by the filters. */
.bulk-count.warn {
  color: var(--warn-text);
}

/* --- Node page ---
   On a desktop screen the page is exactly one viewport tall: three columns
   whose last panel takes what is left, with feeds and tables scrolling in
   their own boxes. */

.node-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.node-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  position: relative;
}
.node-ident {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  margin-right: auto;
}
.node-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.crumb {
  color: var(--text-3);
  font-size: 0.8125rem;
}
.crumb:hover {
  color: var(--text);
  text-decoration: none;
}
.crumb::after {
  content: "/";
  margin-left: 10px;
  color: var(--border-strong);
}
.node-title h2 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  min-width: 0;
}
.node-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  font-size: 0.75rem;
  color: var(--text-3);
}
.node-meta > span:not(:empty) ~ span:not(:empty)::before {
  content: "\00b7";
  margin: 0 7px;
  color: var(--border-strong);
}
.node-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.action-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.ctl-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.node-body {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}
.node-col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
}
.node-col > .panel.fill {
  min-height: 260px;
}
/* Only the feeds (and the lag chart) give way when the screen is short. */
.node-col > .panel:not(.fill):not(.shrink) {
  flex-shrink: 0;
}

@media (min-width: 900px) {
  .node-body {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  }
  .node-col-3 {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

@media (min-width: 1280px) {
  .node-body {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr);
  }
  .node-col-3 {
    grid-column: auto;
    display: flex;
  }
}

/* Tall enough: the page is one screen, and the feeds take what is left. */
@media (min-width: 1280px) and (min-height: 680px) {
  .node-page {
    height: calc(100vh - var(--header-h) - 2 * var(--page-pad));
    height: calc(100dvh - var(--header-h) - 2 * var(--page-pad));
  }
  .node-body {
    flex: 1 1 auto;
  }
  .node-col > .panel.fill {
    flex: 1 1 0;
    min-height: 120px;
  }
  .node-col > .panel.fill > .panel-body {
    overflow-y: auto;
  }
  /* The timing panel gives up chart height, and the outputs table rows,
     before a feed drops under its minimum. */
  .node-col > .panel.shrink {
    flex: 0 1 auto;
    min-height: 96px;
  }
  .node-col > .panel.shrink > .panel-body {
    min-height: 0;
  }
  /* On a tall screen the lag chart takes a small share of the spare
     height; most of it goes to the transcript. */
  .node-col > .panel.chart-panel {
    flex: 0.35 1 auto;
  }
  .node-col > .panel.fill .feed {
    flex: 1 1 0;
    height: auto;
    min-height: 0;
  }
}

/* The stage chain: one row, left to right, in signal order. */
.stage-chain {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
  gap: 6px;
}
.stage-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stage-box.dot-bad {
  border-color: var(--bad-line);
  background: linear-gradient(var(--bad-soft), var(--bad-soft)), var(--surface);
}
.stage-box.dot-warn {
  border-color: var(--warn-line);
}
.stage-box-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-2);
}
.stage-box-title::before {
  content: "";
}
.stage-box-state {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: capitalize;
}
.stage-box.dot-ok .stage-box-state {
  color: var(--ok-text);
}
.stage-box.dot-warn .stage-box-state {
  color: var(--warn-text);
}
.stage-box.dot-bad .stage-box-state {
  color: var(--bad-text);
}
.stage-box-lines {
  font-size: 0.6875rem;
  color: var(--text-3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-height: 1.4em;
}
.stage-box-lines span + span::before {
  content: "\00b7";
  margin: 0 5px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 104px), 1fr));
  gap: 6px 12px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.stat-wide {
  grid-column: span 2;
}
.stat-label {
  font-size: 0.6875rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value {
  font-size: 0.8125rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.stat-value.ok {
  color: var(--ok-text);
}
.stat-value.warn {
  color: var(--warn-text);
}
.stat-value.bad {
  color: var(--bad-text);
}
/* The three figures the timing panel leads with. */
.stat-grid.kpis {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.stat-grid.kpis .stat {
  padding: 6px 10px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.stat-grid.kpis .stat-value {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* One row of small figures; the cell's title spells out a short label. */
.stat-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  gap: 4px 10px;
}
.stat-grid.kpis .stat:has(.stat-value.bad) {
  border-color: var(--bad-line);
  background: var(--bad-soft);
}
.stat-grid.kpis .stat:has(.stat-value.warn) {
  border-color: var(--warn-line);
}
.hint-line {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-2);
  line-height: 1.4;
}
.hint-line.warn {
  color: var(--warn-text);
}

/* Level meters and the lag chart */
canvas {
  background: var(--surface-2);
  border-radius: 3px;
  display: block;
}
.meter-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.meter-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 76px;
  grid-template-areas: "label bar value";
  align-items: center;
  gap: 4px 10px;
}
.vu-label {
  grid-area: label;
  font-size: 0.6875rem;
  color: var(--text-3);
}
.meter-canvas {
  grid-area: bar;
  width: 100%;
  height: 10px;
}
.meter-value {
  grid-area: value;
  font-size: 0.75rem;
  text-align: right;
  white-space: nowrap;
  color: var(--text-2);
}
.sub-head {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 2px 0 8px;
}
.timing-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chart-wrap {
  margin-top: 8px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chart-canvas {
  width: 100%;
  height: 100px;
  flex: 1 1 100px;
  min-height: 64px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: crosshair;
}
.chart-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
  min-height: 1.4em;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.6875rem;
  color: var(--text-3);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  width: 14px;
  height: 0;
  border-top: 2px solid var(--text-3);
}
.legend-swatch.series-1 {
  border-top-color: var(--series-1);
}
.legend-swatch.series-2 {
  border-top-color: var(--series-2);
}
.legend-swatch.reference {
  border-top: 1.5px dashed var(--text-2);
}
.chart-readout {
  margin-left: auto;
  font-size: 0.6875rem;
  color: var(--text-2);
}

/* Tabs inside a panel header */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tab {
  position: relative;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  height: 22px;
  padding: 0 10px;
  cursor: pointer;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  background: var(--surface-3);
  color: var(--text);
}
/* Something in a tab that is not showing needs a look. */
.tab.tab-warn::after,
.tab.tab-bad::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  vertical-align: 1px;
  background: var(--warn);
}
.tab.tab-bad::after {
  background: var(--bad);
}

/* Configuration at a glance: one line per area, each opening its section. */
.config-summary {
  display: flex;
  flex-direction: column;
}
.cfg-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 10px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 23px;
  padding: 2px 6px;
  margin: 0 -6px;
  width: calc(100% + 12px);
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}
.cfg-row + .cfg-row {
  border-top: 1px solid var(--border);
  border-radius: 0;
}
.cfg-row:hover {
  background: var(--surface-2);
}
.cfg-row::after {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg);
}
.cfg-label {
  font-size: 0.75rem;
  color: var(--text-3);
}
.cfg-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cfg-value.warn {
  color: var(--warn-text);
  font-weight: 600;
}
.cfg-value .cfg-sub {
  color: var(--text-3);
}

/* --- Configuration sheet ---
   Pulls down from the node bar over the dashboard: section list on the
   left, the chosen section on the right, the save bar at the bottom. */

.config-sheet {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 120;
  width: min(820px, calc(100vw - 2 * var(--page-pad)));
  max-height: calc(100vh - var(--header-h) - 90px);
  max-height: calc(100dvh - var(--header-h) - 90px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-right: auto;
}
.sheet-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-2);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.sheet-close:hover {
  background: var(--surface-3);
  color: var(--text);
}
.sheet-alerts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 14px;
}
.sheet-alerts:has(> :not([hidden])) {
  padding-top: 10px;
}
.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sheet-form {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sheet-form > .banner {
  margin: 10px 14px 0;
}
.cfg-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
}
.cfg-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 8px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.cfg-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}
.cfg-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}
.cfg-tab.active {
  background: var(--accent-soft);
  color: var(--text);
}
.cfg-tab.has-edits::after,
.cfg-tab.has-errors::after {
  content: "";
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}
.cfg-tab.has-errors::after {
  background: var(--bad);
}
.cfg-pane {
  padding: 14px 16px;
  overflow-y: auto;
  min-height: 260px;
}
.cfg-pane > h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 10px;
}
.save-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.save-bar > .muted {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-3);
}

/* --- Tables --- */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 0;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}
.data-table tr:last-child td {
  border-bottom: none;
}
.data-table td.cell-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 140px;
}
.data-table tr.row-firing td:first-child {
  box-shadow: inset 3px 0 0 var(--bad);
}
.data-table tr.row-pending td:first-child {
  box-shadow: inset 3px 0 0 var(--warn);
}
.data-table tr.row-resolved {
  color: var(--text-2);
}

/* --- Feeds (transcript, log, events, audit) --- */

.feed {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  height: 240px;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
}
.feed-tall {
  height: 320px;
}
.feed-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 8px;
  font-size: 0.8125rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.feed-line:last-child {
  border-bottom: none;
}
.feed-time {
  color: var(--text-3);
  font-size: 0.6875rem;
  white-space: nowrap;
}
.feed-badge {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0 5px;
  line-height: 16px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--text-2);
}
.feed-badge.level-error {
  background: var(--bad-soft);
  color: var(--bad-text);
}
.feed-badge.level-warn {
  background: var(--warn-soft);
  color: var(--warn-text);
}
.feed-badge.dir-out {
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--lang-color, var(--text-3));
}
.feed-text {
  flex: 1 1 200px;
  min-width: 0;
  color: var(--text);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.feed-data {
  flex-basis: 100%;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-3);
  overflow-wrap: anywhere;
}

/* --- Config form pieces --- */

.secret-field {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
}
.secret-state {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
}
.secret-field input {
  flex: 1 1 160px;
}
.output-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface-2);
}
.output-card.removed {
  opacity: 0.45;
}
.output-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.output-id {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.code-block {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}

/* --- Alerts page --- */

.alerts-page .panel {
  flex: 1 1 auto;
}
.alert-summary {
  font-weight: 500;
}
.alert-rule {
  font-size: 0.75rem;
  color: var(--text-3);
}

/* --- Settings page --- */

.settings-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 1100px) {
  .settings-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    align-items: start;
  }
}
@media (min-width: 1100px) and (min-height: 680px) {
  .settings-page {
    height: calc(100dvh - var(--header-h) - 2 * var(--page-pad));
    display: flex;
    flex-direction: column;
    gap: var(--gap);
  }
  .settings-grid {
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
  }
  .settings-grid > .panel,
  .settings-grid > .panel-stack > .panel.fill {
    min-height: 0;
  }
  .settings-grid > .panel > .panel-body {
    overflow-y: auto;
  }
  .settings-grid > .panel-stack > .panel.fill {
    flex: 1 1 0;
  }
  .settings-grid .panel.fill .feed {
    flex: 1 1 0;
    height: auto;
    min-height: 0;
  }
}
/* Alert rules as a compact list: name on the left, its fields in a row. */
.rules-list .form-section {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
  align-items: center;
  gap: 8px 16px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
}
.rules-list .form-section:first-child {
  border-top: none;
}
.rules-list .form-section > h3 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}
.rules-list .config-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
}
.rules-list .form-group {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.rules-list .form-group > label {
  white-space: nowrap;
}
.rules-list .form-group input[type="number"] {
  width: 76px;
  height: 28px;
}
.rules-list .toggle-field {
  min-height: 28px;
}
/* Always reachable, however long the rule list gets. */
.settings-page .save-bar {
  position: sticky;
  bottom: 0;
  padding: 10px 0 2px;
  margin-top: 6px;
  background: var(--surface);
}
.settings-page .empty-msg {
  text-align: left;
  padding: 2px 0 8px;
}
.row > input[type="url"],
.row > input[type="text"].input-compact {
  flex: 1 1 260px;
  width: auto;
}
.settings-page .output-card {
  margin-bottom: 6px;
  padding: 6px 10px;
}

/* --- Dialogs and toasts --- */

dialog.modal {
  margin: auto;
  width: min(540px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  padding: 18px;
}
dialog.modal::backdrop {
  background: rgba(5, 7, 11, 0.72);
}
/* Fallback when showModal() is not available. */
dialog.modal.modal-fallback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
}
.modal-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.8125rem;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.path-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow-wrap: anywhere;
}

.toast-stack {
  position: fixed;
  right: 16px;
  /* --toast-lift (set by ui.js) raises the stack above whatever a page pins
     to the bottom edge, such as the fleet page's bulk bar. */
  bottom: calc(16px + var(--toast-lift, 0px));
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-pop);
  font-size: 0.8125rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  animation: slideIn 0.15s ease-out;
}
.toast-ok {
  border-left-color: var(--ok);
}
.toast-warn {
  border-left-color: var(--warn);
}
.toast-error {
  border-left-color: var(--bad);
}

/* --- Login page --- */

.login-wrap {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-panel {
  width: min(360px, 100%);
  padding: 24px;
  gap: 18px;
}
.login-panel form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* --- Animations --- */

@keyframes flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* --- Small screens (down to 380 px) --- */

@media (max-width: 760px) {
  /* The header wraps; pinned, it would cover a large part of a phone. */
  header {
    position: static;
    height: auto;
    padding: 8px 12px;
  }
  .header-content {
    flex-wrap: wrap;
    gap: 6px 14px;
  }
  .main-nav {
    order: 3;
    width: 100%;
  }
  .nav-link {
    height: 32px;
  }
  .container {
    padding: 12px;
  }
  .fleet-toolbar {
    margin-left: 0;
    width: 100%;
  }
  .fleet-toolbar input[type="search"],
  .fleet-toolbar select {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
  }
  .attention-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .attention-row .attention-text {
    grid-column: 1 / -1;
    white-space: normal;
  }
  .attention-row .attention-since {
    display: none;
  }
  /* Label and reading share a line; the bar gets the full width below. */
  .meter-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label value"
      "bar bar";
  }
  .stat-grid.kpis .stat-value {
    font-size: 1rem;
    white-space: normal;
  }
  .fleet-toolbar .ctl-sep {
    display: none;
  }
  .config-sheet {
    position: fixed;
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .cfg-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .cfg-nav {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .rules-list .form-section {
    grid-template-columns: minmax(0, 1fr);
  }
  .bulk-bar {
    gap: 8px 12px;
  }
  .bulk-bar .spacer {
    display: none;
  }
  dialog.modal {
    padding: 14px;
  }
}
