/* ============================================================
   WP Multi-Site Console — modern SaaS UI
   ============================================================ */
:root {
  --bg: #f6f7fb;
  --bg-2: #eef0f6;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --soft: #475569;
  --muted: #94a3b8;
  --line: #e6e8ef;
  --line-2: #eef0f6;

  --brand: #6366f1;
  --brand-dk: #4f46e5;
  --brand-sf: #eef0fe;
  --brand-2: #8b5cf6;

  --ok: #16a34a;
  --ok-bg: #e7f7ed;
  --warn: #d97706;
  --warn-bg: #fef4e2;
  --bad: #dc2626;
  --bad-bg: #fdecec;
  --info: #0284c7;
  --info-bg: #e1f3fc;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.06), 0 24px 48px rgba(15, 23, 42, 0.08);

  --sidebar-w: 240px;
  --topbar-h: 60px;
}

[data-theme="dark"] {
  --bg: #0b1020;
  --bg-2: #0e1428;
  --surface: #121a31;
  --surface-2: #0f1730;
  --ink: #e5e9f4;
  --ink-2: #f1f4fb;
  --soft: #b1bbd1;
  --muted: #7d889f;
  --line: #1e2741;
  --line-2: #182040;

  --brand: #818cf8;
  --brand-dk: #a5b4fc;
  --brand-sf: #1c2350;
  --brand-2: #c4b5fd;

  --ok-bg: #0e2f1d;
  --warn-bg: #3a2810;
  --bad-bg: #3a1414;
  --info-bg: #0d2b40;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.5), 0 24px 48px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter",
               Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dk); }

code, pre {
  font-family: "SF Mono", "JetBrains Mono", Consolas, Menlo, monospace;
  font-size: 12.5px;
}
code {
  background: var(--bg-2);
  color: var(--ink);
  padding: 0.12em 0.45em;
  border-radius: 5px;
}

/* ============================================================
   App shell — sidebar + topbar + main
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--line-2);
}
.brand-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.28);
}
.brand-name { font-weight: 700; font-size: 14.5px; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.sidebar-section {
  padding: 14px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar-nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--soft);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.sidebar-nav a:hover {
  background: var(--bg-2);
  color: var(--ink);
}
.sidebar-nav a.on {
  background: var(--brand-sf);
  color: var(--brand-dk);
  font-weight: 600;
}
.sidebar-nav a .ico {
  width: 18px; height: 18px;
  display: inline-grid; place-items: center;
  flex-shrink: 0;
}
.sidebar-nav a .ico svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid var(--line-2);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  position: relative;
  cursor: pointer;
}
.user-card:hover { background: var(--bg-2); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.user-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 30;
}
.user-menu.open { display: block; }
.user-menu a, .user-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--soft);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}
.user-menu a:hover, .user-menu button:hover { background: var(--bg-2); color: var(--ink); }

/* Topbar */
.app-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.crumb { font-size: 13.5px; color: var(--muted); }
.crumb strong { color: var(--ink); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid transparent;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--soft);
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.search {
  position: relative;
}
.search input {
  background: var(--bg-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 34px;
  font-size: 13.5px;
  width: 240px;
  color: var(--ink);
  font-family: inherit;
}
.search input:focus { outline: none; background: var(--surface); border-color: var(--brand); }
.search svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--muted);
  stroke: currentColor; fill: none; stroke-width: 1.7;
}

/* Main content area */
.content {
  flex: 1;
  padding: 28px 32px 60px;
  max-width: 1400px;
  width: 100%;
}

