/* Real Estate CRM — one stylesheet, no framework, no build step.
   Layout is desktop-first with the sales-critical screens working at 375px (§71). */

/* Any class rule that sets `display` beats the UA [hidden] rule, which left the
   quick-action drawer stuck open on every page. Every JS `el.hidden = true`
   routes through here. */
[hidden] { display: none !important; }

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --brand: #1d4ed8;
  --brand-dark: #1e40af;
  --brand-soft: #eff6ff;

  --success: #047857;
  --success-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --info-soft: #f1f5f9;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .16);
  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  padding: 18px 18px 14px;
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  letter-spacing: -.01em;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .brand small { display: block; font-weight: 400; color: #94a3b8; font-size: 11px; margin-top: 2px; }
.sidebar nav { padding: 10px 10px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #cbd5e1; font-size: 13.5px;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; font-weight: 500; }
.sidebar nav a .ico { width: 16px; text-align: center; opacity: .9; }
.sidebar .side-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; }
.sidebar .side-foot a { color: #94a3b8; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .search { flex: 1; max-width: 420px; position: relative; }
.topbar .search input { width: 100%; }
.topbar .spacer { flex: 1; }

.content { padding: 20px; flex: 1; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head .sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-head .grow { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }

/* ---------- Work tiles (§8) ---------- */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: block;
  color: inherit;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--border-strong);
}
.tile:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.tile.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.tile .num { font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.tile .lbl { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.tile.t-new { border-left-color: var(--brand); }
.tile.t-due { border-left-color: var(--success); }
.tile.t-visit { border-left-color: #7c3aed; }
.tile.t-missed { border-left-color: var(--danger); }
.tile.t-reinq { border-left-color: var(--warn); }

/* ---------- Tables & work rows ---------- */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 600;
  padding: 9px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.t-name { font-weight: 600; }
.t-sub { color: var(--text-muted); font-size: 12.5px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.6;
  background: var(--info-soft); color: var(--text-muted);
  white-space: nowrap;
}
.badge.b-blue { background: var(--brand-soft); color: var(--brand-dark); }
.badge.b-green { background: var(--success-soft); color: var(--success); }
.badge.b-amber { background: var(--warn-soft); color: var(--warn); }
.badge.b-red { background: var(--danger-soft); color: var(--danger); }
.badge.b-violet { background: #f5f3ff; color: #6d28d9; }
.badge.b-slate { background: #f1f5f9; color: #475569; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: currentColor; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: #334155; }
label .opt { font-weight: 400; color: var(--text-faint); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=time], input[type=url], input[type=search], select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--danger); }
textarea { min-height: 76px; resize: vertical; }
.field { margin-bottom: 13px; }
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.field .err { font-size: 12px; color: var(--danger); margin-top: 3px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
fieldset legend { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; padding: 0 0 8px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 13.5px; margin-bottom: 6px; }
.check input { width: auto; margin: 0; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 150px; }

/* ---------- Flash & alerts ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.flash-error { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.flash-success { background: var(--success-soft); border-color: #a7f3d0; color: var(--success); }
.flash-info { background: var(--brand-soft); border-color: #bfdbfe; color: var(--brand-dark); }
.flash-warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }

/* ---------- Empty states (§69) ---------- */
.empty { padding: 44px 20px; text-align: center; color: var(--text-muted); }
.empty h3 { color: var(--text); margin-bottom: 5px; }
.empty p { max-width: 380px; margin: 0 auto 14px; font-size: 13.5px; }

/* ---------- Timeline (§21) ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 16px 4px; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.tl-item.kind-alert::before { border-color: var(--danger); }
.tl-item.kind-win::before { border-color: var(--success); }
.tl-item.kind-action::before { border-color: var(--brand); }
.tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-title { font-weight: 600; font-size: 13.5px; }
.tl-meta { color: var(--text-faint); font-size: 12px; }
.tl-body { color: var(--text-muted); font-size: 13px; margin-top: 2px; white-space: pre-wrap; }

/* ---------- Drawer (§103.1) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; justify-content: flex-end; z-index: 50;
}
.drawer {
  width: 460px; max-width: 100%; background: var(--surface);
  height: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer-head .grow { flex: 1; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }
.drawer .read-only-summary {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 16px; font-size: 13px;
}

/* ---------- Detail lists ---------- */
.dl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 6px 12px; font-size: 13px; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 12px 14px; font-size: 13px; }
.pagination a, .pagination span {
  padding: 4px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  color: var(--text-muted); background: var(--surface);
}
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #334155 100%); }
.auth-card { width: 100%; max-width: 392px; background: var(--surface); border-radius: 14px; padding: 28px; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 19px; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 20px; }
.auth-foot { margin-top: 16px; font-size: 13px; display: flex; justify-content: space-between; }

/* ---------- Public pages (mini site / QR) ---------- */
.public-wrap { max-width: 960px; margin: 0 auto; padding: 24px 18px 60px; }
.public-hero { background: var(--surface); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); margin-bottom: 20px; }

/* ---------- Mobile (§71) ---------- */
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar .side-foot { display: none; }
  .content { padding: 14px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .field-row, .field-row.three { grid-template-columns: minmax(0, 1fr); }
  .drawer { width: 100%; }
  .hide-sm { display: none !important; }
  table.responsive thead { display: none; }
  table.responsive tbody tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  table.responsive tbody td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 3px 0; }
  table.responsive tbody td::before { content: attr(data-label); color: var(--text-muted); font-size: 12px; }
  .row-actions { justify-content: flex-start; padding-top: 6px; }
}

/* ======================================================================
   V1.1 — connected flow
   ====================================================================== */

/* ---------- NEW pulse (§6) ---------- */
.pulse-new { position: relative; }
.pulse-new .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; margin-right: 4px; vertical-align: middle;
  animation: pulse-dot 1.6s ease-in-out infinite;
}
.pulse-new::after {
  content: ''; position: absolute; inset: -2px; border-radius: 999px;
  border: 1px solid currentColor; opacity: 0;
  animation: pulse-ring 1.6s ease-out infinite; pointer-events: none;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes pulse-ring { 0% { opacity: .5; transform: scale(.96); } 70%, 100% { opacity: 0; transform: scale(1.12); } }
/* §6.4: motion is decoration. Emphasis must survive without it. */
@media (prefers-reduced-motion: reduce) {
  .pulse-new .dot, .pulse-new::after { animation: none; }
  .pulse-new::after { opacity: .55; }
}
.badge-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* ---------- Stage funnel (§17) ---------- */
.funnel-card { margin-bottom: 14px; }
.funnel { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 0; list-style: none; margin: 0; padding: 0; }
.fn-step {
  display: flex; align-items: baseline; gap: 6px; padding: 4px 14px 4px 10px;
  font-size: 13px; position: relative; color: var(--text-faint);
}
.fn-step + .fn-step::before {
  content: ''; position: absolute; left: -2px; top: 13px; width: 8px;
  border-top: 1px solid var(--border-strong);
}
.fn-mark { font-size: 12px; line-height: 1; }
.fn-name { white-space: nowrap; }
.fn-completed { color: var(--success); }
.fn-current { color: var(--brand); font-weight: 600; }
.fn-current .fn-name { position: relative; }
.fn-skipped { color: var(--text-faint); }
.fn-skipped .fn-name { text-decoration: line-through; text-decoration-color: var(--border-strong); }
.fn-future { color: var(--text-faint); }
.fn-sub { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.fn-when { color: var(--text-faint); font-size: 11.5px; font-weight: 400; }
.fn-hint {
  font-size: 11px; color: var(--brand); background: none; border: 0; padding: 0 0 0 2px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.funnel-branch { margin-top: 8px; font-size: 12.5px; color: var(--text-faint); }
.funnel-branch.is-lost { color: var(--danger); font-weight: 600; }

/* ---------- Deal card (§25) ---------- */
.deal-strip {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.deal-strip .lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.deal-strip .val { display: block; font-size: 13.5px; font-weight: 600; margin-top: 2px; }
.hint-inline { font-size: 12px; color: var(--text-muted); align-self: center; }
.card-alert { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn-soft); }
.card-alert .card-head h2 { color: var(--warn); }

/* ---------- Quick date presets (§21.4) ---------- */
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.chip {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-muted); cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

/* ---------- Dashboard search (§5) ---------- */
.dash-search { position: relative; display: flex; gap: 8px; margin-bottom: 14px; }
.dash-search input[type=search] {
  flex: 1; padding: 11px 14px; font-size: 14.5px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.dash-search input[type=search]:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.qs-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 400px; overflow-y: auto;
}
.qs-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); color: inherit; text-decoration: none;
}
.qs-row:last-child { border-bottom: 0; }
.qs-row:hover { background: var(--surface-2); }
.qs-main { flex: 1; min-width: 0; }
.qs-row.is-locked { background: var(--info-soft); cursor: default; }
.qs-row.is-locked .t-sub:last-child { color: var(--warn); }
.qs-empty { padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text-muted); font-size: 13.5px; }

@media (max-width: 720px) {
  .deal-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel { flex-direction: column; }
  .fn-step + .fn-step::before { display: none; }
  .dash-search { flex-direction: column; }
}

/* ---------- Capture form (§7–§13) ---------- */
.card.section > summary { cursor: pointer; list-style: none; }
.card.section > summary::-webkit-details-marker { display: none; }
.card.section > summary::before { content: '▸'; color: var(--text-faint); margin-right: 6px; }
.card.section[open] > summary::before { content: '▾'; }
.dup-notice {
  margin-top: 8px; padding: 9px 11px; font-size: 13px; line-height: 1.5;
  background: var(--warn-soft); border: 1px solid #fcd34d; border-radius: var(--radius-sm); color: #78350f;
}
.dup-notice a { color: var(--brand-dark); font-weight: 600; }
.decision-card { border-color: var(--warn); }
.decision-card .card-head h2 { color: var(--warn); }

/* ---------- Lead allocation (§66–§76) ---------- */
.alloc-model { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-muted); }
.alloc-model .arrow { color: var(--text-faint); }
.member-list, .upcoming { list-style: none; margin: 0; padding: 0; }
.member {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; margin-bottom: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13.5px;
}
.member.is-inactive { opacity: .7; border-style: dashed; }
.member .grip { color: var(--text-faint); cursor: grab; }
.upcoming li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13.5px; }
.upcoming .pos {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 700;
}

