:root {
  --paper: #f3eee4;
  --paper-2: #e8e0d2;
  --ink: #1a1714;
  --ink-soft: #5c5348;
  --card: #fffcf7;
  --line: #d9d0c2;
  --forest: #1e4a38;
  --forest-2: #163628;
  --copper: #c45c26;
  --copper-2: #a34718;
  --ok: #2f6f4e;
  --warn: #b45309;
  --danger: #9f2d2d;
  --shadow: 0 10px 30px rgba(26, 23, 20, 0.08);
  --radius: 18px;
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--forest);
  color: #f3eee4;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 13px;
}
.demo-switch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 12px;
}
.demo-switch button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 12px;
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 650;
}
.demo-switch button.on {
  background: var(--forest);
  border-color: var(--forest);
  color: #f3eee4;
}
.brand strong { display: block; font-size: 14px; }
.demo-pill {
  background: #efe3c8;
  color: #6b4e16;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.nav-bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255,252,247,0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.nav-bottom a {
  text-align: center;
  text-decoration: none;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 8px 4px;
  border-radius: 12px;
}
.nav-bottom a.active {
  background: var(--paper-2);
  color: var(--ink);
  font-weight: 600;
}

h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: -0.03em; }
h2 { font-size: 20px; margin: 0 0 12px; letter-spacing: -0.02em; }
.lede { color: var(--ink-soft); margin: 0 0 20px; }

.grid-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 26px; letter-spacing: -0.04em; }
.stat span { color: var(--ink-soft); font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.muted { color: var(--ink-soft); font-size: 13px; }
.tiny { font-size: 12px; color: var(--ink-soft); }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.pill-offer { background: #efe3c8; color: #6b4e16; }
.pill-job { background: #d7e8de; color: #1e4a38; }
.pill-done { background: #e4e4e0; color: #3f3f3a; }
.pill-inv { background: #e1d8f0; color: #4c2d7a; }
.pill-demo { background: #f3d6c8; color: #8a3416; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 16px;
  padding: 16px 18px;
  font-size: 17px;
  font-weight: 650;
  text-decoration: none;
  min-height: 56px;
}
.btn-primary { background: var(--forest); color: #f6f1e8; }
.btn-primary:active { background: var(--forest-2); }
.btn-copper { background: var(--copper); color: white; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 18px; }
.actions { display: grid; gap: 10px; margin-top: 16px; }
.actions-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.fab-wrap { margin: 8px 0 20px; }

.list-item {
  display: block;
  text-decoration: none;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }

.customer {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 8px;
  min-height: 64px;
}
.customer.selected { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(30,74,56,0.15); }
.avatar {
  width: 42px; height: 42px; border-radius: 14px;
  background: var(--paper-2);
  display: grid; place-items: center;
  font-weight: 700;
}

.record {
  display: grid;
  place-items: center;
  padding: 28px 8px 12px;
}
.rec-btn {
  width: 168px; height: 168px; border-radius: 50%;
  border: 0;
  background: var(--copper);
  color: white;
  font-size: 20px;
  font-weight: 700;
  box-shadow: 0 16px 40px rgba(196,92,38,0.35);
}
.rec-btn.live {
  animation: pulse 1.2s ease-in-out infinite;
  background: var(--danger);
}
.timer {
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.live-final { margin: 8px 0 4px; font-size: 18px; line-height: 1.4; }
.live-interim { margin: 0; min-height: 1.4em; font-style: italic; }
@keyframes pulse {
  50% { transform: scale(1.04); }
}

.waves {
  height: 36px;
  display: flex;
  align-items: end;
  gap: 4px;
  margin-top: 16px;
}
.waves i {
  display: block;
  width: 5px;
  background: var(--copper);
  border-radius: 3px;
  animation: bar 0.9s ease-in-out infinite;
}
.waves i:nth-child(2) { animation-delay: .1s }
.waves i:nth-child(3) { animation-delay: .2s }
.waves i:nth-child(4) { animation-delay: .15s }
.waves i:nth-child(5) { animation-delay: .05s }
@keyframes bar {
  0%,100% { height: 8px; }
  50% { height: 32px; }
}

textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.45; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th { text-align: left; color: var(--ink-soft); font-weight: 600; font-size: 12px; padding: 6px 4px; }
td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.understood dt { color: var(--ink-soft); font-size: 12px; margin-top: 10px; }
.understood dd { margin: 2px 0 0; font-weight: 650; }

.insight {
  background: #eaf3ee;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--forest-2);
  font-size: 14px;
  margin: 12px 0;
}

.doc {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px 18px;
  font-size: 13px;
}
.doc-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.doc h3 { margin: 0 0 4px; font-size: 22px; }
.doc .org { color: var(--ink-soft); font-size: 12px; }

.toast {
  background: var(--forest);
  color: #f6f1e8;
  border-radius: 16px;
  padding: 14px 16px;
  margin: 12px 0;
}
.toast small { display: block; opacity: 0.85; margin-top: 4px; }

.timeline { border-left: 2px solid var(--line); margin: 8px 0 0 12px; padding-left: 16px; }
.tl-item { margin-bottom: 16px; position: relative; }
.tl-item::before {
  content: "";
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--forest);
  position: absolute; left: -22px; top: 4px;
}
.photo-ph {
  height: 140px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, #cfc4b0, #e8dfd0);
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-weight: 650;
  margin-bottom: 6px;
  overflow: hidden;
}
.photo-ph img { width: 100%; height: 100%; object-fit: cover; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }

.banner-demo {
  background: #f8eadf;
  color: #7a3414;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.edit-line {
  display: grid;
  grid-template-columns: 1fr 64px 78px 56px;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 650;
  min-height: 48px;
}
.chip:active { background: var(--paper-2); }
.guess {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 6px 0 12px;
}
.internal {
  background: #1e4a38;
  color: #f3eee4;
  border: 0;
}
.internal h2, .internal .tiny, .internal p { color: #d5e4db; }
.internal strong { color: #fff; }
.stepper {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 4px 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.stepper span { white-space: nowrap; padding: 6px 8px; border-radius: 8px; }
.stepper .on { background: var(--forest); color: #f6f1e8; }
.warn-card { background: #f8eadf; border-color: #e8c8a8; }

.nav-bottom a { min-height: 52px; display: grid; place-items: center; font-size: 13px; }

@media (min-width: 860px) {
  .app { padding-bottom: 32px; }
  .nav-bottom {
    position: sticky;
    top: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    margin-bottom: 18px;
    grid-template-columns: repeat(4, max-content);
    justify-content: start;
    gap: 8px;
    padding: 8px;
  }
  .nav-bottom a { padding: 10px 14px; }
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}

html.gated .app { visibility: hidden; }
.gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--paper);
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.gate-card h1 { margin: 0 0 8px; font-size: 22px; }
.gate-card p { margin: 0 0 16px; color: var(--ink-soft); }
.gate-card input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 16px;
}
.gate-card button {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--forest);
  color: #f3eee4;
  font-weight: 700;
  font-size: 16px;
}
.gate-err { color: var(--danger) !important; }

@media print {
  body { background: white; }
  .topbar, .nav-bottom, .no-print, .actions, .fab-wrap, .banner-demo, .demo-pill, .internal, .demo-switch, .gate { display: none !important; }
  .app { max-width: none; padding: 0; }
  .card, .doc { box-shadow: none; border: 0; }
}
