:root {
  color-scheme: dark;
  --font-sans: "Manrope", "Inter", "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --bg: #0b0f0f;
  --surface: rgba(20, 25, 25, .92);
  --surface-2: rgba(28, 35, 35, .92);
  --surface-3: rgba(9, 13, 13, .96);
  --surface-raised: rgba(24, 31, 31, .96);
  --field: rgba(7, 11, 12, .92);
  --line: rgba(99, 119, 119, .25);
  --line-strong: rgba(135, 156, 154, .36);
  --text: #eef5f2;
  --muted: #9dafac;
  --soft: #c9d8d4;
  --green: #48c78e;
  --blue: #63a8ff;
  --yellow: #edc768;
  --red: #ff7777;
  --teal: #55d8c6;
  --shadow: 0 22px 58px rgba(0, 0, 0, .33);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, .18);
  --focus: rgba(85,216,198,.18);
  --success-soft: rgba(72,199,142,.12);
  --danger-soft: rgba(255,116,116,.12);
  --panel-topline: rgba(255, 255, 255, .07);
  --app-bg:
    linear-gradient(135deg, rgba(72, 199, 142, .09) 0%, transparent 28%),
    linear-gradient(225deg, rgba(99, 168, 255, .07) 0%, transparent 31%),
    linear-gradient(180deg, #0b0f0f 0%, #111715 48%, #0b0f0f 100%);
  --grid-color: rgba(209, 232, 224, .035);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f1;
  --surface: rgba(255, 255, 255, .94);
  --surface-2: rgba(236, 243, 240, .95);
  --surface-3: rgba(247, 250, 248, .96);
  --surface-raised: rgba(255, 255, 255, .98);
  --field: rgba(255, 255, 255, .96);
  --line: rgba(111, 132, 132, .25);
  --line-strong: rgba(83, 105, 105, .34);
  --text: #16221f;
  --muted: #62736f;
  --soft: #31443f;
  --green: #128a5c;
  --blue: #276ce3;
  --yellow: #98660a;
  --red: #c83d3d;
  --teal: #087f77;
  --shadow: 0 22px 52px rgba(28, 55, 52, .13);
  --shadow-soft: 0 12px 28px rgba(28, 55, 52, .08);
  --focus: rgba(8,127,119,.16);
  --success-soft: rgba(20,151,101,.09);
  --danger-soft: rgba(206,61,61,.09);
  --panel-topline: rgba(255, 255, 255, .92);
  --app-bg:
    linear-gradient(135deg, rgba(18, 138, 92, .10) 0%, transparent 32%),
    linear-gradient(225deg, rgba(39, 108, 227, .08) 0%, transparent 34%),
    linear-gradient(180deg, #f5f8f6 0%, #eef3f1 48%, #f7faf8 100%);
  --grid-color: rgba(32, 65, 61, .045);
}

* { box-sizing: border-box; }
/* clip, not hidden: hidden on body makes it a scroll container that never
   scrolls, and position: sticky (the side rail) then never sticks. */
html { min-width: 0; overflow-x: hidden; overflow-x: clip; }
html, body { scrollbar-color: var(--line-strong) transparent; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  background:
    repeating-linear-gradient(90deg, var(--grid-color) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(0deg, var(--grid-color) 0 1px, transparent 1px 56px),
    var(--app-bg);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    linear-gradient(120deg, transparent 0 18%, rgba(85, 216, 198, .055) 18% 19%, transparent 19% 100%),
    linear-gradient(300deg, transparent 0 45%, rgba(237, 199, 104, .045) 45% 46%, transparent 46% 100%);
  mix-blend-mode: screen;
}
:root[data-theme="light"] body::after {
  mix-blend-mode: multiply;
  opacity: .55;
}
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font-sans);
  letter-spacing: 0;
  font-feature-settings: "cv02", "cv03", "cv04", "liga";
  text-rendering: geometricPrecision;
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  transform: translateY(-160%);
  clip-path: inset(50%);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.skip-link:focus { transform: translateY(0); clip-path: none; }
:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

button, input, textarea, select, .button { font: inherit; }
button, .button {
  border: 1px solid var(--line);
  background-color: var(--surface-2);
  background-image: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,0));
  color: var(--text);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: 0 1px 0 var(--panel-topline) inset;
  transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