/* ---------- Stage tree (§19) ---------- */
.stage-node { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface); }
.stage-node > summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; cursor: pointer; list-style: none;
}
.stage-node > summary::-webkit-details-marker { display: none; }
.stage-node > summary::before { content: '▸'; color: var(--text-faint); }
.stage-node[open] > summary::before { content: '▾'; }
.stage-body { padding: 0 12px 12px 30px; border-top: 1px solid var(--border); padding-top: 10px; }
.substage-tree { list-style: none; margin: 0; padding: 0; }
.substage-tree li {
  display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px;
  border-bottom: 1px dashed var(--border);
}
.substage-tree li:last-child { border-bottom: 0; }
.substage-tree .branch { color: var(--text-faint); font-family: ui-monospace, monospace; }

/* ---------- Project stepper (§26–§37) ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.steps .step {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-muted); text-decoration: none;
}
.steps .step:hover { border-color: var(--brand); color: var(--brand); }
.steps .step.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.steps .step .n {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-muted); font-size: 11px; font-weight: 700;
}
.steps .step.on .n { background: rgba(255,255,255,.25); color: #fff; }

.unit-preview { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; }
.pv-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 3px 0; }
.pv-floor { width: 74px; flex: none; font-size: 12px; color: var(--text-muted); }
.pv-unit {
  font-family: ui-monospace, monospace; font-size: 12px; padding: 2px 7px;
  border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand-dark);
}
.pv-unit.is-skipped { background: var(--surface-2); color: var(--text-faint); text-decoration: line-through; }

.plan-block { padding: 10px 0; border-bottom: 1px solid var(--border); }
.plan-block:last-child { border-bottom: 0; }
.plan-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.plan-row input[name=msPercentage] { width: 74px; flex: none; }
.plan-row input[name=msLabel] { flex: 1; min-width: 0; }
table.mini td { padding: 3px 8px; font-size: 13px; border: 0; }

.readiness { list-style: none; margin: 0; padding: 0; }
.readiness li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; }
.readiness .mark { width: 16px; text-align: center; font-weight: 700; }
.readiness .ok, .readiness li.ok { color: var(--success); }
.readiness li.blocking { color: var(--danger); }
.readiness li.warn { color: var(--warn); }

/* ---------- Unit pickers (§40, §46, §51) ---------- */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.unit-card {
  display: flex; flex-direction: column; gap: 3px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); text-decoration: none; color: inherit;
}
.unit-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.unit-card.on { border-color: var(--brand); background: var(--brand-soft); }
.unit-card .u-num { font-weight: 700; font-size: 14.5px; }
.unit-card .u-meta { font-size: 11.5px; color: var(--text-muted); }
.unit-card .u-price { font-size: 13px; font-weight: 600; color: var(--brand-dark); }
.unit-card .badge { align-self: flex-start; }

