:root {
  --teal: #5b9130;
  --teal-dark: #3b611e;
  --amber: #b8812a;
  --amber-tint: #faf1e2;
  --teal-tint: #eef4e6;
  --ink: #1a1d24;
  --muted: #5c6470;
  --line: #e5e3dc;
  --bg: #f7f5f0;
  --card: #ffffff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  display: flex; flex-direction: column; min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink);
}

#pin-gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--teal); display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
#pin-gate.unlocked { display: none; }
.pin-box { width: 100%; max-width: 300px; text-align: center; }
.pin-title { color: #fff; font-weight: 800; font-size: 1.15rem; margin: 0 0 4px; }
.pin-sub { color: #d7e6c9; font-size: 0.88rem; margin: 0 0 20px; }
#pin-input {
  width: 100%; text-align: center; letter-spacing: 0.4em; font-size: 1.4rem;
  padding: 14px; border-radius: 10px; border: none; margin-bottom: 12px;
}
.pin-error { color: #ffd7d7; font-size: 0.82rem; margin: -4px 0 12px; }

header.app {
  background: var(--teal); color: #fff;
  padding: calc(env(safe-area-inset-top) + 16px) 18px 14px;
  position: sticky; top: 0; z-index: 5;
  box-shadow: 0 2px 8px rgba(20, 30, 10, 0.12);
  flex-shrink: 0;
}
header.app p.eyebrow { margin: 0; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: #b9c8dc; }
header.app h1 { margin: 2px 0 0; font-size: 1.25rem; }

main { padding: 6px 16px 16px; flex: 1 0 auto; }
.screen { display: none; }
.screen.active { display: block; }

.search-wrap { padding: 12px 0 4px; }
input[type="text"], input[type="tel"], textarea {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line); font-size: 0.95rem; background: var(--card);
  font-family: inherit; color: var(--ink);
}
textarea { resize: vertical; min-height: 84px; }
input[type="text"]:focus, input[type="tel"]:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(20, 30, 10, 0.04);
}
.row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card h3 { margin: 0 0 3px; font-size: 0.98rem; }
.card p { margin: 0; font-size: 0.85rem; color: var(--muted); }
.src { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.right { text-align: right; flex-shrink: 0; }
.time { margin: 5px 0 0; font-size: 0.72rem; color: #9aa2ac; }

.badge { display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge-new { background: var(--teal-tint); color: var(--teal); }
.badge-contacted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge-quoted { background: var(--amber-tint); color: var(--amber); }
.badge-booked { background: var(--teal-tint); color: var(--teal-dark); }
.badge-done { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.status-pill {
  flex: 1; border: none; cursor: pointer; font-family: inherit;
  font-weight: 700; font-size: 0.78rem; padding: 9px 6px; border-radius: 999px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.status-pill.badge-new.active { background: var(--teal); color: #fff; }
.status-pill.badge-contacted.active { background: var(--muted); color: #fff; border-color: var(--muted); }
.status-pill.badge-quoted.active { background: var(--amber); color: #fff; }
.status-pill.badge-booked.active { background: var(--teal-dark); color: #fff; border-color: var(--teal-dark); }
.status-pill.badge-done.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 0.9rem; }

.section-label { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 4px 0 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; cursor: pointer; font-family: inherit; transition: background 0.15s, opacity 0.15s, transform 0.1s; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--teal); color: #fff; font-weight: 700; font-size: 0.9rem; padding: 11px 18px; border-radius: 10px; width: 100%; box-shadow: 0 1px 2px rgba(20,30,10,0.08); }
.btn-primary:active { background: var(--teal-dark); }
.btn-outline { background: var(--card); color: var(--muted); font-weight: 700; font-size: 0.9rem; padding: 11px 18px; border-radius: 10px; border: 1px solid var(--line); }
.btn-outline:active { background: var(--bg); }
.btn-danger { background: var(--card); color: #b23a3a; font-weight: 700; font-size: 0.9rem; padding: 11px 18px; border-radius: 10px; border: 1px solid #f0c6c6; }
.btn-danger:active { background: #fdf1f1; }
.btn-danger-solid { background: #d94b4b; color: #fff; font-weight: 700; font-size: 0.9rem; padding: 11px 18px; border-radius: 10px; }
.btn-danger-solid:active { background: #b23a3a; }

.detail-row { display: flex; align-items: baseline; gap: 6px; font-size: 0.88rem; padding: 3px 0; }
.detail-row .k { color: var(--muted); flex-shrink: 0; }
.detail-row .v { color: var(--ink); font-weight: 600; }

.record-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px; font-size: 0.95rem; font-weight: 700; color: var(--ink);
}
.record-dot { width: 14px; height: 14px; border-radius: 50%; background: #d94b4b; flex-shrink: 0; }
.record-dot.pulsing { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.record-btn.recording { border-color: #d94b4b; }
.record-sub { font-size: 0.78rem; color: var(--muted); font-weight: 500; margin-left: auto; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; padding: 4px 0; }
.check-box { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; display: inline-block; border: 1.5px solid var(--line); }
.check-box.done { background: var(--teal); border-color: var(--teal); }
.done-text { text-decoration: line-through; color: var(--muted); }

.segmented {
  display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 3px; margin: 4px 0 16px;
}
.seg-btn {
  flex: 1; background: none; border: none; font-family: inherit;
  padding: 9px 6px; border-radius: 8px; font-size: 0.85rem; font-weight: 700; color: var(--muted);
}
.seg-btn.active { background: var(--card); color: var(--teal); box-shadow: 0 1px 3px rgba(15,21,38,0.12); }
.sub-panel { display: none; }
.sub-panel.active { display: block; }

nav.tabbar {
  flex-shrink: 0;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding: 2px 4px calc(env(safe-area-inset-bottom, 0px) + 2px);
  box-shadow: 0 -2px 8px rgba(20, 30, 10, 0.06);
}
nav.tabbar button {
  flex: 1; background: none; border: none; font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 2px; color: var(--muted); font-size: 0.66rem; font-weight: 600;
  transition: color 0.15s;
}
nav.tabbar button .ic { line-height: 1; }
nav.tabbar button .ic svg { width: 22px; height: 22px; display: block; margin: 0 auto; }
nav.tabbar button.active { color: var(--teal); }
