/* DeployHub dashboard — Nocturne design system (see claude.ai/design project
   "DeployHub v2"). Tokens below are Nocturne's; --panel/--panel-2/--text-dim/
   --text-faint/--border are DeployHub-local aliases onto them so existing
   inline styles (app.js/index.html) and older class names keep resolving
   without having to touch every call site. DeployHub explicitly supports a
   LAN-only layout with no outbound internet - an @import of a Google Fonts
   URL here used to block first paint for the DNS/connect timeout on such a
   workstation before falling back; dropped in favor of the system-ui/
   -apple-system/Segoe UI/Roboto stack --font-body already falls back to. */

:root {
  --color-bg: #161826;
  --color-surface: #232532;
  --color-text: #e9e9ed;
  --color-accent: #9184d9;
  --color-accent-2: #a7a1db;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  --color-neutral-100: #f3f5fe;
  --color-neutral-200: #e4e7f5;
  --color-neutral-300: #cfd3e5;
  --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab;
  --color-neutral-600: #75798c;
  --color-neutral-700: #595d6c;
  --color-neutral-800: #3f424d;
  --color-neutral-900: #292b31;

  --color-accent-100: #f5f4ff;
  --color-accent-200: #e7e5fe;
  --color-accent-300: #d2cefd;
  --color-accent-400: #b5abfc;
  --color-accent-500: #968ae0;
  --color-accent-600: #796cbf;
  --color-accent-700: #5d5294;
  --color-accent-800: #423a6a;
  --color-accent-900: #2b2741;

  --font-heading: "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 0 0 1px var(--color-neutral-800);
  --shadow-md: 0 0 0 1px var(--color-neutral-700), 0 6px 18px rgba(0,0,0,0.55);
  --shadow-lg: 0 0 0 1px var(--color-neutral-500), 0 16px 40px rgba(0,0,0,0.65);

  /* ---- DeployHub-local aliases (used throughout app.js/index.html) ---- */
  --bg: var(--color-bg);
  --panel: var(--color-surface);
  --panel-2: var(--color-neutral-900);
  --border: var(--color-divider);
  --text: var(--color-text);
  --text-dim: var(--color-neutral-400);
  --text-faint: var(--color-neutral-600);
  --accent: var(--color-accent);
  --radius: var(--radius-md);

  /* Status colors - kept as their own tokens (not tied to --accent) so a
     device's online/offline/checking state reads unambiguously regardless
     of the chosen accent color. */
  --online: #7dd4a0;
  --checking: #e3c878;
  --offline: #e58a8a;
  --snmp: #8b8fa3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body), -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
}

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 500; margin: 0; }

button, select, input, textarea {
  font-family: inherit;
  font-size: inherit;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--color-neutral-700); border-radius: 8px; border: 2px solid var(--bg); }

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

/* ================================ Layout ================================ */

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 100%;
  height: 100vh;
}

/* The map editor ("Настройки") wants the full main-column width for the
   floor-plan canvas - there is no third column anymore to hide (Activity
   lives inside the Дашборд tab now, not a persistent right rail), so this
   only toggles the settings-view's own layout, not the grid. */

/* ---------- Sidebar ---------- */

.sidebar {
  background: linear-gradient(180deg, var(--color-neutral-900), var(--bg));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
}

.brand .logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--color-accent-700);
  background: var(--color-accent-900);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent-300);
  box-shadow: 0 0 18px color-mix(in oklab, var(--accent) 25%, transparent);
  flex-shrink: 0;
}

.brand .title { font-family: var(--font-heading); font-weight: 500; font-size: 16px; letter-spacing: 0.01em; }
.brand .subtitle { font-size: 11px; color: var(--color-neutral-400); }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--color-neutral-300);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}

.nav-item:hover { background: var(--color-neutral-800); color: var(--text); }

.nav-item.active {
  background: var(--color-accent-900);
  border-color: var(--color-accent-700);
  color: var(--color-accent-100);
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.9; }
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--color-accent-900);
  border: 1px solid var(--color-accent-700);
  color: var(--color-accent-200);
}

