/* Load last in every complete HTML document; preserve existing body classes and add theme-dark. */
body.theme-dark {
  --c-bg:#080808; --c-panel:#121212; --c-raised:#1a1a1a; --c-inset:#0c0c0c;
  --c-line:#303030; --c-strong-line:#727272; --c-text:#f5f5f5; --c-muted:#b0b0b0;
  --c-accent:#8ddbc4; --c-accent-ink:#08110e;
  --c-data-down:#8ddbc4; --c-data-up:#8799b3; --c-data-neutral:#c4c4c4;
  --bg:var(--c-bg); --bg2:var(--c-inset); --card:var(--c-panel); --card-hover:#202020;
  --ink:var(--c-text); --muted:var(--c-muted); --line:var(--c-line);
  --acc:var(--c-accent); --acc-2:#69b79f; --acc-glow:#192923; --acc-ink:var(--c-accent-ink);
  color-scheme:dark; margin:0; min-height:100vh; min-height:100dvh;
  background:var(--c-bg) !important; background-image:none !important; color:var(--c-text);
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif;
  -webkit-text-size-adjust:100%; -webkit-font-smoothing:antialiased;
  padding-bottom:calc(32px + env(safe-area-inset-bottom, 0px));
}
.theme-dark *, .theme-dark *::before, .theme-dark *::after { box-sizing:border-box; }
.theme-dark [hidden] { display:none !important; }
.theme-dark ::selection { background:#35564b; color:#fff; }
.theme-dark :is(button,a,input,select,textarea,summary) { -webkit-tap-highlight-color:rgba(141,219,196,.14); touch-action:manipulation; }
.theme-dark :is(button,input,select,textarea) { font-family:inherit; }
.theme-dark :is(button,[role=button],summary) { min-width:44px !important; min-height:44px; }
.theme-dark :is(button,[role=button]) { white-space:normal; overflow-wrap:anywhere; }
.theme-dark button { cursor:pointer; }
.theme-dark :is(button,[role=button]):disabled, .theme-dark [aria-disabled=true] { opacity:.48; cursor:not-allowed; }
.theme-dark :is(input:not([type=hidden]):not([type=checkbox]):not([type=radio]),select,textarea) {
  min-width:0; min-height:46px; max-width:100%; font-size:16px !important; line-height:1.45;
  background-color:var(--c-inset) !important; color:var(--c-text); border-color:var(--c-strong-line) !important;
  border-radius:10px;
}
.theme-dark :is(input,textarea)::placeholder { color:#919191 !important; opacity:1; }
.theme-dark input[readonly] { color:#bebebe; background-color:#191919 !important; }
.theme-dark select { padding-right:28px; }
.theme-dark input[type=date] { display:block; -webkit-appearance:none; appearance:none; }
.theme-dark input[type=date]::-webkit-date-and-time-value { text-align:left; min-height:1.4em; }
.theme-dark input:-webkit-autofill { -webkit-text-fill-color:#f5f5f5; -webkit-box-shadow:0 0 0 1000px #1a1a1a inset !important; caret-color:#f5f5f5; }
.theme-dark :is(button,a,input,select,textarea,summary,[tabindex]):focus-visible {
  outline:2px solid var(--c-accent) !important; outline-offset:3px; box-shadow:none;
}
.theme-dark a { color:var(--c-accent); text-underline-offset:3px; }
.theme-dark :is(p,dd,li,h1,h2,h3,h4,code) { overflow-wrap:anywhere; }
.theme-dark :is(.flex,.grid,.a-grid,.a-stack,.a-heading,.a-card-head) > * { min-width:0; }
.theme-dark :is(img,svg,video,canvas) { max-width:100%; }
.theme-dark :is(.mono,.font-mono) { font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; }

/* Neutralize former navy/blue surfaces while preserving semantic status accents. */
.theme-dark :is(.glass-card,.panel,.card,.stat,.a-card) {
  background:var(--c-panel) !important; border-color:var(--c-line); box-shadow:none !important; backdrop-filter:none;
}
.theme-dark :is(.glass-nav,.tabs,header.app) { background:#101010 !important; border-color:var(--c-line); backdrop-filter:none; }
.theme-dark [class*="bg-slate-950"], .theme-dark [class*="bg-gray-950"] { background-color:var(--c-inset) !important; }
.theme-dark [class*="bg-slate-900"], .theme-dark [class*="bg-gray-900"] { background-color:#151515 !important; }
.theme-dark [class*="bg-slate-800"], .theme-dark [class*="bg-gray-800"] { background-color:#202020 !important; }
.theme-dark [class*="bg-slate-700"], .theme-dark [class*="bg-slate-600"] { background-color:#292929 !important; }
.theme-dark :is([class~="bg-void"],[class~="bg-surface"],[class~="bg-panel"],[class~="bg-card"]) { background-color:var(--c-panel) !important; }
.theme-dark [class*="bg-gradient-"] { background-image:none !important; }
.theme-dark [class*="bg-sky-"], .theme-dark [class*="bg-cyan-"], .theme-dark [class*="bg-indigo-"], .theme-dark [class*="bg-purple-"] { background-color:#19221f !important; }
.theme-dark [class*="bg-white/"] { background-color:#202020; }
.theme-dark [class*="text-slate-100"], .theme-dark [class*="text-slate-200"] { color:#ebebeb !important; }
.theme-dark [class*="text-slate-300"] { color:#d1d1d1 !important; }
.theme-dark [class*="text-slate-400"] { color:#b4b4b4 !important; }
.theme-dark [class*="text-slate-500"], .theme-dark [class*="text-slate-600"] { color:#999 !important; }
.theme-dark [class*="text-sky-"], .theme-dark [class*="text-cyan-"] { color:var(--c-accent) !important; }
.theme-dark [class*="text-indigo-"], .theme-dark [class*="text-purple-"] { color:#c5cbc8 !important; }
.theme-dark [class*="border-slate-"], .theme-dark [class*="border-white/"], .theme-dark [class*="border-sky-"], .theme-dark [class*="border-indigo-"], .theme-dark [class*="border-purple-"] { border-color:var(--c-line) !important; }
.theme-dark [class*="shadow-"], .theme-dark :is(.glow-cyan,.glow-amber,.glow-rose) { box-shadow:none !important; }
.theme-dark :is([class~="blur-3xl"],[class~="blur-2xl"]) { display:none; }
.theme-dark .animate-pulse { animation:none; }
.theme-dark .progress-bar-cyan, .theme-dark .bar span { background:var(--c-accent); }
.theme-dark .progress-bar-amber { background:#d6b87a; }
.theme-dark .progress-bar-rose { background:#d98d97; }
.theme-dark [class*="text-emerald-"], .theme-dark [class*="text-green-"] { color:#b0dcc6 !important; }
.theme-dark [class*="text-amber-"], .theme-dark [class*="text-yellow-"] { color:#e8cca0 !important; }
.theme-dark [class*="text-rose-"], .theme-dark [class*="text-red-"] { color:#efb2b7 !important; }
.theme-dark [class*="bg-emerald-"], .theme-dark [class*="bg-green-"] { background-color:#18261e !important; }
.theme-dark [class*="bg-amber-"], .theme-dark [class*="bg-yellow-"] { background-color:#292217 !important; }
.theme-dark [class*="bg-rose-"], .theme-dark [class*="bg-red-"] { background-color:#2a1a1d !important; }
.theme-dark [class*="border-emerald-"], .theme-dark [class*="border-green-"] { border-color:#375244 !important; }
.theme-dark [class*="border-amber-"], .theme-dark [class*="border-yellow-"] { border-color:#51442e !important; }
.theme-dark [class*="border-rose-"], .theme-dark [class*="border-red-"] { border-color:#56363b !important; }
.theme-dark :is(button,a)[class~="bg-sky-500"], .theme-dark :is(button,a)[class~="bg-indigo-500"], .theme-dark :is(button,a)[class*="from-sky-"] {
  background:var(--c-accent) !important; color:var(--c-accent-ink) !important; border-color:var(--c-accent) !important;
}
.theme-dark :is(button,a)[class~="bg-sky-500"] :is(i,span), .theme-dark :is(button,a)[class*="from-sky-"] :is(i,span) { color:inherit !important; }
.theme-dark :is(button,a)[class~="bg-sky-500"]:hover, .theme-dark :is(button,a)[class*="from-sky-"]:hover { background:#ace9d6 !important; }
.theme-dark .flash { box-shadow:none !important; backdrop-filter:none; }
.theme-dark .flash.ok { background:#15251d; color:#bfdfce; border-color:#365344; }
.theme-dark .flash.err { background:#29191b; color:#efb2b7; border-color:#543438; }
.theme-dark .flash > div { min-width:0; }
.theme-dark .flash .shrink-0 { min-width:32px; }

/* Identical navigation on access and legacy content pages. */
.theme-dark .console-header {
  padding:calc(14px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) 0 max(24px, env(safe-area-inset-left, 0px));
  border-bottom:1px solid var(--c-line); background:#0f0f0f !important;
}
.theme-dark .console-top { max-width:1120px; margin:auto; display:flex; align-items:center; justify-content:space-between; gap:16px; }
.theme-dark .console-brand { display:flex; align-items:center; justify-content:flex-start; gap:11px; min-height:44px; color:var(--c-text) !important; text-decoration:none; }
.theme-dark .console-brand strong { display:block; font-size:17px; line-height:1.3; letter-spacing:-.3px; }
.theme-dark .console-domain { display:block; font-size:12px; line-height:1.45; color:#a0a0a0 !important; overflow-wrap:anywhere; }
.theme-dark :is(.console-mark,.a-mark) { width:38px; height:38px; display:grid; place-items:center; flex:none; border-radius:10px; background:var(--c-accent) !important; color:var(--c-accent-ink) !important; font-size:23px; font-weight:750; box-shadow:none; }
.theme-dark .console-account { display:flex; align-items:center; gap:14px; flex:none; }
.theme-dark .console-mode { display:inline-flex; align-items:center; min-height:44px; font-size:12px; color:#bcbcbc !important; max-width:140px; }
.theme-dark .console-logout { min-height:44px; padding:9px 13px; background:#191919; color:#e8e8e8; border:1px solid #3a3a3a; border-radius:9px; font-size:13px; white-space:nowrap; }
.theme-dark .console-nav { display:flex; gap:5px; width:100%; max-width:1120px; margin:15px auto 0; padding:0 0 10px; overflow-x:auto; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch; scrollbar-width:thin; scrollbar-color:#494949 transparent; }
.theme-dark .console-nav a { display:flex; flex:none; align-items:center; justify-content:center; min-height:44px; padding:10px 14px; border:1px solid transparent; border-radius:9px; color:#b9b9b9 !important; font-size:14px; font-weight:550; white-space:nowrap; text-decoration:none; background:transparent !important; }
.theme-dark .console-nav a.is-active { background:#182820 !important; color:var(--c-accent) !important; border-color:#365347 !important; box-shadow:none; }
.theme-dark .console-main { width:100%; max-width:1168px; margin:auto; padding:28px max(24px, env(safe-area-inset-right, 0px)) 24px max(24px, env(safe-area-inset-left, 0px)); }
.theme-dark .console-main > * { min-width:0; max-width:100%; }
.theme-dark > main:not([class]) { width:calc(100% - 32px); background:var(--c-panel); border-color:var(--c-line); }
.theme-dark > main:not([class]) :is(button,.btn) { background:var(--c-accent); color:var(--c-accent-ink); }
.theme-dark #subscription-url { color:var(--c-accent); }

/* Each table keeps its width inside a dedicated scroll area; never clip the document. */
.theme-dark :is(.mobile-table-scroll,.mobile-chart-scroll,.a-table-scroll,.overflow-x-auto) {
  min-width:0; max-width:100%; overflow-x:auto; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch;
  scrollbar-width:thin; scrollbar-color:#555 #141414;
}
.theme-dark :is(.mobile-table-scroll,.mobile-chart-scroll,.a-table-scroll,.overflow-x-auto):focus-visible { outline-offset:-2px; }
.theme-dark :is(.mobile-table-scroll,.a-table-scroll,.overflow-x-auto) > table { min-width:620px; border-collapse:collapse; }
.theme-dark table th { background:#171717; color:#bcbcbc; font-weight:600; }
.theme-dark table :is(th,td) { vertical-align:top; border-color:var(--c-line); }
.theme-dark :is(.a-badge,span[class*="rounded"][class*="text-"]) { max-width:100%; white-space:normal; overflow-wrap:anywhere; }
.theme-dark :is(.mobile-actions,.modal-actions) { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.theme-dark :is(.mobile-actions,.modal-actions) > :is(a,button,form) { min-width:0; }
.theme-dark :is(a[class*="px-"],a[class*="py-"],a.btn,a[role=button]) { display:inline-flex; align-items:center; justify-content:center; min-height:44px; white-space:normal; }

/* iPhone dialogs: the overlay accounts for the notch; the panel owns its scroll. */
.theme-dark :is(.modal-overlay,[role=dialog]) {
  position:fixed; inset:0; z-index:60;
  padding:max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background:rgba(0,0,0,.8); overscroll-behavior:contain;
}
.theme-dark :is(.modal-panel,[role=dialog] > .glass-card) {
  width:100%; min-width:0; max-height:calc(100vh - 32px); max-height:calc(100dvh - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px)));
  overflow-y:auto; overscroll-behavior-y:contain; -webkit-overflow-scrolling:touch;
  background:var(--c-panel) !important; border:1px solid #3a3a3a; border-radius:16px;
}
.theme-dark .modal-scroll-body { min-height:0; overflow-y:auto; overscroll-behavior-y:contain; -webkit-overflow-scrolling:touch; }
.theme-dark .modal-actions { padding-top:16px; padding-bottom:4px; }
.theme-dark .modal-actions :is(button,a) { min-height:44px; }

@media (max-width:600px) {
  .theme-dark { font-size:15px; }
  .theme-dark .console-header { padding-left:max(16px, env(safe-area-inset-left, 0px)); padding-right:max(16px, env(safe-area-inset-right, 0px)); }
  .theme-dark .console-top { gap:10px; }
  .theme-dark .console-account { gap:8px; }
  .theme-dark .console-mode { max-width:88px; font-size:11px; line-height:1.45; }
  .theme-dark .console-logout { padding-inline:11px; font-size:12px; }
  .theme-dark .console-brand { gap:9px; }
  .theme-dark .console-brand strong { font-size:16px; }
  .theme-dark .console-domain { font-size:11px; }
  .theme-dark .console-nav { margin-top:13px; gap:4px; }
  .theme-dark .console-nav a { padding-inline:12px; font-size:13px; }
  .theme-dark .console-main { padding:22px max(16px, env(safe-area-inset-right, 0px)) 20px max(16px, env(safe-area-inset-left, 0px)); }
  .theme-dark :is(.glass-card,.panel,.card) { border-radius:14px; }
  .theme-dark .mobile-wrap { flex-wrap:wrap; }
  .theme-dark .mobile-actions > :is(button,a), .theme-dark .mobile-actions > form > button { min-height:44px; padding-inline:12px; }
  .theme-dark .modal-panel, .theme-dark [role=dialog] > .glass-card { padding:20px 18px; }
  .theme-dark .modal-actions > :is(button,a) { flex:1 1 auto; }
  .theme-dark .a-table th, .theme-dark .a-table td { padding:12px 10px; }
}
@media (max-height:500px) and (orientation:landscape) {
  .theme-dark .console-header { position:static; padding-top:max(10px, env(safe-area-inset-top, 0px)); }
  .theme-dark .console-main { padding-top:20px; }
  .theme-dark .console-nav { margin-top:8px; padding-bottom:8px; }
  .theme-dark :is(.modal-overlay,[role=dialog]) { align-items:center; }
  .theme-dark .modal-panel, .theme-dark [role=dialog] > .glass-card { padding:18px 22px; }
}
@media (hover:hover) {
  .theme-dark .console-nav a:not(.is-active):hover { background:#222 !important; color:#fff !important; }
  .theme-dark :is(button,a.btn,.a-button) { transition:background-color .15s ease, border-color .15s ease; }
}
@media (prefers-reduced-motion:reduce) {
  .theme-dark *, .theme-dark *::before, .theme-dark *::after { animation:none !important; scroll-behavior:auto !important; transition:none !important; }
}

/* Match the visible viewport supplied by the modal controller, including the iOS keyboard. */
.theme-dark .modal-overlay {
  top:var(--modal-viewport-top, 0px); left:0; right:0; bottom:auto;
  height:100vh; height:var(--modal-viewport-height, 100dvh);
}
.theme-dark .modal-overlay .modal-panel {
  max-height:calc(var(--modal-viewport-height, 100dvh) - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px)));
}
body.theme-dark.modal-open { overflow:hidden; overscroll-behavior:none; }
.theme-dark input.a-code { font-size:23px !important; }
.theme-dark :is(.glass-card,.panel,.card,.stat) { background:var(--c-panel) !important; }
.theme-dark .subscription-receipt { color:var(--c-text); }
body.theme-dark.subscription-receipt {
  padding:calc(28px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.theme-dark.subscription-receipt > main { width:100%; background:var(--c-panel); border:1px solid var(--c-line); border-radius:16px; box-shadow:none; }
.theme-dark.subscription-receipt :is(.muted,.warning) { color:#b0b0b0; }
.theme-dark.subscription-receipt .urlbox { background:var(--c-inset); border-color:#3a3a3a; }
.theme-dark.subscription-receipt .notice { background:#252016; border-color:#4b402d; color:#dec99e; }
.theme-dark.subscription-receipt a { display:inline-flex; align-items:center; min-height:44px; background:#202020; color:var(--c-accent); border:1px solid #3b3b3b; }
.theme-dark #pin-lock-modal { padding:max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.theme-dark #pin-lock-modal > .glass-card { max-height:calc(100vh - 32px); max-height:calc(100dvh - 32px); overflow-y:auto; overscroll-behavior:contain; }
@media (max-width:600px) {
  .theme-dark.subscription-receipt > main { margin-top:8px; padding:22px 18px; }
  .theme-dark.subscription-receipt h1 { font-size:24px; line-height:1.4; }
  .theme-dark.subscription-receipt .urlbox { padding:14px; }
  .theme-dark.subscription-receipt .notice { padding:13px 14px; }
}
@media (max-height:500px) and (orientation:landscape) {
  .theme-dark.subscription-receipt > main { margin-top:0; }
}

/* Data marks must stay distinct from subdued control/card surfaces.
   Both hourly and daily traffic stacks use the same two scoped selectors. */
.theme-dark .mobile-chart-scroll [style*="height:"][class*="from-sky-"] {
  background-color:var(--c-data-down) !important; background-image:none !important;
}
.theme-dark .mobile-chart-scroll [style*="height:"][class*="bg-indigo-"] {
  background-color:var(--c-data-up) !important; background-image:none !important;
}
.theme-dark .glass-card:has(.mobile-chart-scroll) span[class~="bg-sky-500"] {
  background-color:var(--c-data-down) !important;
}
.theme-dark .glass-card:has(.mobile-chart-scroll) span[class~="bg-indigo-500"] {
  background-color:var(--c-data-up) !important;
}
/* Horizontal protocol/percentage bars are identified by their actual width and h-full class. */
.theme-dark div[style*="width:"][class~="h-full"]:is([class*="bg-sky-"],[class*="bg-cyan-"]) {
  background-color:var(--c-data-down) !important; background-image:none !important;
}
.theme-dark div[style*="width:"][class~="h-full"][class*="bg-indigo-"] {
  background-color:var(--c-data-up) !important; background-image:none !important;
}
.theme-dark div[style*="width:"][class~="h-full"][class*="bg-emerald-"] {
  background-color:var(--c-data-neutral) !important; background-image:none !important;
}
.theme-dark div[style*="width:"][class~="h-full"][class*="bg-amber-"] {
  background-color:#d6b87a !important; background-image:none !important;
}
.theme-dark div[style*="width:"][class~="h-full"][class*="bg-rose-"] {
  background-color:#d98d97 !important; background-image:none !important;
}
/* Keep protocol legend swatches aligned with their bars; no text or QR image recoloring. */
.theme-dark .glass-card:has(div[class~="h-full"][style*="width:"][class~="bg-cyan-400"]) span[class~="w-2"][class~="h-2"][class~="bg-cyan-400"] { background-color:var(--c-data-down) !important; }
.theme-dark .glass-card:has(div[class~="h-full"][style*="width:"][class~="bg-indigo-400"]) span[class~="w-2"][class~="h-2"][class~="bg-indigo-400"] { background-color:var(--c-data-up) !important; }
.theme-dark .glass-card:has(div[class~="h-full"][style*="width:"][class~="bg-emerald-400"]) span[class~="w-2"][class~="h-2"][class~="bg-emerald-400"] { background-color:var(--c-data-neutral) !important; }

/* Safari's menu-list appearance can ignore a useful visual height; keep the native select semantics. */
.theme-dark select:not([multiple]) {
  -webkit-appearance:none; appearance:none; height:48px; min-height:48px !important;
  padding:10px 40px 10px 12px; line-height:1.4;
  background-image:linear-gradient(45deg, transparent 50%, #bfbfbf 50%), linear-gradient(135deg, #bfbfbf 50%, transparent 50%) !important;
  background-position:right 18px center, right 12px center !important;
  background-size:6px 6px !important; background-repeat:no-repeat !important;
}
.theme-dark select:disabled { opacity:.6; }

/* The six-column authorization table needs its own readable width, inside its scroll region. */
.theme-dark .user-card .mobile-table-scroll > table { min-width:1080px; }
.theme-dark .user-card .mobile-table-scroll :is(th,td):nth-child(1) { min-width:190px; }
.theme-dark .user-card .mobile-table-scroll :is(th,td):nth-child(2) { min-width:140px; }
.theme-dark .user-card .mobile-table-scroll :is(th,td):nth-child(3) { min-width:180px; }
.theme-dark .user-card .mobile-table-scroll :is(th,td):nth-child(4) { min-width:160px; }
.theme-dark .user-card .mobile-table-scroll :is(th,td):nth-child(5) { min-width:160px; }
.theme-dark .user-card .mobile-table-scroll :is(th,td):nth-child(6) { min-width:200px; }
.theme-dark .user-card td:is(:nth-child(2),:nth-child(3)) span {
  white-space:nowrap; overflow-wrap:normal; word-break:normal;
}
.theme-dark .user-card td:first-child :is(.break-all,.break-words,span,strong) {
  word-break:normal; overflow-wrap:break-word;
}
