/* ServicePro Budget Calculator — styles
   Chrome/ink tokens and the validated 3-slot categorical palette (light + dark). */

:root {
  color-scheme: light dark;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --bucket-online: #2a78d6;   /* categorical slot 1 (blue) */
  --bucket-offline: #1baf7a;  /* slot 2 (aqua) */
  --bucket-other: #eda100;    /* slot 3 (yellow) */
  --good: #006300;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --bucket-online: #3987e5;
    --bucket-offline: #199e70;
    --bucket-other: #c98500;
    --good: #0ca30c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Read-only replay (/b/<ref>): hide the interactive inputs + the in-results
   toggles (which would trigger a live recompute), show a static breakdown. */
body.readonly .inputs, body.readonly #leadsSection, body.readonly .footer-index { display: none; }
body.readonly .switch { display: none; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px; }

.site-header { padding: 40px 0 8px; }
.kicker {
  margin: 0 0 6px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent);
}
h1 { margin: 0 0 10px; font-size: clamp(26px, 4.5vw, 38px); line-height: 1.15; letter-spacing: -0.015em; }
.sub { margin: 0; max-width: 60ch; color: var(--ink-2); }

h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -0.01em; }
h3 { margin: 0; font-size: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 14px;
  padding: 22px;
  margin: 22px 0;
}

/* ---------- Inputs ---------- */
.field-stack { display: flex; flex-direction: column; gap: 24px; }
.inputs .narrow { max-width: 460px; }

.field > label, .field > .seg-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }

.money-input {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--page);
  padding: 10px 14px; font-size: 20px; font-weight: 600;
}
.money-input:focus-within { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.money-input.readonly { background: var(--surface); opacity: .7; pointer-events: none; }
.money-input span { color: var(--muted); }
.money-input input {
  border: 0; background: none; color: var(--ink);
  font: inherit; width: 100%; outline: none;
  font-variant-numeric: tabular-nums;
}

select {
  width: 100%; padding: 10px 12px; font: inherit;
  border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--page); color: var(--ink);
}
select.big-select {
  max-width: 460px;
  padding: 13px 14px;
  font-size: 18px; font-weight: 600;
}

/* Planning Mode panel */
.planning-panel {
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid var(--hairline); border-radius: 12px;
  background: var(--page);
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 26px;
  max-width: 640px;
}
@media (max-width: 640px) { .planning-panel { grid-template-columns: 1fr; } }
.planning-panel .span2 { grid-column: 1 / -1; }
.pfield > label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }

input.num-input {
  width: 110px; padding: 9px 12px; font: inherit; font-weight: 600;
  border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
input.num-input:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); }

.money-input.small-money { padding: 9px 12px; font-size: 16px; background: var(--surface); max-width: 220px; }

.planning-summary { margin: 0; font-size: 14px; color: var(--ink-2); }
.planning-summary strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Leads Required section */
.leads-summary { font-size: 14px; color: var(--ink-2); }
.leads-summary .leads-table {
  width: 100%; max-width: 460px; border-collapse: collapse; margin: 6px 0 0;
}
.leads-summary .leads-table td {
  padding: 8px 0; border-bottom: 1px dashed var(--hairline); font-size: 15px;
}
.leads-summary .leads-table td:last-child {
  text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink);
}
.leads-summary .leads-table tr:last-child td { border-bottom: 0; }
.leads-summary .leads-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* Custom growth panel */
.custom-panel {
  margin-top: 12px;
  padding: 14px 18px;
  border: 1px solid var(--hairline); border-radius: 12px;
  background: var(--page);
  max-width: 460px;
}
.custom-range { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.custom-range .range-sep { padding-bottom: 10px; color: var(--muted); font-size: 14px; }
.pct-input {
  display: flex; align-items: center; gap: 6px; width: 104px;
  border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--surface); padding: 9px 12px;
}
.pct-input input {
  border: 0; background: none; color: var(--ink);
  font: inherit; font-weight: 600; width: 100%; outline: none;
  font-variant-numeric: tabular-nums;
}
.pct-input span { color: var(--muted); }
.pct-input:focus-within { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); }

