/* Rizzpenses web — matches mobile theme (light, pink accent) */
:root {
  --primary: #F0657C;
  --primary-light: #F9A8B4;
  --primary-subtle: rgba(240, 101, 124, 0.08);
  --bg: #FAF9F7;
  --card: #FFFFFF;
  --gradient-top: #FFF2F4;
  --gradient-mid: #FDF5F3;
  --gradient-bottom: #FAF9F7;
  --label: #1A1A2E;
  --secondary-label: #5C5C70;
  --tertiary-label: #9A9AAE;
  --separator: rgba(26, 26, 46, 0.07);
  --fill: rgba(26, 26, 46, 0.04);
  --green: #2ECC87;
  --orange: #F5A623;
  --purple: #9B6BF2;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-full: 999px;
  --shadow-sm: 0 2px 8px rgba(26, 26, 46, 0.06);
  --shadow-md: 0 4px 16px rgba(26, 26, 46, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, var(--gradient-top) 0%, var(--gradient-mid) 40%, var(--gradient-bottom) 100%);
  min-height: 100dvh;
  color: var(--label);
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 8px);
}

.app-header {
  padding: max(12px, env(safe-area-inset-top)) 20px 8px;
}
.app-header--home .greeting { font-size: 15px; color: var(--tertiary-label); font-weight: 500; }
.app-header--home .title { font-size: 34px; font-weight: 800; color: var(--primary); letter-spacing: -0.5px; line-height: 1.1; }
.app-header--tab {
  display: flex; align-items: center; justify-content: center; min-height: 44px;
  position: relative; padding-left: 20px; padding-right: 20px;
}
.app-header--tab .title { font-size: 17px; font-weight: 700; }

.screen { display: none; padding: 0 20px 24px; max-width: 560px; margin: 0 auto; }
.screen.active { display: block; }

/* Smart input */
.smart-wrap { margin-bottom: 16px; }
.smart-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: var(--radius-lg);
  padding: 6px 6px 6px 16px; border: 1px solid var(--separator);
  box-shadow: var(--shadow-sm);
}
.smart-row input {
  flex: 1; border: none; background: transparent; font-size: 17px; color: var(--label);
  padding: 10px 0; outline: none;
}
.smart-row input::placeholder { color: var(--tertiary-label); }
.smart-send {
  width: 36px; height: 36px; border-radius: 18px; background: var(--primary); color: #fff;
  border: none; font-size: 18px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.smart-send:disabled { opacity: 0.35; cursor: not-allowed; }
.smart-err { color: #c00; font-size: 13px; margin-top: 6px; padding-left: 4px; }

/* Stat cards horizontal scroll */
.stats-scroll {
  display: flex; gap: 12px; overflow-x: auto; padding: 16px 0 8px; margin: 0 -20px; padding-left: 20px; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.stats-scroll::-webkit-scrollbar { display: none; }
.stat-card {
  flex: 0 0 200px; scroll-snap-align: start;
  background: var(--card); border-radius: var(--radius-md); padding: 16px;
  box-shadow: var(--shadow-md);
}
.stat-card .icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 12px; }
.stat-card .label { font-size: 12px; color: var(--tertiary-label); font-weight: 500; margin-bottom: 4px; }
.stat-card .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card .sub { font-size: 12px; color: var(--tertiary-label); margin-top: 6px; }

/* Apple-style card */
.card {
  background: var(--card); border-radius: var(--radius-md); padding: 16px;
  box-shadow: var(--shadow-md); margin-bottom: 16px;
}
.card-flat { box-shadow: var(--shadow-sm); border: 1px solid var(--separator); }
.section-title { font-size: 20px; font-weight: 700; margin-bottom: 12px; letter-spacing: -0.3px; }

/* Charts */
.chart-wrap { position: relative; height: 200px; margin-top: 8px; }

/* Transaction row */
.txn-list { border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-md); background: var(--card); }
.txn-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--separator);
  cursor: pointer;
}
.txn-row:last-child { border-bottom: none; }
.txn-row:hover { background: var(--fill); }
.txn-emoji { font-size: 28px; width: 44px; text-align: center; }
.txn-mid { flex: 1; min-width: 0; }
.txn-desc { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-meta { font-size: 13px; color: var(--tertiary-label); margin-top: 2px; }
.txn-amt { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.txn-amt.income { color: var(--green); }

.recent-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 12px; }
.recent-head .section-title { margin: 0; }
.link { color: var(--primary); font-weight: 600; font-size: 17px; text-decoration: none; border: none; background: none; cursor: pointer; font-family: inherit; }

/* Filters */
.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 12px; border: 1px solid var(--separator); box-shadow: var(--shadow-sm);
}
.search-box input { flex: 1; border: none; font-size: 17px; outline: none; background: transparent; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; overflow-x: auto; }
.pill {
  padding: 8px 16px; border-radius: var(--radius-full); background: var(--card); border: 1px solid var(--separator);
  font-size: 12px; font-weight: 600; color: var(--tertiary-label); cursor: pointer; white-space: nowrap; font-family: inherit;
}
.pill.active { background: var(--primary-subtle); border-color: var(--primary-light); color: var(--primary); }
.pills--sub { margin-top: -4px; margin-bottom: 10px; }
.pills--sub .pill { font-size: 11px; padding: 6px 12px; }
.count-meta { font-size: 13px; color: var(--tertiary-label); margin-bottom: 8px; font-weight: 500; }

