/* Confidere · Admin — light design system control plane */
:root {
  /* Surfaces */
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --raised: #F0F2F5;
  --hairline: #E6E8EC;
  /* Text */
  --ink-strong: #0B0F14;
  --ink: #1C2530;
  --ink-soft: #5A6473;
  --ink-faint: #8A93A0;
  /* Accent + semantic */
  --accent: #16E0C8;
  --accent-pressed: #0FB8A6;
  --accent-ink: #0B0F14;
  --citation: #2F6FD0;
  --success: #1B8A5A;
  --success-soft: #E4F4EC;
  --danger: #B3261E;
  --danger-soft: #F8E7E6;
  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  /* Shadow */
  --shadow-1: 0 1px 2px rgba(11,15,20,.04), 0 1px 3px rgba(11,15,20,.06);
  --shadow-2: 0 4px 12px rgba(11,15,20,.06), 0 2px 6px rgba(11,15,20,.04);
  --shadow-3: 0 18px 48px rgba(11,15,20,.16), 0 6px 16px rgba(11,15,20,.10);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Newsreader", ui-serif, Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--citation); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(22,224,200,.28); }

/* ---------- Brand glyph (matches confidere.app: dark chip + teal arc mark) ---------- */
.glyph {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink-strong);
}
.glyph .mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--ink-strong);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.glyph .mark svg { width: 17px; height: 17px; display: block; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .12s ease, transform .06s ease, box-shadow .12s ease, border-color .12s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-1); }
.btn-primary:hover:not(:disabled) { background: var(--accent-pressed); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--hairline); }
.btn-ghost:hover:not(:disabled) { background: var(--raised); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-success { background: var(--surface); color: var(--success); border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: var(--success-soft); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label {
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  letter-spacing: .01em;
}
.input, .select {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-strong);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent-pressed);
  box-shadow: 0 0 0 3px rgba(22,224,200,.18);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235A6473' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  letter-spacing: .01em;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill-active { color: var(--success); background: var(--success-soft); }
.pill-suspended { color: var(--danger); background: var(--danger-soft); }
.pill-neutral { color: var(--ink-soft); background: var(--raised); }
/* Pilot orgs — mint accent, distinct from status/super pills. */
.pill-pilot { color: var(--accent-ink); background: var(--accent-soft, rgba(22, 224, 200, 0.14)); }

/* Owner billing breakdown (plan → pilot credit → due). */
.bill-box { border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 12px 16px; max-width: 440px; }
.bill-row { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; font-size: 14px; color: var(--ink); }
.bill-row .bl-label { color: var(--ink-soft); }
.bill-row.credit .bl-value { color: var(--success); }
.bill-row.strong { border-top: 1px solid var(--hairline); margin-top: 4px; padding-top: 10px; font-weight: 600; }
.bill-row.strong .bl-label { color: var(--ink-strong); }
.reward-note { margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--accent-soft, rgba(22, 224, 200, 0.10)); border: 1px solid rgba(22, 224, 200, 0.30); font-size: 13px; line-height: 1.5; color: var(--ink); }
.reward-note b { color: var(--accent-ink); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(22,224,200,.08), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 32px;
}
.login-head { text-align: center; margin-bottom: 26px; }
.login-head .glyph { font-size: 19px; justify-content: center; }
.login-head .sub {
  margin-top: 8px; color: var(--ink-soft); font-size: 13px; font-weight: 500;
}
.login-hint {
  margin-top: 18px; text-align: center; color: var(--ink-faint);
  font-size: 11.5px;
}
.login-hint code { font-family: var(--mono); color: var(--ink-soft); }

