/* Leads app. Phone first: one column, big tap targets, a bottom tab bar. */
body { background: var(--paper); }
.loading { padding: 4rem 1rem; text-align: center; color: var(--muted); }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 0.5rem; min-height: 52px; padding: calc(0.4rem + env(safe-area-inset-top)) 1rem 0.4rem; background: var(--ink); color: #fff; }
.top-brand { font-weight: 800; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-title { font-size: 1.05rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.back { color: #fff; text-decoration: none; font-size: 2rem; line-height: 1; padding: 0 0.6rem 0.2rem 0; min-width: 44px; min-height: 44px; display: grid; place-items: center start; }
.main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem calc(6rem + env(safe-area-inset-bottom)); }
.main.narrow { max-width: 420px; padding-top: 3.5rem; }
.page-title { font-size: 1.75rem; margin: 0.4rem 0 0.9rem; }
.sec { font-size: 1.1rem; margin: 1.5rem 0 0.6rem; }
.muted { color: var(--muted); font-size: 0.92rem; }
.help { display: block; color: var(--muted); font-size: 0.88rem; margin-top: 0.25rem; }
.err { color: var(--err); min-height: 1.2em; }
.ok { color: var(--ok); font-weight: 650; }
.note { background: var(--sheet); border-left: 4px solid var(--marker); padding: 0.8rem 1rem; border-radius: 0 10px 10px 0; }
.btn.small { min-height: 40px; padding: 0 0.9rem; font-size: 0.95rem; border-radius: 10px; }
.linkish { border: 0; background: none; color: var(--ink-2); text-decoration: underline; cursor: pointer; min-height: 40px; padding: 0 0.4rem; font-size: 0.95rem; }
.small-link { font-size: 0.92rem; }
.stack { display: grid; gap: 0.75rem; }
.stack label, .sheet label { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.95rem; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
label.check input { width: 22px; height: 22px; accent-color: var(--ink); }
label.check.big { font-size: 1.05rem; }
label.inline { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

/* login */
.login { display: grid; gap: 0.6rem; }
.login h1 { margin: 0.5rem 0 0; }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--sheet); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { position: relative; display: grid; justify-items: center; gap: 0.15rem; padding: 0.45rem 0 0.5rem; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-decoration: none; min-height: 54px; }
.tabs a[aria-current='page'] { color: var(--ink); }
.tabs a[aria-current='page'] .ic { background: var(--ink); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--err); color: #fff; font-size: 0.7rem; border-radius: 999px; padding: 0 0.4rem; line-height: 1.4; }
.ic { width: 24px; height: 24px; background: var(--muted); -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; display: inline-block; }
.ic-inbox { --m: url('/icons/inbox.svg'); } .ic-calendar { --m: url('/icons/calendar.svg'); } .ic-tasks { --m: url('/icons/tasks.svg'); }
.ic-contacts { --m: url('/icons/contacts.svg'); } .ic-more { --m: url('/icons/more.svg'); } .ic-call { --m: url('/icons/call.svg'); }
.ic-text { --m: url('/icons/text.svg'); } .ic-email { --m: url('/icons/email.svg'); } .ic-map { --m: url('/icons/map.svg'); }

/* inbox */
.search { margin-bottom: 0.6rem; }
.chips { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.5rem; margin-bottom: 0.4rem; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { flex: none; border: 1.5px solid var(--line-2); background: var(--sheet); border-radius: 999px; min-height: 40px; padding: 0 0.85rem; font-weight: 600; font-size: 0.92rem; cursor: pointer; }
.chip[aria-selected='true'] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .n { margin-left: 0.35rem; font-weight: 500; opacity: 0.8; }
.today { display: block; background: var(--marker-soft); border-radius: 10px; padding: 0.65rem 0.85rem; margin-bottom: 0.6rem; font-weight: 600; text-decoration: none; }
.today.warn { background: #FBE9E7; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.1rem 0.6rem; background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 0.75rem 0.9rem; text-decoration: none; color: var(--ink); }
.row.status-new { border-left: 5px solid var(--marker); }
.r-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-time { color: var(--muted); font-size: 0.85rem; }
.r-sub { color: var(--ink-2); font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-msg { grid-column: 1 / -1; color: var(--muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { justify-self: end; align-self: center; font-size: 0.75rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; background: #E5E9E4; color: var(--ink-2); }
.p-new { background: var(--marker); color: var(--ink); } .p-booked { background: #DCE8F7; color: #1D4E89; } .p-won { background: #DDEFE5; color: #1F5C41; } .p-lost { background: #F1E4E3; color: #8A2E26; } .p-quoted { background: #EDE5F5; color: #57397A; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty .btn { margin-top: 1rem; }
.fab { position: fixed; right: 1.1rem; bottom: calc(5rem + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 2rem; text-decoration: none; box-shadow: 0 8px 22px rgba(23, 42, 58, 0.3); }

/* lead */
.quick { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.5rem; margin-bottom: 0.9rem; }
.qbtn { display: grid; justify-items: center; gap: 0.25rem; background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 0.65rem 0; font-weight: 700; text-decoration: none; color: var(--ink); min-height: 64px; }
.qbtn .ic { background: var(--ink); }
.stages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; margin-bottom: 0.9rem; }
.stage { min-height: 42px; border: 1.5px solid var(--line-2); background: var(--sheet); border-radius: 10px; font-weight: 600; cursor: pointer; }
.stage[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (min-width: 560px) { .stages { grid-template-columns: repeat(6, 1fr); } }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 0.9rem; background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 0.85rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.88rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts .pill { margin-left: 0.4rem; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.4rem; margin-top: 0.8rem; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.msg { display: grid; max-width: 88%; }
.msg.in { justify-self: start; } .msg.out { justify-self: end; }
.bubble { white-space: pre-wrap; overflow-wrap: anywhere; padding: 0.6rem 0.8rem; border-radius: 16px; background: var(--sheet); border: 1px solid var(--line); }
.msg.out .bubble { background: #DCE8F7; border-color: #C5D6EE; }
.msg.ch-note .bubble { background: var(--marker-soft); border-color: #EDD98F; }
.msg.ch-system .bubble { background: transparent; border-style: dashed; color: var(--muted); font-size: 0.9rem; }
.meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; padding: 0 0.3rem; }
.msg.out .meta { text-align: right; }
.compose { margin-top: 1rem; display: grid; gap: 0.5rem; }
.compose-actions, .more-actions, .row-btns { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.more-actions { margin-top: 1rem; }
.card { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem 1rem; margin-top: 0.9rem; }
.card h2 { font-size: 1.05rem; margin: 0 0 0.5rem; }
.task { display: flex; justify-content: space-between; gap: 0.75rem; align-items: center; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.task:first-of-type { border-top: 0; }
.task-body { color: var(--ink-2); font-size: 0.92rem; white-space: pre-wrap; margin: 0.2rem 0; }
.task-btns { display: grid; gap: 0.2rem; justify-items: end; flex: none; }
.tasks > div { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 0.4rem 0.9rem; margin-bottom: 0.5rem; }
.inline-add { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; }
.inline-add .field { flex: 1; }

/* calendar */
.day { margin-top: 1.1rem; }
.day h2 { font-size: 1rem; margin: 0 0 0.4rem; color: var(--ink-2); }
.appt { display: grid; grid-template-columns: 4.6rem 1fr; gap: 0.6rem; background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; padding: 0.65rem 0.8rem; margin-bottom: 0.4rem; }
.appt-time { font-weight: 800; }
.appt.st-requested { border-left: 5px solid var(--err); }

/* sheet (booking) */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(23, 42, 58, 0.45); display: grid; align-items: end; }
.sheet-box { background: var(--paper); border-radius: 20px 20px 0 0; padding: 1.1rem 1rem calc(1.2rem + env(safe-area-inset-bottom)); display: grid; gap: 0.7rem; max-height: 92vh; overflow: auto; max-width: 640px; width: 100%; margin: 0 auto; }
.sheet-box h2 { margin: 0; }

/* reports */
.month { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.7rem; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tiles.small { grid-template-columns: repeat(2, 1fr); }
.tile { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 0.8rem 0.9rem; display: grid; }
.tile b { font-size: 1.5rem; letter-spacing: -0.02em; }
.tile span { color: var(--muted); font-size: 0.85rem; }
.bar { display: grid; grid-template-columns: 9.5rem 1fr 2rem; align-items: center; gap: 0.5rem; margin: 0.35rem 0; font-size: 0.92rem; }
.bar i { height: 12px; border-radius: 6px; background: var(--ink); display: block; min-width: 4px; }
.bar b { text-align: right; }

/* settings */
.set { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 0.6rem; }
.set summary { cursor: pointer; padding: 1rem; font-weight: 700; list-style: none; }
.set summary::-webkit-details-marker { display: none; }
.set-body { padding: 0 1rem 1rem; display: grid; gap: 0.75rem; }
.hours-row { display: grid; grid-template-columns: 1fr 6.5rem 6.5rem; gap: 0.4rem; align-items: center; }
.hours-row .field { min-height: 42px; padding: 0.35rem 0.4rem; }
.auto { border-top: 1px solid var(--line); padding-top: 0.75rem; display: grid; gap: 0.45rem; }
.delay { width: 5.5rem; }
.team { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.4rem; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.code { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem; font-size: 0.82rem; overflow-wrap: anywhere; }
.menu { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.menu a { display: block; background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 1rem; font-weight: 700; text-decoration: none; }
.menu .foot { padding: 1rem 0.2rem; }
.toast { position: fixed; left: 50%; bottom: calc(5.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 0.7rem 1rem; border-radius: 10px; font-weight: 600; z-index: 60; max-width: 90vw; }
.toast.bad { background: var(--err); }
