/* Bump design system — calm, money-trustworthy, warm paper canvas.
   Deliberately light-only for v1: consistent in demos, semantic color
   carries meaning (red = past due) that must not shift per device theme.
   All colors/spacing live in the custom properties below. */

:root {
  --canvas: #f6f5f2;
  --surface: #ffffff;
  --surface-dim: #fbfaf8;
  --ink: #1c1e21;
  --muted: #68707c;
  --line: #e6e4de;
  --line-strong: #d5d2c9;

  --accent: #146152;
  --accent-hover: #0f4f43;
  --accent-tint: #e7f0ed;

  --good: #1c7a4d;
  --good-tint: #e8f3ec;

  --warn: #96690c;
  --warn-tint: #faf3e2;

  --danger: #b3352c;
  --danger-tint: #f9ecea;

  --info: #33587a;
  --info-tint: #eaf0f6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-pop: 0 12px 40px rgba(28, 30, 33, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.money, .stat-chip__value, .card__balance, .ledger td.text-right,
.detail-header__balance-value, .digest-stat__value, .family-row__balance {
  font-variant-numeric: tabular-nums;
}

/* ---------- nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 max(16px, calc(50vw - 440px));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  height: 52px;
}

.nav__brand {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
  margin-right: 1.1rem;
}

.nav__brand::after {
  content: ".";
  color: var(--accent);
}

.nav__link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 0 0.65rem;
  height: 52px;
  line-height: 52px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.nav__link:hover { color: var(--ink); }

.nav__link.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ---------- page scaffold ---------- */

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 16px 80px;
}

.page-header { margin-bottom: 22px; }

.page-header__eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 0;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14.5px;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 30px 0 10px;
}

.muted { color: var(--muted); }

.loading-state, .error-state {
  color: var(--muted);
  padding: 28px 0;
}

.error-state { color: var(--danger); }

/* ---------- stat tiles ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-chip__label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.stat-chip__value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stat-chip--danger .stat-chip__value { color: var(--danger); }
.stat-chip--success .stat-chip__value { color: var(--good); }

/* ---------- queue cards ---------- */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 14px 19px;
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: var(--line-strong);
}

.card--hold::before { background: var(--danger); }
.card--late_fee::before { background: var(--warn); }
.card--reminder::before { background: var(--info); }
.card--summary::before { display: none; }
.card--summary { background: var(--surface-dim); }

.card__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.card__family {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card__balance {
  font-size: 15.5px;
  font-weight: 650;
  white-space: nowrap;
}

.card--summary .card__family { font-weight: 600; color: var(--muted); }
.card--summary .card__balance { color: var(--ink); }

.card__badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  margin-right: 8px;
  vertical-align: 2px;
}

.card__badge--hold { background: var(--danger-tint); color: var(--danger); }
.card__badge--late_fee { background: var(--warn-tint); color: var(--warn); }
.card__badge--reminder { background: var(--info-tint); color: var(--info); }

.card__meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.card__snooze {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
}

.card__snooze.is-open { display: flex; }

.card__snooze input[type="text"] {
  flex: 1;
  min-width: 140px;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover { background: var(--surface-dim); border-color: var(--muted); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Severity lives in the card; destructive-ish verbs stay quiet outline-red. */
.btn--danger {
  color: var(--danger);
  border-color: #dcaaa5;
  background: var(--surface);
}

.btn--danger:hover { background: var(--danger-tint); border-color: var(--danger); }

.btn--small { padding: 4px 10px; font-size: 12.5px; }

/* ---------- empty state ---------- */

.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  padding: 44px 20px;
}

.empty-state__title {
  font-size: 17px;
  font-weight: 650;
}

.empty-state__title::before {
  content: "✓";
  display: block;
  width: 34px;
  height: 34px;
  line-height: 34px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--good-tint);
  color: var(--good);
  font-size: 17px;
}

.empty-state__subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ---------- families list ---------- */

.search-box {
  width: 100%;
  margin-bottom: 14px;
}

