:root {
  color-scheme: dark;
  --bg: #0a161a;
  --bg-deep: #071014;
  --panel: #0b1920;
  --panel-raised: #0e2028;
  --panel-soft: #0c1c22;
  --text: #e0eded;
  --muted: #83aaaa;
  --line: rgba(224, 237, 237, 0.12);
  --line-strong: rgba(29, 162, 126, 0.42);
  --accent: #1da27e;
  --accent-strong: #28bd93;
  --accent-soft: rgba(29, 162, 126, 0.14);
  --blue: #22d3ee;
  --danger: #e05252;
  --danger-strong: #f06464;
  --warn: #e4a541;
  --ok: #36c98f;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.34), 0 1px 0 rgba(255, 255, 255, 0.025);
  --shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.22);
  --focus: 0 0 0 3px rgba(29, 162, 126, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-deep);
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 14% -10%, rgba(29, 162, 126, 0.16), transparent 35%),
    radial-gradient(circle at 94% 8%, rgba(34, 211, 238, 0.07), transparent 30%),
    linear-gradient(rgba(224, 237, 237, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(224, 237, 237, 0.018) 1px, transparent 1px),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  background-size: auto, auto, 42px 42px, 42px 42px, auto;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(29, 162, 126, 0.36);
  color: #ffffff;
}

* {
  scrollbar-color: rgba(131, 170, 170, 0.5) var(--bg-deep);
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

*::-webkit-scrollbar-thumb {
  border: 3px solid var(--bg-deep);
  border-radius: 999px;
  background: rgba(131, 170, 170, 0.5);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h1::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1px solid rgba(224, 237, 237, 0.22);
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent-strong), #1c8585);
  box-shadow: 0 0 22px rgba(29, 162, 126, 0.48);
}

h2 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.012em;
}

h3 {
  font-size: 18px;
  letter-spacing: -0.015em;
}

p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.sr-only {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.topbar {
  min-height: 82px;
  padding: 16px clamp(16px, 3vw, 34px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 20, 0.88);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  position: sticky;
  top: 0;
  z-index: 3;
}

body.auth-mode .topbar {
  justify-content: center;
}

body.auth-mode .top-actions,
body.auth-mode #server-subtitle,
body.auth-mode:not(.setup-mode) .auth-heading {
  display: none !important;
}

body.auth-mode.setup-mode .auth-heading {
  display: flex;
}

#auth-subtitle:empty {
  display: none;
}

.topbar > div:first-child {
  min-width: 0;
}

#server-subtitle {
  max-width: min(1050px, 72vw);
  margin-top: 5px;
  overflow: hidden;
  color: rgba(224, 237, 237, 0.58);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions,
.toolbar,
.dialog-head,
.section-title,
.device-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions,
.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.server-switcher {
  min-width: min(390px, 46vw);
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr);
  align-items: center;
  gap: 7px;
}

.server-switcher > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.server-switcher select {
  min-height: 40px;
  padding-right: 30px;
  color: var(--text);
  background-color: rgba(11, 25, 32, 0.92);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
}

.section-title {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 15px;
  min-width: 0;
}

.section-title.compact {
  align-items: center;
  margin-bottom: 11px;
}

.server-pill {
  min-width: 116px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(29, 162, 126, 0.27);
  border-radius: 999px;
  padding: 8px 13px;
  color: var(--text);
  background: rgba(29, 162, 126, 0.08);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.server-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(29, 162, 126, 0.11), 0 0 12px rgba(29, 162, 126, 0.7);
}

.auth-layout {
  min-height: calc(100vh - 82px);
  display: grid;
  place-items: start center;
  padding: 54px 16px;
}

.auth-panel {
  width: min(460px, 100%);
  position: relative;
  overflow: hidden;
}

.auth-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--blue), transparent);
  opacity: 0.8;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  padding: 18px clamp(16px, 3vw, 34px) 36px;
  max-width: 100%;
}

.layout.single-column {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  background: linear-gradient(180deg, rgba(14, 32, 40, 0.97), rgba(11, 25, 32, 0.98));
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow-soft);
  padding: 17px;
  min-width: 0;
}

.devices-panel {
  min-height: calc(100vh - 124px);
  min-width: 0;
  box-shadow: var(--shadow);
}

.side {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
  max-width: 100%;
}

.console-panel {
  grid-column: 1 / -1;
}

.console-filter-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.console-filter-label select {
  width: auto;
  min-height: 36px;
}

.live-console {
  min-height: 230px;
  max-height: 420px;
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid rgba(29, 162, 126, 0.24);
  border-radius: 9px;
  background: #050c0f;
  color: #ffd166;
  box-shadow: inset 0 1px 16px rgba(0, 0, 0, 0.42);
  font: 11px/1.55 "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  scrollbar-color: rgba(106, 158, 158, 0.5) #050c0f;
}

