* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  position: sticky; top: 0; z-index: 100;
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--text); font-weight: 700; text-decoration: none; font-size: 1.1rem;
  letter-spacing: -0.3px;
}
.brand img { height: 30px; width: auto; border-radius: 7px; }
.brand .accent {
  background: var(--gradient-accent);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
main { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 1.5rem 1.25rem; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.5rem; max-width: 420px; margin: 3rem auto;
}

/* ---- drag-and-drop upload dropzone ---- */
.upload-dropzone {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.75rem 1.5rem; border-radius: 14px;
  border: 2px dashed var(--border);
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent-border); background: var(--accent-dim);
}
.upload-icon {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.upload-icon svg { width: 22px; height: 22px; }
.upload-text { font-weight: 700; color: var(--text); }
.upload-browse { display: inline; color: var(--accent); text-decoration: underline; cursor: pointer; }
.upload-subtext { color: var(--muted); font-size: 1rem; line-height: 1.55; margin-top: 2px; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0.25rem; }
input {
  width: 100%; padding: 0.6rem 0.75rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
button {
  margin-top: 1rem; width: 100%; padding: 0.65rem; border: 0; border-radius: 8px;
  background: var(--accent); color: #14100a; font-weight: 700; cursor: pointer;
}
button:hover { background: var(--accent-light); }
input[type="checkbox"] { width: auto; padding: 0; margin: 0; flex-shrink: 0; }
/* Selects had no styling at all until now, so every one in the app rendered as
   a native control against the dark card — including the share-role dropdown,
   which has looked that way since sharing shipped. Matched to the input rule
   above rather than invented, so the two read as one control family.
   font-family/font-size are explicit because a native select inherits neither. */
select {
  width: 100%; padding: 0.6rem 0.75rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 1rem; line-height: 1.4;
  cursor: pointer;
}
select:hover { border-color: var(--accent-border); }
/* The app had exactly one focus-visible rule before this. A keyboard user
   tabbing through a form had no visible position at all, which is a floor,
   not a preference — so it covers the whole control family, not just select. */
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent-light); outline-offset: 2px;
}
/* The share row is a flex line, so its select must not claim the full width
   and squash the email field next to it. */
.share-add-row select { width: auto; }
.field-hint { display: block; color: var(--muted); font-size: 1rem; line-height: 1.5; margin-top: 0.35rem; }
.checkbox-row {
  display: flex; align-items: flex-start; gap: 0.6rem;
  margin-top: 1rem; cursor: pointer; font-size: 1rem; line-height: 1.5; color: var(--text);
}
.checkbox-row input { margin-top: 0.2rem; }
.checkbox-row small { display: block; color: var(--muted); margin-top: 0.2rem; font-weight: 400; }
.ai-badge {
  display: inline-block; padding: 0.1rem 0.45rem; border-radius: 999px;
  background: rgba(245, 166, 35, 0.15); color: var(--accent); font-size: 0.65rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; vertical-align: middle;
}
.divider {
  display: flex; align-items: center; gap: 0.75rem;
  margin: 1rem 0; color: var(--muted); font-size: 0.75rem; text-transform: uppercase;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.btn-google {
  margin-top: 0; width: 100%; padding: 0.65rem; border-radius: 8px;
  background: #fff; color: #14100a; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  text-decoration: none; font-size: 0.95rem;
}
.btn-google:hover { background: #f3f3f3; }
.error { color: var(--danger); font-size: 1rem; line-height: 1.5; min-height: 1.2em; margin-top: 0.5rem; }
.credit {
  text-align: center; padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom));
  font-size: 0.875rem; opacity: 0.55;
}
.credit a { color: var(--muted); text-decoration: none; }
.project-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.25rem; margin-bottom: 0.75rem;
}
.btn-danger {
  margin-top: 0; width: auto; padding: 0.4rem 0.9rem; font-size: 0.8rem;
  background: transparent; border: 1px solid #f56565; color: #f56565;
}
.btn-danger:hover { background: rgba(245, 101, 101, 0.1); }
.legal {
  max-width: 680px; margin: 2rem auto; padding: 0 1.25rem 3rem;
  line-height: 1.6;
}
.legal h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.legal .updated { color: var(--muted); font-size: 0.875rem; margin-bottom: 1.5rem; }
.legal h2 { font-size: 1.15rem; margin-top: 2rem; color: var(--accent-light); }
.legal p, .legal li { color: var(--text); }
.legal ul { padding-left: 1.25rem; }
.legal a { color: var(--accent); }