button:hover, .button:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--surface-2) 82%, var(--text));
  transform: translateY(-1px);
}
button:active, .button:active { transform: translateY(0); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.is-busy::after {
  content: '';
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: action-spin .7s linear infinite;
}
@keyframes action-spin { to { transform: rotate(360deg); } }
button.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--green) 86%, white), var(--green));
  color: #04100b;
  border-color: color-mix(in srgb, var(--green) 82%, white);
  font-weight: 760;
  box-shadow: 0 1px 0 rgba(255,255,255,.28) inset, 0 10px 22px color-mix(in srgb, var(--green) 18%, transparent);
}
button.primary:hover { filter: brightness(1.06); }
button.ghost { background: transparent; }
button.danger, button.danger-lite { border-color: rgba(255,116,116,.55); color: #ffd2d2; }
button.danger { background: var(--danger-soft); }
:root[data-theme="light"] button.primary { color: #fff; }
:root[data-theme="light"] button.danger,
:root[data-theme="light"] button.danger-lite { color: #8f2424; }
:root[data-theme="light"] body::before { opacity: 1; }
:root[data-theme="light"] button:hover,
:root[data-theme="light"] .button:hover {
  background: color-mix(in srgb, var(--surface-2) 78%, var(--text));
}
.wide { width: 100%; }
.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.i {
  width: 18px;
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  line-height: 1;
}
.icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}
.i-fallback { font-size: 14px; line-height: 1; }
.icon-only {
  width: 36px;
  min-width: 36px;
  padding: 0;
}
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: calc(100% + 9px);
  translate: -50% 0;
  z-index: 30;
  max-width: 220px;
  width: max-content;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--surface-raised) 96%, black);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity .14s ease, transform .14s ease;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  box-shadow: 0 1px 0 var(--panel-topline) inset;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus); }
textarea {
  resize: none;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
textarea::-webkit-scrollbar { width: 8px; }
textarea::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
textarea::-webkit-scrollbar-track { background: transparent; }
textarea::-webkit-resizer { display: none; }
label { display: grid; gap: 7px; color: var(--muted); min-width: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 34px; line-height: 1.05; }
h2 { font-size: 25px; line-height: 1.18; }
h3 { font-size: 17px; line-height: 1.25; }
small { color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 20px; }
.local-error {
  width: 100%;
  margin: 10px 0 0;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--red) 50%, var(--line));
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.eyebrow { color: var(--teal); text-transform: uppercase; font-size: 12px; font-weight: 760; }
.product-credit,
.app-credit {
  color: color-mix(in srgb, var(--muted) 82%, var(--text));
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}
.product-credit {
  margin: -4px 0 0;
  text-align: center;
}
.app-credit {
  padding: 4px 2px 0;
  text-align: right;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background-color: var(--surface);
  background-image: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,0));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%);
}
.login-mark, .brand-mark {
  position: relative;
  overflow: hidden;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: #03110d;
  background:
    linear-gradient(135deg, rgba(255,255,255,.38), transparent 31%),
    linear-gradient(135deg, #5ee8a5, #24c59a 50%, #7adce3);
  font-weight: 900;
  letter-spacing: .02em;
  box-shadow: 0 12px 28px rgba(37, 181, 143, .25);
}
.login-mark::after, .brand-mark::after {
  content: "";
  position: absolute;
  width: 140%;
  height: 2px;
  background: rgba(3, 17, 13, .32);
  transform: rotate(-35deg);
  pointer-events: none;
}
.brand-mark { width: 36px; height: 36px; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
}
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-3) 92%, var(--green)) 0%, var(--surface-3) 42%),
    var(--surface-3);
  padding: 16px 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  box-shadow: 1px 0 0 rgba(255,255,255,.03) inset;
  backdrop-filter: blur(18px) saturate(130%);
}
.brand { display: grid; justify-items: center; gap: 8px; min-width: 0; }
.brand strong { font-size: 17px; display: block; }
.brand span { color: var(--muted); font-size: 12px; display: block; overflow-wrap: anywhere; }
.brand > div:last-child { display: none; }
#logout,
.side #logout {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  justify-self: center;
  align-self: end;
  padding: 0;
  font-size: 0;
  border-radius: var(--radius-sm);
  flex: 0 0 40px;
}
.side #logout .i { margin: 0; }
.side nav { display: grid; align-content: start; gap: 8px; }
.side nav { display: none; }
.side nav button {
  position: relative;
  justify-content: flex-start;
  color: var(--soft);
  min-height: 38px;
  background: color-mix(in srgb, var(--surface-2) 74%, transparent);
}
.side nav button::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 99px;
  background: transparent;
}
.side nav button.active {
  border-color: color-mix(in srgb, var(--green) 72%, transparent);
  color: var(--green);
  background: linear-gradient(90deg, var(--success-soft), color-mix(in srgb, var(--success-soft) 55%, transparent));
}
.side nav button.active::before { background: var(--green); }

