:root {
  color-scheme: light;
  --ink: #15283c;
  --ink-soft: #365067;
  --paper: #f6f2e9;
  --card: #fffdf8;
  --line: #e5ded1;
  --coral: #d65f48;
  --coral-dark: #b84b37;
  --gold: #f4c56a;
  --aqua: #80c9c4;
  --success: #3c7965;
  --danger: #a63f39;
  --shadow: 0 18px 50px rgb(21 40 60 / 10%);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgb(128 201 196 / 55%);
  outline-offset: 2px;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

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

.offline-banner {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  background: var(--gold);
  color: #4b3712;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  min-height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: calc(104px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: calc(22px + var(--safe-top)) 22px 18px;
}

.topbar h1,
.page-heading h2,
.section-heading h2,
.sheet-header h2,
.editor-header h2,
.login-card h1 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.025em;
}

.topbar h1 {
  max-width: 580px;
  font-size: clamp(25px, 7vw, 38px);
  line-height: 1.05;
}

.eyebrow {
  margin: 0;
  color: var(--coral);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.eyebrow.pale {
  color: rgb(255 255 255 / 72%);
}

.icon-button {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 8px 20px rgb(21 40 60 / 7%);
  font-size: 22px;
  cursor: pointer;
}

.view {
  display: none;
  padding: 0 18px;
}

.view.active {
  display: block;
  animation: lift-in 220ms ease-out;
}

@keyframes lift-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

.hero-card {
  position: relative;
  min-height: 218px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 28px;
  border-radius: 30px;
  background:
    radial-gradient(circle at 80% 15%, rgb(244 197 106 / 30%), transparent 35%),
    linear-gradient(145deg, #1f4157, var(--ink));
  box-shadow: var(--shadow);
  color: white;
}

.hero-copy {
  position: relative;
  z-index: 2;
}

.trip-total {
  margin: 5px 0 2px;
  font-size: clamp(48px, 15vw, 78px);
  line-height: 1;
  font-weight: 850;
  letter-spacing: -0.055em;
}

.hero-detail {
  margin: 10px 0 0;
  color: rgb(255 255 255 / 72%);
  font-size: 14px;
}

.hero-orbit {
  position: absolute;
  top: -54px;
  right: -42px;
  width: 240px;
  height: 240px;
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 50%;
}

.hero-orbit::before,
.hero-orbit::after {
  content: "";
  position: absolute;
  inset: 35px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 50%;
}

.hero-orbit::after {
  inset: 76px;
}

.orbit-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
}

.orbit-dot.one {
  top: 108px;
  left: -6px;
}

.orbit-dot.two {
  right: 37px;
  bottom: 18px;
  background: var(--aqua);
}

.orbit-dot.three {
  top: 64px;
  right: 42px;
  width: 7px;
  height: 7px;
  background: var(--coral);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.stat-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 12px;
  align-items: center;
  min-width: 0;
  padding: 18px;
  border: 1px solid rgb(229 222 209 / 70%);
  border-radius: 20px;
  background: var(--card);
}

.stat-icon {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgb(128 201 196 / 22%);
  color: var(--success);
  font-size: 20px;
}

.stat-icon.sun {
  background: rgb(244 197 106 / 25%);
  color: #a26b0f;
}

.stat-card strong {
  overflow: hidden;
  font-size: 22px;
  text-overflow: ellipsis;
}

.stat-card span:last-child {
  color: var(--ink-soft);
  font-size: 12px;
}

.section-block {
  margin-top: 34px;
}

.section-heading,
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.section-heading.tight {
  align-items: center;
  margin-bottom: 12px;
}

.section-heading h2,
.page-heading h2 {
  font-size: 26px;
}

.section-heading h3 {
  margin: 2px 0 0;
  font-size: 21px;
}

.text-button {
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--coral-dark);
  font-weight: 750;
  cursor: pointer;
}

.text-button.strong {
  color: var(--success);
}

.receipt-list {
  display: grid;
  gap: 10px;
}

.receipt-list.roomy {
  margin-top: 16px;
}

.receipt-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  width: 100%;
  padding: 14px;
  border: 1px solid rgb(229 222 209 / 70%);
  border-radius: 18px;
  background: var(--card);
  text-align: left;
  cursor: pointer;
}

.receipt-row:active {
  transform: scale(0.99);
}

.merchant-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: rgb(214 95 72 / 12%);
  color: var(--coral-dark);
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 800;
}

.receipt-row-copy {
  min-width: 0;
}

.receipt-row-copy strong,
.receipt-row-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receipt-row-copy small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 12px;
}

