/* ─── RESET ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  background: #000;
}

/* ─── THEME ──────────────────────────────────────────────────────────────────── */
:root {
  --bg:        #F2F2F7;
  --bg2:       #E5E5EA;
  --card:      #FFFFFF;
  --card2:     #F2F2F7;
  --label:     #000000;
  --label2:    #3C3C43CC;
  --label3:    #6C6C70;
  --sep:       rgba(60,60,67,0.18);
  --accent:    #007AFF;
  --red:       #FF3B30;
  --green:     #34C759;
  --orange:    #FF9500;
  --purple:    #AF52DE;
  --ring1:     #FF375F;
  --ring2:     #30D158;
  --ring3:     #0A84FF;
  --safe-top:    env(safe-area-inset-top,    44px);
  --safe-bottom: env(safe-area-inset-bottom, 34px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:     #000000;
    --bg2:    #1C1C1E;
    --card:   #1C1C1E;
    --card2:  #2C2C2E;
    --label:  #FFFFFF;
    --label2: #EBEBF599;
    --label3: #8E8E93;
    --sep:    rgba(84,84,88,0.65);
    --accent: #0A84FF;
    --red:    #FF453A;
    --green:  #30D158;
    --orange: #FF9F0A;
    --purple: #BF5AF2;
  }
}

/* ─── APP SHELL ──────────────────────────────────────────────────────────────── */
#app {
  height: 100vh; height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  color: var(--label);
}
.screen {
  min-height: 100vh; min-height: 100dvh;
  background: var(--bg);
  padding-bottom: calc(var(--safe-bottom) + 32px);
  animation: fadeUp .22s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── NAVBAR ─────────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 90;
  background: var(--bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: calc(var(--safe-top) + 6px) 16px 12px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: .5px solid var(--sep);
}
.navbar-title { flex: 1; font-size: 17px; font-weight: 600; text-align: center; }
.large-title-wrap { padding: 8px 20px 12px; }
.large-title { font-size: 34px; font-weight: 700; }

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 14px;
  font-family: inherit; font-size: 17px; font-weight: 600;
  cursor: pointer; transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: .72; transform: scale(.96); }
.btn-primary  { background: var(--accent); color: #fff; padding: 15px 24px; width: 100%; }
.btn-secondary{ background: var(--card2); color: var(--accent); padding: 15px 24px; }
.btn-danger   { background: rgba(255,59,48,.14); color: var(--red); padding: 15px 24px; width: 100%; }
.btn-ghost    { background: transparent; color: var(--accent); padding: 8px 4px; font-size: 17px; border-radius: 8px; }
.btn-icon     { width: 34px; height: 34px; border-radius: 50%; background: var(--card2); color: var(--accent); font-size: 18px; padding: 0; flex-shrink: 0; }

/* FAB */
.fab {
  position: fixed; bottom: calc(var(--safe-bottom) + 24px); right: 24px;
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 30px;
  border: none; cursor: pointer; z-index: 50;
  box-shadow: 0 6px 24px rgba(10,132,255,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(.91); }

/* ─── CARDS ──────────────────────────────────────────────────────────────────── */
.card { background: var(--card); border-radius: 16px; overflow: hidden; margin: 0 16px 12px; }
.card-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; color: var(--label3); padding: 16px 16px 8px;
}

/* ─── FORM ───────────────────────────────────────────────────────────────────── */
.form-section { padding: 0 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--label3); margin: 0 4px 6px; }
.form-input {
  width: 100%; background: var(--card); border: none; border-radius: 12px;
  padding: 14px 16px; font-size: 17px; font-family: inherit; color: var(--label);
  outline: none; -webkit-appearance: none; margin-bottom: 16px;
}
.form-input:focus { box-shadow: 0 0 0 2.5px var(--accent); }
.form-input::placeholder { color: var(--label3); }
select.form-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238E8E93' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}

/* Amount input */
.amount-wrap {
  display: flex; align-items: center; background: var(--card);
  border-radius: 12px; padding: 0 16px; margin-bottom: 16px;
}
.amount-prefix { font-size: 24px; font-weight: 600; color: var(--label3); margin-right: 6px; }
.amount-input {
  flex: 1; border: none; background: transparent;
  font-size: 34px; font-weight: 700; color: var(--label);
  padding: 14px 0; outline: none; font-family: inherit;
}
.amount-input::placeholder { color: var(--label3); }

