/* ==========================================================================
   Refract — Modern Premium Infrastructure Platform Design System
   Light-first architectural aesthetic with full dark mode parity
   ========================================================================== */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg-canvas: #f8f9fb;
  --bg-surface: #ffffff;
  --bg-subtle: #f2f4f8;
  --bg-inset: #eef1f6;
  --bg-hover: #eaedf4;
  --bg-elevated: #ffffff;
  --bg-backdrop: rgba(15, 23, 42, 0.36);

  /* Typography */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #526074;
  --text-faint: #64748b;
  --text-inverse: #ffffff;

  /* Hairline Borders */
  --border-subtle: rgba(15, 23, 42, 0.06);
  --border-default: #e2e6ef;
  --border-strong: #cbd2e1;

  /* Brand Accent — Restrained Precision Indigo */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-active: #3730a3;
  --accent-soft: rgba(79, 70, 229, 0.08);
  --accent-soft-strong: rgba(79, 70, 229, 0.14);
  --accent-border: rgba(79, 70, 229, 0.24);

  /* Semantic Status Palette */
  --emerald: #059669;
  --emerald-soft: rgba(5, 150, 105, 0.09);
  --emerald-border: rgba(5, 150, 105, 0.22);

  --sky: #0284c7;
  --sky-soft: rgba(2, 132, 199, 0.09);
  --sky-border: rgba(2, 132, 199, 0.22);

  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.1);
  --amber-border: rgba(217, 119, 6, 0.25);

  --rose: #dc2626;
  --rose-hover: #b91c1c;
  --rose-soft: rgba(220, 38, 38, 0.09);
  --rose-border: rgba(220, 38, 38, 0.22);

  /* Legacy chart palette aliases */
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --border: var(--border-default);
  --panel: var(--bg-surface);
  --blue: var(--sky);
  --green: var(--emerald);
  --red: var(--rose);

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px -4px rgba(15, 23, 42, 0.08), 0 12px 32px -8px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.14), 0 28px 64px -16px rgba(15, 23, 42, 0.18);

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 11px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 999px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --sidebar-expanded: 226px;
  --sidebar-collapsed: 64px;
  --sidebar-width: var(--sidebar-expanded);
  --topbar-height: 56px;
  --content-max: 1340px;

  /* Font Stacks */
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-canvas: #0b0d12;
  --bg-surface: #12151d;
  --bg-subtle: #0e1117;
  --bg-inset: #171b26;
  --bg-hover: #1d2230;
  --bg-elevated: #161a24;
  --bg-backdrop: rgba(2, 4, 10, 0.68);

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #8d9bb0;
  --text-inverse: #0b0d12;

  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-active: #4f46e5;
  --accent-soft: rgba(129, 140, 248, 0.13);
  --accent-soft-strong: rgba(129, 140, 248, 0.2);
  --accent-border: rgba(129, 140, 248, 0.3);

  --emerald: #34d399;
  --emerald-soft: rgba(52, 211, 153, 0.12);
  --emerald-border: rgba(52, 211, 153, 0.26);

  --sky: #38bdf8;
  --sky-soft: rgba(56, 189, 248, 0.12);
  --sky-border: rgba(56, 189, 248, 0.26);

  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --amber-border: rgba(251, 191, 36, 0.28);

  --rose: #f87171;
  --rose-hover: #ef4444;
  --rose-soft: rgba(248, 113, 113, 0.13);
  --rose-border: rgba(248, 113, 113, 0.28);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 16px -4px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.45), 0 16px 40px -10px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6), 0 32px 72px -16px rgba(0, 0, 0, 0.72);
}

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

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg-canvas); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.48; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
svg { display: block; width: 16px; height: 16px; stroke-width: 1.75; flex-shrink: 0; }
i[data-lucide] { display: block; width: 16px; height: 16px; flex: 0 0 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft-strong); color: var(--text-primary); }

.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: 10px; left: 10px; z-index: 200;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--text-primary); color: var(--bg-surface);
  font-size: 12.5px; font-weight: 600;
  transform: translateY(-160%); transition: transform 160ms var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

.mono, .tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.num { font-variant-numeric: tabular-nums; }

/* Subtle architectural grid overlay for auth pages */
.grid-backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(ellipse 75% 45% at 50% -8%, var(--accent-soft-strong), transparent 70%),
    linear-gradient(to right, var(--border-subtle) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border-subtle) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
  mask-image: radial-gradient(ellipse 85% 75% at 50% 25%, #000 35%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 25%, #000 35%, transparent 100%);
}

/* ==========================================================================
   Shared Components: Buttons, Inputs, Toggles, Badges
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13px; font-weight: 550; line-height: 1; white-space: nowrap;
  transition: background-color 150ms var(--ease-std), border-color 150ms var(--ease-std),
              color 150ms var(--ease-std), box-shadow 150ms var(--ease-std), transform 120ms var(--ease-out);
}
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn svg, .btn i[data-lucide] { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #ffffff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
:root[data-theme="dark"] .btn-primary {
  background: #6366f1; border-color: #6366f1; color: #ffffff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
:root[data-theme="dark"] .btn-primary:hover:not(:disabled) { background: #4f46e5; border-color: #4f46e5; }

.btn-secondary {
  background: var(--bg-surface); border-color: var(--border-default); color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--rose); border-color: var(--rose); color: #ffffff;
  box-shadow: 0 1px 2px rgba(220, 38, 38, 0.24);
}
:root[data-theme="dark"] .btn-danger { background: #dc2626; border-color: #dc2626; color: #ffffff; }
.btn-danger:hover:not(:disabled) { background: var(--rose-hover); border-color: var(--rose-hover); }
:root[data-theme="dark"] .btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }

.btn-danger-soft {
  background: var(--rose-soft); border-color: var(--rose-border); color: var(--rose);
}
.btn-danger-soft:hover:not(:disabled) { background: var(--rose); border-color: var(--rose); color: #ffffff; }
:root[data-theme="dark"] .btn-danger-soft:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; color: #ffffff; }

.btn-emerald-soft {
  background: var(--emerald-soft); border-color: var(--emerald-border); color: var(--emerald);
}
.btn-emerald-soft:hover:not(:disabled) { background: var(--emerald); border-color: var(--emerald); color: #ffffff; }
:root[data-theme="dark"] .btn-emerald-soft:hover:not(:disabled) { background: #059669; border-color: #059669; color: #ffffff; }

.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12px; gap: 5px; border-radius: var(--radius-xs); }
.btn-sm svg, .btn-sm i[data-lucide] { width: 13.5px; height: 13.5px; }
.btn-lg { min-height: 40px; padding: 0 18px; font-size: 13.5px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-muted);
  transition: background-color 140ms var(--ease-std), color 140ms var(--ease-std), border-color 140ms var(--ease-std);
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn.bordered { border-color: var(--border-default); background: var(--bg-surface); box-shadow: var(--shadow-xs); }
.icon-btn.bordered:hover:not(:disabled) { border-color: var(--border-strong); background: var(--bg-subtle); }
.icon-btn.danger:hover:not(:disabled) { background: var(--rose-soft); color: var(--rose); border-color: var(--rose-border); }
.icon-btn svg, .icon-btn i[data-lucide] { width: 15.5px; height: 15.5px; }

/* Form Inputs */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12.5px; font-weight: 550; color: var(--text-secondary);
}
.field-label .required-mark { color: var(--rose); margin-left: 2px; }
.field-hint { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; }
.field-error {
  margin: 0; padding: 8px 11px; border-radius: var(--radius-xs);
  border: 1px solid var(--rose-border); background: var(--rose-soft);
  color: var(--rose); font-size: 12.5px; line-height: 1.45;
  display: flex; align-items: center; gap: 7px;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="time"],
select,
textarea {
  width: 100%; min-height: 36px; padding: 7px 11px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--bg-surface); color: var(--text-primary);
  font-size: 13px; outline: none; box-shadow: var(--shadow-xs);
  transition: border-color 140ms var(--ease-std), box-shadow 140ms var(--ease-std), background-color 140ms var(--ease-std);
}
textarea { resize: vertical; line-height: 1.55; min-height: 78px; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-subtle); color: var(--text-muted); cursor: not-allowed; opacity: 0.8;
}
input.is-invalid { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-soft); }

.input-with-unit {
  display: flex; align-items: stretch;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--bg-surface); box-shadow: var(--shadow-xs); overflow: hidden;
  transition: border-color 140ms var(--ease-std), box-shadow 140ms var(--ease-std);
}
.input-with-unit:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-with-unit input {
  border: 0; border-radius: 0; box-shadow: none; background: transparent; min-width: 0;
}
.input-with-unit input:focus { box-shadow: none; }
.input-unit {
  display: inline-flex; align-items: center; padding: 0 10px;
  border-left: 1px solid var(--border-subtle); background: var(--bg-subtle);
  color: var(--text-muted); font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  white-space: nowrap; flex-shrink: 0;
}

.password-wrap { position: relative; }
.password-wrap input { padding-right: 40px; }
.password-wrap .icon-btn { position: absolute; top: 2px; right: 2px; width: 32px; height: 32px; }

.search-input-wrap { position: relative; min-width: 240px; }
.search-input-wrap > svg, .search-input-wrap > i[data-lucide] {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14.5px; height: 14.5px; color: var(--text-faint); pointer-events: none;
}
.search-input-wrap input { padding-left: 32px; min-height: 32px; font-size: 12.5px; }

/* Animated Switch Toggle */
.switch {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  user-select: none; white-space: nowrap; font-size: 13px; font-weight: 500; color: var(--text-primary);
}
.switch > span { white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch-track {
  position: relative; width: 36px; height: 20px; flex: 0 0 36px;
  border-radius: var(--radius-pill); background: var(--border-strong);
  transition: background-color 180ms var(--ease-out);
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #ffffff; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 180ms var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.45; cursor: not-allowed; }
.switch input:disabled ~ span { opacity: 0.55; }

/* Badges & Status Indicators */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 22px; padding: 0 8px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-default); background: var(--bg-subtle);
  color: var(--text-secondary); font-size: 11.5px; font-weight: 550;
  white-space: nowrap; line-height: 1;
}
.badge svg, .badge i[data-lucide] { width: 12px; height: 12px; }
.badge-emerald { border-color: var(--emerald-border); background: var(--emerald-soft); color: var(--emerald); }
.badge-sky { border-color: var(--sky-border); background: var(--sky-soft); color: var(--sky); }
.badge-amber { border-color: var(--amber-border); background: var(--amber-soft); color: var(--amber); }
.badge-rose { border-color: var(--rose-border); background: var(--rose-soft); color: var(--rose); }
.badge-accent { border-color: var(--accent-border); background: var(--accent-soft); color: var(--accent); }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: 0 0 7px;
  background: var(--emerald);
}
.status-dot.pulse { box-shadow: 0 0 0 3px var(--emerald-soft); animation: dot-breathe 2.6s ease-in-out infinite; }
.status-dot.amber { background: var(--amber); }
.status-dot.rose { background: var(--rose); }
.status-dot.muted { background: var(--text-faint); }

