/* ==========================================================================
   MirrorRelay Control Plane Design System
   Calm, compact operational UI for Linux repository reverse-proxy management
   ========================================================================== */

:root {
  /* Color Palette - Deep Obsidian & Slate Foundation */
  --bg-canvas: #060911;
  --bg-body: #0a0e1a;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #151f34;
  --bg-surface-hover: #1c2942;
  --bg-dark: #070b14;
  --bg-glass: rgba(15, 23, 42, 0.85);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-color: #1e293b;
  --border-highlight: #334155;
  --border-primary: rgba(56, 189, 248, 0.4);

  /* Typography Colors */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #8492a6;
  --text-inverse: #020617;

  /* Accent */
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --primary-gradient-end: #0284c7;
  --primary-button-text: #020617;
  --primary-glow: rgba(56, 189, 248, 0.18);
  --primary-surface: rgba(56, 189, 248, 0.1);

  /* Status Colors */
  --success: #10b981;
  --success-hover: #059669;
  --success-glow: rgba(16, 185, 129, 0.18);
  --success-surface: rgba(16, 185, 129, 0.1);

  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.18);
  --warning-surface: rgba(245, 158, 11, 0.1);

  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-glow: rgba(244, 63, 94, 0.18);
  --danger-surface: rgba(244, 63, 94, 0.1);

  --accent-purple: #a855f7;
  --accent-purple-surface: rgba(168, 85, 247, 0.12);

  /* Theme-aware component surfaces */
  --sidebar-bg: #080c15;
  --sidebar-foot-bg: rgba(11, 15, 25, 0.95);
  --topology-bg: #0b111e;
  --table-row-hover: rgba(30, 41, 59, 0.45);
  --dialog-backdrop: rgba(4, 7, 14, 0.82);
  --dialog-edge-shadow: 0 0 40px rgba(0, 0, 0, 0.7);
  --login-bg: radial-gradient(circle at 50% 30%, #152038 0%, #060911 75%);
  --login-card-bg: rgba(15, 23, 42, 0.9);
  --code-text: #e2e8f0;
  --notice-danger-bg: rgba(244, 63, 94, 0.14);
  --notice-danger-text: #ffe4e6;
  --link-hover: #7dd3fc;
  --danger-link-hover: #ff6b81;
  --chart-grid: rgba(255, 255, 255, 0.08);
  --chart-label: #8492a6;
  --chart-point-stroke: #0f172a;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Geometry */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Elevation & Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 8px 20px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 32px -6px rgba(0, 0, 0, 0.6), 0 6px 12px -3px rgba(0, 0, 0, 0.4);
  --shadow-glow-cyan: 0 0 24px rgba(56, 189, 248, 0.2);
  --shadow-glow-emerald: 0 0 24px rgba(16, 185, 129, 0.2);
}

:root[data-theme="light"] {
  --bg-canvas: #f8fafc;
  --bg-body: #f4f7fb;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e8eef6;
  --bg-dark: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.9);

  --border-subtle: rgba(15, 23, 42, 0.09);
  --border-color: #d7e0eb;
  --border-highlight: #94a3b8;
  --border-primary: rgba(3, 105, 161, 0.38);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --primary: #0369a1;
  --primary-hover: #075985;
  --primary-gradient-end: #075985;
  --primary-button-text: #ffffff;
  --primary-glow: rgba(3, 105, 161, 0.16);
  --primary-surface: rgba(3, 105, 161, 0.1);

  --success: #047857;
  --success-hover: #065f46;
  --success-glow: rgba(4, 120, 87, 0.15);
  --success-surface: rgba(4, 120, 87, 0.1);
  --warning: #b45309;
  --warning-glow: rgba(180, 83, 9, 0.14);
  --warning-surface: rgba(180, 83, 9, 0.1);
  --danger: #be123c;
  --danger-hover: #9f1239;
  --danger-glow: rgba(190, 18, 60, 0.14);
  --danger-surface: rgba(190, 18, 60, 0.09);
  --accent-purple: #7e22ce;
  --accent-purple-surface: rgba(126, 34, 206, 0.1);

  --sidebar-bg: #ffffff;
  --sidebar-foot-bg: rgba(248, 250, 252, 0.96);
  --topology-bg: #f8fafc;
  --table-row-hover: rgba(226, 232, 240, 0.62);
  --dialog-backdrop: rgba(15, 23, 42, 0.45);
  --dialog-edge-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  --login-bg: radial-gradient(circle at 50% 25%, #dbeafe 0%, #f8fafc 70%);
  --login-card-bg: rgba(255, 255, 255, 0.94);
  --code-text: #1e293b;
  --notice-danger-bg: #fff1f2;
  --notice-danger-text: #9f1239;
  --link-hover: #075985;
  --danger-link-hover: #9f1239;
  --chart-grid: rgba(15, 23, 42, 0.11);
  --chart-label: #475569;
  --chart-point-stroke: #ffffff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 20px -10px rgba(15, 23, 42, 0.22);
  --shadow-lg: 0 22px 48px -14px rgba(15, 23, 42, 0.25), 0 8px 18px -10px rgba(15, 23, 42, 0.16);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

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

html, body {
  height: 100%;
  background-color: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: var(--border-highlight);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.hidden {
  display: none !important;
}

/* Keep each role's interface aligned with the server-side RBAC contract. */
:root[data-role="viewer"] .requires-operator,
:root:not([data-role="admin"]) .requires-admin {
  display: none !important;
}

/* Vector SVG Icon Helper */
.icon-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ==========================================================================
   App Shell Layout
   ========================================================================== */

.shell {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-body);
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */

aside {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 90;
}

aside .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #ffffff;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-info strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-info small {
  font-size: 11px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

aside nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 14px 12px 6px 12px;
}

aside nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.3;
}