.console-line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  padding: 1px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.console-time {
  color: #bd8b4a;
  user-select: none;
}

.console-device { color: #72c7e8; }
.console-command { color: #ffd166; }
.console-sync { color: #74d7ad; }
.console-error { color: #ff7a7a; }
.console-empty { color: #bd8b4a; }

.button,
.tab {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 36px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(224, 237, 237, 0.035);
  color: var(--text);
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.button:hover,
.tab:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06110e;
  box-shadow: 0 6px 18px rgba(29, 162, 126, 0.17);
}

.button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 8px 24px rgba(29, 162, 126, 0.26);
}

.button.secondary:hover,
.tab:hover {
  border-color: var(--line-strong);
  background: var(--accent-soft);
  color: #f2ffff;
}

.button.danger {
  color: #fff3f3;
  border-color: rgba(224, 82, 82, 0.56);
  background: rgba(224, 82, 82, 0.16);
}

.button.danger:hover {
  border-color: var(--danger-strong);
  background: rgba(224, 82, 82, 0.27);
}

.button:focus-visible,
.tab:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.device-list,
.stack {
  display: grid;
  gap: 11px;
  min-width: 0;
}

.sync-layout {
  display: grid;
  gap: 17px;
}

.production-layout {
  display: grid;
  gap: 18px;
}

.production-section {
  display: grid;
  gap: 13px;
}

.production-section + .production-section {
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.production-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 9px;
}

.production-stat {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(7, 16, 20, 0.42);
}

.production-stat span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.production-stat strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font: 700 18px/1.1 "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

.production-forms > .form {
  min-width: 0;
}

.production-form-actions {
  justify-content: flex-start;
}

.production-table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 13, 16, 0.42);
}

.production-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  font-size: 11px;
}

.production-table th,
.production-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(224, 237, 237, 0.08);
  text-align: left;
  vertical-align: top;
}

.production-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #0b1a20;
  font-size: 10px;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.production-table tbody tr:last-child td {
  border-bottom: 0;
}

.production-table tbody tr:hover {
  background: rgba(29, 162, 126, 0.055);
}

.registry-id {
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 650;
  white-space: nowrap;
}

.registry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 230px;
}

.registry-actions .button {
  min-height: 31px;
  padding: 5px 8px;
  font-size: 10px;
}

.pairing-downloads {
  justify-content: center;
}

.muted {
  color: var(--muted);
  font-size: 11px;
}

.sync-section {
  display: grid;
  gap: 12px;
}

.sync-section + .sync-section {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.sync-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 16, 20, 0.34);
}

.sync-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1.4fr) minmax(180px, 0.8fr) auto;
  align-items: center;
  gap: 12px;
}

.sync-node-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  color: rgba(224, 237, 237, 0.68);
  overflow-wrap: anywhere;
}

.sync-node-title,
.version-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sync-node-title strong,
.version-line strong {
  display: inline;
  margin: 0;
}

.sync-node-title strong {
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
}

.node-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 21px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.node-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.node-status.online,
.node-dot.online {
  color: var(--ok);
}

.node-status.online {
  background: rgba(54, 201, 143, 0.08);
}

.node-status.offline,
.node-dot.offline {
  color: var(--danger-strong);
}

.node-status.offline {
  background: rgba(224, 82, 82, 0.08);
}

.version-line {
  margin-top: 5px;
  color: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
}

.version-ok { color: var(--ok); }
.version-bad { color: #ff7474; }

.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 7px 12px;
  margin-top: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.43);
  color: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
}

.resource-metric {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
}

.resource-metric strong {
  display: inline;
  margin: 0;
  font-size: 12px;
}

.resource-metric small {
  flex-basis: 100%;
  color: rgba(131, 170, 170, 0.76);
  font-size: 9px;
}

