/* ============================================================
   Client Billing Portal — modern UI (light + dark, CSP-safe)
   ============================================================ */

:root {
  color-scheme: light;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e7edf5;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --line: #e6e9ef;
  --line-strong: #cbd2dc;

  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --primary-soft: #eef2ff;
  --primary-contrast: #ffffff;
  --accent: #f59e0b;
  --info: #0ea5e9;
  --danger: #ef4444;
  --success: #16a34a;
  --warning: #d97706;

  --sidebar: #0b1220;
  --sidebar-soft: #1b2740;
  --sidebar-text: #e6ecf5;
  --sidebar-muted: #8b97ad;
  --sidebar-line: rgba(255, 255, 255, 0.08);

  --topbar-bg: rgba(246, 247, 251, 0.82);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.18);
  --ring: 0 0 0 3px rgba(99, 102, 241, 0.32);

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  font-family: var(--font-sans);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1526;
  --surface: #1a2336;
  --surface-2: #222d44;
  --surface-3: #2b3852;
  --text: #eef2f9;
  --text-soft: #cbd5e1;
  --muted: #8e9bb4;
  --line: #2a3650;
  --line-strong: #3a4663;

  --primary: #818cf8;
  --primary-strong: #6366f1;
  --primary-soft: rgba(99, 102, 241, 0.18);
  --primary-contrast: #0b1220;
  --accent: #fbbf24;
  --info: #38bdf8;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #fbbf24;

  --sidebar: #080d1a;
  --sidebar-soft: #16223a;
  --sidebar-text: #e6ecf5;
  --sidebar-muted: #8b97ad;
  --sidebar-line: rgba(255, 255, 255, 0.07);

  --topbar-bg: rgba(14, 21, 38, 0.82);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --ring: 0 0 0 3px rgba(129, 140, 248, 0.42);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0e1526;
    --surface: #1a2336;
    --surface-2: #222d44;
    --surface-3: #2b3852;
    --text: #eef2f9;
    --text-soft: #cbd5e1;
    --muted: #8e9bb4;
    --line: #2a3650;
    --line-strong: #3a4663;
    --primary: #818cf8;
    --primary-strong: #6366f1;
    --primary-soft: rgba(99, 102, 241, 0.18);
    --primary-contrast: #0b1220;
    --accent: #fbbf24;
    --info: #38bdf8;
    --danger: #f87171;
    --success: #4ade80;
    --warning: #fbbf24;
    --sidebar: #080d1a;
    --sidebar-soft: #16223a;
    --sidebar-text: #e6ecf5;
    --sidebar-muted: #8b97ad;
    --sidebar-line: rgba(255, 255, 255, 0.07);
    --topbar-bg: rgba(14, 21, 38, 0.82);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
    --ring: 0 0 0 3px rgba(129, 140, 248, 0.42);
  }
}

* { box-sizing: border-box; }

html { min-width: 320px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }

button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(99, 102, 241, 0.25); }

:focus-visible { outline: none; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ---------- App shell & sidebar ---------- */
.app-shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  padding: 20px 16px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex; flex-direction: column; gap: 22px;
  border-right: 1px solid var(--sidebar-line);
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 12px; color: #fff; min-width: 0; padding: 4px 6px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-weight: 800; font-size: 0.95rem; letter-spacing: 0.02em; flex: 0 0 auto;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}
.brand-text { display: grid; min-width: 0; }
.brand-text strong { font-size: 0.95rem; font-weight: 700; color: #fff; overflow-wrap: anywhere; }
.brand-text small { display: block; margin-top: 2px; color: var(--sidebar-muted); font-size: 0.75rem; }

.nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-xs);
  color: var(--sidebar-text); font-weight: 600; font-size: 0.9rem;
  border: 1px solid transparent; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: 0.8; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; color: #fff; }
.nav-item.active { background: rgba(99, 102, 241, 0.22); color: #fff; border-color: rgba(99, 102, 241, 0.4); }
.nav-item.active svg { opacity: 1; }

.sidebar-status {
  margin-top: auto; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px; border: 1px solid var(--sidebar-line); border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.03);
}
.sidebar-status strong { display: block; font-size: 0.82rem; }
.sidebar-status small { display: block; margin-top: 2px; color: var(--sidebar-muted); font-size: 0.72rem; overflow-wrap: anywhere; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; background: var(--sidebar-muted); }
.status-dot.online { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2); }
.status-dot.offline { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2); }