.content {
  min-width: 0;
  padding: 24px 28px;
  display: grid;
  gap: 18px;
  align-content: start;
}
.topbar {
  /* Scrolls with the page; only the side rail and the route tabs stick. */
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  margin: -12px -12px 0;
  min-width: 0;
  max-width: 100%;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px) saturate(140%);
}
.topbar > div:first-child {
  min-width: 220px;
}
.degradation-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--red) 55%, var(--line));
  border-radius: var(--radius-md);
  color: var(--text);
  background: color-mix(in srgb, var(--danger-soft) 82%, var(--surface));
  box-shadow: var(--shadow-soft);
}
.degradation-banner.is-unknown {
  border-color: color-mix(in srgb, var(--yellow) 55%, var(--line));
  background: color-mix(in srgb, var(--yellow) 10%, var(--surface));
}
.degradation-banner__icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--red);
  background: color-mix(in srgb, var(--red) 14%, transparent);
  font-weight: 850;
}
.degradation-banner p { margin-top: 3px; color: var(--muted); }
.top-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-raised) 82%, transparent);
  box-shadow: 0 1px 0 var(--panel-topline) inset;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
}
.top-nav button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  flex: 0 0 auto;
  scroll-snap-align: center;
}
.top-nav button:hover {
  color: var(--text);
  background: var(--surface-2);
}
.top-nav button.active {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 45%, transparent);
  background: var(--success-soft);
  box-shadow: 0 1px 0 var(--panel-topline) inset, 0 8px 20px color-mix(in srgb, var(--green) 12%, transparent);
}
.top-nav [data-tooltip]::after {
  top: calc(100% + 11px);
}
.top-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-raised) 86%, transparent);
  box-shadow: 0 1px 0 var(--panel-topline) inset;
}
.language-picker {
  position: relative;
  display: inline-grid;
  grid-template-columns: 18px minmax(82px, auto) 14px;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,0)),
    color-mix(in srgb, var(--field) 78%, var(--surface-2));
  box-shadow: 0 1px 0 var(--panel-topline) inset;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.language-picker:hover {
  border-color: var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,0)),
    color-mix(in srgb, var(--surface-2) 84%, var(--text));
}
.language-picker:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus), 0 1px 0 var(--panel-topline) inset;
}
.language-picker__icon {
  position: relative;
  width: 16px;
  height: 16px;
  border: 1.7px solid currentColor;
  border-radius: 50%;
  color: var(--teal);
  opacity: .95;
}
.language-picker__icon::before,
.language-picker__icon::after {
  content: "";
  position: absolute;
  inset: 3px auto 3px 50%;
  width: 5px;
  border: 1.4px solid currentColor;
  border-top: 0;
  border-bottom: 0;
  border-radius: 50%;
  translate: -50% 0;
}
.language-picker__icon::after {
  inset: 50% 2px auto;
  width: auto;
  height: 0;
  border: 0;
  border-top: 1.4px solid currentColor;
  translate: 0 -50%;
}
.language-picker__arrow {
  width: 7px;
  height: 7px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  rotate: 45deg;
  translate: 0 -2px;
  color: var(--muted);
  pointer-events: none;
}
.control-select {
  width: auto;
  min-height: 32px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font-weight: 760;
}
.control-select:focus {
  box-shadow: none;
  border-color: transparent;
}
.control-select option {
  color: var(--text);
  background: var(--surface-raised);
}
.icon-button {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}
.actions button,
.actions .button {
  min-width: 0;
}
.view { display: none; gap: 18px; }
.view.active { display: grid; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.metrics article, .panel, .user-card {
  background-color: var(--surface);
  background-image: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft), 0 1px 0 var(--panel-topline) inset;
  backdrop-filter: blur(12px) saturate(128%);
}
.metrics article {
  position: relative;
  padding: 16px;
  display: grid;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}
