:root {
  color-scheme: light;
  --bg-canvas: #f1f5f9;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-inset: #f8fafc;
  --bg-selection: #eff6ff;
  --rail-bg: #090e1a;
  --rail-border: rgba(255, 255, 255, 0.08);
  --rail-text: #cbd5e1;
  --rail-muted: #64748b;
  --ink: #0f172a;
  --secondary-ink: #334155;
  --muted: #475569;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-ring: rgba(37, 99, 235, 0.16);
  --line: #e2e8f0;
  --line-soft: #eef2f6;
  --line-strong: #cbd5e1;
  --emerald: #0f766e;
  --emerald-fg: #065f46;
  --emerald-bg: #ecfdf5;
  --emerald-border: #a7f3d0;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --coral: #be123c;
  --coral-bg: #fff1f2;
  --coral-border: #fecdd3;
  --neutral-fg: #334155;
  --neutral-bg: #f1f5f9;
  --neutral-border: #cbd5e1;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 6px 16px -6px rgba(15, 23, 42, 0.04);
  --shadow-elevated: 0 24px 48px -12px rgba(15, 23, 42, 0.10), 0 4px 14px -2px rgba(15, 23, 42, 0.04);
  --radius-card: 14px;
  --radius-ctrl: 8px;
  --mono-font: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Plus Jakarta Sans", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg-canvas);
  color: var(--ink);
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-size: 14px;
  line-height: 1.55;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(960px 320px at 55% 0%, rgba(37, 99, 235, 0.05), transparent 72%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

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

/* === BRAND LOCKUP === */
a.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #ffffff;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex: none;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.brand-copy small {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  color: #93c5fd;
}

/* === SPLIT-SCREEN AUTH SHELL === */
.auth-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(420px, 46%) minmax(0, 1fr);
}

.auth-showcase {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 36px 44px;
  background-color: #070c18;
  background-image:
    radial-gradient(90% 55% at 0% 0%, rgba(37, 99, 235, 0.30), transparent 60%),
    radial-gradient(75% 50% at 100% 100%, rgba(14, 165, 233, 0.16), transparent 60%),
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  color: #f8fafc;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-mast {
  background: transparent;
  border: 0;
  padding: 0;
}

.showcase-body {
  max-width: 480px;
  margin: auto 0;
  padding: 32px 0;
}

.showcase-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.30);
  background: rgba(37, 99, 235, 0.16);
  color: #bfdbfe;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 16px;
}

.showcase-title {
  margin: 0 0 12px;
  font-size: clamp(24px, 2.5vw, 31px);
  font-weight: 760;
  line-height: 1.26;
  letter-spacing: -0.025em;
  color: #ffffff;
}

.showcase-desc {
  margin: 0 0 28px;
  font-size: 14.5px;
  line-height: 1.65;
  color: #94a3b8;
}

.showcase-features {
  display: grid;
  gap: 12px;
}

.showcase-item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(8px);
}

.showcase-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.24);
  color: #60a5fa;
  flex: none;
}

.showcase-item strong {
  display: block;
  font-size: 13.5px;
  font-weight: 650;
  color: #f1f5f9;
  margin-bottom: 2px;
}

.showcase-item small {
  color: #94a3b8;
  font-size: 12.5px;
  line-height: 1.48;
}

.showcase-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #64748b;
}

.auth-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

main.narrow {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
}

.auth-header {
  margin-bottom: 20px;
}

.eyebrow {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.auth-header h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 760;
  letter-spacing: -0.025em;
}

.auth-card {
  padding: 28px;
  gap: 16px;
  border-radius: 16px;
  border: 1px solid rgba(203, 213, 225, 0.85);
  box-shadow: var(--shadow-elevated);
}

.auth-card input {
  min-height: 40px;
}

.auth-card > button {
  justify-self: stretch;
  min-height: 42px;
  font-size: 14.5px;
  margin-top: 4px;
}

