/* Mandate dashboard — Stripe-inspired design system (vanilla, no build) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:#635BFF; --brand-dark:#5147E8; --brand-soft:#EFEDFF;
  --ink:#1A1F36; --text:#414552; --muted:#687385; --faint:#8792A2;
  --border:#E3E8EE; --border-soft:#EBEEF1; --bg:#F6F8FA; --surface:#FFF;
  --green-bg:#D7F7C2; --green-tx:#05690D;
  --red-bg:#FFE0E0;   --red-tx:#B3261E;
  --amber-bg:#FCEDB9; --amber-tx:#6E5800;
  --blue-bg:#D9E8FF;  --blue-tx:#0055BC;
  --gray-bg:#ECEEF1;  --gray-tx:#545A69;
  --shadow-lg:0 8px 28px rgba(26,31,54,.16); --radius:8px;
}

body { font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  font-size:14px; color:var(--text); background:var(--surface); -webkit-font-smoothing:antialiased; }
a { color:var(--brand); text-decoration:none; }

.shell { display:flex; min-height:100vh; }

/* sidebar */
.sidebar { width:225px; flex-shrink:0; border-right:1px solid var(--border-soft);
  padding:14px 12px; position:sticky; top:0; height:100vh; display:flex; flex-direction:column; gap:2px; }
.workspace { display:flex; align-items:center; gap:9px; padding:7px 8px 13px; }
.workspace-logo { width:26px; height:26px; border-radius:6px; background:var(--brand); color:#fff;
  font-weight:700; font-size:13px; display:flex; align-items:center; justify-content:center; }
.workspace-name { font-weight:600; font-size:14px; color:var(--ink); }
.nav-item { display:flex; align-items:center; gap:9px; padding:6px 8px; border-radius:6px;
  color:var(--text); font-size:13.5px; cursor:pointer; }
.nav-item:hover { background:var(--bg); color:var(--ink); }
.nav-item.active { color:var(--brand); font-weight:600; }
.nav-badge { margin-left:auto; background:var(--brand); color:#fff; font-size:11px; font-weight:600;
  border-radius:999px; padding:0 6px; line-height:16px; }
.nav-group-label { font-size:12px; color:var(--muted); padding:14px 8px 5px; }
.sidebar-foot { margin-top:auto; padding:12px 8px 0; font-size:11px; color:var(--faint); line-height:1.5; }

/* main */
.main { flex:1; min-width:0; }
.topbar { display:flex; align-items:center; gap:14px; padding:12px 32px; position:sticky; top:0;
  z-index:30; background:var(--surface); }
.testmode-pill { background:#FFD23B; color:#5F4A0D; font-size:12px; font-weight:600;
  border-radius:999px; padding:3px 10px; }
.topbar .spacer { flex:1; }
.content { padding:8px 32px 64px; max-width:1120px; }
.page-head { display:flex; align-items:center; gap:12px; margin:18px 0 6px; }
.page-head h1 { font-size:26px; font-weight:700; color:var(--ink); letter-spacing:-.3px; }
.page-head .spacer { flex:1; }
.page-sub { color:var(--muted); font-size:13.5px; margin-bottom:12px; }

.btn { display:inline-flex; align-items:center; gap:6px; border-radius:7px; font-size:13.5px;
  font-weight:600; padding:7px 13px; cursor:pointer; border:1px solid var(--border);
  background:var(--surface); color:var(--ink); }
