/* Leader app. Lake neutrals, float-tip orange accent, the phone's own system font.
   Layout: one scrolling column per screen + fixed bottom tab bar (iOS/Android pattern). */
:root {
  --bg: #eef2f1; --surface: #ffffff; --surface-2: #f5f8f7; --ink: #14232b; --muted: #5b6b72; --line: #d5dfdd;
  --accent: #e8551c; --accent-ink: #ffffff; --accent-soft: #fde9df;
  --hot: #d9471a; --warm: #b87b0c; --cold: #5d7f93; --good: #2f8a5b; --bad: #c2362b;
  --track: #e3eae8; --shadow: 0 1px 2px rgb(20 35 43 / 6%), 0 4px 16px rgb(20 35 43 / 6%);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --tabbar: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1a20; --surface: #15252d; --surface-2: #1a2d36; --ink: #e4ecea; --muted: #94a7ae; --line: #253a44;
    --accent: #ff7a45; --accent-ink: #1a0d06; --accent-soft: #3a241a;
    --hot: #ff6a3a; --warm: #e2a838; --cold: #86a9bd; --good: #5cc28d; --bad: #ff7b6e;
    --track: #22363f; --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 var(--font); -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.app {
  max-width: 640px; margin: 0 auto;
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 24px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 16px;
}
.splash { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.splash img { border-radius: 18px; }

/* Headings */
.screen-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 8px; }
.screen-head h1 { font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
.screen-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 6px 0 -6px; font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Generic blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.pad { padding: 14px 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.empty { padding: 22px 16px; text-align: center; color: var(--muted); }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; }

/* Buttons */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 10px 14px;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600;
  text-decoration: none; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .chip:focus-visible, .lead-row:focus-visible, .tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }

/* Chips (filters, stages, owners) */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { appearance: none; flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 7px 13px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 36px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .n { font-family: var(--mono); font-weight: 500; opacity: .7; margin-left: 4px; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, textarea.input, select.input { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 11px;
  padding: 11px 12px; min-height: 44px; font-size: 16px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea.input { min-height: 84px; resize: vertical; }
.search { position: relative; }
.search .input { padding-left: 36px; }
.search::before { content: ""; position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; translate: 0 -50%;
  background: var(--muted); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat; }

/* Tier pill */
.tier { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 3px 7px; border-radius: 99px;
  border: 1px solid currentColor; white-space: nowrap; }
.tier.hot { color: var(--hot); } .tier.warm { color: var(--warm); } .tier.cold { color: var(--cold); }
.tier.soon { color: var(--accent); border-style: dashed; } .tier.other { color: var(--muted); }

/* Lead list rows */
.list { display: flex; flex-direction: column; }
.lead-row { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; padding: 12px 14px 12px 0;
  text-decoration: none; border-bottom: 1px solid var(--line); align-items: center; }
.list .lead-row:last-child { border-bottom: 0; }
.lead-row .stripe { align-self: stretch; border-radius: 0 3px 3px 0; background: var(--cold); }
.lead-row[data-tier="hot"] .stripe { background: var(--hot); }
.lead-row[data-tier="warm"] .stripe { background: var(--warm); }
.lead-row[data-tier="soon"] .stripe { background: var(--accent); }
.lead-row[data-tier="other"] .stripe { background: var(--line); }
.lead-row .name { font-weight: 650; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-row .meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.lead-row .why { font-size: 14px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead-row .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.score { font: 700 22px/1 var(--font); font-variant-numeric: tabular-nums; }
.score small { font: 500 11px var(--mono); color: var(--muted); }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.due { background: var(--accent-soft); color: var(--accent); }
.badge.overdue { background: var(--bad); color: #fff; }

/* Stats strip */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats div { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); }
.stats div:last-child { border-right: 0; }
.stats b { font-size: 22px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }
.stats .hot b { color: var(--hot); }

/* Lead detail */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); text-decoration: none; font-weight: 600; min-height: 36px; }
.back::before { content: "‹"; font-size: 26px; line-height: 0; margin-top: -3px; }
.detail-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: start; }
.detail-head h1 { font-size: 26px; margin: 0; overflow-wrap: anywhere; letter-spacing: -0.01em; }
.detail-head .score { font-size: 34px; text-align: right; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.facts .k { font-size: 12px; color: var(--muted); display: block; }
.facts .v { font-weight: 600; overflow-wrap: anywhere; }
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.meter { display: grid; grid-template-columns: 62px minmax(0, 1fr) 26px; gap: 8px; align-items: center; font-size: 13px; }
.meter .track { height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; }
.meter .fill { height: 100%; width: 0; background: var(--ink); border-radius: 3px; transition: width .4s ease; }
.meter.pain .fill { background: var(--accent); }
.meter .val { font: 500 12px var(--mono); text-align: right; }
.reasons { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.reasons li::marker { color: var(--accent); }
.pitch { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; }
.pitch p { margin: 6px 0 10px; }
.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-size: 12px; font-weight: 600; min-height: 64px; cursor: pointer; }
.action .ai { width: 22px; height: 22px; background: var(--accent); mask: var(--icon) center / contain no-repeat; }
.action[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.products li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.products li:last-child { border-bottom: 0; }
.products ul { list-style: none; margin: 0; padding: 0; }
.products .w { font: 600 14px var(--mono); color: var(--accent); text-align: right; }
.products a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; color: var(--muted); }
.products .flag { font-size: 12px; color: var(--hot); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .note { white-space: pre-wrap; overflow-wrap: anywhere; }
.contact-line { display: flex; align-items: center; gap: 8px; font: 15px var(--mono); overflow-wrap: anywhere; user-select: all; }

/* Jobs */
.job { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: 0; }
.job .bar { height: 4px; background: var(--track); border-radius: 2px; overflow: hidden; }
.job .bar > div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.job .log { font: 12px/1.5 var(--mono); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.status-dot.running { background: var(--accent); animation: pulse 1.2s infinite; }
.status-dot.done { background: var(--good); } .status-dot.failed { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }

/* Install hint */
.install { display: flex; gap: 12px; align-items: center; }
.install img { border-radius: 12px; flex: 0 0 auto; }

/* Login */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 18px; max-width: 380px; margin: 0 auto; width: 100%; }
.login .brand { display: flex; align-items: center; gap: 12px; }
.login .brand img { border-radius: 14px; }
.login h1 { margin: 0; font-size: 30px; }
.error { color: var(--bad); font-weight: 600; font-size: 14px; }

/* Bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabbar);
  font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--accent); }
.ti { width: 24px; height: 24px; background: currentColor; mask: var(--icon) center / contain no-repeat; }
.ti-today { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3Ccircle cx='12' cy='15' r='1.6' fill='black'/%3E%3C/svg%3E"); }
.ti-leads { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3c3 4 5 6.5 5 10a5 5 0 0 1-10 0c0-3.5 2-6 5-10Z'/%3E%3C/svg%3E"); }
.ti-pipe { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6h16M7 12h10M10 18h4'/%3E%3C/svg%3E"); }
.ti-add { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5M11 8v6M8 11h6'/%3E%3C/svg%3E"); }
.ai-call { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.6 10.8a15 15 0 0 0 6.6 6.6l2.2-2.2a1 1 0 0 1 1-.25 11.4 11.4 0 0 0 3.6.57 1 1 0 0 1 1 1V20a1 1 0 0 1-1 1A17 17 0 0 1 3 4a1 1 0 0 1 1-1h3.5a1 1 0 0 1 1 1c0 1.25.2 2.45.57 3.57a1 1 0 0 1-.25 1Z'/%3E%3C/svg%3E"); }
.ai-wa { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 0 0-8.6 15.1L2 22l5-1.3A10 10 0 1 0 12 2Zm0 2a8 8 0 1 1-4.1 14.9l-.3-.2-3 .8.8-2.9-.2-.3A8 8 0 0 1 12 4Zm-3 4c-.3 0-.7.1-1 .5-.4.4-1 1-1 2.4s1 2.8 1.2 3c.1.2 2 3.2 5 4.4 2.5 1 3 .8 3.5.7.6 0 1.8-.7 2-1.4.3-.7.3-1.3.2-1.4l-.5-.3-1.8-.9c-.3-.1-.4-.1-.6.1l-.8 1c-.1.2-.3.2-.6.1a6.6 6.6 0 0 1-3.3-2.9c-.2-.4.2-.4.7-1.3l.1-.5-.9-2c-.2-.6-.4-.5-.6-.5H9Z'/%3E%3C/svg%3E"); }
.ai-mail { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='m3 7 9 6 9-6'/%3E%3C/svg%3E"); }
.ai-web { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c2.5 3 2.5 15 0 18M12 3c-2.5 3-2.5 15 0 18'/%3E%3C/svg%3E"); }

/* Toast + offline */
.toast { position: fixed; left: 50%; translate: -50% 0; z-index: 30; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 14px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgb(0 0 0 / 20%); }
.offline { position: sticky; top: 0; z-index: 25; background: var(--warm); color: #1a1205; text-align: center; font-size: 13px; font-weight: 600;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 12px 6px; }

@media (min-width: 700px) { .app { padding-top: 28px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Small utilities (the app's CSP forbids inline style attributes) */
.tight { gap: 4px; }
.mt-6 { margin-top: 6px; }
[data-fs="12"] { font-size: 12px; } [data-fs="13"] { font-size: 13px; } [data-fs="14"] { font-size: 14px; }

/* Notifications */
.switches { display: flex; flex-direction: column; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.switch { appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 46px; height: 28px; border-radius: 14px; background: var(--track);
  position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.update { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-bottom: 1px solid var(--line); text-decoration: none; }
.update:last-child { border-bottom: 0; }
.update .muted { font-size: 14px; }
.update .when { font-size: 12px; color: var(--muted); }
.tabs a { position: relative; }
.tab-badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font: 700 11px/18px var(--font); text-align: center; }

/* Offer & email */
textarea.mail-body { min-height: 320px; font-size: 15px; line-height: 1.5; }
#offer-settings textarea.input { min-height: 90px; }