@keyframes dot-breathe {
  0%, 100% { box-shadow: 0 0 0 3px var(--emerald-soft); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

@keyframes spin { to { transform: rotate(360deg); } }
.spinning { animation: spin 0.8s linear infinite; }

/* Skeleton shimmer */
.skeleton {
  position: relative; overflow: hidden; border-radius: var(--radius-xs);
  background: var(--bg-inset); color: transparent !important; user-select: none;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
:root[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ==========================================================================
   Authentication Pages (/login, /setup)
   ========================================================================== */

.auth-page {
  min-height: 100vh;
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--bg-canvas);
}

.auth-topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; max-width: 1120px; width: 100%; margin: 0 auto;
}
.auth-back {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  transition: color 140ms ease, background-color 140ms ease;
}
.auth-back:hover { color: var(--text-primary); background: var(--bg-hover); }

.auth-main {
  position: relative; z-index: 2;
  display: grid; place-items: center; padding: 20px 18px 40px;
}

.auth-card {
  width: min(100%, 416px);
  padding: 32px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
  animation: fade-rise 280ms var(--ease-out) both;
}

.auth-brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.brand-avatar {
  width: 38px; height: 38px; flex: 0 0 38px; overflow: hidden;
  border-radius: 10px; border: 1px solid var(--border-default);
  background: var(--bg-subtle); display: grid; place-items: center;
}
.brand-avatar img { width: 100%; height: 100%; object-fit: cover; }
.auth-brand-text strong { display: block; font-size: 15px; font-weight: 650; letter-spacing: -0.015em; }
.auth-brand-text span { display: block; font-size: 12px; color: var(--text-muted); }

.auth-header { margin-bottom: 22px; }
.auth-header .badge { margin-bottom: 10px; }
.auth-header h1 { margin: 0 0 6px; font-size: 22px; font-weight: 650; letter-spacing: -0.025em; }
.auth-header p { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }

.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form .btn-primary { margin-top: 6px; min-height: 40px; }

.password-checks {
  display: grid; gap: 5px; margin-top: 2px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg-subtle); border: 1px solid var(--border-subtle);
}
.password-check {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-muted);
  transition: color 150ms ease;
}
.password-check svg { width: 13.5px; height: 13.5px; }
.password-check.pass { color: var(--emerald); }

.turnstile-box {
  padding: 12px; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-subtle);
}
.turnstile-label {
  margin: 0 0 9px; display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 550; color: var(--text-secondary);
}
.turnstile-label svg { width: 14px; height: 14px; color: var(--accent); }
.turnstile-box iframe { max-width: 100%; }

.auth-card-footer {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 12px; color: var(--text-faint);
}
.auth-card-footer svg { width: 14px; height: 14px; }

.auth-page-footer {
  position: relative; z-index: 2;
  padding: 16px 24px; text-align: center;
  font-size: 12px; color: var(--text-faint);
}

/* ==========================================================================
   Admin Console Shell
   ========================================================================== */

.panel-page { background: var(--bg-canvas); }
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar — Compact Tactile Linear-style Navigation */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-width);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border-default);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-subtle) 100%);
  transition: width 240ms var(--ease-out), transform 260ms var(--ease-out);
}
body.boot-no-transition .sidebar,
body.boot-no-transition .workspace { transition: none !important; }

.sidebar-brand {
  height: var(--topbar-height); padding: 0 12px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0; position: relative;
}
.brand-avatar-wrap { position: relative; flex: 0 0 30px; width: 30px; height: 30px; }
.sidebar-brand .brand-avatar { width: 30px; height: 30px; border-radius: 9px; box-shadow: var(--shadow-xs); }
.brand-presence {
  position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--emerald);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 1px var(--emerald-border);
}
.sidebar-brand-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.sidebar-brand-copy strong {
  font-size: 13.5px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand-copy small {
  font-family: var(--font-mono); font-size: 10px; font-weight: 550; letter-spacing: 0.03em;
  color: var(--text-faint); line-height: 1.1; text-transform: uppercase;
}
.sidebar-collapse-btn {
  width: 26px; height: 26px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  transition: background-color 150ms ease, color 150ms ease, transform 180ms var(--ease-out);
}
.sidebar-collapse-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-collapse-btn:active { transform: scale(0.92); }

.sidebar-nav {
  position: relative; flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 10px 9px 14px;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-hover-pill {
  position: absolute; z-index: 0; top: 0; left: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  opacity: 0; pointer-events: none;
  transition: transform 170ms var(--ease-out), width 170ms var(--ease-out), height 170ms var(--ease-out), opacity 130ms ease;
}
.nav-hover-pill.visible { opacity: 1; }

.nav-active-pill {
  position: absolute; z-index: 1; top: 0; left: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xs);
  opacity: 0; pointer-events: none;
  transition: transform 230ms var(--ease-out), width 230ms var(--ease-out), height 230ms var(--ease-out), opacity 140ms ease;
}
.nav-active-pill::before {
  content: ""; position: absolute; left: -1px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-active-pill.ready { opacity: 1; }

.nav-group { position: relative; z-index: 2; }
.nav-group + .nav-group { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border-subtle); }
.nav-group-label {
  margin: 0 0 4px; padding: 0 9px;
  font-size: 10px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint); white-space: nowrap; overflow: hidden;
  transition: opacity 160ms ease;
}

.nav-item {
  width: 100%; height: 33px; padding: 0 9px; margin: 1px 0;
  display: flex; align-items: center; gap: 9px;
  border-radius: var(--radius-sm); background: transparent;
  color: var(--text-secondary); font-size: 12.8px; font-weight: 500;
  text-align: left; white-space: nowrap; overflow: hidden;
  transition: color 150ms ease, transform 120ms var(--ease-out);
}
.nav-item:active { transform: scale(0.985); }
.nav-item svg, .nav-item i[data-lucide] {
  width: 15px; height: 15px; color: var(--text-muted);
  transition: color 150ms ease, transform 180ms var(--ease-out);
}
.nav-item:hover { color: var(--text-primary); }
.nav-item:hover svg, .nav-item:hover i[data-lucide] { color: var(--text-primary); transform: scale(1.08); }
.nav-item.active { color: var(--text-primary); font-weight: 600; }
.nav-item.active svg, .nav-item.active i[data-lucide] { color: var(--accent); transform: scale(1.04); }
.nav-item-badge {
  margin-left: auto; padding: 1px 6px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-mono); font-size: 10px; font-weight: 650; font-style: normal;
}

.sidebar-footer {
  padding: 8px 9px 10px; border-top: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
}

.sidebar-update-btn {
  width: 100%; height: 30px; padding: 0 9px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 11.5px; text-align: left;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.sidebar-update-btn svg, .sidebar-update-btn i[data-lucide] { width: 14px; height: 14px; }
.sidebar-update-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-update-btn.available {
  border-color: var(--accent-border); background: var(--accent-soft); color: var(--accent);
}
.sidebar-update-btn.available:hover { background: var(--accent-soft-strong); }
.sidebar-update-meta { min-width: 0; flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.sidebar-update-meta span { font-family: var(--font-mono); font-size: 11px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.update-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 7px; box-shadow: 0 0 0 3px var(--accent-soft); animation: dot-breathe 2.4s infinite; }

.sidebar-account {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px;
  border-radius: 9px; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); box-shadow: var(--shadow-xs);
  transition: border-color 150ms ease;
}
.sidebar-account:hover { border-color: var(--border-default); }
.account-avatar {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 7px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700; overflow: hidden;
}
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-meta { min-width: 0; flex: 1; }
.account-meta strong { display: block; font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-meta small { display: block; font-size: 10.5px; color: var(--text-muted); line-height: 1.15; }
.sidebar-account .icon-btn { width: 26px; height: 26px; }
.sidebar-account .icon-btn:hover { background: var(--rose-soft); color: var(--rose); }

/* Floating Tooltip for Collapsed Sidebar Rail */
.sidebar-tooltip {
  position: fixed; z-index: 80; pointer-events: none;
  padding: 5px 10px; border-radius: 7px;
  background: var(--text-primary); color: var(--bg-surface);
  font-size: 12px; font-weight: 550; white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0; transform: translate(-4px, -50%);
  transition: opacity 130ms ease, transform 160ms var(--ease-out);
}
.sidebar-tooltip.visible { opacity: 1; transform: translate(0, -50%); }

/* Collapsed Sidebar State (Desktop only so mobile slide-out drawer always displays labels) */
@media (min-width: 861px) {
  body.sidebar-collapsed { --sidebar-width: var(--sidebar-collapsed); }
  body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0 8px; }
  body.sidebar-collapsed .sidebar-brand-copy,
  body.sidebar-collapsed .nav-group-label,
  body.sidebar-collapsed .nav-item span,
  body.sidebar-collapsed .nav-item-badge,
  body.sidebar-collapsed .sidebar-update-meta,
  body.sidebar-collapsed .account-meta { display: none; }
  body.sidebar-collapsed .sidebar-collapse-btn {
    position: absolute; right: -12px; top: 15px; z-index: 5;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--bg-surface); border: 1px solid var(--border-default); box-shadow: var(--shadow-sm);
  }
  body.sidebar-collapsed .nav-group + .nav-group { margin-top: 8px; padding-top: 8px; }
  body.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
  body.sidebar-collapsed .nav-active-pill::before { left: 0; top: 8px; bottom: 8px; }
  body.sidebar-collapsed .sidebar-update-btn { justify-content: center; padding: 0; }
  body.sidebar-collapsed .sidebar-account { flex-direction: column; padding: 6px 4px; gap: 5px; }
}

.sidebar-scrim {
  position: fixed; inset: 0; z-index: 35;
  background: var(--bg-backdrop); border: 0;
  animation: fade-in 180ms ease both;
}

/* Main Workspace */
.workspace {
  flex: 1; min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex; flex-direction: column; min-height: 100vh;
  transition: margin-left 220ms var(--ease-out);
}
.workspace.full-width { --content-max: 100%; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 25;
  height: var(--topbar-height); padding: 0 24px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border-default);
  background: color-mix(in srgb, var(--bg-canvas) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.mobile-menu-btn { display: none; }

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-size: 13px; color: var(--text-muted);
}
.topbar-breadcrumb-sep { color: var(--text-faint); }
.topbar-breadcrumb strong {
  color: var(--text-primary); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-spacer { flex: 1; }

.live-pulse-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 11px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-default); background: var(--bg-surface);
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-secondary);
  box-shadow: var(--shadow-xs); white-space: nowrap;
}
.live-pulse-pill .rate-up { color: var(--emerald); font-weight: 600; }
.live-pulse-pill .rate-down { color: var(--sky); font-weight: 600; }
.live-pulse-sep { width: 1px; height: 12px; background: var(--border-default); }

.command-trigger {
  display: inline-flex; align-items: center; gap: 9px;
  height: 32px; min-width: 210px; padding: 0 10px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--bg-surface); color: var(--text-muted);
  font-size: 12.5px; box-shadow: var(--shadow-xs); overflow: hidden;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}
.command-trigger:hover { border-color: var(--border-strong); color: var(--text-primary); }
.command-trigger svg { width: 14px; height: 14px; }
.command-trigger > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-trigger kbd {
  margin-left: auto; padding: 2px 5px; border-radius: 4px;
  border: 1px solid var(--border-default); background: var(--bg-subtle);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); line-height: 1;
}

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

