:root {
  --ink: #141414;
  --cream: #fef4e2;
  --card-white: #ffffff;
  --brand-green: #00b140;
  --green-deep-text: #062b12;
  --text-default: #191919;
  --text-secondary: #5e5e5e;
  --text-tertiary: #8a8a8a;
  --success-text: #00822e;
  --success-bg: #e8faee;
  --error-text: #940023;
  --border-default: #d9d9d9;
  --cat-food: #cfe6ff;
  --cat-cab: #ffe8a3;
  --cat-other: #ffd8c2;
  --tip-bg: #fff8ea;
  --tip-border: #d19942;
  --tip-text: #8d3200;
  --font-display: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--text-default);
  margin: 0;
  padding: 0 20px 230px;
  max-width: 480px;
  margin-inline: auto;
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}

/* --- Header --- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 0;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--cream) 80%, transparent);
  z-index: 5;
  margin-bottom: 18px;
}

.brand-logo {
  height: 46px;
  width: auto;
}

.icon-btn {
  background: var(--card-white);
  border: 2.5px solid var(--ink);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}

/* --- Hero card --- */

.hero-card {
  position: relative;
  background: var(--brand-green);
  border: 3px solid var(--ink);
  border-radius: 28px;
  padding: 22px 22px 20px;
  box-shadow: 6px 6px 0 var(--ink);
  overflow: hidden;
  margin-bottom: 18px;
}

.hero-overline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #004115;
}

.hero-amount {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 52px;
  line-height: 1;
  letter-spacing: -2px;
  color: var(--green-deep-text);
  margin: 8px 0 6px;
  font-variant-numeric: tabular-nums;
}

.hero-tagline {
  font-size: 13px;
  color: #003d14;
  max-width: 200px;
  line-height: 1.35;
  margin: 0;
}

/* --- Big black CTA (empty-state "Add your first bill") --- */

.add-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink);
  color: #fff;
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: 6px 6px 0 var(--brand-green);
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.add-cta-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--brand-green);
  color: var(--green-deep-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex: none;
}

.add-cta-text {
  flex: 1;
}

.add-cta-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.4px;
  color: #fff;
}

.add-cta-arrow {
  font-size: 22px;
  color: #fff;
  flex: none;
}

/* --- Chips --- */

.chip-row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 0.25rem;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  background: var(--card-white);
  border: 2px solid var(--border-default);
  color: var(--text-secondary);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: var(--cat-food);
  color: var(--ink);
  border-color: var(--ink);
  border-width: 2.5px;
}

/* --- Bill rows --- */

.bills-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.bill-card {
  background: var(--card-white);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.bill-card.clickable {
  cursor: pointer;
}

.bill-thumb {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  object-fit: cover;
  background: var(--card-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex: none;
}

.bill-thumb.cat-Food { background: var(--cat-food); }
.bill-thumb.cat-Cab { background: var(--cat-cab); }
.bill-thumb.cat-Other { background: var(--cat-other); }

.bill-info {
  flex: 1;
  min-width: 0;
}

.bill-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-default);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bill-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.bill-amount {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--text-default);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.bill-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.bill-actions button {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 16px;
  cursor: pointer;
  padding: 0.15rem;
}

.bill-actions button:hover {
  color: var(--ink);
}

.add-another-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 3px dashed var(--ink);
  border-radius: 18px;
  padding: 15px;
  color: var(--text-default);
  cursor: pointer;
  margin-top: 14px;
  background: none;
  width: 100%;
  font-family: var(--font-body);
}

.add-another-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--brand-green);
  color: var(--green-deep-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex: none;
}

.add-another-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
}

/* --- Empty state --- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 14px;
}

.empty-mascot {
  width: 220px;
  height: 220px;
  object-fit: contain;
}

.empty-headline {
  font-size: 32px;
  line-height: 1.03;
  letter-spacing: -1.2px;
  color: var(--text-default);
  margin: 26px 0 10px;
  max-width: 280px;
}

.empty-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 26px;
  max-width: 270px;
  line-height: 1.4;
}

/* --- Send bar (Home only) --- */

.send-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin-inline: auto;
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--cream) 74%, transparent);
  z-index: 24;
}

