/* ============================================================
   Sugarloaf CRM — modern, low-clutter. GA = clay, MA = evergreen.
   ============================================================ */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --border: #e3e1db;
  --text: #23211d;
  --text-dim: #6b675f;
  --accent: #b4643c;          /* GA clay — overridden per market */
  --accent-soft: #f3e2d8;
  --good: #3f7d4e;
  --warn: #b8862b;
  --bad: #b23b3b;
  --radius: 12px;
  --radius-sm: 8px;
  --nav-w: 60px;
  --nav-w-open: 208px;
  --rail-w: 300px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
body[data-market="MA"] { --accent: #2f6d4a; --accent-soft: #dfeee4; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1917;
    --surface: #242220;
    --surface-2: #2d2b28;
    --border: #38352f;
    --text: #ece9e2;
    --text-dim: #9c968a;
    --accent-soft: #3a2b22;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
  }
  :root:not([data-theme="light"]) body[data-market="MA"] { --accent-soft: #1f3329; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea {
  font: inherit; color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- login ---------- */
.login-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px; width: min(340px, 90vw);
  display: flex; flex-direction: column; gap: 14px;
}
.login-mark { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 4px; }
/* ---------- brand / logo ----------
   Two real assets rather than a CSS invert: logo.png is black for light
   backgrounds, logo-white.png is the white version Arthur supplied for dark.
   Inverting the black one produced grey fringing on the antialiased edges of
   the mountain mark; the real white asset is clean.
   In the collapsed 60px sidebar .brand clips the wide logo from the left,
   leaving exactly the mountain mark visible — no separate icon file needed. */
.login-logo { display: block; width: 100%; max-width: 236px; height: auto; margin: 0 auto 10px; }
.brand { overflow: hidden; }
.brand-logo { height: 24px; width: auto; max-width: none; display: block; }

/* default (light): show the black mark, hide the white one */
.logo-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-dark  { display: none; }
  :root:not([data-theme="light"]) .logo-light { display: block; }
}
:root[data-theme="dark"] .logo-dark  { display: none; }
:root[data-theme="dark"] .logo-light { display: block; }
:root[data-theme="light"] .logo-dark  { display: block; }
:root[data-theme="light"] .logo-light { display: none; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.login-card button { background: var(--accent); color: #fff; border: 0; border-radius: var(--radius-sm); padding: 10px; font-weight: 600; }
.login-error { color: var(--bad); font-size: 12px; min-height: 1em; margin: 0; text-align: center; }

/* ---------- shell grid ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr var(--rail-w);
  grid-template-rows: 52px 1fr;
  grid-template-areas: "nav top rail" "nav view rail";
  height: 100vh;
}
.shell.rail-closed { grid-template-columns: var(--nav-w) 1fr 0; }

/* ---------- sidenav ---------- */
.sidenav {
  grid-area: nav;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 10px 8px; gap: 4px;
  overflow: hidden;
  transition: width .16s ease;
  z-index: 30;
}
.sidenav:hover, .sidenav.pinned { width: var(--nav-w-open); position: absolute; height: 100vh; box-shadow: var(--shadow); }
.sidenav.pinned { position: relative; box-shadow: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 10px 8px 14px; font-weight: 700; white-space: nowrap; }
.brand-icon { font-size: 18px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); white-space: nowrap;
}
.nav-item .ico { width: 20px; text-align: center; font-size: 15px; flex: none; }
.nav-item .ico svg { display: block; margin: 0 auto; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidenav nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; scrollbar-width: thin; }
.nav-pin { margin-top: auto; background: none; border: 0; color: var(--text-dim); padding: 8px; border-radius: var(--radius-sm); }
.nav-pin:hover { background: var(--surface-2); }

/* ---------- topbar ---------- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; font-size: 15px; }
.spacer { flex: 1; }
.icon-btn { background: none; border: 0; color: var(--text-dim); font-size: 15px; padding: 6px 8px; border-radius: var(--radius-sm); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
#nav-toggle { display: none; }
.global-date { padding: 6px 8px; font-size: 13px; }
.market-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.market-switch button { background: var(--surface); border: 0; padding: 5px 14px; font-weight: 600; color: var(--text-dim); font-size: 12px; }
.market-switch button.on { background: var(--accent); color: #fff; }
.user-chip { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }

/* ---------- view ---------- */
.view { grid-area: view; overflow-y: auto; padding: 20px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 18px; margin: 0; }
.page-head .spacer { flex: 1; }
.btn {
  background: var(--accent); color: #fff; border: 0;
  padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
}
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: var(--bad); }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px;
}
.card h3 { margin: 0 0 4px; font-size: 14px; }
.muted { color: var(--text-dim); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-dim); }
.pill.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.pill.bad  { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }

.stat-row { display: flex; gap: 18px; margin-bottom: 16px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; min-width: 96px; }
.stat b { font-size: 20px; display: block; }
.stat span { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }

/* home board */
.board { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-items: start; }
.emp-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.emp-col > header { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-weight: 600; }
.emp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.visit { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.visit:last-child { border-bottom: 0; }
.visit .v-main { flex: 1; min-width: 0; }
.visit .v-name { font-weight: 600; }
.visit .v-sub { font-size: 12px; color: var(--text-dim); }
.visit .v-check { flex: none; }
.visit.done .v-name { text-decoration: line-through; color: var(--text-dim); }
.emp-col .empty { padding: 14px 12px; color: var(--text-dim); font-size: 12px; }

/* tables */
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
table.grid th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); background: var(--surface-2); }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover, table.grid tr.clickable:hover { background: var(--surface-2); cursor: pointer; }
.table-wrap { overflow-x: auto; }

/* Ops tables — keep rows compact on an iPad: short values never wrap, long notes
   clamp to two lines and expand on tap. */
.pill { white-space: nowrap; }
table.grid.ops td { vertical-align: top; }
table.grid.ops td.nw, table.grid.ops th { white-space: nowrap; }
table.grid.ops td.num { text-align: right; font-variant-numeric: tabular-nums; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-width: 180px; max-width: 360px; cursor: pointer; color: var(--text-dim); }
.clamp.open { display: block; -webkit-line-clamp: unset; overflow: visible; }
/* Photos on leads and clients */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.photo-grid figure { margin: 0; cursor: pointer; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.photo-grid figcaption { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-view { max-width: min(92vw, 1100px); max-height: 80vh; object-fit: contain; border-radius: 8px; display: block; margin: 0 auto; }
.due-late { color: var(--bad); font-weight: 600; }
.due-today { color: var(--warn); font-weight: 600; }
.due-later { color: var(--text-dim); }

/* task rail */
.taskrail {
  grid-area: rail;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.shell.rail-closed .taskrail { display: none; }
.taskrail-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.market-tag { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: #fff; }
.taskrail-head .icon-btn { margin-left: auto; }
.task-add { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.task-add input { width: 100%; }
.task-list { overflow-y: auto; padding: 6px 0; flex: 1; }
.task {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.task:hover { background: var(--surface-2); }
.task input[type=checkbox] { margin-top: 2px; }
.task .t-body { flex: 1; min-width: 0; }
.task .t-title { font-size: 13px; }
.task.done .t-title { text-decoration: line-through; color: var(--text-dim); }
.task .t-meta { font-size: 11px; color: var(--text-dim); display: flex; gap: 8px; }
.task .t-del { opacity: 0; border: 0; background: none; color: var(--text-dim); }
.task:hover .t-del { opacity: 1; }
.t-prio-high { color: var(--bad); }
.taskrail-open { position: fixed; right: 0; top: 60px; background: var(--accent); color: #fff; border: 0; padding: 8px 10px; border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-size: 12px; z-index: 20; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(520px, 96vw); max-height: 90vh; overflow-y: auto; padding: 20px;
}
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.form-grid { display: grid; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.form-grid .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 60;
  box-shadow: var(--shadow);
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 0 1fr 0; grid-template-areas: "top top top" "view view view"; }
  .sidenav { position: fixed; height: 100vh; width: var(--nav-w-open); transform: translateX(-100%); transition: transform .16s ease; }
  .sidenav.open { transform: translateX(0); box-shadow: var(--shadow); }
  #nav-toggle { display: inline-block; }
  .nav-pin { display: none; }
  .taskrail { position: fixed; right: 0; top: 52px; height: calc(100vh - 52px); width: min(320px, 88vw); transform: translateX(100%); transition: transform .16s ease; z-index: 25; box-shadow: var(--shadow); }
  .taskrail.open { transform: translateX(0); }
  .shell.rail-closed .taskrail { display: flex; }
  .taskrail-open { display: block !important; }
  .global-date { display: none; }
}

/* ---------------------------------------------------------------------
   Pipeline — horizontal-scrolling stage board, HubSpot-style deal cards
   --------------------------------------------------------------------- */
.pipeline-track {
  display: flex; gap: 14px; overflow-x: auto; overflow-y: hidden;
  padding-bottom: 10px; align-items: start;
  scroll-snap-type: x proximity;
}
.stage-col {
  flex: 0 0 280px; scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: calc(100vh - 190px);
}
.stage-col > header {
  padding: 10px 12px; border-bottom: 1px solid var(--border); border-top: 3px solid var(--accent);
  display: flex; align-items: center; justify-content: space-between; font-weight: 600;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stage-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-total { padding: 2px 12px 8px; font-size: 12px; }
.stage-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 80px; }
.stage-body.drag-over { background: var(--accent-soft); }
.deal-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; cursor: grab; display: flex; flex-direction: column; gap: 6px;
}
.deal-card:active { cursor: grabbing; }
.deal-card:hover { border-color: var(--accent); }
.deal-name { font-weight: 600; }
.deal-value { font-size: 13px; color: var(--text-dim); }
.deal-meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* stage manager (inside the modal) */
.stage-manage-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.stage-manage-row { display: flex; align-items: center; gap: 6px; }
.stage-manage-row input { flex: 1; }

/* ---------------------------------------------------------------------
   Deal detail — notes timeline + follow-up form
   --------------------------------------------------------------------- */
.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.note-form textarea { width: 100%; resize: vertical; }
.inline-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }
.inline-check input { width: auto; }
.due-picker { display: flex; flex-direction: column; gap: 6px; }
.due-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.due-pill {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.due-pill:hover { border-color: var(--accent); }
.due-pill.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.due-picker input[type="date"] { max-width: 180px; }
.due-label { font-size: 12px; }
.note-list { display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow-y: auto; }
.note-row { border-left: 2px solid var(--accent); padding-left: 10px; }
.note-head { font-size: 11px; margin-bottom: 2px; }
.note-body { white-space: pre-wrap; }

/* ---------------------------------------------------------------------
   Tasks page
   --------------------------------------------------------------------- */
.task-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.task-row:first-child { border-top: none; }
.task-main { flex: 1; cursor: pointer; }

/* ---------------------------------------------------------------------
   Quote builder
   --------------------------------------------------------------------- */
.q-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.q-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.q-side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 14px; }
.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 8px 0; }
.q-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); margin: 6px 0; }
.q-field textarea, .q-item textarea, .q-section > textarea, .q-term textarea { width: 100%; resize: vertical; }
.q-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.q-row .q-name { flex: 1; min-width: 160px; }
.q-title { font-weight: 600; font-size: 15px; }
.q-sub { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 10px 0 4px; }
.q-section.hl { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.q-items { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.q-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--bg); }
.q-opts { font-size: 12px; }
.q-photos { display: flex; gap: 6px; flex-wrap: wrap; }
.q-photo { position: relative; margin: 0; cursor: pointer; border-radius: 8px; outline: 2px solid transparent; }
.q-photo img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; display: block; opacity: .55; }
.q-photo.on { outline-color: var(--accent); }
.q-photo.on img { opacity: 1; }
.q-badge { position: absolute; top: 3px; left: 3px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 0 6px; }
.q-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 14px; }
.q-term { border-top: 1px solid var(--border); padding: 6px 0; }
.q-term summary { cursor: pointer; font-weight: 600; }
.q-total { display: flex; justify-content: space-between; padding: 4px 0; }
.q-total b { font-variant-numeric: tabular-nums; }
.q-check { font-size: 12.5px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.q-check:last-child { border-bottom: 0; }
.q-check.bad { color: var(--bad); }
.q-check.warn { color: var(--warn); }
.q-check.good { color: var(--good); }
@media (max-width: 1100px) { .q-layout { grid-template-columns: 1fr; } .q-side { position: static; order: -1; } }
.q-banner { margin-bottom: 14px; border-left: 4px solid var(--warn); }
.q-banner.good { border-left-color: var(--good); }
.q-link { color: var(--accent); word-break: break-all; font-size: 12.5px; flex: 1; min-width: 200px; }

/* ---------------------------------------------------------------------
   Billing — card badge, invoice rows
   --------------------------------------------------------------------- */
.card-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; }
.card-badge.ok { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.card-badge.none { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.billing-card { border-left: 4px solid var(--accent); }
.inv-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 10px 0; border-top: 1px solid var(--border); align-items: start; }
.inv-row:first-child { border-top: 0; }
.inv-amt { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-variant-numeric: tabular-nums; }
.inv-acts { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.card-section { border-left: 4px solid var(--warn); }
.card-section.ok { border-left-color: var(--good); }
.card-section .card-badge { font-size: 14px; }

/* ---------------------------------------------------------------------
   What's clickable (Arthur, 2026-09-27): a darker rounded box on hover
   for every tappable row, card, list item and in-text link.
   --------------------------------------------------------------------- */
.is-clickable, a.row-link, .inv-row, table.grid tr.clickable {
  cursor: pointer; border-radius: 8px;
  transition: background-color .12s ease, box-shadow .12s ease;
}
a.row-link { display: block; padding: 6px 8px; margin-left: -8px; margin-right: -8px; }
.is-clickable:hover, a.row-link:hover, .inv-row:hover {
  background: color-mix(in srgb, var(--text) 9%, transparent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--text) 9%, transparent);
}
table.grid tr.clickable:hover td, table.grid tbody tr:hover td { background: color-mix(in srgb, var(--text) 7%, transparent); }
.inv-row:hover { border-top-color: transparent; }
.card a[href]:not(.btn):not(.row-link):not(.task-row), .muted a[href]:not(.btn) { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; border-radius: 4px; }
.card a[href]:not(.btn):not(.row-link):not(.task-row):hover, .muted a[href]:not(.btn):hover { background: color-mix(in srgb, var(--text) 10%, transparent); text-decoration-color: currentColor; }
figure.is-clickable:hover, figure.q-photo:hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 25%, transparent); }