.family-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.family-row {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.family-row:last-child { border-bottom: none; }
.family-row:hover { background: var(--surface-dim); }

.family-row__top, .family-row__bottom {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.family-row__name { font-weight: 650; font-size: 15px; }

.family-row__balance { font-weight: 650; }

.family-row__meta { font-size: 13px; color: var(--muted); margin-top: 1px; }

.family-row__bottom { margin-top: 6px; }

/* ---------- chips ---------- */

.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 9px;
  border-radius: 99px;
  background: #eeece7;
  color: var(--muted);
  margin-right: 6px;
}

.chip--current { background: var(--good-tint); color: var(--good); }
.chip--late { background: var(--warn-tint); color: var(--warn); }
.chip--overdue { background: var(--danger-tint); color: var(--danger); }
.chip--hold { background: var(--danger); color: #fff; }
.chip--autopay { background: var(--info-tint); color: var(--info); }

/* ---------- family detail ---------- */

.detail-header {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.detail-header__top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.detail-header__name {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.detail-header__contact, .detail-header__teams {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 2px;
}

.detail-header__balance { text-align: right; white-space: nowrap; }

.detail-header__balance-value {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.detail-header__balance-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-header__actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.notes-box {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--warn-tint);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  font-size: 13.5px;
}

/* ---------- ledger table ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}

.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ledger th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.ledger td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.ledger tbody tr:last-child td { border-bottom: none; }

.ledger th.text-right, .ledger td.text-right { text-align: right; }

.ledger__status {
  font-size: 12px;
  color: var(--muted);
}

.ledger__amount--charge { color: var(--ink); }
.ledger__amount--payment { color: var(--good); font-weight: 600; }

.ledger td.text-right:nth-child(4) { color: var(--muted); }

.ledger__menu { position: relative; width: 36px; }

.ledger__menu-btn {
  appearance: none;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}

.ledger__menu-btn:hover { background: var(--surface-dim); color: var(--ink); }

.ledger__menu-dropdown {
  display: none;
  position: absolute;
  right: 6px;
  top: 26px;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  min-width: 190px;
  padding: 4px;
}

.ledger__menu-dropdown.is-open { display: block; }

.ledger__menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.ledger__menu-dropdown button:hover { background: var(--surface-dim); }
.ledger__menu-dropdown button:disabled { color: var(--muted); cursor: default; }

/* ---------- timeline ---------- */

.timeline {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 16px;
}

.timeline__item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.timeline__item:last-child { border-bottom: none; }

.timeline__kind {
  font-weight: 650;
  text-transform: capitalize;
}

.timeline__date {
  color: var(--muted);
  margin-left: 8px;
  font-size: 12.5px;
}

.timeline__detail {
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- forms ---------- */

input[type="text"], input[type="number"], input[type="date"],
input[type="password"], select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-tint);
  border-color: var(--accent);
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 4px;
}

.field input, .field select { width: 100%; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ---------- settings ---------- */

.policy-sentence {
  font-size: 15px;
  line-height: 2.4;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.num-input {
  width: 68px;
  text-align: center;
  margin: 0 2px;
}

.template-block { margin-bottom: 20px; }

.template-block textarea {
  width: 100%;
  min-height: 120px;
  line-height: 1.55;
  resize: vertical;
}

.template-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 2px 0 6px;
}

.autopay-section {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--muted);
}

.autopay-section__badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  background: var(--warn-tint);
  color: var(--warn);
  border-radius: 99px;
  padding: 3px 10px;
  margin-bottom: 8px;
}

/* ---------- digest ---------- */

.digest-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.digest-section { margin-bottom: 8px; }

.digest-stats > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.digest-stat__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.digest-stat__value {
  font-size: 24px;
  font-weight: 700;
}

.digest-delta--down { color: var(--good); }
.digest-delta--up { color: var(--danger); }

.digest-stat__hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.action-count-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 16px;
  margin: 0;
  list-style: none;
}

.action-count-list > * {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.action-count-list > *:last-child { border-bottom: none; }

/* ---------- login ---------- */

.login-form {
  max-width: 360px;
  margin: 10vh auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.login-form .error { color: var(--danger); font-size: 13.5px; }

.login-brand {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 2px;
}

.login-brand::after { content: "."; color: var(--accent); }

.login-tagline {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(24, 26, 29, 0.45);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}

.modal-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh 16px 40px;
}

.modal {
  position: relative;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  width: min(560px, 100%);
  padding: 22px;
}

.modal__close {
  position: absolute;
  top: 10px;
  right: 12px;
  appearance: none;
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}

.modal__close:hover { color: var(--ink); background: var(--surface-dim); }

.modal__title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}

.modal__draft {
  width: 100%;
  min-height: 190px;
  line-height: 1.55;
  resize: vertical;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* ---------- toast ---------- */

.toast-host {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.toast {
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 550;
  padding: 9px 16px;
  border-radius: 99px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }

.toast--error { background: var(--danger); }

/* ---------- responsive ---------- */

@media (max-width: 719px) {
  .page { padding-top: 20px; }
  .stat-row { grid-template-columns: 1fr; }
  .digest-stats { grid-template-columns: 1fr; }
  .stat-chip { display: flex; align-items: baseline; justify-content: space-between; }
  .stat-chip__label { margin-bottom: 0; }
  .stat-chip__value { font-size: 19px; }
  .detail-header__top { flex-direction: column; }
  .detail-header__balance { text-align: left; }
  .nav { overflow-x: auto; }
}
