:root {
  color-scheme: dark;
  --bg: #07101f;
  --bg-elevated: #0b1628;
  --surface: #101d31;
  --surface-strong: #15253d;
  --surface-hover: #1a2b45;
  --surface-inset: #0a1424;
  --text: #f5f8fc;
  --text-muted: #aebbd0;
  --text-subtle: #7f90aa;
  --border: #273952;
  --border-strong: #3b506e;
  --primary: #65a7ff;
  --primary-strong: #2f7de1;
  --primary-soft: rgba(74, 144, 240, 0.14);
  --success: #52d39a;
  --success-soft: rgba(52, 199, 137, 0.13);
  --warning: #f0ba63;
  --warning-soft: rgba(226, 165, 65, 0.14);
  --danger: #ff7b84;
  --danger-strong: #dc4f5a;
  --danger-soft: rgba(239, 92, 103, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 16px 36px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.42);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --sidebar-width: 248px;
  --topbar-height: 104px;
  --transition: 180ms cubic-bezier(0.2, 0, 0, 1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f9;
  --bg-elevated: #f7f9fc;
  --surface: #ffffff;
  --surface-strong: #f4f7fb;
  --surface-hover: #eaf1fa;
  --surface-inset: #edf2f8;
  --text: #15243a;
  --text-muted: #52647c;
  --text-subtle: #64748b;
  --border: #d4dfec;
  --border-strong: #b9c8da;
  --primary: #175fae;
  --primary-strong: #0f4e94;
  --primary-soft: rgba(23, 95, 174, 0.1);
  --success: #15734d;
  --success-soft: rgba(21, 115, 77, 0.1);
  --warning: #925e0b;
  --warning-soft: rgba(146, 94, 11, 0.1);
  --danger: #b42332;
  --danger-strong: #981b29;
  --danger-soft: rgba(180, 35, 50, 0.09);
  --shadow-sm: 0 1px 3px rgba(39, 55, 77, 0.08);
  --shadow-md: 0 16px 34px rgba(39, 55, 77, 0.1);
  --shadow-lg: 0 28px 64px rgba(39, 55, 77, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
input,
textarea {
  touch-action: manipulation;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

a {
  color: inherit;
}

svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] {
  display: none !important;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-strong);
  color: #fff;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--transition);
}

.skip-link:focus {
  transform: translateY(0);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
}

.brand-lockup strong {
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.brand-lockup small {
  margin-top: 1px;
  color: var(--text-subtle);
  font-size: 0.74rem;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid rgba(101, 167, 255, 0.35);
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

.login-screen {
  position: relative;
  display: grid;
  min-height: 100dvh;
  padding: 28px 20px 64px;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}

.login-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 18% 18%, rgba(47, 125, 225, 0.2), transparent 32%),
    radial-gradient(circle at 82% 72%, rgba(44, 163, 124, 0.1), transparent 30%),
    linear-gradient(145deg, var(--bg), var(--bg-elevated));
}

.login-atmosphere::after {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(101, 167, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(101, 167, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.login-card {
  width: min(100%, 450px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-lg);
}

.brand-lockup--login {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.login-copy {
  margin: 26px 0 22px;
}

.login-copy h1 {
  margin: 0;
  font-size: clamp(1.8rem, 6vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.login-copy > p:last-child {
  margin: 10px 0 0;
  color: var(--text-muted);
}

.form-stack {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.field small {
  color: var(--text-subtle);
  font-size: 0.76rem;
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition),
    background var(--transition);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-subtle);
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 52px;
}

.password-field .icon-button {
  position: absolute;
  top: 0;
  right: 0;
}

.form-error {
  min-height: 1.25rem;
  margin: -6px 0 0;
  color: var(--danger);
  font-size: 0.82rem;
}

.button,
.icon-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.button {
  padding: 9px 15px;
  font-size: 0.85rem;
}

.button--wide {
  width: 100%;
}

.button--primary {
  background: var(--primary-strong);
  color: #fff;
  box-shadow: 0 8px 20px rgba(47, 125, 225, 0.22);
}

.button--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary-strong) 88%, #fff);
}

.button--secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button--secondary:hover:not(:disabled),
.button--ghost:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.button--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.button--danger {
  background: var(--danger-strong);
  color: #fff;
}

.button--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger-strong) 88%, #fff);
}

.icon-button {
  width: 44px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.security-note {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: 0.75rem;
}

.security-note svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--success);
}

.login-footer {
  position: absolute;
  bottom: 20px;
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.72rem;
}

.app-shell {
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
}

.sidebar-head {
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px;
}

.nav-list {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
}

.nav-item {
  position: relative;
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 650;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.nav-item::before {
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: -12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
  content: "";
  opacity: 0;
  transition: opacity var(--transition);
}

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

.nav-item[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-item[aria-current="page"]::before {
  opacity: 1;
}

.sidebar-foot {
  display: grid;
  gap: 14px;
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-subtle);
  font-size: 0.75rem;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px var(--warning-soft);
}

.connection-state.is-online .connection-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.connection-state.is-offline .connection-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.admin-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.admin-identity strong,
.admin-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-identity strong {
  font-size: 0.82rem;
}

.admin-identity small {
  color: var(--text-subtle);
  font-size: 0.7rem;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.sidebar-actions .button {
  padding-inline: 8px;
  font-size: 0.75rem;
}

.workspace {
  min-height: 100dvh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  gap: 18px;
  justify-content: space-between;
  padding: 18px clamp(20px, 3vw, 42px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
}

.page-heading {
  min-width: 0;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.5vw, 1.9rem);
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.page-heading > p:last-child {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.83rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.last-updated {
  color: var(--text-subtle);
  font-size: 0.72rem;
  white-space: nowrap;
}

.main-content {
  width: min(100%, 1520px);
  min-height: calc(100dvh - var(--topbar-height));
  padding: 28px clamp(20px, 3vw, 42px) 54px;
}

.loading-panel,
.empty-state,
.error-state {
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-align: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.section-stack {
  display: grid;
  gap: 22px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-head h2,
.card h2,
.card h3 {
  margin: 0;
  letter-spacing: -0.02em;
}

.section-head h2,
.card h2 {
  font-size: 1rem;
}

.section-head p,
.card-heading p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

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

.stat-card,
.card {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-card {
  min-width: 0;
  padding: 16px;
  border-radius: var(--radius-md);
}

.stat-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-subtle);
}

.stat-card__head span {
  font-size: 0.74rem;
  font-weight: 650;
}

.stat-card__value {
  display: block;
  margin-top: 14px;
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 2.8vw, 1.8rem);
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  letter-spacing: -0.035em;
}

.stat-card__meta {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.card {
  padding: 18px;
  border-radius: var(--radius-md);
}

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

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
  gap: 16px;
}

.safety-banner,
.callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.safety-banner {
  justify-content: space-between;
  padding: 15px 16px;
}

.safety-banner__copy {
  display: flex;
  gap: 12px;
}

.safety-banner__icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 10px;
}

.safety-banner strong,
.safety-banner small,
.callout strong,
.callout span {
  display: block;
}

.safety-banner small,
.callout span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.safety-banner--safe,
.callout--success {
  border-color: color-mix(in srgb, var(--success) 38%, var(--border));
  background: var(--success-soft);
}

.safety-banner--safe .safety-banner__icon {
  background: var(--success-soft);
  color: var(--success);
}

.safety-banner--warning,
.callout--warning {
  border-color: color-mix(in srgb, var(--warning) 38%, var(--border));
  background: var(--warning-soft);
}

.safety-banner--warning .safety-banner__icon {
  background: var(--warning-soft);
  color: var(--warning);
}

.safety-banner--danger,
.callout--danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  background: var(--danger-soft);
}

.safety-banner--danger .safety-banner__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.callout {
  padding: 13px 14px;
}

.callout--info {
  border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
  background: var(--primary-soft);
}

.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.badge--success {
  border-color: color-mix(in srgb, var(--success) 32%, var(--border));
  background: var(--success-soft);
  color: var(--success);
}

.badge--warning {
  border-color: color-mix(in srgb, var(--warning) 32%, var(--border));
  background: var(--warning-soft);
  color: var(--warning);
}

.badge--danger {
  border-color: color-mix(in srgb, var(--danger) 32%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--info {
  border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
  background: var(--primary-soft);
  color: var(--primary);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-inset);
  color: var(--text-subtle);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--surface-hover);
}

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

td {
  max-width: 280px;
  overflow-wrap: anywhere;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-muted);
}

.empty-inline {
  padding: 28px 14px;
  color: var(--text-subtle);
  text-align: center;
}

.route-list,
.risk-card-grid,
.system-grid {
  display: grid;
  gap: 12px;
}

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

.route-card {
  display: grid;
  gap: 15px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.route-card__head,
.route-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.route-card__head h3 {
  margin: 0;
  font-size: 0.98rem;
}

.route-card__head p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.route-card__metrics,
.key-value-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric-cell,
.key-value {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-inset);
}

.metric-cell span,
.key-value span {
  display: block;
  color: var(--text-subtle);
  font-size: 0.68rem;
}

.metric-cell strong,
.key-value strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.route-card__footer small {
  color: var(--text-subtle);
  font-size: 0.68rem;
}

.risk-card-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.risk-meter {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-inset);
  appearance: none;
}

.risk-meter::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-inset);
}

