/*
 * BlueVPN user portal stylesheet (logged-in pages and the auth flow).
 *
 * Design tokens, colour palette, typography scale, spacing, radii and
 * component recipes are ported from overtrue/ui
 * (https://github.com/overtrue/ui, commit bd50940, src/index.css and
 * src/components/ui/*.tsx, src/components/overtrue/*.tsx), MIT License,
 * Copyright (c) 2026 overtrue/ui contributors. See THIRD_PARTY_NOTICES.md.
 *
 * Same port as the admin console (internal/web/console/static/admin.css):
 * Tailwind utility recipes are expanded into plain CSS classes with the same
 * token names, so the pages need no Node toolchain and run under a strict
 * CSP (no inline styles or scripts). Portal components are appended below.
 */

:root {
  --background: 220 20% 98%;
  --foreground: 215 19% 27%;
  --card: 0 0% 100%;
  --card-foreground: 220 27% 15%;
  --primary: 208 92% 43%;
  --primary-foreground: 220 20% 98%;
  --secondary: 220 9% 42%;
  --secondary-foreground: 0 0% 100%;
  --muted: 220 14% 96%;
  --muted-foreground: 220 9% 42%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 100%;
  --border: 220 13% 91%;
  --input: 220 13% 91%;
  --ring: 208 92% 43%;
  --success: 142 71% 37%;
  --info: 207 90% 54%;
  --warning: 32 94% 44%;
  --chart-1: 208 92% 43%;
  --chart-2: 142 71% 37%;
  --chart-3: 32 94% 44%;
  --chart-4: 263 70% 58%;
  --chart-5: 340 75% 55%;
  --radius: 0.5rem;
  --sidebar: 0 0% 100%;
  --sidebar-foreground: 215 19% 27%;
  --sidebar-primary: 208 92% 43%;
  --sidebar-accent: 220 14% 96%;
  --pn-blue: #066fd1;
  --pn-azure: #4299e1;
  --pn-red: #dc2626;
  --pn-orange: #f76707;
  --pn-green: #16a34a;
  --pn-dark: #111827;
  --pn-card-border: rgba(31, 41, 55, 0.12);
  --pn-card-shadow: 0 1px 2px rgba(18, 18, 23, 0.05);
  --pn-line: rgba(31, 41, 55, 0.06);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.4285714286;
  -webkit-font-smoothing: antialiased;
}
a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.muted { color: hsl(var(--muted-foreground)); }
.tiny { font-size: 0.75rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.text-green { color: #16a34a; }
.text-red { color: #dc2626; }
.text-orange { color: #f76707; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- app shell: top navbar + sidebar (overtrue TopNavbar / SidebarNav) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .5rem;
  height: 3.5rem; padding: 0 1rem;
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
}
.brand { display: flex; align-items: center; gap: .5rem; color: hsl(var(--card-foreground)); font-weight: 600; font-size: 1.125rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: flex; width: 2rem; height: 2rem; align-items: center; justify-content: center; border-radius: calc(var(--radius) * .75); background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.brand-mark svg { width: 1.25rem; height: 1.25rem; }
.brand small { font-size: .75rem; font-weight: 500; color: hsl(var(--muted-foreground)); margin-left: .25rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.env-pill { font-size: .75rem; padding: .125rem .5rem; border-radius: 999px; background: color-mix(in srgb, #f76707 15%, white); color: #c2410c; font-weight: 500; }
.layout { display: flex; min-height: calc(100svh - 3.5rem);
  /* paint the sidebar column full-height so long pages keep the rail background */
  background: linear-gradient(to right, hsl(var(--sidebar)) calc(15rem - 1px), hsl(var(--border)) calc(15rem - 1px), hsl(var(--border)) 15rem, transparent 15rem); }
.sidebar {
  position: sticky; top: 3.5rem; align-self: flex-start;
  height: calc(100svh - 3.5rem); width: 15rem; flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid hsl(var(--border)); background: hsl(var(--sidebar)); padding: .75rem .5rem;
}
.nav-section { margin-bottom: 1rem; }
.nav-title { padding: .5rem .5rem .25rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .025em; color: hsl(var(--muted-foreground)); }
.nav-link {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .125rem;
  border-radius: calc(var(--radius) * .75); padding: .375rem .5rem;
  font-size: .875rem; color: hsl(var(--muted-foreground));
}
.nav-link svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.nav-link:hover { background: hsl(var(--sidebar-accent)); color: hsl(var(--sidebar-foreground)); text-decoration: none; }
.nav-link.active { background: hsl(var(--sidebar-accent)); color: hsl(var(--sidebar-primary)); font-weight: 500; }
.main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.page { padding: 1.25rem 1.25rem 2rem; max-width: 1320px; width: 100%; }

/* ---------- page header (overtrue PageHeader) ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-pretitle { font-size: .75rem; line-height: 1.25rem; color: #6b7280; text-transform: uppercase; letter-spacing: .02em; font-weight: 500; }
.page-title { margin: 0; font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; color: #374151; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- card (overtrue card chrome) ---------- */
.card {
  background: hsl(var(--card));
  border: 1px solid var(--pn-card-border);
  border-radius: var(--radius);
  box-shadow: var(--pn-card-shadow);
  color: hsl(var(--card-foreground));
  margin-bottom: 1rem;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--pn-line); }
.card-title { margin: 0; font-size: 1rem; line-height: 1.25rem; font-weight: 500; color: #111827; }
.card-subtitle { color: #6b7280; font-size: .8125rem; margin: .25rem 0 0; }
.card-body { padding: 1.25rem; }
.card-body > :first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }
.card-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--pn-line); background: color-mix(in srgb, hsl(var(--muted)) 50%, white); border-radius: 0 0 var(--radius) var(--radius); }
.card-danger { border-color: color-mix(in srgb, #dc2626 35%, transparent); }
.card-danger .card-title { color: #b91c1c; }
.card-gradient { background: linear-gradient(135deg, color-mix(in srgb, #066fd1 6%, white) 0%, white 42%, color-mix(in srgb, #4299e1 5%, white) 100%); }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); margin-bottom: 1rem; }

/* ---------- stat card (overtrue StatCard) ---------- */
.stat { margin: 0; padding: 1.25rem; }
.metric-label { font-size: .75rem; line-height: 1.25rem; color: #6b7280; text-transform: uppercase; letter-spacing: .02em; font-weight: 500; }
.metric-value { margin-top: .25rem; font-size: 1.5rem; line-height: 2rem; font-weight: 600; color: #111827; font-variant-numeric: tabular-nums; }
.metric-hint { margin-top: .25rem; font-size: .75rem; color: #6b7280; }

/* ---------- buttons (overtrue Button variants) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; white-space: nowrap;
  height: 2.5rem; padding: 9px 16px; border-radius: calc(var(--radius) * .75);
  font: inherit; font-size: .875rem; font-weight: 500; cursor: pointer;
  border: 1px solid hsl(var(--input)); background: hsl(var(--card)); color: hsl(var(--foreground));
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn:hover { background: hsl(var(--muted)); text-decoration: none; }
.btn:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 1px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { border-color: transparent; background: #066fd1; color: #f9fafb; }
.btn-primary:hover { background: #0560b5; }
.btn-danger { border-color: transparent; background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { border-color: transparent; background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { border-color: transparent; background: #f76707; color: #fff; }
.btn-warning:hover { background: #ea580c; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 2rem; padding: 5px 12px; font-size: .75rem; }
.btn-block { width: 100%; }
.btn-link { border: 0; background: none; color: #066fd1; padding: 0; height: auto; }
.inline { display: inline; margin: 0; }
.actions { display: flex; gap: .375rem; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- badges (overtrue Badge / StatusBadge soft variants) ---------- */
.badge { display: inline-flex; align-items: center; gap: .375rem; border-radius: calc(var(--radius) * .75); padding: .125rem .5rem; font-size: .75rem; font-weight: 500; line-height: 1.25rem; border: 1px solid transparent; white-space: nowrap; background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.badge::before { content: ""; width: .375rem; height: .375rem; border-radius: 999px; background: currentColor; opacity: .9; }
.badge-plain::before { display: none; }
.badge-success { background: hsl(var(--success) / .15); color: hsl(var(--success)); }
.badge-warning { background: hsl(var(--warning) / .15); color: hsl(var(--warning)); }
.badge-danger { background: hsl(var(--destructive) / .15); color: hsl(var(--destructive)); }
.badge-info { background: hsl(var(--primary) / .15); color: hsl(var(--primary)); }
.badge-muted { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.role-owner { background: hsl(var(--chart-4) / .15); color: hsl(var(--chart-4)); }

/* ---------- forms (overtrue .form-control) ---------- */
.form { display: grid; gap: 1rem; }
.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.field { display: grid; gap: .375rem; font-size: .875rem; font-weight: 500; color: #374151; }
.field .hint { font-weight: 400; font-size: .75rem; color: #6b7280; }
.form-control, .field input:not([type=checkbox]), .field select, .field textarea, .filters input, .filters select {
  width: 100%; height: 2.5rem; border-radius: calc(var(--radius) * .75);
  border: 1px solid #e5e7eb; background: #fff; padding: 9px 16px;
  font: inherit; font-size: .875rem; color: #374151;
}
.field textarea { height: auto; min-height: 5rem; }
.form-control:focus, .field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus { outline: none; border-color: #066fd1; }
.field input::placeholder, .filters input::placeholder { color: #9ca3af; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem 1.25rem; border-bottom: 1px solid var(--pn-line); }
.filters input, .filters select { width: auto; min-width: 9rem; height: 2rem; padding: 4px 10px; font-size: .8125rem; }
.secret-hint { font-family: var(--font-mono); font-size: .75rem; color: #16a34a; }

/* ---------- tables (overtrue Table / DataTable) ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; color: hsl(var(--foreground)); }
thead th { height: 2.5rem; padding: 0 .75rem; text-align: left; vertical-align: middle; font-weight: 500; color: hsl(var(--muted-foreground)); font-size: .75rem; text-transform: uppercase; letter-spacing: .02em; border-bottom: 1px solid hsl(var(--border)); background: color-mix(in srgb, hsl(var(--muted)) 50%, white); white-space: nowrap; }
tbody td { padding: .625rem .75rem; vertical-align: middle; border-bottom: 1px solid var(--pn-line); }
tbody tr:hover { background: hsl(var(--muted) / .5); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }
.empty-state { padding: 2.5rem 1.25rem; text-align: center; color: hsl(var(--muted-foreground)); }
.empty-state strong { display: block; color: #111827; font-size: 1rem; font-weight: 500; margin-bottom: .25rem; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1.25rem; border-top: 1px solid var(--pn-line); color: hsl(var(--muted-foreground)); font-size: .8125rem; }

/* ---------- key/value (definition) lists ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem 1.5rem; margin: 0; }
.kv div { min-width: 0; }
.kv dt { font-size: .75rem; color: #6b7280; margin-bottom: .125rem; }
.kv dd { margin: 0; font-weight: 500; color: #111827; overflow-wrap: anywhere; }

/* ---------- alerts (overtrue Alert) ---------- */
.alert { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid; font-size: .875rem; }
.alert-error { background: color-mix(in srgb, #dc2626 7%, white); border-color: color-mix(in srgb, #dc2626 30%, white); color: #991b1b; }
.alert-ok { background: color-mix(in srgb, #16a34a 7%, white); border-color: color-mix(in srgb, #16a34a 30%, white); color: #166534; }
.alert-info { background: color-mix(in srgb, #066fd1 6%, white); border-color: color-mix(in srgb, #066fd1 25%, white); color: #0b4f94; }
.alert-warn { background: color-mix(in srgb, #f76707 7%, white); border-color: color-mix(in srgb, #f76707 30%, white); color: #9a3412; }

/* ---------- charts (overtrue chart palette, CSS bars) ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 11rem; padding: .5rem 0 0; border-bottom: 1px solid hsl(var(--border)); }
.bar { flex: 1; min-width: 4px; position: relative; display: flex; align-items: flex-end; height: 100%; }
.bar span { display: block; width: 100%; background: hsl(var(--chart-1)); border-radius: 3px 3px 0 0; min-height: 1px; }
.bar:hover span { background: #0560b5; }
.bar.zero span { background: hsl(var(--border)); }
.bars-green .bar span { background: hsl(var(--chart-2)); }
.bar-axis { display: flex; justify-content: space-between; font-size: .6875rem; color: hsl(var(--muted-foreground)); margin-top: .375rem; }
.hbar { height: .5rem; border-radius: 999px; background: hsl(var(--muted)); overflow: hidden; min-width: 6rem; }
.hbar span { display: block; height: 100%; background: hsl(var(--chart-1)); }
.hbar-green span { background: hsl(var(--chart-2)); }
.segmented { display: inline-flex; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) * .75); overflow: hidden; }
.segmented a { padding: .375rem .875rem; color: hsl(var(--foreground)); font-size: .8125rem; border-right: 1px solid hsl(var(--border)); }
.segmented a:last-child { border-right: 0; }
.segmented a.active { background: #066fd1; color: #fff; }
.segmented a:hover { text-decoration: none; }

/* ---------- auth layout (overtrue AuthLayout) ---------- */
.auth { min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-box { width: 100%; max-width: 26rem; }
.auth-head { text-align: center; margin-bottom: 1.5rem; }
.auth-head .brand-mark { margin: 0 auto .75rem; width: 2.5rem; height: 2.5rem; }
.h1 { margin: 0 0 .25rem; font-size: 1.5rem; line-height: 2rem; font-weight: 600; color: #111827; }
.auth .card-body { padding: 1.5rem; }
.totp-secret { font-family: var(--font-mono); font-size: 1.05rem; letter-spacing: .08em; background: hsl(var(--muted)); border-radius: calc(var(--radius) * .75); padding: .75rem; text-align: center; word-break: break-all; color: #111827; }
.code-input { font-family: var(--font-mono); font-size: 1.5rem !important; letter-spacing: .5em; text-align: center; height: 3rem !important; }

/* ---------- misc ---------- */
.codes { columns: 2 16rem; font-family: var(--font-mono); font-size: .875rem; margin: 0; padding: 0; list-style: none; }
.codes li { padding: .25rem 0; break-inside: avoid; }
pre.json { margin: 0; font-family: var(--font-mono); font-size: .75rem; background: hsl(var(--muted)); border-radius: calc(var(--radius) * .75); padding: .5rem .75rem; max-width: 28rem; overflow: auto; white-space: pre-wrap; }
details summary { cursor: pointer; color: #066fd1; }
.divider { height: 1px; background: var(--pn-line); margin: 1rem 0; border: 0; }
.health-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 999px; margin-right: .375rem; }
footer.console-foot { padding: 1rem 1.25rem 2rem; color: hsl(var(--muted-foreground)); font-size: .75rem; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .layout { display: block; background: none; }
  .mobile-nav { display: flex !important; }
}
/* Wrap instead of scrolling sideways: with 8-9 tabs a horizontal strip cut the
   right-most visible tab (and its unread badge) at phone widths. */
.mobile-nav { display: none; flex-wrap: wrap; gap: .25rem; padding: .5rem; border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--card)); }
.mobile-nav a { flex: 0 0 auto; display: inline-flex; align-items: center; white-space: nowrap; padding: .25rem .625rem; border-radius: calc(var(--radius) * .75); color: hsl(var(--muted-foreground)); }
.mobile-nav a.active { background: hsl(var(--sidebar-accent)); color: hsl(var(--sidebar-primary)); }
/* Percentage heights/widths for CSS bars (the CSP forbids inline styles). */
.h-0{height:0%}.h-1{height:1%}.h-2{height:2%}.h-3{height:3%}.h-4{height:4%}.h-5{height:5%}.h-6{height:6%}.h-7{height:7%}.h-8{height:8%}.h-9{height:9%}.h-10{height:10%}.h-11{height:11%}.h-12{height:12%}.h-13{height:13%}.h-14{height:14%}.h-15{height:15%}.h-16{height:16%}.h-17{height:17%}.h-18{height:18%}.h-19{height:19%}.h-20{height:20%}.h-21{height:21%}.h-22{height:22%}.h-23{height:23%}.h-24{height:24%}.h-25{height:25%}.h-26{height:26%}.h-27{height:27%}.h-28{height:28%}.h-29{height:29%}.h-30{height:30%}.h-31{height:31%}.h-32{height:32%}.h-33{height:33%}.h-34{height:34%}.h-35{height:35%}.h-36{height:36%}.h-37{height:37%}.h-38{height:38%}.h-39{height:39%}.h-40{height:40%}.h-41{height:41%}.h-42{height:42%}.h-43{height:43%}.h-44{height:44%}.h-45{height:45%}.h-46{height:46%}.h-47{height:47%}.h-48{height:48%}.h-49{height:49%}.h-50{height:50%}.h-51{height:51%}.h-52{height:52%}.h-53{height:53%}.h-54{height:54%}.h-55{height:55%}.h-56{height:56%}.h-57{height:57%}.h-58{height:58%}.h-59{height:59%}.h-60{height:60%}.h-61{height:61%}.h-62{height:62%}.h-63{height:63%}.h-64{height:64%}.h-65{height:65%}.h-66{height:66%}.h-67{height:67%}.h-68{height:68%}.h-69{height:69%}.h-70{height:70%}.h-71{height:71%}.h-72{height:72%}.h-73{height:73%}.h-74{height:74%}.h-75{height:75%}.h-76{height:76%}.h-77{height:77%}.h-78{height:78%}.h-79{height:79%}.h-80{height:80%}.h-81{height:81%}.h-82{height:82%}.h-83{height:83%}.h-84{height:84%}.h-85{height:85%}.h-86{height:86%}.h-87{height:87%}.h-88{height:88%}.h-89{height:89%}.h-90{height:90%}.h-91{height:91%}.h-92{height:92%}.h-93{height:93%}.h-94{height:94%}.h-95{height:95%}.h-96{height:96%}.h-97{height:97%}.h-98{height:98%}.h-99{height:99%}.h-100{height:100%}
.w-0{width:0%}.w-1{width:1%}.w-2{width:2%}.w-3{width:3%}.w-4{width:4%}.w-5{width:5%}.w-6{width:6%}.w-7{width:7%}.w-8{width:8%}.w-9{width:9%}.w-10{width:10%}.w-11{width:11%}.w-12{width:12%}.w-13{width:13%}.w-14{width:14%}.w-15{width:15%}.w-16{width:16%}.w-17{width:17%}.w-18{width:18%}.w-19{width:19%}.w-20{width:20%}.w-21{width:21%}.w-22{width:22%}.w-23{width:23%}.w-24{width:24%}.w-25{width:25%}.w-26{width:26%}.w-27{width:27%}.w-28{width:28%}.w-29{width:29%}.w-30{width:30%}.w-31{width:31%}.w-32{width:32%}.w-33{width:33%}.w-34{width:34%}.w-35{width:35%}.w-36{width:36%}.w-37{width:37%}.w-38{width:38%}.w-39{width:39%}.w-40{width:40%}.w-41{width:41%}.w-42{width:42%}.w-43{width:43%}.w-44{width:44%}.w-45{width:45%}.w-46{width:46%}.w-47{width:47%}.w-48{width:48%}.w-49{width:49%}.w-50{width:50%}.w-51{width:51%}.w-52{width:52%}.w-53{width:53%}.w-54{width:54%}.w-55{width:55%}.w-56{width:56%}.w-57{width:57%}.w-58{width:58%}.w-59{width:59%}.w-60{width:60%}.w-61{width:61%}.w-62{width:62%}.w-63{width:63%}.w-64{width:64%}.w-65{width:65%}.w-66{width:66%}.w-67{width:67%}.w-68{width:68%}.w-69{width:69%}.w-70{width:70%}.w-71{width:71%}.w-72{width:72%}.w-73{width:73%}.w-74{width:74%}.w-75{width:75%}.w-76{width:76%}.w-77{width:77%}.w-78{width:78%}.w-79{width:79%}.w-80{width:80%}.w-81{width:81%}.w-82{width:82%}.w-83{width:83%}.w-84{width:84%}.w-85{width:85%}.w-86{width:86%}.w-87{width:87%}.w-88{width:88%}.w-89{width:89%}.w-90{width:90%}.w-91{width:91%}.w-92{width:92%}.w-93{width:93%}.w-94{width:94%}.w-95{width:95%}.w-96{width:96%}.w-97{width:97%}.w-98{width:98%}.w-99{width:99%}.w-100{width:100%}

/* ====================================================================== */
/* Portal-specific components (built from the same overtrue tokens)        */
/* ====================================================================== */
.user-chip { display: flex; align-items: center; gap: .5rem; color: hsl(var(--foreground)); font-size: .8125rem; }
.user-chip .avatar { display: inline-flex; width: 2rem; height: 2rem; border-radius: 999px; align-items: center; justify-content: center; background: hsl(var(--primary) / .12); color: hsl(var(--primary)); font-weight: 600; text-transform: uppercase; }
.user-chip .email { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { border-top: 1px solid var(--pn-line); margin-top: 1rem; padding: .75rem .5rem 0; font-size: .75rem; color: hsl(var(--muted-foreground)); }
.sidebar-foot a { color: hsl(var(--muted-foreground)); }
.portal-foot { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--pn-line); color: hsl(var(--muted-foreground)); font-size: .75rem; }
.portal-foot a { color: hsl(var(--muted-foreground)); }
.lede { margin: -.5rem 0 1rem; color: #6b7280; max-width: 52rem; }
.section-title { margin: 1.5rem 0 .75rem; font-size: 1rem; font-weight: 600; color: #111827; }
.section-note { margin: -.5rem 0 .75rem; color: #6b7280; font-size: .8125rem; }
.stack { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
.stack > .card, .grid > .card { margin: 0; }
.card-body p:first-child { margin-top: 0; }
.card-body p:last-child { margin-bottom: 0; }

/* subscription / traffic summary */
.sub-state { display: flex; align-items: center; gap: .5rem; margin: 0 0 .25rem; font-size: 1.125rem; font-weight: 600; color: #111827; }
.sub-state.is-inactive { color: #b91c1c; }
.hero-metric { font-size: 2rem; line-height: 2.5rem; font-weight: 600; color: #111827; font-variant-numeric: tabular-nums; }
.metric-split { color: #6b7280; font-size: .8125rem; margin: .25rem 0 0; }
.meter { height: .5rem; border-radius: 999px; background: hsl(var(--muted)); overflow: hidden; margin: .75rem 0 .25rem; }
.meter span { display: block; height: 100%; background: hsl(var(--chart-1)); border-radius: 999px; }
.meter.is-mid span { background: hsl(var(--warning)); }
.meter.is-high span { background: hsl(var(--destructive)); }
.card-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

/* source badges: purchase / gift card / admin grant */
.badge-source-purchase { background: hsl(var(--primary) / .12); color: hsl(var(--primary)); }
.badge-source-gift_card { background: hsl(var(--chart-4) / .15); color: hsl(var(--chart-4)); }
.badge-source-admin_grant { background: hsl(var(--warning) / .15); color: hsl(var(--warning)); }
.badge-paid { background: hsl(var(--success) / .15); color: hsl(var(--success)); }
.badge-pending { background: hsl(var(--warning) / .15); color: hsl(var(--warning)); }
.badge-failed, .badge-cancelled { background: hsl(var(--destructive) / .15); color: hsl(var(--destructive)); }
.badge-refunded, .badge-unknown { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.free-price { color: hsl(var(--chart-4)); font-weight: 500; }

/* list rows (recent orders etc.) */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--pn-line); }
.rows li:last-child { border-bottom: 0; }
.rows .row-main { min-width: 0; }
.rows .row-title { font-weight: 500; color: #111827; overflow-wrap: anywhere; }
.rows .row-meta { display: flex; flex-wrap: wrap; gap: .375rem; align-items: center; justify-content: flex-end; }

/* call-to-action card (gift card entry) */
.cta { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; }
.cta-icon { display: flex; flex-shrink: 0; width: 2.5rem; height: 2.5rem; border-radius: calc(var(--radius) * .75); align-items: center; justify-content: center; background: hsl(var(--chart-4) / .12); color: hsl(var(--chart-4)); }
.cta-icon svg { width: 1.25rem; height: 1.25rem; }
.cta-text { flex: 1; min-width: 0; }
.cta-text strong { display: block; color: #111827; font-weight: 500; }
.cta-text span { color: #6b7280; font-size: .8125rem; }

/* success state */
.success-card { border-color: color-mix(in srgb, #16a34a 35%, transparent); }
.success-head { display: flex; align-items: center; gap: .75rem; }
.success-icon { display: flex; width: 2.5rem; height: 2.5rem; border-radius: 999px; align-items: center; justify-content: center; background: hsl(var(--success) / .15); color: hsl(var(--success)); flex-shrink: 0; }
.success-icon svg { width: 1.25rem; height: 1.25rem; }
.gains { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; padding: 0; list-style: none; }
.gains li { border: 1px solid var(--pn-card-border); border-radius: calc(var(--radius) * .75); padding: .5rem .875rem; background: #fff; }
.gains li span { display: block; font-size: .75rem; color: #6b7280; }
.gains li strong { font-size: 1.125rem; color: #111827; }

/* packages */
.pkg-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.pkg { display: flex; flex-direction: column; margin: 0; }
.pkg .card-body { display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.pkg-name { margin: 0; font-size: 1rem; font-weight: 600; color: #111827; }
.pkg-bytes { font-size: 1.5rem; line-height: 2rem; font-weight: 600; color: #111827; }
.pkg-price { font-size: 1.125rem; font-weight: 600; color: hsl(var(--primary)); margin-top: auto; }
.pkg-desc { color: #6b7280; font-size: .8125rem; margin: 0; }
.pkg-plan { border-top: 3px solid hsl(var(--primary)); }
.pkg-addon { border-top: 3px solid hsl(var(--chart-2)); }

/* nodes */
.node-card { margin: 0; }
.node-card.is-selected { border-color: hsl(var(--primary)); box-shadow: 0 0 0 1px hsl(var(--primary)); }
.endpoint { font-family: var(--font-mono); font-size: .8125rem; color: #374151; overflow-wrap: anywhere; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* .actions is a flex row; keep table cells as cells so row borders span */
td.actions { display: table-cell; text-align: right; }

/* pager links and disabled buttons */
.pager-links { display: flex; gap: .375rem; }
.btn[aria-disabled="true"] { pointer-events: none; opacity: .5; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* auth flow */
.auth-card { margin: 0; }
.auth-links { text-align: center; margin: 1rem 0 0; color: #6b7280; font-size: .8125rem; }
.label-row { display: flex; justify-content: space-between; align-items: center; }
.label-row a { font-weight: 400; font-size: .8125rem; }
.auth-foot { text-align: center; margin-top: 1.25rem; font-size: .75rem; color: hsl(var(--muted-foreground)); }
.auth-foot a { color: hsl(var(--muted-foreground)); }
.dev-box { border: 1px dashed hsl(var(--warning)); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; background: color-mix(in srgb, #f76707 5%, white); }
.dev-box p { margin: .25rem 0; }

/* responsive stacked tables (td[data-label]) */
@media (max-width: 640px) {
  .page { padding: 1rem .75rem 2rem; }
  .user-chip .email { display: none; }
  .hero-metric { font-size: 1.75rem; }
  table.stacked thead { display: none; }
  table.stacked, table.stacked tbody, table.stacked tr, table.stacked td { display: block; width: 100%; }
  table.stacked tr { padding: .625rem 1rem; border-bottom: 1px solid var(--pn-line); }
  table.stacked tbody td { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; border: 0; text-align: right; }
  table.stacked tbody td::before { content: attr(data-label); color: #6b7280; font-size: .75rem; text-align: left; flex-shrink: 0; }
  table.stacked tbody td.actions { justify-content: flex-end; }
  table.stacked tbody td.actions::before { content: none; }
  .rows li { flex-direction: column; align-items: flex-start; }
  .rows .row-meta { justify-content: flex-start; }
  .cta { flex-wrap: wrap; }
}

/* Support tickets (工单). Message bodies are plain text: preserve line
   breaks, never overflow. */
.nav-count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.25rem; height: 1.25rem; margin-left: auto; padding: 0 .375rem; border-radius: 999px; background: hsl(var(--warning)); color: #fff; font-size: .6875rem; font-weight: 700; line-height: 1; }
.mobile-nav .nav-count { flex-shrink: 0; margin-left: .25rem; }
.unread-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 999px; background: hsl(var(--warning)); vertical-align: middle; }
tr.is-unread td { font-weight: 600; }
.ticket-link { color: inherit; overflow-wrap: anywhere; }
.ticket-title { overflow-wrap: anywhere; }
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: .875rem; }
.msg { border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: .75rem 1rem; background: hsl(var(--card)); max-width: 46rem; }
.msg-user { margin-left: auto; background: hsl(var(--primary) / .06); border-color: hsl(var(--primary) / .25); }
.msg-admin { border-left: 3px solid hsl(var(--primary)); }
.msg-system { background: hsl(var(--muted)); }
.msg-meta { font-size: .8125rem; margin-bottom: .375rem; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: .9375rem; line-height: 1.6; }
