/* Spaceshift dashboard - base: tokens, dark/light theme, and primitives
   every page uses (top bar, page shell, buttons, tables, badges, switch,
   small screens, theme toggle, status dots). Split from dashboard.css. */

/* Spaceshift dashboard
   ---------------------------------------------------------------------
   Everything below is built from the tokens in :root. If you want to
   change how the dashboard looks, change a token - not a component.
   Dark-first slate theme by default; a light palette is offered back to
   anyone whose OS/browser prefers it. */

:root {
  color-scheme: dark light;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  /* Type scale: five sizes is enough for a data tool. */
  --text-xs: 0.6875rem;   /* 11px - table headers, keys */
  --text-sm: 0.8125rem;   /* 13px - table body, controls, notes */
  --text-md: 0.875rem;    /* 14px - body copy, labels */
  --text-lg: 1rem;        /* 16px - section headings */
  --text-xl: 1.375rem;    /* 22px - page heading */
  --text-stat: 1.875rem;  /* 30px - KPI numbers */

  /* Spacing on a 4px grid. */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  --radius-sm: 4px; --radius: 8px; --radius-lg: 12px; --radius-xl: 16px;
  --page-max: 1440px;
  --ease: 140ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Dark palette (default) - slate, Datadog/Vercel/Linear-adjacent. */
  --bg: #0a0e14;
  --surface: #10151d;
  --surface-2: #161c26;
  --surface-raised: #1a212c;
  --border: #232b38;
  --border-strong: #333e4f;
  --text: #eef1f6;
  --text-2: #9aa6b8;
  --text-3: #667186;
  --accent: #6c8dff;
  --accent-hover: #86a2ff;
  --accent-soft: color-mix(in srgb, #6c8dff 16%, transparent);
  --on-accent: #06101f;
  --green: #35d399;
  --red: #ff6b6b;
  --amber: #f0b93a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.22);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --glow-accent: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e14;
  --surface: #10151d;
  --surface-2: #161c26;
  --surface-raised: #1a212c;
  --border: #232b38;
  --border-strong: #333e4f;
  --text: #eef1f6;
  --text-2: #9aa6b8;
  --text-3: #667186;
  --accent: #6c8dff;
  --accent-hover: #86a2ff;
  --accent-soft: color-mix(in srgb, #6c8dff 16%, transparent);
  --on-accent: #06101f;
  --green: #35d399;
  --red: #ff6b6b;
  --amber: #f0b93a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.22);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --glow-accent: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-raised: #ffffff;
  --border: #e3e6eb;
  --border-strong: #cdd2da;
  --text: #1a1d23;
  --text-2: #5b6370;
  --text-3: #8a919d;
  --accent: #2f5fd6;
  --accent-hover: #2551bb;
  --accent-soft: color-mix(in srgb, #2f5fd6 10%, transparent);
  --on-accent: #ffffff;
  --green: #1d7f4c;
  --red: #c2362f;
  --amber: #9a6700;
  --shadow: 0 1px 2px rgba(20, 24, 32, 0.05), 0 8px 24px rgba(20, 24, 32, 0.04);
  --shadow-sm: 0 1px 2px rgba(20, 24, 32, 0.05);
  --glow-accent: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-raised: #ffffff;
    --border: #e3e6eb;
    --border-strong: #cdd2da;
    --text: #1a1d23;
    --text-2: #5b6370;
    --text-3: #8a919d;
    --accent: #2f5fd6;
    --accent-hover: #2551bb;
    --accent-soft: color-mix(in srgb, #2f5fd6 10%, transparent);
    --on-accent: #ffffff;
    --green: #1d7f4c;
    --red: #c2362f;
    --amber: #9a6700;
    --shadow: 0 1px 2px rgba(20, 24, 32, 0.05), 0 8px 24px rgba(20, 24, 32, 0.04);
    --shadow-sm: 0 1px 2px rgba(20, 24, 32, 0.05);
    --glow-accent: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
  }
}

/* ---- Base ------------------------------------------------------------- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 480px at 12% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
p { margin: 0; }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

svg.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- Top bar ---------------------------------------------------------- */

.topbar {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--sp-6);
  height: 56px;
  display: flex;
  align-items: stretch;
  gap: var(--sp-4);
}

.brand {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.03em;
  color: var(--text);
  transition: opacity var(--ease);
}
.brand:hover { text-decoration: none; opacity: 0.9; color: var(--text); }

.brand-mark {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
  flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; display: block; }

.scope-badge {
  align-self: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-3);
  padding: 2px var(--sp-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  flex-shrink: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--ease), border-color var(--ease);
}
.nav-link svg { opacity: 0.85; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.is-active { color: var(--text); border-bottom-color: var(--accent); }

.live {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--text-3);
  white-space: nowrap;
  cursor: default;
  padding: 3px var(--sp-2);
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.live-label { font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent);
  transition: background var(--ease);
}
.live[data-state="refreshing"] .live-dot { animation: live-pulse 900ms ease-in-out infinite; }
.live[data-state="error"] .live-dot { background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 20%, transparent); }
.live[data-state="error"] .live-label { color: var(--red); }

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.user-menu {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  margin-left: var(--sp-2);
  padding-left: var(--sp-4);
  border-left: 1px solid var(--border);
  font-size: var(--text-sm);
}
.user-chip { display: inline-flex; align-items: center; gap: var(--sp-2); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  text-transform: uppercase;
  flex: none;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { color: var(--text); max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.role-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); padding: 4px 8px; }