.metrics article::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--green), transparent 62%);
  opacity: .62;
}
.metrics span { color: var(--muted); }
.metrics strong { font-size: clamp(22px, 2vw, 30px); overflow-wrap: anywhere; }
.panel { padding: 16px; display: grid; gap: 14px; min-width: 0; }
.panel.warning {
  border-color: color-mix(in srgb, var(--yellow) 48%, var(--line));
  color: color-mix(in srgb, var(--yellow) 78%, var(--text));
  background-color: var(--surface);
  background-image: linear-gradient(90deg, rgba(237, 199, 104, .12), transparent 70%);
}
.hero-panel {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.panel-head > div { min-width: 0; }
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 18px;
}
.chart-panel canvas {
  width: 100%;
  height: 260px;
  max-height: 260px;
  display: block;
  background-color: var(--field);
  background-image:
    linear-gradient(180deg, rgba(72, 199, 142, .055), rgba(255,255,255,0)),
    repeating-linear-gradient(90deg, var(--grid-color) 0 1px, transparent 1px 44px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 var(--panel-topline) inset;
}
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 99px; display: inline-block; margin-right: 6px; }
.dot.in { background: var(--green); }
.dot.out { background: var(--blue); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  align-content: flex-start;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: color-mix(in srgb, var(--field) 90%, var(--surface-2));
  color: var(--soft);
  flex: 0 0 auto;
  max-width: 100%;
  height: auto;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.route-list, .traffic-detail, .traffic-users, .configs-grid, .route-editor { display: grid; gap: 10px; }
.route-row, .traffic-row, .config-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background-color: var(--field);
  background-image: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0));
  min-width: 0;
  box-shadow: 0 1px 0 var(--panel-topline) inset;
}
.route-row:hover, .traffic-row:hover, .config-card:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--field) 88%, var(--surface-2));
}
.route-row { grid-template-columns: 170px minmax(0, 1fr) 150px 170px; align-items: center; }
.traffic-row { grid-template-columns: 210px repeat(4, minmax(100px, 1fr)); align-items: center; }
.route-row strong, .traffic-row strong { color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.route-row span, .traffic-row span { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.attribution { color: var(--yellow) !important; font-size: 12px; }
.configs-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.config-card strong { font-size: 20px; overflow-wrap: anywhere; }

.profile-hero {
  border-color: color-mix(in srgb, var(--green) 22%, var(--line));
}
.profile-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.profile-summary span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--field);
}
.profile-summary strong { color: var(--text); }
.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .82fr);
  gap: 24px;
  align-items: start;
}
.profile-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-soft), 0 1px 0 var(--panel-topline) inset;
  backdrop-filter: blur(12px) saturate(128%);
  min-width: 0;
}
.profile-list, .check-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.profile-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  box-shadow: 0 1px 0 var(--panel-topline) inset;
}
.profile-card.active {
  border-color: color-mix(in srgb, var(--green) 46%, var(--line));
  background: color-mix(in srgb, var(--green) 9%, var(--field));
}
.profile-card.health-degraded,
.profile-card.health-unknown,
.profile-card.health-stale { border-color: color-mix(in srgb, var(--yellow) 48%, var(--line)); }
.profile-card.health-unhealthy { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); }
.health-badge.healthy, .transport-state.healthy { color: var(--green); }
.health-badge.degraded, .health-badge.unknown, .health-badge.stale, .transport-state.missing { color: var(--yellow); }
.health-badge.unhealthy { color: var(--red); }
.profile-card-main {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.profile-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--green);
  background: var(--success-soft);
  box-shadow: 0 1px 0 var(--panel-topline) inset;
}
.profile-title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.profile-title-line h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.profile-card p {
  color: var(--soft);
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}
.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.profile-meta span {
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  font-size: 12px;
  font-weight: 700;
}
.profile-risk {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted) !important;
}
.check-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
}
.check-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 16%, transparent);
}
.check-row.ok .check-dot { background: var(--green); box-shadow: 0 0 0 4px var(--success-soft); }
.check-row.warn .check-dot { background: var(--yellow); box-shadow: 0 0 0 4px color-mix(in srgb, var(--yellow) 16%, transparent); }
.check-row.reserved .check-dot { background: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 14%, transparent); }
.check-row strong { overflow-wrap: anywhere; }

#routes > .panel {
  background: transparent;
  background-image: none;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
}
#routes > .hero-panel {
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.route-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  background:
    linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 88%, transparent));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(130%);
}
.route-tabs button {
  min-height: 34px;
  padding: 7px 12px;
  color: var(--soft);
}
.route-tabs button.active {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 72%, var(--line));
  background: color-mix(in srgb, var(--green) 14%, var(--surface-2));
}
.route-tab-panels {
  display: grid;
  gap: 18px;
  padding-top: 16px;
}
.route-tab-panel {
  display: none;
  min-width: 0;
}
.route-tab-panel.active {
  display: grid;
  gap: 14px;
}
.route-tab-panel > .panel-head {
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}
.route-tab-panel > .panel-head h3 {
  font-size: 18px;
}
#routes .raw-panel {
  display: grid;
  gap: 12px;
  padding: 0;
}
#routes .warning {
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--yellow) 44%, var(--line));
  border-radius: var(--radius-md);
  background-color: color-mix(in srgb, var(--yellow) 9%, transparent);
  background-image: none;
  box-shadow: none;
}
.rule-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  background-color: color-mix(in srgb, var(--field) 88%, var(--surface-raised));
  background-image:
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0)),
    linear-gradient(90deg, color-mix(in srgb, var(--blue) 18%, transparent), transparent 42%);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft), 0 1px 0 color-mix(in srgb, var(--text) 4%, transparent) inset;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}
