/* RootUIP — Dashboard shell
   Layered on top of /legal/legal.css (which provides the base palette tokens:
   --bg, --bg-2, --bg-3, --ink, --ink-dim, --line, --trust, --success, etc.).
   Used by every page under /dashboard/* — gives them a single product surface
   with persistent sidebar nav, top bar, panels, skeletons, and empty states. */

/* ── Brand token override: teal → indigo (dashboard surfaces only) ──────────
   legal.css defines --trust as #38b2ac (teal). dashboard.css loads after it
   so this :root block wins the cascade for every page that loads dashboard.css.
   legal.css and marketing.css pages are unaffected — they never load this file.
   ──────────────────────────────────────────────────────────────────────────── */
:root {
  --trust:       #6366f1;
  --trust-bright:#818cf8;
  --trust-soft:  rgba(99, 102, 241, 0.12);
  --trust-line:  rgba(99, 102, 241, 0.28);
  --accent:      #6366f1;
}

/* ---------- Layout shell ---------- */
.dash-app {
  --sidebar-w: 232px;
  --topbar-h: 56px;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  background: var(--bg);
}

.dash-sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  align-self: stretch;
  height: 100vh;
  background: #0a0d12;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
}

.dash-topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  background: rgba(14, 17, 22, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  z-index: 15;
}

.dash-main {
  grid-area: main;
  padding: 28px 32px 60px;
  min-width: 0;          /* allow overflow control */
  overflow-x: clip;
}

@media (max-width: 900px) {
  .dash-app {
    --sidebar-w: 0px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .dash-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 100;
  }
  .dash-app.is-nav-open .dash-sidebar { transform: translateX(0); }
  .dash-app.is-nav-open::before {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }
  .dash-main { padding: 20px 16px 40px; }
  .dash-topbar { padding: 0 12px; }
}

/* ---------- Sidebar ---------- */
.dash-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}
.dash-brand-mark {
  width: 26px; height: 26px;
  display: grid; place-items: center;
}
.dash-brand-name {
  font-family: var(--font-display, 'Fraunces', Georgia, serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.dash-brand-name em {
  font-style: italic;
  color: var(--trust);
}

.dash-nav {
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  flex: 1 1 auto;
}
.dash-nav-section {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 16px 12px 6px;
}
.dash-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.dash-nav-link:hover {
  background: rgba(56, 178, 172, 0.07);
  color: var(--ink);
}
.dash-nav-link.is-active {
  background: var(--trust-soft);
  color: var(--trust-bright);
}
.dash-nav-link.is-active::before {
  content: '';
  position: absolute;
  left: -10px; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--trust);
  border-radius: 0 3px 3px 0;
}
.dash-nav-link svg {
  width: 16px; height: 16px;
  flex: 0 0 16px;
  color: currentColor;
  opacity: 0.85;
}
.dash-nav-link .badge {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(192, 22, 22, 0.18);
  color: #f0b8b8;
  border: 1px solid rgba(192, 22, 22, 0.35);
}
.dash-nav-link .badge.ok {
  background: rgba(95, 212, 126, 0.12);
  color: #a9e2b3;
  border-color: rgba(95, 212, 126, 0.32);
}

.dash-sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-dim);
}
.dash-sidebar-footer a { color: var(--trust); text-decoration: none; }
.dash-sidebar-footer a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.dash-burger {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 8px;
  color: var(--ink-2);
  cursor: pointer;
  align-items: center; justify-content: center;
}
.dash-burger:hover { background: var(--bg-2); }
@media (max-width: 900px) { .dash-burger { display: inline-flex; } }