/* ── Desktop account nav ─────────────────────────────────────── */
.account-nav {
  display: flex; align-items: center; gap: 0.9rem; font-size: 0.85rem; color: var(--muted);
}
.account-nav button {
  margin-top: 0; width: auto; padding: 0.4rem 0.9rem; font-size: 0.8rem;
  background: transparent; border: 1px solid var(--border); color: var(--text);
}
.account-nav button:hover { background: var(--panel-hover); }

/* ── Token balance badge ─────────────────────────────────────── */
.tok-badge {
  position: fixed; top: 4.2rem; right: 1rem; z-index: 150;
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.85rem; border-radius: 999px;
  font-size: 0.85rem; font-weight: 700; white-space: nowrap;
  text-decoration: none; cursor: pointer; transition: transform .15s ease;
  background: var(--accent-dim); border: 1px solid var(--accent-border); color: var(--accent);
}
.tok-badge .tok-badge-icon { font-size: 0.95rem; }
.tok-badge[data-state="low"] {
  background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.4); color: #fbbf24;
}
.tok-badge[data-state="zero"] {
  background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.4); color: #f87171;
}
.tok-badge.tok-badge-pulse { transform: scale(1.06); }

/* ── Subscription status badge ───────────────────────────────── */
.sub-badge {
  position: fixed; top: 7.4rem; right: 1rem; z-index: 150;
  display: inline-flex; align-items: center;
  padding: 0.4rem 0.85rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700; white-space: nowrap;
  text-decoration: none; cursor: pointer;
  background: rgba(245, 158, 11, 0.14); border: 1px solid rgba(245, 158, 11, 0.4); color: #fbbf24;
}
.sub-badge[data-state="past_due"] {
  background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.4); color: #f87171;
}

/* ── Mobile bottom nav ───────────────────────────────────────── */
#sa-mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 1060; height: 60px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #0a0c14; border-top: 1px solid #1e2535;
  align-items: stretch;
}
@media (max-width: 1024px) {
  #sa-mobile-nav { display: flex; }
  #topnav { display: none; }
  body.sa-authed { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  #sa-more-drawer, #sa-more-overlay { display: block; }
}
@media (min-width: 1025px) {
  #sa-more-drawer, #sa-more-overlay { display: none !important; }
}
.sa-mobile-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: #718096; text-decoration: none;
  font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  transition: color 0.15s; padding: 6px 2px; border: none; background: none; cursor: pointer;
}
.sa-mobile-tab i { font-size: 1.15rem; line-height: 1; font-style: normal; }
.sa-mobile-tab:hover { color: var(--accent-light); }
.sa-mobile-tab.active { color: var(--accent); }

#sa-more-overlay {
  position: fixed; inset: 0; z-index: 1070;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
#sa-more-overlay.active { opacity: 1; pointer-events: auto; }