aside nav button .nav-icon {
  color: var(--text-muted);
  transition: color 0.15s ease;
}

aside nav button:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

aside nav button:hover .nav-icon {
  color: var(--primary);
}

aside nav button.active {
  background: var(--primary-surface);
  color: var(--primary);
  font-weight: 600;
  border-color: var(--border-primary);
}

aside nav button.active .nav-icon {
  color: var(--primary);
}

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--sidebar-foot-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-highlight);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.user-avatar-sm {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-details span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-details small {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Header Control Bar
   ========================================================================== */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-body);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 80;
}

.header-title-block h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.header-title-block p {
  font-size: 12px;
  color: var(--text-muted);
}

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

/* Explicit light / dark / automatic theme selector. */
.theme-switch {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
}

.theme-switch button {
  width: 28px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.theme-switch button:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  box-shadow: none;
}

.theme-switch button.active {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

/* Integrated Header Language Switch */
.header-lang {
  display: inline-flex;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
}

.header-lang button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.header-lang button:hover {
  color: var(--text-primary);
}

.header-lang button.active {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Live Status Indicator */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
}

.status.online {
  background: var(--success-surface);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}

.status.online::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
}

.pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}

.pulse-dot.green {
  background: var(--success);
}

.pulse-dot.red {
  background: var(--danger);
}

/* ==========================================================================
   Buttons & Interactive Elements
   ========================================================================== */

button {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--text-inverse);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.3;
}

button:hover {
  background: var(--primary-hover);
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button.btn-primary,
.btn-primary {
  background: var(--primary);
  color: var(--primary-button-text);
  border: none;
}

button.btn-primary:hover,
.btn-primary:hover {
  background: var(--primary-hover);
}

button.secondary {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-highlight);
  color: var(--text-primary);
}

button.secondary:hover {
  background: var(--border-highlight);
  border-color: var(--text-secondary);
}

button.danger {
  background: var(--danger-surface);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: var(--danger);
}

button.danger:hover {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

button.small {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

button.btn-restart {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-highlight);
  color: var(--text-primary);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
}

button.btn-restart:hover {
  background: var(--border-highlight);
  border-color: var(--primary);
  color: var(--primary);
}

button.btn-restart-inline {
  background: var(--primary-surface);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--primary);
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: var(--radius-md);
}

button.btn-restart-inline:hover {
  background: var(--primary);
  color: var(--text-inverse);
}

button.text-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  cursor: pointer;
  text-align: left;
  display: inline;
}

button.text-button:hover {
  text-decoration: underline;
  color: var(--link-hover);
}

button.text-button strong {
  color: var(--primary);
}

button.link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

button.link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

button.link.danger {
  color: var(--danger);
}

button.link.danger:hover {
  color: var(--danger-link-hover);
}

button.icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: var(--radius-sm);
}

button.icon:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

button.icon-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  cursor: pointer;
  line-height: 1;
}

button.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--primary);
}

/* ==========================================================================
   Notification Toasts
   ========================================================================== */

#notice {
  position: fixed;
  top: 72px;
  right: 24px;
  z-index: 2000;
  pointer-events: none;
  max-width: 480px;
}

