/* Cold Caller: flat, big buttons, light + dark. No gradients. */
:root {
  --bg: #f4f4f5; --card: #ffffff; --text: #111113; --muted: #67676d; --line: #e2e2e6;
  --field: #f4f4f5; --primary: #16a34a; --primary-text: #ffffff;
  --gray: #6b6b73; --red: #dc2626; --amber: #c2700a; --blue: #2563eb; --green: #16a34a;
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f11; --card: #1a1b1f; --text: #f4f4f5; --muted: #9b9ba3; --line: #2b2c31;
    --field: #111215; --primary: #22c55e; --primary-text: #04210f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0f11; --card: #1a1b1f; --text: #f4f4f5; --muted: #9b9ba3; --line: #2b2c31;
  --field: #111215; --primary: #22c55e; --primary-text: #04210f; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
  overscroll-behavior: contain;
}
[hidden] { display: none !important; }
button, .btn, a.btn { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.msg { min-height: 1.4em; margin: 10px 0 0; }

input, textarea, select {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--field);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 4px 0 12px;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
label { display: block; font-size: 15px; color: var(--muted); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 56px; padding: 12px 16px; margin: 8px 0 0; border: 0; border-radius: 14px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--field); color: var(--text); border: 1px solid var(--line);
}
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.bad { background: transparent; color: var(--red); border-color: var(--red); }
.btn:active { transform: scale(0.98); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }

/* Layout */
.app { display: flex; flex-direction: column; height: 100dvh; }
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--safe-t) + 10px) 16px 10px; background: var(--card); border-bottom: 1px solid var(--line);
}
.stats { display: flex; flex: 1; gap: 8px; }
.stat { flex: 1; text-align: center; }
.stat b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.syncdot {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 22px; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px;
}
.syncdot i { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.syncdot.pending i { background: var(--amber); }
.syncdot.offline i { background: var(--gray); }

main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.tab { padding: 16px 16px 24px; max-width: 640px; margin: 0 auto; }

.tabs {
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs button {
  position: relative; flex: 1; min-height: 60px; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tabs svg { width: 26px; height: 26px; fill: currentColor; }
.tabs button.on { color: var(--primary); }
.tabs em {
  position: absolute; top: 6px; left: 55%; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--red); color: #fff; font-style: normal; font-size: 12px; line-height: 20px; font-weight: 700;
}

/* Lead card */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card.danger { border-color: var(--red); }
.lead-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.lead-biz { font-size: 26px; font-weight: 700; line-height: 1.15; margin: 0 0 4px; overflow-wrap: anywhere; }
.lead-meta { color: var(--muted); margin: 0 0 2px; overflow-wrap: anywhere; }
.lead-phone { font-size: 20px; font-weight: 600; margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.links { display: flex; gap: 8px; margin-top: 12px; }
.links a { flex: 1; text-align: center; padding: 12px; border-radius: 12px; border: 1px solid var(--line); text-decoration: none; font-weight: 600; min-height: 48px; }
.links span { flex: 1; text-align: center; padding: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }
.pill { display: inline-block; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--field); border: 1px solid var(--line); white-space: nowrap; }
.pill.new { color: var(--blue); } .pill.no_answer { color: var(--gray); } .pill.not_interested { color: var(--red); }
.pill.callback { color: var(--amber); } .pill.mockup_sent { color: var(--blue); } .pill.sold { color: var(--green); }

.call-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 84px;
  margin: 4px 0 14px; border: 0; border-radius: 20px; background: var(--green); color: #fff;
  font: inherit; font-size: 26px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.call-btn svg { width: 30px; height: 30px; fill: currentColor; }
.call-btn:active, .out:active { transform: scale(0.98); }

.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.out {
  min-height: 68px; border: 0; border-radius: 16px; color: #fff; font: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
}
.out.no_answer { background: var(--gray); } .out.not_interested { background: var(--red); }
.out.callback { background: var(--amber); } .out.mockup_sent { background: var(--blue); }
.out.sold { background: var(--green); grid-column: 1 / -1; min-height: 72px; }
.skip { margin-top: 10px; }
.notes { margin-top: 14px; }
.notes textarea { min-height: 84px; }
.queue-left { text-align: center; color: var(--muted); font-size: 14px; margin: 10px 0 0; }
.empty { text-align: center; padding: 40px 12px; }
.empty p { color: var(--muted); }
.banner { background: var(--card); border: 1px solid var(--amber); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }
.banner p { margin: 0; flex: 1; }
.banner .btn { width: auto; margin: 0; min-height: 44px; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 12px 12px 16px; min-height: 64px; cursor: pointer;
}
.row.overdue { border-color: var(--red); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub.late { color: var(--red); font-weight: 600; }
.row .mini {
  display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; flex: none; border-radius: 50%;
  background: var(--green); border: 0; color: #fff; text-decoration: none; cursor: pointer;
}
.row .mini svg { width: 24px; height: 24px; fill: currentColor; }
.search { margin-top: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 4px; scrollbar-width: none; overscroll-behavior-x: contain; }
.chips button {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 15px;
}
.chips button.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Segmented control */
.seg { display: flex; background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; min-height: 48px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-weight: 600; }
.seg button.on { background: var(--card); box-shadow: 0 1px 2px rgb(0 0 0 / 0.15); }

/* Sheet */
.backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 90dvh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 20px 16px calc(var(--safe-b) + 12px);
  max-width: 640px; margin: 0 auto; animation: up 0.2s ease-out;
}
.sheet.opening, .backdrop.opening { pointer-events: none; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.big-number { font-size: 40px; font-weight: 700; text-align: center; margin: 8px 0 4px; font-variant-numeric: tabular-nums; -webkit-user-select: all; user-select: all; }
.preview { white-space: pre-wrap; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0 0 6px; font-size: 16px; overflow-wrap: anywhere; }
.warn { color: var(--amber); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

/* Toast */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 76px); z-index: 30; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; background: var(--text); color: var(--bg);
  padding: 10px 10px 10px 16px; border-radius: 14px; min-height: 56px;
}
.toast span { flex: 1; }
.toast button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-weight: 700; }
.toast button:empty { display: none; }

/* Sign-in */
.login { min-height: 100dvh; display: grid; place-items: center; padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 20px); }
.login-box { width: 100%; max-width: 380px; text-align: center; }
.login-box img { border-radius: 18px; }
.login-box h1 { margin: 12px 0 24px; }
.login-box form { text-align: left; }
#code { font-size: 28px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }

@media (min-width: 700px) {
  .outcomes { grid-template-columns: repeat(5, 1fr); }
  .out.sold { grid-column: auto; min-height: 68px; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .btn:active, .call-btn:active, .out:active { transform: none; }
}
