:root {
  --bg: #09090c;
  --surface: #131318;
  --surface-2: #1b1b22;
  --surface-3: #24242d;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #f5f3ee;
  --muted: #8d8c96;
  --faint: #5c5b66;
  --accent: #ff3b3b;
  --accent-2: #c8102e;
  --accent-soft: rgba(255, 59, 59, 0.13);
  --grad: linear-gradient(135deg, #ff5a4f 0%, #e8172f 55%, #b3001b 100%);
  --wa: #25d366;
  --danger: #ff5c63;
  --radius: 22px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input { outline: none; }
.num { font-variant-numeric: tabular-nums; }

/* ambient glow behind everything */
body::before {
  content: "";
  position: fixed;
  inset: -20% -40% auto;
  height: 60vh;
  background: radial-gradient(closest-side, rgba(230, 20, 40, 0.16), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 120px);
}

.view { animation: viewIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 18px;
}
.topbar h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.12s, background 0.2s;
}
.icon-btn:active { transform: scale(0.92); background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; margin: 6px 0 26px; }
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--grad);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 10px 30px -8px rgba(230, 20, 40, 0.6);
}
.brand-mark svg { width: 28px; height: 28px; }
.brand-text small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.brand-text strong {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  padding: 26px 22px 22px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(230, 20, 40, 0.28), transparent 60%),
    linear-gradient(180deg, #1d1013, #141317);
  border: 1px solid rgba(255, 60, 60, 0.2);
}
.hero-mark {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 64px;
  color: #fff;
  opacity: 0.14;
  pointer-events: none;
}
.hero-mark svg { width: 100%; height: auto; display: block; }
.hero h2 {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-weight: 800;
  margin: 0 0 8px;
  max-width: 85%;
}
.hero h2 em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.hero .live-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 4px 0 18px;
}
.hero .live-total {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  height: 54px;
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field input { flex: 1; min-width: 0; background: none; border: 0; height: 100%; font-size: 16px; }
.field input::placeholder { color: var(--faint); }
.field .prefix { color: var(--muted); font-size: 18px; }

/* ---------- buttons ---------- */
.btn {
  height: 56px;
  border-radius: 18px;
  font-weight: 800;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 0 20px;
  transition: transform 0.12s, filter 0.2s, opacity 0.2s;
  letter-spacing: -0.01em;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }
.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 14px 34px -12px rgba(230, 20, 40, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-ghost { background: var(--surface-2); border: 1px solid var(--line-2); }
.btn-wa { background: var(--wa); color: #052e14; box-shadow: 0 14px 34px -14px rgba(37, 211, 102, 0.7); }
.btn-danger { background: rgba(255, 92, 99, 0.12); color: var(--danger); border: 1px solid rgba(255, 92, 99, 0.25); }
.btn-sm { height: 44px; border-radius: 14px; font-size: 15px; }
.btn-row { display: flex; gap: 10px; }
.link-btn { color: var(--muted); font-size: 14px; font-weight: 700; padding: 10px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 30px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 12px;
}
.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat span { color: var(--muted); font-size: 12px; font-weight: 600; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 12px;
}
.section-title h3 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 800;
}
.section-title span { color: var(--faint); font-size: 13px; font-weight: 700; }

/* ---------- history ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.history-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  text-align: left;
  width: 100%;
  transition: transform 0.12s, background 0.2s;
}
.history-card:active { transform: scale(0.98); background: var(--surface-2); }
.date-badge {
  width: 52px;
  height: 56px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.date-badge b { font-family: var(--font-display); font-size: 20px; line-height: 1; }
.date-badge small { font-size: 11px; color: var(--accent); font-weight: 800; text-transform: uppercase; margin-top: 3px; }
.history-card .info { flex: 1; min-width: 0; }
.history-card .info strong { display: block; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-card .info span { color: var(--muted); font-size: 13px; }
.history-card .amount { text-align: right; }
.history-card .amount b { display: block; font-family: var(--font-display); font-size: 17px; }
.history-card .amount span { color: var(--muted); font-size: 12px; }

.empty {
  text-align: center;
  padding: 36px 20px;
  border: 1.5px dashed var(--line-2);
  border-radius: 22px;
  color: var(--muted);
}
.empty .emoji { font-size: 40px; display: block; margin-bottom: 8px; }
.empty p { margin: 0; font-size: 14px; }

/* ---------- active rolê ---------- */
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 99px;
  background: rgba(37, 211, 102, 0.1);
  color: #5ff09a;
  font-size: 13px;
  font-weight: 800;
  border: 1px solid rgba(37, 211, 102, 0.2);
  flex-shrink: 0;
}
.live-chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(95, 240, 154, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(95, 240, 154, 0); }
  100% { box-shadow: 0 0 0 0 rgba(95, 240, 154, 0); }
}