.rule-card + .rule-card { margin-top: 2px; }
.rule-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.rule-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.rule-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rule-index {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  color: var(--blue);
  font-weight: 800;
  box-shadow: 0 1px 0 var(--panel-topline) inset;
}
.rule-grid {
  display: grid;
  grid-template-columns: minmax(150px, .55fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.rule-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.rule-card label {
  gap: 7px;
  color: color-mix(in srgb, var(--muted) 88%, var(--text));
  font-size: 12px;
  font-weight: 650;
}
.rule-card textarea {
  min-height: 104px;
  max-height: 196px;
  line-height: 1.45;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}
.rule-card textarea.is-scrollable { overflow-y: auto; }
.rule-card input,
.rule-card textarea {
  background: color-mix(in srgb, var(--field) 82%, black);
  color: var(--text);
  font-size: 13px;
  font-weight: 560;
}
.rule-card .field-target textarea,
.rule-card .field-target input {
  min-height: 54px;
  font-weight: 760;
}
.rule-card .field-wide {
  grid-column: span 2;
}
.rule-card .field-small input {
  min-height: 38px;
}
.rule-card .empty-field input,
.rule-card .empty-field textarea {
  border-style: dashed;
  opacity: .78;
}
.rule-card .empty-field {
  color: color-mix(in srgb, var(--muted) 72%, var(--field));
}
:root[data-theme="light"] .rule-card {
  background-color: #ffffff;
  background-image:
    linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,0)),
    linear-gradient(90deg, rgba(39, 108, 227, .07), transparent 42%);
  box-shadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 12px 28px rgba(27, 48, 77, .05);
}
:root[data-theme="light"] .rule-card input,
:root[data-theme="light"] .rule-card textarea {
  background: #ffffff;
}
.rule-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
}
.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
}
.mini-badge.proxy,
.mini-badge.block {
  color: var(--soft);
  border-color: var(--line);
}
.compact-rules .rule-card {
  padding: 12px;
}
.compact-rules .rule-grid {
  grid-template-columns: minmax(135px, .7fr) minmax(0, 1fr);
}
.compact-rules .rule-card textarea {
  min-height: 92px;
  max-height: 180px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.setting-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: var(--radius-sm);
}
.raw-panel summary { cursor: pointer; font-weight: 760; }

#configs-json, #core-config, #client-routes-json {
  min-height: 460px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}