/* Main Content Area */
.content {
  flex: 1; width: 100%; max-width: var(--content-max);
  margin: 0 auto; padding: 24px 28px 48px;
}

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-header-copy { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-header-icon {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
  border: 1px solid var(--border-default); background: var(--bg-surface);
  color: var(--accent); display: grid; place-items: center; box-shadow: var(--shadow-xs);
}
.page-header-icon svg, .page-header-icon i[data-lucide] { width: 18px; height: 18px; }
.page-header h1 {
  margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.2;
}
.page-header p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-muted); }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Views */
.view { display: none; }
.view.active {
  display: flex; flex-direction: column; gap: 18px;
  animation: view-enter 200ms var(--ease-out) both;
}

@keyframes view-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   Surfaces, Cards, Metrics, Segmented Controls
   ========================================================================== */

.surface {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.surface-pad { padding: 18px 20px; }

.surface-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.surface-header.flush { padding: 0 0 14px; margin-bottom: 14px; }
.surface-title { min-width: 0; }
.surface-title h2 {
  margin: 0; font-size: 14px; font-weight: 620; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.surface-title h2 svg { width: 15px; height: 15px; color: var(--text-muted); }
.surface-title p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.surface-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* KPI Strip (Crisp architectural hairline grid, not bloated boxes) */
.kpi-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  background: var(--bg-surface); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.kpi-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi-cell {
  position: relative; padding: 16px 18px; min-width: 0;
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 6px;
  transition: background-color 150ms ease;
}
.kpi-cell:last-child { border-right: 0; }
.kpi-cell:hover { background: color-mix(in srgb, var(--bg-subtle) 55%, transparent); }

.kpi-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.kpi-label { font-size: 12px; font-weight: 500; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-chip {
  width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--bg-subtle); color: var(--text-muted);
}
.kpi-chip svg, .kpi-chip i[data-lucide] { width: 13.5px; height: 13.5px; }
.kpi-chip.emerald { background: var(--emerald-soft); color: var(--emerald); }
.kpi-chip.sky { background: var(--sky-soft); color: var(--sky); }
.kpi-chip.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-chip.rose { background: var(--rose-soft); color: var(--rose); }
.kpi-chip.accent { background: var(--accent-soft); color: var(--accent); }

.kpi-value {
  font-size: 22px; font-weight: 660; letter-spacing: -0.025em; line-height: 1.15;
  font-variant-numeric: tabular-nums; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-sub {
  font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Segmented Controls & Tabs */
.segmented {
  position: relative; display: inline-flex; align-items: center; padding: 3px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-default);
  background: var(--bg-subtle); isolation: isolate; max-width: 100%;
  overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented-indicator {
  position: absolute; z-index: 0; top: 0; left: 0;
  border-radius: var(--radius-xs); background: var(--bg-surface);
  border: 1px solid var(--border-subtle); box-shadow: var(--shadow-xs);
  opacity: 0; pointer-events: none;
  transition: transform 200ms var(--ease-out), width 200ms var(--ease-out), height 200ms var(--ease-out), opacity 120ms ease;
}
.segmented-indicator.ready { opacity: 1; }
.segmented button {
  position: relative; z-index: 1; height: 28px; padding: 0 11px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius-xs); color: var(--text-muted);
  font-size: 12px; font-weight: 550; white-space: nowrap;
  transition: color 140ms ease;
}
.segmented button:hover { color: var(--text-primary); }
.segmented button.active { color: var(--text-primary); font-weight: 600; }
.segmented button small {
  font-family: var(--font-mono); font-size: 10.5px; opacity: 0.72;
}

/* ==========================================================================
   Tables & Compact Lists
   ========================================================================== */

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  padding: 10px 16px; text-align: left;
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  background: var(--bg-subtle); border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 16px; border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle; color: var(--text-primary);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background-color 120ms ease; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--bg-subtle) 65%, transparent); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table th.num-col, .data-table td.num-col { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table td.actions-col, .data-table th.actions-col { text-align: right; white-space: nowrap; width: 1%; }

.cell-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-primary { font-weight: 560; color: var(--text-primary); overflow-wrap: break-word; }
.cell-secondary { font-size: 11.5px; color: var(--text-muted); overflow-wrap: break-word; }
.nowrap { white-space: nowrap; }
.cell-meta-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.meta-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 500;
  background: var(--bg-subtle); border: 1px solid var(--border-subtle); color: var(--text-secondary);
}
.meta-tag.accent { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.meta-tag.sky { background: var(--sky-soft); border-color: var(--sky-border); color: var(--sky); }
.meta-tag.amber { background: var(--amber-soft); border-color: var(--amber-border); color: var(--amber); }
.meta-tag.rose { background: var(--rose-soft); border-color: var(--rose-border); color: var(--rose); }

.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; }

.empty-state {
  padding: 36px 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text-muted);
}
.empty-state-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--bg-subtle); border: 1px solid var(--border-subtle);
  color: var(--text-faint); display: grid; place-items: center; margin-bottom: 2px;
}
.empty-state strong { font-size: 13.5px; font-weight: 600; color: var(--text-secondary); }
.empty-state p { margin: 0; font-size: 12.5px; color: var(--text-muted); max-width: 360px; }

/* Inline List (Overview Cards) */
.compact-list { display: flex; flex-direction: column; }
.compact-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 20px; border-bottom: 1px solid var(--border-subtle);
  transition: background-color 120ms ease;
}
.compact-row:last-child { border-bottom: 0; }
.compact-row:hover { background: color-mix(in srgb, var(--bg-subtle) 65%, transparent); }
.compact-row-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.compact-row-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ==========================================================================
   Overview View — Charts, Map, Feeds
   ========================================================================== */

.overview-top-grid {
  display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); gap: 18px;
}
.overview-two-col {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px;
}

.chart-stage { width: 100%; height: 248px; padding: 8px 12px 12px; position: relative; }
.echart-canvas { width: 100%; height: 100%; }
.chart-empty-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12.5px; color: var(--text-muted); pointer-events: none;
}

/* Geography Workspace (3D Dot-Matrix Globe + 2D Map) */
.geo-layout {
  display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(276px, 0.85fr);
  border-bottom: 1px solid var(--border-subtle);
}
.map-viewport {
  position: relative; height: 416px; overflow: hidden;
  background: radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--accent-soft) 55%, transparent), color-mix(in srgb, var(--sky-soft) 22%, transparent) 46%, transparent 74%);
  border-right: 1px solid var(--border-subtle);
}
[data-theme="dark"] .map-viewport.is-globe-mode {
  background: radial-gradient(circle at 50% 48%, rgba(79, 70, 229, 0.16), rgba(14, 165, 233, 0.06) 44%, rgba(9, 12, 20, 0.45) 78%);
}
#geography-map { width: 100%; height: 100%; }
.geo-globe-canvas {
  display: block; width: 100%; height: 100%;
  cursor: grab; touch-action: none; user-select: none;
}
.geo-globe-canvas.is-dragging { cursor: grabbing; }
.geo-globe-tooltip {
  position: absolute; left: 0; top: 0; z-index: 8; pointer-events: none;
  max-width: 248px; padding: 8px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: color-mix(in srgb, var(--bg-elevated) 95%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md);
  font-size: 12px; line-height: 1.48; color: var(--text-primary);
}
.geo-globe-tooltip strong { display: block; font-size: 12.5px; font-weight: 650; margin-bottom: 2px; }
.geo-globe-tooltip span { display: block; color: var(--text-secondary); font-size: 11.5px; }
.geo-globe-legend {
  position: absolute; left: 14px; bottom: 12px; z-index: 4;
  display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 5px 11px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
  backdrop-filter: blur(8px);
  font-size: 11px; color: var(--text-muted);
  pointer-events: none;
}
.geo-legend-item { display: inline-flex; align-items: center; gap: 5px; font-weight: 550; color: var(--text-secondary); }
.geo-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.geo-legend-dot.is-node { background: var(--accent); box-shadow: 0 0 0 2.5px var(--accent-soft); }
.geo-legend-dot.is-visitor { background: var(--emerald); box-shadow: 0 0 0 2.5px var(--emerald-soft); }
.geo-legend-hint { padding-left: 8px; border-left: 1px solid var(--border-subtle); color: var(--text-faint); }
.map-empty {
  position: absolute; inset: 0; margin: 0;
  display: grid; place-items: center;
  font-size: 12.5px; color: var(--text-muted); pointer-events: none;
}
.map-controls {
  position: absolute; top: 14px; right: 14px; z-index: 4;
  display: flex; flex-direction: column; gap: 4px; padding: 4px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-default);
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}
.map-controls .icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.geo-sidebar {
  display: flex; flex-direction: column; padding: 16px 18px; gap: 14px;
  background: color-mix(in srgb, var(--bg-subtle) 35%, var(--bg-surface));
}
.geo-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.geo-stat-card {
  padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
}
.geo-stat-card.wide { grid-column: 1 / -1; }
.geo-stat-card span { display: block; font-size: 11px; color: var(--text-muted); }
.geo-stat-card strong { display: block; margin-top: 3px; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.geo-stat-card small { display: block; margin-top: 2px; font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.geo-rank-box { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.geo-rank-box h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.geo-rank-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--border-subtle); font-size: 12.5px;
}
.geo-rank-row:last-child { border-bottom: 0; }
.geo-rank-row strong { font-family: var(--font-mono); font-size: 12px; color: var(--sky); }

.geo-detail-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle); flex-wrap: wrap;
}

/* Gateway Summary Card next to Trend */
.gateway-pulse-card {
  display: flex; flex-direction: column; height: 100%;
}
.pulse-list { display: flex; flex-direction: column; flex: 1; }
.pulse-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--border-subtle); font-size: 13px;
}
.pulse-item:last-child { border-bottom: 0; }
.pulse-item span { color: var(--text-muted); font-size: 12.5px; }
.pulse-item strong { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ==========================================================================
   Emby Health Monitoring View
   ========================================================================== */

.health-group-header td, .health-group-header th {
  padding: 9px 16px; background: var(--bg-subtle);
  font-size: 12px; font-weight: 650; color: var(--text-secondary);
  border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-subtle);
}
.sla-meter { display: inline-flex; flex-direction: column; gap: 4px; min-width: 66px; }
.sla-meter strong { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.sla-track { width: 64px; height: 4px; border-radius: var(--radius-pill); background: var(--bg-inset); overflow: hidden; }
.sla-fill { height: 100%; border-radius: inherit; background: var(--emerald); }
.sla-fill.warn { background: var(--amber); }
.sla-fill.bad { background: var(--rose); }

/* ==========================================================================
   Requests & Pagination
   ========================================================================== */

.filter-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.filter-bar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; min-width: 0; }
.filter-bar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.pagination-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle); font-size: 12.5px; color: var(--text-muted);
  flex-wrap: wrap;
}
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.pagination-controls select { width: auto; min-height: 30px; padding: 3px 26px 3px 9px; font-size: 12px; }

/* ==========================================================================
   Reports View
   ========================================================================== */

