@import url('https://fonts.googleapis.com/css2?family=Lora:wght@400;600;700&family=DM+Sans:wght@400;500;600&display=swap');

/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --terracotta: #B07355;
  --brown:      #5C3D2E;
  --tan:        #E8DDD0;
  --tan-dark:   #D6C9B8;
  --green:      #7A9E7E;
  --rose:       #C4847A;
  --bg:         #F5EFE8;
  --white:      #FFFAF6;
  --text:       #3A2A20;
  --text-muted: #8A7060;
  --radius:     14px;
  --radius-sm:  8px;
}

html { font-size: 16px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Layout ────────────────────────────────────────────── */
.app {
  width: 100%;
  max-width: 420px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--white);
}

/* ─── Header ────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  background: var(--white);
  border-bottom: 1px solid var(--tan-dark);
}

.header h1 {
  font-family: 'Lora', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--brown);
}

.header-actions { display: flex; gap: 10px; align-items: center; }

/* ─── Nav tabs ──────────────────────────────────────────── */
.nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--tan-dark);
  background: var(--white);
}

.nav-tab {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-tab.active {
  color: var(--terracotta);
  border-bottom-color: var(--terracotta);
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--tan-dark);
  border-radius: var(--radius);
  padding: 20px;
}

.card + .card { margin-top: 12px; }

/* ─── Balance Card ──────────────────────────────────────── */
.balance-card {
  background: var(--brown);
  color: var(--tan);
  border: none;
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  margin: 16px 16px 0;
  text-align: center;
}

.balance-label {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 6px;
}

.balance-amount {
  font-family: 'Lora', serif;
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  color: var(--white);
  margin-bottom: 4px;
}

.balance-direction {
  font-size: 0.9rem;
  opacity: 0.8;
}

.balance-card.settled .balance-amount { font-size: 2rem; opacity: 0.6; }