.btn-quiet:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }

/* ---- Page ------------------------------------------------------------- */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-8) var(--sp-10);
}

.page-header { margin-bottom: var(--sp-6); }
.page-narrow { max-width: 440px; padding: var(--sp-6) var(--sp-4) var(--sp-10); margin: 0 auto; }

.flashes { margin-bottom: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.flash {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--text-sm);
}
.flash-error { border-left-color: var(--red); }
.flash-success { border-left-color: var(--green); }
.flash-warning { border-left-color: var(--amber); }
.lede {
  margin-top: var(--sp-1);
  color: var(--text-2);
  max-width: 72ch;
}

.section { margin-top: var(--sp-8); }
.section-header { margin-bottom: var(--sp-3); }
.section-note { color: var(--text-2); font-size: var(--text-sm); margin-top: 2px; }

/* ---- Buttons ---------------------------------------------------------- */

.btn {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-raised); border-color: var(--border-strong); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  font-size: var(--text-sm);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* ---- Tables ----------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  white-space: nowrap;
}

th, td {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.is-hidden { display: none; }
tbody tr.is-clickable, tbody tr.audit-row { cursor: pointer; }

td.mono { font-size: 12.5px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.ts { color: var(--text-2); font-variant-numeric: tabular-nums; }

tr.empty-row:hover td { background: transparent; }
td.empty {
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  white-space: normal;
}
.empty-title { display: block; color: var(--text-2); font-size: var(--text-md); }
.empty-hint { display: block; margin-top: var(--sp-1); color: var(--text-3); font-size: var(--text-sm); }

.eligibility-note, .muted-note { color: var(--text-3); font-size: var(--text-xs); }

/* ---- Badges ------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 2px var(--sp-2);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-green { color: var(--green); background: color-mix(in srgb, var(--green) 16%, transparent); }
.badge-red { color: var(--red); background: color-mix(in srgb, var(--red) 16%, transparent); }
.badge-blue { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.badge-amber { color: var(--amber); background: color-mix(in srgb, var(--amber) 18%, transparent); }
.badge-muted { color: var(--text-2); background: color-mix(in srgb, var(--text-3) 16%, transparent); }

/* ---- Switch ------------------------------------------------------------- */

.switch { position: relative; display: inline-block; width: 32px; height: 18px; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--ease);
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 14px; height: 14px; left: 2px; top: 2px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: transform var(--ease);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(14px); }
.switch input:disabled + .slider { opacity: 0.5; cursor: default; }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Small screens ------------------------------------------------------- */

@media (max-width: 720px) {
  .topbar-inner { padding: 0 var(--sp-4); gap: var(--sp-4); }
  .nav { overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-link { padding: 0 var(--sp-2); }
  .nav-link span.nav-text { display: none; }
  .live-label { display: none; }
  .user-meta { display: none; }
  .scope-badge { display: none; }
  .page { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
  .setting { grid-template-columns: 1fr; gap: var(--sp-3); }
  .setting-control { align-items: flex-start; }
  .config-value-input { text-align: left; }
  .drawer { width: 100vw; }
}

/* ---- Theme Toggle -------------------------------------------------------- */

.theme-toggle {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-raised);
}
:root[data-theme="dark"] .theme-icon-light { display: block; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }
:root[data-theme="light"] .theme-icon-light { display: none; }
:root[data-theme="light"] .theme-icon-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-light { display: block; }
  :root:not([data-theme="light"]) .theme-icon-dark { display: none; }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-icon-light { display: none; }
  :root:not([data-theme="dark"]) .theme-icon-dark { display: block; }
}

/* ---- Status Dots --------------------------------------------------------- */

.dot-green, .dot-gray, .dot-red, .dot-amber, .dot-blue {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: 1px;
}
.dot-green { background: var(--green); }
.dot-gray { background: var(--text-3); }
.dot-red { background: var(--red); }
.dot-amber { background: var(--amber); }
.dot-blue { background: var(--accent); }