.metric-cool { color: #4dc5ef; }
.metric-good { color: var(--ok); }
.metric-warn { color: #efae49; }
.metric-hot { color: #ff7474; }
.metric-na { color: var(--muted); }

.node-inventory {
  display: grid;
  gap: 5px;
  margin-top: 5px;
}

.node-inventory details {
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.node-inventory summary {
  width: fit-content;
  border-radius: 5px;
  cursor: pointer;
  color: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
}

.node-inventory summary:hover {
  color: var(--text);
}

.node-inventory summary strong {
  display: inline;
  margin: 0 0 0 4px;
  color: var(--text);
}

.inventory-list {
  display: grid;
  gap: 5px;
  padding: 8px 2px 2px;
}

.inventory-row {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
}

.inventory-row strong,
.inventory-row small {
  display: block;
  margin: 0;
}

.inventory-row small,
.inventory-empty {
  color: var(--muted);
  font-size: 10px;
}

.user-presence-meta {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.node-dot {
  width: 8px;
  height: 8px;
  margin-top: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.local-sync-row {
  border-color: rgba(29, 162, 126, 0.26);
  background: linear-gradient(90deg, rgba(29, 162, 126, 0.09), rgba(12, 28, 34, 0.72) 32%);
  box-shadow: inset 3px 0 0 var(--accent);
}

.status-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 14px;
}

.status-mark.ok {
  color: var(--ok);
  border-color: rgba(54, 201, 143, 0.36);
  background: rgba(54, 201, 143, 0.1);
  box-shadow: 0 0 16px rgba(54, 201, 143, 0.12);
}

.status-mark.danger {
  color: var(--danger-strong);
  border-color: rgba(224, 82, 82, 0.4);
  background: rgba(224, 82, 82, 0.1);
}

.sync-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.metrics-toggle {
  white-space: nowrap;
}

.metrics-panel {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  gap: 13px;
  margin-top: 5px;
  padding: clamp(12px, 2vw, 18px);
  border: 1px solid rgba(76, 222, 157, 0.18);
  border-radius: 11px;
  background:
    radial-gradient(circle at 78% -25%, rgba(58, 189, 137, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(7, 17, 24, 0.98), rgba(5, 13, 19, 0.98));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025), 0 12px 32px rgba(0, 0, 0, 0.22);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.metrics-panel-head,
.metrics-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.metrics-panel-head > div:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.metrics-panel-head strong {
  font-size: 14px;
}

.metrics-panel-head span,
.metrics-panel-foot {
  color: rgba(174, 210, 210, 0.68);
  font-size: 10px;
}

.metrics-ranges {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(224, 237, 237, 0.1);
  border-radius: 8px;
  background: rgba(4, 12, 17, 0.72);
}

.metrics-range {
  min-height: 31px;
  border: 0;
  border-radius: 6px;
  padding: 5px 10px;
  color: rgba(174, 210, 210, 0.68);
  background: transparent;
  cursor: pointer;
  font: 700 10px/1 Inter, ui-sans-serif, system-ui, sans-serif;
}

.metrics-range:hover {
  color: var(--text);
  background: rgba(224, 237, 237, 0.06);
}

.metrics-range[aria-pressed="true"] {
  color: #eafff7;
  background: rgba(29, 162, 126, 0.22);
  box-shadow: inset 0 0 0 1px rgba(54, 201, 143, 0.26);
}

.metrics-range:focus-visible,
.metric-switch input:focus-visible + .metric-switch-track,
.metrics-canvas:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.metric-switches {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 7px;
}

.metric-switch {
  --series-color: #4ade80;
  min-height: 38px;
  display: grid;
  grid-template-columns: 28px 7px auto auto;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid rgba(224, 237, 237, 0.1);
  border-radius: 8px;
  background: rgba(9, 22, 28, 0.74);
  cursor: pointer;
  color: rgba(224, 237, 237, 0.76);
  font-size: 10px;
  user-select: none;
}

.metric-series-cpu_percent { --series-color: #4ade80; }
.metric-series-memory_percent { --series-color: #38bdf8; }
.metric-series-network_bps { --series-color: #f5b74b; }
.metric-series-feeder_count { --series-color: #a78bfa; }
.metric-series-user_count { --series-color: #fb7185; }

.metric-switch:hover {
  border-color: color-mix(in srgb, var(--series-color) 35%, transparent);
  background: rgba(12, 29, 36, 0.86);
}

.metric-switch input {
  width: 1px;
  height: 1px;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.metric-switch-track {
  width: 28px;
  height: 16px;
  display: block;
  position: relative;
  border: 1px solid rgba(174, 210, 210, 0.3);
  border-radius: 999px;
  background: rgba(174, 210, 210, 0.13);
  transition: background 150ms ease, border-color 150ms ease;
}

.metric-switch-track > span {
  width: 10px;
  height: 10px;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: rgba(224, 237, 237, 0.56);
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.metric-switch input:checked + .metric-switch-track {
  border-color: color-mix(in srgb, var(--series-color) 60%, transparent);
  background: color-mix(in srgb, var(--series-color) 24%, transparent);
}

.metric-switch input:checked + .metric-switch-track > span {
  transform: translateX(12px);
  background: var(--series-color);
  box-shadow: 0 0 8px color-mix(in srgb, var(--series-color) 75%, transparent);
}

.metric-series-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--series-color);
  box-shadow: 0 0 7px color-mix(in srgb, var(--series-color) 60%, transparent);
}

.metric-switch-label {
  white-space: nowrap;
}

.metric-switch strong {
  margin-left: 2px;
  color: var(--series-color);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
  white-space: nowrap;
}

.metrics-chart-stage {
  min-height: 310px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(224, 237, 237, 0.075);
  border-radius: 9px;
  background:
    linear-gradient(rgba(185, 220, 220, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(185, 220, 220, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 72% 20%, rgba(54, 201, 143, 0.055), transparent 35%),
    #071219;
  background-size: 34px 34px, 34px 34px, auto, auto;
}

.metrics-canvas {
  width: 100%;
  height: 310px;
  display: block;
  cursor: crosshair;
  touch-action: pan-y;
}

.metrics-chart-empty {
  max-width: min(440px, calc(100% - 32px));
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 10px 14px;
  border: 1px solid rgba(224, 237, 237, 0.1);
  border-radius: 8px;
  background: rgba(6, 15, 20, 0.88);
  color: rgba(174, 210, 210, 0.74);
  font-size: 11px;
  text-align: center;
  pointer-events: none;
}

.metrics-status.error {
  color: #ff8686;
}

.metrics-scale-note {
  max-width: 620px;
  text-align: right;
}

.food-consumption-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(224, 237, 237, 0.1);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(10, 27, 34, 0.96), rgba(5, 15, 20, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.food-consumption-head,
.food-consumption-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.food-consumption-head > div:first-child {
  display: grid;
  gap: 3px;
}

.food-consumption-head strong {
  color: #eafff7;
  font-size: 13px;
}

.food-consumption-head span,
.food-consumption-foot {
  color: rgba(174, 210, 210, 0.66);
  font-size: 10px;
}

.food-consumption-ranges {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(224, 237, 237, 0.1);
  border-radius: 8px;
  background: rgba(4, 12, 17, 0.72);
}

.food-consumption-range {
  min-height: 31px;
  border: 0;
  border-radius: 6px;
  padding: 5px 10px;
  color: rgba(174, 210, 210, 0.68);
  background: transparent;
  cursor: pointer;
  font: 700 10px/1 Inter, ui-sans-serif, system-ui, sans-serif;
}

.food-consumption-range:hover {
  color: var(--text);
  background: rgba(224, 237, 237, 0.06);
}

.food-consumption-range[aria-pressed="true"] {
  color: #eafff7;
  background: rgba(29, 162, 126, 0.22);
  box-shadow: inset 0 0 0 1px rgba(54, 201, 143, 0.26);
}

.food-consumption-range:focus-visible,
.consumption-switch input:focus-visible + .consumption-switch-track,
.food-consumption-canvas:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.food-consumption-switches {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 7px;
}

.consumption-switch {
  --consumption-series-color: #4ade80;
  min-height: 38px;
  display: grid;
  grid-template-columns: 28px 7px auto auto;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid rgba(224, 237, 237, 0.1);
  border-radius: 8px;
  background: rgba(9, 22, 28, 0.74);
  color: rgba(224, 237, 237, 0.76);
  cursor: pointer;
  font-size: 10px;
  user-select: none;
}

.consumption-series-planned_gr { --consumption-series-color: #4ade80; }
.consumption-series-dispensed_gr { --consumption-series-color: #f5b74b; }
.consumption-series-consumed_estimated_gr { --consumption-series-color: #38bdf8; }

.consumption-switch:hover {
  border-color: color-mix(in srgb, var(--consumption-series-color) 35%, transparent);
  background: rgba(12, 29, 36, 0.86);
}

.consumption-switch input {
  width: 1px;
  height: 1px;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.consumption-switch-track {
  width: 28px;
  height: 16px;
  display: block;
  position: relative;
  border: 1px solid rgba(174, 210, 210, 0.3);
  border-radius: 999px;
  background: rgba(174, 210, 210, 0.13);
  transition: background 150ms ease, border-color 150ms ease;
}

.consumption-switch-track > span {
  width: 10px;
  height: 10px;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: rgba(224, 237, 237, 0.56);
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.consumption-switch input:checked + .consumption-switch-track {
  border-color: color-mix(in srgb, var(--consumption-series-color) 60%, transparent);
  background: color-mix(in srgb, var(--consumption-series-color) 24%, transparent);
}

.consumption-switch input:checked + .consumption-switch-track > span {
  transform: translateX(12px);
  background: var(--consumption-series-color);
  box-shadow: 0 0 8px color-mix(in srgb, var(--consumption-series-color) 75%, transparent);
}

.consumption-series-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--consumption-series-color);
  box-shadow: 0 0 7px color-mix(in srgb, var(--consumption-series-color) 60%, transparent);
}

.consumption-switch strong {
  margin-left: 2px;
  color: var(--consumption-series-color);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
  white-space: nowrap;
}

.food-consumption-chart-stage {
  min-height: 300px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(224, 237, 237, 0.075);
  border-radius: 9px;
  background:
    linear-gradient(rgba(185, 220, 220, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(185, 220, 220, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 72% 20%, rgba(54, 201, 143, 0.055), transparent 35%),
    #071219;
  background-size: 34px 34px, 34px 34px, auto, auto;
}

.food-consumption-canvas {
  width: 100%;
  height: 300px;
  display: block;
  cursor: crosshair;
  touch-action: pan-y;
}

.food-consumption-empty {
  max-width: min(440px, calc(100% - 32px));
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 10px 14px;
  border: 1px solid rgba(224, 237, 237, 0.1);
  border-radius: 8px;
  background: rgba(6, 15, 20, 0.88);
  color: rgba(174, 210, 210, 0.74);
  font-size: 11px;
  text-align: center;
  pointer-events: none;
}

.food-consumption-status.error {
  color: #ff8686;
}

.food-consumption-foot > span:last-child {
  max-width: 620px;
  text-align: right;
}

.device-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(14, 32, 40, 0.78), rgba(9, 22, 27, 0.84));
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.14);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.device-card:hover {
  border-color: rgba(29, 162, 126, 0.28);
  box-shadow: 0 11px 28px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.device-head {
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.device-name {
  font-weight: 720;
  font-size: 17px;
  letter-spacing: -0.012em;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(224, 237, 237, 0.035);
}

.badge.ok {
  color: var(--ok);
  border-color: rgba(54, 201, 143, 0.3);
  background: rgba(54, 201, 143, 0.09);
}

.badge.warn {
  color: var(--warn);
  border-color: rgba(228, 165, 65, 0.3);
  background: rgba(228, 165, 65, 0.09);
}

.badge.danger {
  color: var(--danger-strong);
  border-color: rgba(224, 82, 82, 0.32);
  background: rgba(224, 82, 82, 0.09);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.meta {
  min-height: 56px;
  padding: 9px 10px;
  border: 1px solid rgba(224, 237, 237, 0.09);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.36);
}

.meta span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.035em;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.meta strong {
  display: block;
  font-size: 12px;
  font-weight: 630;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.device-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 136px;
}

.form {
  display: grid;
  gap: 10px;
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 39px;
  border-radius: 8px;
  border: 1px solid rgba(224, 237, 237, 0.14);
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: rgba(5, 13, 16, 0.7);
  caret-color: var(--accent-strong);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(224, 237, 237, 0.23);
}

input:focus,
select:focus,
textarea:focus {
  background: rgba(5, 13, 16, 0.92);
}

input::placeholder,
textarea::placeholder {
  color: rgba(131, 170, 170, 0.52);
}

select option {
  color: var(--text);
  background: var(--panel-raised);
}

textarea {
  min-height: 150px;
  resize: vertical;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px;
  font-size: 12px;
  line-height: 1.45;
  background: rgba(7, 16, 20, 0.38);
  min-width: 0;
  overflow-wrap: anywhere;
}

.item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.empty {
  border: 1px dashed rgba(131, 170, 170, 0.34);
  border-radius: 10px;
  padding: 34px 28px;
  text-align: center;
  color: var(--muted);
  background: rgba(7, 16, 20, 0.3);
}

dialog {
  color: var(--text);
  border: 1px solid rgba(224, 237, 237, 0.14);
  border-radius: 13px;
  padding: 0;
  background: linear-gradient(180deg, #0e2028, #0a171c);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.65);
}

dialog::backdrop {
  background: rgba(2, 7, 9, 0.76);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

dialog[open] {
  animation: dialog-in 150ms ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dialog-form {
  min-width: min(440px, calc(100vw - 32px));
  padding: 19px;
  display: grid;
  gap: 15px;
}

.large-dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.pairing-qr-dialog {
  width: min(460px, calc(100vw - 32px));
}

.pairing-qr-preview {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.pairing-qr-preview img {
  width: min(360px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
  border: 8px solid #ffffff;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
}

.dialog-head {
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 3px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-view-tabs {
  margin-bottom: 15px;
  padding: 4px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(224, 237, 237, 0.08);
  border-radius: 10px;
  background: rgba(5, 13, 16, 0.42);
}

.admin-search-tools {
  max-width: 680px;
  margin: -2px 0 15px;
}

.admin-search-field {
  width: min(100%, 560px);
  min-height: 43px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid rgba(224, 237, 237, 0.12);
  border-radius: 10px;
  background: rgba(5, 13, 16, 0.64);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.018);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.admin-search-field:focus-within {
  border-color: rgba(29, 162, 126, 0.72);
  background: rgba(5, 13, 16, 0.92);
  box-shadow: var(--focus);
}

.admin-search-field input {
  min-height: 41px;
  padding: 8px 48px 8px 39px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.admin-search-field input:focus {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.search-icon {
  width: 14px;
  height: 14px;
  position: absolute;
  left: 14px;
  border: 2px solid rgba(131, 170, 170, 0.72);
  border-radius: 50%;
  pointer-events: none;
}

.search-icon::after {
  content: "";
  width: 6px;
  height: 2px;
  position: absolute;
  right: -5px;
  bottom: -3px;
  border-radius: 2px;
  background: rgba(131, 170, 170, 0.72);
  transform: rotate(45deg);
}

.search-count {
  position: absolute;
  right: 12px;
  color: rgba(131, 170, 170, 0.72);
  font: 10px/1.2 "JetBrains Mono", ui-monospace, monospace;
  pointer-events: none;
}

.tab.active {
  border-color: rgba(29, 162, 126, 0.5);
  color: #eefffa;
  background: rgba(29, 162, 126, 0.2);
  box-shadow: inset 0 0 0 1px rgba(29, 162, 126, 0.07), 0 5px 18px rgba(0, 0, 0, 0.16);
}

.user-card {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 16, 20, 0.38);
}

.user-card-identity,
.user-dialog-identity,
.assigned-device-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.user-avatar {
  width: 46px;
  height: 46px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(29, 162, 126, 0.42);
  border-radius: 13px;
  color: #eafff9;
  background: linear-gradient(145deg, rgba(29, 162, 126, 0.3), rgba(34, 211, 238, 0.11));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.22);
  font-size: 14px;
  font-weight: 760;
  letter-spacing: 0.04em;
}

.user-avatar.small {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 11px;
}

.role-badge {
  text-transform: none;
}

.role-owner {
  color: #ffd88a;
  border-color: rgba(245, 183, 75, 0.42);
  background: rgba(245, 183, 75, 0.1);
}

.role-admin {
  color: #8ce7ca;
  border-color: rgba(29, 162, 126, 0.44);
}

.user-dialog-shell {
  width: min(1100px, calc(100vw - 26px));
  max-width: none;
}

.user-dialog {
  width: 100%;
  min-width: 0;
  max-height: calc(100vh - 30px);
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.user-dialog-head {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 35, 42, 0.98), rgba(11, 27, 33, 0.92));
}

.user-dialog-head h3 {
  margin-top: 2px;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--accent-strong);
  font-size: 9px;
  font-weight: 760;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.owner-protection {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 14px 22px 0;
  padding: 11px 13px;
  border: 1px solid rgba(245, 183, 75, 0.34);
  border-radius: 9px;
  color: #f4d999;
  background: rgba(245, 183, 75, 0.075);
  font-size: 11px;
  line-height: 1.45;
}

.owner-protection strong {
  flex: 0 0 auto;
  color: #ffe2a2;
}

.owner-protection span {
  color: rgba(244, 217, 153, 0.8);
}

.user-settings-tabs {
  padding: 14px 22px 0;
  border-bottom: 1px solid var(--line);
  gap: 3px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.user-settings-tabs .tab {
  min-height: 38px;
  border-color: transparent;
  border-radius: 7px 7px 0 0;
  color: var(--muted);
  white-space: nowrap;
  background: transparent;
  box-shadow: none;
}

.user-settings-tabs .tab.active {
  border-color: var(--line) var(--line) transparent;
  color: var(--text);
  background: rgba(29, 162, 126, 0.1);
  box-shadow: inset 0 -2px var(--accent);
}

.user-settings-tabs .danger-tab {
  color: rgba(240, 100, 100, 0.82);
}

.user-dialog-body {
  min-height: 370px;
  max-height: calc(100vh - 230px);
  padding: 20px 22px 24px;
  overflow: auto;
  background:
    radial-gradient(circle at 90% -20%, rgba(29, 162, 126, 0.09), transparent 35%),
    rgba(6, 15, 19, 0.28);
}

.user-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 15px;
}

.user-stat {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 16, 20, 0.48);
}

.user-stat span {
  color: var(--muted);
  font-size: 10px;
}

.user-stat strong {
  font-size: 16px;
}

.status-banned,
.status-deleted,
.status-disabled {
  color: var(--danger-strong);
}

.status-active {
  color: var(--ok);
}

.user-settings-section,
.danger-zone {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(7, 16, 20, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.016);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h3 {
  margin-bottom: 3px;
  font-size: 14px;
}

.compact-fields input[readonly],
.compact-fields input:disabled {
  color: rgba(224, 237, 237, 0.72);
  background: rgba(5, 13, 16, 0.38);
}

.mono,
.assigned-device code,
.permission-copy code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.user-access-form,
.permission-section,
.permission-list,
.security-grid,
.assigned-device-list,
.audit-timeline {
  display: grid;
  gap: 12px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.role-choice {
  min-height: 72px;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: rgba(5, 13, 16, 0.44);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.role-choice:hover,
.role-choice.selected {
  border-color: rgba(29, 162, 126, 0.42);
  background: rgba(29, 162, 126, 0.08);
}

.role-choice.disabled {
  cursor: default;
  opacity: 0.66;
}

.role-choice input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.role-choice span,
.role-choice strong,
.role-choice small {
  display: block;
}

.role-choice small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.35;
}

.permission-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 13, 16, 0.34);
}

.permission-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 32, 40, 0.54);
}

.permission-group-head h3 {
  font-size: 12px;
}

.permission-group-head span {
  color: var(--muted);
  font-size: 9px;
}

.permission-list {
  gap: 0;
}

.permission-row {
  min-height: 70px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 13px;
  border-bottom: 1px solid rgba(224, 237, 237, 0.075);
}

.permission-row:last-child {
  border-bottom: 0;
}

.permission-copy {
  display: grid;
  gap: 3px;
}

.permission-copy strong {
  font-size: 12px;
}

.permission-copy span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.permission-copy code {
  width: fit-content;
  color: rgba(131, 170, 170, 0.64);
  font-size: 9px;
}

.permission-control {
  min-width: 144px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: end;
  gap: 5px 10px;
}

.permission-source {
  color: var(--muted);
  font-size: 9px;
}

.permission-source.custom {
  color: var(--accent-strong);
}

.permission-switch {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
}

.permission-reset {
  grid-column: 1 / -1;
  appearance: none;
  padding: 0;
  border: 0;
  color: rgba(131, 170, 170, 0.78);
  background: transparent;
  font: inherit;
  font-size: 9px;
  text-decoration: underline;
  cursor: pointer;
}

.sticky-save {
  position: sticky;
  bottom: -24px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -22px -24px;
  padding: 12px 22px;
  border-top: 1px solid rgba(29, 162, 126, 0.24);
  background: rgba(7, 16, 20, 0.94);
  box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.sticky-save span {
  color: var(--muted);
  font-size: 10px;
}

.security-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.session-section {
  grid-column: 1 / -1;
}

.security-status {
  display: flex;
  gap: 10px;
  margin-bottom: 13px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.security-status.is-safe {
  border-color: rgba(54, 201, 143, 0.27);
  background: rgba(54, 201, 143, 0.065);
}

.security-status.is-banned {
  border-color: rgba(224, 82, 82, 0.35);
  background: rgba(224, 82, 82, 0.08);
}

.security-status-icon {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(54, 201, 143, 0.11);
}

.is-banned .security-status-icon {
  background: var(--danger-strong);
  box-shadow: 0 0 0 4px rgba(224, 82, 82, 0.12);
}

.compact-form textarea {
  min-height: 78px;
}

.field-status {
  min-height: 15px;
  color: var(--danger-strong);
  font-size: 10px;
}

.permission-note,
.login-lock-note {
  display: grid;
  gap: 3px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(5, 13, 16, 0.42);
  font-size: 11px;
  line-height: 1.45;
}

.login-lock-note {
  border-color: rgba(245, 183, 75, 0.28);
  color: #e7c77f;
}

.count-pill {
  min-width: 27px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
  font-size: 10px;
}

.assigned-device {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(5, 13, 16, 0.44);
}

.assigned-device-main code {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.device-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.device-dot.online {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(54, 201, 143, 0.55);
}

.subtle-danger {
  min-height: 31px;
  padding: 6px 9px;
  font-size: 10px;
}

.assign-device-section {
  margin-top: 12px;
}

.assign-device-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) 150px auto;
  align-items: end;
  gap: 9px;
}

.compact-search {
  width: 100%;
}

.ownership-warning {
  margin-top: 9px;
}

.compact-empty {
  padding: 22px 18px;
}

.audit-event {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
}

.audit-marker {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(29, 162, 126, 0.08);
}

.audit-event strong {
  font-size: 12px;
}

.audit-event small {
  color: rgba(131, 170, 170, 0.7);
  font-size: 9px;
}

.danger-zone {
  border-color: rgba(224, 82, 82, 0.28);
  background: rgba(61, 18, 22, 0.16);
}

.danger-zone > .owner-protection {
  margin: 0;
}

.danger-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-top: 1px solid rgba(224, 82, 82, 0.16);
}

.danger-action strong {
  font-size: 12px;
}

.permission-empty {
  display: grid;
  gap: 6px;
}

.permission-empty strong {
  color: var(--text);
}

.permission-empty span {
  font-size: 11px;
}

.user-head,
.mini-device,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-head,
.mini-device {
  justify-content: space-between;
}

.mini-device {
  flex-wrap: wrap;
}

.inline-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 13px;
}

.two-col > .form {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(7, 16, 20, 0.34);
  align-content: start;
}

.pre {
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #061015;
  color: rgba(224, 237, 237, 0.88);
  font: 12px/1.5 "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(29, 162, 126, 0.42);
  border-radius: 9px;
  background: rgba(11, 25, 32, 0.96);
  color: #f2fffb;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  z-index: 5;
  font-size: 13px;
}

.toast.error {
  border-color: rgba(224, 82, 82, 0.55);
  background: rgba(94, 28, 31, 0.97);
}

@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .device-card {
    grid-template-columns: 1fr;
  }

  .device-actions {
    flex-direction: row;
    width: auto;
    flex-wrap: wrap;
  }

  .user-head,
  .mini-device {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-actions {
    justify-content: flex-start;
  }

  .role-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .assign-device-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .topbar,
  .section-title,
  .dialog-head {
    align-items: stretch;
    flex-direction: column;
  }

  #server-subtitle {
    max-width: calc(100vw - 32px);
  }

  .top-actions,
  .toolbar {
    justify-content: flex-start;
  }

  .server-switcher {
    width: 100%;
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .server-switcher select,
  .button,
  .tab,
  input,
  select {
    min-height: 44px;
  }

  .server-pill {
    width: fit-content;
  }

  .meta-grid,
  .two-col,
  .production-summary,
  .sync-form,
  .sync-row,
  .resource-grid {
    grid-template-columns: 1fr;
  }

  .status-mark {
    justify-self: start;
  }

  .metrics-panel {
    grid-column: 1;
    padding: 11px;
  }

  .metrics-panel-head,
  .metrics-panel-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics-ranges {
    width: 100%;
  }

  .metrics-range {
    min-height: 44px;
    flex: 1 1 auto;
    padding-inline: 6px;
  }

  .metric-switch {
    min-height: 44px;
    flex: 1 1 min(100%, 210px);
  }

  .metrics-chart-stage {
    min-height: 260px;
  }

  .metrics-canvas {
    height: 260px;
  }

  .metrics-scale-note {
    text-align: left;
  }

  .food-consumption-panel {
    padding: 11px;
  }

  .food-consumption-head,
  .food-consumption-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .food-consumption-ranges {
    width: 100%;
  }

  .food-consumption-range {
    min-height: 44px;
    flex: 1 1 auto;
    padding-inline: 5px;
  }

  .consumption-switch {
    min-height: 44px;
    flex: 1 1 min(100%, 210px);
  }

  .food-consumption-chart-stage {
    min-height: 260px;
  }

  .food-consumption-canvas {
    height: 260px;
  }

  .food-consumption-foot > span:last-child {
    text-align: left;
  }

  .console-line {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .admin-view-tabs {
    width: 100%;
  }

  .admin-view-tabs .tab {
    flex: 1 1 auto;
  }

  .user-dialog-shell {
    width: calc(100vw - 12px);
    margin: 6px;
  }

  .user-dialog {
    max-height: calc(100vh - 12px);
  }

  .user-dialog-head,
  .user-dialog-body {
    padding-inline: 14px;
  }

  .owner-protection {
    margin-inline: 14px;
    flex-direction: column;
  }

  .user-settings-tabs {
    padding-inline: 14px;
  }

  .user-dialog-body {
    max-height: calc(100vh - 240px);
  }

  .user-overview-grid,
  .security-grid,
  .role-grid,
  .assign-device-form {
    grid-template-columns: 1fr;
  }

  .session-section {
    grid-column: auto;
  }

  .permission-row,
  .assigned-device {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .permission-control {
    width: 100%;
    justify-items: start;
    grid-template-columns: auto auto;
  }

  .permission-reset {
    grid-column: auto;
  }

  .sticky-save {
    bottom: -24px;
    align-items: stretch;
    flex-direction: column;
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .danger-action,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .production-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .production-table {
    min-width: 0;
    display: block;
  }

  .production-table thead {
    display: none;
  }

  .production-table tbody {
    display: grid;
    gap: 12px;
  }

  .production-table tbody tr {
    display: grid;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(7, 16, 20, 0.52);
    box-shadow: var(--shadow-soft);
  }

  .production-table tbody td {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(94px, 34%) minmax(0, 1fr);
    gap: 10px;
    padding: 9px 0;
    overflow-wrap: anywhere;
  }

  .production-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.035em;
    text-transform: uppercase;
  }

  .production-table .registry-id {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .production-table .registry-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .production-table .registry-actions .button {
    min-height: 44px;
    width: 100%;
  }

  .production-table .production-empty-row td {
    display: block;
    padding: 0;
  }

  .production-table .production-empty-row td::before {
    content: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .button:hover,
  .tab:hover,
  .device-card:hover {
    transform: none;
  }
}
