:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #6c8cff;
  --accent-2: #4f6fe5;
  --positive: #3ecf8e;
  --negative: #ff6b6b;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1a1f2b 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 17, 21, 0.8);
  backdrop-filter: blur(10px);
  z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }

main#app { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 24px 18px 60px; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 18px; border-top: 1px solid var(--border); }

.loading { color: var(--muted); text-align: center; padding: 60px 0; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 17px; }
.card h2 .count { color: var(--muted); font-weight: 500; font-size: 14px; }

/* Hero / landing */
.hero { text-align: center; padding: 30px 0 10px; }
.hero h1 { font-size: 34px; margin: 0 0 10px; letter-spacing: -0.5px; }
.hero p { color: var(--muted); max-width: 460px; margin: 0 auto 26px; }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
input, select, button {
  font: inherit;
  color: var(--text);
}
input, select {
  width: 100%;
  padding: 11px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 0.05s ease, background 0.15s ease;
}
button:hover { background: #262b35; }
button:active { transform: translateY(1px); }
button.primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border: none; color: white; font-weight: 600; }
button.primary:hover { filter: brightness(1.05); }
button.ghost { background: transparent; }
button.small { padding: 7px 11px; font-size: 13px; }
button.danger { color: var(--negative); }

.btn-row { display: flex; gap: 10px; margin-top: 6px; }
.full { width: 100%; }

/* Pills / chips */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* Segmented control */
.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px; gap: 4px; }
.segmented button { flex: 1; background: transparent; border: none; padding: 8px; color: var(--muted); }
.segmented button.active { background: var(--accent); color: white; }

/* Expense list */
.expense { border-top: 1px solid var(--border); padding: 14px 0; }
.expense:first-of-type { border-top: none; }
.expense-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.expense-title { font-weight: 600; }
.expense-amount { font-weight: 700; white-space: nowrap; }
.expense-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.breakdown { margin-top: 10px; display: grid; gap: 4px; }
.breakdown .line { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.expense-actions { margin-top: 8px; display: flex; gap: 8px; }

/* Header */
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.subhead { margin: 0 0 12px; font-size: 15px; }
.subhead .count { color: var(--muted); font-weight: 500; font-size: 14px; }

/* Member management */
.member-list { display: grid; gap: 4px; margin-bottom: 4px; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.member-row:first-child { border-top: none; }
.member-row input { flex: 1; }
.member-name { display: inline-flex; align-items: center; gap: 8px; }
.member-actions { display: flex; gap: 6px; flex: none; }

/* Balances */
.balance { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--border); }
.balance:first-child { border-top: none; }
.amt-pos { color: var(--positive); font-weight: 600; }
.amt-neg { color: var(--negative); font-weight: 600; }
.amt-zero { color: var(--muted); }

/* Settle up */
.settle { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.settle:first-child { border-top: none; }
.settle .arrow { color: var(--accent); }
.settle .who { font-weight: 600; }
.settle .amt { margin-left: auto; font-weight: 700; }

.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.muted { color: var(--muted); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.participant-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.participant-row label { margin: 0; flex: 1; display: flex; align-items: center; gap: 8px; color: var(--text); }
.participant-row input[type="number"] { width: 110px; flex: none; }
.participant-row input[type="checkbox"] { width: auto; }

@media (max-width: 520px) {
  .row { flex-direction: column; }
  .hero h1 { font-size: 27px; }
}