.report-charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.report-chart-box { width: 100%; height: 270px; padding: 8px 12px 12px; }
.report-region-grid { display: grid; grid-template-columns: minmax(280px, 0.95fr) minmax(0, 1.35fr); }
.report-region-chart-wrap {
  height: 310px; padding: 12px; border-right: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Unified In-Page Secondary Navigation Tabs (Settings & Access Policies)
   Replaces bulky double-sidebar rails and tall card tabs with a crisp 42px strip
   ========================================================================== */

.subnav-tabs {
  display: flex; align-items: center; gap: 4px;
  border-bottom: 1px solid var(--border-default);
  margin-top: -6px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.subnav-tabs::-webkit-scrollbar { display: none; }

.subnav-tab {
  position: relative; flex: 0 0 auto;
  height: 40px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  white-space: nowrap;
  transition: color 140ms ease;
}
.subnav-tab::before {
  content: ""; position: absolute; inset: 4px 2px;
  border-radius: var(--radius-xs); background: transparent;
  transition: background-color 140ms ease; z-index: 0;
}
.subnav-tab::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px;
  border-radius: 2px 2px 0 0; background: var(--accent);
  transform: scaleX(0); opacity: 0;
  transition: transform 200ms var(--ease-out), opacity 140ms ease;
}
.subnav-tab > * { position: relative; z-index: 1; }
.subnav-tab svg, .subnav-tab i[data-lucide] { width: 14.5px; height: 14.5px; color: var(--text-faint); transition: color 140ms ease; }
.subnav-tab:hover { color: var(--text-primary); }
.subnav-tab:hover::before { background: var(--bg-hover); }
.subnav-tab:hover svg, .subnav-tab:hover i[data-lucide] { color: var(--text-secondary); }
.subnav-tab.active { color: var(--text-primary); font-weight: 600; }
.subnav-tab.active svg, .subnav-tab.active i[data-lucide] { color: var(--accent); }
.subnav-tab.active::after { transform: scaleX(1); opacity: 1; }
.subnav-tab .badge { min-height: 19px; padding: 0 6px; font-size: 10.5px; }

/* ==========================================================================
   Access Policy View (Unified Tabbed Workspace)
   ========================================================================== */

/* Radio Mode Cards */
.mode-cards {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  border: 0; padding: 0; margin: 0;
}
.mode-card {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-default); background: var(--bg-surface);
  cursor: pointer; transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.mode-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mode-card:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.mode-card:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-border);
}
.mode-card strong { font-size: 13px; font-weight: 620; color: var(--text-primary); }
.mode-card small { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

.inline-add-form {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
  gap: 12px; align-items: end;
}
.inline-add-form.cols-2 { grid-template-columns: minmax(0, 1fr) auto; }

/* Quota Usage Bar */
.quota-bar-wrap { display: flex; flex-direction: column; gap: 5px; min-width: 170px; }
.quota-bar-labels { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12px; }
.quota-bar-labels strong { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.quota-bar-labels small { font-size: 11px; color: var(--text-muted); }
.quota-progress-track { width: 100%; height: 5px; border-radius: var(--radius-pill); background: var(--bg-inset); overflow: hidden; }
.quota-progress-fill { height: 100%; border-radius: inherit; background: var(--accent); transition: width 260ms var(--ease-out); }
.quota-bar-wrap.reached .quota-bar-labels strong { color: var(--rose); }
.quota-bar-wrap.reached .quota-progress-fill { background: var(--rose); }

/* 24h Schedule Visual Bar */
.schedule-visual {
  padding: 14px 16px; border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle); background: var(--bg-subtle);
  display: flex; flex-direction: column; gap: 10px;
}
.schedule-timeline {
  position: relative; height: 14px; border-radius: var(--radius-pill);
  background: var(--bg-inset); overflow: hidden; border: 1px solid var(--border-default);
}
.schedule-segment {
  position: absolute; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--accent), var(--emerald));
  border-radius: var(--radius-pill);
}
.schedule-ticks {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint);
}
.schedule-form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(140px, 200px)) 1fr auto;
  gap: 14px; align-items: end;
}

/* ==========================================================================
   Backups View
   ========================================================================== */

.backup-top-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; }
.backup-form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, 150px) auto; gap: 12px; align-items: end; }
.backup-action-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 18px 20px; }
.backup-action-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 14px 16px; border-radius: var(--radius-md);
  border: 1px solid var(--border-default); background: var(--bg-subtle);
  cursor: pointer; text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease;
}
.backup-action-tile:hover { border-color: var(--accent-border); background: var(--accent-soft); }
.backup-action-tile strong { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.backup-action-tile small { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }
.backup-action-tile .tile-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg-surface); border: 1px solid var(--border-default);
  color: var(--accent); display: grid; place-items: center;
}

/* ==========================================================================
   Settings Workspace (Full-width with compact top tab strip)
   ========================================================================== */

.settings-layout { display: flex; flex-direction: column; gap: 18px; }
.settings-stage { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.settings-panel[hidden] { display: none !important; }

.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.span-full { grid-column: 1 / -1; }

.toggle-list { display: flex; flex-direction: column; border: 1px solid var(--border-default); border-radius: var(--radius-md); overflow: hidden; }
.toggle-list-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--border-subtle);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.toggle-live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 550; color: var(--emerald);
}
.toggle-live-dot {
  width: 6px; height: 6px; border-radius: 999px; background: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-soft);
}
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 16px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface);
  transition: background-color 260ms ease, opacity 180ms ease;
}
.toggle-row.is-saving { opacity: 0.65; }
.toggle-row.is-applied { background: var(--emerald-soft); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row-copy strong { display: block; font-size: 13px; font-weight: 600; }
.toggle-row-copy small { display: block; margin-top: 2px; font-size: 12px; color: var(--text-muted); }

.form-footer-bar {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle); flex-wrap: wrap;
}
.form-footer-hint {
  margin-right: auto; font-size: 12px; color: var(--text-muted);
}

/* Edge Nodes & Multi-Node Cluster Controls */
.node-scope-select {
  width: auto; min-height: 0; height: 32px; padding: 0 26px 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default); background-color: var(--bg-surface);
  color: var(--text-primary); font-size: 12.5px; font-weight: 550; line-height: 30px;
  cursor: pointer; max-width: 220px; flex: 0 0 auto;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.node-scope-select:hover { border-color: var(--border-strong); }
.node-scope-select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.badge-sky {
  background: var(--sky-soft); border-color: color-mix(in srgb, var(--sky) 28%, transparent); color: var(--sky);
}
.node-override-section {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--border-default);
  border-radius: var(--radius-md); background: var(--bg-subtle);
}
.node-override-head strong { display: block; font-size: 13px; font-weight: 620; }
.node-override-head small { display: block; margin-top: 2px; font-size: 11.5px; color: var(--text-muted); }

.deploy-token-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.deploy-token-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-default); background: var(--bg-subtle);
}
.deploy-token-box code {
  font-family: var(--font-mono); font-size: 12px; color: var(--accent);
  overflow-wrap: anywhere; word-break: break-all;
}
.deploy-tabs { margin-bottom: 12px; width: 100%; }
.deploy-code-wrap { position: relative; margin-bottom: 10px; }
.deploy-code-box {
  margin: 0; padding: 14px 16px 44px; border-radius: var(--radius-md);
  border: 1px solid var(--border-default); background: var(--bg-subtle);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  color: var(--text-primary); white-space: pre-wrap; word-break: break-all;
  max-height: 240px; overflow: auto;
}
.deploy-copy-btn { position: absolute; right: 10px; bottom: 10px; }
.node-url-copy {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary);
  background: transparent; border: 0; padding: 0; cursor: pointer; text-align: left;
}
.node-url-copy:hover { color: var(--accent); }
.node-url-copy svg { width: 12px; height: 12px; opacity: 0.65; flex-shrink: 0; }
.node-agent-sub {
  max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.node-status-sub { white-space: nowrap; }
#view-nodes .data-table th,
#view-nodes .data-table td {
  padding: 12px 14px;
}
#view-nodes .row-actions {
  gap: 4px;
}
.node-sub-inline {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 450;
}
.node-ip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Controller Slim Mode (Option B) */
.controller-only { display: none !important; }
body.mode-controller .controller-only { display: inline-flex !important; }
body.mode-controller .toggle-row.controller-only { display: flex !important; }
body.mode-controller .controller-hide { display: none !important; }

.overview-export-group {
  display: inline-flex; align-items: center; gap: 6px;
}
.compact-select {
  width: auto; min-height: 0; height: 30px; padding: 0 24px 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default); background-color: var(--bg-surface);
  color: var(--text-primary); font-size: 12px; font-weight: 540; line-height: 28px;
  cursor: pointer; flex: 0 0 auto;
}
.compact-select:hover { border-color: var(--border-strong); }

.advanced-fold {
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--bg-subtle); overflow: hidden;
}
.advanced-fold-summary {
  display: flex; align-items: center; gap: 8px; padding: 11px 16px;
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; list-style: none; user-select: none;
  transition: background-color 140ms ease, color 140ms ease;
}
.advanced-fold-summary::-webkit-details-marker { display: none; }
.advanced-fold-summary:hover { background: var(--bg-surface); color: var(--text-primary); }
.advanced-fold-summary svg { width: 14px; height: 14px; color: var(--text-muted); }
.advanced-fold-chevron { margin-left: auto; transition: transform 180ms ease; }
.advanced-fold[open] .advanced-fold-chevron { transform: rotate(180deg); }
.advanced-fold-body {
  padding: 14px 16px 16px; border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

/* Security Checklist */
.security-rows { display: flex; flex-direction: column; }
.security-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 20px; border-bottom: 1px solid var(--border-subtle);
}
.security-row:last-child { border-bottom: 0; }
.security-row-copy strong { display: block; font-size: 13px; font-weight: 560; }
.security-row-copy small { display: block; font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* Branding Preview */
.branding-stage { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 22px; align-items: center; }
.branding-preview-box {
  width: 120px; height: 120px; border-radius: 22px;
  border: 1px solid var(--border-default); background: var(--bg-subtle);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.branding-preview-box img { width: 100%; height: 100%; object-fit: cover; }
.branding-controls { display: flex; flex-direction: column; gap: 10px; }
.branding-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Turnstile Stepper */
.step-guide {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  margin-bottom: 16px;
}
.step-pill {
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle); background: var(--bg-subtle);
  display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text-muted);
}
.step-pill .step-num {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 20px;
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  background: var(--bg-surface); border: 1px solid var(--border-default); color: var(--text-secondary);
}
.step-pill.done { border-color: var(--emerald-border); background: var(--emerald-soft); color: var(--emerald); }
.step-pill.done .step-num { background: var(--emerald); border-color: var(--emerald); color: #fff; }
:root[data-theme="dark"] .step-pill.done .step-num { background: #059669; border-color: #059669; color: #fff; }

/* ==========================================================================
   Centered Floating Modals (Domain Wizard, Node Config, Emby, Request Detail)
   ========================================================================== */

body.modal-open { overflow: hidden; }

.drawer-root {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  pointer-events: none; opacity: 0;
  transition: opacity 180ms ease;
}
.drawer-root.open { pointer-events: auto; opacity: 1; }
.drawer-scrim {
  position: absolute; inset: 0;
  background: var(--bg-backdrop);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  border: 0;
}
.drawer-panel {
  position: relative; z-index: 1;
  width: min(100%, 560px);
  max-height: min(88vh, 840px);
  height: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(0.975);
  transition: transform 220ms var(--ease-out);
}
.drawer-root.open .drawer-panel { transform: translateY(0) scale(1); }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 22px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0;
}
.drawer-header-main {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.drawer-header h2 { margin: 0; font-size: 15.5px; font-weight: 650; }
.drawer-header p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }

.drawer-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 16px;
}
.drawer-body > *,
.modal-body > * {
  flex-shrink: 0;
}
.drawer-form {
  display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden;
}
#emby-drawer .drawer-panel {
  width: min(100%, 540px);
}
#request-drawer .drawer-panel {
  width: min(100%, 600px);
}
#node-drawer .drawer-panel {
  width: min(100%, 580px);
}
#domain-drawer .drawer-panel {
  width: min(100%, 720px);
}
.drawer-footer {
  padding: 14px 22px; border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle); display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
}
.drawer-footer-left {
  margin-right: auto; display: flex; align-items: center; gap: 8px;
}