/* ---------- Top nav / shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 24px;
}
.topbar .glyph { font-size: 16px; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  color: var(--ink-soft); font-weight: 600; font-size: 13.5px;
  padding: 7px 12px; border-radius: var(--r-sm); cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.nav a:hover { background: var(--raised); text-decoration: none; color: var(--ink); }
.nav a.active { color: var(--ink-strong); background: var(--raised); }
.topbar .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 12.5px; }
.who .email { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }

.page { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }

/* ---------- Headings ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1.title { font-family: var(--serif); font-weight: 500; font-size: 30px; line-height: 1.1; color: var(--ink-strong); margin: 0; letter-spacing: -.01em; }
.subtitle { color: var(--ink-soft); font-size: 13.5px; margin-top: 6px; }
h2.section { font-family: var(--serif); font-weight: 500; font-size: 20px; color: var(--ink-strong); margin: 0 0 14px; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.stat {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 20px; box-shadow: var(--shadow-1);
}
.stat .k { font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-family: var(--serif); font-weight: 500; font-size: 40px; line-height: 1; color: var(--ink-strong); margin-top: 10px; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md); box-shadow: var(--shadow-1); overflow: hidden;
}
.panel + .panel { margin-top: 20px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--hairline); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin: 0; }
.panel-body { padding: 6px 0; }
.panel-pad { padding: 20px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 20px; border-bottom: 1px solid var(--hairline);
}
.table td { padding: 13px 20px; border-bottom: 1px solid var(--hairline); color: var(--ink); font-size: 13.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; transition: background .1s ease; }
.table tbody tr.clickable:hover { background: var(--raised); }
.table .num { font-variant-numeric: tabular-nums; color: var(--ink); }
.table .name { font-weight: 600; color: var(--ink-strong); }
.mono { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Lists (workspaces / users) ---------- */
.row-list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--hairline); }
.row-item:last-child { border-bottom: none; }
.row-item .primary { font-weight: 600; color: var(--ink-strong); }
.row-item .meta { color: var(--ink-soft); font-size: 12.5px; }
.row-item .meta .mono { font-size: 12px; }

/* ---------- Detail header ---------- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.detail-head .meta-line { color: var(--ink-soft); font-size: 13px; margin-top: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-head .actions { display: flex; gap: 10px; align-items: center; }
.crumb { color: var(--ink-faint); font-size: 12.5px; font-weight: 600; cursor: pointer; margin-bottom: 8px; display: inline-flex; align-items: center; gap: 5px; }
.crumb:hover { color: var(--ink-soft); }

/* ---------- Invite code reveal ---------- */
.invite-box { background: var(--raised); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 20px; text-align: center; }
.invite-box .code {
  font-family: var(--mono); font-weight: 600; font-size: 30px; letter-spacing: .08em;
  color: var(--ink-strong); user-select: all; word-break: break-all;
}
.invite-box .link { margin-top: 10px; font-family: var(--mono); font-size: 12.5px; color: var(--citation); word-break: break-all; }
.invite-box .actions { margin-top: 16px; display: flex; justify-content: center; gap: 10px; }
.invite-box .helper { margin-top: 14px; color: var(--ink-soft); font-size: 12.5px; }

/* ---------- Modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(11,15,20,.34); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 24px; z-index: 40; }
.modal { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden; }
.modal-head { padding: 22px 24px 4px; }
.modal-head h2 { font-family: var(--serif); font-weight: 500; font-size: 22px; color: var(--ink-strong); margin: 0; }
.modal-head p { color: var(--ink-soft); font-size: 13px; margin: 6px 0 0; }
.modal-body { padding: 18px 24px 4px; }
.modal-foot { padding: 16px 24px 22px; display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- States ---------- */
.note { font-size: 13px; padding: 10px 13px; border-radius: var(--r-sm); margin-bottom: 14px; }
.note-error { color: var(--danger); background: var(--danger-soft); border: 1px solid rgba(179,38,30,.2); }
.note-success { color: var(--success); background: var(--success-soft); border: 1px solid rgba(27,138,90,.2); }
.empty { text-align: center; color: var(--ink-faint); padding: 40px 20px; font-size: 13.5px; }
.empty .big { font-family: var(--serif); font-size: 18px; color: var(--ink-soft); display: block; margin-bottom: 4px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 20px; color: var(--ink-faint); font-size: 13.5px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--hairline); border-top-color: var(--accent-pressed); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.center-state { max-width: 1080px; margin: 0 auto; padding: 80px 24px; text-align: center; color: var(--ink-soft); }
.center-state h1 { font-family: var(--serif); font-weight: 500; color: var(--ink-strong); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink-strong); color: #fff; font-size: 13px; font-weight: 500;
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Misc ---------- */
.divider-label { font-size: 11.5px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; padding: 0 20px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; }
.inline-form .field { flex: 1; margin-bottom: 0; }
.muted { color: var(--ink-faint); }

