:root {
  --bg: #F3E9D3;
  --surface: #FBF3E3;
  --surface-2: #EDDFC0;
  --ink: #3B2A1E;
  --muted: #7E6850;
  --red: #A6321E;
  --gold: #8A6316;
  --green: #4F7236;
  --amber: #B0700F;
  --border: rgba(59, 42, 30, 0.14);
  --border-strong: rgba(59, 42, 30, 0.28);
  --on-red: #FBF3E3;
  --shadow: 0 1px 2px rgba(59, 42, 30, 0.08);
  --display: "Fraunces", Georgia, serif;
  --body: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1E120A; --surface: #2A1A10; --surface-2: #3A2416; --ink: #F3E7D2; --muted: #B79A78;
    --red: #E2806A; --gold: #D9AE45; --green: #93B571; --amber: #E3A548;
    --border: rgba(243, 231, 210, 0.13); --border-strong: rgba(243, 231, 210, 0.26);
    --on-red: #1E120A; --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #1E120A; --surface: #2A1A10; --surface-2: #3A2416; --ink: #F3E7D2; --muted: #B79A78;
  --red: #E2806A; --gold: #D9AE45; --green: #93B571; --amber: #E3A548;
  --border: rgba(243, 231, 210, 0.13); --border-strong: rgba(243, 231, 210, 0.26);
  --on-red: #1E120A; --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--red); }
.boot { padding: 40vh 16px; text-align: center; color: var(--muted); }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }

/* header */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  border-bottom: 1px solid var(--border); padding: calc(10px + env(safe-area-inset-top)) 0 10px;
}
.top-inner { max-width: 640px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 10px; }
.top h1 { font-family: var(--display); font-weight: 600; font-size: 21px; margin: 0; line-height: 1.15; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .sub { font-size: 12.5px; color: var(--muted); }

/* bottom nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface);
  border-top: 1px solid var(--border-strong); padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.nav button {
  background: none; border: 0; padding: 9px 2px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11.5px; font-weight: 600; color: var(--muted); cursor: pointer; position: relative;
}
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--red); }
.nav .dot { position: absolute; top: 5px; left: calc(50% + 8px); min-width: 17px; height: 17px; border-radius: 9px; background: var(--red); color: var(--on-red); font-size: 10.5px; line-height: 17px; padding: 0 4px; }

/* type */
h2 { font-family: var(--display); font-weight: 600; font-size: 19px; margin: 22px 0 10px; }
h3 { font-size: 13px; font-weight: 600; color: var(--gold); margin: 18px 0 8px; text-transform: none; letter-spacing: 0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.big { font-family: var(--display); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* cards & rows */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.warn { border-color: var(--amber); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.grid2 .card { margin: 0; }
.stat .label { font-size: 12.5px; color: var(--muted); }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.row { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .meta { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.row .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.row.click { cursor: pointer; }
.row.sub { padding-left: 26px; background: var(--bg); }
.empty { padding: 22px 14px; color: var(--muted); text-align: center; font-size: 14px; }

/* chips + status */
.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border-strong); color: var(--muted); white-space: nowrap; }
.chip.pending { color: var(--amber); border-color: var(--amber); }
.chip.approved, .chip.yes { color: var(--green); border-color: var(--green); }
.chip.rejected, .chip.no { color: var(--red); border-color: var(--red); }
.chip.maybe { color: var(--gold); border-color: var(--gold); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; margin: 14px 0 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.filter { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 500; cursor: pointer; }
.filter.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* bars */
.bar { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin: 8px 0 4px; }
.bar > div { height: 100%; background: var(--gold); border-radius: 6px; }
.bar.over > div { background: var(--red); }

/* buttons */
.btn {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; padding: 10px 14px;
  font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--red); border-color: var(--red); color: var(--on-red); }
.btn.ok { background: var(--green); border-color: var(--green); color: var(--on-red); }
.btn.ghost { background: none; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.fab {
  position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 5;
  background: var(--red); color: var(--on-red); border: 0; border-radius: 99px; padding: 13px 20px; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22); cursor: pointer;
}
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.icon-btn svg { width: 19px; height: 19px; }

/* forms */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
input.i, select.i, textarea.i {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 16px;
}
textarea.i { min-height: 80px; resize: vertical; }
input.i:focus, select.i:focus, textarea.i:focus { outline: 2px solid var(--gold); outline-offset: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search { margin: 4px 0 10px; }
.err { color: var(--red); font-size: 13.5px; margin: 6px 0; min-height: 1em; }
.pin { letter-spacing: 0.6em; text-align: center; font-size: 24px !important; font-variant-numeric: tabular-nums; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(20, 10, 4, 0.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; }

/* guests */
.guest-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.toggle { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.toggle.on-called { background: var(--green); border-color: var(--green); color: var(--on-red); }
.toggle.on-no_answer { background: var(--amber); border-color: var(--amber); color: var(--on-red); }
.toggle.on-yes { background: var(--green); border-color: var(--green); color: var(--on-red); }
.toggle.on-no { background: var(--red); border-color: var(--red); color: var(--on-red); }
.toggle.on-maybe { background: var(--gold); border-color: var(--gold); color: var(--on-red); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.stepper button { border: 0; background: var(--surface); width: 30px; height: 30px; cursor: pointer; font-size: 16px; }
.stepper span { min-width: 26px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }

/* AI chat */
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { padding: 10px 13px; border-radius: 12px; max-width: 88%; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.msg.user { align-self: flex-end; background: var(--red); color: var(--on-red); }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.chat-input { display: flex; gap: 8px; position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 0; }
.chat-input textarea { min-height: 46px; height: 46px; }

.menu .row { align-items: center; }
.menu .row svg { width: 20px; height: 20px; color: var(--gold); flex-shrink: 0; }
.hero { padding: 48px 0 10px; }
.hero h1 { font-family: var(--display); font-weight: 600; font-size: 34px; margin: 0 0 6px; }
.feature { display: flex; gap: 12px; margin: 14px 0; }
.feature b { display: block; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl td, .tbl th { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
.tbl td:first-child, .tbl th:first-child { text-align: left; }
.tbl th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.pos { color: var(--green); }
.neg { color: var(--red); }
@media (max-width: 380px) { .two { grid-template-columns: 1fr; } .big { font-size: 22px; } }
.click { cursor: pointer; }
