/* Splitwide Open — Splitwise-flavored skin. No framework, no build.
   Palette: teal-green brand, green = you're owed / you lent,
   orange = you owe / you borrowed. Light, card-based, mobile-first. */

:root {
  --brand: #1cc29f;          /* Splitwise teal-green */
  --brand-dark: #17a589;
  --brand-ink: #ffffff;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --text: #2b2f33;
  --muted: #8a94a0;
  --line: #ededf0;
  --owed: #1aa179;           /* positive: you're owed / you lent (green) */
  --owe: #fe5e3a;            /* negative: you owe / you borrowed (orange) */
  --shadow: 0 1px 2px rgba(18, 38, 33, 0.05), 0 6px 18px rgba(18, 38, 33, 0.05);
  --radius: 12px;
  --maxw: 680px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); }
h1 { font-size: 21px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
h3 { font-size: 12px; margin: 14px 0 8px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.empty { padding: 8px 2px; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 14px; }

/* ---- app bar (the instantly-Splitwise green header) ---- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px;
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: 0 1px 0 rgba(0,0,0,0.05), 0 2px 10px rgba(28,194,159,0.25);
}
.appbar__brand { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 17px; letter-spacing: -0.01em; }
.appbar__brand .logo {
  width: 26px; height: 26px; border-radius: 7px; background: rgba(255,255,255,0.18);
  display: grid; place-items: center; font-size: 15px;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: rgba(255,255,255,0.5); }
.status-dot--on { background: #eafff7; box-shadow: 0 0 0 3px rgba(255,255,255,0.25); }
.status-dot--off { background: #ffd9cc; box-shadow: 0 0 0 3px rgba(255,255,255,0.2); }

main.container { padding-top: 16px; padding-bottom: 56px; display: grid; gap: 14px; }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row .grow { flex: 1 1 150px; }
.grid { display: grid; gap: 10px; }

label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #4a5158; }
input, select { width: 100%; padding: 11px 12px; border: 1px solid #dfe3e8; border-radius: 10px; background: #fff; color: var(--text); font: inherit; }
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(28,194,159,0.18); }

/* ---- buttons ---- */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 650;
  border: 1px solid #dfe3e8; background: #fff; color: var(--text);
  padding: 9px 15px; border-radius: 999px;
  transition: transform .04s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: #cfd4da; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; box-shadow: 0 2px 8px rgba(28,194,159,0.35); }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--brand-dark); padding-left: 8px; padding-right: 8px; }
.btn--ghost:hover { background: rgba(28,194,159,0.08); }
.back { color: var(--muted); margin: -4px 0 6px -4px; font-weight: 600; }
.icon-btn { cursor: pointer; border: none; background: transparent; color: var(--muted); font-size: 14px; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ---- avatars ---- */
.avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
  text-transform: uppercase; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}
.avatar--sm { width: 26px; height: 26px; font-size: 11px; }

/* ---- top bar inside a group ---- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.topbar__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.topbar__actions { display: flex; gap: 8px; }
code.invite { cursor: pointer; background: var(--bg); padding: 2px 8px; border-radius: 7px; border: 1px solid var(--line); font-size: 12px; color: var(--text); }
.pill { font-size: 11.5px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); }
.pill--warn { color: var(--owe); border-color: rgba(254,94,58,0.35); background: rgba(254,94,58,0.06); }
.pill--ok { color: var(--owed); border-color: rgba(26,161,121,0.35); background: rgba(26,161,121,0.07); }

/* ---- balance hero (the big "you owe / you are owed") ---- */
.hero { text-align: center; padding: 22px 16px 18px; }
.hero__label { color: var(--muted); font-size: 13px; }
.hero__amount { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.hero--owed .hero__amount { color: var(--owed); }
.hero--owe .hero__amount { color: var(--owe); }
.hero--zero .hero__amount { color: var(--text); font-size: 22px; }

/* ---- balances list ---- */
.balances { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.balances li { display: flex; align-items: center; gap: 11px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.balances li:last-child { border-bottom: none; }
.balances .who { flex: 1; min-width: 0; font-weight: 600; }
.bal { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; font-size: 13px; white-space: nowrap; }
.bal small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.bal--pos { color: var(--owed); }
.bal--neg { color: var(--owe); }
.bal--zero { color: var(--muted); }

.settle ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.settle li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line); }
.settle li strong { color: var(--owe); font-variant-numeric: tabular-nums; }

/* ---- activity feed (Splitwise-style rows) ---- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed__item {
  display: grid;
  grid-template-columns: 38px 40px 1fr auto auto;
  align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line);
}
.feed__item:last-child { border-bottom: none; }
.feed__date { text-align: center; line-height: 1.05; color: var(--muted); }
.feed__date .m { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.feed__date .d { display: block; font-size: 17px; font-weight: 700; color: #6b7480; }
.feed__cat { width: 40px; height: 40px; border-radius: 11px; background: var(--bg); display: grid; place-items: center; font-size: 19px; border: 1px solid var(--line); }
.feed__body { min-width: 0; display: grid; gap: 1px; }
.feed__title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed__sub { font-size: 12px; color: var(--muted); }
.feed__lent { text-align: right; line-height: 1.15; white-space: nowrap; }
.feed__lent .lbl { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.feed__lent .amt { display: block; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.feed__lent--pos .amt { color: var(--owed); }
.feed__lent--neg .amt { color: var(--owe); }
.feed__lent--neutral .amt { color: var(--muted); font-weight: 600; }
.feed__tools { display: flex; gap: 1px; opacity: 0; transition: opacity .12s ease; }
.feed__item:hover .feed__tools { opacity: 1; }

/* ---- device / integrity ---- */
.device code { background: var(--bg); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); font-size: 12px; }
.device .row { margin-top: 10px; align-items: center; }
.tamper { border-color: rgba(254,94,58,0.55); background: #fff6f3; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tamper strong { color: var(--owe); }
.tamper .btn { margin-left: auto; }

/* ---- auth ---- */
.auth { max-width: 400px; margin: 7vh auto 0; }
.auth__tabs { display: flex; gap: 4px; margin-bottom: 18px; background: var(--bg); padding: 4px; border-radius: 999px; }
.auth__tabs button { flex: 1; cursor: pointer; border: none; background: transparent; color: var(--muted); padding: 9px; border-radius: 999px; font-weight: 700; font: inherit; }
.auth__tabs button.is-active { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow); }

/* ---- groups list ---- */
.group-card {
  width: 100%; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow);
  font: inherit; color: var(--text);
}
.group-card:hover { border-color: rgba(28,194,159,0.5); }
.group-card__name { font-weight: 700; font-size: 16px; }
.group-card__meta { color: var(--muted); font-size: 12.5px; }
.group-card .chev { margin-left: auto; color: #cfd4da; font-size: 20px; }

/* ---- modal ---- */
.modal { border: none; border-radius: 16px 16px 0 0; background: var(--surface); color: var(--text); padding: 0; width: min(560px, 100vw); max-height: 92vh; overflow-y: auto; margin: auto auto 0; box-shadow: var(--shadow); }
@media (min-width: 600px) { .modal { border-radius: 16px; margin: auto; } }
.modal::backdrop { background: rgba(20,30,28,0.45); }
.modal__form { padding: 20px; }
.modal__form h2 { color: var(--text); text-transform: none; letter-spacing: -0.01em; font-size: 18px; margin-bottom: 6px; }
.modal__actions { justify-content: flex-end; margin-top: 6px; }
.participants { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); }
.participants legend { padding: 0 6px; font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }

/* ---- toasts ---- */
.toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(420px, calc(100vw - 28px)); }
.toast { padding: 11px 14px; border-radius: 10px; background: #2b2f33; color: #fff; box-shadow: var(--shadow); font-size: 13.5px; opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
.toast--in { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--brand-dark); }
.toast--error { background: var(--owe); }