.notice {
  pointer-events: auto;
  background: var(--bg-surface);
  border: 1px solid var(--primary);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.notice.error {
  border-color: var(--danger);
  background: var(--notice-danger-bg);
  color: var(--notice-danger-text);
}

.page > .notice {
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.notice-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
}

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

/* ==========================================================================
   Page Containers & Toolbars
   ========================================================================== */

.page-container {
  flex: 1;
  width: 100%;
}

.page {
  padding: 24px 28px 44px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
  flex-wrap: wrap;
}

.toolbar.end {
  justify-content: flex-end;
}

.toolbar h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-bar .search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding-left: 36px;
}

/* ==========================================================================
   Metric Cards Grid (.cards)
   ========================================================================== */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.cards.detail-cards {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 20px;
}

.cards.compact-cards {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 84px;
}

.card:hover {
  border-color: var(--border-highlight);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card small {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.1px;
}

.card-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.card-icon.accent {
  background: var(--primary-surface);
  color: var(--primary);
}

.card strong {
  display: block;
  font-size: 18px;
  font-weight: 650;
  color: var(--text-primary);
  font-family: var(--font-mono);
  word-break: break-all;
  letter-spacing: -0.5px;
}

.card strong.accent {
  color: var(--primary);
}

.card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   Topology Pipeline Diagram
   ========================================================================== */

.topology-pipeline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--topology-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 0;
  overflow-x: auto;
}

.topo-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  min-width: 145px;
  position: relative;
}

.topo-node.active {
  border-color: var(--border-highlight);
}

.topo-node.inactive {
  opacity: 0.6;
}

.node-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.node-icon-wrap.primary {
  background: var(--primary-surface);
  color: var(--primary);
  border-color: rgba(56, 189, 248, 0.4);
}

.node-icon-wrap.success {
  background: var(--success-surface);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.4);
}

.node-icon-wrap.danger {
  background: var(--danger-surface);
  color: var(--danger);
}

.node-content {
  display: flex;
  flex-direction: column;
}

.node-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.node-protocol {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--bg-dark);
  color: var(--primary);
  border: 1px solid var(--border-color);
}

.topo-arrow {
  color: var(--primary);
  opacity: 0.5;
  flex-shrink: 0;
}

/* ==========================================================================
   Panels, Grids & Key-Value Lists
   ========================================================================== */

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.panel.narrow {
  max-width: 540px;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header-row h2 {
  margin-bottom: 0;
}

.panel h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.6;
}

.panel p.muted, p.muted {
  color: var(--text-muted);
  font-size: 12px;
}

.panel-actions {
  margin-top: 14px;
  margin-bottom: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.grid2 > .panel {
  margin-bottom: 0;
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  gap: 16px;
}

.kv:last-child {
  border-bottom: none;
}

.kv > span:first-child {
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.kv > span:last-child {
  color: var(--text-primary);
  font-family: var(--font-mono);
  text-align: right;
  word-break: break-all;
}

/* Native progressive disclosure used for secondary and technical content. */
.disclosure-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.disclosure-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: clip;
}

.disclosure-stack .disclosure-panel {
  margin-bottom: 0;
}

.disclosure-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  color: var(--text-primary);
}

.disclosure-panel > summary::-webkit-details-marker {
  display: none;
}

.disclosure-panel > summary:hover {
  background: var(--bg-surface-hover);
}

.disclosure-panel > summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.disclosure-heading {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.disclosure-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 650;
}

.disclosure-title .icon-svg {
  color: var(--text-muted);
}

.disclosure-description {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 400;
}