.segmented { display: flex; border: 1px solid var(--hairline); border-radius: 10px; overflow: hidden; background: var(--page); }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: 9px 6px;
  font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer;
  border-left: 1px solid var(--hairline);
}
.segmented label:first-child span { border-left: 0; }
.segmented input:checked + span { background: var(--accent); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.segmented.small { margin-top: 8px; }
.segmented.small span { padding: 6px 6px; font-size: 13px; }

.checks { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.check { display: grid; grid-template-columns: 22px 1fr; gap: 2px 10px; cursor: pointer; }
.check input { width: 17px; height: 17px; margin-top: 3px; accent-color: var(--accent); }
.check span { font-weight: 600; font-size: 14px; }
.check em { grid-column: 2; font-style: normal; font-size: 13px; color: var(--muted); }

/* ---------- Headline ---------- */
.recap { font-size: 14px; color: var(--muted); margin: 0 0 4px; }
.headline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 18px; }
.headline .big { font-size: clamp(34px, 6vw, 48px); font-weight: 700; letter-spacing: -0.02em; }
.headline .per { font-size: 16px; color: var(--ink-2); font-weight: 500; }
.range-line { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.range-line strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.note-list { margin: 14px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.note-list li {
  font-size: 14px; color: var(--ink-2);
  padding: 10px 12px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--page);
}
.note-list li strong { color: var(--ink); }

/* ---------- Bucket bar ---------- */
.bucket-bar { display: flex; gap: 2px; height: 34px; margin: 18px 0 12px; }
.bucket-bar .seg { border-radius: 2px; min-width: 6px; transition: flex-basis 0.35s ease; }
.bucket-bar .seg:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.bucket-bar .seg:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.seg.online { background: var(--bucket-online); }
.seg.offline { background: var(--bucket-offline); }
.seg.other { background: var(--bucket-other); }

.bucket-legend { display: flex; flex-wrap: wrap; gap: 8px 26px; margin: 0; padding: 0; list-style: none; }
.bucket-legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.bucket-legend .chip { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.bucket-legend .name { font-weight: 600; }
.bucket-legend .val { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- Groups & rows ---------- */
.group { border-top: 1px solid var(--hairline); padding: 14px 0 6px; }
.group:first-of-type { border-top: 0; }
.group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.group-head .amount { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.group-head .tag {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--hairline); border-radius: 99px; padding: 1px 8px;
}
.group-note { margin: 2px 0 6px; font-size: 13px; color: var(--muted); max-width: 68ch; }
.group-note.annual-note { font-weight: 600; font-size: 12.5px; margin-bottom: 2px; }

.collapsible { cursor: pointer; user-select: none; }
.collapsible .chevron {
  font-size: 10px; color: var(--muted); transition: transform .2s ease;
  display: inline-block; flex: none; position: relative; top: -1px;
}
.collapsible[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.rows.collapsed { display: none; }
.rows.expanded { display: block; }

.rows { margin: 6px 0 8px; padding: 0; list-style: none; }
.rows li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
  padding: 7px 0; font-size: 15px;
  border-top: 1px dashed var(--hairline);
}
.rows li > span:first-child { flex: none; }
.rows li:first-child { border-top: 0; }
.rows .amount { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rows .pct { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.rows li.ghost { color: var(--muted); }
.rows li.ghost .amount { color: var(--muted); }
.row-note { flex-basis: 100%; font-size: 13px; color: var(--muted); margin: -2px 0 2px; padding-left: 2px; }

.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; }

/* Tooltip */
.tip { position: relative; display: inline-flex; }
.tip > button {
  border: 1px solid var(--hairline); background: var(--page); color: var(--muted);
  border-radius: 99px; width: 18px; height: 18px; font-size: 11px; line-height: 1;
  cursor: pointer; padding: 0;
}
.tip .tipbox {
  display: none; position: absolute; z-index: 10; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  width: min(340px, 78vw);
  background: var(--ink); color: var(--page);
  font-size: 13px; line-height: 1.45; font-weight: 400;
  padding: 10px 12px; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.tip:hover .tipbox, .tip:focus-within .tipbox { display: block; }
@media (max-width: 560px) { .tip .tipbox { left: auto; right: -8px; transform: none; } }

/* ---------- Special cards ---------- */
.focus-card { border-color: var(--accent); }
.focus-card h2 { color: var(--accent); }

/* Closing CTA card under the full breakdown */
.cta-card { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.cta-card h2 { color: var(--accent); }
/* .cta-card scope raises specificity above the later `.btn { width: 100% }`. */
.cta-card .cta-btn { display: inline-block; width: auto; margin-top: 14px; text-decoration: none; }

/* Unlock (email gate) teaser card: readable line items with the dollar amounts
   blurred, behind a compact unlock box. Labels tease the structure; amounts
   (the gated part) stay hidden. */
.locked-teaser { position: relative; overflow: hidden; padding: 0; min-height: 420px; }
.teaser-preview { padding: 22px; pointer-events: none; user-select: none; }
.teaser-tag {
  display: inline-block; margin-bottom: 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--hairline); border-radius: 99px; padding: 2px 9px;
}
.teaser-preview .t-group { border-top: 1px solid var(--hairline); padding: 12px 0; }
.teaser-preview .t-group:first-child { border-top: 0; }
.teaser-preview h3 { margin: 0; font-size: 16px; }
.teaser-preview .group-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.teaser-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 15px; }
.teaser-row .t-label { color: var(--ink); }
/* Only the amounts are hidden. */
.t-amt {
  margin-left: auto; filter: blur(5px); opacity: 0.7; user-select: none;
  font-variant-numeric: tabular-nums; color: var(--ink-2);
}
.t-amt.t-total { font-weight: 700; color: var(--ink); }

.teaser-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(130% 80% at 50% 50%, color-mix(in srgb, var(--surface) 35%, transparent), transparent 70%);
}
.unlock-box {
  width: 100%; max-width: 360px; text-align: left;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 14px;
  padding: 20px 22px; box-shadow: 0 14px 44px rgba(0, 0, 0, 0.22);
}
.unlock-box h3 { margin: 0 0 6px; font-size: 18px; color: var(--accent); }
.unlock-box .unlock-note { margin: 0; font-size: 13.5px; color: var(--ink-2); overflow-wrap: break-word; }

.lock-form { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.lock-form input {
  width: 100%; padding: 10px 12px; font: inherit;
  border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--page); color: var(--ink);
}
.lock-form input:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.btn {
  width: 100%; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  /* Darker than --accent on purpose: white on #1e63c0 is 5.8:1 (WCAG AA);
     white on the accent blues is 3.6–4.4:1 and fails at body size. */
  border: 0; border-radius: 10px; background: #1e63c0; color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.6; cursor: default; }
.unlock-box .hint { margin-top: 10px; }
.unlock-box .hint a { color: var(--accent); text-decoration: none; }
.unlock-box .hint a:hover { text-decoration: underline; }
#lockCode { letter-spacing: 4px; font-variant-numeric: tabular-nums; }

.caution {
  margin: 10px 0 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--bucket-other) 55%, transparent);
  background: color-mix(in srgb, var(--bucket-other) 10%, transparent);
  font-size: 14px; color: var(--ink-2);
}

/* Admin dashboard table */
.admin-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--hairline); vertical-align: top; white-space: nowrap; }
.admin-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.admin-table td.num, .admin-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.admin-table th.sortable { cursor: pointer; user-select: none; }
.admin-table th.sortable:hover { color: var(--ink); }
.admin-table th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.link-btn:hover { color: #b91c1c; background: color-mix(in srgb, #b91c1c 10%, transparent); }
.admin-table a { color: var(--accent); text-decoration: none; font-variant-numeric: tabular-nums; }
.admin-table a:hover { text-decoration: underline; }

.footer-index dl { margin: 0; }
.footer-index dt { font-weight: 600; font-size: 14px; margin-top: 10px; }
.footer-index dd { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); }

.fine { font-size: 12.5px; color: var(--muted); margin: 26px 0 44px; max-width: 78ch; }

/* Account widget (header) + My Plans modal + save/share toolbar */
.kicker-row { display: flex; align-items: baseline; gap: 12px; }
.account { margin: 0 0 6px auto; font-size: 13.5px; color: var(--muted); }
.account a { color: var(--accent); text-decoration: none; font-weight: 600; }
.account a:hover { text-decoration: underline; }

/* Modal overlay + card */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 20px;
  overflow-y: auto;
  animation: fadeIn 0.15s ease-out;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 460px;
  background: var(--surface); border-radius: 16px;
  padding: 28px 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  position: relative;
  animation: slideUp 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 520px) {
  .modal-overlay { padding: 12px; align-items: flex-start; padding-top: 10vh; }
  .modal-card { padding: 22px 18px; border-radius: 14px; }
}