.logout-form { margin: 0; }
.logout-form .button { width: 100%; justify-content: flex-start; }

/* ---------- Icon buttons & topbar ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 40px; height: 40px; border-radius: var(--radius-xs);
  border: 1px solid var(--line); background: var(--surface); color: var(--text-soft);
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.icon-btn:focus-visible { box-shadow: var(--ring); }
.icon-btn svg { width: 18px; height: 18px; }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 32px; background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title .eyebrow { margin: 0 0 4px; }
.topbar-title h1 { font-size: 1.45rem; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.nav-toggle { display: none; }

.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: block; }
}

.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 14px 5px 5px; border: 1px solid var(--line);
  background: var(--surface); border-radius: 99px; box-shadow: var(--shadow-sm); max-width: 280px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-weight: 700; font-size: 0.78rem; letter-spacing: 0.02em;
}
.user-meta { display: grid; min-width: 0; }
.user-meta > span { font-size: 0.82rem; font-weight: 600; overflow-wrap: anywhere; }
.user-meta small { display: block; color: var(--muted); font-size: 0.72rem; overflow-wrap: anywhere; }

.content { padding: 28px 32px 52px; flex: 1; }

/* ---------- Typography helpers, surfaces, metrics ---------- */
.eyebrow { margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; font-weight: 700; }
.muted { color: var(--muted); }

.surface {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 22px;
}
.surface.narrow { max-width: 620px; }
.surface.wide { max-width: 1140px; }

.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.15rem; }
.section-note { margin: -2px 0 2px; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }

.account-hero { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
.account-hero .eyebrow { margin-bottom: 6px; }
.account-hero h2 { font-size: 1.45rem; }
.account-hero .muted { margin: 4px 0 0; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metrics.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; display: grid; gap: 10px; align-content: start;
}
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.metric-label { color: var(--muted); font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.metric-icon { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--primary-soft); color: var(--primary-strong); flex: 0 0 auto; }
.metric-icon svg { width: 18px; height: 18px; }
.metric-icon.warn { background: rgba(245, 158, 11, 0.16); color: var(--warning); }
.metric-icon.good { background: rgba(34, 197, 94, 0.16); color: var(--success); }
.metric-icon.info { background: rgba(14, 165, 233, 0.16); color: var(--info); }
.metric strong { display: block; font-size: 1.7rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.metric strong.small-value { font-size: 0.98rem; font-weight: 600; word-break: break-all; line-height: 1.3; }
.metric small { color: var(--muted); font-size: 0.78rem; line-height: 1.4; }
.metric-primary { border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); background: linear-gradient(180deg, var(--primary-soft), var(--surface)); }
.metric.warning strong { color: var(--warning); }

.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }

/* ---------- Tables & status pills ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 100%; }
th { text-align: left; color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td strong { font-weight: 600; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline-flex; }
.table-action { font-weight: 700; white-space: nowrap; color: var(--primary-strong); }
.table-action:hover { text-decoration: underline; }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px; border: 1px solid transparent;
  font-size: 0.74rem; font-weight: 700; text-transform: capitalize; white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.status.active { background: rgba(34, 197, 94, 0.14); color: var(--success); }
.status.pending, .status.draft { background: rgba(245, 158, 11, 0.16); color: var(--warning); }
.status.paused { background: rgba(14, 165, 233, 0.16); color: var(--info); }
.status.past_due, .status.canceled, .status.archived { background: rgba(239, 68, 68, 0.14); color: var(--danger); }
:root[data-theme="dark"] .status.active { background: rgba(74, 222, 128, 0.16); }
:root[data-theme="dark"] .status.pending, :root[data-theme="dark"] .status.draft { background: rgba(251, 191, 36, 0.18); }
:root[data-theme="dark"] .status.paused { background: rgba(56, 189, 248, 0.18); }
:root[data-theme="dark"] .status.past_due, :root[data-theme="dark"] .status.canceled, :root[data-theme="dark"] .status.archived { background: rgba(248, 113, 113, 0.16); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.grid-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
.form-section, .stacked { display: grid; gap: 16px; align-content: start; }
.form-section h2 { font-size: 1.05rem; }
.stacked { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.stacked h3 { font-size: 0.95rem; }
.form-title { display: grid; gap: 4px; margin-bottom: 4px; }
.form-title p { margin: 0; color: var(--muted); font-size: 0.88rem; }

label { display: grid; gap: 7px; color: var(--text-soft); font-weight: 600; font-size: 0.85rem; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); border-radius: var(--radius-xs); min-height: 44px; padding: 10px 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
select {
  appearance: none; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.checkbox { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.checkbox input { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
.compact-control { width: auto; min-height: 34px; padding: 6px 10px; }

/* ---------- Buttons ---------- */
.button, .link-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius-xs); min-height: 42px; padding: 10px 16px;
  cursor: pointer; font-weight: 600; font-size: 0.88rem; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.button:hover, .link-button:hover { text-decoration: none; border-color: var(--primary); color: var(--primary-strong); }
.button:active { transform: translateY(1px); }
.button:focus-visible, .link-button:focus-visible { box-shadow: var(--ring); }
.button svg { width: 16px; height: 16px; }
.button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); box-shadow: 0 6px 18px rgba(99, 102, 241, 0.3); }
.button.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: var(--primary-contrast); }
.button.small { min-height: 34px; padding: 7px 12px; font-size: 0.8rem; }
.button.ghost { width: 100%; background: transparent; border-color: var(--sidebar-line); color: var(--sidebar-text); justify-content: flex-start; }
.button.ghost:hover { background: var(--sidebar-soft); border-color: var(--sidebar-line); color: #fff; }
.link-button { border: 0; min-height: 0; padding: 2px 0; background: transparent; color: var(--primary-strong); white-space: nowrap; font-weight: 600; }
.link-button:hover { color: var(--primary); text-decoration: underline; }

.button-row, .form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; }
.button-row > form { display: inline-flex; }
.inline-form { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Flash & secrets ---------- */
.flash {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); border-left: 4px solid var(--primary);
}
.flash.error { border-left-color: var(--danger); }
.flash-icon { flex: 0 0 auto; width: 22px; height: 22px; color: var(--primary); margin-top: 1px; }
.flash.error .flash-icon { color: var(--danger); }
.flash-body { min-width: 0; }
.flash strong { font-size: 0.9rem; }
.flash p { margin: 3px 0 0; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.secret-box { margin-top: 12px; display: grid; gap: 8px; padding: 12px; border-radius: var(--radius-xs); background: var(--surface-2); border: 1px dashed var(--line-strong); }
.secret-label { color: var(--muted); font-weight: 700; font-size: 0.78rem; }
.secret-row { display: flex; align-items: center; gap: 10px; }
.secret-row code { font-family: var(--font-mono); font-size: 1rem; font-weight: 600; color: var(--text); word-break: break-all; flex: 1; min-width: 0; }
.copy-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-soft); border-radius: 7px; padding: 6px 10px; cursor: pointer; font-size: 0.78rem; font-weight: 600; flex: 0 0 auto; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.copy-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--primary); }
.copy-btn.copied { color: var(--success); border-color: var(--success); }
.copy-btn svg { width: 14px; height: 14px; }