#client-routes-json { min-height: 360px; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}
.security-form {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
}
.users-list { display: grid; gap: 12px; }
.user-card { padding: 14px; display: grid; gap: 12px; }
.user-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.user-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.user-title h3 { overflow-wrap: anywhere; }
.status { border-radius: 999px; padding: 3px 8px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.status.active { background: var(--success-soft); color: var(--green); }
.status.disabled, .status.expired, .status.limited { background: var(--danger-soft); color: var(--red); }
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  color: var(--muted);
}
.user-grid span {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  overflow-wrap: anywhere;
}
.user-grid strong { display: block; color: var(--text); font-weight: 700; }
.user-management {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 74%, transparent);
}
.user-management[open] {
  border-color: color-mix(in srgb, var(--green) 42%, var(--line));
  box-shadow: 0 1px 0 var(--panel-topline) inset;
}
.user-management > summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.user-management > summary::-webkit-details-marker { display: none; }
.user-management > summary::after {
  content: '›';
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform .18s ease;
}
.user-management[open] > summary::after { transform: rotate(-90deg); }
.user-management > summary > span { display: inline-flex; align-items: center; gap: 9px; }
.user-management > summary .icon { color: var(--green); }
.user-management > summary small { margin-left: auto; }
.user-management-form {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--field);
}
.management-grid {
  display: grid;
  grid-template-columns: minmax(150px, .7fr) minmax(150px, .7fr) minmax(180px, .9fr) minmax(220px, 1.5fr);
  gap: 12px;
  align-items: end;
}
.expiry-tools {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, .8fr);
  gap: 14px;
  align-items: end;
}
.field-caption { display: block; margin-bottom: 7px; color: var(--muted); }
.preset-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-actions button { min-height: 36px; padding: 7px 10px; }
.preset-actions button.selected {
  border-color: color-mix(in srgb, var(--green) 65%, var(--line));
  color: var(--green);
  background: var(--success-soft);
}
.expiry-preview {
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.expiry-preview strong { overflow-wrap: anywhere; }
.expiry-preview small { line-height: 1.35; }
.reactivation-hint { color: var(--green); }
.management-actions { display: flex; justify-content: flex-end; }
.profile-box { display: grid; gap: 8px; }
.credentials-hidden {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--field);
}
.credentials-hidden .icon {
  flex: 0 0 auto;
  color: var(--green);
}
.profile-box .actions input {
  flex: 1 1 220px;
  min-width: 160px;
}
.user-card {
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.user-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow), 0 1px 0 var(--panel-topline) inset;
}
.audit-list { display: grid; gap: 8px; }
.audit-row {
  display: grid;
  grid-template-columns: 190px 160px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
}
.audit-row span { overflow-wrap: anywhere; min-width: 0; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}
.pagination:empty { display: none; }
.pagination span { min-width: 130px; text-align: center; color: var(--muted); }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--green);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-width: min(380px, calc(100vw - 28px));
  box-shadow: var(--shadow);
  z-index: 10;
}

@media (max-width: 1120px) {
  .dashboard-grid, .profile-layout { grid-template-columns: 1fr; }
  .metrics, .configs-grid, .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compact-rules .rule-grid { grid-template-columns: minmax(150px, .55fr) minmax(0, 1fr) minmax(0, 1fr); }
  .topbar { align-items: stretch; flex-wrap: wrap; }
  .top-nav { order: 3; flex: 1 1 100%; justify-content: flex-start; overflow-x: auto; }
  .route-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
  .route-tabs button { flex: 0 0 auto; }
  .management-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side {
    /* On phones the brand bar scrolls away to keep the screen for content. */
    position: relative;
    z-index: 3;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto;
    align-items: center;
    backdrop-filter: blur(18px) saturate(140%);
  }
  .side nav { display: none; }
  .side #logout { justify-self: end; align-self: center; }
  .brand, .brand > div:last-child { min-width: 0; }
  .brand strong, .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar {
    top: auto;
    margin: 0;
    overflow-x: clip;
  }
  .top-nav {
    order: 0;
    flex: 0 0 auto;
    width: 100%;
  }
  .topbar, .user-head, .hero-panel { align-items: stretch; flex-direction: column; display: flex; }
  .grid-form, .user-grid, .route-row, .traffic-row, .rule-grid { grid-template-columns: 1fr 1fr; }
  .compact-rules .rule-grid { grid-template-columns: 1fr 1fr; }
  .expiry-tools { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
  .content { padding: 14px; }
  .side { padding: 14px; gap: 14px; }
  .brand-mark { width: 32px; height: 32px; }
  .topbar > div:first-child { min-width: 0; }
  .top-nav button { width: 36px; min-width: 36px; }
  .topbar { padding: 10px; border-radius: var(--radius-md); }
  .topbar .actions, .top-controls, .top-nav { max-width: 100%; }
  .top-nav, .route-tabs { scrollbar-width: thin; }
  .topbar .actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px 40px;
    gap: 8px;
    align-items: center;
  }
  .topbar .actions > button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    font-size: 0;
  }
  .topbar .actions > button .i {
    margin: 0;
  }
  .top-controls {
    min-width: 0;
    width: 100%;
  }
  .language-picker {
    min-width: 0;
    grid-template-columns: 16px minmax(46px, 1fr) 12px;
    gap: 6px;
    padding: 0 8px;
  }
  .control-select {
    width: 100%;
  }
  h2 { font-size: 22px; }
  h3 { font-size: 16px; }
  .metrics, .grid-form, .user-grid, .audit-row, .route-row, .traffic-row, .configs-grid, .settings-grid, .rule-grid { grid-template-columns: 1fr; }
  .management-grid { grid-template-columns: 1fr; }
  .profile-card-main, .check-row { grid-template-columns: 1fr; }
  .degradation-banner { grid-template-columns: auto minmax(0, 1fr); }
  .degradation-banner button { grid-column: 1 / -1; width: 100%; }
  .profile-icon { width: 34px; height: 34px; }
  .compact-rules .rule-grid { grid-template-columns: 1fr; }
  .panel, .user-card { padding: 12px; }
  .user-management > summary { align-items: flex-start; }
  .user-management > summary small { display: none; }
  .management-actions button { width: 100%; }
  .actions > button,
  .actions > .button,
  .grid-form > button,
  .wide { width: 100%; }
  .actions > button,
  .actions > .button { max-width: 100%; }
  #routes .actions > button,
  #routes .actions > .button {
    width: min(100%, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
  }
  .hero-panel .actions { width: 100%; }
  .top-nav button,
  .rule-tools button,
  .icon-button,
  .icon-only { width: 36px; min-width: 36px; }
  .route-tab-panels { padding-top: 12px; }
  [data-tooltip]::after { display: none; }
}

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