#sa-more-drawer {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 1080;
  background: #0d0f18; border: 1px solid #1e2535; border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 8px 14px 14px;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 72vh; overflow-y: auto;
  pointer-events: none;
}
#sa-more-drawer.open {
  transform: translateY(calc(-60px - env(safe-area-inset-bottom, 0px)));
  pointer-events: auto;
}
.sa-more-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: #2d3748; margin: 4px auto 12px;
}
.sa-more-account {
  font-size: 0.8rem; color: var(--muted); text-align: center; padding: 0 0 12px;
  border-bottom: 1px solid #1e2535; margin-bottom: 12px;
}
.sa-more-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 18px 8px;
  background: #141720; border: 1px solid #1e2535; border-radius: 12px;
  color: #a0aec0; text-decoration: none;
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  text-align: center; width: 100%;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  cursor: pointer;
}
.sa-more-tile i { font-size: 1.4rem; color: var(--accent-light); line-height: 1; font-style: normal; }
.sa-more-tile:hover { background: #1a1e2e; color: #e2e8f0; border-color: #3a4060; }
.sa-more-tile-danger {
  flex-direction: row; gap: 10px; padding: 14px 20px; justify-content: center;
  background: rgba(252, 129, 129, 0.06); border-color: rgba(252, 129, 129, 0.2);
  color: #fc8181; text-transform: none; font-size: 0.88rem; letter-spacing: 0;
  width: 100%; margin-top: 8px; display: flex;
}
.sa-more-tile-danger i { font-size: 1rem; color: #fc8181; font-style: normal; }
.sa-more-tile-danger:hover { background: rgba(252, 129, 129, 0.12); border-color: rgba(252, 129, 129, 0.35); }

/* ── Admin console ───────────────────────────────────────────── */
.admin-nav-link { color: var(--text); text-decoration: none; font-weight: 600; }
.admin-nav-link:hover { color: var(--accent-light); }

.admin-tabs {
  display: flex; gap: 0.75rem; border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem; overflow-x: auto;
}
.admin-tab {
  background: transparent; border: 0; border-bottom: 3px solid transparent;
  color: var(--muted); font-weight: 700; font-size: 1.05rem; padding: 0.85rem 1.3rem; margin: 0;
  width: auto; cursor: pointer; white-space: nowrap; border-radius: 0;
}
.admin-tab:hover { background: transparent; color: var(--text); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }

.admin-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.85rem 1.1rem; margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.admin-row .admin-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.admin-row .admin-actions button {
  margin-top: 0; width: auto; padding: 0.4rem 0.8rem; font-size: 0.8rem;
  background: transparent; border: 1px solid var(--border); color: var(--text);
}
.admin-row .admin-actions button:hover { background: var(--panel-hover); }

.admin-row-clickable { cursor: pointer; }
.admin-detail { display: none; margin: -0.4rem 0 0.6rem; padding: 0 1.1rem; }
.admin-detail.open {
  display: block; background: var(--panel); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 12px 12px; padding: 0.85rem 1.1rem;
}
.admin-detail-inner strong {
  display: block; font-size: 0.7rem; text-transform: uppercase; color: var(--muted);
  margin: 0.6rem 0 0.2rem;
}
.admin-detail-inner strong:first-child { margin-top: 0; }

.badge {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  background: rgba(148, 163, 184, 0.15); color: var(--muted); margin-left: 0.4rem;
}
.badge-danger { background: rgba(245, 101, 101, 0.15); color: #f56565; }
.badge-accent { background: rgba(245, 166, 35, 0.15); color: var(--accent-light); }

.admin-filters { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.admin-filters input, .admin-filters select { width: auto; margin: 0; }

.admin-stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.admin-stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.9rem 1.25rem; min-width: 140px;
}
.admin-stat .value { font-size: 1.4rem; font-weight: 800; color: var(--accent-light); }
.admin-stat .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }

.ws-takeoff-filters {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.ws-takeoff-filters .chip-group { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.ws-takeoff-filters .chip {
  /* The global `button { width: 100% }` otherwise stretches each chip across
     the panel and stacks them one per line. */
  width: auto;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.ws-takeoff-filters .chip-active {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-dim);
}
.ws-takeoff-filters input[type="text"],
.ws-takeoff-filters input[type="number"],
.ws-takeoff-filters select { width: auto; margin: 0; }
.tk-group-header td {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding-top: 0.6rem;
}
.tk-row { cursor: pointer; }
.tk-row:hover { background: var(--panel-hover); }

/* ---- chat panel ---- */
.chat-tabs { display: flex; gap: 4px; }
.chat-tab {
  background: none; border: none; cursor: pointer; padding: 4px 10px;
  font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); opacity: 0.7; border-bottom: 2px solid transparent;
}
.chat-tab:hover { color: var(--accent); opacity: 1; }
.chat-tab.active { color: var(--accent); opacity: 1; border-bottom-color: var(--accent); }
.chat-body { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 90%; padding: 9px 12px; border-radius: 12px; font-size: 1rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chat-msg-user { align-self: flex-end; background: var(--accent); color: #14100a; border-bottom-right-radius: 4px; }
.chat-msg-ai { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-msg-sender { display: block; font-size: 0.875rem; font-weight: 700; opacity: 0.65; margin-bottom: 2px; }
.chat-msg-error { align-self: center; font-size: 0.875rem; color: #f56565; padding: 4px 10px; }
.chat-chip { align-self: flex-start; font-size: 0.72rem; color: var(--muted); padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; }
.chat-chip-err { color: #f56565; }

.chat-file-card { align-self: flex-start; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); font-size: 1rem; line-height: 1.55; }
.chat-file-card-type { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 4px; background: var(--accent); color: #14100a; }
.chat-file-card-title { font-weight: 600; }
.chat-file-card a { color: var(--accent); text-decoration: none; font-weight: 600; margin-left: auto; }

.chat-email-draft { align-self: stretch; max-width: 95%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); font-size: 1rem; line-height: 1.55; display: flex; flex-direction: column; gap: 6px; }
.chat-draft-body { white-space: pre-wrap; color: var(--muted); }
.chat-draft-docs { font-size: 0.875rem; color: var(--muted); }
.chat-draft-actions { display: flex; gap: 8px; margin-top: 4px; }
.chat-draft-actions button { font-size: 0.875rem; padding: 4px 12px; border-radius: 6px; border: 1px solid var(--border); background: transparent; cursor: pointer; }
.chat-draft-send { background: var(--accent) !important; color: #14100a; border: none !important; font-weight: 600; }
.chat-status { padding: 4px 12px; font-size: 0.875rem; color: var(--muted); }
.chat-inputrow { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.chat-inputrow textarea { flex: 1; min-width: 0; resize: none; }
.chat-inputrow button { width: auto; margin-top: 0; flex-shrink: 0; padding: 0.65rem 1rem; }

/* ── Projects card grid ──────────────────────────────────────── */
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.project-card {
  padding: 1.25rem; display: flex; flex-direction: column; gap: 0.9rem;
  cursor: pointer; transition: border-color 0.15s, transform 0.15s;
  text-decoration: none; color: inherit;
}
.project-card:hover { border-color: var(--accent-border); transform: translateY(-2px); }
.project-card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.6rem;
}
.project-card-name { display: flex; flex-direction: column; gap: 2px; }
.project-card-name strong { font-size: 0.95rem; letter-spacing: -0.2px; }
.project-card-name small { color: var(--muted); font-size: 0.875rem; }
.project-card-progress { display: flex; flex-direction: column; gap: 0.4rem; }
.project-card-progress-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.project-card-progress-row .pct { font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.project-card-stats {
  display: flex; gap: 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem;
}
.project-card-stat { display: flex; flex-direction: column; gap: 1px; }
.project-card-stat strong { font-family: 'JetBrains Mono', monospace; font-size: 0.95rem; }
.project-card-stat span { font-size: 0.62rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.project-card-actions { display: flex; justify-content: flex-end; }
.project-card-actions .btn-danger { margin: 0; }

/* ── Admin stat cards + charts ───────────────────────────────── */
.admin-stat-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem; margin-bottom: 1.25rem;
}
.admin-stat-card { padding: 1rem 1.1rem 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.admin-stat-card .label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.admin-stat-card .value-row { display: flex; align-items: baseline; gap: 0.5rem; }
.admin-stat-card .value { font-family: 'JetBrains Mono', monospace; font-size: 1.5rem; font-weight: 800; }
.admin-stat-card .delta { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; font-weight: 700; }
.admin-stat-card .delta.good { color: var(--accent-green); }
.admin-stat-card .delta.bad { color: var(--danger); }
.admin-stat-card svg { width: 100%; height: 26px; display: block; }

.admin-chart-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 0.9rem; }
@media (max-width: 900px) { .admin-chart-grid { grid-template-columns: 1fr; } }
.admin-chart-panel { padding: 1.1rem 1.25rem; }
.admin-chart-head {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.75rem;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.admin-chart-panel svg { width: 100%; height: auto; display: block; }

/* ── Drawings pipeline card ──────────────────────────────────── */
.pipeline-card { padding: 1.25rem 1.4rem; display: flex; flex-direction: column; gap: 1rem; margin-bottom: 0.9rem; }
.pipeline-head { display: flex; align-items: center; justify-content: space-between; gap: 0.9rem; flex-wrap: wrap; }
.pipeline-title { display: flex; align-items: center; gap: 0.75rem; }
.pipeline-title-text { display: flex; flex-direction: column; gap: 1px; }
.pipeline-title-text strong { font-size: 0.95rem; }
.pipeline-title-text small { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; color: var(--accent-light); }
.pipeline-pct { font-family: 'JetBrains Mono', monospace; font-size: 1.25rem; font-weight: 700; color: var(--accent); }
.pipeline-stages { display: flex; gap: 0.35rem; }
.pipeline-stage { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.pipeline-stage .progress { height: 8px; }
.pipeline-stage-label {
  font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase; text-align: center; color: var(--muted);
}
.pipeline-stage-label.active { color: var(--accent-light); }
.pipeline-stage-label.done { color: var(--accent-green); }
.pipeline-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.pipeline-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 7px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border); color: var(--muted);
}
.pipeline-chip.done { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.3); color: var(--accent-green); }
.pipeline-chip.active { background: var(--accent-dim); border-color: var(--accent-border); color: var(--accent-light); }
.pipeline-chip.failed { background: rgba(245, 101, 101, 0.08); border-color: rgba(245, 101, 101, 0.3); color: var(--danger); }

/* ── Takeoff category bar strip ──────────────────────────────── */
.tk-bars {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem 1.25rem; padding: 0 0.9rem 0.75rem; border-bottom: 1px solid var(--border); margin-bottom: 0.5rem;
}
.tk-bar { display: flex; flex-direction: column; gap: 4px; }
.tk-bar-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.72rem; }
.tk-bar-row .name { font-weight: 600; text-transform: capitalize; }
.tk-bar-row .qty { font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.tk-bar .progress { height: 6px; }

/* ── Project sharing modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-panel {
  background: var(--panel); border: 1px solid var(--border, #333);
  border-radius: 8px; padding: 1.5rem; max-width: 480px; width: 90%;
  max-height: 80vh; overflow-y: auto;
}
.share-member-row {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0;
  border-bottom: 1px solid var(--border, #333);
}
.share-member-row span { flex: 1; }
.share-add-row { display: flex; gap: 0.5rem; margin-top: 1rem; }
.share-add-row input { flex: 1; }
.btn-share { background: var(--accent); color: #fff; border: none; border-radius: 4px; padding: 0.4rem 0.8rem; cursor: pointer; }

/* ---- takeoff panel: export control + placeholder-source warning ---- */
.ws-head-spacer { margin-left: auto; }
.ws-head-btn {
  width: auto; margin: 0; padding: 0.32rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--accent-border); background: var(--accent-dim);
  color: var(--accent); font-size: 0.7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer;
  transition: background 160ms ease-out, color 160ms ease-out, border-color 160ms ease-out;
}
.ws-head-btn:hover:not(:disabled) {
  background: var(--accent); color: #14100a; border-color: var(--accent);
}
.ws-head-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ws-head-btn:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }

/* Placeholder-detector warning. Hazard, not accent: the accent is the colour of
   everything normal in this panel, so a warning wearing it would not read as one. */
.tk-warn {
  display: flex; flex-direction: column; gap: 0.35rem;
  margin: 0.75rem 0.9rem 0; padding: 0.8rem 1rem;
  border: 1px solid rgba(255, 107, 53, 0.4);
  border-left: 3px solid var(--accent-hazard);
  border-radius: 10px; background: rgba(255, 107, 53, 0.08);
}
.tk-warn strong {
  color: var(--accent-hazard); font-size: 1.02rem; font-weight: 800;
  text-transform: none; letter-spacing: 0;
}
.tk-warn span { color: var(--text); font-size: 1rem; line-height: 1.55; max-width: 78ch; }

.tk-tag-placeholder {
  display: inline-block; margin-left: 0.4rem; padding: 0.1rem 0.4rem;
  border-radius: 4px; font-size: 0.62rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent-hazard); background: rgba(255, 107, 53, 0.14);
  border: 1px solid rgba(255, 107, 53, 0.3);
}

@media (prefers-reduced-motion: reduce) {
  .ws-head-btn { transition: none; }
}

/* ---- workspace toast: completed-action confirmation over the drawing ---- */
.ws-toast {
  position: absolute; top: 18%; left: 50%; z-index: 30;
  display: flex; align-items: center; gap: 0.5rem;
  transform: translate(-50%, -6px);
  max-width: min(90%, 460px);
  padding: 0.7rem 1.1rem;
  border: 1px solid rgba(216, 210, 200, 0.16);
  border-radius: 999px;
  background: rgba(10, 9, 7, 0.88);
  color: #f2eee7; font-size: 1rem; font-weight: 600; line-height: 1.35;
  text-align: center; pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.ws-toast.ws-toast-in { opacity: 1; transform: translate(-50%, 0); }
.ws-toast-check { color: var(--accent-green); font-weight: 800; }

@media (prefers-reduced-motion: reduce) {
  .ws-toast { transition: none; transform: translate(-50%, 0); }
}


/* ---- rate cards ---------------------------------------------------------
   Reuses the input/select/focus family added 2026-08-27 rather than adding a
   second control style. Prose sits at the 16px floor; only the uppercase
   column headers and the "any type" tag run smaller, which the type rule
   exempts as labels rather than reading matter. */
/* flex-start, not space-between: the token and trial badges are position:fixed
   in the top-right, and pushing this link to the far edge leaves it sitting
   ~20px from them. Beside the title it also reads as what it is, a link to a
   related page rather than a page action. */
.page-head { display: flex; align-items: baseline; gap: 1.25rem; flex-wrap: wrap; }
.page-head-link {
  color: var(--accent); text-decoration: none; font-weight: 600; font-size: 1rem;
  border-bottom: 1px solid transparent; transition: border-color 160ms var(--ease-out, ease-out);
}
.page-head-link:hover { border-bottom-color: var(--accent); }

.page-intro { color: var(--muted); font-size: 1rem; line-height: 1.6; max-width: 68ch; margin: 0 0 1.5rem; }
.rc-readonly { color: var(--muted); font-size: 1rem; line-height: 1.6; margin: 0 0 1.25rem; }
.rc-empty { color: var(--muted); font-size: 1rem; line-height: 1.6; }

.rc-card { margin-bottom: 1.25rem; padding: 1.1rem 1.25rem; }
.rc-card-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.rc-card-head strong { font-size: 1.05rem; }
.rc-count {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent); background: var(--accent-dim);
  padding: 0.15rem 0.5rem; border-radius: 999px;
}

.rc-table { width: 100%; border-collapse: collapse; }
.rc-table th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border);
}
.rc-table td { padding: 0.5rem; font-size: 1rem; border-bottom: 1px solid var(--border); }
.rc-table td.num { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.rc-any { color: var(--muted); font-size: 0.85rem; font-style: italic; }

.rc-add { display: flex; gap: 0.5rem; margin-top: 0.9rem; flex-wrap: wrap; }
.rc-add input, .rc-add select { width: auto; margin: 0; flex: 1 1 8rem; min-width: 0; }
.rc-add .rc-add-btn { width: auto; margin: 0; padding: 0.5rem 1rem; flex: 0 0 auto; }

.btn-inline-danger {
  width: auto; margin: 0; margin-left: auto; padding: 0.3rem 0.7rem;
  font-size: 0.875rem; font-weight: 600; border-radius: 6px;
  background: transparent; border: 1px solid var(--border); color: #fc8181; cursor: pointer;
}
.btn-inline-danger:hover { border-color: #fc8181; background: rgba(252, 129, 129, 0.1); }

/* ---- project costing settings ---- */
.pc-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-end; margin-top: 0.75rem; }
.pc-field { flex: 1 1 9rem; min-width: 0; }
.pc-field label { margin-top: 0; }
.pc-field input, .pc-field select { width: 100%; margin: 0; }
.pc-status { font-size: 0.875rem; color: var(--muted); margin-top: 0.4rem; min-height: 1.2em; }
.pc-status.ok { color: var(--built, #4ade80); }


/* ---- estimate totals strip in the takeoff panel ----
   Money reads at the body floor, not as chrome: it is the number the user came
   for. The label and card name are the only sub-floor items here, and both are
   labels rather than reading matter. */
.tk-estimate {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1.1rem;
  margin: 0.75rem 0.9rem 0; padding: 0.7rem 1rem;
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; background: var(--accent-dim);
}
.tk-est-label {
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent);
}
.tk-est-card { font-size: 0.875rem; color: var(--muted); }
.tk-est-fig { font-size: 1rem; color: var(--text); font-variant-numeric: tabular-nums; }
.tk-est-total {
  font-size: 1.05rem; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums; margin-left: auto;
}
.tk-est-warn {
  font-size: 0.875rem; color: var(--accent-hazard);
  flex-basis: 100%;
}

/* A trace refusal ("that looks like a wall") is instructional, not a failure
   of the app, so it stays in the status line rather than the toast — toast.js
   stamps a checkmark on everything it shows. Hazard colour so it is not
   mistaken for the ordinary prompt sitting in the same slot. */
.ws-tool-status-warn { color: var(--accent-hazard); font-weight: 600; }


/* ---- review queue and revision compare ----
   Reuses the input/select/focus/table family rather than adding another.
   Semantic colour for added/removed is deliberately NOT the amber accent —
   accent means "this app", these mean "this number moved". */
.rv-tabs { display: flex; gap: 0.5rem; margin: 0 0 1.5rem; border-bottom: 1px solid var(--border); }
.rv-tab {
  width: auto; margin: 0; padding: 0.6rem 1rem; background: transparent; border: none;
  border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); font-size: 1rem; font-weight: 600; cursor: pointer;
}
.rv-tab:hover { color: var(--text); }
.rv-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.rv-threshold { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.15rem; margin-bottom: 1.5rem; }
.rv-threshold-row { display: flex; gap: 0.5rem; align-items: center; }
.rv-threshold-row input { width: 7rem; margin: 0; }
.rv-threshold-row button { width: auto; margin: 0; padding: 0.5rem 1rem; }
.rv-status { font-size: 0.875rem; color: var(--muted); }

.rv-empty { color: var(--muted); font-size: 1rem; line-height: 1.6; }
/* An empty queue is success, not a void. */
.rv-empty-good { color: var(--built, #4ade80); }

.rv-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.rv-table th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border);
}
.rv-table td { padding: 0.6rem; font-size: 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.rv-table td.num { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rv-sub { display: block; color: var(--muted); font-size: 0.875rem; }

.rv-conf {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.875rem; font-weight: 700;
  color: var(--accent-hazard); background: rgba(255, 107, 53, 0.14);
  border: 1px solid rgba(255, 107, 53, 0.3);
}
.rv-actions { display: flex; gap: 0.5rem; align-items: center; white-space: nowrap; }
.rv-open { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.rv-open:hover { text-decoration: underline; }
.rv-approve { width: auto; margin: 0; padding: 0.35rem 0.8rem; font-size: 0.875rem; }

.rv-compare-pick { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.rv-compare-pick button { width: auto; margin: 0; padding: 0.6rem 1.2rem; }

.rv-summary { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0 0.5rem; }
.rv-pill {
  font-size: 0.875rem; font-weight: 600; padding: 0.25rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.rv-pill.rv-added { color: #4ade80; border-color: rgba(74, 222, 128, 0.4); background: rgba(74, 222, 128, 0.1); }
.rv-pill.rv-removed { color: #fc8181; border-color: rgba(252, 129, 129, 0.4); background: rgba(252, 129, 129, 0.1); }
.rv-pill.rv-changed { color: var(--accent); border-color: var(--accent-border); background: var(--accent-dim); }

.rv-tag { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.rv-tag.rv-added { color: #4ade80; }
.rv-tag.rv-removed { color: #fc8181; }
.rv-tag.rv-unchanged { color: var(--muted); }
.rv-row-added td { background: rgba(74, 222, 128, 0.06); }
.rv-row-removed td { background: rgba(252, 129, 129, 0.06); }

/* The Review link sits in the card's action row beside real buttons, so it has
   to match their box without becoming a third button style. */
.btn-review {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.4rem 0.9rem; border-radius: 8px; font-size: 0.875rem; font-weight: 700;
  border: 1px solid var(--accent-border); background: var(--accent-dim);
  color: var(--accent); text-decoration: none; white-space: nowrap;
}
.btn-review:hover { background: var(--accent); color: #14100a; border-color: var(--accent); }
