/* CRM — builds on /shared/base.css. Brand colors arrive per site as --brand / --accent. */

/* ---------- brand in the chrome ---------- */
.logo-text { font-family: var(--font-display); font-size: 1.35rem; font-weight: 800; color: var(--ink); }
.sidebar .brand-logo { gap: 0.6rem; }
.sidebar .brand-logo.badge img { height: 64px; }
.sidebar .brand-logo.wide img { height: 40px; max-width: 150px; }
.app-tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 0.3rem 0.45rem 0.25rem;
  border-radius: 5px;
  background: var(--brand);
  color: var(--brand-ink);
}
.topbar .top-logo img { height: 34px; }
.topbar .top-logo.badge img { height: 40px; }
.me-link .avatar-chip { margin-right: 0.1rem; }
.me-link .grow { display: flex; flex-direction: column; line-height: 1.15; }
.me-link small { color: var(--ink-3); font-weight: 500; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-nav .nav-link { padding: 0.7rem 0.65rem; }

.avatar-chip {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font: 700 0.78rem/1 var(--font);
  letter-spacing: 0.02em;
}
.avatar-chip.sm { width: 24px; height: 24px; font-size: 0.66rem; }
.avatar-chip.xs { width: 18px; height: 18px; font-size: 0.55rem; }
.who { display: inline-flex; align-items: center; gap: 0.45rem; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background:
  linear-gradient(180deg, var(--brand) 0, var(--brand) 38vh, var(--bg) 38vh); }
.auth-card { width: min(440px, 100%); background: var(--panel); border-radius: var(--r-lg); border: 1px solid var(--line-soft); padding: clamp(1.25rem, 4vw, 2.25rem); box-shadow: var(--shadow-pop); }
.auth-brand { display: flex; justify-content: center; margin-bottom: 1rem; }
.auth-brand .logo-img { height: 76px; width: auto; max-width: 240px; object-fit: contain; }
.auth-brand.wide .logo-img { height: 52px; }
.auth-card h1 { font-size: 2rem; text-align: center; margin-bottom: 0.2rem; }
.auth-card .sub { text-align: center; color: var(--ink-3); margin-bottom: 1.25rem; }
.auth-card form { display: grid; gap: 0.9rem; }
.auth-alt { text-align: center; margin: 1.1rem 0 0; color: var(--ink-3); font-size: 0.9rem; }

/* ---------- small utilities ---------- */
.bad-text { color: var(--bad); }
.warn-text { color: var(--warn); }
.danger-text { color: var(--bad) !important; }
.break { overflow-wrap: anywhere; }
.link-btn { border: 0; background: none; padding: 0; font: 600 1em var(--font); color: var(--brand); cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.back { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--ink-3); text-decoration: none; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.6rem; }
.back svg { width: 16px; height: 16px; }
.back:hover { color: var(--brand); }
.fine { color: var(--ink-3); font-size: 0.84rem; max-width: 80ch; margin: 1rem 0 0; }
.callout { border-radius: var(--r-sm); padding: 0.75rem 0.9rem; background: var(--info-bg); color: var(--ink); }
.callout.ok { background: var(--ok-bg); }
.callout.warn { background: var(--warn-bg); }
.callout ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.panel-note { padding: 0.9rem 1.25rem; margin: 0; }
.small-empty { padding: 1.5rem 1rem; }
.small-empty p { margin-bottom: 0.75rem; }
.page-head .sub { max-width: 72ch; }

/* ---------- forms ---------- */
/* base.css styles typed inputs; these cover inputs without a type and month pickers. */
input:not([type]), input[type='month'] {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--ink);
  font: 400 1rem/1.35 var(--font);
}
input[type='file'] { font: 400 0.95rem var(--font); max-width: 100%; }
.record-form > .hint, .panel > .hint { font-size: 0.84rem; color: var(--ink-3); margin: 0.75rem 0 0; }
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
.fs { border: 0; margin: 0 0 1.4rem; padding: 0; min-width: 0; }
.fs:last-child { margin-bottom: 0.5rem; }
.fs legend { font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; padding: 0; margin-bottom: 0.7rem; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem 1rem; }
.form-grid.one { grid-template-columns: minmax(0, 1fr); }
.form-grid .wide { grid-column: 1 / -1; }
.field.bool { justify-content: center; }
.field .req { color: var(--bad); }
.affix { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
.affix:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.affix input { border: 0 !important; box-shadow: none !important; min-width: 0; flex: 1; background: transparent; }
.affix .pre, .affix .post { display: grid; place-items: center; padding: 0 0.6rem; color: var(--ink-3); font-weight: 600; font-size: 0.92rem; background: var(--sunk); }
.affix .pre { border-right: 1px solid var(--line-soft); border-radius: var(--r-sm) 0 0 var(--r-sm); }
.affix .post { border-left: 1px solid var(--line-soft); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.affix.tiny { display: inline-flex; width: 5.5rem; vertical-align: middle; }
.affix.tiny input { min-height: 32px; padding: 0.2rem 0.4rem; font-size: 0.92rem; text-align: right; }
output.computed { display: block; min-height: 42px; padding: 0.55rem 0.75rem; border-radius: var(--r-sm); background: var(--sunk); font-weight: 600; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; flex-wrap: wrap; padding-top: 1rem; margin-top: 0.5rem; border-top: 1px solid var(--line-soft); }
.form-actions .muted { margin-right: auto; }
.record-form { margin-bottom: 1rem; }
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.color-row { display: flex; gap: 0.5rem; }
.color-row input[type='color'] { width: 46px; min-height: 42px; padding: 3px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); flex: none; }
@media (max-width: 620px) { .form-grid, .two-up { grid-template-columns: minmax(0, 1fr); } }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 0.15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }
.switch input:disabled + span { opacity: 0.5; }