.plans-list { list-style: none; margin: 0; padding: 0; }
.plan-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--hairline); font-size: 14px;
}
.plan-row:last-child { border-bottom: 0; }
.plan-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.plan-actions a { color: var(--accent); text-decoration: none; font-size: 14px; }
.plan-actions a:hover { text-decoration: underline; }
.plan-actions .link-btn { color: var(--accent); }
.plan-actions .link-btn[data-plan-del] { color: var(--muted); }
#plansPanel .group-head { display: flex; align-items: baseline; gap: 12px; }
#plansPanel .group-head a { color: var(--muted); text-decoration: none; font-size: 13.5px; }
#loginPanel .lock-form { max-width: 340px; display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.btn.tb-btn { width: auto; padding: 9px 14px; font-size: 14px; }

/* Admin: tab nav, type badges, clients screen */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button {
  border: 1px solid var(--hairline); background: var(--page); color: var(--ink);
  padding: 8px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--ink-2);
}
.badge.client { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.client-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; max-width: 720px; }
.client-form .span2 { grid-column: 1 / -1; }
.client-form label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.client-form input, .client-form textarea {
  width: 100%; box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--hairline);
  border-radius: 10px; background: var(--page); color: var(--ink); font: inherit; font-size: 14px;
}
.attach-select {
  padding: 4px 6px; border: 1px solid var(--hairline); border-radius: 8px;
  background: var(--page); color: var(--ink); font-size: 13px; max-width: 140px;
}
.status-select {
  padding: 4px 6px; border: 1px solid var(--hairline); border-radius: 8px;
  background: var(--page); color: var(--ink); font-size: 13px; width: 105px;
}
.detail-panel {
  padding: 14px 18px; background: color-mix(in srgb, var(--accent) 4%, var(--surface));
  border-bottom: 2px solid var(--hairline); font-size: 14px;
}
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 14px 18px;
}
.detail-grid dl { margin: 0; }
.detail-grid dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0; }
.detail-grid dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.archive-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.archive-toggle input { margin: 0; }
@media (max-width: 640px) { .client-form { grid-template-columns: 1fr; } }

@media print {
  .site-header, .inputs, .footer-index { break-inside: avoid; }
  .tip > button { display: none; }
  body { background: #fff; }
  /* Expand every detail section so a printed plan carries all line items,
     even the ones the reader never manually opened (e.g. a /b/<ref> share). */
  .rows.collapsed { display: block; }
  .collapsible .chevron { display: none; }
}