/* Inline click-through link (owner cell, org link, member rows in meta lines). */
.link-inline { color: var(--citation); cursor: pointer; font-weight: 600; }
.link-inline:hover { text-decoration: underline; }

/* Clickable who-cell (user/team detail member rows). */
.who-cell.clickable { cursor: pointer; border-radius: var(--r-sm); transition: background .1s ease; }
.who-cell.clickable:hover { background: var(--raised); }

/* Danger-zone panel (delete organization). */
.panel-danger { border-color: rgba(179,38,30,.28); }
.panel-danger .panel-head { border-bottom-color: rgba(179,38,30,.18); }
.panel-danger .panel-head h2 { color: var(--danger); }

/* Plan-mix total row on the dashboard. */
.table tr.tier-total td { font-weight: 700; color: var(--ink-strong); border-top: 1px solid var(--hairline); }

/* ---------- Bottom tab bar (mobile-first nav) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: stretch;
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--hairline);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: 54px; padding: 7px 2px 6px; cursor: pointer;
  color: var(--ink-faint); font-size: 10.5px; font-weight: 600;
  letter-spacing: .02em; background: none; border: none;
  transition: color .12s ease;
}
.tabbar .tab svg { width: 22px; height: 22px; }
.tabbar .tab.active { color: var(--accent-pressed); }
.tabbar .tab:hover { color: var(--ink-soft); }
.tabbar .tab.active:hover { color: var(--accent-pressed); }

/* ---------- Search / toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 200px; }
.search input {
  font-family: var(--sans); font-size: 14px; color: var(--ink-strong);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: 11px 13px 11px 38px; width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.search input:focus { outline: none; border-color: var(--accent-pressed); box-shadow: 0 0 0 3px rgba(22,224,200,.18); }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); display: inline-flex; pointer-events: none; }
.count-chip { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }

/* ---------- Segmented control / filter chips ---------- */
.segment { display: inline-flex; background: var(--raised); border: 1px solid var(--hairline); border-radius: 999px; padding: 3px; gap: 2px; }
.segment button {
  border: none; background: none; cursor: pointer; border-radius: 999px;
  padding: 6px 13px; font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft); transition: background .12s ease, color .12s ease; white-space: nowrap;
}
.segment button.on { background: var(--surface); color: var(--ink-strong); box-shadow: var(--shadow-1); }

/* ---------- Role badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 6px; background: var(--raised); color: var(--ink-soft);
}
.badge-owner { background: rgba(22,224,200,.16); color: var(--accent-pressed); }
.badge-admin { background: rgba(47,111,208,.12); color: var(--citation); }
.badge-super { background: var(--ink-strong); color: #fff; }

/* ---------- Member rows w/ inline controls ---------- */
.member-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--hairline); }
.member-row:last-child { border-bottom: none; }
.member-row .who-cell { flex: 1; min-width: 0; }
.member-row .who-cell .primary { font-weight: 600; color: var(--ink-strong); }
.member-row .who-cell .meta { color: var(--ink-soft); font-size: 12px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .ctrl { display: flex; align-items: center; gap: 8px; }
.member-row .select-sm { width: auto; padding: 6px 28px 6px 10px; font-size: 12.5px; background-position: right 9px center; }
.icon-btn {
  border: 1px solid var(--hairline); background: var(--surface); border-radius: var(--r-sm);
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-soft); transition: background .12s, color .12s, border-color .12s; flex-shrink: 0;
}
.icon-btn:hover:not(:disabled) { background: var(--raised); color: var(--ink); }
.icon-btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Inline icon sizing ----------
   The inline SVGs carry a viewBox but no intrinsic width/height, so without an
   explicit size they collapse to 0x0 (empty boxes). Size them by context. The
   more-specific .tabbar rule (22px) still wins for the tab bar. */
.i, .ico { display: inline-flex; align-items: center; justify-content: center; }
.i svg, .ico svg { width: 18px; height: 18px; display: block; }
.icon-btn .i svg { width: 18px; height: 18px; }
.btn svg { width: 16px; height: 16px; }
.search .ico svg { width: 16px; height: 16px; }

