/* Penny — minimalist but cute. Warm cream, coral accent, pastel chips, springy motion. */

:root {
  --bg: #FAF6F0;
  --card: #FFFFFF;
  --ink: #2E2A33;
  --muted: #948B9E;
  --line: #F0EAE2;
  --coral: #FF6B5E;
  --coral-deep: #F4564A;
  --peach: #FFD9C7;
  --lilac: #E4DCFB;
  --mint: #D7F0E1;
  --butter: #FFF0BF;
  --radius: 22px;
  --shadow: 0 10px 30px -12px rgba(72, 48, 40, 0.18);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --nav-h: 84px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Nunito", ui-rounded, -apple-system, "SF Pro Rounded", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 16px) 20px calc(var(--nav-h) + 24px);
  overscroll-behavior-y: none;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font: inherit; color: inherit; }

/* ---------- header ---------- */
.app-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 8px 2px 18px; }
.greeting { font-size: 24px; font-weight: 900; letter-spacing: -0.02em; }
.subgreeting { font-size: 14px; font-weight: 600; color: var(--muted); }
.sync-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--butter); border-radius: 999px; padding: 6px 12px;
  font-size: 12px; font-weight: 700; color: #8A6D1A;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #E4A11B; animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }

/* ---------- views ---------- */
.view { display: none; }
.view.active { display: block; animation: view-in 0.32s var(--spring); }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- hero ---------- */
.hero-card {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #FFE7D9 0%, #F3EBFF 100%);
  border-radius: 26px;
  padding: 26px 24px 24px;
  box-shadow: var(--shadow);
}
.hero-label { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: #A2708B; }
.hero-amount { font-size: 42px; font-weight: 900; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.hero-meta { font-size: 14px; font-weight: 700; color: #A2708B; margin-top: 4px; }
.hero-blobs i {
  position: absolute; border-radius: 50%; opacity: 0.5; filter: blur(2px);
  animation: floaty 7s ease-in-out infinite;
}
.hero-blobs i:nth-child(1) { width: 90px; height: 90px; background: #FFC7B8; right: -24px; top: -28px; }
.hero-blobs i:nth-child(2) { width: 46px; height: 46px; background: #D9CDFF; right: 64px; bottom: -16px; animation-delay: -2.5s; }
.hero-blobs i:nth-child(3) { width: 22px; height: 22px; background: #BFE8D2; right: 34px; top: 34px; animation-delay: -5s; }
@keyframes floaty { 50% { transform: translateY(-8px); } }

/* ---------- sections & lists ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 12px; }
.section-head h2 { font-size: 18px; font-weight: 900; letter-spacing: -0.01em; }
.link-btn { font-size: 14px; font-weight: 800; color: var(--coral); transition: transform 0.15s var(--spring); }
.link-btn:active { transform: scale(0.92); }

.expense-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.expense-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: 0 4px 14px -8px rgba(72, 48, 40, 0.12);
  transition: transform 0.15s var(--spring);
  animation: row-in 0.35s var(--spring) backwards;
}
.expense-row:active { transform: scale(0.975); }
@keyframes row-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.row-emoji {
  width: 44px; height: 44px; border-radius: 15px; flex: none;
  display: grid; place-items: center; font-size: 21px;
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amount { font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums; }
.row-amount .unsynced { color: #E4A11B; font-size: 11px; display: block; text-align: right; }

.day-group { margin-bottom: 18px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 8px; }
.day-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.day-total { font-size: 13px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- empty states ---------- */
.empty-state { text-align: center; padding: 44px 0 30px; }
.empty-emoji { font-size: 44px; margin-bottom: 10px; animation: floaty 4s ease-in-out infinite; }
.empty-state p { font-weight: 800; }
.empty-sub { color: var(--muted); font-weight: 600 !important; font-size: 14px; margin-top: 2px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-around;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 84px; opacity: 0.45; transition: opacity 0.2s, transform 0.2s var(--spring); }
.nav-btn.active { opacity: 1; }
.nav-btn:active { transform: scale(0.9); }
.nav-icon { font-size: 20px; }
.nav-text { font-size: 11.5px; font-weight: 800; }
.fab {
  width: 62px; height: 62px; border-radius: 22px; margin-top: -26px;
  background: linear-gradient(145deg, var(--coral), var(--coral-deep));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 12px 24px -8px rgba(244, 86, 74, 0.55);
  transition: transform 0.2s var(--spring), box-shadow 0.2s;
}
.fab:active { transform: scale(0.86) rotate(90deg); box-shadow: 0 6px 14px -6px rgba(244, 86, 74, 0.5); }

/* ---------- sheets ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(46, 42, 51, 0.4); z-index: 30;
  animation: fade-in 0.25s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 10px 22px calc(env(safe-area-inset-bottom) + 22px);
  z-index: 40;
  animation: sheet-up 0.38s var(--spring);
}
@keyframes sheet-up { from { transform: translate(-50%, 100%); } }
.sheet-handle { width: 42px; height: 5px; border-radius: 99px; background: #E3DBD1; margin: 6px auto 14px; }
.sheet-title { font-size: 21px; font-weight: 900; letter-spacing: -0.02em; margin-bottom: 16px; }

/* ---------- add form ---------- */
.amount-card {
  background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.amount-row { display: flex; align-items: center; gap: 12px; justify-content: center; }
.currency-btn {
  flex: none; display: flex; align-items: center; gap: 6px;
  background: var(--bg); border-radius: 999px; padding: 8px 13px;
  font-size: 14px; font-weight: 900; color: var(--ink);
  transition: transform 0.18s var(--spring);
}
.currency-btn:active { transform: scale(0.9); }
.conv-line {
  display: block; width: 100%; text-align: center; margin-top: 10px;
  font-size: 13.5px; font-weight: 800; color: var(--muted);
}
.conv-line .fx-flag { opacity: 0.9; }
.override-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  margin-top: 10px; background: var(--bg); border-radius: 14px; padding: 10px 14px;
  font-size: 13px; font-weight: 800; color: var(--muted);
  animation: row-in 0.3s var(--spring);
}
.override-row input {
  width: 110px; border: 0; outline: 0; background: transparent; text-align: right;
  font-weight: 900; font-size: 16px; font-variant-numeric: tabular-nums; caret-color: var(--coral);
}
.amount-input {
  border: 0; outline: 0; background: transparent; width: 60%;
  font-size: 44px; font-weight: 900; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  caret-color: var(--coral);
}
.amount-input::placeholder { color: #E4DCD2; }

.field-label { font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 8px; display: block; }
.field-label em { font-style: normal; font-weight: 600; opacity: 0.7; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  display: flex; align-items: center; gap: 7px;
  border-radius: 999px; padding: 9px 14px 9px 10px;
  background: var(--card); border: 2px solid transparent;
  font-size: 14px; font-weight: 800;
  transition: transform 0.18s var(--spring), border-color 0.15s, background 0.15s;
}
.chip:active { transform: scale(0.9); }
.chip.selected { border-color: var(--ink); animation: chip-pop 0.3s var(--spring); }
@keyframes chip-pop { 40% { transform: scale(1.12); } }

.field { display: block; margin-bottom: 16px; }
.field-cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.field input {
  width: 100%; border: 0; outline: 0; background: var(--card);
  border-radius: 16px; padding: 13px 14px; font-weight: 700; font-size: 15px;
  box-shadow: 0 3px 10px -6px rgba(72, 48, 40, 0.12);
  transition: box-shadow 0.15s;
  -webkit-appearance: none; appearance: none; min-height: 48px;
}
.field input:focus { box-shadow: 0 0 0 2.5px var(--peach); }
.field input::placeholder { color: #CFC7BC; }

.btn-primary {
  width: 100%; padding: 16px; border-radius: 999px;
  background: linear-gradient(145deg, var(--coral), var(--coral-deep));
  color: #fff; font-weight: 900; font-size: 16.5px;
  box-shadow: 0 12px 24px -10px rgba(244, 86, 74, 0.55);
  transition: transform 0.18s var(--spring);
  margin-top: 6px;
}
.btn-primary:active { transform: scale(0.96); }
.btn-ghost { width: 100%; padding: 14px; border-radius: 999px; font-weight: 800; color: var(--muted); transition: transform 0.18s var(--spring); }
.btn-ghost:active { transform: scale(0.96); }
.btn-danger {
  width: 100%; padding: 15px; border-radius: 999px;
  background: #FFE3E0; color: #D33A2E; font-weight: 900;
  transition: transform 0.18s var(--spring);
}
.btn-danger:active { transform: scale(0.96); }

.shake { animation: shake 0.4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* ---------- confirm ---------- */
.confirm-card {
  background: var(--card); border-radius: 26px; padding: 26px 22px;
  text-align: center; box-shadow: var(--shadow); margin-bottom: 16px;
}
.confirm-emoji {
  width: 64px; height: 64px; border-radius: 22px; margin: 0 auto 12px;
  display: grid; place-items: center; font-size: 30px; background: var(--peach);
  animation: chip-pop 0.45s var(--spring);
}
.confirm-amount { font-size: 38px; font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.confirm-category { font-size: 14px; font-weight: 800; color: var(--muted); margin-top: 2px; }
.confirm-details { list-style: none; margin-top: 18px; border-top: 1.5px dashed var(--line); padding-top: 6px; }
.confirm-details li { display: flex; justify-content: space-between; gap: 14px; padding: 9px 2px; font-size: 14.5px; }
.confirm-details span { color: var(--muted); font-weight: 700; flex: none; }
.confirm-details b { font-weight: 800; text-align: right; overflow-wrap: anywhere; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }

/* ---------- row action sheet ---------- */
.sheet-mini { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }
.row-preview { margin-bottom: 14px; }
.row-preview .expense-row { box-shadow: none; background: var(--card); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #FFF8F0; font-weight: 800; font-size: 14.5px;
  padding: 12px 20px; border-radius: 999px; z-index: 60;
  box-shadow: 0 10px 30px -10px rgba(46, 42, 51, 0.5);
  transition: transform 0.35s var(--spring), opacity 0.25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- confetti ---------- */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
.confetti-bit {
  position: absolute; width: 9px; height: 9px; border-radius: 3px;
  animation: confetti-fly 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes confetti-fly {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.4) rotate(var(--rot)); opacity: 0; }
}

/* ---------- pills (insights filters) ---------- */
.pill-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.pill {
  border-radius: 999px; padding: 8px 15px; background: var(--card);
  font-size: 13.5px; font-weight: 800; color: var(--muted);
  box-shadow: 0 3px 10px -6px rgba(72, 48, 40, 0.12);
  transition: transform 0.18s var(--spring), background 0.15s, color 0.15s;
}
.pill:active { transform: scale(0.92); }
.pill.selected { background: var(--ink); color: #FFF8F0; }

/* ---------- insights ---------- */
.insight-total-card {
  background: linear-gradient(135deg, #FFE7D9 0%, #F3EBFF 100%);
  border-radius: var(--radius); padding: 18px 20px; margin: 6px 0 18px;
  box-shadow: var(--shadow);
}
.insight-total { font-size: 30px; font-weight: 900; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.insight-meta { font-size: 13px; font-weight: 700; color: #A2708B; }
.insight-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; animation: row-in 0.35s var(--spring) backwards; }
.insight-bar-emoji { width: 40px; height: 40px; border-radius: 14px; flex: none; display: grid; place-items: center; font-size: 19px; }
.insight-bar-main { flex: 1; min-width: 0; }
.insight-bar-top { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 800; margin-bottom: 5px; }
.insight-bar-top .amt { font-variant-numeric: tabular-nums; }
.insight-bar-track { display: block; height: 10px; border-radius: 99px; background: var(--card); overflow: hidden; }
.insight-bar-fill { display: block; height: 100%; border-radius: 99px; width: 0; transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1); }

/* ---------- settings ---------- */
.settings-card {
  background: var(--card); border-radius: var(--radius); padding: 4px 18px;
  box-shadow: var(--shadow);
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 0; border-bottom: 1.5px dashed var(--line);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row b { font-size: 15px; font-weight: 800; display: block; }
.settings-row small { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.settings-row select {
  border: 0; outline: 0; background: var(--bg); border-radius: 12px;
  padding: 10px 12px; font: inherit; font-weight: 800; color: var(--ink);
  -webkit-appearance: none; appearance: none; text-align: right;
}
.switch { position: relative; flex: none; }
.switch input { position: absolute; opacity: 0; }
.switch i {
  display: block; width: 52px; height: 31px; border-radius: 99px;
  background: #E8E1D7; transition: background 0.25s; position: relative;
}
.switch i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 25px; height: 25px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.25s var(--spring);
}
.switch input:checked + i { background: var(--coral); }
.switch input:checked + i::after { transform: translateX(21px); }
.settings-note { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 14px 6px 0; line-height: 1.5; }
.made-with { text-align: center; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-top: 34px; }

/* ---------- business toggle in add form ---------- */
.biz-block { margin-bottom: 18px; }
.biz-toggle { display: block; margin-bottom: 12px; }
.biz-toggle input { position: absolute; opacity: 0; }
.biz-chip {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 999px; padding: 9px 15px;
  background: var(--card); border: 2px solid transparent;
  font-size: 14px; font-weight: 800;
  transition: transform 0.18s var(--spring), border-color 0.15s;
}
.biz-toggle input:checked + .biz-chip { border-color: var(--ink); animation: chip-pop 0.3s var(--spring); }
.biz-toggle:active .biz-chip { transform: scale(0.94); }

/* ---------- currency sheet ---------- */
.currency-search {
  width: 100%; border: 0; outline: 0; background: var(--card);
  border-radius: 16px; padding: 13px 16px; font: inherit; font-weight: 700;
  box-shadow: 0 3px 10px -6px rgba(72, 48, 40, 0.12); margin-bottom: 12px;
  -webkit-appearance: none; appearance: none;
}
.currency-search:focus { box-shadow: 0 0 0 2.5px var(--peach); }
.currency-list { max-height: 46dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; }
.currency-opt {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--card); border-radius: 16px; padding: 12px 14px;
  font-size: 15px; font-weight: 800;
  transition: transform 0.15s var(--spring);
}
.currency-opt:active { transform: scale(0.97); }
.currency-opt .code { flex: none; }
.currency-opt .cname { flex: 1; font-weight: 600; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.currency-opt .sel { color: var(--coral); font-weight: 900; }

/* ---------- trips ---------- */
.trips-head { margin-top: 32px; }
.trip-card {
  width: 100%; text-align: left;
  background: linear-gradient(135deg, #FFF0E2 0%, #EAF3FF 100%);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px;
  box-shadow: 0 4px 14px -8px rgba(72, 48, 40, 0.14);
  transition: transform 0.15s var(--spring);
  animation: row-in 0.35s var(--spring) backwards;
}
.trip-card:active { transform: scale(0.98); }
.trip-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.trip-name { font-size: 16px; font-weight: 900; }
.trip-total { font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; }
.trip-sub { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700; color: #9B8B7E; margin-top: 3px; }
.trip-expenses { margin-top: 12px; }
.empty-state.slim { padding: 10px 0 4px; text-align: left; }

/* ---------- category management (settings) ---------- */
.cat-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 0; border-bottom: 1.5px dashed var(--line);
  transition: transform 0.15s var(--spring);
}
.cat-row:active { transform: scale(0.98); }
.cat-row:last-child { border-bottom: 0; }
.cat-row .row-emoji { width: 38px; height: 38px; font-size: 18px; border-radius: 13px; }
.cat-row-name { flex: 1; font-size: 15px; font-weight: 800; }
.cat-row-count { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.archived-toggle {
  display: block; margin: 14px 6px 8px; font-size: 13.5px; font-weight: 800; color: var(--muted);
}
.cat-action-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cat-action-head .row-emoji { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; font-size: 21px; }
.cat-action-head b { font-size: 17px; font-weight: 900; display: block; }
.cat-action-head small { font-size: 13px; font-weight: 700; color: var(--muted); }
#cat-action-body .btn-primary, #cat-action-body .btn-danger, #cat-action-body .btn-ghost { margin-top: 8px; }
.reassign-note { font-size: 13.5px; font-weight: 700; color: var(--muted); margin: 4px 2px 10px; }
.field-cols.even { grid-template-columns: 1fr 1fr; }
.field-cols.emoji-name { grid-template-columns: 84px 1fr; }
#in-cat-emoji { text-align: center; font-size: 22px; }

/* ---------- confirm fx line ---------- */
.confirm-fx { font-size: 14px; font-weight: 800; color: var(--muted); margin-top: 2px; }

/* ---------- motion respect ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