.disclosure-chevron {
  display: inline-flex;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.disclosure-panel[open] > summary {
  border-bottom: 1px solid var(--border-subtle);
}

.disclosure-panel[open] > summary .disclosure-chevron {
  transform: rotate(90deg);
}

.disclosure-content {
  padding: 16px;
}

.disclosure-content > :last-child,
.disclosure-content > .table-wrap:last-child,
.disclosure-content > .panel:last-child {
  margin-bottom: 0;
}

.disclosure-content > .form-grid + .table-wrap {
  margin-top: 16px;
}

.preview-section + .preview-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.preview-section h3 {
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 650;
}

.preview-section .config-preview {
  margin-top: 10px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  grid-column: 1 / -1;
  margin-top: 2px;
}

.spaced-form {
  margin-top: 16px;
}

.inline-result {
  margin-top: 14px;
}

/* Cache Progress Bar */
.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 8px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.bar {
  flex: 1;
  height: 8px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #38bdf8 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.bar-percent {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary);
}

/* ==========================================================================
   Badges & Tags
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  line-height: 1.3;
}

.badge.ok, .badge.green {
  background: var(--success-surface);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}

.badge.bad, .badge.red {
  background: var(--danger-surface);
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.3);
}

.badge.blue {
  background: var(--primary-surface);
  color: var(--primary);
  border-color: rgba(56, 189, 248, 0.3);
}

.badge.yellow {
  background: var(--warning-surface);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.3);
}

.badge.purple {
  background: var(--accent-purple-surface);
  color: var(--accent-purple);
  border-color: rgba(168, 85, 247, 0.3);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  line-height: 1.3;
}

.status-pill.status-healthy {
  background: var(--success-surface);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.35);
}

.status-pill.status-degraded {
  background: var(--warning-surface);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.35);
}

.status-pill.status-unhealthy {
  background: var(--danger-surface);
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.35);
}

.status-pill.status-unknown {
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border-color: var(--border-color);
}

.upstream-pill {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.ratio-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

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

.status-codes {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.code-copy-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Table Design
   ========================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

th {
  background: var(--bg-dark);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.2px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

td small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

td strong {
  font-weight: 600;
  color: var(--text-primary);
}

td code {
  font-size: 11.5px;
}

td.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
  font-style: italic;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--table-row-hover);
}

/* Table Row Actions */
.actions,
td.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

td.actions {
  min-width: 380px;
}

td.actions button,
.actions button,
td button {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  gap: 4px;
}

td.actions button:hover,
.actions button:hover,
td button:hover {
  background: var(--border-highlight);
  color: var(--text-primary);
  border-color: var(--border-highlight);
}

td.actions button.danger,
.actions button.danger,
td button.danger {
  background: var(--danger-surface);
  border-color: rgba(244, 63, 94, 0.25);
  color: var(--danger);
}

td.actions button.danger:hover,
.actions button.danger:hover,
td button.danger:hover {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

a.button-link {
  padding: 4px 9px;
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

a.button-link:hover {
  background: var(--border-highlight);
  color: var(--text-primary);
  border-color: var(--border-highlight);
}

.user-row-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Forms & Controls
   ========================================================================== */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.form-grid.single-col {
  grid-template-columns: 1fr;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-grid label.wide,
.form-grid label.full-span {
  grid-column: 1 / -1;
}

.form-grid label.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  grid-column: span 1;
}

.form-grid label span {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.field-help {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
}

.info-callout {
  padding: 12px 14px;
  margin-bottom: 18px;
  background: var(--primary-surface);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
}

.info-callout strong {
  display: block;
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 12px;
}

.panel .info-callout p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
}

input, select, textarea {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

input[type="color"] {
  height: 38px;
  padding: 2px 4px;
  cursor: pointer;
}

textarea {
  font-family: var(--font-mono);
  resize: vertical;
  line-height: 1.5;
}

.error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
  word-break: break-word;
}

dialog footer .error,
.settings-form footer .error,
form.panel footer .error {
  width: 100%;
  margin-top: 0;
  margin-bottom: 8px;
  text-align: left;
  order: -1;
}

/* Settings and Appearance Forms */
.settings-form {
  margin-top: 16px;
}

.settings-form .disclosure-panel {
  margin-bottom: 10px;
}

.settings-form fieldset {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.settings-form legend {
  padding: 0 10px;
  font-weight: 700;
  font-size: 13px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.settings-form footer,
form.panel footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

#webhook-test-form footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

#webhook-test-form footer .error {
  width: 100%;
  margin: 0;
}

/* ==========================================================================
   Dialogs & Modals
   ========================================================================== */

dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  padding: 0;
  box-shadow: var(--shadow-lg), var(--dialog-edge-shadow);
  margin: auto;
  max-width: 90vw;
  max-height: 90vh;
  width: 600px;
  overflow: hidden;
}

dialog::backdrop {
  background: var(--dialog-backdrop);
}

.wide-dialog {
  width: 860px;
}

dialog form,
dialog .dialog-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 90vh;
  overflow: hidden;
}

dialog header {
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-dark);
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}

dialog header h2 {
  font-size: 16px;
  font-weight: 700;
}

.dialog-scroll-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

dialog fieldset {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 12px 24px;
  background: var(--bg-dark);
}

dialog legend {
  padding: 0 8px;
  font-weight: 600;
  font-size: 12px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#custom-dialog .form-grid,
#node-dialog .form-grid {
  padding: 20px 24px;
}

#detail-content,
#preview-content {
  padding: 20px 24px;
}