.sidebar-divider {
  margin: 10px 16px 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-neutral-700), transparent);
}

.sidebar-summary { padding: 14px 16px; }
.sidebar-summary .summary-kicker {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-neutral-500);
  margin-bottom: 8px;
}

/* Pushed to the very bottom of the sidebar via margin-top:auto regardless
   of how many nav items/summary rows sit above it. */
.sidebar-user {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .avatar {
  width: 28px; height: 28px; border-radius: 99px; flex-shrink: 0;
  background: var(--color-neutral-800); border: 1px solid var(--color-neutral-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--color-accent-200); text-transform: uppercase;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .role { font-size: 11px; color: var(--color-neutral-500); }

.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.online { background: var(--online); box-shadow: 0 0 8px color-mix(in oklab, var(--online) 60%, transparent); }
.dot.checking { background: var(--checking); }
.dot.offline { background: var(--offline); }
.dot.snmp { background: var(--snmp); }

/* ---------- Main ---------- */

.main {
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  padding: 18px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.topbar h1 { font-size: 21px; margin: 0 0 2px; }
.topbar .crumb { font-size: 12.5px; color: var(--text-dim); }

.last-update {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: right;
  cursor: pointer;
}
.last-update svg { width: 16px; height: 16px; opacity: 0.8; }
.pulse-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--online); animation: dhPulse 2.4s infinite; }

/* ---------- KPI stat cards ---------- */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card {
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.stat-card .label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.stat-card .value {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 10px;
}
.stat-card .value .pct { font-size: 12px; font-weight: 400; color: var(--color-neutral-500); margin-left: 6px; }

.stat-bar { height: 3px; border-radius: 99px; background: var(--color-neutral-800); overflow: hidden; }
.stat-bar > div { height: 100%; border-radius: 99px; }

.card {
  background: var(--panel);
  border-radius: var(--radius-md);
}

.card-header {
  padding: 14px 16px 0;
  font-size: 13px;
  font-weight: 500;
}

.card-body { padding: 4px 16px 14px; }

/* ---------- Dashboard layout ----------
   The office map is a full-width block on its own so it never has to be
   cropped/scrolled inside a narrow side column (confirmed live: a fixed
   1000px-floor canvas next to a side column always got clipped on a normal
   laptop screen) - "Требует внимания" and "Активность" sit in a narrower
   row underneath instead. */

.dash-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---------- Alerts card ("Требует внимания") ---------- */

.alert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--color-neutral-800);
  font-size: 12.5px;
}
.alert-row:first-child { border-top: none; }
.alert-row .body { flex: 1; min-width: 0; }
.alert-row .title { color: var(--text); }
.alert-row .detail { color: var(--text-dim); font-size: 11.5px; margin-top: 1px; }
.alerts-empty { text-align: center; color: var(--text-faint); padding: 14px 0; font-size: 12.5px; }

/* ---------- Office map ---------- */

.map-canvas-wrap {
  flex: 1;
  overflow: auto;
  padding: 18px;
  min-height: 380px;
  min-width: 0;
}

.office-map {
  position: relative;
  background: var(--panel);
  border-radius: var(--radius-md);
  background-image: linear-gradient(var(--color-neutral-800) 1px, transparent 1px), linear-gradient(90deg, var(--color-neutral-800) 1px, transparent 1px);
}

.map-legend {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }

.map-svg { position: absolute; top: 0; left: 0; }

.grid-line { stroke: var(--color-neutral-800); stroke-width: 1; opacity: 0.5; pointer-events: none; }
.grid-line.major { opacity: 0.9; }
.office-map:not(.editable) .grid-line { display: none; }

.room-shape {
  fill: var(--cab-color, var(--color-neutral-700));
  fill-opacity: 0.06;
  stroke: var(--cab-color, var(--color-neutral-700));
  stroke-width: 1;
  stroke-opacity: 0.55;
}
.office-map.editable .room-shape { cursor: move; stroke-dasharray: 4 3; stroke-opacity: 1; }
.room-shape.room-selected { stroke-width: 1.5; stroke-dasharray: none; filter: drop-shadow(0 0 8px color-mix(in oklab, var(--accent) 35%, transparent)); }
.room-shape.filter-dim { opacity: 0.3; }