.detail-kv-list {
  display: flex; flex-direction: column; border: 1px solid var(--border-default);
  border-radius: var(--radius-md); overflow: hidden;
}
.detail-kv {
  display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); font-size: 12.5px;
}
.detail-kv:last-child { border-bottom: 0; }
.detail-kv dt { color: var(--text-muted); font-weight: 500; }
.detail-kv dd { margin: 0; color: var(--text-primary); overflow-wrap: anywhere; }

/* ==========================================================================
   Modal Dialogs (Command Palette, Version/Release, Confirm, Quota)
   ========================================================================== */

dialog.modal {
  margin: auto; padding: 0; border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); background: var(--bg-surface); color: var(--text-primary);
  box-shadow: var(--shadow-lg); max-width: calc(100vw - 28px);
  overflow: hidden;
}
dialog.modal[open] { animation: modal-in 180ms var(--ease-out) both; }
dialog.modal::backdrop { background: var(--bg-backdrop); backdrop-filter: blur(3px); }
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Command Palette */
.command-dialog { width: 540px; margin-top: min(14vh, 110px) !important; }
.command-search-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.command-search-row > svg { width: 16px; height: 16px; color: var(--text-faint); }
.command-search-row input {
  border: 0; box-shadow: none; background: transparent; padding: 4px 0; min-height: 28px; font-size: 14px;
}
.command-search-row input:focus { box-shadow: none; }
.command-list { max-height: 380px; overflow-y: auto; padding: 8px; }
.command-group-label {
  margin: 8px 8px 4px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint);
}
.command-group-label:first-child { margin-top: 2px; }
.command-item {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  text-align: left; color: var(--text-primary);
  transition: background-color 110ms ease;
}
.command-item:hover, .command-item.focused { background: var(--accent-soft); }
.command-item svg { width: 15.5px; height: 15.5px; color: var(--text-muted); }
.command-item.focused svg, .command-item:hover svg { color: var(--accent); }
.command-item-copy { min-width: 0; flex: 1; }
.command-item-copy strong { display: block; font-size: 13px; font-weight: 560; }
.command-item-copy small { display: block; font-size: 11.5px; color: var(--text-muted); }
.command-item kbd {
  padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border-default);
  background: var(--bg-subtle); font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted);
}
.command-empty { display: block; padding: 28px 16px; text-align: center; font-size: 13px; color: var(--text-muted); }
.command-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle); font-size: 11px; color: var(--text-faint);
}

/* Standard Modal Layout */
.modal-sm { width: 430px; }
.modal-md { width: 580px; }
.modal-header {
  display: flex; align-items: center; gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-icon {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
}
.modal.danger .modal-icon { background: var(--rose-soft); color: var(--rose); }
.modal-header-copy { min-width: 0; flex: 1; }
.modal-header-copy h2 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-header-copy p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.modal-body { padding: 18px 20px; max-height: 62vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 13px 20px; border-top: 1px solid var(--border-subtle); background: var(--bg-subtle);
}

/* Release Notes */
.release-card {
  padding: 14px 16px; border-radius: var(--radius-md);
  border: 1px solid var(--border-default); background: var(--bg-subtle);
}
.release-card.latest { border-color: var(--accent-border); background: var(--accent-soft); }
.release-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.release-card-head h3 { margin: 2px 0 0; font-size: 14.5px; font-weight: 650; }
.release-kicker { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.release-date { margin: 4px 0 10px; font-size: 11.5px; color: var(--text-muted); }
.release-notes { font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; }
.release-notes h4 { margin: 12px 0 4px; font-size: 12.5px; font-weight: 650; color: var(--text-primary); }
.release-notes h4:first-child { margin-top: 0; }
.release-notes ul, .release-notes ol { margin: 4px 0 8px; padding-left: 18px; }
.release-notes li { margin: 3px 0; }
.release-notes p { margin: 5px 0; }
.release-notes pre {
  margin: 8px 0; padding: 10px 12px; border-radius: var(--radius-xs);
  background: var(--bg-surface); border: 1px solid var(--border-default);
  font-family: var(--font-mono); font-size: 11.5px; overflow-x: auto;
}
.diagnostic-box {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--amber-border); background: var(--amber-soft);
}
.diagnostic-box > svg { width: 16px; height: 16px; color: var(--amber); margin-top: 2px; }
.diagnostic-box strong { display: block; font-size: 13px; color: var(--text-primary); }
.diagnostic-box p { margin: 3px 0 0; font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.recovery-cmd {
  margin-top: 8px; display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: var(--radius-xs);
  border: 1px solid var(--border-default); background: var(--bg-surface);
}
.recovery-cmd code {
  flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 11.5px;
  overflow-x: auto; white-space: nowrap;
}

/* ==========================================================================
   Toast Notification Stack
   ========================================================================== */

.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast-item {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-default); background: var(--bg-elevated);
  color: var(--text-primary); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 220ms var(--ease-out) both;
}
.toast-item.closing { animation: toast-out 180ms ease forwards; }
.toast-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast-item.success svg { color: var(--emerald); }
.toast-item.error svg { color: var(--rose); }
.toast-item.warn svg { color: var(--amber); }
.toast-item.info svg { color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.97); } }

/* ==========================================================================
   Responsive Design (Large Desktop, Desktop, Tablet, Mobile)
   ========================================================================== */

@media (max-width: 1260px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-cell { border-bottom: 1px solid var(--border-subtle); }
  .kpi-grid:not(.cols-4) .kpi-cell:nth-child(3n) { border-right: 0; }
  .kpi-grid:not(.cols-4) .kpi-cell:nth-last-child(-n+3) { border-bottom: 0; }
  .kpi-grid.cols-4 .kpi-cell:nth-child(2n) { border-right: 0; }
  .kpi-grid.cols-4 .kpi-cell:nth-last-child(-n+2) { border-bottom: 0; }
  .overview-top-grid { grid-template-columns: 1fr; }
  .geo-layout { grid-template-columns: 1fr; }
  .map-viewport { border-right: 0; border-bottom: 1px solid var(--border-subtle); height: 320px; }
  .report-charts-grid, .report-region-grid { grid-template-columns: 1fr; }
  .report-region-chart-wrap { border-right: 0; border-bottom: 1px solid var(--border-subtle); height: 260px; }
}

@media (max-width: 1024px) {
  .content { padding: 20px 20px 44px; }
  .overview-two-col, .backup-top-grid { grid-template-columns: 1fr; }
  .live-pulse-pill { display: none; }
  .schedule-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar {
    width: var(--sidebar-expanded);
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-collapse-btn { display: none; }
  .workspace { margin-left: 0; }
  .mobile-menu-btn { display: inline-flex; }
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-breadcrumb { display: none; }
  .command-trigger { min-width: 0; flex: 1; }
  .command-trigger kbd { display: none; }
  .search-input-wrap { min-width: 0; width: 100%; }
  .content { padding: 16px 14px 40px; }
  .kpi-grid, .kpi-grid.cols-4, .kpi-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid .kpi-cell { border-right: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); padding: 13px 14px; }
  .kpi-grid .kpi-cell:nth-child(2n),
  .kpi-grid .kpi-cell:last-child { border-right: 0; }
  .kpi-grid .kpi-cell:nth-last-child(-n+2) { border-bottom: 0; }
  .kpi-grid.cols-3 .kpi-cell:nth-last-child(2) { border-bottom: 1px solid var(--border-subtle); }
  .kpi-grid.cols-3 .kpi-cell:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .kpi-value { font-size: 19px; }
  .mode-cards, .form-grid-2, .form-grid-3, .inline-add-form, .backup-form-row, .step-guide { grid-template-columns: 1fr; }
  .branding-stage { grid-template-columns: 1fr; }
  .backup-action-cards { grid-template-columns: 1fr; }
  .drawer-root { padding: 12px; }
  .drawer-panel { width: 100%; max-height: 92vh; border-radius: var(--radius-lg); }
  .domain-flow-strip { grid-template-columns: 1fr; }
  .domain-node-grid { grid-template-columns: 1fr; }
  .domain-wizard-steps { padding: 10px 14px; gap: 6px; }
  .domain-wizard-tab { padding: 8px 10px; font-size: 12px; }
  .surface-header { padding: 12px 14px; }
  .surface-pad { padding: 14px; }
  .filter-bar { padding: 12px 14px; }
  .data-table th, .data-table td { padding: 10px 12px; }
  .compact-row { padding: 11px 14px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .compact-row-side { width: 100%; justify-content: space-between; }
  .toast-stack { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 20px; border-radius: var(--radius-lg); }
  .page-header h1 { font-size: 18px; }
  .schedule-form-grid { grid-template-columns: 1fr; }
  .detail-kv { grid-template-columns: 1fr; gap: 3px; }
}

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

/* ==========================================================================
   Pro Features: Country Chips, Node Monthly Quota Bar, Cloudflare Failover
   ========================================================================== */

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

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.chip-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.chip-toggle.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.node-quota-cell {
  min-width: 120px;
  max-width: 162px;
}

.node-quota-track {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-inset);
  overflow: hidden;
  margin-top: 5px;
}

.node-quota-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--emerald);
  transition: width 240ms ease;
}

.node-quota-fill.warn { background: var(--amber); }
.node-quota-fill.danger { background: var(--rose); }

.failover-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.failover-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.failover-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.failover-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.failover-node-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.failover-node-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  font-size: 12px;
}

.failover-node-chip.is-active {
  border-color: var(--emerald);
  background: var(--emerald-soft);
}

.failover-chip-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 1px 3px;
  cursor: pointer;
  line-height: 1;
  font-size: 11px;
}

.failover-chip-btn:hover { color: var(--text-primary); }

.failover-add-node-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.failover-add-node-bar select {
  width: auto;
  min-width: 180px;
  min-height: 32px;
  height: 32px;
}

.domain-node-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 260px;
}

.domain-node-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.domain-node-pill.online {
  border-color: var(--emerald-border);
  background: var(--emerald-soft);
  color: var(--emerald);
}

.domain-node-pill.draining {
  border-color: var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber);
}

.domain-node-pill.offline {
  border-color: var(--rose-border);
  background: var(--rose-soft);
  color: var(--rose);
}

#view-domains .data-table th,
#view-domains .data-table td {
  padding: 11px 10px;
}

#view-domains .row-actions {
  gap: 3px;
}

#view-domains .cell-stack > .badge {
  align-self: flex-start;
}

#discovery-dialog .modal-body {
  max-height: 74vh;
}

