/* ============================================================
   VPN Fleet — Design System
   Hand-rolled CSS, no external dependencies.
   ============================================================ */

/* ── Custom properties (light theme) ── */
:root {
  /* Accent */
  --accent:        #3D6BFF;
  --accent-hover:  #2d58e8;
  --accent-subtle: #eef1ff;

  /* Status */
  --status-alive-bg:   #d1fae5;
  --status-alive-fg:   #065f46;
  --status-pending-bg: #fef3c7;
  --status-pending-fg: #92400e;
  --status-dead-bg:    #fee2e2;
  --status-dead-fg:    #991b1b;
  --status-disabled-bg:#f3f4f6;
  --status-disabled-fg:#6b7280;

  /* Grays */
  --bg:            #f8f9fb;
  --surface:       #ffffff;
  --surface-2:     #f3f4f6;
  --border:        #e5e7eb;
  --border-focus:  var(--accent);
  --text:          #111827;
  --text-2:        #6b7280;
  --text-3:        #9ca3af;

  /* Sidebar (light) */
  --sidebar-bg:    #f5f7fa;
  --sidebar-fg:    #6b7280;
  --sidebar-fg-active: #111827;
  --sidebar-active-bg: rgba(61,107,255,0.10);
  --sidebar-border:    #e5e7eb;
  --sidebar-hover-bg:  rgba(17,24,39,0.04);
  --sidebar-w:     220px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Fira Code", Consolas, monospace;

  /* Radii */
  --r-sm:  6px;
  --r:     10px;
  --r-lg:  14px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10);

  /* Semantic accent colors (status, callouts) */
  --ok: #10B981;
  --warn: #F59E0B;
  --danger: #EF4444;

  /* Font size scale */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
}

/* ── Dark theme (system preference) ── */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --accent:        #5b87ff;
    --accent-hover:  #7099ff;
    --accent-subtle: #1e2d5a;

    --status-alive-bg:   #064e3b;
    --status-alive-fg:   #6ee7b7;
    --status-pending-bg: #451a03;
    --status-pending-fg: #fbbf24;
    --status-dead-bg:    #450a0a;
    --status-dead-fg:    #fca5a5;
    --status-disabled-bg:#1f2937;
    --status-disabled-fg:#9ca3af;

    --bg:            #0d1117;
    --surface:       #161b22;
    --surface-2:     #21262d;
    --border:        #30363d;
    --text:          #e6edf3;
    --text-2:        #8b949e;
    --text-3:        #6e7681;

    --sidebar-bg:    #090d13;
    --sidebar-fg:    #6e7681;
    --sidebar-fg-active: #e6edf3;
    --sidebar-active-bg: rgba(255,255,255,0.06);
    --sidebar-border:    #21262d;
    --sidebar-hover-bg:  rgba(255,255,255,0.04);

    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow:    0 4px 12px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.45);
  }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 600; line-height: 1.25; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 .75em; }
code, pre { font-family: var(--font-mono); font-size: .875rem; }
pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: .75rem 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}
small { font-size: .8125rem; color: var(--text-2); }
dl { margin: 0 0 1.5rem; }
dt { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-top: .75rem; }
dd { margin: .2rem 0 0; }

/* ── Layout shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.25rem 1.25rem 1rem;
  color: var(--sidebar-fg-active);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.01em;
  text-decoration: none;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: .5rem;
}
.sidebar-brand:hover { text-decoration: none; color: var(--sidebar-fg-active); }
.sidebar-brand-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar-nav { flex: 1; padding: 0 .25rem; }
.sidebar-section { margin: 16px 0; }
.sidebar-section__label {
  padding: 0 16px 8px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  color: var(--sidebar-fg);
  text-decoration: none;
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
  margin: 0 8px;
  transition: background .12s, color .12s;
}
.sidebar-link:hover {
  color: var(--sidebar-fg-active);
  background: var(--sidebar-hover-bg);
  text-decoration: none;
}
.sidebar-link.is-active {
  color: var(--sidebar-fg-active);
  background: var(--sidebar-active-bg);
  font-weight: var(--fw-medium);
}
.sidebar-link svg { flex-shrink: 0; }
.sidebar-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  font-size: .8125rem;
}
.sidebar-email {
  color: var(--sidebar-fg);
  margin-bottom: .5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Top bar (no sidebar variant — login page, forbidden) ── */
