/* Door Leads — phone-first, one-thumb UI. Colors follow the michael-sales site (ink + aqua on paper). */
:root {
  color-scheme: light;
  --paper: #f7f5f0; --surface: #ffffff; --surface-2: #efece4;
  --ink: #0b2540; --ink-2: #36506b; --muted: #5f7286;
  --aqua: #2bb3bd; --aqua-ink: #04202b; --aqua-soft: #d6f1f2;
  --line: rgba(11, 37, 64, .12); --line-2: rgba(11, 37, 64, .22);
  --err: #c0392b; --ok: #1b7f4b;
  --s1: #2a78d6; --s2: #eb6834; --grid: rgba(11, 37, 64, .08);
  /* status: new, appointment, demo, sold, not sold */
  --st-new: #5f7286; --st-appt: #2a78d6; --st-demo: #6250d6; --st-sold: #1b7f4b; --st-notsold: #a14a3b;
  --hot: #c2410c; --warm: #b7791f; --cold: #2a78d6; --none: #5f7286;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px; --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0a1724; --surface: #11233a; --surface-2: #17304b;
    --ink: #eaf1f7; --ink-2: #c3d2e0; --muted: #93a7ba;
    --aqua: #38c3cd; --aqua-ink: #04202b; --aqua-soft: #12414a;
    --line: rgba(234, 241, 247, .12); --line-2: rgba(234, 241, 247, .24);
    --err: #ff7a6b; --ok: #4cc38a;
    --s1: #3987e5; --s2: #d95926; --grid: rgba(234, 241, 247, .08);
    --st-new: #93a7ba; --st-appt: #5598e7; --st-demo: #9085e9; --st-sold: #4cc38a; --st-notsold: #e88a7a;
    --hot: #f2884e; --warm: #e0b14f; --cold: #5598e7; --none: #93a7ba;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0a1724; --surface: #11233a; --surface-2: #17304b;
  --ink: #eaf1f7; --ink-2: #c3d2e0; --muted: #93a7ba;
  --aqua: #38c3cd; --aqua-ink: #04202b; --aqua-soft: #12414a;
  --line: rgba(234, 241, 247, .12); --line-2: rgba(234, 241, 247, .24);
  --err: #ff7a6b; --ok: #4cc38a;
  --s1: #3987e5; --s2: #d95926; --grid: rgba(234, 241, 247, .08);
  --st-new: #93a7ba; --st-appt: #5598e7; --st-demo: #9085e9; --st-sold: #4cc38a; --st-notsold: #e88a7a;
  --hot: #f2884e; --warm: #e0b14f; --cold: #5598e7; --none: #93a7ba;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--sans); min-height: 100svh; overflow-x: clip; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--aqua); outline-offset: 2px; border-radius: 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 24px 0; }
.err { color: var(--err); font-size: 14px; min-height: 1.2em; }
.err:empty { min-height: 0; }

/* splash */
.splash { min-height: 100svh; display: grid; place-items: center; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--aqua); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 999px; border: 0; font-weight: 600; text-decoration: none; cursor: pointer; background: var(--surface-2); color: var(--ink); transition: transform .15s, background .15s, opacity .15s; touch-action: manipulation; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--aqua); color: var(--aqua-ink); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn.link { background: none; min-height: 40px; padding: 0 4px; color: var(--ink-2); font-weight: 600; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.danger-ghost { background: none; color: var(--err); box-shadow: inset 0 0 0 1.5px currentColor; margin-top: 8px; }
.btn.busy { opacity: .6; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: none; border-radius: 50%; cursor: pointer; color: inherit; }

/* auth */
.auth { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px 22px; display: grid; gap: 16px; box-shadow: 0 20px 50px -30px rgba(11, 37, 64, .45); }
.auth-card h1 { font-size: 26px; letter-spacing: -.02em; }
.auth-card form { display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.code-input { font-size: 28px !important; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.steps { padding-left: 20px; display: grid; gap: 14px; }
.steps li > * { margin-top: 8px; }
.qr { width: 200px; max-width: 100%; background: #fff; padding: 6px; border-radius: 10px; }
.qr:empty { display: none; }
.qr svg { width: 100%; height: auto; }
.secret { display: block; font-size: 15px; word-break: break-all; background: var(--surface-2); padding: 10px; border-radius: 8px; margin-top: 6px; user-select: all; }
details summary { cursor: pointer; color: var(--ink-2); font-weight: 600; font-size: 14px; }

/* chrome */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: calc(6px + var(--safe-t)) 8px 6px 16px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .title { font-weight: 700; font-size: 18px; flex: 1; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sync svg { width: 16px; height: 16px; }
.sync.off { color: var(--err); }
.view { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(var(--tabs-h) + 32px + var(--safe-b)); outline: none; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr); height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--line); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.tabs a.active { color: var(--ink); }
.tabs a.active svg { color: var(--aqua); }

/* form */
.lead-form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; border: 0; min-width: 0; }
.field > span, .field > legend, .label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field em { font-style: normal; font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
input:not([type=radio]):not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); font-size: 17px; appearance: none; -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--aqua); box-shadow: 0 0 0 3px color-mix(in srgb, var(--aqua) 25%, transparent); }
input[type=datetime-local], input[type=date] { min-width: 0; }
textarea { resize: vertical; min-height: 96px; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.field-group { display: grid; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 input[name=zip] { max-width: none; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg .opt { flex: 1 1 auto; position: relative; }
.seg .opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg .opt span, .seg button.opt { display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 12px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: 15px; white-space: nowrap; cursor: pointer; }
.seg .opt input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.seg .opt input:focus-visible + span { outline: 3px solid var(--aqua); outline-offset: 2px; }
.seg .i-hot input:checked + span { background: var(--hot); border-color: var(--hot); color: #fff; }
.seg .i-warm input:checked + span { background: var(--warm); border-color: var(--warm); color: #fff; }
.seg .i-cold input:checked + span { background: var(--cold); border-color: var(--cold); color: #fff; }
/* house number: 3 suggestions + "Other" box */
.house { display: grid; grid-template-columns: 3fr 1fr; gap: 6px; }
.house.idle { grid-template-columns: 1fr; }
.house.idle .hn-opts { display: none; }
.hn-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.hn-opt { position: relative; min-width: 0; }
.hn-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.hn-opt span { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 54px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.hn-opt span small { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hn-opt input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.hn-opt input:checked + span small { color: var(--aqua); }
.hn-opt input:focus-visible + span { outline: 3px solid var(--aqua); outline-offset: 2px; }
.house #hn-other { min-height: 54px; text-align: center; font-weight: 700; font-size: 19px; padding: 8px 4px; }
.house.idle #hn-other { text-align: left; padding: 12px 14px; font-weight: 400; font-size: 17px; }
.house:not(.idle) #hn-other.on { background: var(--ink); color: var(--paper); border-color: var(--ink); caret-color: var(--aqua); }
.house:not(.idle) #hn-other.on:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--aqua) 35%, transparent); }
.hn-skel { height: 54px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
#hn-status:empty { display: none; }
.money { position: relative; }
.money span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money input { padding-left: 28px !important; }
.actions.sticky { position: sticky; bottom: calc(var(--tabs-h) + var(--safe-b) + 8px); z-index: 5; padding-top: 4px; }
.actions.sticky .btn { box-shadow: 0 12px 30px -12px rgba(11, 37, 64, .5); }
.meta { text-align: center; }
.detail-head { margin: -8px 0 8px -4px; }

/* status */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.status-card { display: grid; gap: 12px; }
.status-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn.chip { min-height: 46px; border-radius: 12px; background: var(--surface-2); font-size: 15px; }
.btn.chip.on { color: #fff; }
.btn.chip.s-appt.on { background: var(--st-appt); }
.btn.chip.s-demo.on { background: var(--st-demo); }
.btn.chip.s-sold.on { background: var(--st-sold); }
.btn.chip.s-notsold.on { background: var(--st-notsold); }
.sale { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; color: #fff; background: var(--st-new); }
.pill.s-appt { background: var(--st-appt); } .pill.s-demo { background: var(--st-demo); }
.pill.s-sold { background: var(--st-sold); } .pill.s-notsold { background: var(--st-notsold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill, :root:not([data-theme="light"]) .btn.chip.on { color: #04121f; } }
:root[data-theme="dark"] .pill, :root[data-theme="dark"] .btn.chip.on { color: #04121f; }
.quick { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }

/* photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.photos:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-open { all: unset; display: block; width: 100%; height: 100%; cursor: pointer; }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; }
.thumb-x svg { width: 16px; height: 16px; }
.btn.file { cursor: pointer; }
.viewer { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100svh; margin: auto; }
.viewer::backdrop { background: rgba(0, 0, 0, .9); }
.viewer img { max-width: 100vw; max-height: 100svh; object-fit: contain; display: block; }
.viewer .close { position: fixed; top: calc(8px + var(--safe-t)); right: 8px; color: #fff; background: rgba(0, 0, 0, .5); }

/* leads list */
.list-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 44px !important; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; margin: 0 -16px; padding-inline: 16px; }
.filters::-webkit-scrollbar { display: none; }
.filters select { width: auto; min-height: 42px; font-size: 15px; padding: 8px 32px 8px 12px; flex: none; border-radius: 999px; }
.chip-toggle { position: relative; flex: none; }
.chip-toggle input { position: absolute; opacity: 0; inset: 0; }
.chip-toggle span { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--surface); font-size: 15px; font-weight: 600; white-space: nowrap; }
.chip-toggle span svg { width: 18px; height: 18px; }
.chip-toggle input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.range .row2 { margin-top: 8px; }
.cards { list-style: none; display: grid; gap: 10px; }
.lead-card { display: flex; align-items: stretch; padding: 0; overflow: hidden; }
.lead-link { flex: 1; min-width: 0; padding: 14px 12px 12px 16px; text-decoration: none; display: grid; gap: 4px; }
.lead-name { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.tag svg { width: 14px; height: 14px; }
.tag.i-hot { color: var(--hot); } .tag.i-warm { color: var(--warm); } .tag.i-cold { color: var(--cold); }
.when { margin-left: auto; }
.call { display: grid; place-items: center; width: 60px; flex: none; border-left: 1px solid var(--line); color: var(--ok); text-decoration: none; }
.empty { text-align: center; padding: 40px 16px; display: grid; gap: 12px; justify-items: center; }

/* stats */
.period { margin-bottom: 14px; flex-wrap: nowrap; }
.period .opt { flex: 1 1 0; min-width: 0; font-size: 13px; padding: 0 4px; }
.period .opt.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
#stats-body { display: grid; gap: 12px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tiles .tile.wide { grid-column: 1 / -1; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 2px; }
.tiles.flat .tile { background: var(--surface-2); border: 0; }
.tile-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.card h2 { font-size: 17px; }
.chart-card { display: grid; gap: 6px; }
.chart { position: relative; margin-top: 6px; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--s1); }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.s1 { fill: var(--s1); }
.chart .bar.s1 { fill: var(--s1); } .chart .bar.s2 { fill: var(--s2); }
.chart .cross { stroke: var(--line-2); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart g.dim .bar { opacity: .35; }
.tip { position: absolute; z-index: 3; pointer-events: none; background: var(--ink); color: var(--paper); font-size: 13px; line-height: 1.35; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.tip .muted { color: color-mix(in srgb, var(--paper) 70%, transparent); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); }
.hbars { list-style: none; display: grid; gap: 10px; margin-top: 6px; }
.bar-track { height: 10px; border-radius: 4px; background: var(--surface-2); margin-top: 4px; overflow: hidden; }
.hbars .bar { height: 100%; background: var(--s1); border-radius: 4px; min-width: 2px; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.table-view th, .table-view td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.table-view td:last-child, .table-view th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.recount { display: grid; justify-items: center; gap: 2px; margin-top: 18px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 84px); transform: translate(-50%, 12px); opacity: 0; z-index: 50; max-width: calc(100vw - 32px); width: max-content; background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; font-size: 15px; font-weight: 500; transition: opacity .2s, transform .2s; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok::before { content: "✓ "; color: var(--aqua); font-weight: 700; }
.toast.err { background: var(--err); color: #fff; }

@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tiles.two { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}