.send-bar-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.send-bar-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.send-bar-total {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  color: var(--text-default);
  letter-spacing: -0.8px;
  font-variant-numeric: tabular-nums;
}

/* --- Buttons (general) --- */

.btn-cta {
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  cursor: pointer;
  width: 100%;
  text-align: center;
}

.btn-cta.green {
  background: var(--brand-green);
  color: var(--green-deep-text);
  box-shadow: 5px 5px 0 var(--ink);
}

.btn-cta:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.85rem;
  cursor: pointer;
  display: block;
  margin: 1rem auto 0;
}

.link-btn.danger {
  color: var(--error-text);
}

/* --- Forms --- */

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 1.1rem 0 0.4rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  border: 2.5px solid var(--ink);
  font-size: 1rem;
  font-family: var(--font-body);
  background: var(--card-white);
  color: var(--text-default);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-green);
}

textarea {
  resize: vertical;
}

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

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

.cat-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.cat-option {
  background: var(--card-white);
  border: 2px solid var(--border-default);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.cat-option span {
  font-size: 0.8rem;
  font-weight: 700;
}

.cat-option.active {
  border-color: var(--ink);
  border-width: 2.5px;
  color: var(--ink);
}

.cat-option[data-category="Food"].active { background: var(--cat-food); }
.cat-option[data-category="Cab"].active { background: var(--cat-cab); }
.cat-option[data-category="Other"].active { background: var(--cat-other); }

.hint {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  margin-top: 0.6rem;
}

.hint.accent {
  color: var(--success-text);
  font-weight: 600;
}

.hint.danger {
  color: var(--error-text);
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* --- Full-screen pages (Chooser / Scan preview) --- */

.page {
  position: fixed;
  inset: 0;
  background: var(--cream);
  z-index: 40;
  overflow-y: auto;
  animation: pageIn 0.2s ease;
}

.page-content {
  max-width: 480px;
  margin-inline: auto;
  padding: 20px 20px 40px;
}

.scan-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.scan-header h1 {
  font-size: 24px;
  letter-spacing: -0.6px;
}

@keyframes pageIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* --- Chooser page --- */

.chooser-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 24px;
  line-height: 1.4;
}

.choice-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.choice-card {
  display: block;
  border: 3px solid var(--ink);
  border-radius: 24px;
  padding: 24px 22px;
  box-shadow: 6px 6px 0 var(--ink);
  cursor: pointer;
}

.choice-card.green { background: var(--brand-green); }
.choice-card.white { background: var(--card-white); }

.choice-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 16px;
}

.choice-card.green .choice-icon { background: #062b12; }
.choice-card.white .choice-icon { background: #e2d5ff; border: 2px solid var(--ink); }

.choice-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.5px;
  margin: 0 0 4px;
}

.choice-card.green .choice-title { color: var(--green-deep-text); }
.choice-card.white .choice-title { color: var(--text-default); }

.choice-subtitle {
  font-size: 13px;
}

.choice-card.green .choice-subtitle { color: #003d14; }
.choice-card.white .choice-subtitle { color: var(--text-tertiary); }

.tip-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--tip-bg);
  border: 2px dashed var(--tip-border);
  border-radius: 16px;
  padding: 13px 15px;
  margin-top: 22px;
  font-size: 13px;
  color: var(--tip-text);
  line-height: 1.35;
}

/* --- Scan preview page --- */

.scan-top {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
}

.scan-thumb {
  position: relative;
  width: 104px;
  height: 132px;
  flex: none;
  border: 3px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 4px 4px 0 var(--ink);
  background: var(--card-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.scan-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scan-thumb.scanning::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 45%;
  top: -45%;
  background: linear-gradient(to bottom, transparent, rgba(0, 177, 64, 0.4), transparent);
  animation: scanSweep 1.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes scanSweep {
  0% { top: -45%; }
  100% { top: 100%; }
}

.dot-loader {
  display: inline-flex;
  gap: 3px;
  margin-left: 5px;
  vertical-align: middle;
}

.dot-loader span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  animation: dotPulse 1.2s infinite ease-in-out;
}

.dot-loader span:nth-child(2) { animation-delay: 0.2s; }
.dot-loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1.15); }
}

.scan-amount-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.scan-amount-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.scan-amount-row {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin: 4px 0 2px;
}

