@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

/* Haven Ops — "granite ledger": a dignified dark workspace for a memorial
   business. Deep graphite surfaces, one warm gold accent, serif display,
   engineered sans for data. Calm over flashy; legibility over density. */

:root {
  --bg: #0e131c;
  --surface: #171e2b;
  --surface-2: #202938;
  --surface-3: #29334580;
  --ink: #ecedf1;
  --muted: #9aa4b6;
  --line: rgba(255,255,255,0.07);
  --line-strong: rgba(255,255,255,0.16);
  --gold: #cda85f;
  --gold-ink: #1a1305;
  --gold-bg: rgba(205,168,95,0.14);
  --gold-line: rgba(205,168,95,0.35);
  --danger: #e88179;
  --danger-bg: rgba(232,129,121,0.14);
  --success: #74c79c;
  --success-bg: rgba(116,199,156,0.14);
  --blue: #79b0e6;
  --blue-bg: rgba(121,176,230,0.14);
  --amber: #e0b25e;
  --amber-bg: rgba(224,178,94,0.14);
  --radius: 12px;
  --radius-sm: 8px;   /* concentric: outer 12 = inner 8 + 4 gap */
  --radius-xs: 6px;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.18);
  --shadow-2: 0 2px 4px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.28);
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-serif: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(205,168,95,0.05), transparent 60%),
    var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--ink); margin: 0 0 0.4rem; text-wrap: balance; }
h1 { font-size: 1.7rem; font-family: var(--font-serif); font-weight: 700; letter-spacing: 0.015em; }
h2 { font-size: 1.15rem; font-weight: 600; letter-spacing: 0.01em; }
h3 { font-size: 0.98rem; font-weight: 600; }
p { text-wrap: pretty; }
code { background: var(--surface-2); border-radius: var(--radius-xs); padding: 0.1em 0.35em; font-size: 0.86em; }

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--gold); }

/* Focus is always visible, never removed silently. */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
form input:focus-visible, form select:focus-visible, form textarea:focus-visible {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(205,168,95,0.2);
}

/* ---------------------------------------------------------------- app shell */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.65rem 1.5rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
}
.brand {
  font-family: var(--font-serif); font-size: 1.5rem; font-weight: 700;
  color: var(--ink); letter-spacing: 0.01em; white-space: nowrap;
}
.brand span { color: var(--gold); }
.site-nav { display: flex; gap: 0.2rem; flex-wrap: wrap; align-items: center; }
.site-nav a {
  font-size: 0.9rem; padding: 0.45rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--muted); transition: background-color 130ms, color 130ms;
}
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }
.site-nav a.active { background: var(--surface-2); color: var(--ink); font-weight: 500; box-shadow: inset 0 -2px 0 var(--gold); }

/* Logout is a POST (state-changing actions are never GET links); these make
   the buttons look like the nav links around them. */
.nav-logout {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 0.9rem; padding: 0.45rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--muted); transition: background-color 130ms, color 130ms;
}
.nav-logout:hover { background: var(--surface-2); color: var(--ink); }

/* Phone: primary destinations live in a thumb-reach bottom bar. */
.tabbar { display: none; }
.logout-mobile-form { display: none; margin: 0; }
.logout-mobile { display: none; background: none; border: none; cursor: pointer; font-family: inherit; }
@media (max-width: 700px) {
  .site-nav { display: none; }
  .logout-mobile-form { display: block; }
  .logout-mobile {
    display: inline-flex; align-items: center; min-height: 40px;
    font-size: 0.85rem; color: var(--muted); padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
  }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding: 0.3rem 0.4rem calc(0.3rem + env(safe-area-inset-bottom));
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    min-height: 44px; justify-content: center;
    font-size: 0.68rem; color: var(--muted); border-radius: var(--radius-sm);
    transition: color 130ms, background-color 130ms;
  }
  .tabbar a .t-ico { font-size: 1.05rem; line-height: 1; }
  .tabbar a.active { color: var(--gold); background: var(--gold-bg); }
  body { padding-bottom: 70px; }
}