/* Shared helpers --------------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.subheading { font-size: 13px; color: var(--muted); font-weight: 700; margin: 0; }
.state-panel {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-3);
}
.state-panel p { margin: 0; }
.state-panel.error-state { border-style: solid; border-color: color-mix(in srgb, var(--red) 50%, var(--line)); }
.state-panel.loading-state { color: var(--muted); }

/* Overview: transport status ------------------------------------------------ */
.transports-panel { align-content: start; }
.transport-status { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.transport-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
}
.transport-name { display: grid; min-width: 0; }
.transport-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transport-name small { font-size: 12px; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.transport-row.healthy .health-dot { background: var(--green); box-shadow: 0 0 0 4px var(--success-soft); }
.transport-row.degraded .health-dot,
.transport-row.stale .health-dot,
.transport-row.unknown .health-dot { background: var(--yellow); }
.transport-row.unhealthy .health-dot { background: var(--red); box-shadow: 0 0 0 4px var(--danger-soft); }

/* Users toolbar and creation -------------------------------------------------- */
.users-toolbar {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(150px, 220px) auto;
  gap: 10px;
  align-items: center;
}
.users-count { margin: 0; white-space: nowrap; }
.search-field input { padding-left: 36px; background-image: none; }
.search-field { position: relative; display: block; }
.search-field::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 50%;
  width: 11px;
  height: 11px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  translate: 0 -60%;
  pointer-events: none;
}
.search-field::after {
  content: '';
  position: absolute;
  left: 24px;
  top: 58%;
  width: 6px;
  height: 2px;
  background: var(--muted);
  rotate: 45deg;
  pointer-events: none;
}
.create-panel { padding: 0; gap: 0; overflow: hidden; }
.create-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}
.create-panel > summary::-webkit-details-marker { display: none; }
.create-summary { display: inline-flex; align-items: center; gap: 8px; font-weight: 760; color: var(--text); }
.create-summary .i { color: var(--green); }
.create-panel[open] > summary { border-bottom: 1px solid var(--line); }
.create-panel > form { padding: 16px; }

/* User card -------------------------------------------------------------- */
.user-card.status-disabled,
.user-card.status-expired,
.user-card.status-limited { border-left: 3px solid color-mix(in srgb, var(--red) 70%, var(--line)); }
.user-card.status-active { border-left: 3px solid color-mix(in srgb, var(--green) 70%, var(--line)); }
.user-title { align-items: baseline; }
.user-note {
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.user-primary-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.user-summary {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 1.6fr);
  gap: 12px;
  align-items: stretch;
}
.usage {
  display: grid;
  gap: 8px;
  align-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
}
.usage-line { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }
.usage-line strong { color: var(--text); text-align: right; }
.usage progress {
  width: 100%;
  height: 8px;
  appearance: none;
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  background: var(--surface-2);
}
.usage progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 99px; }
.usage progress::-webkit-progress-value { background: var(--green); border-radius: 99px; }
.usage progress::-moz-progress-bar { background: var(--green); border-radius: 99px; }
.usage.warn progress::-webkit-progress-value { background: var(--yellow); }
.usage.warn progress::-moz-progress-bar { background: var(--yellow); }
.usage.critical progress::-webkit-progress-value { background: var(--red); }
.usage.critical progress::-moz-progress-bar { background: var(--red); }
.user-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}
.user-facts > div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  min-width: 0;
}
.user-facts dt { color: var(--muted); font-size: 12px; }
.user-facts dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.user-badges { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}
.user-badge strong { color: var(--text); }
.user-badge.ok strong { color: var(--green); }
.user-badge.warn strong { color: var(--yellow); }