.foot {
  padding: 20px 32px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.foot a { color: var(--soft); }
.foot a:hover { color: var(--ink); }

/* ============================================================
   Page head, flash messages
   ============================================================ */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 24px;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.page-sub {
  color: var(--soft);
  font-size: 13.5px;
  margin-top: 4px;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.flashbox { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid;
  display: flex; align-items: center; gap: 10px;
}
.flash-success { background: var(--ok-bg); border-color: #bfe6cd; color: #166534; }
.flash-error   { background: var(--bad-bg); border-color: #f3c6c6; color: #b91c1c; }
.flash-info    { background: var(--info-bg); border-color: #bfdcef; color: #075985; }
[data-theme="dark"] .flash-success { color: #4ade80; border-color: #14532d; }
[data-theme="dark"] .flash-error   { color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .flash-info    { color: #7dd3fc; border-color: #0c4a6e; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.05s;
  font-family: inherit;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.btn-primary:hover { background: var(--brand-dk); color: #fff; }
.btn-soft {
  background: var(--surface);
  color: var(--soft);
  border-color: var(--line);
}
.btn-soft:hover { background: var(--bg-2); color: var(--ink); }
.btn-ghost {
  background: transparent;
  color: var(--soft);
}
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn-danger {
  background: var(--surface);
  color: var(--bad);
  border-color: var(--line);
}
.btn-danger:hover { background: var(--bad-bg); border-color: #f3c6c6; }
.btn-block { width: 100%; padding: 11px; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ============================================================
   Panels / cards
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}
.panel-tight { padding: 16px 18px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}
.panel-head h2 { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
.panel-head h3 { font-size: 14px; font-weight: 600; }
.panel-foot {
  border-top: 1px solid var(--line-2);
  margin: 14px -24px -16px;
  padding: 12px 24px;
  color: var(--muted);
  font-size: 12.5px;
}
.panel + .panel { margin-top: 18px; }

/* ============================================================
   KPI cards (stat cards)
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kpi-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--brand-sf);
  color: var(--brand-dk);
}
.kpi-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.kpi-icon.ok    { background: var(--ok-bg);   color: var(--ok); }
.kpi-icon.warn  { background: var(--warn-bg); color: var(--warn); }
.kpi-icon.bad   { background: var(--bad-bg);  color: var(--bad); }
.kpi-icon.info  { background: var(--info-bg); color: var(--info); }

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.kpi-delta {
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
}
.kpi-delta.down { background: var(--bad-bg); color: var(--bad); }
.kpi-foot {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ============================================================
   Charts
   ============================================================ */
.chart-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
}
@media (max-width: 1000px) { .chart-row { grid-template-columns: 1fr; } }
.chart-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 10px;
}
.chart-title { font-size: 14.5px; font-weight: 700; }
.chart-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.chart-canvas { position: relative; min-height: 240px; }
.chart-canvas canvas { max-width: 100%; }
.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 12.5px;
  color: var(--soft);
  margin-top: 12px;
  flex-wrap: wrap;
}
.legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* ============================================================
   Tables (grid)
   ============================================================ */
.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.grid th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 700;
}
.grid td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13.5px;
  vertical-align: middle;
}
.grid tr:last-child td { border-bottom: none; }
.grid tr:hover td { background: var(--surface-2); }
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.row-actions form { display: inline; }
.row-actions .btn { padding: 6px 12px; font-size: 12px; }
.muted { color: var(--muted); }
.cell-strong { font-weight: 600; color: var(--ink); }

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
  flex-wrap: wrap;
}
.table-search {
  position: relative;
}
.table-search input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 32px;
  font-size: 13px;
  width: 260px;
  color: var(--ink);
  font-family: inherit;
}
.table-search svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--muted);
  stroke: currentColor; fill: none; stroke-width: 1.7;
}

/* Pills / badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.02em;
  background: var(--bg-2);
  color: var(--soft);
  text-transform: uppercase;
}
.pill-ok    { background: var(--ok-bg);   color: var(--ok); }
.pill-warn  { background: var(--warn-bg); color: var(--warn); }
.pill-bad   { background: var(--bad-bg);  color: var(--bad); }
.pill-info  { background: var(--info-bg); color: var(--info); }
.pill-brand { background: var(--brand-sf); color: var(--brand-dk); }
.pill-dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ============================================================
   Forms
   ============================================================ */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ink);
}
.opt {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg-2);
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 5px;
  text-transform: uppercase;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-sf);
  background: var(--surface);
}
.field small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 6px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
#test-result { margin-top: 12px; font-size: 13px; }
.test-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
}
.test-box.good { background: var(--ok-bg);  border-color: #bfe6cd; color: #166534; }
.test-box.bad  { background: var(--bad-bg); border-color: #f3c6c6; color: #b91c1c; }
[data-theme="dark"] .test-box.good { color: #4ade80; border-color: #14532d; }
[data-theme="dark"] .test-box.bad  { color: #fca5a5; border-color: #7f1d1d; }

.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select {
  flex: 1;
  min-width: 200px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--ink);
}

/* ============================================================
   Empty state
   ============================================================ */
.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 60px 30px;
  text-align: center;
}
.empty-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--brand-sf);
  color: var(--brand-dk);
  display: inline-grid; place-items: center;
  margin-bottom: 14px;
}
.empty-icon svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.empty h2 { font-size: 18px; margin-bottom: 6px; }
.empty p { color: var(--soft); margin-bottom: 18px; }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-page {
  min-height: 100vh;
  padding: 30px 20px;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(99, 102, 241, 0.12), transparent),
    radial-gradient(800px 500px at 10% 110%, rgba(139, 92, 246, 0.10), transparent),
    var(--bg);
}
.auth-page .wrap {
  max-width: 100% !important;
  padding: 0 !important;
  min-height: calc(100vh - 60px);
  display: flex !important;
  align-items: center;
  justify-content: center;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 38px 36px 32px;
  width: 100%;
  max-width: 400px;
}
.brand-lg {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.brand-lg .brand-mark { width: 48px; height: 48px; font-size: 16px; }
.brand-lg .brand-name { font-size: 17px; }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; letter-spacing: -0.02em; }
.auth-sub { color: var(--soft); font-size: 13.5px; text-align: center; margin-bottom: 22px; }
.auth-alt { text-align: center; font-size: 13.5px; color: var(--soft); margin-top: 18px; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin: 22px 0 14px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* ============================================================
   API keys page
   ============================================================ */
.keybox {
  border-left: 4px solid var(--ok);
  background: linear-gradient(to right, var(--ok-bg), var(--surface) 50%);
}
[data-theme="dark"] .keybox {
  background: linear-gradient(to right, var(--ok-bg), var(--surface) 60%);
}
.code-line {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #0f172a;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin: 8px 0;
}
.code-line code {
  background: transparent;
  color: #e6e8f0;
  flex: 1;
  word-break: break-all;
  font-size: 12.5px;
}
.code-line .btn-soft {
  background: rgba(255, 255, 255, 0.08);
  color: #e6e8f0;
  border-color: rgba(255, 255, 255, 0.1);
}
.code-line .btn-soft:hover { background: rgba(255, 255, 255, 0.14); }

.guide-steps {
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.guide-steps li { font-size: 13px; color: var(--soft); }

/* ============================================================
   Legal pages
   ============================================================ */
.legal h1 { font-size: 24px; margin-bottom: 14px; letter-spacing: -0.02em; }
.legal h3 { font-size: 15.5px; margin: 22px 0 6px; font-weight: 700; }
.legal p, .legal li { color: var(--soft); font-size: 14px; margin-bottom: 8px; }
.legal ul { padding-left: 22px; }
.legal-note {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--warn-bg);
  border: 1px solid #f0d9a8;
  border-radius: var(--radius-sm);
  color: var(--warn);
  font-size: 13px;
}

/* ============================================================
   Utility
   ============================================================ */
.mt   { margin-top: 14px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.gap  { gap: 10px; }
.row  { display: flex; gap: 10px; align-items: center; }
.right { margin-left: auto; }
.center { text-align: center; }
.hide { display: none; }
.spacer { flex: 1; }
.dim { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ============================================================
   Responsive — collapse sidebar on small screens
   ============================================================ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -100%;
    width: 260px;
    z-index: 50;
    transition: left 0.22s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .menu-toggle { display: grid !important; }
  .content { padding: 22px 18px 50px; }
  .topbar { padding: 0 18px; }
  .search input { width: 180px; }
}
.menu-toggle { display: none; }

/* Scrim when sidebar is open on mobile */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 40;
  display: none;
}
.scrim.show { display: block; }

/* ============================================================
   Profile — SaaS-style hero, tabs, activity feed
   ============================================================ */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
  text-transform: uppercase;
}
.profile-identity { flex: 1; min-width: 0; }
.profile-identity h1 {
  font-size: 22px;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.profile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--soft);
  font-size: 13.5px;
}
.profile-meta .dot { color: var(--muted); }
.profile-actions { flex: 0 0 auto; }