/* ---------- Row actions (kebab) ---------- */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Mobile card list (tables collapse) ---------- */
.cardlist { display: none; }
/* Always-visible vertical card stack (used by the Waitlist view on all widths). */
.cardstack { display: flex; flex-direction: column; gap: 12px; }
.card-item {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); padding: 14px 16px; margin-bottom: 12px;
}
.card-item.clickable { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.card-item.clickable:active { transform: translateY(1px); }
.card-item .ci-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-item .ci-title { font-weight: 600; color: var(--ink-strong); font-size: 15px; }
.card-item .ci-sub { color: var(--ink-soft); font-size: 12.5px; margin-top: 2px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; }
.card-item .ci-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; color: var(--ink-soft); font-size: 12px; }
.card-item .ci-meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.card-item .ci-actions { display: flex; gap: 8px; margin-top: 12px; }
.card-item .ci-actions .btn { flex: 1; }
.card-item .ci-note { margin-top: 10px; color: var(--ink-soft); font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; }

/* ---------- Inline help / sublabels in modals ---------- */
.field .hint { font-size: 11px; color: var(--ink-faint); font-weight: 500; }
.check-row { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent-pressed); cursor: pointer; }
.check-row .lbl { font-size: 13.5px; color: var(--ink); }
.check-row .lbl small { display: block; color: var(--ink-faint); font-size: 11.5px; }

/* ---------- KPI row on dashboard (clickable) ---------- */
.stat.linkable { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .06s; }
.stat.linkable:hover { border-color: var(--accent); box-shadow: var(--shadow-2); }
.stat.linkable:active { transform: translateY(1px); }

/* desktop nav lives in topbar; tabbar hidden */
.tabbar { display: none; }
@media (max-width: 760px) { .nav { display: none; } .tabbar { display: flex; } }

@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 16px; }
  .stat .v { font-size: 30px; }
  .topbar-inner { gap: 10px; padding: 0 16px; height: 56px; }
  .who .email { display: none; }
  .page { padding: 22px 16px 92px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn { width: 100%; }
  .detail-head .actions { width: 100%; }
  .detail-head .actions .btn { flex: 1; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .btn { width: 100%; }
  /* collapse tables into cards */
  .table-wrap .table { display: none; }
  .table-wrap .cardlist { display: block; }
  .modal { max-width: 100%; }
  /* touch targets >=44px on phones */
  .icon-btn { width: 44px; height: 44px; }
  .btn-sm { padding: 11px 14px; font-size: 13px; min-height: 44px; }
  .member-row .select-sm { min-height: 44px; padding: 10px 30px 10px 12px; font-size: 13.5px; }
  .member-row { gap: 10px; }
  .member-row .ctrl { gap: 8px; }
  .segment button { padding: 10px 14px; }
  .card-item .ci-actions .btn { min-height: 44px; }
}
@media (min-width: 761px) {
  .cardlist { display: none !important; }
}

/* --- Org-list context menu (right-click / ⋮ kebab) --- */
.ctx-menu {
  position: fixed; z-index: 1200; min-width: 196px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md); box-shadow: var(--shadow-3);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.ctx-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; padding: 9px 10px; border-radius: var(--r-sm);
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
}
.ctx-item:hover:not(:disabled) { background: var(--raised); }
.ctx-item:disabled { color: var(--ink-faint); cursor: default; }
.ctx-item svg { width: 15px; height: 15px; flex: 0 0 auto; }
.ctx-item.ctx-danger { color: var(--danger); }
.ctx-item.ctx-danger:hover:not(:disabled) { background: var(--danger-soft); }
.ctx-divider { height: 1px; background: var(--hairline); margin: 4px 2px; }
.kebab {
  border: 0; background: none; cursor: pointer; width: 30px; height: 30px;
  border-radius: var(--r-sm); font-size: 18px; line-height: 1; color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
}
.kebab:hover { background: var(--raised); color: var(--ink-strong); }
td.row-actions { width: 44px; text-align: right; }
.ci-top-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* --- Topbar: Admin pill + account email link --- */
.pill-super { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.who .email-link { color: var(--ink); text-decoration: none; cursor: pointer; border-bottom: 1px solid transparent; }
.who .email-link:hover { color: var(--accent-pressed); border-bottom-color: var(--accent-pressed); }

/* --- Account page: "this is you" banner --- */
.self-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(22, 224, 200, 0.10); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 10px 14px; margin: 10px 0 6px;
}