/* ---------- Empty states & errors ---------- */
.empty-state { display: grid; gap: 8px; padding: 28px 22px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; align-content: center; justify-items: center; }
.empty-state.compact { padding: 22px; margin-bottom: 18px; }
.empty-icon { width: 42px; height: 42px; border-radius: 11px; display: inline-grid; place-items: center; background: var(--surface-3); color: var(--muted); margin-bottom: 4px; }
.empty-icon svg { width: 22px; height: 22px; }
.empty-state strong { font-size: 0.98rem; }
.empty-state p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 0.86rem; max-width: 44ch; }

.error-panel { display: grid; gap: 14px; align-items: center; text-align: center; justify-items: center; }
.error-icon { width: 56px; height: 56px; border-radius: 14px; display: inline-grid; place-items: center; background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.error-icon svg { width: 30px; height: 30px; }
.error-panel h2 { font-size: 1.3rem; }
.error-panel p { margin: 0; }

/* ---------- Auth (login) ---------- */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 28px; position: relative;
  background: radial-gradient(120% 120% at 0% 0%, rgba(99, 102, 241, 0.1), transparent 50%), radial-gradient(120% 120% at 100% 100%, rgba(139, 92, 246, 0.1), transparent 50%), var(--bg);
}
.auth-theme-toggle { position: fixed; top: 20px; right: 20px; z-index: 20; }
.login-panel { width: min(960px, 100%); display: grid; grid-template-columns: 1.05fr 0.95fr; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.login-copy { padding: 44px; background: linear-gradient(160deg, #0b1220, #1e293b 55%, #312e81 130%); color: #fff; display: grid; align-content: center; gap: 18px; position: relative; overflow: hidden; }
.login-copy::after { content: ""; position: absolute; inset: auto -40% -65% auto; width: 360px; height: 360px; background: radial-gradient(circle, rgba(129, 140, 248, 0.35), transparent 70%); filter: blur(8px); }
.login-copy .brand-mark { width: 54px; height: 54px; font-size: 1.1rem; position: relative; }
.login-copy .eyebrow { color: #a5b4fc; position: relative; }
.login-copy h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; position: relative; }
.login-copy p { color: #c7d2e8; max-width: 420px; margin: 0; line-height: 1.55; font-size: 0.96rem; position: relative; }
.login-features { display: grid; gap: 12px; margin-top: 6px; position: relative; }
.login-feature { display: flex; align-items: center; gap: 10px; color: #dbe4f5; font-size: 0.88rem; }
.login-feature svg { width: 18px; height: 18px; color: #a5b4fc; flex: 0 0 auto; }
.login-panel .surface { margin: 0; align-content: center; border: 0; box-shadow: none; border-radius: 0; padding: 44px; }

/* ---------- Mobile drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); z-index: 35; opacity: 0; transition: opacity 0.2s; }
.scrim[hidden] { display: none; }
.scrim.show { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 280px; height: 100vh; transform: translateX(-100%); transition: transform 0.25s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .nav-toggle { display: inline-flex; }
  .content { padding: 20px 18px 44px; }
  .topbar { padding: 12px 18px; }
  .metrics, .metrics.compact, .two-column, .grid-form, .login-panel { grid-template-columns: 1fr; }
  .login-panel { border-radius: var(--radius); }
  .login-copy { padding: 32px; }
  .login-panel .surface { padding: 32px; }
}
@media (max-width: 720px) {
  .topbar-title h1 { font-size: 1.2rem; }
  .user-meta { display: none; }
  .user-pill { padding: 4px; }
  .surface { padding: 18px; }
  .button-row, .form-actions { justify-content: stretch; }
  .button-row .button, .form-actions .button, .button-row > form { flex: 1; }
}
@media (max-width: 560px) {
  .metrics, .metrics.compact { grid-template-columns: 1fr; }
  .table-wrap table { min-width: 540px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

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