.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--brand-sf);
  color: var(--brand-dk);
}
.role-badge.role-owner    { background: #f3e8ff; color: #6b21a8; }
.role-badge.role-admin    { background: #fef3c7; color: #92400e; }
.role-badge.role-staff    { background: var(--brand-sf); color: var(--brand-dk); }
.role-badge.role-client   { background: #ecfeff; color: #0e7490; }
[data-theme="dark"] .role-badge.role-owner  { background: #2e1065; color: #d8b4fe; }
[data-theme="dark"] .role-badge.role-admin  { background: #3a2810; color: #fbbf24; }
[data-theme="dark"] .role-badge.role-client { background: #082f3a; color: #67e8f9; }

/* Tabs */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 12px 16px;
  font: inherit;
  color: var(--soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  color: var(--brand-dk);
  border-bottom-color: var(--brand);
  font-weight: 600;
}
[data-theme="dark"] .tab.is-active { color: var(--brand-dk); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.panel-sub {
  color: var(--soft);
  font-size: 13px;
  margin-top: 4px;
}
.form-stack { display: flex; flex-direction: column; gap: 16px; }

/* Activity feed */
.activity-feed { list-style: none; padding: 0; margin: 0; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
}
.activity-item:last-child { border-bottom: 0; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 7px;
  flex: 0 0 auto;
}
.activity-body { flex: 1; min-width: 0; }
.activity-action {
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
}
.activity-detail {
  color: var(--soft);
  font-size: 13px;
  margin-top: 2px;
  word-break: break-word;
}
.activity-time {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.empty-state {
  text-align: center;
  padding: 26px 12px;
  color: var(--muted);
  font-size: 13.5px;
}

/* ============================================================
   Error pages — friendly 404/403/500 layout
   ============================================================ */
.error-page {
  max-width: 520px;
  margin: 40px auto;
  padding: 40px 28px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.error-code {
  font-size: 72px;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  line-height: 1;
  margin-bottom: 8px;
}
.error-title {
  font-size: 22px;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.error-message {
  color: var(--soft);
  font-size: 15px;
  margin-bottom: 6px;
}
.error-subtle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}
.error-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}
.error-ref {
  font-size: 12.5px;
  color: var(--muted);
}
.error-ref code {
  font-size: 12px;
}

/* ============================================================
   Responsive polish — mobile (< 600px)
   ============================================================ */
@media (max-width: 700px) {
  .topbar .search { display: none; }
}

@media (max-width: 600px) {
  .content { padding: 18px 14px 40px; }
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-head h1 { font-size: 20px; }
  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .form-actions .btn { width: 100%; justify-content: center; }
  .panel { padding: 16px; }
  .profile-hero {
    flex-direction: column;
    text-align: center;
    padding: 22px 18px;
  }
  .profile-meta { justify-content: center; }
  .profile-actions { width: 100%; }
  .profile-actions .btn { width: 100%; }
  .tab { padding: 10px 12px; font-size: 13.5px; }
  .activity-item { flex-wrap: wrap; }
  .activity-time { width: 100%; padding-left: 20px; }
  .error-page { margin: 20px auto; padding: 28px 18px; }
  .error-code { font-size: 56px; }
  .flash { font-size: 13.5px; padding: 10px 12px; }
}

/* Tables — horizontal scroll on small screens instead of overflowing the page */
@media (max-width: 700px) {
  .table, table.table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}

/* ============================================================
   Sites page — stats grid, site cell, status badges, toolbar
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  font-weight: 600;
}
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.stat-value .stat-of {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}
.stat-card.stat-action { display: flex; flex-direction: column; justify-content: space-between; }
.stat-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-dk);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.search-inline { flex: 1; min-width: 220px; }
.search-inline input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font: inherit;
}
.search-inline input:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-sf);
}

.panel-flush { padding: 0; overflow: hidden; }
.panel-flush > table { margin: 0; }

.sites-table th, .sites-table td { vertical-align: middle; }
.th-right { text-align: right; }

.site-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.site-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex: 0 0 auto;
  text-transform: uppercase;
}
.site-meta { min-width: 0; }
.site-name {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}
.site-url {
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
  display: block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-url:hover { color: var(--brand-dk); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-2);
  color: var(--soft);
  white-space: nowrap;
}
.status-badge .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.status-ok      { background: var(--ok-bg);   color: var(--ok); }
.status-warn    { background: var(--warn-bg); color: var(--warn); }
.status-bad     { background: var(--bad-bg);  color: var(--bad); }
.status-auth    { background: var(--bad-bg);  color: var(--bad); }
.status-testing { background: var(--info-bg); color: var(--info); }
.status-testing .status-dot { animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { display: inline; }

.site-detail-row td { background: var(--bg-2); padding: 14px 18px; }
.site-detail .detail-good {
  color: var(--ok);
  font-size: 13.5px;
}
.site-detail .detail-bad {
  color: var(--bad);
  font-size: 13.5px;
}
.detail-msg {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--soft);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .site-url { max-width: 160px; }
  .row-actions { justify-content: flex-start; }
}

/* ============================================================
   CSS variable aliases — settings page uses these names
   ============================================================ */
:root {
  --border:    var(--line);
  --text:      var(--ink);
  --hover:     var(--bg-2);
  --brand-dim: var(--brand-sf);
  --good:      var(--ok);
  --good-bg:   var(--ok-bg);
}

/* ============================================================
   Search box — hide on very small screens
   ============================================================ */
@media (max-width: 480px) {
  .search { display: none; }
  .topbar { padding: 0 14px; }
  .content { padding: 18px 14px 50px; }
}