dialog footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 14px 24px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Client Examples */
.example {
  margin-bottom: 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.example .toolbar {
  background: var(--bg-surface-elevated);
  border: none;
  border-bottom: 1px solid var(--border-color);
  border-radius: 0;
  margin-bottom: 0;
  padding: 8px 14px;
}

.example .toolbar strong {
  font-size: 12px;
  color: var(--text-primary);
}

.example pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 12px 14px;
}

/* ==========================================================================
   Charts & Visualizations
   ========================================================================== */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.chart-box {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.chart-header strong {
  font-size: 12.5px;
  color: var(--text-primary);
  font-weight: 600;
}

.chart-max {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--primary);
  background: var(--primary-surface);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.chart-empty {
  text-align: center;
  padding: 36px 0;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.chart-svg-wrap {
  width: 100%;
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: 160px;
  display: block;
}

.chart-point {
  cursor: pointer;
  transition: r 0.15s ease, stroke-width 0.15s ease;
}

.chart-point:hover {
  r: 5.5;
  stroke-width: 2.5;
}

/* Donut Chart */
.donut-box {
  min-height: 180px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 14px;
  padding: 8px 0;
}

.donut-svg {
  flex-shrink: 0;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
}

.donut-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-label {
  color: var(--text-secondary);
  flex: 1;
}

.donut-legend-val {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* ==========================================================================
   Interactive Client Setup Playground
   ========================================================================== */

.playground-panel {
  border-color: var(--border-color);
}

.playground-controls {
  margin-bottom: 18px;
}

.playground-output {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.playground-output .example {
  margin-bottom: 0;
}

/* ==========================================================================
   Live Log Streaming UI
   ========================================================================== */

.log-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.log-toolbar-left h2 {
  margin-bottom: 0;
}

.log-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.log-search-bar {
  max-width: 280px;
}

.log-search-bar input {
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 12px;
}

.live-stream-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-dark);
  color: var(--text-muted);
}

.live-stream-badge.active {
  background: var(--success-surface);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}

.log-terminal {
  max-height: 480px;
  overflow-y: auto;
}

/* ==========================================================================
   Code Blocks & Pre
   ========================================================================== */

pre, .config-preview {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

code {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary);
}

/* ==========================================================================
   Login Page
   ========================================================================== */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: var(--login-bg);
  padding: 20px;
  position: relative;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--login-card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.login-brand p {
  color: var(--text-secondary);
  font-size: 12.5px;
  margin-bottom: 0;
}

.login-mode-copy {
  margin: -4px 0 20px;
}

.login-mode-copy h2 {
  color: var(--text-primary);
  font-size: 16px;
  margin-bottom: 5px;
}

.login-mode-copy p {
  color: var(--text-secondary);
  font-size: 12.5px;
  margin: 0;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  margin-top: 8px;
}

/* Floating theme and language controls on login */
.login-controls {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
}

#login-lang {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 3px;
  box-shadow: var(--shadow-md);
}

#login-lang button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

#login-lang button.active {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 900px) {
  .shell {
    flex-direction: column;
  }
  aside {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  aside nav {
    max-height: 220px;
    overflow-y: auto;
  }
  header {
    padding: 12px 18px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .header-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .page {
    padding: 18px 14px 36px 14px;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .search-bar {
    max-width: 100%;
    width: 100%;
  }
  .toolbar button,
  .toolbar .actions {
    width: 100%;
    justify-content: flex-start;
  }
  .disclosure-panel > summary {
    min-height: 50px;
    padding: 11px 14px;
  }
  .disclosure-content {
    padding: 14px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid label.wide,
  .form-grid label.full-span {
    grid-column: span 1;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .cards {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
  }
  .donut-wrap {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }
  dialog {
    max-width: 95vw;
    width: 95vw;
    border-radius: var(--radius-lg);
  }
  dialog footer {
    flex-direction: column;
    align-items: stretch;
  }
  dialog footer button {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .cards {
    grid-template-columns: 1fr 1fr;
  }
  .header-title-block h1 {
    font-size: 16px;
  }
  .brand {
    padding: 14px 16px;
  }
  .kv {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .kv > span:last-child {
    text-align: left;
  }
  .cards.compact-cards {
    grid-template-columns: 1fr;
  }
  .disclosure-description {
    display: 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;
  }
}