.risk-meter::-webkit-progress-value {
  border-radius: 999px;
  background: var(--primary);
}

.risk-meter::-moz-progress-bar {
  border-radius: 999px;
  background: var(--primary);
}

.plain-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.plain-list li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.plain-list svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin-top: 2px;
  color: var(--success);
}

.credential-card {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}

.credential-status,
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.credential-copy {
  max-width: 72ch;
  margin: 12px 0 16px;
  font-size: 0.8rem;
}

.clipboard-fallback {
  position: fixed;
  width: 1px;
  height: 1px;
  inset: auto auto 0 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.dialog {
  width: min(calc(100% - 32px), 660px);
  max-height: calc(100dvh - 48px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.dialog::backdrop {
  background: rgba(2, 7, 16, 0.68);
  backdrop-filter: blur(5px);
}

.dialog form {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.dialog-head p:last-child {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.toggle-row {
  display: flex;
  min-height: 60px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-inset);
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row strong {
  font-size: 0.8rem;
}

.toggle-row small {
  margin-top: 2px;
  color: var(--text-subtle);
  font-size: 0.7rem;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 28px;
  flex: 0 0 48px;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch > span[aria-hidden="true"] {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-strong);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.switch > span[aria-hidden="true"]::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  content: "";
  transition: transform var(--transition), background var(--transition);
}

.switch input:checked + span[aria-hidden="true"] {
  border-color: var(--success);
  background: var(--success-soft);
}

.switch input:checked + span[aria-hidden="true"]::after {
  background: var(--success);
  transform: translateX(20px);
}

.switch--danger input:checked + span[aria-hidden="true"] {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.switch--danger input:checked + span[aria-hidden="true"]::after {
  background: var(--danger);
}

.switch input:focus-visible + span[aria-hidden="true"] {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: grid;
  width: min(calc(100% - 40px), 360px);
  gap: 8px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 0.78rem;
  animation: toast-in 180ms ease-out;
}

.toast--success {
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
}

.toast--danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

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

.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(2, 7, 16, 0.64);
}

.mobile-only {
  display: none;
}

.noscript-message {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 1000;
  padding: 14px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: var(--surface);
  color: var(--danger);
  text-align: center;
}

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    width: min(86vw, 292px);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform var(--transition);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .workspace {
    margin-left: 0;
  }

  .topbar {
    min-height: 92px;
    align-items: flex-start;
    padding: 16px 18px;
  }

  .page-heading {
    flex: 1;
  }

  .page-heading > p:last-child,
  .last-updated {
    display: none;
  }

  .topbar-actions .button span {
    display: none;
  }

  .topbar-actions .button {
    width: 44px;
    padding: 0;
  }

  .main-content {
    padding: 20px 16px 44px;
  }

  .route-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .login-screen {
    align-items: start;
    padding: 18px 12px 70px;
  }

  .login-card {
    margin-top: 6vh;
    padding: 24px 20px;
    border-radius: 18px;
  }

  .stat-grid,
  .risk-card-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .safety-banner,
  .section-head,
  .route-card__footer {
    align-items: stretch;
    flex-direction: column;
  }

  .safety-banner .button,
  .route-card__footer .button {
    width: 100%;
  }

  .dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  .dialog form {
    padding: 18px;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .card-actions .button {
    width: 100%;
  }

  .key-value-grid,
  .route-card__metrics {
    grid-template-columns: 1fr;
  }
}

@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;
  }
}