/* combobox */
.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 0.3rem; list-style: none; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop); max-height: 280px; overflow-y: auto;
}
.combo-list li { padding: 0.5rem 0.6rem; border-radius: var(--r-sm); cursor: pointer; display: flex; flex-direction: column; }
.combo-list li small { color: var(--ink-3); }
.combo-list li:hover, .combo-list li.active { background: var(--brand-soft); }
.combo-list li.none { color: var(--ink-3); cursor: default; }

/* ---------- toolbar + lists ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }
.toolbar select { width: auto; max-width: 15rem; min-height: 40px; }
.toolbar .search { position: relative; flex: 1 1 260px; max-width: 420px; }
.toolbar .search svg { position: absolute; left: 0.7rem; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--ink-4); pointer-events: none; }
.toolbar .search input { padding-left: 2.3rem; min-height: 40px; }
.check.toggle { align-items: center; font-size: 0.92rem; font-weight: 500; white-space: nowrap; }
.check.toggle input { margin-top: 0; }
.cell-title { font-weight: 600; text-decoration: none; color: var(--ink); }
.cell-title:hover { color: var(--brand); text-decoration: underline; }
.cell-sub { display: block; color: var(--ink-3); font-size: 0.84rem; }
.cell-sub.bad-text { color: var(--bad); font-weight: 600; }
.list-count { margin: 0.75rem 0 0; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin-top: 0.9rem; }
.pager .muted { margin-right: auto; }
table.data tr.row-low td { background: color-mix(in srgb, var(--warn-bg) 55%, #fff); }

@media (max-width: 620px) {
  .toolbar select { flex: 1 1 calc(50% - 0.6rem); max-width: none; }
  .toolbar .search { flex-basis: 100%; max-width: none; }
  table.rtable thead { display: none; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable tr { padding: 0.75rem 1rem; border-bottom: 1px solid var(--line-soft); }
  table.rtable tr:last-child { border-bottom: 0; }
  table.rtable td { padding: 0.12rem 0; border: 0; display: flex; gap: 0.75rem; justify-content: space-between; align-items: baseline; text-align: right; }
  table.rtable td:first-child { display: block; text-align: left; padding-bottom: 0.35rem; }
  table.rtable td:not(:first-child)::before { content: attr(data-label); color: var(--ink-3); font-size: 0.82rem; text-align: left; flex: none; }
  table.rtable td[data-label='']::before { content: none; }
  table.rtable td.num { text-align: right; }
}

/* ---------- KPIs + dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.kpi { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 1rem 1.1rem; min-width: 0; }
.kpi .value { font-family: var(--font-display); font-weight: 800; font-size: 2.15rem; line-height: 1; }
.kpi .label { color: var(--ink-3); font-size: 0.86rem; margin-top: 0.35rem; }
.kpi .hint { color: var(--ink-4); font-size: 0.78rem; margin-top: 0.15rem; }
@media (max-width: 520px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi .value { font-size: 1.8rem; } }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
@media (max-width: 980px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }

.stage-bars { list-style: none; margin: 0; padding: 0.4rem 0; }
.stage-bars a { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr) 2.5rem 4.5rem; gap: 0.75rem; align-items: center; padding: 0.42rem 1.25rem; text-decoration: none; color: var(--ink-2); }
.stage-bars a:hover { background: var(--sunk); }
.sb-label { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-bar { height: 10px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.sb-bar span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.stage-bars .won .sb-bar span { background: var(--ok); }
.stage-bars .lost .sb-bar span { background: var(--ink-4); }
.sb-count { text-align: right; font-weight: 700; color: var(--ink); }
.sb-value { text-align: right; color: var(--ink-3); font-size: 0.85rem; }
@media (max-width: 520px) { .stage-bars a { grid-template-columns: minmax(0, 1fr) 4.5rem 2rem; } .sb-value { display: none; } }

.feed { list-style: none; margin: 0; padding: 0.3rem 0; }
.feed li { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.6rem 1.25rem; }
.feed li + li { border-top: 1px solid var(--line-soft); }
.feed-icon { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--sunk); color: var(--ink-3); }
.feed-icon svg { width: 16px; height: 16px; }
.feed-icon.warn { background: var(--warn-bg); color: var(--warn); }
.feed a { font-weight: 600; text-decoration: none; }
.feed a:hover { text-decoration: underline; }
.leaders { list-style: none; margin: 0; padding: 0.3rem 0; }
.leaders li { display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 1.25rem; }
.leaders li + li { border-top: 1px solid var(--line-soft); }
.leaders .place { width: 1.4rem; font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; color: var(--ink-4); }
.leaders li:first-child .place { color: var(--accent); }

/* ---------- pipeline board (the one loud thing) ---------- */
.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 272px;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.15rem 0.15rem 1rem;
  margin: 0 calc(-1 * clamp(1rem, 3vw, 2.5rem));
  padding-left: clamp(1rem, 3vw, 2.5rem);
  padding-right: clamp(1rem, 3vw, 2.5rem);
  scroll-padding-left: clamp(1rem, 3vw, 2.5rem);
  align-items: start;
}
.col { background: var(--sunk); border: 1px solid var(--line-soft); border-radius: var(--r-md); display: flex; flex-direction: column; min-height: 220px; max-height: calc(100vh - 230px); }
.col.over { border-color: var(--brand); background: var(--brand-soft); }
.col-head { padding: 0.7rem 0.85rem 0.6rem; border-bottom: 1px solid var(--line-soft); }
.col-head h2 { font-size: 1rem; margin: 0 0 0.15rem; font-weight: 700; letter-spacing: 0.01em; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-figs { display: flex; align-items: baseline; gap: 0.6rem; }
.col-figs .count { font-family: var(--font-display); font-weight: 800; font-size: 2rem; line-height: 1; color: var(--ink); }
.col-figs .sum { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; color: var(--ink-3); }
.col.won .col-head { border-bottom-color: color-mix(in srgb, var(--ok) 30%, #fff); }
.col.won .col-figs .count { color: var(--ok); }
.col.lost { opacity: 0.85; }
.col.lost .col-figs .count { color: var(--ink-4); }
.col-body { padding: 0.55rem; display: flex; flex-direction: column; gap: 0.5rem; overflow-y: auto; flex: 1; min-height: 120px; }
.col-empty { margin: 0.4rem 0; padding: 1.2rem 0.5rem; text-align: center; font-size: 0.85rem; color: var(--ink-4); border: 1px dashed var(--line); border-radius: var(--r-sm); }
.col-more { font-size: 0.85rem; text-align: center; padding: 0.3rem; }
.deal {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--age, var(--line));
  border-radius: 8px;
  padding: 0.6rem 0.7rem 0.45rem 0.75rem;
  cursor: grab;
  box-shadow: 0 1px 0 rgba(23, 34, 49, 0.04);
}
.deal:hover { border-color: var(--line); border-left-color: var(--age, var(--line)); }
.deal.dragging { opacity: 0.45; cursor: grabbing; }
.deal.fresh { --age: var(--ok); }
.deal.aging { --age: #d99a1e; }
.deal.stale { --age: var(--bad); }
.deal.settled { --age: color-mix(in srgb, var(--ok) 55%, #fff); }
.deal-title { display: block; font-weight: 600; color: var(--ink); text-decoration: none; line-height: 1.25; overflow-wrap: anywhere; }
.deal-title:hover { color: var(--brand); text-decoration: underline; }
.deal-sub { color: var(--ink-3); font-size: 0.84rem; margin-top: 0.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.45rem; }
.deal-value { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: var(--ink); }
.deal-value small { font-family: var(--font); font-weight: 500; font-size: 0.75rem; color: var(--ink-3); margin-left: 1px; }
.deal-value.none { font-family: var(--font); font-size: 0.82rem; font-weight: 500; color: var(--ink-4); }
.deal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 0.3rem; padding-top: 0.3rem; border-top: 1px solid var(--line-soft); }
.deal-foot .age { font-size: 0.78rem; color: var(--ink-3); }
.deal.stale .deal-foot .age { color: var(--bad); font-weight: 600; }
.deal-foot .btn-sm { min-height: 26px; padding: 0.15rem 0.5rem; font-size: 0.8rem; }
@media (max-width: 860px) {
  .board { grid-auto-columns: 84vw; scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; max-height: none; }
}
.move-list { display: grid; gap: 0.4rem; }
.move-opt { display: flex; justify-content: space-between; align-items: center; text-align: left; padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); font: 600 0.98rem var(--font); color: var(--ink); cursor: pointer; }
.move-opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.move-opt.current { border-color: var(--brand); color: var(--brand); }
.move-opt.won { color: var(--ok); }
.move-opt.lost { color: var(--bad); }
.move-opt small { color: var(--ink-3); font-weight: 500; }

/* stage pills */
.stage-pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; background: var(--brand-soft); color: var(--brand); }
.stage-pill.won { background: var(--ok-bg); color: var(--ok); }
.stage-pill.customer { background: var(--ok); color: #fff; }
.stage-pill.lost { background: var(--sunk); color: var(--ink-3); }

/* ---------- lead detail ---------- */
.lead-head { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.lead-head h1 { margin: 0; overflow-wrap: anywhere; }
.lead-head .sub { margin: 0.3rem 0 0; color: var(--ink-3); }
.track-wrap { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.track { list-style: none; margin: 0; padding: 0 0 0.25rem; display: flex; gap: 3px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: thin; }
.track li { flex: 1 0 auto; }
.track button {
  width: 100%;
  min-height: 38px;
  padding: 0.35rem 0.7rem 0.35rem 1rem;
  border: 0;
  background: var(--panel);
  color: var(--ink-3);
  font: 600 0.84rem var(--font);
  white-space: nowrap;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%, 9px 50%);
}
.track li:first-child button { clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%); border-radius: var(--r-sm) 0 0 var(--r-sm); padding-left: 0.8rem; }
.track li:last-child button { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 9px 50%); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.track button:hover { background: var(--brand-soft); color: var(--brand); }
.track li.done button { background: color-mix(in srgb, var(--brand) 16%, #fff); color: var(--brand-deep); }
.track li.current button { background: var(--brand); color: var(--brand-ink); }
.track li.current.won button { background: var(--ok); color: #fff; }
.track.is-lost li button { opacity: 0.6; }
.lost-note { display: flex; align-items: center; gap: 0.5rem; color: var(--bad); font-weight: 600; white-space: nowrap; }
.lost-note svg { width: 18px; height: 18px; }
.lost-btn { color: var(--ink-3); white-space: nowrap; }
.lead-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.25rem; align-items: start; }
.lead-main .tabs { margin-bottom: 1rem; }
.lead-side { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 1rem; }
@media (max-width: 1080px) { .lead-grid { grid-template-columns: minmax(0, 1fr); } .lead-side { position: static; } }
.side-card { display: grid; gap: 0.55rem; padding: 1rem 1.15rem; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-size: 0.93rem; }
.kv > span:first-child { color: var(--ink-3); }
.kv select { width: auto; max-width: 60%; min-height: 34px; padding: 0.25rem 0.5rem; font-size: 0.92rem; }
.side-card .btn-ghost { justify-self: start; padding-left: 0; }
.portal-callout { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; border-left: 4px solid var(--brand); }
.lead-main > div > .panel + .panel, .lead-main .panel.flush { margin-bottom: 1rem; }

.note-form { padding: 0.9rem 1.15rem; border-bottom: 1px solid var(--line-soft); display: grid; gap: 0.5rem; }
.note-form textarea { min-height: 64px; }
.timeline { list-style: none; margin: 0; padding: 0.4rem 0; max-height: 520px; overflow-y: auto; }
.tl { display: flex; gap: 0.7rem; padding: 0.55rem 1.15rem; font-size: 0.92rem; }
.tl-icon { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--sunk); color: var(--ink-3); }
.tl-icon svg { width: 14px; height: 14px; }
.tl.tl-note .tl-icon { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 60%, #000); }
.tl.tl-stage .tl-icon { background: var(--brand-soft); color: var(--brand); }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--sunk); border-radius: 0 var(--r-md) var(--r-md) var(--r-md); padding: 0.5rem 0.7rem; margin-bottom: 0.2rem; }

/* tasks */
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.65rem 1.15rem; }
.task + .task { border-top: 1px solid var(--line-soft); }
.task-check { width: 20px; height: 20px; margin-top: 0.15rem; accent-color: var(--ok); flex: none; cursor: pointer; }
.task-title { border: 0; background: none; padding: 0; font: 500 0.98rem/1.3 var(--font); color: var(--ink); text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.task-title:hover { color: var(--brand); text-decoration: underline; }
.task.done .task-title { color: var(--ink-4); text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.8rem; margin-top: 0.2rem; font-size: 0.83rem; color: var(--ink-3); }
.task-meta a { color: var(--ink-2); }
.due { display: inline-flex; align-items: center; gap: 0.25rem; }
.due svg { width: 14px; height: 14px; }
.due.overdue { color: var(--bad); font-weight: 600; }
.due.today { color: var(--warn); font-weight: 600; }
.quick-task { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; padding: 0.8rem 1.15rem; border-top: 1px solid var(--line-soft); }
.quick-task input { min-height: 36px; font-size: 0.92rem; }
.quick-task input[type='text'] { grid-column: 1 / -1; }
.quick-task input[type='datetime-local'] { width: 100%; min-width: 0; }
.done-tasks { border-top: 1px solid var(--line-soft); }
.done-tasks summary { padding: 0.6rem 1.15rem; cursor: pointer; color: var(--ink-3); font-size: 0.9rem; }
.task-add { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1.25rem; }
.task-add .field { flex: 0 1 auto; }
.task-add .field.grow { flex: 1 1 260px; }
.task-add .ta-lead { flex: 1 1 220px; }
.task-add .form-error { flex-basis: 100%; }
.task-group { margin-bottom: 1.25rem; }
.task-group h2 { display: flex; align-items: baseline; gap: 0.5rem; font-size: 1.25rem; margin-bottom: 0.5rem; }
.task-group h2 .num { font-size: 1rem; color: var(--ink-3); font-weight: 600; }
.task-group.overdue h2 { color: var(--bad); }

/* ---------- savings calculator ---------- */
.savings { padding: 0; overflow: hidden; }
.calc { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
.calc-in { display: grid; gap: 0.9rem; align-content: start; padding: 1.25rem; border-right: 1px solid var(--line-soft); }
.calc-more summary { cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 0.92rem; }
.calc-more[open] summary { margin-bottom: 0.8rem; }
.calc-more .field + .field { margin-top: 0.8rem; }
.calc-out { padding: 1.25rem 1.5rem; display: grid; gap: 1rem; align-content: start; background: var(--sunk); }
.calc-out .label { display: block; color: var(--ink-3); font-size: 0.88rem; font-weight: 600; }
.rate-today .num { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; }
.saving .hero-num { display: block; font-family: var(--font-display); font-weight: 800; font-size: clamp(3rem, 2rem + 4vw, 4.6rem); line-height: 0.95; color: var(--brand); letter-spacing: -0.01em; }
.saving .per { display: block; color: var(--ink-2); font-size: 0.98rem; margin-top: 0.25rem; }
.compare { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.compare th { text-align: left; font-weight: 500; color: var(--ink-2); padding: 0.4rem 0; }
.compare td { text-align: right; font-weight: 600; padding: 0.4rem 0; }
.compare tr + tr th, .compare tr + tr td { border-top: 1px solid var(--line); }
.compare tr.pick th, .compare tr.pick td { color: var(--brand); }
.price-tag { display: inline-grid; grid-template-columns: 1fr 1fr; justify-self: start; border: 2px solid var(--ink); border-radius: 6px; background: #fff; overflow: hidden; }
.price-tag div { padding: 0.45rem 0.9rem; display: grid; }
.price-tag div + div { border-left: 2px dashed var(--ink); background: var(--accent-soft); }
.price-tag span { font-size: 0.72rem; font-weight: 600; color: var(--ink-3); }
.price-tag strong { font-family: var(--font-display); font-size: 1.45rem; line-height: 1.05; }
.savings .fine { padding: 0 1.25rem 1.25rem; margin-top: 0; }
.savings.has-result .saving .hero-num { animation: pop 0.35s ease-out; }
@keyframes pop { from { transform: translateY(3px); opacity: 0.6; } }
@media (max-width: 760px) { .calc { grid-template-columns: minmax(0, 1fr); } .calc-in { border-right: 0; border-bottom: 1px solid var(--line-soft); } }

/* ---------- quotes ---------- */
.quote-top { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: 1rem; }
.quote-top h3 { margin: 0 0 0.2rem; }
.quote-pick { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 0.9rem; }
.quote-lines td { vertical-align: top; }
.quote-lines input { min-height: 38px; }
.quote-lines .q-qty { width: 5.5rem; }
.quote-lines .q-price { width: 11rem; }
.quote-lines .q-total { width: 8rem; padding-top: 1.1rem; font-weight: 600; }
.quote-lines .q-del { width: 3rem; }
.quote-empty { padding: 1rem 0; margin: 0; }
.quote-sum { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: 1.5rem; margin-top: 1rem; align-items: start; }
.totals { margin: 0; display: grid; gap: 0.25rem; }
.totals div { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.35rem 0; }
.totals dt { color: var(--ink-2); display: flex; align-items: center; gap: 0.4rem; }
.totals dd { margin: 0; font-weight: 600; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 0.25rem; padding-top: 0.55rem; }
.totals .grand dt { font-weight: 700; color: var(--ink); }
.totals .grand dd { font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; }
@media (max-width: 620px) {
  .quote-sum { grid-template-columns: minmax(0, 1fr); }
  .quote-lines .q-qty, .quote-lines .q-price, .quote-lines .q-total, .quote-lines .q-del { width: 100%; padding-top: 0.15rem; }
  .quote-lines td input { max-width: 60%; }
  .quote-lines td .affix { max-width: 60%; }
  .quote-lines td:first-child input { max-width: none; }
  .quote-lines .q-del { text-align: right; }
}

/* printable quote sheet */
.sheet-preview { background: var(--sunk); border-radius: var(--r-md); padding: 1rem; }
.quote-sheet { background: #fff; color: #161a20; padding: 2.2rem 2.4rem; border: 1px solid var(--line); font-size: 0.95rem; }
.qs-head { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-start; padding-bottom: 1.2rem; border-bottom: 3px solid var(--brand); }
.qs-brand { display: grid; gap: 0.45rem; }
.qs-logo { height: 56px; width: auto; max-width: 220px; object-fit: contain; object-position: left; }
.qs-title { text-align: right; }
.qs-title h2 { font-size: 2.4rem; margin: 0 0 0.4rem; color: var(--brand); }
.qs-meta { display: grid; grid-template-columns: auto auto; gap: 0.1rem 0.9rem; font-size: 0.86rem; justify-content: end; }
.qs-meta span { color: #6a6f78; text-align: right; }
.qs-to { display: grid; gap: 0.1rem; padding: 1.1rem 0; }
.qs-to strong { font-size: 1.15rem; }
.qs-lines { width: 100%; border-collapse: collapse; }
.qs-lines th { text-align: left; font-size: 0.8rem; color: #6a6f78; font-weight: 600; padding: 0.5rem 0.4rem; border-bottom: 1px solid #c9ced6; }
.qs-lines td { padding: 0.6rem 0.4rem; border-bottom: 1px solid #e6e9ee; vertical-align: top; }
.qs-lines .num { text-align: right; white-space: nowrap; }
.qs-sku { display: block; color: #6a6f78; font-size: 0.8rem; }
.qs-totals { margin: 1rem 0 0 auto; width: min(320px, 100%); display: grid; gap: 0.2rem; }
.qs-totals div { display: flex; justify-content: space-between; padding: 0.3rem 0.4rem; }
.qs-totals dt { color: #3f4650; }
.qs-totals dd { margin: 0; font-weight: 600; }
.qs-totals .grand { border-top: 2px solid #161a20; margin-top: 0.2rem; padding-top: 0.5rem; }
.qs-totals .grand dd, .qs-totals .grand dt { font-weight: 800; font-size: 1.15rem; color: #161a20; }
.qs-notes { margin-top: 1.4rem; }
.qs-notes h4 { margin-bottom: 0.25rem; }
.qs-notes p { white-space: pre-wrap; }
.qs-terms { margin-top: 1.6rem; padding-top: 0.9rem; border-top: 1px solid #e6e9ee; color: #4b525c; font-size: 0.84rem; }
@media (max-width: 620px) { .quote-sheet { padding: 1.2rem; } .qs-head { flex-direction: column; } .qs-title { text-align: left; } .qs-meta { justify-content: start; } }
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  body.printing .quote-sheet { border: 0; padding: 0; }
  @page { margin: 14mm; }
}

/* ---------- portals ---------- */
.portal-group { margin-bottom: 1.5rem; }
.portal-group h2 { font-size: 1.2rem; margin-bottom: 0.6rem; color: var(--ink-2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.75rem; }
.tile { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 0.95rem; display: flex; flex-direction: column; gap: 0.6rem; }
.tile-main { display: flex; gap: 0.75rem; align-items: center; }
.tile-main h3 { font-family: var(--font); font-size: 1rem; font-weight: 600; margin: 0; line-height: 1.25; }
.tile-mark { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font: 800 1.2rem var(--font-display); }
.tile-tip { margin: 0; color: var(--ink-3); font-size: 0.86rem; }
.tile-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: auto; }

/* ---------- residuals + inventory ---------- */
.totals-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-md); margin-bottom: 1rem; }
.totals-strip div { padding: 0.8rem 1.1rem; display: grid; }
.totals-strip div + div { border-left: 1px solid var(--line-soft); }
.totals-strip .label { color: var(--ink-3); font-size: 0.84rem; }
.totals-strip strong { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; line-height: 1.1; }
.totals-strip .pay strong { color: var(--ok); }
@media (max-width: 620px) { .totals-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } .totals-strip div:nth-child(3) { border-left: 0; } .totals-strip div:nth-child(n + 3) { border-top: 1px solid var(--line-soft); } }
.pricing-note { display: flex; gap: 0.6rem; align-items: flex-start; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 0.7rem 0.9rem; margin-bottom: 1rem; font-size: 0.9rem; color: var(--ink-2); }
.pricing-note svg { width: 18px; height: 18px; flex: none; color: var(--brand); margin-top: 0.1rem; }
.prod { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.prod img, .prod-ph { width: 44px; height: 44px; flex: none; border-radius: 8px; object-fit: contain; background: var(--sunk); border: 1px solid var(--line-soft); }
.prod-ph { display: grid; place-items: center; color: var(--ink-4); }
.prod-ph svg { width: 20px; height: 20px; }
.calc-note { margin-top: 1rem; display: grid; gap: 0.4rem; }

/* ---------- admin ---------- */
.code-block { position: relative; }
.code-block pre { margin: 0; padding: 0.9rem 1rem; padding-right: 5.5rem; background: #141a22; color: #e6edf5; border-radius: var(--r-md); overflow-x: auto; font: 400 0.84rem/1.55 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.code-block .btn { position: absolute; top: 0.5rem; right: 0.5rem; --b-bg: #2a3442; --b-ink: #fff; --b-line: #3a4656; }
.code-block .btn:hover { --b-bg: #364254; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }
.stage-names { display: grid; gap: 0.6rem; }
.stage-names label { font-weight: 500; }
.hook-list { list-style: none; margin: 0; padding: 0; }
.hook-list li { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; padding: 0.8rem 0; }
.hook-list li + li { border-top: 1px solid var(--line-soft); }
.hook-list .chip-row { margin-top: 0.35rem; }
.panel.stack > h3 { margin: 0; }
.panel.stack + .panel, .panel + .panel.stack, .panel.flush + .panel.flush { margin-top: 1rem; }
.panel.stack .form-actions { margin-top: 0; }

@media print {
  .quote-top, .quote-pick, .form-actions { display: none !important; }
}
