:root,
html[data-theme="light"] {
  --bg: #f6f1ea;
  --bg-2: #fffaf4;
  --card: #ffffff;
  --line: rgba(40, 28, 20, 0.1);
  --ink: #1c1612;
  --muted: #6f6358;
  --red: #d01222;
  --red-dim: rgba(208, 18, 34, 0.12);
  --good: #2f7d3a;
  --warn: #b36a12;
  --info: #2b6f8f;
  --hold: #6d635a;
  --shadow: 0 10px 22px rgba(40, 28, 20, 0.08);
  --tabbar: #fffdf9;
  --wash: rgba(208, 18, 34, 0.08);
  --poc: #b40f1c;
  --btn-2: #3a332c;
  --toast-bg: #1c1612;
  --toast-ink: #f6f1ea;
  --sheet-dim: rgba(28, 22, 18, 0.4);
  --desk: #e8e0d4;
  --tab: calc(64px + env(safe-area-inset-bottom));
}
html[data-theme="dark"] {
  --bg: #161210;
  --bg-2: #1e1914;
  --card: #241e18;
  --line: rgba(244, 238, 228, 0.1);
  --ink: #f4eee4;
  --muted: #b7aa9a;
  --red: #e11d2e;
  --red-dim: rgba(225, 29, 46, 0.16);
  --good: #7dba62;
  --warn: #e0a04a;
  --info: #6ea8c9;
  --hold: #8d7f72;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  --tabbar: #100e0c;
  --wash: rgba(225, 29, 46, 0.16);
  --poc: #ff8a93;
  --btn-2: #3a332c;
  --toast-bg: #fff;
  --toast-ink: #161210;
  --sheet-dim: rgba(0, 0, 0, 0.55);
  --desk: #0c0a09;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}
body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 0;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 400px at 80% -10%, var(--wash), transparent 50%),
    var(--bg);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 10px; }
.brand-name { font-weight: 800; letter-spacing: 0.01em; }
.brand-sub { color: var(--muted); font-size: 12px; }
.top-right { text-align: right; display: grid; justify-items: end; gap: 4px; }
.theme-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  min-height: 32px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}
.clock { font-size: 12px; color: var(--muted); }
.poc {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--red-dim);
  color: var(--poc);
}

.install {
  margin: 0 16px 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.install span { flex: 1; }
.install button, .sheet-close, .action {
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  padding: 8px 12px;
  min-height: 40px;
}
.ghost { background: transparent !important; color: var(--muted) !important; }

.view {
  flex: 1;
  padding: 8px 16px var(--tab);
  overflow: auto;
}
.kicker {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}
h1 {
  margin: 2px 0 12px;
  font-size: 26px;
  line-height: 1.15;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat, .card, .person, .chase {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.stat { padding: 12px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }

.card, .person, .chase {
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  text-align: left;
  width: 100%;
}
.card { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: start; }
.card-wide { grid-template-columns: 1fr auto; }
.when { color: var(--muted); font-size: 12px; font-weight: 700; }
.title { font-weight: 800; }
.meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--red-dim);
  color: var(--poc);
  white-space: nowrap;
}
.pill.good { background: rgba(125, 186, 98, 0.16); color: var(--good); }
.pill.warn { background: rgba(224, 160, 74, 0.16); color: var(--warn); }
.pill.info { background: rgba(110, 168, 201, 0.16); color: var(--info); }
.pill.hold { background: rgba(141, 127, 114, 0.18); color: var(--hold); }

.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.money { font-variant-numeric: tabular-nums; font-weight: 800; }
.note { color: var(--muted); font-size: 13px; line-height: 1.45; }

.person {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--red);
  color: #fff;
}
.list-head { margin: 16px 0 8px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.tabs {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--tabbar);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  min-height: 48px;
  padding: 6px 0;
}
.tabs svg { width: 20px; height: 20px; fill: currentColor; }
.tabs button.is-on { color: var(--ink); }
.tabs button.is-on svg { color: var(--red); }

.sheet[hidden],
.toast[hidden],
.install[hidden] {
  display: none !important;
}
.sheet {
  position: fixed;
  inset: 0;
  background: var(--sheet-dim);
  z-index: 40;
  display: grid;
  align-items: end;
}
.sheet-card {
  background: var(--bg-2);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 82dvh;
  overflow: auto;
}
.sheet-close { margin-bottom: 8px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab) + 12px);
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-ink);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 50;
  white-space: nowrap;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.action.secondary { background: var(--btn-2); color: #fff; }

@media (min-width: 720px) {
  body { background: var(--desk); }
  .app { min-height: 100dvh; box-shadow: 0 0 0 1px var(--line); }
}