/* --- Invoice confirm modal: preview lines --- */
.inv-lines { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 12px; }
.inv-lines .kv { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 14px; }
.inv-lines .kv:last-child { border-top: 1px solid var(--hairline); padding-top: 8px; margin-top: 2px; font-weight: 600; }
.recipient { font-size: 13px; }

/* ── GTM / Sales module ── */
/* Board (pipeline view on the list page) */
.gtm-board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.gtm-col { flex: 1 0 220px; min-width: 220px; background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; padding: 10px; }
.gtm-col-head { display: flex; align-items: center; justify-content: space-between; font-size: 10.5px; letter-spacing: .08em; color: var(--ink-faint); margin: 2px 4px 10px; }
.gtm-col .card-item { margin-bottom: 8px; }

/* Detail page */
.gtm-back {
  background: none; border: none; padding: 0; margin: 0 0 12px; cursor: pointer;
  font-family: var(--sans); font-size: 13px; color: var(--ink-soft); display: block;
}
.gtm-back:hover { color: var(--ink-strong); }
.gtm-head-actions { display: flex; align-items: center; gap: 12px; padding-top: 26px; }
.gtm-grid {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 20px; align-items: start; margin-bottom: 20px;
}
@media (max-width: 900px) { .gtm-grid { grid-template-columns: 1fr; } }
.gtm-col-stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.gtm-col-stack .panel + .panel { margin-top: 0; }

.gtm-form { display: block; }
.gtm-field { margin-bottom: 16px; }
.gtm-field:last-child { margin-bottom: 4px; }
.gtm-label {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint);
  margin-bottom: 7px;
}
.gtm-hint {
  font-family: var(--sans); font-size: 11.5px; font-weight: 400;
  letter-spacing: 0; text-transform: none; color: var(--ink-faint);
}
.gtm-row { display: flex; gap: 8px; align-items: center; }
.gtm-row .input { flex: 1; min-width: 0; }
.gtm-row .btn { flex-shrink: 0; }
.gtm-div { height: 1px; background: var(--hairline); margin: 18px 0; }
.gtm-2col { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 14px; }
.gtm-2col .gtm-field { margin-bottom: 0; }
.gtm-swatch { height: 40px; padding: 4px; cursor: pointer; }
.mono-sm { font-family: var(--mono); font-size: 12.5px; }
.gtm-danger-link { color: var(--danger); }
.gtm-note { margin: 0 0 12px; font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); }
.gtm-ids { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); word-break: break-all; }

/* Vertical pipeline stepper */
.gtm-vsteps { display: flex; flex-direction: column; }
.gtm-vstep { display: flex; align-items: center; gap: 12px; padding: 8px 0; position: relative; }
.gtm-vstep .dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--raised);
  border: 1px solid var(--hairline); flex-shrink: 0; position: relative; z-index: 1;
}
.gtm-vstep.reached .dot { background: var(--accent); border-color: var(--accent); }
.gtm-vstep .lbl { font-size: 13.5px; color: var(--ink-faint); }
.gtm-vstep.reached .lbl { color: var(--ink); }
.gtm-vstep.current .lbl { font-weight: 600; color: var(--ink-strong); }
.gtm-vstep:not(:last-child)::before {
  content: ''; position: absolute; left: 4.5px; top: 26px; height: 16px;
  width: 1px; background: var(--hairline);
}
.gtm-vstep.reached:not(:last-child)::before { background: rgba(15, 184, 166, .4); }

/* Contacts */
.gtm-addrow {
  display: grid; grid-template-columns: 1.1fr 1.5fr 1fr auto; gap: 8px;
  padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--hairline);
}
@media (max-width: 760px) { .gtm-addrow { grid-template-columns: 1fr; } }
.gtm-contacts { display: flex; flex-direction: column; }
.gtm-contact {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px 0; border-bottom: 1px solid var(--hairline);
}
.gtm-contact:last-child { border-bottom: none; padding-bottom: 4px; }
.gtm-contact-id { min-width: 200px; flex: 1; }
.gtm-contact-meta { display: flex; align-items: center; gap: 10px; }
.gtm-contact-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }

/* Events */
.gtm-event {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 2px; border-bottom: 1px solid var(--hairline);
  font-family: var(--mono); font-size: 11.5px; color: var(--ink);
}
.gtm-event:last-child { border-bottom: none; }
.gtm-event-meta { color: var(--ink-faint); white-space: nowrap; }

/* --- Topbar account control (avatar + email → dropdown) --- */
.account { position: relative; }
.account-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 1px solid transparent; border-radius: 999px;
  padding: 4px 10px 4px 4px; cursor: pointer; color: var(--ink-soft);
  transition: background .12s ease;
}
.account-trigger:hover, .account.open .account-trigger { background: var(--raised); }
.account-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  background: var(--accent-pressed); color: #fff;
  font-family: var(--serif); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.account-email { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.account-caret { font-size: 10px; color: var(--ink-faint); }
.account-menu {
  position: absolute; right: 0; top: 100%; margin-top: 8px; min-width: 236px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md); box-shadow: var(--shadow-3);
  padding: 6px; display: none; z-index: 1200;
}
/* transparent bridge so hover survives the gap between trigger and menu */
.account-menu::before { content: ''; position: absolute; top: -8px; left: 0; right: 0; height: 8px; }
.account:hover .account-menu, .account.open .account-menu { display: block; }
.account-id { padding: 10px 10px 12px; }
.account-name { font-weight: 600; color: var(--ink-strong); font-size: 14px; }
.account-mail { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); margin: 2px 0 8px; }
.account-id .pill-super { font-size: 11px; }
.account-sep { height: 1px; background: var(--hairline); margin: 2px 2px 4px; }
.account-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; padding: 9px 10px; border-radius: var(--r-sm);
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
}
.account-item:hover { background: var(--raised); }
.account-item svg { width: 16px; height: 16px; flex: 0 0 auto; opacity: .75; }
.account-danger { color: var(--danger); }
.account-danger:hover { background: var(--danger-soft); }
/* On mobile the topbar is tight — show just the avatar (still opens the menu). */
@media (max-width: 760px) {
  .account-email, .account-caret { display: none; }
  .account-trigger { padding: 3px; }
}