.tx-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.tx-sum-cell {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.tx-sum-lbl {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--tertiary-label);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.tx-sum-val {
  display: block;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--label);
}
.tx-sum-val.spent { color: var(--label); }
.tx-sum-val.earned { color: var(--green); }
.tx-sum-val.net-pos { color: var(--green); }
.tx-sum-val.net-neg { color: var(--primary); }
.tx-sum-val.net-zero { color: var(--tertiary-label); }

/* Month-grouped transactions */
.tx-by-month-wrap {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}
.tx-month-block { margin-bottom: 20px; }
.tx-month-block:last-child { margin-bottom: 8px; }
.tx-month-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--label);
  padding: 6px 4px 10px;
  letter-spacing: -0.2px;
}
.tx-month-header span { color: var(--tertiary-label); font-weight: 600; font-size: 12px; margin-left: 8px; }

/* Balances */
.summary-row { display: flex; gap: 12px; overflow-x: auto; padding: 8px 0 16px; margin: 0 -20px; padding-left: 20px; }
.summary-card {
  flex: 0 0 165px; background: var(--card); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-md);
}
.summary-card .s-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 12px; }
.summary-card .s-label { font-size: 12px; color: var(--tertiary-label); margin-bottom: 4px; }
.summary-card .s-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-card .s-meta { font-size: 11px; color: var(--tertiary-label); margin-top: 4px; }