.btn:hover { background:var(--bg); }
.btn-primary { background:var(--brand); border-color:var(--brand); color:#fff; }
.btn-primary:hover { background:var(--brand-dark); }
.btn-danger-soft { color:var(--red-tx); }
.btn-danger-soft:hover { background:#FFF5F5; border-color:#F4C7C4; }
.btn-sm { font-size:12.5px; padding:4px 10px; border-radius:6px; }
.btn:disabled { opacity:.5; cursor:default; }

/* tiles / cards */
.tiles { display:flex; gap:10px; margin:16px 0 4px; flex-wrap:wrap; }
.tile { flex:1; min-width:140px; border:1px solid var(--border); border-radius:var(--radius); padding:12px 14px; }
.tile .t-label { font-size:13px; font-weight:500; }
.tile .t-num { font-size:18px; font-weight:700; color:var(--ink); margin-top:4px; }
.tile.hl { border-color:var(--brand); box-shadow:inset 0 0 0 1px var(--brand); }
.tile.hl .t-label { color:var(--brand); }
.card { border:1px solid var(--border); border-radius:var(--radius); padding:16px 18px; background:var(--surface); }
.card h3 { font-size:13.5px; font-weight:600; }
.grid { display:grid; gap:14px; }
.grid-3 { grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); }
.section-title { font-size:16px; font-weight:700; color:var(--ink); margin:28px 0 8px; }

/* tables */
table { width:100%; border-collapse:collapse; margin-top:10px; }
th { text-align:left; font-size:12px; font-weight:600; color:var(--muted); padding:9px 12px;
  border-bottom:1px solid var(--border); white-space:nowrap; }
td { font-size:13.5px; padding:11px 12px; border-bottom:1px solid var(--border-soft);
  vertical-align:middle; white-space:nowrap; }
tr:hover td { background:#F9FAFB; }
.amt { font-weight:600; color:var(--ink); }
.cur { color:var(--muted); font-size:12px; margin-left:3px; }
.mono { font-family:ui-monospace,Menlo,monospace; font-size:12.5px; }
.dim { color:var(--muted); }
.cell-sub { font-size:12px; color:var(--faint); margin-top:1px; }
.row-count { font-size:13px; color:var(--muted); padding:12px 2px; }

.badge { display:inline-flex; align-items:center; gap:4px; font-size:12px; font-weight:500;
  border-radius:5px; padding:1.5px 7px; white-space:nowrap; }
.badge-green{background:var(--green-bg);color:var(--green-tx);}
.badge-red{background:var(--red-bg);color:var(--red-tx);}
.badge-amber{background:var(--amber-bg);color:var(--amber-tx);}
.badge-blue{background:var(--blue-bg);color:var(--blue-tx);}
.badge-gray{background:var(--gray-bg);color:var(--gray-tx);}
.badge-brand{background:var(--brand-soft);color:var(--brand-dark);}

.util-bar { height:6px; border-radius:999px; background:var(--gray-bg); overflow:hidden; margin-top:5px; min-width:140px; }
.util-fill { height:100%; border-radius:999px; background:var(--brand); }
.util-fill.hot { background:#DF1B41; }
.util-label { font-size:12px; color:var(--muted); }

/* forms & dialogs */
dialog { border:none; border-radius:14px; padding:0; width:min(620px,94vw);
  box-shadow:0 24px 60px rgba(26,31,54,.28); color:var(--text); }
dialog::backdrop { background:rgba(26,31,54,.45); }
.dlg-head { padding:20px 24px 0; }
.dlg-head h2 { font-size:18px; font-weight:700; color:var(--ink); }
.dlg-head p { font-size:13px; color:var(--muted); margin-top:4px; }
.dlg-body { padding:16px 24px; max-height:64vh; overflow-y:auto; }
.dlg-foot { padding:14px 24px 20px; display:flex; justify-content:flex-end; gap:10px;
  border-top:1px solid var(--border-soft); }
.field { margin-bottom:12px; }
.field label { display:block; font-size:12.5px; font-weight:600; color:var(--text); margin-bottom:5px; }
.field input, .field select, .field textarea { width:100%; padding:8px 11px; border:1px solid var(--border);
  border-radius:8px; font:inherit; font-size:13.5px; color:var(--ink); background:#fff; }
.field input:focus, .field select:focus, .field textarea:focus { outline:none; border-color:var(--brand); }
.field .hint { font-size:11.5px; color:var(--faint); margin-top:4px; }
.field-row { display:flex; gap:10px; }
.field-row .field { flex:1; }

.codeblock { background:#0E1726; color:#E6EDF7; border-radius:10px; padding:13px 15px;
  font-family:ui-monospace,Menlo,monospace; font-size:12px; line-height:1.6; overflow-x:auto;
  white-space:pre; margin-top:8px; }
.code-label { font-size:12px; font-weight:700; color:var(--muted); margin:16px 0 0;
  text-transform:uppercase; letter-spacing:.06em; }
.keybox { background:var(--brand-soft); border:1px solid #C9C4FF; border-radius:10px;
  padding:13px 15px; font-family:ui-monospace,Menlo,monospace; font-size:13px; color:var(--ink);
  word-break:break-all; margin:10px 0; }

/* evidence chain */
.chain { position:relative; margin:18px 0 6px; padding-left:26px; }
.chain::before { content:""; position:absolute; left:8px; top:14px; bottom:26px; width:2px;
  background:linear-gradient(var(--brand) 0%, #C9C4FF 100%); }
.chain-block { position:relative; margin-bottom:14px; }
.chain-block::before { content:""; position:absolute; left:-24px; top:14px; width:12px; height:12px;
  border-radius:50%; background:var(--surface); border:3px solid var(--brand); }
.chain-card { border:1px solid var(--border); border-radius:10px; padding:13px 16px; }
.ch-head { display:flex; align-items:center; gap:8px; }
.ch-step { font-size:11px; font-weight:700; color:var(--brand); letter-spacing:.08em; text-transform:uppercase; }
.ch-title { font-size:14px; font-weight:700; color:var(--ink); }
.ch-body { font-size:13px; margin-top:6px; line-height:1.55; }
.ch-hash { margin-top:8px; font-family:ui-monospace,Menlo,monospace; font-size:11.5px; color:var(--muted);
  display:flex; gap:14px; flex-wrap:wrap; }
.ch-hash b { color:var(--brand-dark); font-weight:600; }

/* approvals */
.approve-card { border:1px solid var(--border); border-left:3px solid #ED6804; border-radius:10px;
  padding:16px 18px; display:flex; gap:18px; align-items:center; flex-wrap:wrap; margin-bottom:10px; }
.approve-amt { font-size:22px; font-weight:800; color:var(--ink); }
.approve-meta { font-size:13px; color:var(--muted); line-height:1.6; flex:1; min-width:240px; }
.approve-actions { display:flex; gap:8px; }

/* misc */
.empty { text-align:center; color:var(--muted); padding:46px 20px; font-size:13.5px; }
.empty .big { font-size:34px; margin-bottom:10px; }
#toast { position:fixed; left:50%; bottom:26px; transform:translateX(-50%) translateY(8px);
  background:var(--ink); color:#fff; font-size:13px; font-weight:500; border-radius:8px;
  padding:10px 16px; box-shadow:var(--shadow-lg); opacity:0; pointer-events:none;
  transition:opacity .18s, transform .18s; z-index:100; max-width:90vw; text-align:center; }
#toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
.rule-results { font-family:ui-monospace,Menlo,monospace; font-size:11.5px; line-height:1.7; color:var(--muted); }
.rule-results .ok::before { content:"✓ "; color:var(--green-tx); }
.rule-results .fail::before { content:"✗ "; color:var(--red-tx); }
@media (max-width:860px){ .sidebar{display:none;} .content{padding:8px 16px 64px;} }

/* ── Auth & onboarding ───────────────────────────────────────── */
body.unauthed .sidebar, body.unauthed .authed-only { display: none; }
body.unauthed .main { width: 100%; }
.user-chip { font-size: 13px; color: var(--muted); }
.user-chip b { color: var(--ink); font-weight: 600; }

.auth-wrap { min-height: 78vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: min(400px, 94vw); border: 1px solid var(--border); border-radius: 14px;
  padding: 30px 30px 26px; box-shadow: 0 8px 30px rgba(26,31,54,.08); }
.auth-card h1 { font-size: 22px; font-weight: 800; color: var(--ink); letter-spacing: -.3px; }
.auth-card .sub { font-size: 13px; color: var(--muted); margin: 6px 0 18px; line-height: 1.5; }
.auth-card .switch { font-size: 13px; color: var(--muted); margin-top: 16px; text-align: center; }
.form-error { color: var(--red-tx); font-size: 12.5px; min-height: 16px; margin-top: 6px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 11.5px;
  margin: 16px 0; text-transform: uppercase; letter-spacing: .08em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
#google-btn { display: flex; justify-content: center; min-height: 40px; }

.stepper { display: flex; gap: 0; margin: 22px 0 26px; }
.step { flex: 1; text-align: center; position: relative; font-size: 12.5px; color: var(--faint); }
.step::before { content: ""; display: block; width: 26px; height: 26px; border-radius: 50%;
  margin: 0 auto 6px; background: var(--gray-bg); border: 2px solid var(--border);
  line-height: 22px; }
.step.done::before { background: var(--green-bg); border-color: var(--green-tx); }
.step.now { color: var(--brand); font-weight: 600; }
.step.now::before { background: var(--brand-soft); border-color: var(--brand); }
.step::after { content: ""; position: absolute; top: 13px; left: calc(50% + 16px);
  right: calc(-50% + 16px); height: 2px; background: var(--border); }
.step:last-child::after { display: none; }
.step .n { position: absolute; top: 4px; left: 0; right: 0; font-size: 12px; font-weight: 700; }
.step.done .n { color: var(--green-tx); }
.step.now .n { color: var(--brand); }

.stripe-element { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; }
.stripe-element.StripeElement--focus { border-color: var(--brand); }