#discovery-dialog .deploy-tabs {
  flex-shrink: 0;
}

/* ==========================================================================
   OpenFlare-style Domain Flow Strip & 3-Step Floating Wizard
   ========================================================================== */

.domain-flow-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.domain-flow-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
  transition: border-color 150ms ease, background-color 150ms ease;
}

.domain-flow-card.is-ready {
  border-color: var(--emerald-border);
  background: color-mix(in srgb, var(--emerald-soft) 36%, var(--bg-surface));
}

.domain-flow-num {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  margin-top: 1px;
}

.domain-flow-card.is-ready .domain-flow-num {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #ffffff;
}
:root[data-theme="dark"] .domain-flow-card.is-ready .domain-flow-num {
  background: #059669;
  border-color: #059669;
  color: #ffffff;
}

.domain-flow-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.domain-flow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.domain-flow-copy strong {
  font-size: 13px;
  font-weight: 620;
  color: var(--text-primary);
}

.domain-flow-copy small {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.domain-flow-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 560;
  color: var(--accent);
  white-space: nowrap;
}

.domain-flow-link:hover {
  text-decoration: underline;
}

/* 3-Step Wizard Stepper inside Floating Domain Modal */
.domain-wizard-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 22px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.domain-wizard-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 550;
  text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.domain-wizard-tab:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.domain-wizard-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 620;
  box-shadow: 0 0 0 1px var(--accent-border);
}

.domain-wizard-tab.done:not(.active) {
  border-color: var(--emerald-border);
  color: var(--text-primary);
}

.wizard-step-idx {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--text-muted);
}

.domain-wizard-tab.active .wizard-step-idx {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
:root[data-theme="dark"] .domain-wizard-tab.active .wizard-step-idx {
  background: #6366f1;
  border-color: #6366f1;
  color: #ffffff;
}

.domain-wizard-tab.done:not(.active) .wizard-step-idx {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #ffffff;
}
:root[data-theme="dark"] .domain-wizard-tab.done:not(.active) .wizard-step-idx {
  background: #059669;
  border-color: #059669;
  color: #ffffff;
}

.wizard-step-badge {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 650;
  font-style: normal;
}

.domain-wizard-tab.active .wizard-step-badge {
  background: var(--accent-soft-strong);
  color: var(--accent);
}

.domain-step-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Step 1 Live Preview & Info Banner */
.domain-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  font-size: 12px;
  flex-wrap: wrap;
}

.domain-preview-url {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  min-width: 0;
}

.domain-preview-url svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.domain-preview-url strong {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.domain-callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.domain-callout > svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--accent);
}

.domain-callout.is-emerald {
  border-color: var(--emerald-border);
  background: var(--emerald-soft);
  color: var(--text-primary);
}

.domain-callout.is-emerald > svg { color: var(--emerald); }

.domain-callout.is-amber {
  border-color: var(--amber-border);
  background: var(--amber-soft);
  color: var(--text-primary);
}

.domain-callout.is-amber > svg { color: var(--amber); }

.domain-callout.is-sky {
  border-color: var(--sky-border);
  background: var(--sky-soft);
  color: var(--text-primary);
}

.domain-callout.is-sky > svg { color: var(--sky); }

.domain-callout-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.domain-callout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Step 2 Visual Selectable Node Cards */
.domain-picker-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.domain-picker-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.domain-picker-title strong {
  font-size: 13px;
  font-weight: 620;
}

.domain-picker-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.domain-node-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 12px 13px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-default);
  background: var(--bg-surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease, transform 120ms var(--ease-out);
}

.domain-node-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.domain-node-card:active {
  transform: scale(0.99);
}

.domain-node-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.domain-node-check {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin-top: 2px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  display: grid;
  place-items: center;
  color: transparent;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.domain-node-check svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.6;
}

.domain-node-card.selected .domain-node-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
:root[data-theme="dark"] .domain-node-card.selected .domain-node-check {
  background: #6366f1;
  border-color: #6366f1;
  color: #ffffff;
}

.domain-node-card-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.domain-node-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.domain-node-card-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  font-weight: 620;
  color: var(--text-primary);
}

.domain-node-card-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.domain-node-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-muted);
}

.domain-node-card-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-faint);
  flex-shrink: 0;
}

.domain-node-card.selected .domain-node-card-tag {
  border-color: var(--accent-border);
  background: var(--bg-surface);
  color: var(--accent);
}

.domain-priority-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
  background: var(--bg-subtle);
}

.domain-priority-box > small {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Step 3 Compact Mode Cards, Manual DNS Records & Summary Pipeline */
.mode-cards.compact .mode-card {
  padding: 10px 12px;
  gap: 3px;
}

.mode-cards.compact .mode-card strong {
  font-size: 12.5px;
}

.mode-cards.compact .mode-card small {
  font-size: 11px;
}

.domain-dns-records {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}

.domain-dns-record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  font-size: 11.5px;
  flex-wrap: wrap;
}

.domain-dns-record-left {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex-wrap: wrap;
}

.domain-dns-record-left code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-primary);
}

.domain-summary-pipeline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  font-size: 12px;
}

.domain-summary-sep {
  color: var(--text-faint);
  font-size: 11px;
}

/* Domain Speed & Per-Machine Limit Rows inside Step 2 */
.domain-speed-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
}

.domain-speed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.domain-speed-head strong {
  font-size: 13px;
  font-weight: 620;
  color: var(--text-primary);
}

.domain-speed-head small {
  font-size: 11.5px;
  color: var(--text-muted);
}

.domain-bound-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.domain-bound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  flex-wrap: wrap;
}

.domain-bound-row-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.domain-bound-row-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.domain-bound-row-name strong {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.domain-bound-row-name small {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.domain-bound-row-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.domain-node-speed-input {
  width: 178px;
}

.domain-node-speed-input input {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 12px;
}

.domain-node-speed-input .input-unit {
  padding: 0 8px;
  font-size: 11px;
}

.domain-bound-order-btns {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.domain-bound-order-btns .icon-btn {
  width: 26px;
  height: 26px;
}

/* ==========================================================================
   Universal Styled Custom Select Dropdowns (Replaces Native OS <select>)
   ========================================================================== */

.cselect-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.cselect-wrap.is-compact,
.cselect-wrap.is-scope {
  width: auto;
  display: inline-flex;
  flex: 0 0 auto;
}

.cselect-wrap.is-scope {
  max-width: 220px;
}

.cselect-native {
  position: absolute !important;
  inset: 0 !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}

.cselect-trigger {
  width: 100%;
  min-height: 36px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 480;
  line-height: 1.3;
  text-align: left;
  box-shadow: var(--shadow-xs);
  transition: border-color 140ms var(--ease-std), box-shadow 140ms var(--ease-std), background-color 140ms var(--ease-std);
}

.cselect-wrap.is-compact .cselect-trigger {
  min-height: 30px;
  height: 30px;
  padding: 0 9px 0 10px;
  font-size: 12px;
  font-weight: 540;
  white-space: nowrap;
}

.cselect-wrap.is-scope .cselect-trigger {
  min-height: 32px;
  height: 32px;
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}

.cselect-trigger:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--bg-subtle) 45%, var(--bg-surface));
}

.cselect-trigger:focus-visible,
.cselect-trigger.open {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.cselect-trigger:disabled {
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.78;
}

.cselect-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cselect-chevron {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 180ms var(--ease-out), color 140ms ease;
}

.cselect-chevron svg {
  width: 14px;
  height: 14px;
}

.cselect-trigger.open .cselect-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.cselect-popover {
  position: fixed;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px;
  max-height: min(268px, 42vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  transform-origin: top center;
  animation: cselect-pop-down 140ms var(--ease-out) both;
}

.cselect-popover.is-up {
  transform-origin: bottom center;
  animation: cselect-pop-up 140ms var(--ease-out) both;
}

@keyframes cselect-pop-down {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cselect-pop-up {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cselect-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 12.8px;
  font-weight: 480;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 110ms ease, color 110ms ease;
}

.cselect-option:hover:not(:disabled),
.cselect-option.focused:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.cselect-option.selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.cselect-option.selected:hover:not(:disabled),
.cselect-option.selected.focused:not(:disabled) {
  background: var(--accent-soft-strong);
  color: var(--accent);
}

.cselect-option:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
  opacity: 0.55;
}

.cselect-option-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cselect-check {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cselect-check svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.4;
}

/* ==========================================================================
   OpenFlare-Style Visual DAG WAF Flow Editor & Domain WAF Binding
   ========================================================================== */

.waf-template-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.waf-flow-summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Full-Studio Centered Floating Modal for Visual WAF Flow Canvas */
#waf-editor-drawer .drawer-panel {
  width: min(96vw, 1280px);
  height: min(90vh, 800px);
  max-height: 92vh;
}

.waf-editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.waf-editor-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 240px;
}

.waf-name-input {
  max-width: 240px;
  min-height: 32px !important;
  height: 32px;
  font-weight: 600;
}

.waf-scope-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  font-size: 12px;
  white-space: nowrap;
}

.waf-editor-topbar-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.waf-editor-topbar-tools .cselect-wrap.is-compact {
  min-width: 152px;
}

.waf-editor-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr) 288px;
  overflow: hidden;
}

/* Left Node Palette */
.waf-palette {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 12px;
  border-right: 1px solid var(--border-default);
  background: var(--bg-subtle);
  overflow-y: auto;
}

.waf-palette-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.waf-palette-label {
  margin: 0 0 2px;
  padding: 0 4px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.waf-palette-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 560;
  text-align: left;
  box-shadow: var(--shadow-xs);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: border-color 140ms ease, background-color 140ms ease, opacity 140ms ease, transform 110ms var(--ease-out);
}

.waf-palette-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.waf-palette-btn:active {
  cursor: grabbing;
  transform: scale(0.985);
}

.waf-palette-btn.is-dragging {
  opacity: 0.48;
  border-style: dashed;
  border-color: var(--accent);
  cursor: grabbing;
}

.waf-palette-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waf-palette-grip {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--text-faint);
  opacity: 0.65;
  transition: color 140ms ease, opacity 140ms ease;
}

.waf-palette-btn:hover .waf-palette-grip {
  color: var(--accent);
  opacity: 1;
}

body.waf-palette-dragging,
body.waf-palette-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}

.waf-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 120;
  pointer-events: none;
  width: 212px;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border-strong);
  background: color-mix(in srgb, var(--bg-surface) 95%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: border-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
  opacity: 0.88;
}

.waf-drag-ghost.over-canvas {
  border-style: solid;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-lg);
  opacity: 0.98;
}

.waf-drag-ghost-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-primary);
}

