/* SB Clients - one stylesheet, phone first. Colours are set once here, per theme.
   The theme is picked under More and kept on the device (see theme.js). */
/* Light (also what shows if the theme script can't run) */
:root {
  --ink: #16222e; --soft: #5d6f7c; --line: #d9e0e7; --bg: #f4f6f9; --card: #fff;
  --brand: #1f5fa8; --brand-ink: #fff; --accent: #7fb2e5; --link: #1f5fa8;
  --top-bg: #16324f; --top-ink: #fff; --top-line: transparent; --top-btn: rgba(255,255,255,.4); --bar-bg: #fff;
  --good: #1f7a4d; --good-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fdf0d2; --bad: #a12b2b; --bad-bg: #fbe4e4;
  --r: 12px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Dark */
html[data-theme="dark"] {
  --ink: #e8eef2; --soft: #9fb0bc; --line: #2c3b47; --bg: #101920; --card: #18242d;
  --brand: #2b6cb8; --link: #8fc0ee; --top-bg: #16324f; --bar-bg: #18242d;
  --good-bg: #173d2a; --good: #7fd6a4; --warn-bg: #45360f; --warn: #f1cf7a; --bad-bg: #4a1f1f; --bad: #f3a3a3;
  color-scheme: dark;
}
/* iPhone: looks like the phone's own apps and follows the phone's light or dark setting */
html[data-theme="iphone"] {
  --ink: #000; --soft: #6c6c70; --line: #d9d9de; --bg: #f2f2f7; --card: #fff;
  --brand: #007aff; --brand-ink: #fff; --accent: #ff9500; --link: #0066d6;
  --top-bg: rgba(249,249,249,.88); --top-ink: #000; --top-line: #d1d1d6; --top-btn: transparent; --bar-bg: rgba(249,249,249,.88);
  --good: #1d7a36; --good-bg: #e1f6e6; --warn: #8a5300; --warn-bg: #fff1d6; --bad: #c5221c; --bad-bg: #ffe5e3;
  --r: 14px; --font: -apple-system, "SF Pro Text", system-ui, "Helvetica Neue", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="iphone"] {
    --ink: #fff; --soft: #a1a1a8; --line: #38383a; --bg: #000; --card: #1c1c1e;
    --brand: #0a84ff; --accent: #ff9f0a; --link: #4da3ff;
    --top-bg: rgba(22,22,24,.88); --top-ink: #fff; --top-line: #38383a; --bar-bg: rgba(22,22,24,.88);
    --good: #30d158; --good-bg: #12351d; --warn: #ffd60a; --warn-bg: #3d3200; --bad: #ff6961; --bad-bg: #481a17;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 var(--font); color: var(--ink); background: var(--bg); padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
a { color: var(--link); text-decoration: none; }
h1 { font-size: 1.5rem; margin: .2rem 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--soft); margin: 1rem 0 .3rem; }
p { margin: .5rem 0; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; background: var(--top-bg); color: var(--top-ink); border-bottom: 1px solid var(--top-line); padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem; }
.top a { color: var(--top-ink) !important; }
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .55rem; }
.brand::before { content: ""; width: 28px; height: 28px; border-radius: 7px; background: url(/icon-192.png) center / cover; box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.top-btn { font-size: .9rem; border: 1px solid var(--top-btn); border-radius: 99px; padding: .25rem .8rem; }
main { max-width: 760px; margin: 0 auto; padding: 1rem; outline: none; }
main.view-pipeline { max-width: none; }
.loading, .empty { color: var(--soft); padding: .6rem 0; }
.sub { color: var(--soft); font-size: .88rem; }
.lead { margin-top: 0; }
.strong { font-weight: 600; color: var(--ink) !important; }
.late { color: var(--bad); font-weight: 600; }
.grow { flex: 1; min-width: 0; }
.block { display: block; }
.right { text-align: right; white-space: nowrap; }
code { font-size: .85em; word-break: break-all; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--bar-bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: .45rem 0 .5rem; font-size: .7rem; color: var(--soft) !important; }
.tabs .ico { display: block; font-size: 1.25rem; line-height: 1.3; }
.tabs a.on { color: var(--link) !important; font-weight: 700; }

section { margin-top: 1.5rem; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem .9rem; margin-bottom: .6rem; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: var(--r); padding: .7rem .9rem; margin: .8rem 0; font-size: .92rem; }
.notice a, .notice .link { color: inherit !important; text-decoration: underline; }
.hint { color: var(--soft); font-size: .85rem; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 1rem 0 0; }
.tiles div { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .6rem .3rem; text-align: center; font-size: .75rem; color: var(--soft); }
.tiles b { display: block; font-size: 1.5rem; color: var(--ink); line-height: 1.2; }

.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list.plain { border: 0; }
.row { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .9rem; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.done .strong { text-decoration: line-through; color: var(--soft) !important; }
.check { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--soft); background: none; color: var(--good); font-size: 1rem; font-weight: 700; padding: 0; cursor: pointer; }
.row.done .check { border-color: var(--good); background: var(--good-bg); }
details { margin-top: .5rem; }
summary { color: var(--soft); font-size: .9rem; padding: .4rem 0; cursor: pointer; }

.btn, .chip, .link { font: inherit; cursor: pointer; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--ink) !important; border-radius: 10px; padding: .55rem .9rem; font-weight: 600; font-size: .92rem; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink) !important; }
.btn.danger { color: var(--bad) !important; border-color: var(--bad); background: none; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn.wide { width: 100%; padding: .75rem; }
.btn:disabled { opacity: .5; }
.link { border: 0; background: none; padding: 0; color: var(--link); text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .45rem 0 0; align-items: center; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .3rem; margin-bottom: .4rem; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink) !important; border-radius: 99px; padding: .25rem .75rem; font-size: .85rem; white-space: nowrap; }
.chip.solid { background: var(--brand); border-color: var(--brand); color: var(--brand-ink) !important; }
.badge { flex: none; font-size: .72rem; font-weight: 700; border-radius: 99px; padding: .15rem .6rem; background: var(--line); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.birthday { background: var(--accent); color: #2b1a10; } .badge.home { background: var(--brand); color: #fff; }
.count { font-size: .75rem; font-weight: 700; background: var(--line); border-radius: 99px; padding: .05rem .5rem; vertical-align: middle; }
.count.late { background: var(--bad-bg); color: var(--bad); }

.board { display: flex; gap: .7rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 1rem; margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; }
.col { flex: none; width: 82vw; max-width: 320px; scroll-snap-align: center; }
.col-head { display: flex; align-items: center; gap: .4rem; padding: .5rem .2rem; border-bottom: 3px solid var(--brand); margin-bottom: .6rem; }
.col-head.offer { border-color: var(--accent); } .col-head.closed { border-color: var(--good); } .col-head.lost { border-color: var(--soft); }
.deal .move { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; font-size: .8rem; color: var(--soft); }
.deal select { flex: 1; }
@media (min-width: 900px) { .col { width: 19%; max-width: none; flex: 1; } .board { margin: 0; padding-left: 0; padding-right: 0; } }

.facts { display: grid; grid-template-columns: auto 1fr; gap: .25rem .9rem; margin: .9rem 0; font-size: .93rem; }
.facts dt { color: var(--soft); } .facts dd { margin: 0; }
.consent .sub { margin-top: .35rem; }
.timeline { list-style: none; margin: .6rem 0 0; padding: 0; }
.timeline li { border-left: 3px solid var(--brand); padding: .1rem 0 .1rem .7rem; margin-bottom: .8rem; }
.timeline li.system { border-color: var(--line); }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .65rem; width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
.search { display: flex; gap: .4rem; margin: .5rem 0; }
.note-form select { width: auto; }
.field { display: block; margin-bottom: .7rem; }
.field span { display: block; font-size: .82rem; color: var(--soft); margin-bottom: .2rem; }
.field small { color: var(--soft); font-size: .78rem; }
.check-field { display: flex; gap: .5rem; align-items: center; }
.bday { display: grid; grid-template-columns: 1.2fr .8fr 1.4fr; gap: .4rem; }
.err { color: var(--bad); font-weight: 600; }
@media (min-width: 520px) { .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; } .fields .field { grid-column: 1 / -1; } .fields .field.half { grid-column: auto; } }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { background: var(--bg); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
.sheet-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .7rem; }
.sheet-card footer { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; }
.x { border: 0; background: none; font-size: 1.8rem; line-height: 1; color: var(--soft); cursor: pointer; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 18px; } }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: #1c2b36; color: #fff; padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; max-width: 90vw; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.login { max-width: 320px; margin: 12vh auto 0; text-align: center; }
.login img { border-radius: 16px; }
.login .field { text-align: left; }