.label-hint {
  font-size: 11.5px;
  font-weight: 450;
  color: var(--muted);
}

.auth-card label {
  position: relative;
}

.auth-details {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-subtle);
}

.auth-footer {
  margin-top: 20px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
}

.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-links {
  justify-content: center;
  margin-top: 0;
}

/* === FULL-HEIGHT CONSOLE SHELL === */
.console-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--rail-bg);
  background-image: radial-gradient(140% 50% at 0% 0%, rgba(37, 99, 235, 0.22), transparent 58%);
  color: var(--rail-text);
  border-right: 1px solid var(--rail-border);
  z-index: 20;
}

.rail-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--rail-border);
  display: grid;
  gap: 14px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mode-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 29px;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.mode-switch a:hover {
  color: #f1f5f9;
}

.mode-switch a.is-active {
  background: rgba(37, 99, 235, 0.85);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}

.rail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.admin-nav, .personal-nav {
  display: grid;
  gap: 16px;
}

.nav-group {
  display: grid;
  gap: 2px;
}

.nav-group-label {
  margin: 0 0 4px;
  padding: 0 10px;
  color: var(--rail-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-nav a, .personal-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 11px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.admin-nav a:hover, .personal-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
}

.admin-nav a.is-active, .personal-nav a.is-active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.26) 0%, rgba(37, 99, 235, 0.08) 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 #60a5fa, inset 0 0 0 1px rgba(96, 165, 250, 0.20);
}

.admin-nav a.is-active svg, .personal-nav a.is-active svg {
  color: #60a5fa;
}

.admin-nav svg, .personal-nav svg {
  flex: none;
  opacity: 0.9;
}

.rail-foot {
  padding: 12px;
  border-top: 1px solid var(--rail-border);
  background: rgba(2, 6, 23, 0.36);
}

.operator-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.avatar-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  border: 1px solid rgba(147, 197, 253, 0.30);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.operator-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.operator-name {
  font-size: 12.5px;
  font-weight: 650;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-tag {
  align-self: flex-start;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.20);
  color: #bfdbfe;
  white-space: nowrap;
}

.logout-form {
  margin: 0;
  flex: none;
}

.rail .quiet {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  box-shadow: none;
  font-size: 12px;
}

.rail .quiet:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.42);
  color: #fecdd3;
}

/* === WORKSPACE STAGE & STICKY TOPBAR === */
.workspace-stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

header.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 54px;
  padding: 8px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.92);
}

.topbar-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}

.crumb-root {
  font-weight: 600;
  color: var(--secondary-ink);
}

.crumb-sep {
  color: #cbd5e1;
}

.crumb-current {
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  margin-right: 4px;
  border-radius: 999px;
  border: 1px solid var(--emerald-border);
  background: var(--emerald-bg);
  color: var(--emerald-fg);
  font-size: 11.5px;
  font-weight: 600;
}

.env-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