.receipt-amount {
  font-weight: 800;
}

.sync-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--gold);
}

.empty-state {
  padding: 38px 22px;
  border: 1px dashed #d8cdbd;
  border-radius: 22px;
  background: rgb(255 253 248 / 70%);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 13px;
  border-radius: 18px;
  background: rgb(128 201 196 / 20%);
  color: var(--success);
  font-size: 28px;
}

.empty-state h3 {
  margin: 0 0 5px;
}

.empty-state p {
  max-width: 280px;
  margin: 0 auto 17px;
  color: var(--ink-soft);
  font-size: 14px;
}

.page-heading {
  padding-top: 8px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--card);
  color: var(--ink-soft);
}

.search-field input {
  width: 100%;
  padding: 14px 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.button {
  min-height: 44px;
  padding: 11px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  font-weight: 780;
  cursor: pointer;
}

.button.primary {
  border-color: var(--coral);
  background: var(--coral);
  color: white;
}

.button.primary:active {
  background: var(--coral-dark);
}

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: rgb(166 63 57 / 22%);
  color: var(--danger);
}

.button.compact {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 11px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

.scan-fab {
  position: fixed;
  z-index: 12;
  left: 50%;
  bottom: calc(37px + var(--safe-bottom));
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border: 7px solid var(--paper);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 12px 30px rgb(126 54 42 / 30%);
  color: white;
  font-size: 28px;
  transform: translateX(-50%);
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 86px 1fr;
  width: min(100%, 900px);
  min-height: calc(76px + var(--safe-bottom));
  padding: 8px 20px var(--safe-bottom);
  border-top: 1px solid rgb(229 222 209 / 80%);
  background: rgb(255 253 248 / 94%);
  box-shadow: 0 -12px 30px rgb(21 40 60 / 6%);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.nav-button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: #80909c;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.nav-button span:first-child {
  font-size: 24px;
  line-height: 1;
}

.nav-button.active {
  color: var(--coral);
}

dialog {
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(10 22 33 / 48%);
  backdrop-filter: blur(4px);
}

.sheet {
  width: min(100% - 24px, 540px);
  margin: auto auto 12px;
  padding: 0 20px 24px;
  border: 0;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.sheet[open] {
  animation: sheet-up 240ms ease-out;
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(25px);
  }
}

.sheet-handle {
  width: 46px;
  height: 5px;
  margin: 9px auto 16px;
  border-radius: 999px;
  background: #d2c8bb;
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}

.sheet-header h2 {
  font-size: 25px;
}

.capture-options {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.capture-option {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--card);
  text-align: left;
  cursor: pointer;
}

.capture-option strong,
.capture-option small {
  display: block;
}

.capture-option small {
  margin-top: 3px;
  color: var(--ink-soft);
}

.capture-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 15px;
  background: rgb(128 201 196 / 23%);
  color: var(--success);
  font-size: 24px;
  font-weight: 850;
}

.capture-icon.coral {
  background: rgb(214 95 72 / 13%);
  color: var(--coral-dark);
}

.capture-icon.gold {
  background: rgb(244 197 106 / 25%);
  color: #92600d;
}

.full-dialog {
  width: 100%;
  max-width: 900px;
  height: 100%;
  max-height: 100%;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: var(--paper);
}

.full-dialog[open] {
  animation: fade-in 180ms ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.editor,
.detail-panel {
  min-height: 100dvh;
}

.editor-header {
  position: sticky;
  z-index: 5;
  top: 0;
  display: grid;
  grid-template-columns: minmax(56px, 1fr) auto minmax(56px, 1fr);
  align-items: center;
  gap: 10px;
  padding: calc(14px + var(--safe-top)) 18px 12px;
  border-bottom: 1px solid rgb(229 222 209 / 80%);
  background: rgb(246 242 233 / 94%);
  backdrop-filter: blur(18px);
}

.editor-header > :last-child {
  justify-self: end;
}

.editor-header > div {
  text-align: center;
}

.editor-header h2 {
  font-size: 22px;
  white-space: nowrap;
}

.editor-body {
  display: grid;
  gap: 14px;
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 16px calc(32px + var(--safe-bottom));
}

.scan-progress {
  display: flex;
  align-items: center;
  gap: 13px;
  max-width: 648px;
  margin: 16px auto 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: #eaf5f3;
  color: #245f55;
}

.scan-progress strong,
.scan-progress span {
  display: block;
}

.scan-progress span {
  margin-top: 2px;
  font-size: 12px;
}

.spinner {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border: 3px solid rgb(60 121 101 / 24%);
  border-top-color: var(--success);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.receipt-preview-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: #d8d2c8;
  box-shadow: 0 10px 30px rgb(21 40 60 / 10%);
}

.receipt-preview-wrap img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
}

