/* Built for a phone in bright sunlight: high contrast, big type, big targets. */
:root {
  --ink: #111; --paper: #fff; --muted: #555; --line: #c9c9c9; --soft: #f1f1ee;
  --brand: #0b4fd6; --brand-ink: #fff; --bad: #b00020; --bad-soft: #fde8ea;
  --warn: #8a4b00; --warn-soft: #fff1d6; --good: #0a6b2c; --good-soft: #e2f4e7;
  --tap: 56px; --radius: 12px;
}
* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--paper); line-height: 1.4;
}
main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(48px + env(safe-area-inset-bottom)); }
main.wide { max-width: none; }
.narrow { max-width: 420px; margin: 8vh auto 0; }
h1 { font-size: 1.6rem; margin: 12px 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 28px 0 10px; }
h3 { font-size: 1rem; margin: 20px 0 8px; }
a { color: var(--brand); }
h1 a { color: inherit; text-decoration-thickness: 2px; }
.muted { color: var(--muted); font-size: .9rem; }
.lead { margin-top: 0; }
.empty { color: var(--muted); padding: 20px 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Header */
.top { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--ink); position: sticky; top: 0; z-index: 10; }
.brand { color: #fff; text-decoration: none; font-size: 1.6rem; width: 48px; height: 48px; display: grid; place-items: center; }
.search { flex: 1; min-width: 0; }
.search input { height: 48px; border: 0; }
.menu { position: relative; }
.menu summary { list-style: none; color: #fff; font-size: 1.5rem; width: 48px; height: 48px; display: grid; place-items: center; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu nav { position: absolute; right: 0; top: 52px; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius); min-width: 240px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.menu nav a, .menu nav .link { display: block; width: 100%; text-align: left; padding: 14px 12px; color: var(--ink); text-decoration: none; font-size: 1rem; font-weight: 600; }
.tabs { display: flex; overflow-x: auto; border-bottom: 2px solid var(--ink); background: var(--soft); }
.tabs a { padding: 14px 18px; color: var(--ink); text-decoration: none; font-weight: 700; white-space: nowrap; }
.tabs a.on { background: var(--ink); color: #fff; }

/* Forms */
label { display: block; font-weight: 700; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=tel], select, textarea {
  display: block; width: 100%; min-height: var(--tap); padding: 12px 14px; margin-top: 6px;
  font: inherit; font-weight: 400; color: var(--ink); background: #fff;
  border: 2px solid var(--ink); border-radius: var(--radius);
}
textarea { min-height: 120px; resize: vertical; }
:focus-visible { outline: 4px solid #ffbf47; outline-offset: 2px; }
.stack > * + * { margin-top: 16px; }
.inline { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.inline > input, .inline > select { flex: 1 1 180px; margin-top: 0; }
.inline > span { flex: 1 1 200px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.hint { color: var(--muted); margin: 0; }
.link { background: none; border: 0; padding: 8px 0; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: var(--tap); padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer;
  color: var(--ink); background: #fff; border: 2px solid var(--ink); border-radius: var(--radius); text-decoration: none;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.quiet { border-color: var(--line); color: var(--muted); }
.btn.big { min-height: 64px; font-size: 1.05rem; }
.btn.huge { min-height: 84px; font-size: 1.3rem; width: 100%; }
.btn:active { transform: translateY(1px); filter: brightness(.92); }
.actions { display: grid; gap: 10px; margin: 16px 0; }
.actions.two { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.actions.three { grid-template-columns: 1fr; }
@media (min-width: 560px) { .actions.three { grid-template-columns: repeat(3, 1fr); } }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 48px; padding: 8px 16px; font: inherit; font-weight: 700; background: var(--soft); border: 2px solid var(--ink); border-radius: 999px; cursor: pointer; }

/* Messages */
.flash { background: var(--good-soft); border: 2px solid var(--good); color: var(--good); font-weight: 700; padding: 12px 14px; border-radius: var(--radius); margin: 0 0 12px; }
.error { background: var(--bad-soft); border: 2px solid var(--bad); color: var(--bad); font-weight: 700; padding: 12px 14px; border-radius: var(--radius); }
.keybox { border: 2px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius); padding: 4px 14px; overflow-x: auto; }

/* Cards */
.cards { display: grid; gap: 10px; }
.card { display: block; padding: 14px 16px; min-height: var(--tap); background: #fff; color: var(--ink); text-decoration: none; border: 2px solid var(--ink); border-radius: var(--radius); cursor: pointer; }
.card.late { border-left: 10px solid var(--bad); }
.card.current { background: var(--soft); border-style: dashed; cursor: default; }
.card-title { display: block; font-size: 1.15rem; font-weight: 800; }
.card-line { display: block; }
.card-next { display: block; margin-top: 6px; font-weight: 600; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 800; background: var(--soft); border: 1.5px solid var(--ink); white-space: nowrap; }
.badge.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.badge.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.badge.stage.closed { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.badge.stage.lost { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.with-note .muted { display: block; padding: 4px 4px 0; }

/* Log call */
.found { border: 2px solid var(--good); background: var(--good-soft); border-radius: var(--radius); padding: 12px 14px; }
.found-name { font-size: 1.2rem; font-weight: 800; margin: 0 0 8px; }
.choice { display: flex; gap: 12px; align-items: center; min-height: var(--tap); padding: 10px 12px; margin-top: 8px; background: #fff; border: 2px solid var(--ink); border-radius: var(--radius); font-weight: 400; cursor: pointer; }
.choice input { width: 26px; height: 26px; flex: none; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }

/* Job page */
.crumbs { margin: 0; color: var(--muted); }
.crumbs a { font-weight: 700; }
.address { font-size: 1.1rem; margin: 0 0 8px; }
.next { border: 2px solid var(--ink); border-radius: var(--radius); padding: 4px 16px 12px; margin: 16px 0; background: var(--soft); }
.next.late { border-color: var(--bad); background: var(--bad-soft); }
.next h2 { margin-top: 12px; }
.next-text { font-size: 1.15rem; font-weight: 700; margin: 0 0 8px; }
summary { cursor: pointer; font-weight: 700; padding: 12px 0; min-height: 48px; }
.panel { border: 2px solid var(--line); border-radius: var(--radius); padding: 0 16px; margin: 16px 0; }
.panel[open] { padding-bottom: 16px; }
.plain { list-style: none; padding: 0; margin: 8px 0; }
.plain li { padding: 6px 0; }
.log { list-style: none; padding: 0; margin: 0; }
.log-item { border-top: 2px solid var(--line); padding: 12px 0; }
.log-meta { margin: 0 0 4px; color: var(--muted); font-size: .9rem; }
.log-meta strong { color: var(--ink); }
.log-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.photo { display: block; max-width: 100%; max-height: 420px; border-radius: var(--radius); border: 2px solid var(--line); }
.email-body { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .9rem; background: var(--soft); padding: 12px; border-radius: var(--radius); max-height: 420px; overflow: auto; margin: 0; }
.filter { margin-bottom: 12px; }
[hidden] { display: none !important; }

/* Board */
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px; scroll-snap-type: x mandatory; align-items: flex-start; }
.col { flex: 0 0 86vw; max-width: 320px; background: var(--soft); border: 2px solid var(--line); border-radius: var(--radius); padding: 0 10px 10px; scroll-snap-align: start; }
@media (min-width: 720px) { .col { flex-basis: 270px; } .board { scroll-snap-type: none; } }
.col h2 { margin: 12px 4px; display: flex; justify-content: space-between; }
.col.over { border-color: var(--brand); background: #e4edff; }
.col-cards { display: grid; gap: 8px; min-height: 40px; }
.col .card { padding: 10px 12px; font-size: .9rem; }
.col .card-title { font-size: 1rem; }
.count { font-weight: 400; color: var(--muted); }
.drag.dragging { opacity: .4; }
dialog { border: 2px solid var(--ink); border-radius: var(--radius); padding: 20px; width: min(520px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin-top: 0; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.stat { display: block; padding: 10px; border: 2px solid var(--ink); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: #fff; }
.stat.closed { border-color: var(--good); }
.stat.lost { border-color: var(--line); color: var(--muted); }
.stat-n { display: block; font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label { display: block; font-size: .85rem; font-weight: 600; }

/* Inbox queue */
.mail { border: 2px solid var(--ink); border-radius: var(--radius); padding: 12px 16px; margin: 14px 0; }
.mail h2 { margin: 4px 0; }
.mail-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.mail-actions .inline { flex: 1 1 320px; margin: 0; }

/* Upload overlay */
.busy { position: fixed; inset: 0; background: rgba(0,0,0,.75); color: #fff; display: grid; place-items: center; font-size: 1.4rem; font-weight: 800; z-index: 100; }
