:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --text: #17201a;
  --muted: #5d6b61;
  --line: #dfe5df;
  --brand: #14532d;
  --brand-ink: #ffffff;
  --accent: #f5b301;
  --late: #b42318;
  --late-bg: #fdecea;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1411;
    --surface: #18201b;
    --text: #e8eee9;
    --muted: #9aa89f;
    --line: #2a352e;
    --brand: #3fa66a;
    --brand-ink: #08130c;
    --late: #ff8a7a;
    --late-bg: #3a1714;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 76px;
}
h1, h2, h3 { margin: 0; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--late); background: var(--late-bg); padding: 10px 12px; border-radius: var(--radius); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--brand); color: var(--brand-ink);
}
.top h1 { font-size: 19px; }
main#app { padding: 8px 16px 24px; max-width: 640px; margin: 0 auto; }

.stats { display: flex; gap: 8px; margin: 8px 0; }
.stats span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.count { background: var(--line); color: var(--text); border-radius: 999px; padding: 0 8px; font-size: 12px; }

.lead {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
}
.lead.overdue { border-left: 4px solid var(--late); }
.lead-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; }
.lead-head strong { font-size: 16px; }
.next { margin: 6px 0 4px; cursor: pointer; }
.when { font-size: 13px; font-weight: 600; color: var(--brand); }
.when.late { color: var(--late); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--text); white-space: nowrap; }
.chip.interested, .chip.replied { background: #fff3c4; color: #6b4e00; }
.chip.meeting, .chip.proposal { background: #dbeafe; color: #1e3a8a; }
.chip.won { background: #d1fae5; color: #065f46; }
.chip.lost { background: var(--late-bg); color: var(--late); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; text-decoration: none; cursor: pointer;
}
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn.danger { color: var(--late); }
.btn.icon { min-height: 36px; padding: 4px 10px; background: transparent; border-color: transparent; color: inherit; font-size: 18px; }

.fab {
  position: fixed; right: 16px; bottom: 86px; width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--accent); color: #1a1300; font-size: 30px; line-height: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer;
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs > *, .tabs form button { flex: 1; }
.tabs form { display: flex; flex: 1; }
.tabs button { min-height: 58px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.tabs button.active { color: var(--brand); font-weight: 700; box-shadow: inset 0 3px 0 var(--brand); }

details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 10px; }
details summary { cursor: pointer; padding: 4px 0; font-weight: 600; }
details .lead { border-color: var(--line); }

.search, input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.search { margin: 10px 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 4px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }

dialog {
  width: min(560px, 100%); max-height: 92vh; margin: auto auto 0; border: 0; padding: 0;
  border-radius: 18px 18px 0 0; background: var(--bg); color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.sheet { padding: 16px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; }
.log { list-style: none; padding: 0; margin: 10px 0 0; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--line); }

.auth { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; text-align: center; }
.auth h1 { color: var(--brand); margin-bottom: 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 16px; text-align: left; }
.card .btn { width: 100%; }

/* Header actions */
.top-actions { display: flex; align-items: center; gap: 2px; }
.top-actions form { margin: 0; }

/* My Day */
.day-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 8px 0 12px; }
.progress-label { margin: 2px 0 8px; font-size: 16px; }
.progress { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.quick-add { display: flex; gap: 8px; margin-bottom: 4px; }
.quick-add input { flex: 1; }
.quick-add .btn { flex: none; }

.checklist { list-style: none; padding: 0; margin: 0 0 8px; }
.item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; margin-bottom: 8px;
}
.item-body { flex: 1; min-width: 0; cursor: default; }
.item-body[data-open] { cursor: pointer; }
.item-title { font-weight: 600; margin-right: 6px; }
.item.done .item-title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.check {
  flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--brand);
  background: transparent; cursor: pointer; position: relative;
}
.check.on { background: var(--brand); }
.check.on::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--brand-ink); font-weight: 700; }
.tag { font-size: 11px; font-weight: 700; color: #6b4e00; background: #fff3c4; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.btn.small-icon { min-height: 36px; padding: 4px 8px; font-size: 16px; }
.btn.review { width: 100%; margin: 16px 0 8px; }
.btn.wide { width: 100%; margin: 8px 0; }

/* Follow-up done prompt */
.label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.choice { min-height: 40px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.choice.selected { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
#pick-at { margin-bottom: 10px; }
.review-wins { font-size: 16px; }

/* Templates */
.template-body { white-space: pre-wrap; margin: 8px 0; font-size: 14px; color: var(--text); }
.tpl-pick { padding: 6px 10px; }
.tpl-pick summary { font-weight: 600; }
code { background: var(--line); padding: 1px 5px; border-radius: 4px; }
.tabs button { font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; z-index: 50; font-size: 14px;
}