/* Collapsible card sections share the management disclosure style. */
.user-section { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--surface-2) 74%, transparent); }
.user-section[open] { border-color: color-mix(in srgb, var(--green) 42%, var(--line)); }
.user-section > summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.user-section > summary::-webkit-details-marker { display: none; }
.user-section > summary::after {
  content: '›';
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform .18s ease;
}
.user-section[open] > summary::after { transform: rotate(-90deg); }
.user-section > summary > span { display: inline-flex; align-items: center; gap: 9px; }
.user-section > summary .icon { color: var(--green); }
.user-section > summary small { margin-left: auto; }
.section-body {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--field);
}
.access-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.access-actions button { justify-content: flex-start; }
.credentials-hidden { margin: 0; min-height: 0; }
.danger-zone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid color-mix(in srgb, var(--red) 35%, var(--line));
  background: color-mix(in srgb, var(--danger-soft) 60%, var(--field));
}
.danger-zone > div:first-child { display: grid; gap: 2px; }
.danger-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ProAnima Bridge devices ------------------------------------------------------ */
.bridge-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bridge-head p { margin: 0; max-width: 62ch; }
.enroll-code {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--green) 55%, var(--line));
  border-radius: var(--radius-sm);
  background: var(--success-soft);
}
.enroll-code-label { color: var(--muted); }
.enroll-code-value { font: 700 22px/1.1 var(--font-mono); letter-spacing: .08em; color: var(--text); }
.enroll-code button { margin-left: auto; }
.client-devices { display: grid; gap: 10px; }
.client-devices:empty { display: none; }
.device-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
}
.device-group-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.device-group-title { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.device-group-title .icon { color: var(--teal); }
.device-group-title small {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  text-align: center;
}
.device-group-actions { display: inline-flex; gap: 6px; }
.device-group-actions button { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.device-group-empty { margin: 0; font-size: 13px; }
.device-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.device-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
}
.platform-badge {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--blue) 16%, var(--surface-2));
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.platform-badge.android { background: color-mix(in srgb, var(--green) 16%, var(--surface-2)); color: var(--green); }
.device-main { display: grid; min-width: 0; }
.device-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-main small { font-size: 12px; }
.device-actions { display: inline-flex; align-items: center; gap: 8px; }
.device-actions select { width: auto; min-width: 140px; padding: 7px 10px; }
.folder-create, .folder-rename { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.folder-create label, .folder-rename label { flex: 1 1 200px; display: block; }
.folder-hint { margin: 0; font-size: 12px; }

@media (max-width: 900px) {
  .user-summary { grid-template-columns: 1fr; }
  .bridge-head { flex-direction: column; align-items: stretch; }
}
@media (max-width: 580px) {
  .users-toolbar { grid-template-columns: 1fr; }
  .user-head { gap: 10px; }
  .user-primary-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .user-primary-actions button { width: 100%; }
  .user-facts { grid-template-columns: 1fr 1fr; }
  .user-facts > div:last-child { grid-column: 1 / -1; }
  .access-actions { grid-template-columns: 1fr; }
  .device-row { grid-template-columns: auto minmax(0, 1fr); }
  .device-actions { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .device-actions select { min-width: 0; width: 100%; }
  .danger-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .enroll-code button { margin-left: 0; width: 100%; }
  .transport-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .transport-row > .mini-badge:not(.health-badge) { display: none; }
  .create-panel > summary small { display: none; }
  .user-section > summary small:not([data-device-count]) { display: none; }
}

@media (max-width: 1120px) {
  /* On one column the transport status matters more than the chart. */
  .dashboard-grid .transports-panel { order: -1; }
}
@media (max-width: 580px) {
  #overview .metrics, #security .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article { padding: 12px; }
  .metrics strong { font-size: 22px; }
}

/* Client route lifecycle and canary devices ---------------------------------- */
.route-lifecycle {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.route-lifecycle label { display: grid; gap: 4px; min-width: 160px; }
.route-lifecycle select { padding: 7px 10px; }
.route-lifecycle small { flex: 1 1 100%; }
.canary-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; cursor: pointer; }
.canary-toggle input { width: 16px; height: 16px; padding: 0; accent-color: var(--yellow); }
@media (max-width: 580px) {
  .device-actions { grid-template-columns: auto minmax(0, 1fr) auto; }
}

/* User card: links by protocol ------------------------------------------------ */
.access-heading { margin: 4px 0 0; font-size: 13px; color: var(--muted); font-weight: 700; }
.access-hint { margin: 0; font-size: 12px; }
.access-rotate button { justify-content: flex-start; }