.map-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.room-label {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}
.room-label.filter-dim { opacity: 0.3; }
.room-label .name { display: block; font-weight: 500; font-size: 13px; color: var(--color-neutral-300); }
.room-label .sub { display: block; font-size: 10.5px; color: var(--color-neutral-500); }

.vertex-handle {
  position: absolute;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel);
  cursor: grab;
  pointer-events: auto;
}
.vertex-handle:active { cursor: grabbing; }

.device {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--color-neutral-800);
  border: 1px solid var(--color-neutral-700);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-neutral-200);
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
}

.office-map.editable .device { cursor: move; }
.device.dev-selected { border-color: var(--accent); box-shadow: 0 0 12px color-mix(in oklab, var(--accent) 40%, transparent); z-index: 5; }
.device.device-hidden-ghost { opacity: 0.35; border-style: dashed; }

.device svg { width: 14px; height: 14px; }

.device .dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--bg);
  box-sizing: content-box;
}

.draw-in-progress { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 4; pointer-events: none; }
.draw-vertex-dot { fill: var(--accent); pointer-events: none; }
.draw-preview-line { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 4; pointer-events: none; }
.draw-preview-label { fill: var(--text); font-size: 12px; pointer-events: none; }

.map-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  padding: 4px 0 2px;
}

/* Floating hover tooltip + right-click context menu on the read-only
   (dashboard) map - built by app.js's renderMapTooltip/openMapContextMenu. */
.map-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 10;
  background: var(--color-neutral-900);
  border: 1px solid var(--color-neutral-700);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}
.map-tooltip .head { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.map-tooltip .meta { color: var(--text-dim); margin-top: 3px; }
.map-tooltip .status { margin-top: 2px; color: var(--color-neutral-300); }

/* Hover readout on the Сеть tab's canvas charts (app.js NET.chartHover):
   same chrome as .map-tooltip, with a timestamp head and one value row per
   series - value first (it's what the reader came for), series name dim. */
.net-chart-tip { min-width: 120px; }
.net-chart-tip .head { color: var(--text-dim); font-weight: 400; font-variant-numeric: tabular-nums; margin-bottom: 5px; }
.net-chart-tip .row { display: flex; align-items: center; gap: 7px; line-height: 19px; }
.net-chart-tip .key { width: 10px; height: 3px; border-radius: 2px; flex: none; }
.net-chart-tip .val { font-weight: 500; font-variant-numeric: tabular-nums; min-width: 54px; }
.net-chart-tip .val.none { color: var(--text-faint); font-weight: 400; }
.net-chart-tip .lbl { color: var(--text-dim); }

.map-context-menu {
  position: fixed;
  z-index: 60;
  background: var(--color-neutral-900);
  border: 1px solid var(--color-neutral-700);
  border-radius: 8px;
  padding: 0 0 6px;
  min-width: 190px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.map-context-menu .head {
  padding: 8px 12px 6px;
  font-size: 11px;
  color: var(--color-neutral-500);
  border-bottom: 1px solid var(--color-neutral-800);
  white-space: nowrap;
}
.map-context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--color-neutral-200);
}
.map-context-menu button:hover { background: var(--color-neutral-800); }
.map-context-menu button.danger { color: var(--offline); }
.map-context-backdrop { position: fixed; inset: 0; z-index: 59; }

/* ---- Map editor layout ("Настройки") ---- */
.map-editor-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 0 16px 16px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.show-hidden-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.editor-panel {
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 16px;
}
.editor-panel h4 { margin: 0 0 12px; font-size: 13px; font-weight: 500; }
.editor-panel .form-field { margin-bottom: 10px; }
.editor-panel-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }

/* ---------- Sidebar summary rows (also used standalone) ---------- */

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 12.5px;
  color: var(--color-neutral-300);
}
.summary-row .n { color: var(--text); font-weight: 500; }
.summary-row .n.zero { color: var(--color-neutral-600); }