.total-card {
  position: relative;
  border-radius: 28px;
  padding: 22px;
  margin-bottom: 22px;
  background: var(--grad);
  color: #fff;
  overflow: hidden;
  box-shadow: 0 24px 50px -24px rgba(230, 20, 40, 0.8);
}
.total-card::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -70px;
  bottom: -110px;
  border-radius: 50%;
  border: 30px solid rgba(255, 255, 255, 0.14);
}
.total-card small { font-weight: 800; font-size: 13px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.08em; }
.total-card .big {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 4px 0 10px;
}
.total-card .big.bump { animation: bump 0.28s; }
@keyframes bump { 50% { transform: scale(1.05); } }
.total-card .meta { display: flex; gap: 8px; flex-wrap: wrap; }
.total-card .meta span {
  background: rgba(0, 0, 0, 0.12);
  padding: 6px 11px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 800;
}

.quick { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 24px; padding: 2px 16px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 10px 10px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.12s;
}
.quick button:active { transform: scale(0.94); background: var(--surface-2); }
.quick button .e { font-size: 18px; }
.quick button .p { color: var(--muted); font-weight: 600; font-size: 13px; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  animation: itemIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes itemIn { from { opacity: 0; transform: scale(0.96); } }
.emoji-tile {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 24px;
  flex-shrink: 0;
}
.item .info { flex: 1; min-width: 0; text-align: left; }
.item .info strong { display: block; font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .info span { color: var(--muted); font-size: 13px; }
.item .info span b { color: var(--text); font-weight: 700; }

.stepper {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 3px;
  flex-shrink: 0;
}
.stepper button {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  transition: transform 0.1s, background 0.15s;
}
.stepper button:active { transform: scale(0.88); }
.stepper .plus { background: var(--grad); color: #fff; }
.stepper .qty {
  min-width: 30px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
}

/* ---------- bottom dock ---------- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 14px 16px calc(var(--safe-bottom) + 14px);
  background: linear-gradient(180deg, transparent, var(--bg) 35%);
}
.dock-inner { max-width: 488px; margin: 0 auto; display: flex; gap: 10px; }
.dock .btn-ghost { flex: 0 0 auto; width: auto; }

/* ---------- sheet ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  animation: fadeIn 0.2s;
}
.backdrop.out { animation: fadeOut 0.2s forwards; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 51;
  max-width: 520px;
  margin: 0 auto;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  padding: 10px 16px calc(var(--safe-bottom) + 16px);
  animation: sheetUp 0.34s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.sheet.out { animation: sheetDown 0.22s forwards ease-in; }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(100%); } }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: 0 auto 14px; flex-shrink: 0; }
.sheet h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}
.sheet .scroll { overflow-y: auto; margin: 0 -16px; padding: 0 16px; flex: 1; min-height: 0; }
.sheet .field { background: var(--surface-2); }

.catalog-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 6px;
  border-radius: 16px;
  text-align: left;
  transition: background 0.15s;
}
.catalog-row:active { background: var(--surface-2); }
.catalog-row .info { flex: 1; min-width: 0; }
.catalog-row .info strong { display: block; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catalog-row .info span { color: var(--muted); font-size: 13px; }
.catalog-row .edit {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.catalog-row .edit svg { width: 17px; height: 17px; }
.catalog-row .add {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
}
.catalog-row .in-role {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 99px;
  margin-left: 6px;
}
.create-box {
  border: 1px solid rgba(255, 59, 59, 0.3);
  background: linear-gradient(180deg, rgba(255, 59, 59, 0.08), transparent);
  border-radius: 20px;
  padding: 14px;
  margin-bottom: 14px;
}
.create-box .label { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.create-box .label b { color: var(--text); }
.hint { color: var(--faint); font-size: 13px; text-align: center; padding: 18px 0 6px; }

/* ---------- finish ---------- */
.lead { color: var(--muted); margin: -6px 0 20px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 7px;
  border-radius: 99px;
  background: var(--surface);
  border: 1.5px solid var(--line-2);
  font-weight: 800;
  font-size: 15px;
  transition: all 0.18s;
}
.chip .av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #1a0f00;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); }
.chip:not(.on) { color: var(--muted); }
.chip:not(.on) .av { filter: grayscale(1) brightness(0.6); }
.chip .x { font-size: 16px; opacity: 0.6; margin-left: 2px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 12px;
  width: 100%;
  text-align: left;
}
.toggle-row strong { display: block; font-weight: 800; }
.toggle-row span { color: var(--muted); font-size: 13px; }
.switch {
  width: 52px;
  height: 32px;
  border-radius: 99px;
  background: var(--surface-3);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }

.split-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
.split-preview div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}
.split-preview div.hl { border-color: rgba(255, 59, 59, 0.35); background: linear-gradient(180deg, rgba(255, 59, 59, 0.1), var(--surface)); }
.split-preview small { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.split-preview b { display: block; font-family: var(--font-display); font-size: 24px; letter-spacing: -0.02em; margin-top: 2px; }

/* ---------- receipt ---------- */
.receipt {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  overflow: hidden;
  margin-bottom: 18px;
}
.receipt-head {
  padding: 22px 20px 20px;
  background:
    radial-gradient(100% 120% at 100% 0%, rgba(230, 20, 40, 0.3), transparent 60%),
    var(--surface-2);
  border-bottom: 1.5px dashed var(--line-2);
}
.receipt-head .tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.receipt-head h2 {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
}
.receipt-head p { margin: 0; color: var(--muted); font-size: 14px; }
.receipt-body { padding: 18px 20px; }
.receipt-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  font-size: 15px;
}
.receipt-line .q { color: var(--accent); font-weight: 800; min-width: 46px; font-size: 13px; }
.receipt-caption { font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.receipt-line .n { flex: 1; min-width: 0; }
.receipt-line .n small { display: block; color: var(--faint); font-size: 12px; }
.receipt-line .v { font-weight: 700; }
.receipt-sep { border-top: 1.5px dashed var(--line-2); margin: 12px 0; }
.receipt-line.muted { color: var(--muted); font-size: 14px; padding: 3px 0; }
.receipt-line.total { font-size: 18px; font-weight: 800; }
.receipt-line.total .v { font-family: var(--font-display); font-size: 22px; }

.per-head {
  margin: 0 20px 20px;
  border-radius: 20px;
  padding: 18px;
  background: var(--grad);
  color: #fff;
  text-align: center;
}
.per-head small { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.7; }
.per-head b { display: block; font-family: var(--font-display); font-size: 40px; letter-spacing: -0.04em; line-height: 1.1; }
.per-head span { font-weight: 700; font-size: 14px; opacity: 0.75; }

.people { display: flex; flex-direction: column; gap: 2px; padding: 0 20px 20px; }
.person { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.person .av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #1a0f00;
}
.person .n { flex: 1; font-weight: 700; }
.person .v { font-weight: 800; }

.actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 96px);
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px 12px 18px;
  border-radius: 16px;
  background: #f5f3ee;
  color: #111;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.7);
  animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  max-width: calc(100% - 32px);
  white-space: nowrap;
}
.toast.out { animation: fadeOut 0.2s forwards; }
.toast button { color: #d0101f; font-weight: 800; padding: 4px 6px; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px) scale(0.95); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