.waf-drag-ghost-foot {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.waf-drag-ghost.over-canvas .waf-drag-ghost-foot {
  color: var(--accent);
  font-weight: 560;
}

.waf-palette-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.waf-palette-icon svg { width: 13.5px; height: 13.5px; }
.waf-palette-icon.sky { background: var(--sky-soft); color: var(--sky); }
.waf-palette-icon.emerald { background: var(--emerald-soft); color: var(--emerald); }
.waf-palette-icon.amber { background: var(--amber-soft); color: var(--amber); }
.waf-palette-icon.accent { background: var(--accent-soft); color: var(--accent); }
.waf-palette-icon.rose { background: var(--rose-soft); color: var(--rose); }

.waf-palette-tip {
  margin-top: auto;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--bg-surface);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Center Interactive Dot-Grid Flow Canvas */
.waf-canvas-wrap {
  position: relative;
  overflow: hidden;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(circle, var(--border-strong) 1px, transparent 1px);
  background-size: 20px 20px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.waf-canvas-wrap.is-panning {
  cursor: grabbing;
}

.waf-canvas-wrap.is-connecting {
  cursor: crosshair;
}

.waf-canvas-wrap.is-drop-ready {
  box-shadow: inset 0 0 0 2px var(--accent);
  background-color: color-mix(in srgb, var(--accent-soft) 36%, var(--bg-canvas));
}

@keyframes waf-node-drop-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.waf-node.just-dropped {
  animation: waf-node-drop-in 170ms var(--ease-out) both;
}

.waf-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  transform-origin: 0 0;
}

.waf-edges-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 4000px;
  height: 3000px;
  overflow: visible;
  pointer-events: none;
}

.waf-edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 20;
  pointer-events: stroke;
  cursor: pointer;
}

.waf-edge-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  pointer-events: none;
  transition: stroke 120ms ease, stroke-width 120ms ease, filter 120ms ease;
}

.waf-edge-path.port-true { stroke: var(--emerald); }
.waf-edge-path.port-false { stroke: var(--amber); }
.waf-edge-hit:hover + .waf-edge-path {
  stroke: var(--rose);
  stroke-width: 3.1;
}
.waf-edge-path.selected {
  stroke: var(--rose);
  stroke-width: 3.4;
  filter: drop-shadow(0 0 4px var(--rose-border));
}
.waf-edge-path.traced {
  stroke-width: 3.6;
  stroke-dasharray: 8 5;
  animation: waf-dash 0.7s linear infinite;
}

@keyframes waf-dash {
  to { stroke-dashoffset: -26; }
}

.waf-edge-draft {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-dasharray: 6 5;
  stroke-linecap: round;
  pointer-events: none;
}

.waf-edge-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 620;
  line-height: 1.35;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  z-index: 4;
  transition: border-color 120ms ease, transform 120ms ease, background-color 120ms ease;
}

.waf-edge-badge:hover {
  border-color: var(--rose);
  color: var(--rose);
  background: var(--rose-soft);
}

.waf-edge-badge.port-next {
  padding: 1px 6px;
  border-color: var(--accent-border);
  color: var(--accent);
}
.waf-edge-badge.port-true { border-color: var(--emerald-border); color: var(--emerald); }
.waf-edge-badge.port-false { border-color: var(--amber-border); color: var(--amber); }

.waf-edge-x {
  font-size: 11px;
  line-height: 1;
  opacity: 0.65;
  font-weight: 700;
}

.waf-edge-badge:hover .waf-edge-x,
.waf-edge-badge.selected .waf-edge-x {
  opacity: 1;
}
.waf-edge-badge.selected {
  border-color: var(--rose);
  background: var(--rose);
  color: #ffffff;
  transform: translate(-50%, -50%) scale(1.06);
}
:root[data-theme="dark"] .waf-edge-badge.selected {
  border-color: #dc2626;
  background: #dc2626;
  color: #ffffff;
}

.waf-nodes-layer {
  position: absolute;
  left: 0;
  top: 0;
}

/* Flow Node Card */
.waf-node {
  position: absolute;
  width: 218px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  cursor: move;
  z-index: 2;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

.waf-node:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.waf-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
  z-index: 5;
}

.waf-node.traced {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px var(--sky-soft), var(--shadow-md);
}

.waf-node.traced-blocked {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px var(--rose-soft), var(--shadow-md);
}

.waf-node.traced-passed {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-soft), var(--shadow-md);
}

.waf-node-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: calc(var(--radius-md) - 1.5px) calc(var(--radius-md) - 1.5px) 0 0;
  background: var(--bg-subtle);
}

.waf-node.type-start .waf-node-head { background: var(--accent-soft); }
.waf-node.type-pass .waf-node-head { background: var(--emerald-soft); }
.waf-node.type-block .waf-node-head { background: var(--rose-soft); }

.waf-node-title {
  min-width: 0;
  flex: 1;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.waf-node-del {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 120ms ease, background-color 120ms ease, color 120ms ease;
}

.waf-node:hover .waf-node-del,
.waf-node.selected .waf-node-del {
  opacity: 1;
}

.waf-node-del:hover {
  background: var(--rose-soft);
  color: var(--rose);
}

.waf-node-del svg { width: 12.5px; height: 12.5px; }

.waf-node-body {
  padding: 8px 11px 9px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.waf-node-ports {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-subtle);
}

.waf-port-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 14px 6px 11px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.waf-port-row + .waf-port-row {
  border-top: 1px dashed var(--border-subtle);
}

.waf-port-row.port-true { color: var(--emerald); }
.waf-port-row.port-false { color: var(--amber); }

.waf-port {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2.5px solid var(--accent);
  background: var(--bg-surface);
  cursor: crosshair;
  z-index: 6;
  transition: transform 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.waf-port:hover {
  transform: translateY(-50%) scale(1.25);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.waf-port.port-in {
  left: -8px;
  top: 22px;
  transform: translateY(-50%);
  border-color: var(--text-muted);
}

.waf-port.port-in.drop-ready {
  border-color: var(--accent);
  background: var(--accent);
  transform: translateY(-50%) scale(1.3);
  box-shadow: 0 0 0 5px var(--accent-soft-strong);
}

.waf-port.port-out {
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
}

.waf-port.port-out.port-true { border-color: var(--emerald); }
.waf-port.port-out.port-false { border-color: var(--amber); }
.waf-port.port-out.wired { background: var(--accent); }
.waf-port.port-out.port-true.wired { background: var(--emerald); }
.waf-port.port-out.port-false.wired { background: var(--amber); }

/* Floating Canvas Controls & Simulation Bar */
.waf-sim-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: color-mix(in srgb, var(--bg-surface) 95%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md);
  flex-wrap: wrap;
}

.waf-sim-bar input {
  width: auto;
  min-width: 64px;
  flex: 1 1 72px;
  min-height: 30px;
  height: 30px;
  padding: 4px 8px;
  font-size: 12px;
}

#waf-sim-host {
  flex: 1.45 1 108px;
}

#waf-sim-country {
  flex: 0 0 50px;
  min-width: 50px;
  text-align: center;
}

.waf-canvas-zoom {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
  box-shadow: var(--shadow-sm);
}

.waf-canvas-zoom span {
  min-width: 42px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.waf-canvas-status {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--emerald-border);
  background: color-mix(in srgb, var(--bg-surface) 95%, transparent);
  color: var(--emerald);
  font-size: 12px;
  font-weight: 560;
  box-shadow: var(--shadow-sm);
  max-width: min(440px, calc(100% - 180px));
}

.waf-canvas-status.has-error {
  border-color: var(--amber-border);
  color: var(--amber);
}

.waf-canvas-status span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Right Node Inspector Panel */
.waf-inspector {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-default);
  background: var(--bg-surface);
  overflow-y: auto;
  padding: 16px;
  gap: 14px;
}

.waf-inspector > * {
  flex-shrink: 0;
}

.waf-inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.waf-inspector-head strong {
  font-size: 13.5px;
  font-weight: 650;
}

.waf-wire-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  font-size: 11.5px;
}

.waf-player-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.waf-player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.waf-player-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.waf-player-mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 560;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}
.waf-player-mini-btn:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-soft);
}
.waf-player-mini-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.waf-player-mini-btn svg {
  width: 11px;
  height: 11px;
}
.waf-player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.waf-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 540;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}
.waf-player-chip:hover {
  border-color: var(--accent-border);
  color: var(--text-primary);
}
.waf-player-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 620;
}
.waf-player-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 2px var(--emerald-soft);
  flex-shrink: 0;
}
.waf-player-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.85;
}
.waf-player-chip.active .waf-player-count {
  color: var(--accent);
}
.waf-player-empty {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 6px 9px;
  border-radius: var(--radius-xs);
  border: 1px dashed var(--border-default);
  background: var(--bg-subtle);
}

/* Domain Modal Step 3 WAF Binding Section */
.domain-waf-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
}

.domain-cdn-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.domain-cdn-cidrs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.domain-cdn-presets {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

#domain-ov-trusted-cidrs {
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

.domain-waf-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.domain-waf-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 540;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.domain-waf-chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.domain-waf-chip.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 620;
}

.domain-waf-chip-order {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
:root[data-theme="dark"] .domain-waf-chip-order {
  background: #6366f1;
  color: #ffffff;
}

@media (max-width: 980px) {
  .waf-editor-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(320px, 1fr) auto;
    overflow-y: auto;
  }
  .waf-palette {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border-default);
    overflow-y: visible;
  }
  .waf-palette-group {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }
  .waf-palette-label {
    width: 100%;
    margin: 0;
  }
  .waf-palette-btn {
    width: auto;
    padding: 6px 10px;
    touch-action: manipulation;
  }
  .waf-palette-grip { display: none; }
  .waf-palette-tip { display: none; }
  .waf-inspector {
    border-left: 0;
    border-top: 1px solid var(--border-default);
  }
}

/* ==================== LIVE NOW PLAYING & WATCH HISTORY ==================== */

.nav-item-badge.emerald {
  background: var(--emerald-soft);
  color: var(--emerald);
  border-color: var(--emerald-border);
}

.overview-watching-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
  padding: 12px 16px 14px;
}

.overview-watch-pill {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 120ms var(--ease-out);
}

.overview-watch-pill:hover {
  border-color: var(--accent);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

.overview-watch-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.overview-watch-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-watch-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.watching-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 14px;
  padding: 16px;
}

.watching-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 15px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.watching-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.watching-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.watching-media-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}

.watching-media-icon.movie { background: var(--sky-soft); color: var(--sky); }
.watching-media-icon.audio { background: var(--emerald-soft); color: var(--emerald); }
.watching-media-icon.video { background: var(--amber-soft); color: var(--amber); }
.watching-media-icon svg { width: 20px; height: 20px; }

.watching-card-titlebox {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.watching-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.watching-card-title {
  font-size: 14.5px;
  font-weight: 680;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watching-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watching-card-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.watching-progress-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.watching-progress-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
}

.watching-progress-track {
  position: relative;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  overflow: hidden;
}

.watching-progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent), var(--sky));
  transition: width 320ms var(--ease-out);
}

.watching-progress-fill.is-paused {
  background: var(--amber);
}
.watching-progress-fill.is-paused.is-indeterminate {
  width: 38%;
}

.watching-progress-fill.is-live {
  width: 38%;
  background: linear-gradient(90deg, transparent, var(--emerald), var(--sky), transparent);
  animation: watching-stream-slide 1.8s ease-in-out infinite;
}

@keyframes watching-stream-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(280%); }
}

.watching-viewer-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.watching-viewer-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.watching-viewer-item svg {
  width: 13px;
  height: 13px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.watching-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.watching-speed-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
}

.watching-speed-rate {
  color: var(--sky);
  font-weight: 650;
}

@media (max-width: 640px) {
  .watching-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}

/* ==================== AXISNOW SMART DNS ==================== */
.mode-cards.mode-cards-2x2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.smart-provider-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.smart-provider-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--text-primary);
}