/* ---------- Settings / map editor ---------- */

.settings-view { display: none; flex-direction: column; gap: 14px; }
.settings-view.active { display: flex; flex: 1; min-height: 0; }

.settings-tabs { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.settings-tab {
  background: transparent;
  border: 1px solid var(--color-neutral-700);
  color: var(--color-neutral-400);
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.settings-tab:hover { color: var(--text); border-color: var(--color-neutral-500); }
.settings-tab.active { background: var(--color-accent-900); border-color: var(--color-accent-600); color: var(--color-accent-100); }

.settings-tab-panel { display: none; flex-direction: column; flex: 1; min-height: 0; }
.settings-tab-panel.active { display: flex; }
/* The 4 placeholder tabs are static forms, not full-height flex layouts
   like the map editor - block display (not flex) when active. */
.settings-tab-panel:not(#settingsTab-map).active { display: block; }

.settings-placeholder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 420px));
  gap: 16px;
  align-items: start;
}
.settings-placeholder-grid .card { padding: 18px; }
.settings-placeholder-grid .card-title-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 13px; font-weight: 500;
}
.settings-status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 2px 9px; border-radius: 99px;
  border: 1px solid color-mix(in oklab, var(--pill-c, var(--online)) 45%, transparent);
  color: var(--pill-c, var(--online));
  background: color-mix(in oklab, var(--pill-c, var(--online)) 10%, transparent);
}

.dashboard-view { display: none; flex-direction: column; gap: 16px; flex: 1; }
.dashboard-view.active { display: flex; }

.form-row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.form-field { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.form-field label { font-size: 11.5px; color: var(--text-faint); }
.form-field input, .form-field select, .input, .settings-static-input {
  background: var(--color-surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  min-height: 34px;
  width: 100%;
}
.form-field input:hover, .form-field select:hover, .input:hover, .settings-static-input:hover { border-color: var(--color-neutral-500); }
.form-field input:focus-visible, .form-field select:focus-visible, .input:focus-visible, .settings-static-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }

.tag {
  display: inline-flex; align-items: center; font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px; border-radius: 99px; white-space: nowrap;
}
.tag-neutral { background: var(--color-neutral-800); color: var(--color-neutral-200); }
.tag-outline { border: 1px solid var(--accent); color: var(--accent); }
.tag-danger { border: 1px solid var(--offline); color: var(--offline); }

.switch-row {
  display: flex; align-items: center; gap: 9px;
  background: transparent; border: none; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 12.5px; color: var(--color-neutral-300);
  text-align: left;
}
.switch-track {
  display: inline-flex; align-items: center; width: 34px; height: 19px; border-radius: 99px; padding: 2px;
  box-sizing: border-box; flex: 0 0 auto; transition: background .15s, border-color .15s;
  background: var(--color-neutral-800); border: 1px solid var(--color-neutral-600);
}
.switch-track.on { background: var(--color-accent-800); border-color: var(--color-accent-500); }
.switch-thumb {
  width: 13px; height: 13px; border-radius: 99px; background: var(--color-neutral-400);
  transition: transform .15s, background .15s;
}
.switch-track.on .switch-thumb { background: var(--color-accent-200); transform: translateX(15px); }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--offline); border-color: var(--offline); }
.icon-btn svg { width: 14px; height: 14px; }

.icon-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn-primary:hover { filter: brightness(1.1); color: #fff; border-color: var(--accent); }

.icon-btn-danger { color: var(--offline); border-color: color-mix(in oklab, var(--offline) 40%, transparent); }
.icon-btn-danger:hover { background: color-mix(in oklab, var(--offline) 12%, transparent); color: var(--offline); border-color: var(--offline); }

.supply-low { color: var(--offline); font-weight: 600; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--font-heading);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  cursor: pointer;
  font-family: var(--font-heading);
}
.btn-secondary:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
/* #netRefreshBtn is the only .btn-secondary with a raw <svg><use> icon (no
   width/height attributes) - without this, a bare SVG falls back to the
   browser's default replaced-element size (300x150 CSS px), rendering as a
   huge icon instead of a small button glyph like every other icon button
   in this file (.icon-btn svg, .nav-item svg, etc. all set this). */