/* Active | Archived switch */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; flex: none; }
.seg button { background: var(--surface); border: 0; padding: 4px 12px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.seg button.on { background: var(--accent); color: #fff; }
.deal-card:hover { background: color-mix(in srgb, var(--text) 7%, var(--bg)); }

/* phone number + Call / Text */
.phone-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 8px; }
.phone-num { font-weight: 600; font-size: 15px; color: var(--text); }
.phone-line .btn { text-decoration: none; }

/* Pipeline deal search */
.deal-search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.deal-search { width: 100%; }
.deal-search-results { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; }
.deal-search-hit { margin: 0 !important; padding: 8px 10px !important; }
.nw { white-space: nowrap; }
/* task categories (tasks v2) */
.cat-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; color: var(--cat); border: 1px solid var(--cat); background: color-mix(in srgb, var(--cat) 10%, transparent); line-height: 1.5; vertical-align: 1px; }
.home-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.home-cat { margin: 10px 0 4px; }
.home-task { display: flex; gap: 8px; align-items: flex-start; padding: 7px 8px; border-left: 3px solid var(--cat); border-radius: 6px; background: var(--surface); margin: 4px 0; cursor: pointer; }
.home-task:hover { background: color-mix(in srgb, var(--cat) 7%, var(--surface)); }
.home-task input[type=checkbox] { margin-top: 3px; }
.emp-col .home-cat, .emp-col .home-task, .emp-col .empty { margin-left: 10px; margin-right: 10px; }
/* busy state for every modal's main button */
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-busy { opacity: .85; cursor: progress; }
.modal-slow { font-size: 12px; margin: 4px 0 0; }
/* Jobber history card */
.jh-stats { display: flex; flex-wrap: wrap; gap: 18px; margin: 4px 0; }
.jh-stat b { display: block; font-size: 20px; }
.jh-stat b.bad { color: var(--bad, #b33); }
.jh-stat span { font-size: 12px; color: var(--text-dim); }

/* Prospecting swipe deck */
.deck { max-width: 560px; margin: 0 auto 22px; }
.deck-head { display: flex; align-items: center; margin-bottom: 10px; }
.deck-stage { position: relative; }
.deck-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: 0 6px 22px rgba(0,0,0,.12); touch-action: pan-y; user-select: none; cursor: grab; will-change: transform; }
.deck-card.editing { user-select: auto; cursor: default; }
.deck-card.sending { opacity: .7; }
.deck-behind { position: absolute; inset: 0; transform: scale(.95) translateY(12px); opacity: .6; z-index: 0; box-shadow: none; pointer-events: none; }
.deck-stage > .deck-card:not(.deck-behind) { z-index: 1; }
.deck-why { margin: 6px 0 2px; color: var(--text-dim); }
.deck-draft { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; max-height: 46vh; overflow-y: auto; }
.deck-subj { font-weight: 600; margin-bottom: 6px; }
.deck-body { white-space: pre-wrap; line-height: 1.45; }
.deck-card input, .deck-card textarea { width: 100%; margin: 4px 0 8px; }
.deck-stamp { position: absolute; top: 14px; padding: 2px 10px; font-weight: 800; font-size: 22px; letter-spacing: 2px; border: 3px solid; border-radius: 8px; opacity: 0; pointer-events: none; z-index: 2; }
.deck-stamp.yes { left: 14px; color: var(--good); transform: rotate(-12deg); }
.deck-stamp.no { right: 14px; color: var(--bad); transform: rotate(12deg); }
.deck-actions { display: flex; justify-content: center; gap: 22px; margin: 18px 0 6px; }
.deck-btn { width: 58px; height: 58px; border-radius: 50%; border: 2px solid; background: var(--surface); font-size: 26px; cursor: pointer; line-height: 1; }
.deck-btn.yes { color: var(--good); border-color: var(--good); }
.deck-btn.no { color: var(--bad); border-color: var(--bad); }
.deck-btn.edit { width: 46px; height: 46px; align-self: center; font-size: 20px; color: var(--text-dim); border-color: var(--border); }
.deck-hint { text-align: center; font-size: 12px; margin: 4px 0 0; }
/* ---- Inbox (texts) ---- */
.sms-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }
.sms-list { padding: 4px; max-height: 70vh; overflow-y: auto; }
.sms-thread { padding: 10px; border-radius: var(--radius-sm); cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.sms-thread:hover { background: var(--surface-2); }
.sms-thread.on { background: var(--accent-soft); }
.sms-thread-top { display: flex; align-items: center; gap: 6px; }
.sms-thread-top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sms-when { font-size: 11px; }
.sms-unread { background: var(--accent); color: #fff; }
.sms-snip { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sms-conv { display: flex; flex-direction: column; gap: 10px; min-height: 320px; }
.sms-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sms-log { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; padding: 4px 2px; }
.sms-msg { max-width: 80%; padding: 8px 12px; border-radius: 14px; display: flex; flex-direction: column; gap: 4px; }
.sms-msg.in { align-self: flex-start; background: var(--surface-2); }
.sms-msg.out { align-self: flex-end; background: var(--accent-soft); }
.sms-msg.draft { border: 1px dashed var(--warn); background: var(--surface); }
.sms-body { white-space: pre-wrap; word-break: break-word; }
.sms-meta { font-size: 11px; }
.sms-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sms-compose { display: flex; gap: 8px; align-items: flex-end; }
.sms-input { flex: 1; resize: vertical; min-height: 40px; }
@media (max-width: 760px) { .sms-wrap { grid-template-columns: 1fr; } .sms-msg { max-width: 92%; } }

/* authenticator step */
.mfa-qr { display: flex; justify-content: center; padding: 10px; background: #fff; border-radius: 8px; align-self: center; }
.mfa-qr img, .mfa-qr canvas { max-width: 100%; }
.mfa-key { display: block; word-break: break-all; font-size: 13px; letter-spacing: .5px; user-select: all; }