.topbar-links a {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-links a:hover {
  background: var(--bg-canvas);
  color: var(--ink);
}

.topbar-links a.is-active {
  background: var(--bg-selection);
  color: var(--accent);
  font-weight: 650;
}

.topbar-links .topbar-switch {
  margin-inline-start: 4px;
  border: 1px solid var(--line-strong);
  color: var(--secondary-ink);
}

.topbar-links .topbar-switch.is-active {
  border-color: #bfdbfe;
  background: var(--bg-selection);
  color: var(--accent);
}

.workspace-main {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 26px 32px 56px;
}

/* === PAGE HERO & TYPOGRAPHY === */
.page-hero {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

h1, h2, h3 {
  color: var(--ink);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 2.4vw, 26px);
  font-weight: 760;
  letter-spacing: -0.025em;
}

.page-lead {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

h3 {
  margin: 20px 0 10px;
  font-size: 13.5px;
  font-weight: 680;
  color: var(--secondary-ink);
}

p {
  margin: 0 0 12px;
}

.muted, small {
  color: var(--muted);
}

small {
  display: block;
  font-size: 12px;
  font-weight: 450;
  line-height: 1.45;
}

code, .mono, .codes {
  font-family: var(--mono-font);
}

code, .mono {
  overflow-wrap: anywhere;
}

.metric, .mono, .badge, .nowrap, td, input[type="number"], input[type="date"] {
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

/* === CARDS & SURFACES === */
.panel, .table-wrap, .filters {
  min-width: 0;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.panel {
  padding: 20px;
}

.filters {
  padding: 15px 18px;
}

.panel > :last-child, .panel p:last-child {
  margin-bottom: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: -20px -20px 18px;
  padding: 15px 20px 13px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.panel-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

.danger-panel {
  border-color: #fecdd3;
}

.danger-panel .panel-head {
  background: linear-gradient(180deg, #fffafa 0%, #fff5f6 100%);
  border-bottom-color: #ffe4e6;
}

/* === BENTO KPI STRIP === */
.cards, .kpi-grid, .ops-grid, .settings-pair, .abuse-grid {
  display: grid;
  gap: 0 18px;
  align-items: start;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.ops-grid, .settings-pair, .abuse-grid, .account-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-settings {
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
}

.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr));
}

@media (min-width: 1120px) {
  .kpi-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.kpi-card {
  padding: 16px 18px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title icon"
    "metric icon"
    "sub sub";
  align-items: center;
  gap: 4px 10px;
}

.kpi-card h2 {
  grid-area: title;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}

.kpi-card .metric {
  grid-area: metric;
  margin: 2px 0 0;
  font-size: 30px;
  font-weight: 760;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
}

.kpi-icon {
  grid-area: icon;
  align-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.kpi-blue { background: #eff6ff; color: #2563eb; border-color: #dbeafe; }
.kpi-emerald { background: #ecfdf5; color: #059669; border-color: #d1fae5; }
.kpi-indigo { background: #eef2ff; color: #4f46e5; border-color: #e0e7ff; }
.kpi-cyan { background: #ecfeff; color: #0891b2; border-color: #cffafe; }
.kpi-coral { background: #fff1f2; color: #e11d48; border-color: #ffe4e6; }
.kpi-slate { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

.kpi-sub {
  grid-area: sub;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-alert {
  border-color: var(--coral-border);
  background: linear-gradient(180deg, #ffffff 0%, #fff8f9 100%);
}

.kpi-alert .metric {
  color: var(--coral);
}

.stat-line {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* === OPERATIONAL HEALTH TILES === */
.tile-stack {
  display: grid;
  gap: 10px;
}

.health-tile {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-subtle);
}

.health-heading, .account-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.health-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.health-tile .callout {
  margin-top: 8px;
  margin-bottom: 0;
}

.empty-hint {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 2px;
}

.retention-list, .domain-list {
  display: grid;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 10px;
}

.retention-list {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}

.retention-list li, .domain-list li, .rate-tile, .check-grid {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--bg-subtle);
}

.retention-list li {
  display: grid;
  justify-items: start;
  gap: 6px;
}

.domain-list {
  margin-top: 14px;
}

.domain-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* === FORMS & TINTED CARD FOOTERS === */
.fields, .form-grid, .filters {
  display: grid;
  align-items: start;
  gap: 14px;
}

.fields > button, .form-grid > button {
  justify-self: start;
}

form.auth-card > button {
  justify-self: stretch;
  width: 100%;
}

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

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

.span-2 {
  grid-column: span 2;
}

.form-actions, .span-all {
  grid-column: 1 / -1;
}

.align-end, .filters {
  align-items: end;
}

.align-self-end {
  align-self: end;
  padding-bottom: 8px;
}

.panel form > .form-actions,
.panel > form.form-actions,
.panel > .form-actions {
  margin: 6px -20px -20px;
  padding: 12px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.panel form:not(:last-child) > .form-actions {
  margin: 6px -20px 16px;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
}

.report-workbench form > .form-actions {
  margin: 4px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid #cbd5e1;
  border-bottom: 0;
  background: transparent;
  border-radius: 0;
}

.foot-note {
  margin-right: auto;
  font-size: 12px;
  color: var(--muted);
}

/* === INTEGRATED FILTER TOOLBARS === */
.filters {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
}

.joined-toolbar {
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: none;
}

.joined-table {
  border-top: 0;
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}

.account-filters {
  grid-template-columns: minmax(0, 400px) auto;
  justify-content: start;
}

.device-filters {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr) minmax(0, 0.85fr) minmax(0, 1.1fr) minmax(0, 0.85fr) auto;
}

.session-filters {
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
}

.audit-filters {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.audit-filters .filter-actions {
  grid-column: 1 / -1;
}

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

.version-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.rate-grid, .check-grid {
  display: grid;
  align-items: start;
  gap: 10px;
}

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

.action-row, .filter-actions, .links, .inline, .check-row, .section-jumps, .account-identity, .identity-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

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

.check-row {
  gap: 10px 20px;
}

.links {
  margin-top: 12px;
}

.section-jumps {
  padding: 5px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
  width: fit-content;
  max-width: 100%;
}

.section-jumps a, .auth-links a {
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  border-radius: 7px;
  color: var(--secondary-ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.auth-links a {
  border: 1px solid var(--line);
  background: var(--bg-card);
  border-radius: 999px;
}

.section-jumps a:hover, .auth-links a:hover {
  background: var(--bg-selection);
  color: var(--accent);
}

[id^="sec-"], #edit-network, #edit-relay {
  scroll-margin-top: 72px;
}

/* === INPUTS, SELECTS & BUTTONS === */
label {
  display: grid;
  min-width: 0;
  gap: 5px;
  color: var(--secondary-ink);
  font-size: 12.5px;
  font-weight: 600;
}

input, select, textarea, button {
  font: inherit;
}

input, select, textarea {
  min-width: 0;
  max-width: 100%;
  min-height: 36px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctrl);
  background: var(--bg-card);
  color: var(--ink);
  font-size: 13.5px;
  box-shadow: var(--shadow-xs);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input::placeholder, textarea::placeholder {
  color: #94a3b8;
}

input:hover, select:hover, textarea:hover {
  border-color: #94a3b8;
}

input[type="date"], input[type="datetime-local"] {
  width: 100%;
}

input[type="hidden"] {
  display: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  outline: none;
}

.checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.checkbox input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 2px 0 0;
  box-shadow: none;
  accent-color: var(--accent);
  cursor: pointer;
}

button, a.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid #1d4ed8;
  border-radius: var(--radius-ctrl);
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

button:hover {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
}

button.secondary, a.btn-secondary {
  color: var(--secondary-ink);
  border-color: var(--line-strong);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

button.secondary:hover, a.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: #94a3b8;
  color: var(--ink);
}

button.danger {
  color: var(--coral);
  border-color: var(--coral-border);
  background: var(--coral-bg);
  box-shadow: none;
}

button.danger:hover {
  background: #ffe4e6;
  border-color: #fda4af;
}

button.btn-sm, a.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
}

/* === BADGES & PROGRESS METERS === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border: 1px solid var(--neutral-border);
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}

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

.badge-ok { color: var(--emerald-fg); background: var(--emerald-bg); border-color: var(--emerald-border); }
.badge-warn { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-border); }
.badge-danger { color: var(--coral); background: var(--coral-bg); border-color: var(--coral-border); }
.badge-accent { color: var(--accent-hover); background: var(--bg-selection); border-color: #bfdbfe; }
.badge-info { color: #0369a1; background: #f0f9ff; border-color: #bae6fd; }
.badge-neutral { color: var(--neutral-fg); background: var(--neutral-bg); border-color: #e2e8f0; }

.meter {
  --meter-fill: var(--accent);
  display: block;
  appearance: none;
  height: 6px;
  width: 100%;
  margin: 5px 0 7px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
  color: var(--meter-fill);
}

.meter-warn { --meter-fill: #d97706; }
.meter-danger { --meter-fill: #e11d48; }
.meter::-webkit-progress-bar { background: #e2e8f0; }
.meter::-webkit-progress-value { border-radius: 999px; background: var(--meter-fill); }
.meter::-moz-progress-bar { border-radius: 999px; background: var(--meter-fill); }

/* === DATA TABLES & AVATARS === */
.table-wrap {
  max-width: 100%;
  overflow: auto;
}

.panel > form + .table-wrap,
.panel > .form-actions + .table-wrap {
  margin-top: 18px;
}

.inset-table {
  box-shadow: none;
  margin-top: 14px;
  margin-bottom: 0;
}

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

td, th {
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.networks-table td,
.relay-table td,
.audit-table td {
  vertical-align: top;
}

th {
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding: 10px 16px;
}

th.col-actions, td.col-actions {
  text-align: right;
  white-space: nowrap;
}

tbody tr {
  transition: background-color 120ms ease;
}

tbody tr:hover {
  background: #f8fafc;
}

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

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px;
}

.entity-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.entity-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 12.5px;
  font-weight: 700;
  flex: none;
}

.entity-avatar-lg {
  width: 40px;
  height: 40px;
  font-size: 15px;
}

.entity-device {
  border-radius: 8px;
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #475569;
}

.account-summary {
  padding: 16px 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.cap-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 550;
}

.capacity-cell {
  min-width: 155px;
}

.networks-table td:last-child { width: 28%; }
.relay-table .cmd-cell { width: 34%; min-width: 220px; }
.relay-table td:last-child:not(.cmd-cell) { width: 24%; }

.cmd-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cmd-inline .copy-source {
  flex: 1 1 180px;
  margin: 0;
  height: 32px;
  min-height: 32px;
  padding: 5px 10px;
  background: #0f172a;
  border-color: #1e293b;
  color: #e2e8f0;
  white-space: pre;
  overflow-x: auto;
  overflow-y: hidden;
  resize: none;
}

td a.mono {
  font-size: 12.5px;
  text-decoration: none;
}

td a.mono:hover {
  text-decoration: underline;
}

.audit-table td:first-child,
.audit-table td:nth-child(3),
.audit-table td:nth-child(5) {
  white-space: nowrap;
}

.audit-table td:nth-child(2) { min-width: 124px; }
.audit-table td:nth-child(6) { width: 30%; min-width: 160px; }

.audit-target {
  min-width: 112px;
  font-size: 12px;
  word-break: break-all;
  color: var(--secondary-ink);
}

.code-pill {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--ink);
  padding: 2px 7px;
  font-size: 12px;
}

.audit-detail {
  display: block;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--bg-subtle);
  padding: 4px 8px;
  font-size: 12px;
  white-space: pre-wrap;
}

/* === CALLOUTS & NOTICES === */
.notice, .problem, .callout {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.notice, .callout-success {
  border-color: var(--emerald-border);
  background: var(--emerald-bg);
  color: var(--emerald-fg);
}

.problem {
  color: var(--coral);
  border-color: var(--coral-border);
  background: var(--coral-bg);
}

.callout-warn {
  color: var(--amber);
  border-color: var(--amber-border);
  background: var(--amber-bg);
}

.panel > form + .callout {
  margin-top: 28px;
}

.report-workbench {
  margin-bottom: 16px;
  padding: 16px;
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #eff6ff 0%, #f8fafc 100%);
}

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

.workbench-head h3, .workbench-head p {
  margin: 0;
}

.qr {
  display: block;
  width: min(192px, 100%);
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #ffffff;
  image-rendering: pixelated;
}

.codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 12px 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-subtle);
  overflow-wrap: anywhere;
}

fieldset {
  min-width: 0;
  display: grid;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fcfdff;
}

.sub-fieldset {
  padding: 14px 16px;
}

legend {
  padding: 0 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--secondary-ink);
}

summary {
  font-weight: 650;
  cursor: pointer;
}

details[open] > div {
  margin-top: 12px;
}

dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 14px;
}

dt {
  color: var(--muted);
  font-weight: 600;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.copy-source {
  width: 100%;
  margin: 4px 0 6px;
  background: #0f172a;
  border-color: #1e293b;
  color: #e2e8f0;
  font: 12px/1.5 var(--mono-font);
  resize: vertical;
}

.copy-status:empty, [data-proof-status]:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

/* === RESPONSIVE & REDUCED MOTION === */
@media (max-width: 1220px) {
  .device-filters, .session-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-showcase {
    padding: 22px 24px;
  }

  .showcase-body, .showcase-foot {
    display: none;
  }

  .console-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: static;
    height: auto;
  }

  .rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 14px 18px;
  }

  .rail-scroll {
    padding: 10px 18px;
    overflow-x: auto;
  }

  .admin-nav, .personal-nav {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .nav-group {
    display: flex;
    align-items: center;
    flex: none;
    gap: 4px;
  }

  .nav-group-label {
    display: none;
  }

  .rail-foot {
    padding: 10px 18px;
  }

  header.topbar {
    padding-inline: 18px;
  }

  .workspace-main {
    padding: 20px 18px 42px;
  }
}

@media (max-width: 760px) {
  .ops-grid, .settings-pair, .abuse-grid, .account-actions, .rate-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid, .device-filters, .session-filters, .audit-filters, .version-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-2 {
    grid-column: 1 / -1;
  }

  .invite-grid > button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .form-grid, .cols-2, .check-grid, .device-filters, .session-filters, .audit-filters, .version-grid, .account-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-stage {
    padding: 24px 16px;
  }

  .auth-card {
    padding: 20px;
  }

  .topbar-links {
    display: none;
  }
}

/* === SYSTEM UPGRADE CONSOLE === */
.upgrade-root {
  display: grid;
  gap: 18px;
}

.upgrade-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.upgrade-progress-panel {
  border-color: rgba(37, 99, 235, 0.28);
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.upgrade-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.upgrade-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  min-width: 0;
}

.upgrade-step .step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--neutral-bg);
  border: 1px solid var(--neutral-border);
  color: var(--secondary-ink);
  font-size: 12px;
  font-weight: 700;
  flex: none;
  margin-top: 1px;
}

.upgrade-step strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 2px;
}

.upgrade-step small {
  display: block;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.upgrade-step.is-current {
  border-color: rgba(37, 99, 235, 0.45);
  background: var(--bg-selection);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.upgrade-step.is-current .step-index {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.upgrade-step.is-done {
  border-color: var(--emerald-border);
  background: var(--emerald-bg);
}

.upgrade-step.is-done .step-index {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #ffffff;
}

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

.compare-card {
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  display: grid;
  gap: 12px;
  min-width: 0;
}

.compare-card.compare-highlight {
  border-color: rgba(37, 99, 235, 0.38);
  background: linear-gradient(180deg, #eff6ff 0%, #f8fafc 100%);
}

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

.compare-head strong {
  font-size: 14px;
  font-weight: 680;
  color: var(--ink);
}

.upgrade-dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

.upgrade-dl > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  min-width: 0;
}

.upgrade-dl dt {
  color: var(--muted);
  flex: none;
}

.upgrade-dl dd {
  margin: 0;
  color: var(--ink);
  font-weight: 550;
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}

.upgrade-notes {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: var(--secondary-ink);
  font-size: 13.5px;
  line-height: 1.6;
}

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

@media (max-width: 760px) {
  .upgrade-kpi-grid, .upgrade-compare, .upgrade-steps {
    grid-template-columns: minmax(0, 1fr);
  }

  .upgrade-dl > div {
    flex-direction: column;
    gap: 2px;
  }

  .upgrade-dl dd {
    text-align: left;
  }
}

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