.person-card {
  background: var(--card); border-radius: var(--radius-md); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow-md); cursor: pointer;
}
.person-top { display: flex; justify-content: space-between; align-items: center; }
.person-left { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: var(--radius-sm); color: #fff; font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.person-name { font-weight: 600; font-size: 17px; }
.person-status { font-size: 13px; color: var(--tertiary-label); }
.person-bal { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.person-bal.pos { color: var(--orange); }
.person-bal.neg { color: var(--green); }
.person-details { display: flex; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--separator); font-size: 13px; color: var(--tertiary-label); }
.settle-btn {
  margin-left: auto; background: var(--primary); color: #fff; border: none; padding: 6px 12px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.txn-history { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--separator); display: none; }
.txn-history.open { display: block; }
.hist-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: 13px; }
.hist-row .desc { flex: 1; color: var(--tertiary-label); }
.hist-row .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.hist-row .amt.paid { color: var(--green); }
.btn-paid { background: var(--green); color: #fff; border: none; padding: 4px 10px; border-radius: var(--radius-full); font-size: 11px; font-weight: 700; cursor: pointer; font-family: inherit; }
.hint { text-align: center; font-size: 11px; color: var(--primary); font-weight: 600; margin-top: 12px; }

/* Insights grid */
.ins-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ins-card {
  background: var(--card); border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--separator);
}
.ins-card.wide { grid-column: 1 / -1; }
.ins-card .ic { font-size: 22px; margin-bottom: 8px; }
.ins-card .it { font-size: 11px; color: var(--tertiary-label); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.ins-card .iv { font-size: 17px; font-weight: 700; }
.ins-card .is { font-size: 12px; color: var(--tertiary-label); margin-top: 4px; }

.ins-section { margin-top: 16px; padding: 16px 18px; }
.ins-section .section-title { margin-bottom: 12px; }
.ins-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--separator);
}
.ins-metric-row:last-of-type { border-bottom: none; }
.ins-metric-row .im-k { font-size: 14px; color: var(--label); }
.ins-metric-row .im-v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ins-metric-row.sub .im-k { color: var(--tertiary-label); font-size: 13px; }
.ins-metric-row.sub .im-v { font-size: 16px; color: var(--primary); }
.ins-metric-hint { font-size: 12px; color: var(--tertiary-label); margin: -4px 0 12px; line-height: 1.35; }
.ins-cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.ins-cat-row .ick { font-size: 12px; font-weight: 600; color: var(--label); min-width: 0; flex: 1; }
.ins-cat-row .ict {
  flex: 2;
  height: 8px;
  background: var(--fill);
  border-radius: 4px;
  overflow: hidden;
  display: block;
  min-width: 0;
}
.ins-cat-row .icf {
  display: block;
  height: 100%;
  border-radius: 4px;
  max-width: 100%;
}
.ins-cat-row .icv { font-size: 12px; font-weight: 600; color: var(--tertiary-label); width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
.ins-chart-tall .chart-wrap { height: 220px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ins-month-readable {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--label);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.ins-month-input-label {
  cursor: pointer;
  display: block;
}

.ins-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ins-month-arrow {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--label);
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.ins-month-arrow:hover:not(:disabled) {
  background: var(--primary-subtle);
  color: var(--primary);
}
.ins-month-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.ins-month-input {
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  color: var(--label);
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 10px 14px;
  min-width: 168px;
  text-align: center;
  cursor: pointer;
}
.ins-month-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

/* Tab bar */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(250, 249, 247, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--separator);
  padding-bottom: var(--safe-bottom);
  display: flex; justify-content: space-around; align-items: flex-end;
  padding-top: 6px; height: calc(var(--tab-h) + var(--safe-bottom)); z-index: 100;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer; color: var(--tertiary-label); font-size: 10px; font-weight: 600; font-family: inherit; padding: 4px;
}
.tab.active { color: var(--primary); }
.tab .emoji { font-size: 20px; line-height: 1.2; }
.tab.active .emoji { font-size: 22px; }
.tab-add-wrap { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding-top: 0; }
.tab-add {
  width: 44px; height: 44px; border-radius: 22px; background: var(--primary); color: #fff;
  border: none; font-size: 22px; font-weight: 300; cursor: pointer; margin-top: -8px;
  box-shadow: 0 4px 12px rgba(240, 101, 124, 0.35); display: flex; align-items: center; justify-content: center; line-height: 1;
}

/* Modal */
.modal-bg {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; align-items: flex-end; justify-content: center;
}
.modal-bg.show { display: flex; }
.modal-sheet {
  background: var(--card); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 12px 20px 32px; animation: up 0.25s ease;
  -webkit-overflow-scrolling: touch;
}
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 36px; height: 4px; background: #ddd; border-radius: 2px; margin: 0 auto 16px; }
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--tertiary-label); margin-bottom: 6px; font-weight: 500; }
.splits-heading {
  display: block;
  font-size: 13px;
  color: var(--tertiary-label);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--separator);
  font-size: 17px; font-family: inherit; background: var(--bg);
}
.type-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.type-toggle button {
  flex: 1; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--separator);
  background: var(--card); font-weight: 600; cursor: pointer; font-family: inherit;
}
.type-toggle button.active-exp { background: var(--primary-subtle); border-color: var(--primary); color: var(--primary); }
.type-toggle button.active-inc { background: rgba(46, 204, 135, 0.12); border-color: var(--green); color: var(--green); }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.btn { flex: 1; padding: 14px; border-radius: var(--radius-sm); font-size: 17px; font-weight: 600; border: none; cursor: pointer; font-family: inherit; }
.btn-secondary { background: var(--fill); color: var(--secondary-label); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: transparent; color: #c00; flex: 0; }

.splits-editor {
  background: var(--fill);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--separator);
  font-size: 15px;
  margin-bottom: 10px;
  /* Do NOT use z-index/isolation here — it stacks the whole box above #f-split-add and steals clicks on “+ Add person” */
}
.split-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.split-edit-row:last-of-type { margin-bottom: 0; }
/* Override .form-group input { width:100% } — that was stretching the name field over the whole row and hiding × / amount */
#f-splits-wrap .split-edit-row input.split-person {
  flex: 1;
  min-width: 0;
  width: auto;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--separator);
  font-size: 16px;
  font-family: inherit;
  background: var(--card);
}
#f-splits-wrap .split-edit-row input.split-amt {
  width: 96px;
  max-width: 35%;
  flex-shrink: 0;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--separator);
  font-size: 16px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  background: var(--card);
}
.split-remove {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border: none;
  background: var(--fill);
  color: var(--tertiary-label);
  border-radius: var(--radius-sm);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.06);
}
.split-remove:hover { color: #c00; background: rgba(204, 0, 0, 0.08); }
/* Clicks hit the button, not a text node (fixes remove on last row / some browsers) */
.split-remove-label {
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
}
.btn-split-add {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 0 8px;
  min-height: 44px;
  margin-bottom: 8px;
  border: none;
  background: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 5;
  pointer-events: auto;
}
.btn-split-add-label {
  pointer-events: none;
}
#f-splits-summary {
  margin-top: 12px;
  margin-bottom: 0;
}
.splits-warn {
  color: #b00020;
  font-size: 13px;
  margin-top: 8px;
  font-weight: 500;
}
.splits-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--tertiary-label);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}
.split-read-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--separator);
  font-variant-numeric: tabular-nums;
}
.split-read-row:last-child { border-bottom: none; }
.split-read-you {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--separator);
  border-bottom: none;
  font-weight: 600;
  color: var(--label);
}
.splits-empty {
  color: var(--tertiary-label);
  font-size: 15px;
  padding: 4px 0;
}
.splits-hint {
  font-size: 12px;
  color: var(--tertiary-label);
  margin-top: 10px;
  line-height: 1.4;
}