/* ─── WIZARD ─────────────────────────────────────────────────────────────────── */
.wizard-wrap { padding: 20px 16px 0; }
.wizard-progress { display: flex; gap: 6px; margin-bottom: 28px; }
.wdot { flex: 1; height: 4px; border-radius: 2px; background: var(--card2); transition: background .3s; }
.wdot.done   { background: var(--green); }
.wdot.active { background: var(--accent); }
.wizard-title    { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.wizard-subtitle { font-size: 15px; color: var(--label3); margin-bottom: 24px; }
.wizard-actions  { display: flex; gap: 12px; margin-top: 28px; }
.wizard-actions .btn-secondary { flex: 1; }
.wizard-actions .btn-primary   { flex: 2; }

/* ─── SEGMENT CONTROL ────────────────────────────────────────────────────────── */
.seg {
  display: flex; background: var(--card2); border-radius: 10px;
  padding: 2px; margin-bottom: 20px;
}
.seg-btn {
  flex: 1; border: none; background: transparent; color: var(--label3);
  font-family: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 4px; border-radius: 8px; cursor: pointer;
  transition: all .2s; -webkit-tap-highlight-color: transparent;
}
.seg-btn.active {
  background: var(--card); color: var(--label); font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}

/* ─── CHECKBOX LIST ──────────────────────────────────────────────────────────── */
.check-list { background: var(--card); border-radius: 16px; overflow: hidden; margin-bottom: 16px; }
.check-item {
  display: flex; align-items: center; padding: 14px 16px; gap: 12px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.check-item + .check-item { border-top: .5px solid var(--sep); }
.check-circle {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--label3);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all .2s; font-size: 13px;
}
.check-circle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.check-text { flex: 1; font-size: 17px; font-weight: 500; }
.check-sub  { font-size: 13px; color: var(--label3); }

/* Search inside lists */
.list-search {
  width: 100%; background: var(--card2); border: none; border-radius: 10px;
  padding: 10px 14px; font-size: 15px; font-family: inherit; color: var(--label);
  outline: none; margin-bottom: 10px;
}
.list-search::placeholder { color: var(--label3); }
.scroll-list { max-height: 260px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ─── PERSON ROWS ────────────────────────────────────────────────────────────── */
.person-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--card);
}
.person-row + .person-row { border-top: .5px solid var(--sep); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.person-name-label { flex: 1; font-size: 16px; font-weight: 500; }
.mini-input {
  background: var(--card2); border: none; border-radius: 8px;
  padding: 7px 10px; font-size: 15px; font-family: inherit;
  color: var(--label); text-align: right; width: 110px; outline: none;
}
.mini-input:focus { box-shadow: 0 0 0 2px var(--accent); }
.mini-label { font-size: 11px; color: var(--label3); text-align: right; margin-top: 2px; }

/* ─── CATEGORY CHIPS ─────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 0 12px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border-radius: 20px; padding: 8px 14px;
  font-size: 14px; font-weight: 500; color: var(--label3);
  cursor: pointer; transition: all .15s; -webkit-tap-highlight-color: transparent;
  border: 1.5px solid transparent;
}
.chip.on { background: rgba(10,132,255,.15); color: var(--accent); border-color: var(--accent); }
.chip-icon { font-size: 16px; }

/* ─── TOGGLE ─────────────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; padding: 14px 16px;
  background: var(--card); border-radius: 12px; margin-bottom: 16px;
}
.toggle-text { flex: 1; }
.toggle-text .tl { font-size: 17px; }
.toggle-text .ts { font-size: 13px; color: var(--label3); margin-top: 2px; }
.toggle { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.tslider {
  position: absolute; inset: 0; background: var(--card2); border-radius: 31px;
  transition: .28s; cursor: pointer;
}
.tslider::before {
  content: ''; position: absolute; width: 27px; height: 27px;
  left: 2px; top: 2px; background: #fff; border-radius: 50%;
  transition: .28s; box-shadow: 0 2px 5px rgba(0,0,0,.3);
}
.toggle input:checked + .tslider { background: var(--green); }
.toggle input:checked + .tslider::before { transform: translateX(20px); }

/* ─── PERSON SELECTOR ────────────────────────────────────────────────────────── */
.person-sel { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 0 8px; }
.psel-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.psel-avatar {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  border: 3px solid transparent; transition: all .2s; opacity: .45;
}
.psel-btn.on .psel-avatar { border-color: #fff; opacity: 1; box-shadow: 0 0 0 2px var(--accent); }
.psel-name { font-size: 11px; color: var(--label3); }
.psel-btn.on .psel-name { color: var(--accent); font-weight: 600; }

/* ─── RING CHART ─────────────────────────────────────────────────────────────── */
.ring-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 16px 16px; position: relative;
}
.ring-rel { position: relative; width: 190px; height: 190px; }
.ring-svg { width: 100%; height: 100%; }
.ring-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.ring-pct  { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.ring-amt  { font-size: 26px; font-weight: 800; line-height: 1; }
.ring-lbl  { font-size: 12px; color: var(--label3); margin-top: 3px; }

/* ─── STAT CARDS ─────────────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 16px 12px; }
.stat-card { background: var(--card); border-radius: 16px; padding: 16px; }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--label3); }
.stat-val   { font-size: 22px; font-weight: 800; margin-top: 5px; }
.stat-sub   { font-size: 12px; color: var(--label3); margin-top: 3px; }

/* ─── PROGRESS BAR ───────────────────────────────────────────────────────────── */
.pbar-wrap { padding: 12px 16px; }
.pbar-wrap + .pbar-wrap { border-top: .5px solid var(--sep); }
.pbar-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.pbar-name { font-size: 15px; font-weight: 500; }
.pbar-hero { font-size: 16px; font-weight: 700; }
.pbar-amts { font-size: 13px; color: var(--label3); }
.pbar-track { height: 7px; background: var(--card2); border-radius: 4px; overflow: hidden; }
.pbar-fill  { height: 100%; border-radius: 4px; transition: width .8s ease; }
.pbar-track.cat { height: 10px; border-radius: 5px; }
.pbar-track.cat .pbar-fill { border-radius: 5px; }

/* ─── TRIP CARD (list) ───────────────────────────────────────────────────────── */
.trip-card {
  background: var(--card); border-radius: 20px;
  margin: 12px 16px; overflow: hidden;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .12s;
}
.trip-card:active { transform: scale(.98); }
.tc-delete {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,.15); border: none;
  color: rgba(255,255,255,.7); font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.trip-card-header {
  background: linear-gradient(135deg, #0f0c29, #1a1a3e 60%, #16213e);
  padding: 20px; position: relative; overflow: hidden;
}
.trip-card-header::after {
  content: ''; position: absolute; top: -40px; right: -40px;
  width: 130px; height: 130px;
  background: rgba(10,132,255,.18); border-radius: 50%;
}
.tc-name  { font-size: 20px; font-weight: 700; color: #fff; }
.tc-dates { font-size: 13px; color: rgba(255,255,255,.55); margin-top: 3px; }
.tc-dest  { font-size: 13px; color: rgba(255,255,255,.7); margin-top: 2px; }
.tc-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; margin-top: 10px;
}
.tc-badge.active { background: rgba(48,209,88,.22); color: #30D158; }
.tc-badge.ended  { background: rgba(142,142,147,.18); color: #8E8E93; }
.trip-card-body { padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
.tc-budget { font-size: 26px; font-weight: 800; }
.tc-budget-lbl { font-size: 12px; color: var(--label3); margin-top: 2px; }
.tc-people { font-size: 13px; color: var(--label3); }

/* ─── EXPENSE ITEMS ──────────────────────────────────────────────────────────── */
.date-group-hdr {
  font-size: 13px; font-weight: 600; color: var(--label3);
  padding: 12px 20px 5px; text-transform: uppercase; letter-spacing: .5px;
}
.exp-item {
  display: flex; align-items: center; padding: 12px 16px; gap: 12px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.exp-item + .exp-item { border-top: .5px solid var(--sep); }
.exp-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.exp-info    { flex: 1; min-width: 0; }
.exp-cat     { font-size: 15px; font-weight: 500; }
.exp-note    { font-size: 13px; color: var(--label3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-meta    { font-size: 11px; color: var(--label3); margin-top: 2px; }
.exp-amount  { font-size: 17px; font-weight: 700; white-space: nowrap; }
.exp-personal{ font-size: 10px; background: var(--card2); color: var(--label3); border-radius: 4px; padding: 2px 5px; margin-left: 6px; vertical-align: middle; }

/* ─── SETTLEMENT ─────────────────────────────────────────────────────────────── */
.settle-card { background: var(--card); border-radius: 16px; margin: 0 16px 12px; overflow: hidden; }
.settle-row  { display: flex; align-items: center; padding: 15px 16px; gap: 10px; }
.settle-row + .settle-row { border-top: .5px solid var(--sep); }
.settle-from { font-size: 15px; font-weight: 600; }
.settle-arrow{ color: var(--label3); font-size: 14px; }
.settle-to   { font-size: 15px; font-weight: 600; }
.settle-amt  { margin-left: auto; font-size: 18px; font-weight: 800; color: var(--green); }

/* Person breakdown */
.pbd-card { background: var(--card); border-radius: 16px; margin: 0 16px 12px; overflow: hidden; }
.pbd-head { display: flex; align-items: center; padding: 14px 16px; gap: 10px; }
.pbd-name { font-size: 17px; font-weight: 600; flex: 1; }
.pbd-spent { font-size: 17px; font-weight: 800; }
.pbd-rows  { padding: 0 16px 12px; }
.pbd-row   { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; color: var(--label3); }
.pbd-row span:last-child { font-weight: 500; color: var(--label); }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 64px 32px; text-align: center; gap: 12px;
}
.empty-icon  { font-size: 60px; }
.empty-title { font-size: 22px; font-weight: 700; }
.empty-sub   { font-size: 15px; color: var(--label3); line-height: 1.55; }

/* ─── ACTION SHEET ───────────────────────────────────────────────────────────── */
#overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 200; display: none; align-items: flex-end;
}
#overlay.show { display: flex; }
.action-sheet {
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 8px 0 calc(var(--safe-bottom) + 10px); width: 100%;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.as-title {
  font-size: 13px; color: var(--label3); text-align: center;
  padding: 12px 20px; border-bottom: .5px solid var(--sep);
}
.as-btn {
  width: 100%; background: none; border: none; padding: 17px 20px;
  font-size: 18px; font-family: inherit; cursor: pointer;
  display: flex; align-items: center; gap: 14px; color: var(--label);
  -webkit-tap-highlight-color: transparent;
}
.as-btn + .as-btn { border-top: .5px solid var(--sep); }
.as-btn.danger { color: var(--red); }
.as-btn:active { background: var(--card2); }

/* ─── TOAST ──────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: calc(var(--safe-bottom) + 110px);
  left: 50%; transform: translateX(-50%) translateY(16px);
  background: rgba(40,40,40,.95); color: #fff;
  padding: 11px 22px; border-radius: 22px;
  font-size: 14px; font-weight: 500; z-index: 9999;
  opacity: 0; transition: opacity .22s, transform .22s;
  backdrop-filter: blur(10px); white-space: nowrap; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── MISC ───────────────────────────────────────────────────────────────────── */
.row-sep { height: .5px; background: var(--sep); margin: 0 16px; }
.spacer12 { height: 12px; }
.spacer20 { height: 20px; }
.text-red   { color: var(--red); }
.text-green { color: var(--green); }
.text-muted { color: var(--label3); }
.center     { text-align: center; }
.fw8        { font-weight: 800; }
.del-btn {
  background: rgba(255,59,48,.13); color: var(--red);
  border: none; border-radius: 8px; padding: 6px 12px;
  font-size: 13px; font-family: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.end-trip-btn {
  display: block; margin: 16px; width: calc(100% - 32px);
  background: rgba(255,59,48,.13); color: var(--red);
  border: none; border-radius: 14px; padding: 15px;
  font-size: 17px; font-weight: 600; font-family: inherit;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.add-person-row {
  display: flex; gap: 10px; align-items: center; margin-bottom: 12px;
}
.cur-tag {
  font-size: 11px; font-weight: 600; background: var(--card2);
  color: var(--label3); padding: 3px 7px; border-radius: 5px;
}
.filter-row {
  display: flex; gap: 8px; padding: 0 16px 12px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0; background: var(--card); border-radius: 20px;
  padding: 7px 14px; font-size: 14px; font-weight: 500; color: var(--label3);
  cursor: pointer; border: 1.5px solid transparent;
  -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.filter-chip.on { color: var(--accent); border-color: var(--accent); background: rgba(10,132,255,.1); }
.section-lbl {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--label3); padding: 12px 20px 6px;
}
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px; background: var(--card);
}
.info-row + .info-row { border-top: .5px solid var(--sep); }
.info-key { font-size: 15px; color: var(--label3); }
.info-val { font-size: 15px; font-weight: 500; }

/* ─── SETTINGS ROWS ──────────────────────────────────────────────────────────── */
.settings-row {
  display: flex; align-items: center; padding: 14px 16px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.settings-row:active { background: var(--card2); }
.settings-row-icon  { font-size: 20px; margin-right: 14px; line-height: 1; }
.settings-row-label { font-size: 16px; font-weight: 500; flex: 1; }
.settings-row-arrow { color: var(--label3); font-size: 18px; font-weight: 400; }