.topbar {
  background: var(--sidebar-bg);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
  flex-shrink: 0;
}
.topbar-brand {
  font-weight: 700;
  font-size: 1rem;
  color: #f1f5f9;
  display: flex; align-items: center; gap: .5rem;
}
.topbar-brand:hover { text-decoration: none; color: #f1f5f9; }

/* ── Main content area ── */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.main-area.no-sidebar { margin-left: 0; }

.page-content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1100px;
}
.page-content.wide { max-width: none; }
.page-content.centered {
  max-width: 440px;
  margin: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1.5rem;
}

/* ── Flash / Alert ── */
.flash, .alert-success {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--r);
  padding: .875rem 1rem;
  margin-bottom: 1.5rem;
  color: #166534;
  font-size: .875rem;
}
.error, .alert-error {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--r);
  padding: .875rem 1rem;
  margin-bottom: 1.5rem;
  color: #991b1b;
  font-size: .875rem;
}
@media (prefers-color-scheme: dark) {
  .flash, .alert-success { background: #052e16; border-color: #166534; color: #86efac; }
  .error, .alert-error   { background: #450a0a; border-color: #991b1b; color: #fca5a5; }
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}
.page-subtitle {
  color: var(--text-2);
  font-size: .875rem;
  margin: .25rem 0 0;
}

/* ── Stat cards ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-label {
  font-size: .8125rem;
  color: var(--text-2);
  margin-top: .25rem;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  padding: .625rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td {
  padding: .75rem 1rem;
  font-size: .875rem;
  vertical-align: middle;
}
.data-table td.mono {
  font-family: var(--font-mono);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
}
.data-table .actions {
  text-align: right;
  white-space: nowrap;
}
.data-table .empty-row td {
  text-align: center;
  color: var(--text-2);
  padding: 2rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1rem;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1.5px solid transparent;
  line-height: 1.4;
  transition: background .12s, box-shadow .12s, border-color .12s, color .12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Primary */
.btn-primary, button.btn-primary, input[type=submit].btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

/* Secondary / outline */
.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }

/* Destructive */
.btn-danger {
  background: transparent;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fef2f2; border-color: #dc2626; color: #dc2626; }
@media (prefers-color-scheme: dark) {
  .btn-danger { color: #f87171; border-color: #7f1d1d; }
  .btn-danger:hover { background: #450a0a; border-color: #dc2626; color: #f87171; }
}

/* Small */
.btn-sm { padding: .3125rem .75rem; font-size: .8125rem; }

/* Legacy compatibility — bare <button class="danger"> */
button.danger {
  display: inline-flex;
  align-items: center;
  padding: .3125rem .75rem;
  border-radius: var(--r-sm);
  font-size: .8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: #dc2626;
  border: 1.5px solid #fca5a5;
  transition: background .12s, border-color .12s;
}
button.danger:hover { background: #fef2f2; border-color: #dc2626; }
@media (prefers-color-scheme: dark) {
  button.danger { color: #f87171; border-color: #7f1d1d; }
  button.danger:hover { background: #450a0a; border-color: #dc2626; }
}

/* Logout button in sidebar footer */
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem .75rem;
  border-radius: var(--r-sm);
  font-size: .8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-fg);
  border: 1px solid var(--sidebar-border);
  transition: background .12s, color .12s;
  width: 100%;
  justify-content: center;
}
.btn-logout:hover { background: var(--sidebar-active-bg); color: var(--sidebar-fg-active); }

/* ── Forms ── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.form-group {
  margin-bottom: 1.125rem;
}
.form-group label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: .375rem;
}
.form-control {
  display: block;
  width: 100%;
  padding: .5625rem .75rem;
  font-size: .9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color .12s, box-shadow .12s;
  outline: none;
  line-height: 1.5;
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(61, 107, 255, .15);
}
.form-control.mono {
  font-family: var(--font-mono);
  font-size: .875rem;
}
select.form-control { cursor: pointer; }
@media (prefers-color-scheme: dark) {
  .form-control { background: var(--surface-2); }
}

.form-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: 1.5rem;
}
.form-cancel {
  font-size: .875rem;
  color: var(--text-2);
}
.form-cancel:hover { color: var(--text); }

/* ── Status badges ── */
.status {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.status::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status-alive    { background: var(--status-alive-bg);    color: var(--status-alive-fg); }
.status-pending  { background: var(--status-pending-bg);  color: var(--status-pending-fg); }
.status-dead     { background: var(--status-dead-bg);     color: var(--status-dead-fg); }
.status-disabled { background: var(--status-disabled-bg); color: var(--status-disabled-fg); }

/* ── Role badge ── */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--accent-subtle);
  color: var(--accent);
}
.role-badge.admin { background: #ede9fe; color: #6d28d9; }
@media (prefers-color-scheme: dark) {
  .role-badge { background: var(--accent-subtle); color: var(--accent); }
  .role-badge.admin { background: #2e1065; color: #c4b5fd; }
}

/* ── Monospace cells ── */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ── Invite code ── */
.invite-code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .12em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .75rem 1.25rem;
  margin: .75rem 0;
}

/* ── Profile info block ── */
.profile-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .375rem 1.25rem;
  align-items: baseline;
}
.profile-key {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
}
.profile-val {
  font-size: .9375rem;
}

/* ── Device / traffic chart ── */
.traffic-chart-wrap {
  margin: 1rem 0 1.5rem;
}
.traffic-chart-wrap h4 {
  font-size: .875rem;
  color: var(--text-2);
  margin-bottom: .5rem;
}
.traffic-legend {
  font-size: .75rem;
  color: var(--text-2);
  margin-top: .375rem;
}
.traffic-summary { white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }

/* ── Map table ── */
.map-table { border-collapse: collapse; }
.map-table th, .map-table td {
  border: 1px solid var(--border);
  padding: .5rem .75rem;
  text-align: center;
  font-size: .8125rem;
}
.map-table th { background: var(--surface-2); font-weight: 600; }
.map-table td.cell-none { color: var(--text-3); }
.map-table td.fresh-fast { background: var(--status-alive-bg); }
.map-table td.fresh-slow { background: var(--status-pending-bg); }
.map-table td.stale { background: var(--surface-2); color: var(--text-2); }
.map-table td.failed { background: var(--status-dead-bg); }

/* ── Login page ── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin-bottom: 1.75rem;
}
.login-logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: #fff;
}
.login-logo-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.login-card h2 {
  font-size: 1.25rem;
  margin-bottom: .25rem;
}
.login-sub {
  color: var(--text-2);
  font-size: .875rem;
  margin-bottom: 1.5rem;
}

/* ── Forbidden page ── */
.forbidden-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.forbidden-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 3rem 2.5rem;
  max-width: 460px;
  text-align: center;
}
.forbidden-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

/* ── Section divider ── */
.section-title {
  font-size: .8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  margin: 1.75rem 0 .875rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Inline action group ── */
.action-group {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ── Utilities ── */
.text-muted { color: var(--text-2); }
.text-sm    { font-size: .8125rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ── Inline rename form on /me ── */
.inline-rename {
  display: inline-flex; align-items: center; gap: .375rem;
  margin: 0; padding: 0;
}
.form-control-inline {
  width: 100%; max-width: 220px;
  padding: .3rem .55rem; font-size: .9rem;
}

/* ── Page layout (v3 — Phase B) ── */
.page { max-width: 1280px; padding: 32px 40px; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 28px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.page-subtitle { font-size: 14px; color: var(--text-2); margin: 0; }

/* ── Card v3 overrides (no-padding variant + proper card-header) ── */
/* .card--flush: card with no outer padding; children own their spacing.
   Use for cards containing device lists, tables, etc. */
.card--flush { padding: 0; overflow: hidden; }
/* Upgrade card-header for v3: adds internal padding + bottom border separator */
.card--flush .card-header,
.card-header--v3 {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.card--flush .card-header h2,
.card-header--v3 h2 { font-size: 16px; font-weight: 600; margin: 0; color: var(--text); }

/* ── KPI strip ── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--r);
  border: 1px solid var(--border);
}
.kpi-card { padding: 12px 16px; background: var(--surface); border-radius: var(--r-sm); }
.kpi-label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 600; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-trend { font-size: 13px; color: var(--ok); margin-left: 6px; font-weight: 400; }

/* ── Device list ── */
.device-list { list-style: none; padding: 0; margin: 0; }
.device-row {
  display: grid;
  grid-template-columns: 28px 1fr auto 40px;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.device-row:last-child { border-bottom: none; }
.device-row:hover { background: var(--surface-2); }
.device-icon { color: var(--text-3); display: flex; align-items: center; }
.device-name { font-weight: 600; font-size: 14px; color: var(--text); }
.device-hostname { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* sparkline + bytes wrapped in a clickable link */
.device-traffic-link {
  display: inline-flex; align-items: center; gap: 12px;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  color: inherit;
}
.device-traffic-link:hover {
  background: var(--surface);
  border-color: var(--border);
}
.device-sparkline { display: flex; align-items: flex-end; line-height: 0; }
.sparkline-svg { display: block; overflow: hidden; }
.bytes-indicator { font-size: 13px; display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; min-width: 90px; }
.bytes-indicator .up { color: var(--accent); }
.bytes-indicator .down { color: var(--text-2); }

/* KPI card that's clickable for popup */
.kpi-card--link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  display: block;
  transition: background 0.12s, box-shadow 0.12s;
}
.kpi-card--link:hover {
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

/* traffic color accents reusable */
.traffic-up { color: var(--ok); }
.traffic-down { color: var(--accent); }

/* btn-icon variant: danger (delete) — visible trash icon */
.btn-icon--danger { color: var(--text-3); }
.btn-icon--danger:hover { background: var(--status-dead-bg); color: var(--danger); }
.btn-icon svg { display: block; }

/* ── Kebab menu ── */
.kebab-wrap { position: relative; display: flex; justify-content: center; }
.kebab {
  width: 32px; height: 32px;
  border: none; background: transparent;
  color: var(--text-3); cursor: pointer;
  border-radius: var(--r-sm);
  font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.kebab:hover { background: var(--surface-2); color: var(--text); }
.kebab-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 220px;
}
.kebab-rename-form { display: flex; gap: 8px; align-items: center; }
.kebab-rename-input { flex: 1; padding: .3rem .55rem; font-size: .875rem; }
.kebab-divider { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* ── Outline-sm button (card header "Add device") ── */
.btn-outline-sm {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text); background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn-outline-sm:hover { background: var(--surface-2); border-color: var(--text-3); text-decoration: none; }

/* ── Empty state stub (full styling in Phase E Task 14) ── */
.empty-state-stub {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
}

/* ── Mobile top bar (lives inside .main-area; hidden on desktop) ── */
.mobile-bar {
  display: none;
  align-items: center;
  gap: .75rem;
  height: 52px;
  padding: 0 .875rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.mobile-menu-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; padding: 0;
}
.mobile-menu-btn:hover { background: var(--surface-2); }
.mobile-brand { font-weight: 600; letter-spacing: .02em; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 40;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-shell { display: block; }      /* don't fight the sidebar in flex flow */
  .mobile-bar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(260px, 80vw);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    z-index: 60;
    box-shadow: 0 0 24px rgba(0,0,0,.35);
  }
  .main-area {
    margin-left: 0;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;               /* clip stray wide content */
  }
  .page-content { padding: 1rem .875rem; min-width: 0; }

  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }

  /* Tighter cards / typography */
  .stats-row { grid-template-columns: 1fr; }
  .card { padding: 1rem; }
  .page-content h1 { font-size: 1.5rem; }
  .page-content h2 { font-size: 1.15rem; }

  /* Tables: horizontal scroll inside .table-wrap so layout doesn't blow up */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .data-table { min-width: 540px; }

  /* Form / action groups stack vertically on mobile */
  .form-actions, .action-group {
    flex-direction: column; align-items: stretch;
  }
  .form-actions .btn, .action-group .btn { width: 100%; }

  /* Long mono strings (IPs, tokens, pubkeys) break instead of overflowing */
  .mono, code, pre { word-break: break-all; overflow-wrap: anywhere; }

  /* Hero / cards that previously assumed wide viewport */
  .traffic-chart-wrap svg { max-width: 100% !important; }

  /* ── v3 mobile overrides ── */
  .page { padding: 16px; }
  .page-header h1 { font-size: 22px; }

  .kpi-strip { padding: 12px; gap: 8px; }
  .kpi-value { font-size: 22px; }

  .data-table { font-size: 13px; }
  .data-table thead th,
  .data-table tbody td { padding: 10px 12px; }

  .card-header { padding: 12px 16px; }
  .card-header__actions { gap: 4px; }

  .platform-grid { grid-template-columns: 1fr !important; }

  .device-row {
    grid-template-columns: 32px 1fr 80px;
    grid-template-areas:
      "icon meta meta"
      "icon spark bytes";
    gap: 8px;
  }
  .device-row .device-sparkline { grid-area: spark; }
  .device-row .bytes-indicator { grid-area: bytes; }
  .device-row .device-icon { grid-area: icon; }
  .device-row .device-meta { grid-area: meta; }
  .device-row .kebab { display: none; }  /* hide kebab on mobile, swipe-to-delete TBD */

  .map-matrix th, .map-matrix td { padding: 6px 8px; font-size: 12px; }

  .setting-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .setting-row__action { width: 100%; }
}

/* ── Theme switcher ── */
.theme-switcher {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  background: var(--sidebar-hover-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--r-sm);
}
.theme-switcher__btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--sidebar-fg);
  cursor: pointer;
}
.theme-switcher__btn:hover {
  color: var(--sidebar-fg-active);
}
.theme-switcher__btn.is-active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-fg-active);
}

/* ============================================================
   Theme: explicit dark override
   Activates when <html data-theme="dark"> regardless of OS setting.
   ============================================================ */
[data-theme="dark"] {
  --accent:        #5b87ff;
  --accent-hover:  #7099ff;
  --accent-subtle: #1e2d5a;

  --bg:            #0d1117;
  --surface:       #161b22;
  --surface-2:     #21262d;
  --border:        #30363d;

  --text:          #e6edf3;
  --text-2:        #8b949e;
  --text-3:        #6e7681;

  --status-alive-bg:   #064e3b;
  --status-alive-fg:   #6ee7b7;
  --status-pending-bg: #451a03;
  --status-pending-fg: #fbbf24;
  --status-dead-bg:    #450a0a;
  --status-dead-fg:    #fca5a5;
  --status-disabled-bg:#1f2937;
  --status-disabled-fg:#9ca3af;

  --ok: #34D399;
  --warn: #FBBF24;
  --danger: #F87171;

  --sidebar-bg:    #090d13;
  --sidebar-fg:    #6e7681;
  --sidebar-fg-active: #e6edf3;
  --sidebar-active-bg: rgba(255,255,255,0.06);
  --sidebar-border:    #21262d;
  --sidebar-hover-bg:  rgba(255,255,255,0.04);

  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow:    0 4px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.45);
}

/* Component dark-mode rules for explicit data-theme="dark"
   (mirrors the @media (prefers-color-scheme: dark) component blocks above
    so explicit dark mode works even on a light OS). */
[data-theme="dark"] .flash,
[data-theme="dark"] .alert-success { background: #052e16; border-color: #166534; color: #86efac; }
[data-theme="dark"] .error,
[data-theme="dark"] .alert-error   { background: #450a0a; border-color: #991b1b; color: #fca5a5; }

[data-theme="dark"] .btn-danger { color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] .btn-danger:hover { background: #450a0a; border-color: #dc2626; color: #f87171; }

[data-theme="dark"] button.danger { color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] button.danger:hover { background: #450a0a; border-color: #dc2626; }

[data-theme="dark"] .form-control { background: var(--surface-2); }

[data-theme="dark"] .role-badge { background: var(--accent-subtle); color: var(--accent); }
[data-theme="dark"] .role-badge.admin { background: #2e1065; color: #c4b5fd; }

/* ── Clickable traffic cells (open popup on click) ───────────────────── */
.traffic-link {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  cursor: pointer;
  font-family: var(--font-mono);
}
.traffic-link:hover {
  text-decoration: none;
  border-bottom-color: var(--accent);
}

/* ── Traffic popup (universal admin chart modal) ──────────────────────── */
.traffic-popup {
  position: fixed; inset: 0;
  display: none;
  z-index: 1000;
}
body.traffic-popup-open .traffic-popup { display: block; }

.traffic-popup-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.traffic-popup-panel {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem 1.5rem;
}

.traffic-popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.traffic-popup-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.traffic-popup-totals {
  font-size: .95rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.btn-group {
  display: inline-flex;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.btn-group .btn {
  border: none;
  border-radius: 0;
  background: transparent;
}
.btn-group .btn + .btn { border-left: 1px solid var(--border); }
.btn-group .btn.is-active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

.traffic-popup-body { min-height: 160px; }

[data-theme="dark"] .traffic-popup-panel { background: var(--surface-2, var(--surface)); }

/* ── Map matrix (v3 — Phase B Task 2) ── */
.map-matrix-wrap { overflow-x: auto; }

.map-matrix {
  width: 100%;
  border-collapse: collapse;
}

.map-matrix th,
.map-matrix td {
  padding: 8px 12px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

/* Corner cell */
.map-corner {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 2;
}

/* Server column headers */
.map-server-h {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* Device row headers (sticky left column) */
.map-device-h {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 160px;
}

.map-device-h .device-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.map-device-h .device-owner {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 400;
  margin-top: 2px;
}

/* Base cell */
.map-cell {
  min-width: 80px;
  height: 56px;
  border: 1px solid var(--border);
  font-size: 13px;
}

/* Status variants */
.map-cell--alive    { background: var(--status-alive-bg);    color: var(--status-alive-fg); }
.map-cell--pending  { background: var(--status-pending-bg);  color: var(--status-pending-fg); }
.map-cell--dead     { background: var(--status-dead-bg);     color: var(--status-dead-fg); }
.map-cell--disabled { background: var(--status-disabled-bg); color: var(--status-disabled-fg); }

/* Cell content */
.map-latency { font-weight: 600; line-height: 1.2; }
.map-age     { font-size: 11px; opacity: 0.7; margin-top: 2px; }

/* Legend row */
.map-legend {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
}

.legend-chip--alive    { color: var(--status-alive-fg); }
.legend-chip--pending  { color: var(--status-pending-fg); }
.legend-chip--dead     { color: var(--status-dead-fg); }
.legend-chip--disabled { color: var(--status-disabled-fg); }

/* ─── Auth screens (login, forbidden) ─── */
.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--surface);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 32px;
}
.auth-brand {
  width: 40px; height: 40px;
  background: var(--accent); color: white;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  margin: 0 auto 16px;
  user-select: none;
}
.auth-title {
  font-size: 24px; font-weight: 700;
  text-align: center; margin: 0 0 4px;
  color: var(--text);
}
.auth-subtitle {
  font-size: 13px; color: var(--text-2);
  text-align: center; margin: 0 0 24px;
}
.auth-error {
  padding: 12px 16px;
  background: var(--status-dead-bg);
  color: var(--status-dead-fg);
  border-radius: var(--r-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-field input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.1s, box-shadow 0.1s;
  outline: none;
}
.form-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,107,255,0.18);
}
.btn-primary-block {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: var(--accent); color: white;
  border: none; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s;
}
.btn-primary-block:hover { background: var(--accent-hover); text-decoration: none; }
.auth-footer {
  font-size: 13px; color: var(--text-2);
  text-align: center; margin: 24px 0 0;
}
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ─── Settings rows (Account, etc.) ─── */
.settings { padding: 0; }
.setting-row {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row__main { flex: 1; min-width: 0; }
.setting-row__label { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.setting-row__value { font-size: 14px; color: var(--text-2); }
.setting-row__desc { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.setting-row__action { flex-shrink: 0; }

/* ─── Status chips ─── */
.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
}
.chip--admin   { background: #dbeafe; color: #1e40af; }
.chip--member  { background: #f1f5f9; color: #475569; }

/* ─── Buttons (small variants) ─── */
.btn-primary-sm {
  padding: 6px 12px;
  background: var(--accent); color: white;
  border: none; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}
.btn-primary-sm:hover { background: var(--accent-hover); }
.btn-outline-sm {
  display: inline-block;
  padding: 6px 12px;
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn-outline-sm:hover { background: var(--surface); }

/* ─── Inline edit (details/summary) ─── */
.inline-edit summary { list-style: none; cursor: pointer; }
.inline-edit summary::-webkit-details-marker { display: none; }
.inline-edit-form {
  display: flex; gap: 8px; align-items: center;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.inline-edit-form--stacked { flex-direction: column; align-items: stretch; }
.inline-edit-form input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

/* ─── Dark theme overrides ─── */
[data-theme="dark"] .chip--admin   { background: rgba(59,130,246,0.2); color: #93c5fd; }
[data-theme="dark"] .chip--member  { background: var(--surface-2); color: var(--text-2); }
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .chip--admin  { background: rgba(59,130,246,0.2); color: #93c5fd; }
  [data-theme="system"] .chip--member { background: var(--surface-2); color: var(--text-2); }
}

[data-theme="dark"] .form-field input { background: var(--surface-2); }

/* ─── Downloads page ─── */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--r);
}
.platform-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.platform-card--disabled { opacity: 0.6; }
.platform-icon {
  width: 32px; height: 32px;
  color: var(--text);
  margin-bottom: 4px;
}
.platform-icon-svg {
  width: 32px; height: 32px;
}
.platform-name { font-size: 16px; font-weight: 600; color: var(--text); }
.platform-name__version {
  font-size: 12px; color: var(--text-2);
  font-weight: 400;
  margin-left: 8px;
}
.platform-desc {
  font-size: 13px;
  color: var(--text-2);
  margin: 4px 0 12px;
  flex: 1;
}
.platform-action { margin-top: auto; }
.badge-disabled {
  display: inline-block;
  padding: 8px 16px;
  background: var(--surface-2); color: var(--text-3);
  border-radius: 6px;
  font-size: 14px;
}
.downloads-cta {
  text-align: center;
  margin: 24px 0;
  color: var(--text-2);
  font-size: 14px;
}
.downloads-cta a { color: var(--accent); text-decoration: none; }
.downloads-cta a:hover { text-decoration: underline; }

/* ─── Users list — data table v3 extensions ─── */
.data-table__actions { text-align: right; white-space: nowrap; }
.data-table__actions a,
.data-table__actions button { margin-left: 4px; vertical-align: middle; }

.cell-dim { color: var(--text-2); font-size: 13px; }

.cell-user { display: flex; align-items: center; gap: 12px; }
.cell-user__meta { display: flex; flex-direction: column; }
.cell-user__name { font-weight: 600; font-size: 14px; color: var(--text); }
.cell-user__email { font-size: 12px; color: var(--text-2); }

.avatar-initials {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}

.card-header__actions { display: flex; gap: 8px; align-items: center; }

.btn-icon {
  width: 32px; height: 32px;
  background: transparent; border: none;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 6px;
  font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

.link-danger {
  background: transparent; border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  padding: 4px 8px;
  font-family: inherit;
}
.link-danger:hover { text-decoration: underline; }

.inline-form { display: inline; }

/* ─── Status dot prefix (used in KPI labels) ─── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.status-dot--alive    { background: var(--ok); }
.status-dot--pending  { background: var(--warn); }
.status-dot--dead     { background: var(--danger); }
.status-dot--disabled { background: var(--text-3); }

/* ─── Chips for server status ─── */
.chip--alive    { background: var(--status-alive-bg);    color: var(--status-alive-fg); }
.chip--pending  { background: var(--status-pending-bg);  color: var(--status-pending-fg); }
.chip--dead     { background: var(--status-dead-bg);     color: var(--status-dead-fg); }
.chip--disabled { background: var(--status-disabled-bg); color: var(--status-disabled-fg); }

/* ─── Server name cell with provider badge ─── */
.cell-server-name { display: flex; align-items: center; gap: 8px; }
.server-name { font-weight: 600; }

/* ─── Provider badge ─── */
.provider-badge {
  display: inline-block;
  width: 26px; height: 20px;
  border-radius: 4px;
  text-align: center;
  line-height: 20px;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  letter-spacing: 0;
}
.provider-badge--aws      { background: #FF9900; }
.provider-badge--gcp      { background: #4285F4; }
.provider-badge--azure    { background: #0078D4; }
.provider-badge--do       { background: #0080FF; }
.provider-badge--hetzner  { background: #D50C2D; }
.provider-badge--linode   { background: #00A95C; }
.provider-badge--vultr    { background: #007BFC; }
.provider-badge--ovh      { background: #123F6D; }
.provider-badge--scaleway { background: #4F0599; }
.provider-badge--unknown  { background: var(--text-3); }

/* ─── Callout code block (bootstrap token) ─── */
.callout-code {
  margin-top: 8px;
  padding: 12px;
  background: rgba(0,0,0,0.06);
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
  color: inherit;
  border: none;
}

/* ─── Devices list ─── */
.cell-device__name { font-weight: 600; font-size: 14px; color: var(--text); }
.cell-device__host { font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-2); margin-top: 2px; }
.pubkey { font-size: 12px; vertical-align: middle; }
.btn-copy {
  background: transparent; border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 2px 4px;
  margin-left: 4px;
  border-radius: 4px;
  font-size: 14px;
}
.btn-copy:hover { background: var(--surface-2); color: var(--text); }

/* ─── Form layout (forms in cards) ─── */
.form-card-v3 { padding: 20px; }
.form-row {
  display: flex; flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-row label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.1s, box-shadow 0.1s;
  outline: none;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,107,255,0.18);
}
.form-row__help {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 4px;
}
.form-row__inline-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  float: right;
  margin-top: -22px;
}
.form-row__inline-link:hover { text-decoration: underline; }

.form-actions-v3 {
  display: flex; align-items: center; gap: 12px;
  margin-top: 8px;
}
.form-actions-v3__right { margin-left: auto; }
.btn-primary-v3 {
  display: inline-flex; align-items: center;
  padding: 10px 20px;
  background: var(--accent); color: white;
  border: none; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s;
}
.btn-primary-v3:hover { background: var(--accent-hover); color: white; text-decoration: none; }
.btn-link-v3 {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.btn-link-v3:hover { text-decoration: underline; }
.btn-danger-outline {
  display: inline-flex; align-items: center;
  padding: 8px 16px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-danger-outline:hover { background: var(--status-dead-bg); }

.form-row--readonly input {
  background: var(--surface-2);
  color: var(--text-2);
  cursor: default;
}
[data-theme="dark"] .form-row input,
[data-theme="dark"] .form-row select,
[data-theme="dark"] .form-row textarea { background: var(--surface-2); }
[data-theme="dark"] .form-row--readonly input { background: var(--surface); }
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .form-row input,
  [data-theme="system"] .form-row select,
  [data-theme="system"] .form-row textarea { background: var(--surface-2); }
  [data-theme="system"] .form-row--readonly input { background: var(--surface); }
}

/* ─── Success card (invite_success, etc.) ─── */
.success-card {
  max-width: 600px;
  margin: 0 auto;
  padding: 32px;
  text-align: center;
}
.success-card__icon { margin-bottom: 16px; display: flex; justify-content: center; }
.success-card__title {
  font-size: 22px; font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}
.success-card__expires {
  font-size: 13px; color: var(--text-2);
  margin: 0 0 24px;
}
.success-card__hint {
  font-size: 13px; color: var(--text-2);
  margin: 16px 0 24px;
}
.success-card__actions {
  display: flex; justify-content: center; gap: 12px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 8px;
}

/* ─── Copy-input group (read-only URL + Copy button) ─── */
.copy-input-group {
  display: flex; gap: 8px;
  margin: 0 auto;
  max-width: 480px;
}
.copy-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

/* ─── Info / warning callouts (form inline) ─── */
.callout {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.callout svg { flex-shrink: 0; margin-top: 2px; }
.callout--info {
  background: rgba(61,107,255,0.08);
  color: var(--text);
  border: 1px solid rgba(61,107,255,0.18);
}
.callout--info svg { color: var(--accent); }

/* ─── Mono input inside form-row ─── */
.form-row__mono {
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

/* ─── Forbidden screen ─── */
.forbidden-card { text-align: center; padding: 40px 32px; }
.icon-circle {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
}
.icon-circle--danger {
  background: var(--status-dead-bg);
  color: var(--danger);
}
.forbidden-body {
  font-size: 14px; color: var(--text-2);
  margin: 0 0 28px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}
.forbidden-actions {
  display: flex; flex-direction: column;
  gap: 12px; align-items: center;
}
.logout-mini { margin: 0; }
.logout-mini button {
  background: transparent;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* ─── Empty state (lists) ─── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 64px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty-state__icon { width: 48px; height: 48px; color: var(--text-3); margin-bottom: 16px; }
.empty-state__title { font-size: 16px; font-weight: 600; margin: 0 0 6px; color: var(--text); }
.empty-state__desc { font-size: 13px; margin: 0 0 20px; max-width: 320px; }
.empty-state .btn-primary-v3 { font-size: 14px; }

/* ─── Accessibility ─── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Inputs already have explicit focus rings, skip them for :focus-visible */
.form-row input:focus-visible,
.form-row select:focus-visible,
.form-row textarea:focus-visible { outline: none; }

/* Visually hidden but readable by screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
