:root {
  --bg: #fbf6f1;
  --card: #ffffff;
  --ink: #2b1d1a;
  --muted: #7d6a64;
  --line: #eadfd6;
  --brand: #7a2e3a;
  --brand-ink: #ffffff;
  --brand-soft: #f6e6e3;
  --good: #2f7d4f;
  --good-soft: #e5f3ea;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(43, 29, 26, .06), 0 4px 16px rgba(43, 29, 26, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--brand); color: var(--brand-ink);
}
.brand { font-weight: 800; font-size: 19px; display: flex; gap: 8px; align-items: center; }
.icon-btn { background: transparent; border: 0; font-size: 22px; padding: 6px; cursor: pointer; }

main { max-width: 640px; margin: 0 auto; padding: 16px; outline: none; }

h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer; border: 0; width: 100%;
  text-align: left; font: inherit; color: inherit;
}
.list-item .title { font-weight: 700; }
.list-item .sub { color: var(--muted); font-size: 14px; }
.pill { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

label { display: block; font-weight: 700; font-size: 14px; margin: 12px 0 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; align-items: end; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 800; font-size: 16px; border: 0; border-radius: 14px;
  padding: 14px 18px; cursor: pointer; width: 100%;
  background: var(--brand); color: var(--brand-ink); text-decoration: none;
}
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: transparent; color: var(--brand); padding: 10px; }
.btn.danger { background: transparent; color: var(--bad); }
.btn.whats { background: #1f9d55; color: #fff; }
.btn + .btn { margin-top: 10px; }

.item-line {
  display: grid; grid-template-columns: 1fr 96px 36px; gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.item-line:last-child { border-bottom: 0; }
.item-line .x { background: none; border: 0; font-size: 20px; color: var(--muted); cursor: pointer; }

/* O "choque" */
.shock {
  border-radius: var(--radius); padding: 18px; margin: 12px 0;
  background: var(--bad-soft); color: var(--bad);
}
.shock.ok { background: var(--good-soft); color: var(--good); }
.shock .big { font-size: 30px; font-weight: 800; line-height: 1.1; margin: 4px 0; }
.shock p { color: var(--ink); }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.stat { background: var(--bg); border-radius: 12px; padding: 12px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 800; }
.stat.hl { background: var(--brand); color: #fff; }
.stat.hl .k { color: #f3d9dd; }

.breakdown { width: 100%; border-collapse: collapse; font-size: 15px; margin-top: 8px; }
.breakdown td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.breakdown td:last-child { text-align: right; font-weight: 700; }

.empty { text-align: center; padding: 28px 16px; }
.empty .emoji { font-size: 44px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  background: none; border: 0; font: inherit; font-size: 12px; font-weight: 700; color: var(--muted);
  padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.tab span { font-size: 22px; }
.tab.active { color: var(--brand); }

#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 700;
  opacity: 0; transition: .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }

.menu-preview {
  white-space: pre-wrap; background: #e7f6ec; border-radius: 12px; padding: 14px; font-size: 15px;
  border: 1px solid #cfe9d8;
}
.back { background: none; border: 0; color: var(--brand); font: inherit; font-weight: 700; padding: 0; margin-bottom: 8px; cursor: pointer; }