.btn-secondary svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-ghost {
  background: transparent; border: none; color: var(--accent);
  cursor: pointer; font-family: var(--font-heading); padding: 4px 2px;
}
.btn-ghost:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.btn-ghost.danger { color: var(--offline); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid var(--color-neutral-700);
  background: transparent;
  color: var(--color-neutral-400);
}
.chip:hover { color: var(--text); border-color: var(--color-neutral-500); }
.chip.active { border-color: var(--color-accent-600); background: var(--color-accent-900); color: var(--color-accent-100); }

.settings-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 0 16px 14px;
}

.save-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--online);
  color: #0c2417;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
}
.save-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.stub-view { display: none; padding: 40px; text-align: center; color: var(--text-faint); }
.stub-view.active { display: block; }
.stub-view h2 { color: var(--text-dim); font-size: 17px; margin: 0 0 8px; font-weight: 500; }

.filter-dim { opacity: 0.32; }
.device-dim { opacity: 0.28; }
.device-match { box-shadow: 0 0 0 1.5px var(--accent); }

/* ---------- Computers view ---------- */

.computers-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-right: 16px;
}
.computers-toolbar-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.computers-toolbar-controls select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 8px;
}
.computers-count { font-size: 12.5px; color: var(--text-faint); }

.search-field { position: relative; }
.search-field svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--color-neutral-500); pointer-events: none;
}
.search-field input { padding-left: 32px !important; }

.computers-table-wrap { padding: 12px 16px 16px; overflow-x: auto; }
.computers-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.computers-table th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-neutral-800);
}
.computers-table td {
  padding: 10px;
  border-bottom: 1px solid var(--color-neutral-800);
  color: var(--text-dim);
}
.computers-table tbody tr:hover { background: var(--color-neutral-900); cursor: pointer; }
.computers-table tbody tr:last-child td { border-bottom: none; }
.computers-empty { text-align: center; color: var(--text-faint); padding: 20px !important; cursor: default; }

.computers-table tr.computers-group-header td {
  background: var(--panel-2);
  padding: 9px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-neutral-400);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.computers-table tr.computers-group-header:hover td { color: var(--text); background: var(--color-neutral-900); }
.computers-table tr.computers-group-header .chev {
  width: 14px;
  height: 14px;
  color: var(--color-neutral-500);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.computers-table tr.computers-group-header .chev.open { transform: rotate(180deg); }
.computers-table tr.computers-group-header .computers-group-count {
  color: var(--color-neutral-500);
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}
.computers-error {
  display: none;
  margin: 0 16px;
  background: color-mix(in oklab, var(--offline) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--offline) 40%, transparent);
  color: var(--offline);
  font-size: 12.5px;
  border-radius: 8px;
  padding: 8px 10px;
}
.computers-error.show { display: block; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}
.status-badge.discovered { color: var(--color-accent-300); background: color-mix(in oklab, var(--color-accent-300) 12%, transparent); border-color: color-mix(in oklab, var(--color-accent-300) 30%, transparent); }
.status-badge.pending { color: var(--checking); background: color-mix(in oklab, var(--checking) 12%, transparent); border-color: color-mix(in oklab, var(--checking) 30%, transparent); }
.status-badge.approved { color: #84a9d9; background: color-mix(in oklab, #84a9d9 12%, transparent); border-color: color-mix(in oklab, #84a9d9 30%, transparent); }
.status-badge.provisioning { color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, transparent); border-color: color-mix(in oklab, var(--accent) 30%, transparent); }
.status-badge.active { color: var(--online); background: color-mix(in oklab, var(--online) 12%, transparent); border-color: color-mix(in oklab, var(--online) 30%, transparent); }
.status-badge.disabled { color: var(--text-faint); background: color-mix(in oklab, var(--text-faint) 12%, transparent); border-color: color-mix(in oklab, var(--text-faint) 30%, transparent); }

/* ---------- Printers view (card grid) ---------- */

