/* ───────────────────────── Evenly · Midnight theme ───────────────────────── */
:root {
  --bg: #0a0b0e;
  --surface: #14161c;
  --surface-2: #1a1d25;
  --surface-3: #21252f;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #eef1f5;
  --muted: #8a93a3;
  --faint: #5a6373;

  --accent: #34d399;
  --accent-2: #10b981;
  --accent-ink: #04130d;
  --accent-glow: rgba(52, 211, 153, 0.22);

  --danger: #fb7185;

  --r: 24px;
  --r-md: 18px;
  --r-sm: 13px;

  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.8);
  --shadow-pop: 0 24px 60px -12px rgba(0, 0, 0, 0.7);

  --font-display: 'Clash Display', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'General Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* Atmospheric background: emerald glow + faint grain over near-black */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 80% -10%, rgba(52, 211, 153, 0.16), transparent 55%),
    radial-gradient(90% 60% at -10% 10%, rgba(56, 120, 255, 0.08), transparent 50%),
    radial-gradient(100% 80% at 50% 120%, rgba(16, 185, 129, 0.07), transparent 60%),
    var(--bg);
}
.atmosphere::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hidden { display: none !important; }

/* ───────────────────────── Brand ───────────────────────── */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  color: var(--accent-ink);
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  border-radius: 11px;
  box-shadow: 0 6px 18px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.4);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.brand-name .dot { color: var(--accent); }
.brand--sm .brand-mark { width: 28px; height: 28px; font-size: 16px; border-radius: 9px; }
.brand--sm .brand-name { font-size: 17px; }

/* ───────────────────────── Login ───────────────────────── */
.login {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--safe-t) + 32px) 26px calc(var(--safe-b) + 28px);
  max-width: 460px;
  margin-inline: auto;
}
.login-inner { animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.login-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(34px, 11vw, 46px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 30px 0 12px;
}
.login-sub { color: var(--muted); font-size: 15.5px; margin: 0 0 28px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.field { position: relative; }

input {
  font-family: var(--font-body);
  font-size: 16px; /* prevents iOS zoom-on-focus */
  color: var(--text);
}
#password {
  width: 100%;
  padding: 17px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}
#password::placeholder { color: var(--faint); }
#password:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 20px;
  font-family: var(--font-body); font-weight: 600; font-size: 16px;
  color: var(--accent-ink);
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  border: none; border-radius: var(--r-md);
  cursor: pointer;
  box-shadow: 0 10px 26px -10px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.35);
  transition: transform 0.12s ease, box-shadow 0.2s, filter 0.2s;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: scale(0.975); }
.btn-primary--flex { flex: 1; }

.login-error { color: var(--danger); font-size: 14px; margin: 4px 2px 0; }
.login-foot { color: var(--faint); font-size: 13px; text-align: center; margin: 26px 0 0; }

/* ───────────────────────── App shell ───────────────────────── */
.app {
  max-width: 520px;
  margin-inline: auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 14px) 20px 14px;
  background: linear-gradient(to bottom, rgba(10,11,14,0.92), rgba(10,11,14,0.7) 70%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, transform 0.12s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(0.92); }

.scroll {
  flex: 1;
  padding: 8px 16px calc(var(--safe-b) + 28px);
  display: flex; flex-direction: column; gap: 16px;
}