/* iPhone theme: the touches that make it feel like the phone's own apps */
html[data-theme="iphone"] .top, html[data-theme="iphone"] .tabs { -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
html[data-theme="iphone"] .brand { font-size: 1.1rem; letter-spacing: -.01em; }
html[data-theme="iphone"] .top-btn { color: var(--link) !important; padding-right: 0; font-size: 1rem; }
html[data-theme="iphone"] h1 { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; }
html[data-theme="iphone"] h3 { font-weight: 400; }
html[data-theme="iphone"] .card, html[data-theme="iphone"] .list, html[data-theme="iphone"] .tiles div { border-color: transparent; }
html[data-theme="iphone"] .list.plain { background: none; }
html[data-theme="iphone"] .btn { border-color: transparent; background: rgba(120,120,128,.16); color: var(--link) !important; border-radius: 12px; }
html[data-theme="iphone"] .card .btn, html[data-theme="iphone"] .sec-head .btn { background: rgba(120,120,128,.14); }
html[data-theme="iphone"] .btn.primary { background: var(--brand); color: #fff !important; }
html[data-theme="iphone"] .btn.danger { color: var(--bad) !important; }
html[data-theme="iphone"] .chip { border-color: transparent; background: rgba(120,120,128,.16); }
html[data-theme="iphone"] .chip.solid { background: var(--brand); }
html[data-theme="iphone"] .badge.home { background: #5856d6; }
html[data-theme="iphone"] .check { border-color: #c7c7cc; }

/* Theme picker under More */
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .6rem; }
.theme-opt { font: inherit; cursor: pointer; border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: .5rem .3rem .45rem; text-align: center; font-size: .85rem; font-weight: 600; }
.theme-opt.on { border-color: var(--brand); }
.theme-opt .swatch { display: block; height: 44px; border-radius: 8px; margin-bottom: .35rem; border: 1px solid rgba(128,128,128,.35); }
.swatch.iphone { background: linear-gradient(#f9f9f9 0 30%, #f2f2f7 30% 100%); box-shadow: inset 0 -10px 0 -4px #007aff; }
.swatch.light { background: linear-gradient(#16425b 0 30%, #f4f6f8 30% 100%); }
.swatch.dark { background: linear-gradient(#1d5878 0 30%, #101920 30% 100%); }
.musts { margin: .2rem 0 .6rem; padding-left: 1.2rem; font-size: .92rem; }
.preview { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .92rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem .9rem; margin: .5rem 0; }
.compose textarea { min-height: 11rem; }

/* Hot, warm, cold; deal steps; reports */
.badge.heat.hot { background: var(--bad-bg); color: var(--bad); } .badge.heat.warm { background: var(--warn-bg); color: var(--warn); } .badge.heat.cold { background: var(--line); color: var(--soft); }
.step-date { display: flex; align-items: center; gap: .5rem; margin-top: .25rem; } .step-date input { width: auto; padding: .25rem .4rem; font-size: .85rem; }
.tiles.three { grid-template-columns: repeat(3, 1fr); } .tiles.three b { font-size: 1.15rem; overflow-wrap: anywhere; }
.bar-row { display: grid; grid-template-columns: 2.4rem 1fr auto; gap: .5rem; align-items: center; margin: .3rem 0; font-size: .88rem; }
.bar { width: 100%; height: .6rem; accent-color: var(--brand); }
.table { overflow-x: auto; padding: .3rem .6rem; } table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .4rem .3rem; border-bottom: 1px solid var(--line); } tr:last-child td { border-bottom: 0; } th { color: var(--soft); font-size: .78rem; font-weight: 600; } .num { text-align: right; }

/* Open house sign-in */
body.kiosk .top-btn { display: none; } body.kiosk { padding-bottom: 2rem; }
.kiosk-form { max-width: 460px; margin: 1rem auto 0; } .kiosk-form input:not([type=checkbox]) { font-size: 1.1rem; padding: .75rem .8rem; } .kiosk-form .btn { font-size: 1.1rem; padding: .8rem; margin-top: .4rem; }
.notice.good { background: var(--good-bg); color: var(--good); } .kiosk-exit { text-align: center; margin-top: 3rem; font-size: .8rem; opacity: .6; }

/* ---------- Computer layout (wide windows). Everything above is the phone layout and is left alone. ---------- */
.tabs .desk { display: none; }
kbd { font: inherit; font-size: .85em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: .05rem .4rem; background: var(--card); }
.deal.dragging { opacity: .4; } .col.over { outline: 2px dashed var(--brand); outline-offset: 4px; border-radius: var(--r); }
@media (hover: hover) {
  .row:hover, tbody tr:hover, .side-item:hover { background: rgba(127,127,127,.08); }
  .btn:hover, .chip:hover, .theme-opt:hover { filter: brightness(.95); } .tabs a:hover { color: var(--ink) !important; }
  [data-go] { cursor: pointer; } .deal[draggable] { cursor: grab; }
}
@media (min-width: 1000px) {
  body { padding: 0 0 2rem 220px; }
  .tabs { top: 0; right: auto; width: 220px; flex-direction: column; justify-content: flex-start; gap: .15rem; border-top: 0; border-right: 1px solid var(--line); padding: 1rem .7rem; }
  .tabs::before { content: ""; height: 84px; background: url(/icon-192.png) center top / 64px no-repeat; }
  .tabs a, .tabs .desk { flex: none; display: flex; align-items: center; gap: .7rem; text-align: left; padding: .55rem .8rem; font-size: .95rem; border-radius: 10px; }
  .tabs .ico { display: inline-block; width: 1.4rem; text-align: center; font-size: 1.1rem; }
  .tabs a.on { background: rgba(127,127,127,.14); }
  .top-btn { display: none; }
  main { max-width: 1000px; padding: 1.5rem 2rem; }
  main.view-contacts, main.view-contact, main.view-pipeline { max-width: none; }
  .tiles { max-width: 640px; }
  .toast { bottom: 2rem; left: calc(50% + 110px); }
  .sheet { padding-left: 220px; }
  .wide-table { padding: 0; } .wide-table th, .wide-table td { padding: .55rem .8rem; white-space: nowrap; }
  .wide-table thead th { position: sticky; top: 0; background: var(--card); } .th { color: var(--soft); font-weight: 600; font-size: .78rem; }
  tr.kb, .side-item.kb { box-shadow: inset 3px 0 0 var(--brand); background: rgba(127,127,127,.1); }
  .split { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
  .side-list { position: sticky; top: 4.2rem; max-height: calc(100vh - 5.5rem); overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
  .side-item { display: block; padding: .5rem .8rem; border-top: 1px solid var(--line); } .side-item:first-child { border-top: 0; } .side-item .sub { display: block; }
  .side-item.on { background: rgba(127,127,127,.16); box-shadow: inset 3px 0 0 var(--brand); }
  .detail { max-width: 760px; } .detail .back { display: none; }
  .board { scroll-snap-type: none; }
}
html[data-theme="iphone"] .tabs a.on { background: rgba(120,120,128,.16); }
@media (max-width: 999px) { html[data-theme="iphone"] .tabs a.on { background: none; } }