.printers-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.printers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.printer-card {
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.printer-card:hover { box-shadow: 0 0 0 1px var(--color-neutral-600); }
.printer-card-head { display: flex; align-items: flex-start; gap: 11px; }
.printer-card-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--color-neutral-800); border: 1px solid var(--color-neutral-700);
  display: flex; align-items: center; justify-content: center; color: var(--color-neutral-300);
  flex-shrink: 0;
}
.printer-card-title { flex: 1; min-width: 0; }
.printer-card-title .name { font-size: 14px; font-weight: 500; }
.printer-card-title .ip { font-size: 11.5px; color: var(--text-dim); margin-top: 1px; }
.printer-card-supply { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-dim); margin-bottom: 5px; }
.printer-card-bar { height: 5px; border-radius: 99px; background: var(--color-neutral-800); overflow: hidden; }
.printer-card-bar > div { height: 100%; border-radius: 99px; }
.printer-card-foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.printer-card-foot .actions { margin-left: auto; display: flex; gap: 4px; }
.printers-empty { text-align: center; color: var(--text-faint); padding: 60px 0; font-size: 13px; }

/* ---------- Programs & drivers view ---------- */

.pd-view-inner { display: flex; flex-direction: column; gap: 20px; width: 100%; }
.pd-section-title { font-size: 13px; font-weight: 500; color: var(--text-dim); margin: 0 0 4px; }
.pd-list { display: flex; flex-direction: column; gap: 10px; }
.pd-row {
  background: var(--panel);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 18px;
  flex-wrap: wrap;
}
.pd-row:hover { box-shadow: 0 0 0 1px var(--color-neutral-600); }
.pd-icon {
  width: 34px; height: 34px; border-radius: 8px; flex: 0 0 auto;
  background: var(--color-neutral-800); border: 1px solid var(--color-neutral-700);
  display: flex; align-items: center; justify-content: center; color: var(--color-neutral-300);
}
.pd-name { font-size: 13.5px; color: var(--text); font-weight: 500; }
.pd-sub {
  font-size: 11px;
  color: var(--text-faint);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  margin-top: 2px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pd-namebox { min-width: 0; flex: 0 0 220px; }
.pd-groups { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
.pd-actions { display: flex; gap: 4px; }

.type-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.type-badge.type-msi { color: #84a9d9; background: color-mix(in oklab, #84a9d9 12%, transparent); border-color: color-mix(in oklab, #84a9d9 30%, transparent); }
.type-badge.type-exe { color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, transparent); border-color: color-mix(in oklab, var(--accent) 30%, transparent); }
.type-badge.type-zip { color: var(--checking); background: color-mix(in oklab, var(--checking) 12%, transparent); border-color: color-mix(in oklab, var(--checking) 30%, transparent); }
.type-badge.type-ps1 { color: var(--online); background: color-mix(in oklab, var(--online) 12%, transparent); border-color: color-mix(in oklab, var(--online) 30%, transparent); }
.type-badge.type-cmd { color: #e3a878; background: color-mix(in oklab, #e3a878 12%, transparent); border-color: color-mix(in oklab, #e3a878 30%, transparent); }
.type-badge.type-printer_inf { color: var(--color-accent-300); background: color-mix(in oklab, var(--color-accent-300) 12%, transparent); border-color: color-mix(in oklab, var(--color-accent-300) 30%, transparent); }

.pd-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.pd-span-2 { grid-column: 1 / -1; }

.file-dropzone {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.file-dropzone:hover { border-color: var(--text-faint); }
.file-dropzone.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.file-dropzone-icon { width: 20px; height: 20px; color: var(--text-faint); margin-bottom: 6px; }
.file-dropzone-text { font-size: 12.5px; color: var(--text-faint); }
.file-dropzone-text span { color: var(--accent); text-decoration: underline; }
.file-dropzone-filename { font-size: 12.5px; color: var(--text); margin-top: 6px; font-weight: 600; word-break: break-all; }
.file-dropzone-filename:empty { display: none; }

.group-chip {
  display: inline-block;
  padding: 2px 8px;
  margin: 0 4px 4px 0;
  border-radius: 20px;
  font-size: 11px;
  background: var(--color-neutral-800);
  color: var(--color-neutral-200);
}
.group-chip-empty { color: var(--text-faint); background: transparent; padding-left: 0; margin: 0; }

.group-assign-list { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; }
.group-assign-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
}
.group-assign-row:hover { background: var(--color-neutral-900); color: var(--text); }

/* ---------- Modal ---------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 20, 0.66);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 30px;
}
.modal-overlay.show { display: flex; }

.modal-card {
  width: 720px;
  max-width: 96vw;
  max-height: 88vh;
  background: var(--panel);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--color-neutral-800);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}
.modal-title { font-family: var(--font-heading); font-size: 18px; font-weight: 500; }
.modal-subtitle { font-size: 11px; color: var(--text-faint); margin-top: 2px; font-family: "SF Mono", Menlo, Consolas, monospace; }

.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-body h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-neutral-500);
  margin: 18px 0 8px; font-weight: 500;
}
.modal-body h4:first-child { margin-top: 0; }

.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }

.modal-error {
  display: none;
  background: color-mix(in oklab, var(--offline) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--offline) 40%, transparent);
  color: var(--offline);
  font-size: 12.5px;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 14px;
}
.modal-error.show { display: block; }

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 12.5px;
  padding: 6.5px 0;
  border-top: 1px solid var(--color-neutral-800);
  color: var(--text-dim);
}
.modal-grid > div > .kv-row:first-of-type { border-top: none; }
.kv-row span:first-child { color: var(--text-dim); }
.kv-row span:last-child { color: var(--text); text-align: right; word-break: break-all; }

.modal-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; align-items: center; }

.report-item {
  font-size: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--color-neutral-800);
}
.report-item:first-child { border-top: none; }
.report-item .rt-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.report-item .rt-time { color: var(--text-faint); font-size: 11px; flex-shrink: 0; white-space: nowrap; }
.report-item .rt-step { color: var(--text); font-weight: 500; }
.report-item .rt-msg { color: var(--text-dim); margin-top: 2px; }
.report-item.error .rt-step { color: var(--offline); }
.report-item.success .rt-step { color: var(--online); }

/* ---------- Computer detail modal (карточка компьютера) ----------
   Layout contract: sections are stacked and hairline-separated; safe
   actions are btn-secondary, destructive ones live only inside
   .cm-danger-zone as .btn-danger (GitHub-style "danger zone" rows with a
   one-line consequence description next to each button). */

.cm-card { width: 860px; }

.cm-head { min-width: 0; flex: 1; }
.cm-head-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.cm-head-row .modal-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-head-status:empty { display: none; }

.cm-section + .cm-section {
  border-top: 1px solid var(--color-neutral-800);
  margin-top: 20px;
  padding-top: 16px;
}
.modal-body .cm-section > h4 { margin-top: 0; }

/* Approve callout - accent-tinted so the "one thing to do" for a pending
   computer is impossible to miss at the top of the card. */
.cm-approve {
  border: 1px solid var(--color-accent-700);
  background: color-mix(in oklab, var(--color-accent-900) 55%, transparent);
  border-radius: var(--radius-md);
  padding: 14px 16px 12px;
  margin-bottom: 20px;
}
.cm-approve-title { font-size: 13.5px; font-weight: 600; color: var(--color-accent-100); }
.cm-approve-hint { font-size: 12px; color: var(--text-dim); margin: 4px 0 12px; }

/* Overview: two kv columns that collapse to one on narrow screens. */
.cm-kv-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 28px; }
.cm-kv-cols > div > .kv-row:first-of-type { border-top: none; }

/* kv value that carries an extra control (e.g. "Переустановка: запланирована
   [Отменить]" - the cancel button is shown/hidden by openDetail). */
.kv-row .kv-wrap { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.kv-row .kv-wrap > span { color: var(--text); }
.cm-inline-cancel {
  padding: 1px 9px;
  font-size: 11.5px;
  border: 1px solid color-mix(in oklab, var(--offline) 40%, transparent);
  border-radius: 99px;
}
.cm-inline-cancel:hover { border-color: var(--offline); }

/* Collapsible hardware inventory. */
.cm-details {
  border: 1px solid var(--color-neutral-800);
  border-radius: var(--radius-md);
  background: var(--panel-2);
}
.cm-details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-neutral-400);
}
.cm-details > summary::-webkit-details-marker { display: none; }
.cm-details > summary:hover { color: var(--text); }
.cm-details > summary .chev { width: 14px; height: 14px; color: var(--color-neutral-500); transition: transform 0.15s; }
.cm-details[open] > summary .chev { transform: rotate(180deg); }
.cm-details-body { padding: 0 14px 12px; }
.cm-details-body .kv-row:first-of-type { border-top: none; }

/* Safe maintenance actions. */
.cm-actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cm-actions-row .btn-secondary { font-size: 12.5px; padding: 7px 12px; }

/* Danger zone. */
.modal-body h4.cm-danger-title { color: color-mix(in oklab, var(--offline) 85%, var(--text)); }
.cm-danger-zone {
  border: 1px solid color-mix(in oklab, var(--offline) 32%, transparent);
  border-radius: var(--radius-md);
}
.cm-danger-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; flex-wrap: wrap; }
.cm-danger-row + .cm-danger-row { border-top: 1px solid color-mix(in oklab, var(--offline) 18%, transparent); }
.cm-danger-row .txt { flex: 1; min-width: 200px; }
.cm-danger-row .t { font-size: 13px; font-weight: 500; color: var(--text); }
.cm-danger-row .d { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  border: 1px solid color-mix(in oklab, var(--offline) 55%, transparent);
  color: var(--offline);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  font-size: 12.5px;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--font-heading);
  flex-shrink: 0;
}
.btn-danger:hover { background: color-mix(in oklab, var(--offline) 12%, transparent); border-color: var(--offline); }