.footer { padding: 22px 16px 36px; text-align: center; font-size: 12px; }
.footer a { font-weight: 600; }

/* ---- "how it works" explainer ---- */
.explain__intro { color: #5a6169; margin: 0 0 16px; font-size: 14px; }
.explain__intro b { color: var(--text); }
.explain__steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 15px; }
.explain__steps li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; }
.explain__n { width: 26px; height: 26px; border-radius: 50%; background: rgba(28,194,159,0.14); color: var(--brand-dark); font-weight: 800; font-size: 13px; display: grid; place-items: center; }
.explain__t { font-weight: 700; }
.explain__d { color: #5a6169; font-size: 13.5px; margin-top: 1px; }
.explain__tool { display: inline-block; margin-top: 6px; font-size: 11px; color: var(--brand-dark); background: rgba(28,194,159,0.10); border: 1px solid rgba(28,194,159,0.2); border-radius: 999px; padding: 2px 9px; font-weight: 600; }
.explain__note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); color: #5a6169; font-size: 13px; }
.explain__note b { color: var(--text); }

/* ---- device pairing ---- */
.paircode {
  font: 800 30px/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.18em; text-align: center; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.paircode.sas { color: var(--brand-dark); letter-spacing: 0.22em; }

@media (max-width: 560px) {
  .topbar__actions { width: 100%; }
  .topbar__actions .btn { flex: 1; }
  .feed__item { grid-template-columns: 34px 36px 1fr auto; }
  .feed__tools { grid-column: 1 / -1; justify-content: flex-end; opacity: 1; }
}