.receipt-preview-wrap .button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  box-shadow: 0 6px 15px rgb(21 40 60 / 18%);
}

.form-card {
  padding: 18px;
  border: 1px solid rgb(229 222 209 / 75%);
  border-radius: 20px;
  background: var(--card);
}

.form-card > label:not(.toggle-row) {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.form-card > label + label {
  margin-top: 15px;
}

input {
  min-width: 0;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.items-editor {
  display: grid;
  gap: 10px;
}

.item-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px 38px;
  gap: 8px;
  align-items: center;
}

.item-editor .item-name {
  grid-column: 1 / 4;
}

.item-editor .quantity-input {
  text-align: center;
}

.item-editor .amount-input {
  text-align: right;
}

.remove-item-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: rgb(166 63 57 / 9%);
  color: var(--danger);
  font-size: 22px;
  cursor: pointer;
}

.totals-editor {
  display: grid;
  gap: 8px;
}

.totals-editor label {
  display: grid !important;
  grid-template-columns: 1fr 120px;
  align-items: center;
  gap: 16px;
  margin: 0 !important;
  font-size: 15px !important;
}

.totals-editor input {
  width: 100%;
  text-align: right;
}

.totals-editor .grand-total {
  margin-top: 6px !important;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 20px !important;
  font-weight: 850;
}

.detail-photo {
  display: block;
  width: 100%;
  max-height: 460px;
  object-fit: contain;
  border-radius: 20px;
  background: #d8d2c8;
}

.detail-card {
  padding: 18px;
  border-radius: 20px;
  background: var(--card);
}

.detail-card h3 {
  margin: 0 0 13px;
}

.detail-line {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  padding: 8px 0;
}

.detail-line + .detail-line {
  border-top: 1px solid #eee8dd;
}

.detail-line.total {
  margin-top: 5px;
  font-size: 20px;
  font-weight: 850;
}

.email-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #e8f3ee;
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.delete-receipt {
  color: var(--danger);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink);
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row small {
  margin-top: 3px;
  color: var(--ink-soft);
}

input[role="switch"] {
  appearance: none;
  width: 50px;
  height: 30px;
  flex: 0 0 auto;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: #c9c9c9;
  transition: 160ms ease;
}

input[role="switch"]::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
  transition: 160ms ease;
}

input[role="switch"]:checked {
  background: var(--success);
}

input[role="switch"]:checked::before {
  transform: translateX(20px);
}

.setting-status {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
}

.setting-status + .setting-status {
  border-top: 1px solid #eee8dd;
}

.setting-status strong {
  color: var(--success);
  font-size: 13px;
}

.muted,
.fine-print {
  color: var(--ink-soft);
}

.fine-print {
  margin: 5px auto;
  max-width: 500px;
  text-align: center;
  font-size: 11px;
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(30px + var(--safe-top)) 18px calc(30px + var(--safe-bottom));
  background:
    radial-gradient(circle at 18% 15%, rgb(128 201 196 / 30%), transparent 25%),
    radial-gradient(circle at 85% 80%, rgb(244 197 106 / 35%), transparent 28%),
    var(--paper);
}

.login-card {
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgb(255 253 248 / 92%);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  width: 86px;
  margin-bottom: 18px;
  border-radius: 20px;
  box-shadow: 0 13px 25px rgb(21 40 60 / 18%);
}

.login-card h1 {
  margin-top: 6px;
  font-size: 33px;
}

.login-card form {
  display: grid;
  gap: 16px;
  margin-top: 26px;
  text-align: left;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.form-error {
  min-height: 18px;
  margin: -4px 0;
  color: var(--danger);
  font-size: 12px;
}

.toast-region {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  display: grid;
  gap: 8px;
  width: min(calc(100% - 32px), 480px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 13px 16px;
  border-radius: 14px;
  background: var(--ink);
  box-shadow: 0 10px 30px rgb(21 40 60 / 25%);
  color: white;
  font-size: 13px;
  font-weight: 700;
  animation: toast-in 200ms ease-out;
}

.toast.error {
  background: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (min-width: 700px) {
  .topbar,
  .view {
    padding-left: 32px;
    padding-right: 32px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .hero-card {
    min-height: 250px;
  }

  .sheet {
    margin-bottom: 28px;
  }
}

@media (display-mode: standalone) {
  .topbar {
    padding-top: calc(16px + var(--safe-top));
  }
}

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