.dash-crumbs {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.dash-crumbs strong { color: var(--ink); font-weight: 500; }

.dash-topbar-spacer { flex: 1; }

.dash-status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.dash-status-pill .pip {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-muted);
}
.dash-status-pill.is-ready { color: #a9e2dc; border-color: var(--trust-line); background: var(--trust-soft); }
.dash-status-pill.is-ready .pip { background: var(--trust); }
.dash-status-pill.is-blocked { color: #f0b8b8; border-color: rgba(192,22,22,0.35); background: rgba(192,22,22,0.10); }
.dash-status-pill.is-blocked .pip { background: #c01616; }
.dash-status-pill.is-warn { color: #f0d49a; border-color: rgba(240,176,72,0.35); background: rgba(240,176,72,0.10); }
.dash-status-pill.is-warn .pip { background: var(--warning); }

.dash-account {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
}
.dash-account:hover { border-color: var(--line-2); }
.dash-account .avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--trust);
  color: #07120f;
  font-size: 11px;
  font-weight: 700;
  display: grid; place-items: center;
  text-transform: uppercase;
}
.dash-account select {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink);
  font: inherit;
  padding-right: 4px;
  cursor: pointer;
}

.dash-action {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--trust);
  color: #07120f;
  font-weight: 600;
  font-size: 13px;
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.dash-action:hover { background: var(--trust-bright); }
.dash-action.ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.dash-action.ghost:hover { background: var(--bg-2); color: var(--ink); }
.dash-action.danger {
  background: rgba(192,22,22,0.18);
  color: #f0b8b8;
  border: 1px solid rgba(192,22,22,0.35);
}
.dash-action.danger:hover { background: rgba(192,22,22,0.28); }
.dash-action svg { width: 14px; height: 14px; }

/* ---------- Page header ---------- */
.dash-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.dash-page-head .titles { min-width: 0; }
.dash-page-head h1 {
  font-family: var(--font-display, 'Fraunces', Georgia, serif);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 400;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
}
.dash-page-head h1 em { font-style: italic; color: var(--trust); }
.dash-page-head .lede {
  font-size: 14px;
  color: var(--ink-dim);
  margin: 0;
  max-width: 720px;
}
.dash-page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Panels ---------- */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
}
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.panel h2 {
  font-family: var(--font-display, 'Fraunces', Georgia, serif);
  font-size: 19px;
  font-weight: 500;
  margin: 4px 0 0;
  letter-spacing: -0.005em;
}
.panel h2 em { font-style: italic; color: var(--trust); }
.panel .panel-foot {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

/* Grid for KPI strip / readiness slots */
.dash-grid {
  display: grid;
  gap: 16px;
}
.dash-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.dash-grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.dash-grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ---------- KPI cards (no nesting; flat tiles inside the panel) ---------- */
.kpi {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.kpi .label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.kpi .value {
  font-family: var(--font-display, 'Fraunces', Georgia, serif);
  font-size: 28px;
  font-weight: 400;
  margin: 4px 0 2px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.kpi .delta {
  font-size: 12px;
  color: var(--ink-dim);
}
.kpi .delta.up { color: var(--success); }
.kpi .delta.down { color: #f0a0a0; }

/* ---------- Status pills (used inline in lists) ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  background: rgba(255,255,255,0.02);
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-muted); }
.status.connected { color: #a9e2dc; border-color: var(--trust-line); background: var(--trust-soft); }
.status.connected .dot { background: var(--trust); }
.status.error { color: #f0b8b8; border-color: rgba(192,22,22,0.35); background: rgba(192,22,22,0.10); }
.status.error .dot { background: #c01616; }
.status.needs_test, .status.needs_config, .status.warn {
  color: #f0d49a; border-color: rgba(240,176,72,0.35); background: rgba(240,176,72,0.10);
}
.status.needs_test .dot, .status.needs_config .dot, .status.warn .dot { background: var(--warning); }
.status.not_connected, .status.idle { color: var(--ink-dim); }

/* ---------- Readiness slot row ---------- */
.slot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 18px;
  padding: 14px 16px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  align-items: center;
}
.slot + .slot { margin-top: 10px; }
.slot .slot-label {
  display: flex; align-items: center; gap: 10px;
  font-weight: 500;
}
.slot .slot-label svg { width: 16px; height: 16px; color: var(--trust); flex: 0 0 16px; }
.slot .slot-meta {
  font-size: 12px;
  color: var(--ink-dim);
  margin-top: 4px;
}
.slot .slot-action a, .slot .slot-action button {
  white-space: nowrap;
}

/* ---------- Connector card ---------- */
.conn-card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0;
}
.conn-card .head {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
}
.conn-card .name { font-weight: 600; font-size: 14px; color: var(--ink); }
.conn-card .desc { font-size: 12px; color: var(--ink-dim); margin: 0; }
.conn-card .meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.conn-card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Activity timeline ---------- */
.activity {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 0;
}
.activity li {
  position: relative;
  padding: 12px 14px 12px 30px;
  border-bottom: 1px solid var(--line);
}
.activity li:last-child { border-bottom: none; }
.activity li::before {
  content: '';
  position: absolute;
  left: 12px; top: 18px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--trust);
  box-shadow: 0 0 0 3px rgba(56,178,172,0.18);
}
.activity li.is-error::before { background: #c01616; box-shadow: 0 0 0 3px rgba(192,22,22,0.22); }
.activity li.is-warn::before  { background: var(--warning); box-shadow: 0 0 0 3px rgba(240,176,72,0.22); }
.activity .a-title { font-size: 13px; color: var(--ink); }
.activity .a-meta { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.14em; color: var(--ink-muted); margin-top: 2px; text-transform: uppercase; }

/* ---------- Empty states ---------- */
.empty {
  text-align: center;
  padding: 36px 20px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  color: var(--ink-dim);
}
.empty .empty-icon {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  background: var(--trust-soft);
  color: var(--trust);
  border-radius: 50%;
  margin-bottom: 12px;
}
.empty h3 {
  font-family: var(--font-display, 'Fraunces', Georgia, serif);
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--ink);
}
.empty p {
  font-size: 13px;
  max-width: 480px;
  margin: 0 auto 16px;
  line-height: 1.55;
}

/* ---------- Skeleton loaders ---------- */
.skel {
  display: inline-block;
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 6px;
  height: 14px;
  width: 100%;
}
@keyframes skel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel.h-large { height: 28px; }
.skel.h-small { height: 10px; }
.skel.w-half { width: 50%; }
.skel.w-third { width: 33%; }

/* ---------- Stepper (used in blog creator) ---------- */
.stepper {
  display: flex; flex-wrap: wrap;
  gap: 0;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-3);
  padding: 4px;
}
.stepper .step {
  flex: 1 1 0;
  min-width: 110px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--ink-dim);
  position: relative;
  cursor: default;
}
.stepper .step .num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  flex: 0 0 22px;
}
.stepper .step.is-done    { color: var(--ink-2); }
.stepper .step.is-done    .num { background: var(--trust-soft); border-color: var(--trust-line); color: var(--trust-bright); }
.stepper .step.is-active  { color: var(--ink); background: var(--trust-soft); }
.stepper .step.is-active  .num { background: var(--trust); border-color: var(--trust); color: #07120f; }
.stepper .step.is-blocked .num { background: rgba(192,22,22,0.18); border-color: rgba(192,22,22,0.45); color: #f0b8b8; }

/* ---------- Forms ---------- */
.field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--trust);
  box-shadow: 0 0 0 3px var(--trust-soft);
}
.field textarea { min-height: 88px; resize: vertical; }
.field .help { font-size: 12px; color: var(--ink-muted); }

/* ---------- Util ---------- */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row .grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-dim); }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* Disclosure / accordion (used to hide manual fallback under OAuth) */
details.fallback {
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  background: rgba(255,255,255,0.015);
}
details.fallback > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-dim);
  list-style: none;
}
details.fallback > summary::-webkit-details-marker { display: none; }
details.fallback > summary::before {
  content: '▸ ';
  color: var(--trust);
}
details.fallback[open] > summary::before { content: '▾ '; }