/* History: backups + reports side by side, each independently scrollable. */
.cm-history-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 4px 28px; }
.cm-history-box { min-width: 0; }
.cm-history-box > h4 { margin-top: 0; }
.cm-scroll { max-height: 280px; overflow-y: auto; padding-right: 4px; }

/* ---- Role gating (admin vs view-only "user") ----
   app.js's init() sets body.role-user for a view-only session; everything
   tagged .admin-only (mutating buttons/forms/sections whose API routes 403
   for that role) disappears. !important on purpose: several of these
   elements get inline display values from JS (e.g. cmApproveSection,
   cmCancelReimageBtn), and the stylesheet !important must beat those. */
body.role-user .admin-only { display: none !important; }

/* ---- Network ("Сеть") monitoring tab ---- */
.net-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.net-summary { display: flex; align-items: baseline; gap: 8px; }
.net-speed-big { font-size: 26px; font-weight: 600; color: var(--text); }
.net-speed-sub { font-size: 12.5px; color: var(--text-dim); }
.net-hops { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.net-hop { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--snmp); border-radius: var(--radius); padding: 12px 14px; }
.net-hop.net-online { border-left-color: var(--online); }
.net-hop.net-checking { border-left-color: var(--checking); }
.net-hop.net-offline { border-left-color: var(--offline); }
.net-hop-top { display: flex; align-items: center; gap: 7px; }
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--snmp); flex: none; }
.net-online .net-dot { background: var(--online); }
.net-checking .net-dot { background: var(--checking); }
.net-offline .net-dot { background: var(--offline); }
.net-hop-name { font-size: 13px; color: var(--text-dim); }
.net-hop-rtt { font-size: 22px; font-weight: 600; color: var(--text); margin: 4px 0 2px; }
.net-hop-sub { font-size: 11.5px; color: var(--text-faint); }
.net-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.net-chart-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.net-chart-head { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.net-chart-wrap { position: relative; width: 100%; height: 200px; }
.net-chart-wrap canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: pan-y; }
.net-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.net-leg { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-dim); }
.net-leg-dot { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.net-empty { color: var(--text-dim); font-size: 13px; padding: 24px 0; }
.net-updated { margin-top: 12px; font-size: 11.5px; color: var(--text-faint); }