/* ---------- App shell: persistent left sidebar (desktop) + bottom tabbar (mobile) ---------- */
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; align-items: start; }
.mobile-topbar { display: none; }
.main { min-width: 0; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 12px 14px;
  border-right: 1px solid var(--hairline); background: var(--surface);
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 12px; }
.sidebar-brand .wordmark { font-weight: 600; font-size: 15.5px; letter-spacing: -0.3px; color: var(--ink-strong); }
.sidebar-org { font-size: 12px; color: var(--ink-soft); font-family: var(--mono); padding: 0 8px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-search {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: var(--bg); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  padding: 8px 10px; margin-bottom: 8px; cursor: pointer;
  color: var(--ink-faint); font: inherit; font-size: 13px; text-align: left;
}
.sidebar-search:hover { border-color: var(--ink-faint); }
.sidebar-search svg { width: 15px; height: 15px; opacity: .7; flex: 0 0 auto; }
.sidebar-search span { flex: 1; }
.sidebar-search .kbd { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); border: 1px solid var(--hairline); border-radius: 5px; padding: 1px 5px; background: var(--surface); }
.sidebar .nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar .nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px;
  border-radius: var(--r-sm); color: var(--ink-soft); font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: background .12s ease, color .12s ease;
}
.sidebar .nav a svg { width: 17px; height: 17px; opacity: .8; flex: 0 0 auto; }
.sidebar .nav a:hover { background: var(--raised); color: var(--ink-strong); }
.sidebar .nav a.active { background: var(--accent-soft, rgba(22, 224, 200, 0.12)); color: var(--accent-ink); }
.sidebar .nav a.active svg { opacity: 1; }
.sidebar-spacer { flex: 1; }
.sidebar-foot { border-top: 1px solid var(--hairline); padding-top: 10px; }
.sidebar-foot .account { width: 100%; }
.sidebar-foot .account-trigger { width: 100%; justify-content: flex-start; border-radius: var(--r-sm); }
.sidebar-foot .account-email { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* In the footer the menu opens UPWARD, anchored left. */
.sidebar-foot .account-menu { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; margin: 0; }
.sidebar-foot .account-menu::before { top: auto; bottom: -8px; }

@media (max-width: 760px) {
  #app { display: block; }
  .sidebar { display: none; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 20; height: 54px; padding: 10px 16px;
    background: var(--surface); border-bottom: 1px solid var(--hairline);
  }
  .mobile-topbar .brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .mobile-topbar .wordmark { font-weight: 600; font-size: 15px; letter-spacing: -0.3px; color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-topbar .spacer { flex: 1; }
}

/* ---------- ⌘K command palette ---------- */
.palette-scrim { align-items: start; z-index: 45; }
.palette { width: 100%; max-width: 560px; margin-top: 12vh; display: flex; flex-direction: column; max-height: 66vh; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden; }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--hairline); }
.palette-search svg { width: 18px; height: 18px; color: var(--ink-faint); flex: 0 0 auto; }
.palette-input { flex: 1; border: 0; outline: 0; background: none; font: inherit; font-size: 16px; color: var(--ink-strong); }
.palette-input::placeholder { color: var(--ink-faint); }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-row { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-sm); cursor: pointer; }
.palette-row.sel { background: var(--raised); }
.pr-kind { width: 24px; height: 24px; border-radius: 6px; background: var(--bg); border: 1px solid var(--hairline); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--ink-soft); font-family: var(--mono); font-size: 12px; }
.pr-kind svg { width: 14px; height: 14px; }
.pr-label { font-size: 14px; color: var(--ink-strong); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-sub { font-size: 12px; color: var(--ink-faint); font-family: var(--mono); margin-left: auto; flex: 0 0 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42%; }
.palette-empty { padding: 22px; text-align: center; color: var(--ink-faint); font-size: 14px; }
.palette-foot { padding: 8px 14px; border-top: 1px solid var(--hairline); font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }

/* ---------- Quick invite (#/invite) — one-thumb mobile flow ---------- */
.page-narrow { max-width: 620px; }
.invite-card { padding: 22px; }
/* 16px font on the inputs so iOS Safari doesn't zoom-jump when they get focus. */
.input-lg { font-size: 16px; padding: 13px 14px; }
.btn-block { width: 100%; min-height: 50px; font-size: 15.5px; margin-top: 6px; }
.invite-helper { margin-top: 14px; color: var(--ink-soft); font-size: 12.5px; line-height: 1.55; }
.invite-done-check {
  width: 52px; height: 52px; margin: 6px auto 14px; border-radius: 50%;
  background: var(--success-soft); color: var(--success);
  display: flex; align-items: center; justify-content: center;
}
.invite-done-check svg { width: 26px; height: 26px; }
.invite-done-title { text-align: center; font-size: 20px; margin: 0 0 6px; color: var(--ink-strong); }
.invite-done-sub { text-align: center; color: var(--ink-soft); font-size: 14px; line-height: 1.55; margin: 0 auto 18px; max-width: 420px; }
.invite-done-actions { display: flex; gap: 10px; margin-top: 18px; }
.invite-done-actions .btn { flex: 1; min-height: 46px; }

/* Floating invite action — thumb-reach on phones; desktop has the sidebar button. */
.fab { display: none; }
@media (max-width: 760px) {
  .fab {
    position: fixed; right: 16px; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 29;
    width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--accent); color: var(--accent-ink);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(11,15,20,.24);
  }
  .fab svg { width: 24px; height: 24px; }
  .fab:active { transform: scale(.95); }
}

/* Sidebar promoted action (desktop twin of the FAB) */
.sidebar-invite {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: var(--accent-soft, rgba(22, 224, 200, 0.12)); color: var(--accent-pressed);
  border: 0; border-radius: var(--r-sm); padding: 9px 10px; margin-bottom: 10px;
  cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 600; text-align: left;
}
.sidebar-invite:hover { background: rgba(22, 224, 200, 0.22); }
.sidebar-invite svg { width: 16px; height: 16px; flex: 0 0 auto; }
