:root {
  color-scheme: light;
  --ink: #17312b;
  --ink-soft: #50645f;
  --forest: #173f35;
  --forest-light: #245f4f;
  --cream: #f6f2e8;
  --paper: #fffdf8;
  --line: #dcd7ca;
  --orange: #f06f38;
  --orange-soft: #fff0e8;
  --mint: #dcebe2;
  --danger: #a43d2d;
  --shadow: 0 18px 50px rgba(27, 55, 47, 0.1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(240, 111, 56, 0.11), transparent 23rem),
    radial-gradient(circle at 88% 20%, rgba(36, 95, 79, 0.10), transparent 27rem),
    var(--cream);
}

button, input, select { font: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }

.site-header {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--forest);
  font-weight: 760;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--forest);
  border-radius: 12px 12px 12px 4px;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.privacy-note {
  color: var(--forest-light);
  background: rgba(220, 235, 226, 0.8);
  border: 1px solid rgba(36, 95, 79, 0.15);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 700;
}

.account-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.auth-mark {
  margin: 0 auto 1rem;
  background: #fff;
  color: #173f35;
  border: 1px solid #d7e2dd;
}

main {
  width: min(1040px, calc(100% - 32px));
  margin: 50px auto 80px;
}

.intro { max-width: 760px; margin-bottom: 38px; }
.eyebrow, .step-label {
  margin: 0 0 10px;
  color: var(--orange);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 720px;
  margin-bottom: 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 7vw, 72px);
  line-height: 0.98;
  letter-spacing: -0.045em;
  font-weight: 500;
}

.intro-copy {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: clamp(17px, 2.2vw, 20px);
  line-height: 1.55;
}

.upload-card, .status-card {
  position: relative;
  overflow: hidden;
  min-height: 285px;
  padding: 42px;
  display: grid;
  grid-template-columns: 145px minmax(220px, 1fr) auto;
  align-items: center;
  gap: 34px;
  background: var(--paper);
  border: 1px solid rgba(23, 63, 53, 0.12);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.upload-card::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -110px;
  bottom: -140px;
  border-radius: 50%;
  background: var(--orange-soft);
}

.receipt-illustration {
  width: 112px;
  height: 145px;
  padding: 29px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px 8px 3px 3px;
  box-shadow: 0 12px 30px rgba(23, 49, 43, 0.12);
  transform: rotate(-3deg);
}

.receipt-illustration span { height: 5px; background: var(--mint); border-radius: 3px; }
.receipt-illustration span:nth-child(1) { width: 58%; background: var(--forest); }
.receipt-illustration span:nth-child(3) { width: 78%; }
.receipt-illustration span:nth-child(4) { width: 45%; background: var(--orange); }

.upload-copy { max-width: 440px; }
.upload-copy h2, .status-card h2, .review-heading h2 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(29px, 4vw, 38px);
  font-weight: 500;
  letter-spacing: -0.025em;
}
.upload-copy p:last-child, .status-card .muted { color: var(--ink-soft); line-height: 1.55; }