.settings-block { background: var(--card); border-radius: var(--radius-md); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.settings-block p { font-size: 14px; color: var(--secondary-label); line-height: 1.5; }
.settings-block code { font-size: 12px; background: var(--fill); padding: 2px 6px; border-radius: 4px; }

.empty { text-align: center; padding: 48px 20px; color: var(--tertiary-label); }
.empty .e { font-size: 40px; margin-bottom: 12px; }

.loading { text-align: center; padding: 40px; color: var(--tertiary-label); }

.badge-type {
  display: inline-block; padding: 6px 12px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; margin-bottom: 12px;
}
.badge-exp { background: var(--primary-subtle); color: var(--primary); }
.badge-inc { background: rgba(46, 204, 135, 0.12); color: var(--green); }

.preview-main { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.preview-main .pe { font-size: 32px; }
.preview-main .pd { font-weight: 600; font-size: 17px; }
.preview-main .pc { font-size: 13px; color: var(--tertiary-label); }
.preview-main .pa { font-size: 20px; font-weight: 700; margin-left: auto; }

@media (min-width: 768px) {
  body { padding-bottom: calc(var(--tab-h) + 24px); }
  .tab-bar { max-width: 560px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; border-left: 1px solid var(--separator); border-right: 1px solid var(--separator); }
}