.scan-amount-row .currency {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  color: var(--success-text);
}

.scan-amount-row input {
  border: none;
  background: transparent;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 38px;
  letter-spacing: -1px;
  color: var(--text-default);
  width: 100%;
}

.scan-amount-row input:focus {
  outline: none;
}

.summary-card {
  background: var(--card-white);
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  margin-top: 18px;
  overflow: hidden;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1.5px solid #eee;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row.notes-row {
  align-items: flex-start;
}

.summary-label {
  font-size: 13px;
  color: var(--text-tertiary);
  flex: none;
  padding-top: 2px;
}

.summary-input {
  border: none;
  background: transparent;
  padding: 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-default);
  text-align: right;
  width: auto;
  flex: 1;
}

.summary-input:focus {
  outline: none;
}

.notes-row .summary-input {
  text-align: left;
  resize: none;
}

.scan-footnote {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 12px;
}

.scan-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin-inline: auto;
  padding: 14px 20px 26px;
  background: linear-gradient(to top, var(--cream) 72%, transparent);
  display: flex;
  align-items: stretch;
  gap: 12px;
  z-index: 30;
}

.scan-cancel {
  width: 56px;
  flex: none;
  background: var(--card-white);
  border: 3px solid var(--ink);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
}

.scan-confirm {
  flex: 1;
  background: var(--brand-green);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 5px 5px 0 var(--ink);
  text-align: center;
  padding: 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--green-deep-text);
  cursor: pointer;
}

/* --- Submitted overlay --- */

.submitted-overlay {
  background: var(--brand-green);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.submitted-content {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 26px calc(36px + env(safe-area-inset-bottom));
  text-align: center;
}

.submitted-mascot {
  width: 180px;
  height: 180px;
  object-fit: contain;
  margin-top: 22px;
}

.submitted-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--green-deep-text);
  color: #9fecb4;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 9999px;
  margin-top: 20px;
}

.submitted-headline {
  font-size: 36px;
  line-height: 1.02;
  letter-spacing: -1.4px;
  color: var(--green-deep-text);
  margin: 16px 0 10px;
}

.submitted-body {
  font-size: 15px;
  color: #003d14;
  margin: 0 0 24px;
  max-width: 290px;
  line-height: 1.4;
}

.submitted-summary {
  width: 100%;
  background: var(--card-white);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  margin-top: auto;
}

.submitted-summary-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: #c8f4d5;
  border: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex: none;
}

.submitted-summary-text {
  flex: 1;
}

.submitted-summary-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-default);
}

.submitted-summary-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

.submitted-summary-amount {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--text-default);
}

.submitted-back {
  width: 100%;
  background: var(--ink);
  color: #fff;
  border-radius: 18px;
  padding: 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  margin-top: 20px;
  border: none;
  cursor: pointer;
}

.shortcut-card {
  width: 100%;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 20px 18px;
  margin-top: 20px;
  text-align: left;
}

.shortcut-card-row {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
}

.shortcut-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.shortcut-icon img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.shortcut-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.4px;
  color: var(--text-default);
}

.shortcut-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.shortcut-cta {
  width: 100%;
  background: var(--brand-green);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 14px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: var(--green-deep-text);
  cursor: pointer;
}

.shortcut-later {
  width: 100%;
  background: none;
  border: none;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: 2px;
}

/* --- Lightbox (full-size receipt preview) --- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.92);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
}

/* --- Exit confirmation bottom sheet --- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.55);
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: backdropIn 0.2s ease;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--card-white);
  border: 3px solid var(--ink);
  border-radius: 28px 28px 0 0;
  padding: 12px 22px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
  animation: sheetUp 0.25s ease;
}

.modal-drag-handle {
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: var(--border-default);
  margin: 0 auto 18px;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-heading {
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -0.5px;
  color: var(--text-default);
  margin: 0 0 10px;
}

.modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0 0 22px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-modal {
  border-radius: 16px;
  padding: 14px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
}

.btn-modal.primary {
  background: var(--brand-green);
  color: var(--green-deep-text);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}

.btn-modal.secondary {
  background: var(--card-white);
  color: var(--text-secondary);
  border: 2.5px solid var(--border-default);
}