.upload-actions { position: relative; z-index: 1; display: grid; gap: 10px; min-width: 190px; }
.button {
  min-height: 50px;
  padding: 13px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 760;
  cursor: pointer;
  text-align: center;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .text-button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(240, 111, 56, 0.35);
  outline-offset: 2px;
}
.button-primary { color: white; background: var(--forest); box-shadow: 0 7px 18px rgba(23, 63, 53, 0.2); }
.button-primary:hover { background: var(--forest-light); }
.button-primary span { color: #ffb38f; font-size: 11px; }
.button-secondary { color: var(--forest); background: white; border-color: var(--line); }
.button-disabled { color: #8a938f; background: #e9e9e4; cursor: not-allowed; }
.button-disabled:hover { transform: none; }
.file-hint { position: absolute; bottom: 18px; right: 42px; z-index: 1; margin: 0; color: #788782; font-size: 11px; }

.status-card { grid-template-columns: 170px 1fr; text-align: left; }
.scanner { position: relative; width: 130px; height: 160px; display: grid; place-items: center; }
.scanner-receipt { width: 100px; height: 135px; padding: 30px 16px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.scanner-receipt span { display: block; height: 5px; margin-bottom: 14px; border-radius: 3px; background: var(--mint); }
.scan-line { position: absolute; left: 5px; right: 5px; height: 3px; border-radius: 3px; background: var(--orange); box-shadow: 0 0 14px var(--orange); animation: scan 1.7s ease-in-out infinite alternate; }
@keyframes scan { from { transform: translateY(-55px); } to { transform: translateY(55px); } }

.error-card { display: block; padding-left: 125px; }
.error-symbol { position: absolute; left: 42px; top: 50%; width: 56px; height: 56px; display: grid; place-items: center; transform: translateY(-50%); border-radius: 50%; color: white; background: var(--danger); font-size: 28px; font-weight: 800; }
.error-card .button { margin-top: 10px; }
.success-card { display: block; padding-left: 125px; }
.success-symbol { position: absolute; left: 42px; top: 50%; width: 58px; height: 58px; display: grid; place-items: center; transform: translateY(-50%); border-radius: 50%; color: white; background: var(--forest-light); font-size: 28px; font-weight: 800; }
.success-card .button { margin-top: 18px; }

.review-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 25px; }
.review-heading h2 { margin-bottom: 5px; }
.muted { margin-bottom: 0; color: var(--ink-soft); line-height: 1.5; }
.text-button { padding: 8px 0; color: var(--forest-light); background: transparent; border: 0; font-weight: 760; cursor: pointer; }
.text-button:hover { color: var(--orange); }

.receipt-tabs { margin: 0 0 18px; padding: 6px; display: flex; gap: 6px; overflow-x: auto; background: rgba(255,255,255,0.6); border-radius: 14px; }
.receipt-tab { flex: 0 0 auto; padding: 10px 15px; color: var(--ink-soft); background: transparent; border: 0; border-radius: 10px; font-weight: 700; cursor: pointer; }
.receipt-tab.active { color: white; background: var(--forest); }

.review-layout { display: grid; grid-template-columns: 315px 1fr; gap: 22px; align-items: start; }
.summary-card, .items-panel, .save-panel {
  background: var(--paper);
  border: 1px solid rgba(23, 63, 53, 0.12);
  border-radius: 22px;
  box-shadow: 0 10px 34px rgba(27, 55, 47, 0.07);
}
.summary-card { position: sticky; top: 18px; padding: 24px; }
.summary-card label { display: block; margin-bottom: 18px; }
.summary-card label > span:first-child, .item-field label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.summary-card input, .item-field input, .item-field select {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.summary-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 10px; }
.money-input { position: relative; display: block; }
.money-input > span { position: absolute; left: 12px; top: 13px; color: var(--ink-soft); }
.money-input input { padding-left: 26px; }
.summary-stat { padding-top: 17px; display: flex; justify-content: space-between; border-top: 1px dashed var(--line); color: var(--ink-soft); }
.summary-stat strong { color: var(--forest); }

.items-panel { overflow: hidden; }
.items-heading { padding: 20px 22px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.items-heading h3 { margin: 0; font-size: 17px; }
.items-list { display: grid; }
.item-row { position: relative; padding: 18px 22px; display: grid; grid-template-columns: minmax(150px, 1.5fr) minmax(125px, 1fr) 90px 32px; gap: 12px; align-items: end; border-bottom: 1px solid #ebe7dd; }
.item-row:last-child { border-bottom: 0; }
.item-number { position: absolute; top: 7px; left: 9px; color: #9aa49f; font-size: 10px; }
.raw-text { margin: 6px 0 0; color: #7b8984; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.remove-item { width: 32px; height: 42px; color: #8b9792; background: transparent; border: 0; border-radius: 8px; cursor: pointer; font-size: 20px; }
.remove-item:hover { color: var(--danger); background: #fff0ed; }
.empty-items { padding: 40px 22px; color: var(--ink-soft); text-align: center; }

.save-panel { margin-top: 22px; padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 25px; }
.save-panel strong { display: block; margin-bottom: 4px; }
.save-panel p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.save-panel .save-error { margin-top: 7px; color: var(--danger); font-weight: 650; }

footer { width: min(1040px, calc(100% - 32px)); margin: 0 auto; padding: 0 0 32px; color: #71807b; font-size: 12px; text-align: center; }
.hidden { display: none !important; }
.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; }

@media (max-width: 800px) {
  main { margin-top: 30px; }
  .upload-card { grid-template-columns: 100px 1fr; padding: 30px; }
  .receipt-illustration { width: 90px; height: 120px; padding: 24px 14px; }
  .upload-actions { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .file-hint { position: static; grid-column: 1 / -1; text-align: center; }
  .review-layout { grid-template-columns: 1fr; }
  .summary-card { position: static; }
}

@media (max-width: 570px) {
  .site-header { min-height: 66px; }
  .privacy-note { display: none; }
  main { width: min(100% - 22px, 1040px); margin-bottom: 55px; }
  .intro { margin-bottom: 26px; }
  h1 { font-size: clamp(40px, 13vw, 58px); }
  .upload-card, .status-card { min-height: 0; padding: 27px 22px; display: block; text-align: center; border-radius: 22px; }
  .receipt-illustration { margin: 0 auto 26px; }
  .upload-copy { margin: 0 auto; }
  .upload-actions { display: grid; margin-top: 23px; }
  .file-hint { margin-top: 13px; }
  .scanner { margin: 0 auto 20px; }
  .error-card { padding: 28px 22px; }
  .error-symbol { position: static; margin: 0 auto 18px; transform: none; }
  .success-card { padding: 28px 22px; }
  .success-symbol { position: static; margin: 0 auto 18px; transform: none; }
  .review-heading { align-items: flex-start; }
  .review-heading .text-button { white-space: nowrap; }
  .summary-card { padding: 20px; }
  .item-row { padding: 24px 18px 18px; grid-template-columns: 1fr 82px 30px; }
  .item-field-name { grid-column: 1 / -1; }
  .item-field-category { grid-column: 1 / 2; }
  .item-field-price { grid-column: 2 / 3; }
  .remove-item { grid-column: 3 / 4; }
  .save-panel { align-items: stretch; flex-direction: column; }
  .save-panel .button { width: 100%; }
}

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