:root {
  --ink: #1c1914;
  --paper: #f4efe6;
  --card: #fffdf8;
  --line: #d8d0c4;
  --accent: #6b3a22;
  --muted: #6f675c;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}
body.desk-app {
  font-family: var(--sans);
  background: #fff;
}
.app-frame {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(72px + var(--safe-bottom));
}
body.desk-app.login .app-frame {
  padding-bottom: var(--safe-bottom);
}
.app-hdr {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: calc(12px + var(--safe-top)) 1rem 0.5rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 4;
}
.app-hdr h1 { font-size: 1.35rem; font-weight: 600; }
.sign-out, .back-link { font-size: 0.9rem; color: var(--accent); text-decoration: none; }
.pill.status-live { transition: background 0.2s, border-color 0.2s; }
.desk-tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}
.tab-btn.on {
  background: rgba(107, 58, 34, 0.12);
  color: var(--accent);
}
.lead-grid { flex: 1; }
.card {
  transition: border-color 0.15s, box-shadow 0.15s;
}
body.desk-app .card {
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(28, 25, 20, 0.04);
}
body.desk-app .card-link:hover,
body.desk-app .lead-link:hover {
  box-shadow: 0 4px 16px rgba(28, 25, 20, 0.06);
}
body.receipts-page .app-hdr h1,
body.receipts-page .app-hdr .subhdr {
  display: none;
}
.receipt-capture-hero {
  text-align: center;
  padding: 28px 16px 24px;
  margin: 12px 0 20px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(107, 58, 34, 0.08), rgba(107, 58, 34, 0.02));
  border: 1px solid rgba(107, 58, 34, 0.12);
}
.receipt-capture-hero p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}
.receipt-review-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
  background: #fff;
}
.receipt-review-card .receipt-preview img {
  max-height: 200px;
  object-fit: contain;
  cursor: pointer;
}
.receipt-line-items {
  margin: 12px 0;
}
.receipt-line-items h3 {
  font-size: 0.85rem;
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.receipt-line-row {
  display: grid;
  grid-template-columns: 1fr 88px 36px;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}
.receipt-line-row input {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font: inherit;
}
.receipt-line-row button {
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
}
.receipt-totals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
  font-size: 0.95rem;
}
.receipt-totals-grid strong {
  text-align: right;
}
.receipt-ocr details {
  margin: 12px 0;
  font-size: 0.85rem;
}
.receipt-ocr textarea {
  width: 100%;
  min-height: 100px;
  margin-top: 8px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font: inherit;
}
.receipt-history-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.receipt-job-card {
  margin-bottom: 10px;
  cursor: pointer;
}
.receipt-job-card .job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 6px;
}
.receipt-job-card .job-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.receipt-job-receipts {
  margin: 8px 0 16px 12px;
  padding-left: 12px;
  border-left: 2px solid rgba(107, 58, 34, 0.2);
}
.receipt-job-receipts .receipt-row {
  cursor: pointer;
  margin-bottom: 8px;
}
.receipt-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 20, 0.45);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
.receipt-modal {
  background: #fff;
  border-radius: 16px 16px 0 0;
  max-height: 90vh;
  overflow: auto;
  width: 100%;
  max-width: 520px;
  padding: 16px;
}
.receipt-modal h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}
.receipt-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-bottom: 24px;
}
.receipt-subtabs {
  display: flex;
  gap: 8px;
  padding: 0 12px 8px;
  margin-bottom: 4px;
}
.receipt-subtabs button,
.receipt-subtabs label.receipt-capture-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  background: rgba(107, 58, 34, 0.06);
  touch-action: manipulation;
}
.receipt-subtabs button.on,
.receipt-subtabs label.receipt-capture-tab.on {
  color: var(--accent);
  background: rgba(107, 58, 34, 0.14);
}
.receipt-file-inputs {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.receipt-file-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  font-size: 16px;
}
.receipt-capture-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.receipt-capture-actions .btn-primary,
.receipt-capture-actions .btn-ghost {
  display: block;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}