main { padding: 1.5rem; max-width: 1320px; margin: 0 auto; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 40px; padding: 0.45rem 1rem;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink); font-size: 0.9rem; cursor: pointer;
  font-family: inherit;
  transition: background-color 130ms, border-color 130ms, transform 120ms;
}
.btn:hover { background: #2c3547; border-color: var(--muted); }
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 600; }
.btn-primary:hover { background: #d8b870; border-color: #d8b870; }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-sm { min-height: 32px; padding: 0.2rem 0.65rem; font-size: 0.78rem; }

/* -------------------------------------------------------------- page pieces */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-sub { margin: 0; color: var(--muted); font-size: 0.9rem; }
.sync-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.metric {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.85rem 1rem; box-shadow: var(--shadow-1);
}
.metric a { display: block; color: inherit; }
.metric-v { display: block; font-size: 1.65rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric-l { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }

/* Stats on the PIPELINE are a single compact strip - orientation, not
   decoration. It must never push the actual work below the fold (it used to
   eat 1.5 phone screens); on narrow screens the strip scrolls sideways
   instead of wrapping. Scoped to .dash-main; other pages keep the grid. */
.dash-main .metrics {
  display: flex; flex-wrap: nowrap; gap: 0.5rem; margin-bottom: 1rem;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.dash-main .metrics::-webkit-scrollbar { display: none; }
.dash-main .metric {
  flex: 0 0 auto; display: flex; align-items: baseline; gap: 0.45rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.35rem 0.85rem; box-shadow: var(--shadow-1);
}
.dash-main .metric a { display: flex; align-items: baseline; gap: 0.45rem; color: inherit; }
.dash-main .metric-v { font-size: 1.05rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-main .metric-l { font-size: 0.76rem; color: var(--muted); white-space: nowrap; margin-top: 0; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1rem;
  box-shadow: var(--shadow-1);
}
.gold-line { height: 2px; width: 44px; background: var(--gold); margin: 0.4rem 0 1.1rem; border-radius: 1px; }

.badge {
  display: inline-block; padding: 0.14rem 0.55rem; border-radius: 999px;
  font-size: 0.74rem; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
  vertical-align: middle;
}
.badge-alert { background: var(--danger-bg); color: var(--danger); border-color: rgba(232,129,121,0.32); }
.badge-gold { background: var(--gold-bg); color: var(--gold); border-color: var(--gold-line); }
.badge-ok { background: var(--success-bg); color: var(--success); border-color: rgba(116,199,156,0.32); }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--surface); padding: 0.85rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.stat-card strong { display: block; font-size: 1.35rem; }

/* -------------------------------------------------------------------- forms */
form label { display: block; margin-bottom: 0.75rem; font-size: 0.85rem; color: var(--muted); }
form input, form select, form textarea {
  display: block; width: 100%; margin-top: 0.25rem; min-height: 40px; padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink); font-family: inherit; font-size: 0.9rem;
  transition: border-color 130ms, box-shadow 130ms;
}
form input::placeholder, form textarea::placeholder { color: var(--muted); }
form textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.draft-box { min-height: 480px; resize: vertical; line-height: 1.65; font-size: 0.97rem; padding: 0.9rem 1rem; }
form select option { background: var(--surface); color: var(--ink); }

/* ------------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 0.82rem; letter-spacing: 0.02em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------------- alerts */
.alert { padding: 0.8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid var(--line); background: var(--surface); }
.alert-info { background: var(--blue-bg); border-color: rgba(121,176,230,0.32); color: var(--blue); }
.alert-warn { background: var(--amber-bg); border-color: rgba(224,178,94,0.32); color: var(--amber); }
.alert-success { background: var(--success-bg); border-color: rgba(116,199,156,0.32); color: var(--success); }
.alert a { color: inherit; text-decoration: underline; }

.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: end; }

/* ----------------------------------------------------------------- pipeline */
.dash { display: flex; gap: 1.5rem; align-items: flex-start; }
.dash-main { flex: 1; min-width: 0; }
.dash-side {
  width: 300px; flex-shrink: 0; position: sticky; top: 70px;
  max-height: calc(100vh - 90px); overflow-y: auto; scrollbar-width: thin;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.75rem 0.85rem; box-shadow: var(--shadow-1);
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.side-head span { font-weight: 600; font-size: 1rem; }
.side-empty { font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
.note { position: relative; border-left: 3px solid var(--blue); background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.5rem 1.7rem 0.5rem 0.6rem; margin-bottom: 0.5rem; }
.note.note-new { border-left-color: var(--success); }
.note-cust { font-size: 0.85rem; font-weight: 500; }
.note-cust a { color: var(--ink); }
.note-cust a:hover { color: var(--gold); }
.note-msg { font-size: 0.8rem; color: var(--muted); margin-top: 1px; }
.note-time { font-size: 0.72rem; color: var(--muted); margin-top: 2px; opacity: 0.85; }
.note-del { position: absolute; top: 4px; right: 4px; margin: 0; }
.note-del button { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; min-width: 28px; min-height: 28px; border-radius: var(--radius-xs); }
.note-del button:hover { color: var(--danger); background: var(--danger-bg); }

.filterbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }
.filterbar input {
  width: 250px; max-width: 100%; margin: 0; min-height: 40px; padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink); font-size: 0.88rem;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip {
  display: inline-flex; align-items: center;
  font-size: 0.8rem; min-height: 44px; padding: 0.3rem 0.9rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted);
  cursor: pointer; font-family: inherit;
  transition: background-color 130ms, color 130ms, border-color 130ms, transform 120ms;
}
/* Pipeline only: chips share one line with search and scroll sideways. */
.dash-main .filter-chips {
  flex-wrap: nowrap; flex: 1; min-width: 0;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.dash-main .filter-chips::-webkit-scrollbar { display: none; }
.dash-main .fchip { flex: 0 0 auto; min-height: 40px; }
.fchip:hover { background: var(--surface-2); color: var(--ink); }
.fchip:active { transform: scale(0.96); }
.fchip.active { background: var(--gold-bg); color: var(--gold); border-color: var(--gold-line); }

/* Suggestions: sync's proposals awaiting a human decision. Gold edge =
   "needs you", matching the quote panel's accent. */
.sug-panel { border-left: 3px solid var(--gold); }
.sug-row {
  display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap;
  padding: 0.55rem 0; border-top: 1px solid var(--line);
}
.sug-main { flex: 1; min-width: 220px; }
.sug-phases { font-size: 0.85rem; color: var(--muted); margin-left: 0.5rem; }
.sug-phases strong { color: var(--gold); }
.sug-evidence { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.sug-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

.new-order { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 1rem; margin-bottom: 1.5rem; box-shadow: var(--shadow-1); }
.new-order summary { cursor: pointer; color: var(--gold); font-size: 0.9rem; font-weight: 500; padding: 0.45rem 0; }
.new-order-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.85rem; margin-top: 0.85rem; align-items: end; }
.new-order-form .full { grid-column: 1 / -1; }

.board { display: flex; flex-direction: column; gap: 1.1rem; }
.band { border-left: 3px solid var(--line-strong); padding-left: 0.95rem; }
.band.stage-a { border-left-color: var(--blue); }
.band.stage-b { border-left-color: var(--amber); }
.band.stage-c { border-left-color: var(--success); }
/* Phase headers: collapsible (details/summary) and sticky, so mid-scroll you
   always know which stage you are in and can fold stages you are done with. */
.band-head {
  display: flex; align-items: center; gap: 0.6rem; cursor: pointer;
  list-style: none; padding: 0.45rem 0; margin: 0 0 0.35rem;
  position: sticky; top: 52px; z-index: 40;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
}
.band-head::-webkit-details-marker { display: none; }
.band-caret { margin-left: auto; color: var(--muted); font-size: 0.7rem; transition: transform 130ms; }
.band-caret::before { content: "▾"; }
.band:not([open]) .band-caret::before { content: "▸"; }
.band-head:hover .phase-pill { filter: brightness(1.15); }
.phase-pill { font-size: 0.85rem; font-weight: 600; padding: 0.25rem 0.75rem; border-radius: 999px; }
.stage-a .phase-pill { background: var(--blue-bg); color: var(--blue); }
.stage-b .phase-pill { background: var(--amber-bg); color: var(--amber); }
.stage-c .phase-pill { background: var(--success-bg); color: var(--success); }
.band-count { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* One column of slim ledger rows - scannable like a register, not a wall of
   cards. The phase dropdown lives at the row's edge (one-tap moves stay);
   everything rarer sits behind the ⋯ expander. */
.oledger { display: flex; flex-direction: column; gap: 0.45rem; }

.ocard {
  display: flex; gap: 0.9rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem; box-shadow: var(--shadow-1);
  transition: border-color 130ms, box-shadow 130ms;
}
.ocard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.ocard.flag { border-color: rgba(232,129,121,0.5); background: linear-gradient(var(--danger-bg), var(--danger-bg)), var(--surface); }
.omain { flex: 1; min-width: 0; }
.oside { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.ocard-top { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.oname { font-size: 0.95rem; font-weight: 600; color: var(--ink); }
.oname:hover { color: var(--gold); }
.chip { font-size: 0.72rem; padding: 0.12rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip-sup { background: var(--gold-bg); color: var(--gold); border-color: var(--gold-line); }
.chip-paid { background: var(--success-bg); color: var(--success); border-color: rgba(116,199,156,0.32); }
.chip-mail { background: var(--blue-bg); color: var(--blue); border-color: rgba(121,176,230,0.32); }
.chip-flag { background: var(--danger-bg); color: var(--danger); border-color: rgba(232,129,121,0.32); }

.osub { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; font-variant-numeric: tabular-nums; }
.oemail { font-size: 0.78rem; color: var(--blue); background: var(--blue-bg); border-radius: var(--radius-xs); padding: 0.3rem 0.5rem; margin-top: 0.3rem; line-height: 1.4; }
.onote { font-size: 0.78rem; color: var(--ink); background: var(--surface-2); border-radius: var(--radius-xs); padding: 0.3rem 0.5rem; margin-top: 0.3rem; white-space: pre-line; }

.phase-move { margin: 0; }
.phase-move select { width: 168px; font-size: 0.76rem; min-height: 36px; padding: 0.25rem 0.35rem; margin: 0; }
.drive-link { font-size: 0.78rem; white-space: nowrap; color: var(--muted); }
.drive-link:hover { color: var(--gold); }

/* The ⋯ expander: rare actions (Drive, review clear, supplier/note edit)
   stay one tap away without repeating themselves on every row. */
.ocard-edit { position: relative; }
.ocard-edit > summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center;
  justify-content: center; min-width: 36px; min-height: 36px;
  border-radius: var(--radius-xs); border: 1px solid var(--line);
  color: var(--muted); font-size: 1rem; line-height: 1;
}
.ocard-edit > summary::-webkit-details-marker { display: none; }
.ocard-edit > summary:hover { color: var(--gold); border-color: var(--gold-line); }
.ocard-edit[open] > summary { color: var(--gold); border-color: var(--gold-line); background: var(--gold-bg); }
.oactions {
  /* Above the sticky band heads (z 40), below the site header (z 100). */
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  min-width: 300px; padding: 0.55rem 0.65rem;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
}
.quick-form { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; align-items: center; }
.oactions .quick-form { margin-top: 0; flex: 1; }
.quick-form select, .quick-form input { width: auto; flex: 1; min-width: 90px; margin: 0; min-height: 34px; padding: 0.3rem 0.4rem; font-size: 0.76rem; }

/* -------------------------------------------------------------------- inbox */
.mail-list { padding: 0; }
.mail-row { display: flex; align-items: flex-start; gap: 0.8rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); color: inherit; transition: background-color 130ms; }
a.mail-row:hover { background: var(--surface-2); color: inherit; }
.mail-row:last-child { border-bottom: none; }
.mail-main { flex: 1; min-width: 0; }
.mail-line1 { display: flex; align-items: baseline; gap: 0.5rem; }
.mail-from { font-weight: 500; font-size: 0.92rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-when { margin-left: auto; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.mail-subj { font-size: 0.86rem; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.mail-badges { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.3rem; }

/* ------------------------------------------------------------- thread view */
.thread-panel { max-height: calc(100vh - 130px); overflow-y: auto; scrollbar-width: thin; }
.thread-msg { border-left: 3px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); padding: 0.6rem 0.8rem; margin-bottom: 0.7rem; }
.thread-msg.me { border-left-color: var(--gold); background: var(--surface); }
.thread-meta { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; font-size: 0.8rem; margin-bottom: 0.3rem; }
.thread-meta strong { color: var(--ink); }
.thread-meta span { color: var(--muted); white-space: nowrap; }
.thread-body { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.55; overflow-wrap: anywhere; }
.thread-older > summary { cursor: pointer; color: var(--muted); font-size: 0.82rem; padding: 0.3rem 0 0.7rem; }
.thread-older > summary:hover { color: var(--gold); }

/* -------------------------------------------------------------- quote panel */
.quote-panel { border-left: 3px solid var(--gold); }
.msg-detail { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: start; }
/* DOM order is actions-first (phones and assistive tech read Quote/Draft
   before the thread); desktop places the columns explicitly so the thread
   still sits LEFT visually. */
@media (min-width: 1020px) {
  .msg-detail { grid-template-columns: minmax(320px, 5fr) 7fr; }
  .msg-detail > .msg-col-sticky { grid-column: 1; grid-row: 1; position: sticky; top: 70px; }
  .msg-detail > .msg-actions { grid-column: 2; grid-row: 1; }
}

/* Long email bodies (signature walls, legal boilerplate) collapse behind a
   "Show full message" toggle - inbox_detail.html adds .th-clamp via JS only
   when a body is actually tall, so short messages never get a dead button. */
.th-clamp { max-height: 300px; overflow: hidden; position: relative; }
.th-clamp::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56px;
  background: linear-gradient(transparent, var(--surface-2));
}
.thread-msg.me .th-clamp::after { background: linear-gradient(transparent, var(--surface)); }
.th-more {
  display: block; margin-top: 2px; background: none; border: none;
  color: var(--blue); cursor: pointer; font-size: 0.8rem; padding: 6px 0;
  min-height: 32px; font-family: inherit;
}
.th-more:hover { color: var(--gold); }

/* --------------------------------------------------------------- price book */
.pb-progress { display: flex; align-items: center; gap: 0.7rem; margin: 0.2rem 0 1rem; }
.pb-bar { flex: 1; max-width: 380px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.pb-bar span { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.pb-catnav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 1.25rem; position: sticky; top: 62px; z-index: 50; padding: 0.5rem 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
/* Jump targets land below the sticky header + category nav, not under them. */
.panel[id^="cat-"] { scroll-margin-top: 130px; }
.pb-shape { border-bottom: 1px solid var(--line); padding: 0.5rem 0 0.7rem; }
.pb-shape:last-child { border-bottom: none; }
.pb-shape-head { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; padding: 0.3rem 0; }
.pb-shape .pb-entry { border-bottom: none; padding: 0.25rem 0 0.25rem 1rem; }
.pb-entry { border-bottom: 1px solid var(--line); padding: 0.6rem 0; }
.pb-entry:last-child { border-bottom: none; }
.pb-entry > summary { cursor: pointer; display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; min-height: 40px; align-content: center; }
.pb-entry > summary:hover strong { color: var(--gold); }
.pb-price { color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 600; }
.pb-meta { color: var(--muted); font-size: 0.85rem; }

/* -------------------------------------------------------------------- login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: radial-gradient(700px 420px at 50% 20%, rgba(205,168,95,0.07), transparent 65%), var(--bg); }
.login-box { width: 100%; max-width: 390px; padding: 1.8rem 1.9rem; }

.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 980px) {
  .dash { flex-direction: column; }
  .dash-side { width: 100%; position: static; max-height: none; }
}
@media (max-width: 700px) {
  /* One scrollable row: keeps the sticky nav a fixed ~60px tall, so the
     130px scroll-margin always clears header + nav on category jumps. */
  .pb-catnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .pb-catnav::-webkit-scrollbar { display: none; }
  .pb-catnav .fchip { flex: 0 0 auto; }
}
@media (max-width: 600px) {
  main { padding: 1rem; }
  h1 { font-size: 1.45rem; }
  .hide-phone { display: none; }
  /* Inbox filter chips: one scrollable row, like the pipeline's. */
  .mail-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .mail-chips::-webkit-scrollbar { display: none; }
  .mail-chips .fchip { flex: 0 0 auto; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .metric { padding: 0.6rem 0.7rem; }
  .metric-v { font-size: 1.3rem; }
  .panel { padding: 0.9rem 1rem; }
  .pb-catnav { top: 54px; }
  .band-head { top: 48px; }
  .sync-actions .btn { min-height: 36px; padding: 0.3rem 0.75rem; font-size: 0.84rem; }
  /* Phone rows stack: full-width name/meta line, then a slim controls line -
     squeezing a select beside a name at 375px starves both. */
  .ocard { flex-wrap: wrap; gap: 0.4rem 0.55rem; padding: 0.45rem 0.55rem; }
  .omain { flex: 1 1 100%; }
  .oside { width: 100%; justify-content: flex-end; }
  .phase-move { flex: 1; }
  .phase-move select { width: 100%; max-width: 240px; margin-left: auto; }
  /* The action popover hugs the screen edge instead of overflowing it. */
  .oactions { min-width: 0; left: auto; right: 0; width: min(86vw, 340px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