.plan-pick {
  display: block; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); text-decoration: none; color: inherit;
}
.plan-pick:hover { border-color: var(--brand); }
.plan-pick.on { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- Booking success (§54) ---------- */
.booking-done {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 20px 22px; margin-bottom: 16px;
  background: var(--success-soft); border: 1px solid #6ee7b7; border-radius: var(--radius);
}
.booking-done .bd-mark {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 50%; background: var(--success); color: #fff; font-size: 20px; font-weight: 700;
}
.booking-done h1 { font-size: 19px; color: #065f46; margin: 0; }
.booking-done .bd-lines { font-size: 14px; color: #065f46; margin-top: 2px; }
.booking-done .btn-group { margin-left: auto; }

/* ---------- API console (§58–§65) ---------- */
.drawer-wide { width: min(760px, 100%); }
.code {
  position: relative; margin: 0 0 12px; padding: 10px 12px; overflow-x: auto;
  background: #0f172a; color: #e2e8f0; border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.code[data-copy] { cursor: copy; }
.code[data-copy]:hover::after {
  content: 'click to copy'; position: absolute; top: 6px; right: 8px;
  font-size: 10px; color: #94a3b8; letter-spacing: .03em;
}
.code.copied::after { content: 'copied ✓' !important; color: #6ee7b7 !important; }
.drawer-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 16px 0 6px; }
.drawer-body h3:first-child { margin-top: 0; }