/* ─── Breakdown rows ────────────────────────────────────── */
.breakdown {
  margin: 12px 16px 0;
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--white);
  border: 1px solid var(--tan-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.breakdown-person {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.breakdown-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.breakdown-amount {
  font-family: 'Lora', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--brown);
}

/* ─── Avatar chips ──────────────────────────────────────── */
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-sm { width: 24px; height: 24px; font-size: 0.65rem; }
.avatar-lg { width: 40px; height: 40px; font-size: 0.9rem; }

.avatar-paige { background: #F9C784; color: #7A4E0D; }
.avatar-kira  { background: #A8CAAB; color: #2A5C2E; }
.avatar-brent { background: #A4B8D1; color: #1C3E5E; }

/* ─── Section heading ───────────────────────────────────── */
.section-heading {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 16px 8px;
}

/* ─── Transaction list ──────────────────────────────────── */
.txn-list { padding: 0 16px 16px; }

.txn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--tan-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.txn-row:last-child { margin-bottom: 0; }

.txn-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.txn-main { flex: 1; min-width: 0; }

.txn-desc {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.txn-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.txn-right { text-align: right; flex-shrink: 0; }

.txn-amount {
  font-family: 'Lora', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--brown);
}

.txn-owed {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Type badges ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-triad { background: #EDD9C8; color: #7A4E0D; }
.badge-dyad  { background: #C8DED4; color: #2A5C2E; }
.badge-unyad { background: #DDD0E0; color: #5A3870; }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--terracotta);
  color: var(--white);
  width: 100%;
  min-height: 52px;
}

.btn-primary:hover:not(:disabled) { opacity: 0.9; }

.btn-secondary {
  background: var(--tan);
  color: var(--brown);
  width: 100%;
}

.btn-ghost {
  background: none;
  color: var(--text-muted);
  padding: 8px 12px;
}

.btn-settle {
  background: var(--green);
  color: var(--white);
  width: calc(100% - 32px);
  margin: 0 16px 80px;
  padding: 16px;
  font-size: 1rem;
  min-height: 52px;
}

/* ─── Big payer buttons ─────────────────────────────────── */
.payer-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.payer-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  border-radius: var(--radius);
  border: 2px solid var(--tan-dark);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.payer-btn.active-paige { border-color: #F9C784; background: #FEF7EA; }
.payer-btn.active-kira  { border-color: #A8CAAB; background: #EEF7EF; }

/* ─── Split type buttons ────────────────────────────────── */
.split-group {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.split-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--tan-dark);
  background: var(--white);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  line-height: 1.3;
}

.split-btn .split-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.split-btn.active { border-color: var(--terracotta); background: #FBF0EA; color: var(--brown); }
.split-btn { min-height: 48px; }

/* ─── Preview card ──────────────────────────────────────── */
.preview-card {
  background: var(--tan);
  border: 1px solid var(--tan-dark);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.88rem;
}

.preview-row + .preview-row {
  border-top: 1px solid var(--tan-dark);
  padding-top: 8px;
  margin-top: 4px;
}

.preview-key { color: var(--text-muted); }

.preview-val {
  font-family: 'Lora', serif;
  font-weight: 600;
  color: var(--brown);
}

.preview-val.no-charge { color: var(--green); font-style: italic; font-family: 'DM Sans', sans-serif; }

/* ─── Form elements ─────────────────────────────────────── */
.form-section { padding: 0 16px; margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.amount-input {
  font-family: 'Lora', serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--brown);
  background: var(--tan);
  border: 2px solid var(--tan-dark);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.amount-input:focus { border-color: var(--terracotta); }
.amount-input::placeholder { color: var(--tan-dark); }

/* Remove number spinner arrows on all platforms */
.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-input { -moz-appearance: textfield; }

.text-input, .date-input {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--tan);
  border: 1.5px solid var(--tan-dark);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.text-input:focus, .date-input:focus { border-color: var(--terracotta); }

/* ─── Checkbox txn list ─────────────────────────────────── */
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--tan-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--terracotta);
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Page content scroll ───────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 80px;
}

/* ─── Bottom nav ────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 420px;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--tan-dark);
  z-index: 100;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 12px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.bottom-nav-item.active { color: var(--terracotta); }
.bottom-nav-item svg { width: 22px; height: 22px; }

/* ─── Empty state ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state p { margin-top: 8px; font-size: 0.9rem; }

/* ─── Loading ───────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ─── Settle archive groups ─────────────────────────────── */
.settlement-group {
  margin-bottom: 20px;
}

.settlement-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 16px 6px;
}

.settlement-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settlement-total {
  font-family: 'Lora', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--green);
}

/* ─── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brown);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* ─── Auth screen ───────────────────────────────────────── */
.auth-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}

.auth-screen h2 {
  font-family: 'Lora', serif;
  font-size: 1.6rem;
  color: var(--brown);
  margin-bottom: 8px;
}

.auth-screen p {
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.5;
}

.btn-google {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--white);
  border: 1.5px solid var(--tan-dark);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
  width: 100%;
  justify-content: center;
}

.btn-google:hover { border-color: var(--terracotta); }

/* ─── Payment badge + amount ────────────────────────────── */
.badge-payment { background: #C8DED4; color: #2A5C2E; }
.txn-amount-payment { color: var(--green); }

/* ─── Delete button on txn rows ─────────────────────────── */
.txn-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--text-muted);
  opacity: 0.5;
  border-radius: var(--radius-sm);
  transition: opacity 0.15s, color 0.15s;
  display: flex;
  align-items: center;
}
.txn-delete:hover { opacity: 1; color: var(--rose); }

/* ─── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 40, 30, 0.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  background: var(--white);
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius) var(--radius) 0 0;
  padding-bottom: 32px;
  max-height: 90dvh;
  overflow-y: auto;
}

.modal-sheet-sm {
  padding: 24px 20px;
  border-radius: var(--radius);
  margin: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
  border-bottom: 1px solid var(--tan-dark);
  margin-bottom: 4px;
}

.modal-header h3 {
  font-family: 'Lora', serif;
  font-size: 1.1rem;
  color: var(--brown);
}

/* ─── Confirm dialog ────────────────────────────────────── */
.confirm-msg {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.5;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-danger {
  background: var(--rose);
  color: var(--white);
}