.smart-provider-pill small {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.smart-dns-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.smart-dns-toggle-row {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.smart-lines-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.smart-lines-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.smart-lines-title strong {
  font-size: 13px;
  color: var(--text-primary);
}

.smart-lines-title small {
  font-size: 12px;
  color: var(--text-muted);
}

.smart-preset-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.smart-lines-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.smart-line-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: border-color 0.16s ease;
}

.smart-line-card.is-default {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
}

.smart-line-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.smart-line-geo-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 200px;
  min-width: 170px;
}

.smart-line-geo-wrap select,
.smart-line-geo-wrap input,
.smart-line-geo-wrap .cselect-wrap {
  min-width: 0;
  flex: 1;
}

.smart-line-geo-wrap input {
  height: 32px;
  font-size: 12.5px;
  padding: 0 8px;
}

.smart-line-strategy-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.smart-line-strategy-wrap .cselect-wrap {
  min-width: 118px;
  width: auto;
}

.cselect-group-label {
  padding: 6px 10px 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  user-select: none;
}

.smart-line-qty {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.smart-line-qty input {
  width: 52px;
  height: 32px;
  padding: 0 6px;
  text-align: center;
  font-size: 12px;
}

.smart-line-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.smart-node-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.smart-node-chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.smart-node-chip.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-surface));
  color: var(--text-primary);
  font-weight: 600;
}

.smart-node-chip-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
}
:root[data-theme="dark"] .smart-node-chip-rank {
  background: #6366f1;
  color: #ffffff;
}

.smart-node-chip-move {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.smart-node-chip-move:hover {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

.smart-line-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}

.smart-line-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-secondary);
}

.smart-line-check input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.smart-dns-table-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.smart-dns-table-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.smart-dns-table-chip.is-paused {
  opacity: 0.65;
  border-style: dashed;
}

.smart-dns-table-chip.is-error {
  border-color: color-mix(in srgb, var(--rose) 50%, var(--border));
  color: var(--rose);
}

@media (max-width: 640px) {
  .mode-cards.mode-cards-2x2 {
    grid-template-columns: 1fr;
  }
}

/* ==================== DEDICATED DNS & SMART ROUTING HUB ==================== */
.dns-hub-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dns-hub-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dns-hub-pane[hidden] {
  display: none;
}

.dns-providers-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dns-profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 14px;
  padding: 16px;
}

.dns-profile-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.dns-profile-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow-sm);
}

.dns-profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.dns-profile-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.dns-profile-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dns-profile-title-row strong {
  font-size: 14.5px;
  color: var(--text-primary);
}

.dns-profile-title-wrap small {
  font-size: 12px;
  color: var(--text-muted);
}

.dns-profile-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.dns-profile-line-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 10px;
  font-size: 12px;
}

.dns-profile-line-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.dns-profile-line-nodes {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--text-secondary);
}

.dns-profile-bound-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.dns-profile-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.drawer-panel.drawer-wide {
  max-width: 780px;
  width: min(780px, calc(100vw - 32px));
}

.domain-smart-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.domain-smart-profile-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.domain-smart-profile-card:hover {
  border-color: var(--accent);
}

.domain-smart-profile-card.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-surface));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
}

.domain-smart-profile-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.domain-smart-profile-card-top strong {
  font-size: 13px;
  color: var(--text-primary);
}

.domain-smart-profile-card small {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.smart-profile-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.dns-bind-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.dns-bind-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  cursor: pointer;
  transition: border-color 0.14s ease;
}

.dns-bind-item:hover {
  border-color: var(--accent);
}

.dns-bind-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dns-bind-item-left input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}

.dns-bind-item-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dns-bind-item-copy strong {
  font-size: 13px;
  color: var(--text-primary);
}

.dns-bind-item-copy small {
  font-size: 11.5px;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .dns-profiles-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}

/* ==================== Service Probe Cards (Ring + Dense Heartbeat + Latency Area Chart) ==================== */

.uptime-board {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px;
}
.uptime-board:empty {
  padding: 0;
}

.uptime-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.uptime-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}
.uptime-group-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 660;
  color: var(--text-secondary);
}
.uptime-group-summary {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

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

.uptime-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.025);
  transition: border-color 160ms ease, box-shadow 180ms ease;
}
@media (min-width: 761px) {
  .uptime-card {
    aspect-ratio: 1 / 1;
  }
}
:root[data-theme="dark"] .uptime-card {
  border-color: var(--border-default);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28);
}
.uptime-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 8px 24px -8px rgba(15, 23, 42, 0.1), 0 1px 3px rgba(15, 23, 42, 0.04);
}
.uptime-card.is-offline {
  border-color: var(--rose-border);
}
.uptime-card.is-disabled {
  opacity: 0.72;
}

/* Header: Status Circle + Name + Hover Actions + Circular Uptime Ring */
.uptime-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.uptime-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.uptime-status-ico {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--emerald);
}
.uptime-status-ico svg {
  width: 17px;
  height: 17px;
}
.uptime-status-ico.is-offline { color: var(--rose); }
.uptime-status-ico.is-unknown { color: var(--amber); }
.uptime-status-ico.is-disabled { color: var(--text-faint); }

.uptime-name {
  font-size: 15px;
  font-weight: 660;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.uptime-card-actions {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background: color-mix(in srgb, var(--bg-surface) 96%, transparent);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 150ms ease, transform 150ms var(--ease-out);
}
.uptime-card:hover .uptime-card-actions,
.uptime-card:focus-within .uptime-card-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.uptime-card-actions .icon-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}
.uptime-card-actions .icon-btn svg {
  width: 13px;
  height: 13px;
}

.uptime-ring-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.uptime-ring-svg {
  width: 22px;
  height: 22px;
  display: block;
}
.uptime-ring-track {
  fill: none;
  stroke: var(--bg-inset);
  stroke-width: 3;
}
.uptime-ring-arc {
  fill: none;
  stroke: #10b981;
  stroke-width: 3;
  stroke-linecap: round;
}
.uptime-ring-wrap.is-warn .uptime-ring-arc { stroke: var(--amber); }
.uptime-ring-wrap.is-bad .uptime-ring-arc { stroke: var(--rose); }
.uptime-ring-wrap.is-muted .uptime-ring-arc { stroke: var(--text-faint); }

.uptime-pct {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 660;
  color: #10b981;
  white-space: nowrap;
}
.uptime-ring-wrap.is-warn .uptime-pct { color: var(--amber); }
.uptime-ring-wrap.is-bad .uptime-pct { color: var(--rose); }
.uptime-ring-wrap.is-muted .uptime-pct { color: var(--text-muted); font-weight: 560; }

/* Latency Meta + Inline Legend + Dense Heartbeat Strip */
.uptime-strip-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.uptime-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  min-height: 17px;
}
.uptime-lt-al {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.uptime-kv {
  color: var(--text-muted);
}
.uptime-kv b {
  font-weight: 620;
  color: #10b981;
  margin-left: 2px;
}
.uptime-kv b.is-warn { color: var(--amber); }
.uptime-kv b.is-bad { color: var(--rose); }
.uptime-kv b.is-muted { color: var(--text-muted); }

.uptime-inline-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.uptime-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.uptime-leg-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  display: inline-block;
}
.uptime-leg-dot.is-up { background: #10b981; }
.uptime-leg-dot.is-warn { background: #f59e0b; }
.uptime-leg-dot.is-paused { background: #38bdf8; }
.uptime-leg-dot.is-down { background: #ef4444; }
.uptime-hover-readout {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uptime-bars {
  display: grid;
  grid-template-columns: repeat(60, minmax(0, 1fr));
  gap: 2px;
  align-items: center;
  height: 18px;
}
.uptime-bar {
  height: 100%;
  border-radius: 1.5px;
  background: var(--bg-inset);
  transition: transform 110ms var(--ease-out), filter 110ms ease;
}
.uptime-bar.is-up { background: #10b981; }
.uptime-bar.is-warn { background: #f59e0b; }
.uptime-bar.is-paused { background: #38bdf8; }
.uptime-bar.is-down { background: #ef4444; }
.uptime-bar.is-empty {
  background: var(--bg-inset);
  opacity: 0.42;
}
.uptime-bar:not(.is-empty) { cursor: pointer; }
.uptime-bar:not(.is-empty):hover {
  transform: scaleY(1.24);
  filter: brightness(1.08);
}

/* Window Switcher (近 100 次 / 50 次 / 25 次 / 10 次) */
.uptime-win-switch {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: var(--bg-subtle);
}
.uptime-win-btn {
  height: 26px;
  padding: 0 3px;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 540;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.uptime-win-btn:hover {
  color: var(--text-primary);
}
.uptime-win-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 620;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
:root[data-theme="dark"] .uptime-win-btn.active {
  background: var(--bg-inset);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* Latency Area Line Chart */
.uptime-chart-slot {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.uptime-chart-box {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: minmax(112px, 1fr) auto;
  column-gap: 6px;
  row-gap: 6px;
  align-items: stretch;
}
.uptime-chart-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 0;
  white-space: nowrap;
}
.uptime-chart-plot {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 112px;
  overflow: visible;
}
.uptime-chart-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.uptime-chart-gridline {
  stroke: var(--border-subtle);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  vector-effect: non-scaling-stroke;
}
.uptime-chart-line {
  fill: none;
  stroke: #10b981;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.uptime-chart-line.is-warn { stroke: #f59e0b; }
.uptime-chart-line.is-bad { stroke: #ef4444; }
.uptime-chart-hover-line {
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-dasharray: 2 2;
  vector-effect: non-scaling-stroke;
}
.uptime-chart-hover-dot {
  fill: #10b981;
  stroke: var(--bg-surface);
  stroke-width: 2;
}
.uptime-chart-hover-dot.is-bad { fill: #ef4444; }
.uptime-chart-hover-dot.is-warn { fill: #f59e0b; }

.uptime-chart-empty {
  height: 100%;
  min-height: 112px;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  color: var(--text-faint);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-subtle) 55%, transparent);
}
.uptime-chart-xaxis {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.probe-path-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.probe-preset-chip {
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}
.probe-preset-chip:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

#emby-batch-drawer .drawer-panel,
#emby-settings-drawer .drawer-panel {
  width: min(480px, calc(100vw - 24px));
}
#emby-batch-urls {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
}

@media (hover: none) {
  .uptime-card-actions {
    position: static;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
  }
}
@media (max-width: 760px) {
  .uptime-board { padding: 12px; }
  .uptime-grid { grid-template-columns: 1fr; }
  .uptime-inline-legend { display: none; }
}

/* ==================== MULTI-ACCOUNT AXISNOW & AUTO CF ZONES ==================== */
.cf-zones-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.axisnow-accounts-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.axisnow-accounts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.axisnow-accounts-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.axisnow-accounts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.axisnow-account-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: border-color 140ms ease, opacity 140ms ease;
}

.axisnow-account-card.is-disabled {
  opacity: 0.72;
  background: var(--bg-subtle);
}

.axisnow-account-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.axisnow-account-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.axisnow-account-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.axisnow-account-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.axisnow-account-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.h3-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.14);
  color: #0284c7;
  letter-spacing: 0.03em;
}

:root[data-theme="dark"] .h3-pill {
  color: #38bdf8;
}