.receipt-capture, .receipt-history {
  padding: 0 12px 100px;
}
.receipt-shell.receipt-uploading #rc-status {
  color: var(--accent);
  font-weight: 600;
}
.receipt-shell.receipt-uploading #rc-preview::after {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  margin: 12px auto;
  border: 3px solid rgba(107, 58, 34, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: receipt-spin 0.8s linear infinite;
}
@keyframes receipt-spin {
  to {
    transform: rotate(360deg);
  }
}
.receipt-label, .receipt-fields label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}
.receipt-label input, .receipt-fields input {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.receipt-file input[type="file"] {
  width: 100%;
  margin-top: 8px;
}
.receipt-preview img {
  max-width: 100%;
  border-radius: 10px;
  margin: 12px 0;
}
.receipt-warn {
  background: #fff3e0;
  border: 1px solid #e8c49a;
  padding: 10px;
  border-radius: 8px;
  margin: 8px 0;
  font-size: 0.9rem;
}
.receipt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.receipt-toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 88px;
  background: #1c1914;
  color: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 20;
}
.receipt-row-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}
.receipt-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.receipt-totals {
  font-weight: 600;
  margin-bottom: 12px;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 0.75rem;
}
.login-step[hidden] { display: none !important; }
.otp-input {
  font-size: 1.4rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.resend-form { margin-top: 0.75rem; }
.resend-form button { width: 100%; margin-top: 0; }
.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}
.pref-row input[type="checkbox"] {
  width: 28px;
  height: 28px;
  margin: 0;
}
.push-card .push-test { margin-top: 0.5rem; }
.login { display: grid; place-items: center; padding: 1rem; }
.login main {
  width: min(440px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  padding: 2rem 1.6rem;
}
.eyebrow { letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.72rem; color: var(--accent); margin: 0 0 0.4rem; }
h1 { font-size: 1.7rem; margin: 0 0 0.5rem; font-weight: 600; }
h2 { font-size: 1.2rem; margin: 0 0 0.5rem; }
h3 { font-size: 1rem; margin: 0 0 0.75rem; }
.lede, .note, .subhdr { color: var(--muted); line-height: 1.5; }
.subhdr { font-size: 0.9rem; margin: 0.2rem 0 0; }
label { display: block; margin: 1rem 0 0.35rem; font-size: 0.92rem; }
input[type="password"], input[type="text"], input[type="email"], input[type="number"], textarea {
  width: 100%; padding: 0.65rem 0.7rem; border: 1px solid var(--line); background: #fff; font: inherit;
}
textarea { resize: vertical; min-height: 4rem; }
button {
  margin-top: 1.2rem; padding: 0.7rem 1.2rem; border: 0; background: var(--ink); color: var(--paper);
  font: inherit; cursor: pointer;
}
.settings-form button { width: 100%; }
.err { color: #8a2b1e; font-size: 0.92rem; }
.info { color: #2d5016; font-size: 0.92rem; }
.banner { padding: 0.75rem 1rem; margin: 0 1.4rem 1rem; background: #eef6e8; border: 1px solid #c8ddb8; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.verify-block { margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.foot { margin-top: 1.2rem; font-size: 0.9rem; }
header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1.6rem 1.4rem 0.4rem; gap: 1rem;
}
.hdr-right { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.hdr-right a { color: var(--accent); }
.pill { font-size: 0.78rem; border: 1px solid var(--line); padding: 0.2rem 0.55rem; }
.note { padding: 0 1.4rem 1rem; max-width: 48rem; }
.grid { padding: 0 1.4rem 3rem; display: grid; gap: 0.85rem; }
.detail { padding: 0 1.4rem 3rem; display: grid; gap: 0.85rem; max-width: 52rem; }
.card { background: var(--card); border: 1px solid var(--line); padding: 1rem 1.1rem; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:hover { border-color: var(--accent); }
.card h2 { margin: 0.15rem 0 0.25rem; font-size: 1.15rem; }
.kind { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.meta, .addr, .empty, .muted { color: var(--muted); font-size: 0.9rem; }
.card p { margin: 0.35rem 0 0; line-height: 1.45; }
.transcript { line-height: 1.55; font-size: 0.95rem; }
.timeline { margin: 0; padding-left: 1.2rem; }
.timeline li { margin: 0.5rem 0; line-height: 1.4; }
.voice-grid { display: grid; gap: 0.75rem; }
.voice-card { display: flex; gap: 0.65rem; align-items: flex-start; border: 1px solid var(--line); padding: 0.75rem; cursor: pointer; }
.voice-card:has(input:checked) { border-color: var(--accent); background: #faf6ef; }
.voice-card input { margin-top: 0.35rem; }
.voice-card-body { flex: 1; }
.voice-card .tag { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.voice-card audio { width: 100%; margin-top: 0.5rem; height: 32px; }
.voice-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; }
.voice-card-head strong { margin-right: 0.15rem; }
.voice-play-btn {
  margin-left: auto;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
}
.voice-play-btn:active { background: #f0ebe3; }
.voice-grid-compact { gap: 0.55rem; }
.answering-voice-form { padding: 0 1.4rem 1rem; }
.settings-form { padding: 0 1.4rem 3rem; max-width: 52rem; display: grid; gap: 1rem; }
.settings-form section { margin: 0; }
.hours-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.prompt-preview pre {
  white-space: pre-wrap; word-break: break-word; font-size: 0.78rem;
  background: #f0ebe2; padding: 0.75rem; border: 1px solid var(--line); max-height: 320px; overflow: auto;
}
.prompt-preview { margin-top: 1rem; }
.desk-nav {
  display: flex; gap: 1rem; flex-wrap: wrap;
  padding: 0 1.4rem 0.75rem; border-bottom: 1px solid var(--line);
}
.desk-nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.desk-nav a.active { color: var(--accent); font-weight: 600; }
.shell-note { margin-top: 0; }
.receiver-form .toggle-row { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.75rem; }
.receiver-form .toggle-row input { width: auto; margin: 0; }
.login .dest-hint { font-size: 0.88rem; color: var(--muted); margin: 0.5rem 0 0; }
.inbox-tabs {
  display: flex; gap: 0.75rem; padding: 0 1.4rem 0.5rem;
}
.inbox-tabs a {
  color: var(--muted); text-decoration: none; font-size: 0.95rem;
  border-bottom: 2px solid transparent; padding-bottom: 0.2rem;
}
.inbox-tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.lead-card { display: flex; gap: 0.75rem; align-items: stretch; justify-content: space-between; }
.lead-link { flex: 1; color: inherit; text-decoration: none; display: block; }
.lead-link:hover h2 { color: var(--accent); }
.link-hint { margin-top: 0.5rem; font-size: 0.85rem; }
.btn-call {
  align-self: center; flex-shrink: 0;
  padding: 0.55rem 0.9rem; background: var(--accent); color: #fff;
  text-decoration: none; font-size: 0.88rem; white-space: nowrap;
}
.btn-call-lg { display: inline-block; margin: 0; }
.lead-header-top { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.lead-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-end; }
.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 0.45rem 0.75rem; font: inherit; cursor: pointer; margin: 0;
}
.transcript-thread { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.turn { padding: 0.75rem 0.85rem; border-radius: 4px; border: 1px solid var(--line); }
.turn-customer { background: #fff; }
.turn-assistant { background: #f7f2ea; border-color: #e8dfd3; }
.turn-unknown { background: #fafafa; }
.turn-head { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; font-size: 0.82rem; }
.turn-head strong { text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.turn-customer .turn-head strong { color: var(--ink); }
.turn-ts { color: var(--muted); font-size: 0.78rem; }
.turn-text { margin: 0; line-height: 1.5; font-size: 0.96rem; }
.lead-filters-wrap {
  padding: 0 1rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.lead-filter-status-scroll {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.15rem 0.25rem 0.1rem;
  margin: 0 -0.25rem;
}
.lead-filter-status-scroll::-webkit-scrollbar { display: none; }
.filter-pill {
  flex: 0 0 auto;
  display: inline-block;
  padding: 0.38rem 0.72rem;
  font-size: 0.82rem;
  line-height: 1.2;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
}
.filter-pill.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: #faf6f1;
  font-weight: 600;
}
.lead-filters { margin: 0; padding: 0; }
.lead-filter-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  align-items: center;
}
.filter-select-wrap { margin: 0; min-width: 0; }
.filter-select-wrap select {
  width: 100%;
  margin: 0;
  padding: 0.42rem 1.6rem 0.42rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%236b3a22' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") no-repeat right 0.55rem center;
  appearance: none;
  -webkit-appearance: none;
  color: var(--ink);
}
.filter-clear {
  grid-column: 1 / -1;
  justify-self: end;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.2rem 0.55rem;
  border: 1px dashed var(--line);
  border-radius: 999px;
}
.filter-clear:hover { color: var(--accent); border-color: var(--accent); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (min-width: 520px) {
  .lead-filters-wrap { padding: 0 1.4rem 0.75rem; }
  .lead-filter-controls {
    grid-template-columns: 1fr 1fr auto;
  }
  .filter-clear {
    grid-column: auto;
    justify-self: end;
  }
}
.lead-meta-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-bottom: 0.35rem; }
.lead-meta-row .kind { margin: 0; }
.pill.status-new { border-color: #c8ddb8; background: #eef6e8; }
.pill.status-contacted { border-color: #b8cce8; background: #eef3fa; }
.pill.status-scheduled { border-color: #d4c4f0; background: #f3eefb; }
.pill.status-won { border-color: #9bc49b; background: #e5f2e5; }
.pill.status-lost { border-color: #e0c4c4; background: #faf0f0; }
.pill.status-archived { border-color: var(--line); color: var(--muted); }
.pill.source { font-size: 0.72rem; }
.pill.callback-needs { border-color: #e8c4a8; background: #fff4e8; color: #6b4420; }
.pill.callback-handled { border-color: #b8d4b8; background: #eef8ee; color: #2d5a2d; }
.lead-notes { line-height: 1.45; }
.lead-edit-form { display: grid; gap: 0.75rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.lead-edit-form button { width: auto; margin-top: 0.25rem; }
.team-access-card { padding: 0.85rem 1rem 1rem; }
.team-access-note { padding: 0 0 0.65rem; margin: 0; font-size: 0.88rem; }
.team-form { padding: 0; max-width: none; }
.team-table {
  width: 100%; border-collapse: collapse; font-size: 0.82rem;
}
.team-table th {
  text-align: left; font-weight: 600; color: var(--muted);
  padding: 0.35rem 0.25rem; border-bottom: 1px solid var(--line);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.team-table td { padding: 0.2rem 0.25rem; vertical-align: middle; }
.team-table input, .team-table select {
  width: 100%; padding: 0.35rem 0.4rem; margin: 0; font-size: 0.82rem;
}
.team-table select { min-width: 5.5rem; }
.team-role .tag {
  display: inline-block; margin-left: 0.25rem; font-size: 0.65rem;
  vertical-align: middle;
}
.team-push { white-space: nowrap; font-size: 0.82rem; }
.team-push-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
}
.team-push-msg { display: block; font-size: 0.75rem; margin-top: 0.15rem; }
.team-push-msg.ok { color: #2d6a4f; }
.team-push-msg.err { color: #9b2226; }
.team-actions { width: 2rem; text-align: center; }
.btn-compact {
  width: auto; margin: 0; padding: 0.2rem 0.45rem; line-height: 1.2;
  font-size: 1rem;
}
.team-form-actions { margin-top: 0.65rem; }
.team-form-actions .btn-secondary { width: 100%; margin: 0; }
.team-row-add input, .team-row-add select { background: #faf6ef; }
@media (max-width: 520px) {
  .team-table th:nth-child(2), .team-table td.team-phone { display: none; }
}