/* ───────────────────────── Cards ───────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
}
.reveal { animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i) * 90ms + 60ms); }

.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h2 {
  font-family: var(--font-body); font-weight: 600; font-size: 15px;
  letter-spacing: 0.01em; margin: 0; color: var(--text);
}
.card-hint { font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ───────────────────────── Hero (results) ───────────────────────── */
.card--hero {
  background:
    radial-gradient(140% 120% at 50% -30%, rgba(52, 211, 153, 0.13), transparent 60%),
    var(--surface);
  border-color: var(--border-strong);
  text-align: center;
  padding: 30px 22px 24px;
}
.hero-label {
  display: block;
  font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.hero-amount {
  display: block;
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(48px, 17vw, 68px); line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(160deg, #eafff6, var(--accent) 70%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  font-variant-numeric: tabular-nums;
}
.hero-sub { display: block; color: var(--muted); font-size: 14.5px; margin: 10px 0 0; }
.hero-each {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 16px; padding: 7px 13px;
  font-size: 13px; color: var(--accent);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.22);
  border-radius: 999px;
}
.hero-each::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.hero-note {
  margin-top: 6px;
  color: #fbcfa0; font-size: 13.5px; line-height: 1.5;
  background: rgba(251, 146, 60, 0.08);
  border: 1px solid rgba(251, 146, 60, 0.22);
  border-radius: var(--r-md);
  padding: 13px 15px; text-align: left;
}

/* Split visualization */
.split { margin-top: 24px; }
.split-bar {
  height: 12px; border-radius: 999px; overflow: hidden;
  display: flex; gap: 3px;
  background: var(--surface-3);
  padding: 3px;
}
.split-seg { height: 100%; border-radius: 999px; transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.split-seg--a { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.split-seg--b { background: linear-gradient(90deg, #5b8def, #3b6fd4); }

.split-people { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.sp {
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
}
.sp-top { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.sp-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sp--a .sp-dot { background: var(--accent); }
.sp--b .sp-dot { background: #5b8def; }
.sp-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-pct { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.sp-pays-label { font-size: 12px; color: var(--muted); }
.sp-pays {
  font-family: var(--font-display); font-weight: 600; font-size: 23px;
  letter-spacing: -0.02em; margin: 2px 0 12px;
  font-variant-numeric: tabular-nums;
}
.sp-free { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; }
.sp-free b { color: var(--accent); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }

/* Breakdown */
.breakdown { margin-top: 20px; }
.breakdown-title { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin: 0 0 10px; text-align: left; }
.bd-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  align-items: center;
  padding: 11px 0;
  border-top: 1px solid var(--border);
  text-align: left;
}
.bd-name { font-weight: 500; font-size: 14px; }
.bd-amount { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.bd-shares { grid-column: 1 / -1; display: flex; gap: 14px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bd-shares .a-share { color: var(--accent); }
.bd-shares .b-share { color: #7aa5f5; }

/* ───────────────────────── Income inputs ───────────────────────── */
.person-input {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
}
.person-input + .person-input { border-top: 1px solid var(--border); }
.avatar {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  font-weight: 600; font-size: 14px;
  color: var(--accent-ink);
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  border-radius: 12px;
  text-transform: uppercase;
}
.avatar--b { background: linear-gradient(145deg, #6b9bff, #3b6fd4); color: #04101f; }
.name-input {
  flex: 1; min-width: 0;
  padding: 8px 0;
  background: transparent; border: none;
  font-weight: 500; font-size: 16px;
}
.name-input:focus { outline: none; }
.name-input::placeholder { color: var(--faint); }

.amount-field {
  display: flex; align-items: center; gap: 2px;
  padding: 9px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.amount-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.amount-field .cur { color: var(--muted); font-size: 15px; }
.num-input {
  width: 92px;
  background: transparent; border: none;
  font-weight: 600; font-size: 16px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input:focus { outline: none; }
.amount-field--lg { padding: 15px 16px; }
.amount-field--lg .cur { font-size: 20px; }
.amount-field--lg .num-input { width: 100%; font-size: 26px; font-family: var(--font-display); }

/* ───────────────────────── Expenses ───────────────────────── */
.expense-list { list-style: none; padding: 0; margin: 0; }
.expense-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  animation: fade 0.35s ease both;
}
.expense-list li + li { border-top: 1px solid var(--border); }
.exp-icon {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  color: var(--accent);
  background: rgba(52, 211, 153, 0.1);
  border-radius: 11px;
}
.exp-info { flex: 1; min-width: 0; }
.exp-label { font-weight: 500; font-size: 15px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-cat { font-size: 12px; color: var(--faint); text-transform: capitalize; }
.exp-amount { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.exp-del {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  color: var(--faint);
  background: transparent; border: none; border-radius: 9px;
  cursor: pointer; transition: color 0.2s, background 0.2s;
}
.exp-del:hover { color: var(--danger); background: rgba(251, 113, 133, 0.1); }
.exp-del:active { transform: scale(0.9); }

.empty { color: var(--faint); font-size: 14px; text-align: center; padding: 14px 0; margin: 0; }

.btn-add {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 14px;
  padding: 14px;
  font-family: var(--font-body); font-weight: 600; font-size: 15px;
  color: var(--accent);
  background: rgba(52, 211, 153, 0.07);
  border: 1px dashed rgba(52, 211, 153, 0.3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.12s;
}
.btn-add:hover { background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.5); }
.btn-add:active { transform: scale(0.985); }

.footnote { text-align: center; color: var(--faint); font-size: 12.5px; padding: 4px 0 8px; }

/* ───────────────────────── Bottom sheet ───────────────────────── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade 0.25s ease both;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 520px; margin-inline: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 14px 22px calc(var(--safe-b) + 22px);
  box-shadow: var(--shadow-pop);
  animation: sheet-up 0.36s cubic-bezier(0.2, 0.85, 0.2, 1) both;
}
.sheet.closing { animation: sheet-down 0.28s ease-in both; }
.sheet-backdrop.closing { animation: fade-out 0.28s ease-in both; }
.sheet-grip { width: 42px; height: 5px; border-radius: 999px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet-title { font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: -0.02em; margin: 0 0 18px; }
.sheet-form { display: flex; flex-direction: column; }
.sheet-label { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 500; }
.sheet-input {
  width: 100%; padding: 15px 16px; margin-bottom: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.sheet-input::placeholder { color: var(--faint); }
.sheet-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.amount-field--lg { margin-bottom: 18px; }

/* Segmented category picker */
.segmented {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  margin-bottom: 24px;
}
.seg {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 11px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s ease;
}
.seg svg { width: 20px; height: 20px; }
.seg span { font-size: 10.5px; font-weight: 500; }
.seg:active { transform: scale(0.94); }
.seg.is-active {
  color: var(--accent);
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.45);
}

.sheet-actions { display: flex; gap: 10px; }
.btn-ghost {
  padding: 16px 22px;
  font-family: var(--font-body); font-weight: 600; font-size: 16px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, transform 0.12s;
}
.btn-ghost:hover { color: var(--text); }
.btn-ghost:active { transform: scale(0.97); }

/* ───────────────────────── Animations ───────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheet-down { from { transform: translateY(0); } to { transform: translateY(100%); } }

/* ───────────────────────── Desktop layout ───────────────────────── */
@media (min-width: 900px) {
  .app { max-width: 1120px; }
  .appbar { padding: 22px 34px 18px; }

  .card { padding: 26px; transition: border-color 0.25s ease; }
  .card:hover { border-color: var(--border-strong); }
  .card--hero { padding: 52px 40px 38px; }
  .hero-amount { font-size: 78px; }
  .split { margin-top: 34px; }
  .split-people { gap: 16px; }
  .breakdown { margin-top: 26px; }

  /* The add-expense surface becomes a centered modal rather than a bottom sheet */
  .sheet {
    top: 50%; bottom: auto; left: 50%; right: auto;
    width: 460px; max-width: calc(100vw - 48px);
    border: 1px solid var(--border-strong);
    border-radius: 26px;
    padding: 28px 30px 30px;
    transform: translate(-50%, -50%);
    animation: modal-in 0.34s cubic-bezier(0.2, 0.85, 0.2, 1) both;
  }
  .sheet.closing { animation: modal-out 0.24s ease-in both; }
  .sheet-grip { display: none; }
  .sheet-title { margin-top: 2px; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes modal-out {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
}

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

/* ───────────────────────── Personal costs ───────────────────────── */
/* Expense groups (Shared / each partner) */
.exp-group + .exp-group { margin-top: 18px; }
.exp-group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 2px;
}
.exp-group-head .sub { letter-spacing: 0; text-transform: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.exp-group-empty { color: var(--faint); font-size: 13px; padding: 9px 0; margin: 0; }

/* Owner toggle: three text-only segments */
.segmented--owner { grid-template-columns: repeat(3, 1fr); }
.seg--owner { padding: 13px 6px; }
.seg--owner span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Per-person mini statement: income − personal − shared = free */
.sp-rows { margin: 12px 0; display: flex; flex-direction: column; gap: 5px; }
.sp-rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sp-rows dt { color: var(--muted); font-size: 12px; }
.sp-rows dd { margin: 0; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sp-free { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 2px; }
.sp-free.is-negative b { color: var(--danger); }
.sp-warn { margin-top: 6px; font-size: 11px; color: var(--danger); }

/* Expense rows are tappable to edit */
.expense-list li { cursor: pointer; transition: background 0.15s ease; border-radius: 10px; }
.expense-list li:hover { background: var(--surface-2); }
.expense-list li:active { background: var(--surface-3); }

/* ───────────────────────── Auth & join ───────────────────────── */
.auth-input {
  width: 100%; padding: 15px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-input::placeholder { color: var(--faint); }
.auth-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.link-btn { background: none; border: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.join-banner {
  background: rgba(52, 211, 153, 0.1); border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 18px; font-size: 14px; color: var(--accent);
}
.claim-list { display: flex; flex-direction: column; gap: 10px; }
.claim-option {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  color: var(--text); font-weight: 600; cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.claim-option:hover { border-color: var(--accent); }

/* ───────────────────────── Members card ───────────────────────── */
.member-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn-add--sm { margin-top: 0; flex: 1; padding: 11px; font-size: 14px; }
.member-you { font-size: 11px; color: var(--accent); margin-left: 6px; }
.member-del { width: 30px; height: 30px; display: grid; place-items: center; background: none; border: none; color: var(--faint); cursor: pointer; border-radius: 8px; }
.member-del:hover { color: var(--danger); background: rgba(251,113,133,0.1); }
.invite-link {
  margin-top: 12px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 13px; word-break: break-all; color: var(--muted);
}
.invite-link b { color: var(--text); }
.copy-btn { margin-left: 8px; }
.sp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

/* ───────────────────────── Tab navigation ───────────────────────── */
.view { display: flex; flex-direction: column; gap: 16px; }
.placeholder-view { text-align: center; padding: 60px 20px; color: var(--muted); }
.placeholder-view h2 { font-family: var(--font-display); font-weight: 600; font-size: 26px; color: var(--text); margin: 0 0 8px; letter-spacing: -0.02em; }
.placeholder-view p { margin: 0; font-size: 14.5px; }

.tabbar {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; gap: 4px;
  padding: 8px 10px calc(var(--safe-b) + 8px);
  background: linear-gradient(to top, rgba(10,11,14,0.96), rgba(10,11,14,0.75) 70%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; background: none; border: none; cursor: pointer;
  color: var(--faint); font: inherit; font-size: 11px; font-weight: 600;
  border-radius: 12px; transition: color 0.18s, background 0.18s;
}
.tab svg { width: 22px; height: 22px; }
.tab:hover { color: var(--muted); }
.tab.is-active { color: var(--accent); }
.tab.is-active svg { filter: drop-shadow(0 0 8px var(--accent-glow)); }

@media (min-width: 900px) {
  .tabbar {
    position: sticky; top: 0; bottom: auto; order: -1;
    justify-content: center; gap: 6px;
    padding: 10px 34px; max-width: 1120px; margin-inline: auto;
    background: none; backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .tab { flex: 0 0 auto; flex-direction: row; padding: 9px 16px; font-size: 13px; border-radius: 999px; }
  .tab svg { width: 18px; height: 18px; }
  .tab.is-active { background: var(--surface); }
  /* On desktop the existing .scroll grid is for Home; only apply it to the home view */
  .scroll { display: block; }
  #view-home { display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto auto 1fr auto; align-items: start; gap: 22px; }
  #view-home > #results { grid-column: 1; grid-row: 1 / span 3; }
  #view-home > section:nth-of-type(2) { grid-column: 2; grid-row: 1; }
  #view-home > section:nth-of-type(3) { grid-column: 2; grid-row: 2; }
  #view-home > .footnote { grid-column: 1 / -1; grid-row: 4; }
}

/* ───────────────────────── Settings ───────────────────────── */
.settings-row { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 14px; }
.settings-label { color: var(--muted); font-size: 13px; }
.settings-value { color: var(--text); font-weight: 600; font-size: 14px; }
.settings-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.settings-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.settings-btn { width: 100%; }
.settings-msg { font-size: 13px; margin: 2px 0 0; }
.settings-msg.ok { color: var(--accent); }
.settings-msg.err { color: var(--danger); }
.settings-hint { color: var(--faint); font-size: 13px; margin: 0 0 12px; }
.settings-danger { color: var(--danger); border-color: rgba(251,113,133,0.3); }
.settings-danger:hover { background: rgba(251,113,133,0.1); }
.settings-version { text-align: center; color: var(--faint); font-size: 12px; padding: 8px 0 4px; }
select.auth-input { appearance: none; -webkit-appearance: none; }

/* ───────────────────────── Settle up ───────────────────────── */
.settle { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); text-align: left; }
.settle-title { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 12px; }
.settle-line { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: 14px; }
.settle-line .who { font-weight: 600; }
.settle-line .arrow { color: var(--accent); }
.settle-line b { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--accent); }
.settle-note { color: var(--faint); font-size: 13px; }

/* ───────────────────────── Insights ───────────────────────── */
#insights-body { display: flex; flex-direction: column; gap: 16px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.chart-card h2 { font-family: var(--font-body); font-weight: 600; font-size: 15px; margin: 0 0 16px; color: var(--text); }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; flex: none; }
.donut-center { font-family: var(--font-display); font-weight: 600; fill: var(--text); }
.donut-center-sub { fill: var(--faint); }
.legend { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 160px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-row .lbl { color: var(--muted); }
.legend-row .val { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.legend-row .pct { color: var(--faint); font-size: 12px; width: 38px; text-align: right; }
.barstat { margin-bottom: 14px; }
.barstat:last-child { margin-bottom: 0; }
.barstat-top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; }
.barstat-top .lbl { color: var(--muted); }
.barstat-top .val { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.barstat-track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.barstat-fill { height: 100%; border-radius: 999px; transition: width 0.6s cubic-bezier(0.2,0.8,0.2,1); }
.stack { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--surface-3); gap: 2px; padding: 2px; }
.stack > div { height: 100%; border-radius: 999px; }
.insights-empty { text-align: center; color: var(--faint); padding: 50px 20px; }

/* ───────────────────────── History ───────────────────────── */
.history-save { width: auto; padding: 9px 16px; font-size: 13px; }
.trend { width: 100%; height: auto; display: block; }
.trend-labels { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; margin-top: 6px; }
.trend-empty { color: var(--faint); font-size: 14px; text-align: center; padding: 20px 0; }
#history-list { display: flex; flex-direction: column; gap: 10px; }
.snap-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; }
.snap-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.snap-label { font-weight: 600; font-size: 15px; }
.snap-date { font-size: 12px; color: var(--faint); }
.snap-stats { margin-left: auto; text-align: right; display: flex; flex-direction: column; gap: 2px; }
.snap-free { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); font-size: 14px; }
.snap-shared { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.snap-del { width: 30px; height: 30px; flex: none; display: grid; place-items: center; background: none; border: none; color: var(--faint); cursor: pointer; border-radius: 8px; }
.snap-del:hover { color: var(--danger); background: rgba(251,113,133,0.1); }
.history-empty { text-align: center; color: var(--faint); padding: 30px 20px; }

/* ───────────────────────── Onboarding ───────────────────────── */
.onb-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.onb-dots span { width: 7px; height: 7px; border-radius: 999px; background: var(--surface-3); transition: background 0.2s, width 0.2s; }
.onb-dots span.on { background: var(--accent); width: 20px; }
.onb h2 { font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -0.02em; margin: 0 0 10px; }
.onb p { color: var(--muted); font-size: 14.5px; line-height: 1.55; margin: 0 0 18px; }
.onb-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.onb-field label { font-size: 13px; color: var(--muted); }
.onb-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ───────────────────────── Toasts & dialog ───────────────────────── */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 76px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toasts { bottom: calc(var(--safe-b) + 24px); } }
.toast {
  pointer-events: auto; max-width: 460px; width: fit-content;
  padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-pop); animation: toast-in 0.28s cubic-bezier(0.2,0.85,0.2,1) both;
}
.toast.out { animation: toast-out 0.3s ease forwards; }
.toast.ok { border-color: rgba(52,211,153,0.4); }
.toast.ok::before { content: '✓ '; color: var(--accent); }
.toast.err { border-color: rgba(251,113,133,0.4); }
.toast.err::before { content: '! '; color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
.modal-dialog { max-width: 420px; }
.modal-message { color: var(--muted); font-size: 14.5px; line-height: 1.5; margin: 0 0 18px; }
.modal-dialog .auth-input { margin-bottom: 18px; }
.btn-primary.is-danger { background: linear-gradient(145deg, #fb7185, #e11d48); color: #fff; }
.view-enter { animation: view-fade 0.24s ease both; }
@keyframes view-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }


.exp-freq { color: var(--faint); font-size: 11px; font-weight: 500; margin-left: 2px; }

/* Boot splash */
.boot { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: var(--bg); }
.boot.hidden { display: none; }
.boot-spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Visible keyboard focus */
button:focus-visible, a:focus-visible, .seg:focus-visible, .tab:focus-visible, .claim-option:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ───────────────────────── Snapshot expand/detail ───────────────────────── */
.snap-row.is-expanded { border-radius: var(--r-md) var(--r-md) 0 0; }
.snap-rowmain { display: flex; align-items: center; gap: 12px; flex: 1; cursor: pointer; min-width: 0; }
.snap-detail { padding: 12px 16px 14px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); margin-top: -10px; }
.snap-d-row { display: flex; gap: 10px; align-items: baseline; padding: 5px 0; font-size: 13.5px; }
.snap-d-row span:first-child { font-weight: 600; min-width: 70px; }
.snap-d-pays { color: var(--muted); }
.snap-d-free { margin-left: auto; color: var(--accent); font-variant-numeric: tabular-nums; }
.snap-d-bills { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.snap-d-bill { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 3px 0; font-variant-numeric: tabular-nums; }
.snap-rename { margin-top: 10px; }

/* ───────────────────────── Light theme ───────────────────────── */
:root[data-theme="light"] {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --surface-3: #e3e8ee;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #131a24;
  --muted: #5a6573;
  --faint: #97a2b1;
  --accent: #0ea571;
  --accent-2: #0b8f63;
  --accent-ink: #ffffff;
  --accent-glow: rgba(14, 165, 113, 0.20);
  --danger: #e11d48;
  --shadow: 0 10px 28px -14px rgba(15, 23, 42, 0.18);
  --shadow-pop: 0 22px 55px -18px rgba(15, 23, 42, 0.28);
}
:root[data-theme="light"] .atmosphere {
  background:
    radial-gradient(120% 80% at 80% -10%, rgba(16, 185, 129, 0.10), transparent 55%),
    radial-gradient(90% 60% at -10% 10%, rgba(56, 120, 255, 0.06), transparent 50%),
    var(--bg);
}
:root[data-theme="light"] .atmosphere::after { opacity: 0.015; }
:root[data-theme="light"] .appbar {
  background: linear-gradient(to bottom, rgba(244,246,248,0.92), rgba(244,246,248,0.7) 70%, transparent);
}
:root[data-theme="light"] .tabbar {
  background: linear-gradient(to top, rgba(244,246,248,0.96), rgba(244,246,248,0.75) 70%, transparent);
}
:root[data-theme="light"] .hero-amount {
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* Legal links */
.login-legal { text-align: center; font-size: 12.5px; color: var(--faint); margin: 12px 0 0; }
.login-legal a, .settings-version a { color: var(--muted); text-decoration: none; }
.login-legal a:hover, .settings-version a:hover { color: var(--accent); }

/* ───────────────────────── Landing layout ───────────────────────── */
.login:has(.landing) {
  max-width: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  padding: 0;
}

.landing {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.landing-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--safe-t) + 48px) 28px 36px;
}

.landing-brand { margin-bottom: 36px; }

.landing-headline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(38px, 10vw, 62px);
  line-height: 1.03;
  letter-spacing: -0.04em;
  margin: 0 0 18px;
  background: linear-gradient(160deg, #eafff6, var(--accent) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

:root[data-theme="light"] .landing-headline {
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.landing-sub {
  font-size: 16px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 32px;
  max-width: 480px;
}

.landing-props {
  list-style: none;
  padding: 0;
  margin: 0 0 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.landing-prop {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--muted);
}

.landing-prop strong { color: var(--text); }

.prop-icon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.18);
  border-radius: 10px;
}

:root[data-theme="light"] .prop-icon {
  background: rgba(14, 165, 113, 0.08);
  border-color: rgba(14, 165, 113, 0.18);
}

.prop-icon svg { width: 17px; height: 17px; }

.btn-demo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: var(--r-md);
  cursor: pointer;
  width: fit-content;
  transition: background 0.2s, border-color 0.2s, transform 0.12s;
}
.btn-demo:hover { background: rgba(52, 211, 153, 0.14); border-color: rgba(52, 211, 153, 0.55); }
.btn-demo:active { transform: scale(0.975); }

:root[data-theme="light"] .btn-demo {
  background: rgba(14, 165, 113, 0.07);
  border-color: rgba(14, 165, 113, 0.3);
}

.landing-form {
  padding: 0 20px calc(var(--safe-b) + 40px);
}

.landing-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.landing-form-card .login-title {
  font-size: clamp(26px, 7vw, 34px);
  margin: 0 0 10px;
}

/* Adjust title tag from h1 to h2 visually (it's an h2 in the card) */
h2.login-title {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

@media (min-width: 900px) {
  .login:has(.landing) {
    align-items: center;
    padding: calc(var(--safe-t) + 24px) 40px calc(var(--safe-b) + 40px);
    max-width: 1200px;
    margin-inline: auto;
  }

  .landing {
    flex-direction: row;
    align-items: flex-start;
    gap: 64px;
    max-width: 1100px;
    margin-inline: auto;
    width: 100%;
  }

  .landing-hero {
    flex: 1;
    padding: 40px 0 40px;
    position: sticky;
    top: 40px;
  }

  .landing-form {
    flex: 0 0 400px;
    padding: 40px 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .landing-form-card {
    padding: 36px 32px 28px;
  }
}

/* ───────────────────────── Demo banner ───────────────────────── */
.demo-banner {
  background: rgba(52, 211, 153, 0.09);
  border-bottom: 1px solid rgba(52, 211, 153, 0.22);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  padding: 10px 16px;
}

:root[data-theme="light"] .demo-banner {
  background: rgba(14, 165, 113, 0.07);
  border-color: rgba(14, 165, 113, 0.18);
}
.verify-banner { background: rgba(246,196,83,0.12); border-bottom: 1px solid rgba(246,196,83,0.28); color: #d9a93a; text-align: center; font-size: 13px; padding: 9px 14px; }
:root[data-theme="light"] .verify-banner { color: #9a6b00; }
.verify-banner .link-btn { color: inherit; text-decoration: underline; }
