:root {
  --bg: #0f1226;
  --card: #ffffff;
  --ink: #1c1e2e;
  --muted: #6b6f85;
  --accent: #5b5bd6;
  --accent-dark: #4343b8;
  --green: #178a4c;
  --red: #d33a2c;
  --line: #e4e6f0;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(160deg, #141733 0%, #232357 55%, #2e2a6e 100%);
  color: var(--ink);
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.2rem 1.5rem 0.4rem;
  max-width: 880px;
  margin: 0 auto;
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 0.8rem; }
.logo { font-size: 2.2rem; }
.topbar h1 { margin: 0; font-size: 1.7rem; letter-spacing: 0.5px; }
.tagline { margin: 0.15rem 0 0; color: #c6c8e8; font-size: 0.92rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.8rem; }
.currency-switch { font-size: 0.9rem; color: #c6c8e8; display: flex; align-items: center; gap: 0.45rem; }
.currency-switch select {
  padding: 0.4rem 0.5rem; border-radius: 8px; border: 1px solid #4a4a8f;
  background: #1d1f42; color: #fff; font-size: 0.95rem;
}

.layout {
  max-width: 880px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 720px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.25rem;
  box-shadow: 0 10px 28px rgba(5, 6, 20, 0.35);
}
.card h2 { margin: 0 0 0.9rem; font-size: 1.15rem; }
.settle-heading { margin: 1.1rem 0 0.5rem; font-size: 1rem; }

.inline-form { display: flex; gap: 0.5rem; }
.inline-form input { flex: 1; }

input[type="text"], input[type="number"], select {
  padding: 0.55rem 0.65rem;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  font-size: 0.98rem;
  width: 100%;
  background: #fbfbfe;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

.field { display: block; margin-bottom: 0.7rem; }
.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 2fr 1fr 1.4fr; gap: 0.6rem; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.btn {
  border: 1.5px solid var(--line);
  background: #f2f3fa;
  color: var(--ink);
  padding: 0.55rem 1rem;
  border-radius: 9px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: #e6e7f5; border-color: #4a4a8f; }
.btn-wide { width: 100%; margin-top: 0.4rem; }
.btn-small { padding: 0.28rem 0.6rem; font-size: 0.82rem; border-radius: 7px; }

.error {
  color: var(--red);
  background: #fdecea;
  border: 1px solid #f5c6c0;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  margin: 0.6rem 0;
}
.hint { color: var(--muted); font-size: 0.88rem; margin: 0.5rem 0 0; }
.hint.bad { color: var(--red); font-weight: 600; }
.hint.good { color: var(--green); font-weight: 600; }
.empty-state { color: var(--muted); font-size: 0.93rem; margin: 0.4rem 0; }
.settled-state { color: var(--green); font-weight: 600; margin: 0.3rem 0; }

.people-list, .expense-list, .balance-list, .settlement-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.people-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--line);
}
.people-list li:last-child { border-bottom: none; }
.person-name { font-weight: 600; }

.split-box { border: 1.5px solid var(--line); border-radius: 10px; padding: 0.7rem 0.8rem; margin: 0 0 0.7rem; }
.split-box legend { font-size: 0.85rem; font-weight: 600; color: var(--muted); padding: 0 0.3rem; }
.split-mode-toggle { display: flex; gap: 1.1rem; margin-bottom: 0.6rem; font-size: 0.94rem; }
.split-members { display: grid; gap: 0.4rem; }
.split-member-row { display: flex; align-items: center; gap: 0.55rem; font-size: 0.95rem; }
.split-member-row .member-check { display: flex; align-items: center; gap: 0.45rem; flex: 1; cursor: pointer; }
.split-member-row input[type="number"] { width: 110px; }

.expense-list li {
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 0.65rem 0.8rem; margin-bottom: 0.55rem; background: #fbfbfe;
}
.expense-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; }
.expense-desc { font-weight: 700; }
.expense-total { font-weight: 700; white-space: nowrap; }
.expense-meta { color: var(--muted); font-size: 0.87rem; margin-top: 0.25rem; line-height: 1.45; }
.expense-actions { margin-top: 0.45rem; }

.totals-bar {
  display: flex; gap: 1.4rem; flex-wrap: wrap;
  border-top: 1.5px solid var(--line); padding-top: 0.7rem; margin-top: 0.4rem; font-size: 0.95rem;
}

.balance-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--line);
}
.balance-list li:last-child { border-bottom: none; }
.balance-amount { font-weight: 700; }
.balance-amount.positive { color: var(--green); }
.balance-amount.negative { color: var(--red); }
.balance-amount.zero { color: var(--muted); }
.balance-note { display: block; font-size: 0.82rem; color: var(--muted); font-weight: 400; }

.settlement-list li {
  background: #eef7f1; border: 1px solid #cfe8d8; border-radius: 9px;
  padding: 0.55rem 0.75rem; margin-bottom: 0.45rem; font-size: 0.96rem;
}
.settlement-list .amount { font-weight: 700; }

.footer { max-width: 880px; margin: 0 auto; padding: 0 1.5rem 2rem; color: #a9abd0; font-size: 0.83rem; line-height: 1.5; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 10, 30, 0.6);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; border-radius: var(--radius); padding: 1.3rem; max-width: 420px; width: 100%; }
.modal h3 { margin: 0 0 0.6rem; }
.modal p { color: var(--muted); line-height: 1.5; margin: 0 0 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
