:root { --brand: #2563eb; --ink: #1c1917; --ink-2: #57534e; --line: #e7e5e4; --bg: #f5f5f4; --card: #fff; --bad: #b91c1c; --ok: #15803d; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
button, input, textarea, select { font: inherit; color: inherit; }
.muted { color: var(--ink-2); font-size: 14px; }
.center { text-align: center; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.top img { height: 36px; width: auto; max-width: 90px; object-fit: contain; }
.top-t { display: grid; line-height: 1.2; flex: 1; min-width: 0; }
.top-t b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 22px 4px 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer; }
.card:active { transform: scale(.99); }
.card .t { flex: 1; min-width: 0; }
.card .t b { display: block; }
.card .t .muted { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .chev { color: var(--ink-2); font-size: 22px; }
.card img.th { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #ecfdf5; color: var(--ok); margin-left: 6px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; }
.icon { border: 0; background: none; font-size: 26px; width: 44px; height: 44px; cursor: pointer; }
label.f { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=password], textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; min-height: 48px; }
textarea { min-height: 140px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.login { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-top: 30px; }
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--bg); overflow: auto; }
.sheet .bar { position: sticky; top: 0; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; background: var(--card); border-bottom: 1px solid var(--line); }
.sheet .bar b { flex: 1; }
.sheet .body { max-width: 640px; margin: 0 auto; padding: 16px 16px 120px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.item .tools { display: flex; gap: 6px; justify-content: flex-end; }
.item .tools button { min-width: 44px; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.ph { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.ph img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; background: var(--line); }
.ph label.btn input { display: none; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid div { position: relative; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.grid button { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; }
.switch { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-weight: 600; }
.switch input { width: 24px; height: 24px; accent-color: var(--brand); }
.foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.foot .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 20; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.err { color: var(--bad); margin-top: 10px; }
.hint { font-size: 13px; color: var(--ink-2); margin-top: 6px; }

/* ── Requests / inbox ─────────────────────────────────────────────── */
.inbox-card { border-color: #d6ead0; background: linear-gradient(0deg, #fff, #f6faf2); }
.inbox-ic { position: relative; width: 44px; height: 44px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 20px; flex: 0 0 auto; }
.inbox-ic .dot { position: absolute; top: 7px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; border: 2px solid #fff; }
.tag.badge { background: #ef4444; color: #fff; }
.inbox-top { margin-top: 0; align-items: center; }
.inbox-top .icon { flex: 0 0 auto; }
.inbox-h { font-size: 20px; }
.lead { position: relative; }
.lead .lead-dot { width: 9px; height: 9px; border-radius: 50%; background: transparent; flex: 0 0 auto; }
.lead.unread .lead-dot { background: var(--brand); }
.lead.unread .t b { font-weight: 700; }
.lead .t .svc { font-weight: 400; }
.src-tag { color: var(--brand); font-weight: 700; }
.lead .when { font-size: 12px; white-space: nowrap; align-self: flex-start; }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-2); }
.empty-ic { font-size: 40px; opacity: .4; margin-bottom: 8px; }
.empty p { margin: 4px 0; }
.lead-detail { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px; margin-bottom: 14px; }
.lead-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lead-row:last-child { border-bottom: 0; }
.lead-lbl { flex: 0 0 110px; color: var(--ink-2); font-size: 14px; }
.lead-val { font-weight: 600; word-break: break-word; }
.lead-val.link { color: var(--brand); text-decoration: none; }
.lead-actions .btn { text-decoration: none; }
.lead-msg { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; white-space: pre-wrap; margin-top: 6px; line-height: 1.5; }

/* ── Stats tile ───────────────────────────────────────────────────── */
.stats { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; }
.stats-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-bottom: 10px; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 4px 2px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-n { display: block; font-size: 28px; font-weight: 700; color: var(--brand); line-height: 1.1; }
.stat-l { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

/* ── Status pills ─────────────────────────────────────────────────── */
.lead-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: 0 0 auto; }
.pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill-new { background: #fee2e2; color: #b91c1c; }
.pill-quoted { background: #fef3c7; color: #92600a; }
.pill-scheduled { background: #dbeafe; color: #1e49b6; }
.pill-done { background: #dcfce7; color: #15803d; }

/* ── Lead tracker (status / quote / note) ─────────────────────────── */
.tracker { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px 16px; margin-top: 14px; }
.seg-wrap { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg { min-height: 42px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; padding: 0 4px; }
.seg.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ── Email composer + thread ──────────────────────────────────────── */
.composer { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px 16px; margin-top: 14px; }
.composer textarea { min-height: 120px; }
.composer-none { background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 14px; margin-top: 14px; }
.thread { margin-top: 14px; }
.thread-item { background: #ecfdf5; border: 1px solid #c7ecd6; border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.thread-h { font-size: 12px; font-weight: 700; color: var(--ok); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.thread-b { white-space: pre-wrap; font-size: 14px; color: var(--ink); line-height: 1.5; }
