:root {
  --truck-width: min(1360px, 88vw);
  --ink: #4b2e25;
  --cream: #fff0c4;
  --paper: #fff2c9;
  --orange: #df7926;
  --orange-dark: #b84d22;
  --teal: #214748;
  --teal-deep: #142f31;
  --wood: #603b2d;
  --line: #6b4231;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: #143b3e;
}

* { box-sizing: border-box; }

html,
body { min-width: 320px; min-height: 100%; margin: 0; padding: 0; }

body { overflow-x: hidden; }

button,
input { font: inherit; }

button { cursor: pointer; }

#scene-background {
  position: fixed;
  z-index: -2;
  inset: 0;
  background-image: url("./assets/food-truck-scene-bg-v1.png");
  background-size: cover;
  background-position: center top;
}

#scene-background::after {
  content: "";
  position: absolute;
  inset: 38% 0 0;
  background: linear-gradient(to bottom, transparent, rgba(17, 57, 60, .28) 25%, rgba(17, 57, 60, .78));
  pointer-events: none;
}

.page-shell {
  width: 100%;
  min-height: 100vh;
  padding-top: 0;
}

.truck-header {
  position: relative;
  z-index: 2;
  container-type: inline-size;
  width: var(--truck-width);
  margin: 0 auto -2px;
  overflow: visible;
}

.hero-stage {
  --sign-width: clamp(360px, 49cqw, 570px);
  --sign-height: clamp(121px, 16.5cqw, 192px);
  --roof-height: clamp(71px, 9.5cqw, 93px);
  --sign-overlap: clamp(30px, 4cqw, 50px);
  position: relative;
  width: 100%;
  height: calc(var(--roof-height) + var(--sign-height) - var(--sign-overlap));
}

.title-art,
.roof-art {
  position: absolute;
  display: block;
  left: 50%;
  max-width: none;
  transform: translateX(-50%);
}

.title-art {
  z-index: 2;
  top: 0;
  width: var(--sign-width);
  height: var(--sign-height);
}

.roof-art {
  z-index: 1;
  bottom: 0;
  overflow: hidden;
  width: 100%;
  height: var(--roof-height);
}

.roof-art img {
  position: absolute;
  right: 0;
  bottom: calc(var(--roof-height) * -.0708);
  left: 0;
  display: block;
  width: 100%;
  height: calc(var(--roof-height) * 1.3417);
  max-width: none;
  object-fit: fill;
}

.truck-body {
  position: relative;
  z-index: 1;
  width: var(--truck-width);
  min-height: 760px;
  margin: 0 auto 70px;
  padding: 20px clamp(22px, 3vw, 48px) 42px;
  border-right: 7px solid #5c382c;
  border-left: 7px solid #5c382c;
  border-bottom: 12px solid #5c382c;
  border-radius: 18px 18px 34px 34px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.08), transparent 16%, transparent 84%, rgba(94,42,28,.14)),
    var(--orange);
  box-shadow: 0 24px 45px rgba(41, 26, 22, .34);
}

.rivets {
  position: absolute;
  top: 13px;
  right: 26px;
  left: 26px;
  height: 10px;
  background: radial-gradient(circle, #f1aa42 0 3px, #5a382e 3.5px 5px, transparent 5.5px) 0 0 / 70px 10px repeat-x;
}

.budget-board {
  position: relative;
  display: grid;
  grid-template-columns: 1.1fr 1.4fr 1.1fr;
  align-items: center;
  gap: 24px;
  width: min(960px, 76%);
  min-height: 130px;
  margin: 0 auto 18px;
  padding: 12px 24px;
  border: 7px solid var(--wood);
  border-radius: 18px;
  color: var(--cream);
  background: var(--teal);
  box-shadow: 9px 11px 0 rgba(92, 53, 39, .65), inset 0 0 0 3px #c58b57;
}

.budget-main { text-align: center; }

.fy-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 55px;
  min-height: 25px;
  margin-bottom: 2px;
  border: 2px solid #f5b241;
  border-radius: 99px;
  color: #ffd16d;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
}

.budget-main p { margin: 2px 0 3px; color: #c5d1c5; font-size: 13px; font-weight: 700; }

.budget-main > strong {
  display: block;
  color: #fff0c5;
  font-size: clamp(34px, 3.1vw, 52px);
  line-height: 1;
  text-shadow: none;
  white-space: nowrap;
}

.budget-main strong small { font-size: .48em; }

.progress-track {
  height: 14px;
  padding: 3px;
  border: 2px solid #fff0c5;
  border-radius: 99px;
  background: #173235;
}

.progress-track span {
  display: block;
  width: 37.24%;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #f26a3f, #ffc556);
}

.progress-meta { display: flex; justify-content: space-between; margin-top: 7px; color: #c5d1c5; font-size: 12px; }

.budget-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding-left: 22px;
  border-left: 1px solid #6e8984;
}

.budget-stats span { color: #c5d1c5; font-size: 12px; font-weight: 700; }
.budget-stats strong { display: block; margin-top: 2px; font-size: 23px; }
.budget-stats > div:last-child strong { color: #ff9c50; }

.edit-budget {
  width: auto;
  min-width: 64px;
  height: 27px;
  margin-left: 6px;
  padding: 2px 8px;
  border: 2px solid #5b382b;
  border-radius: 8px;
  color: #4a3025;
  background: linear-gradient(145deg, #ffd56d, #ee8e25);
  box-shadow: 0 3px 0 #3d2923, inset 0 2px 0 rgba(255,255,255,.48);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
  transition: transform .12s ease, box-shadow .12s ease;
}

.edit-budget:hover { transform: translateY(-1px); filter: brightness(1.06); }
.edit-budget:active { transform: translateY(3px); box-shadow: 0 1px 0 #3d2923; }

.budget-editor {
  position: absolute;
  right: 18px;
  bottom: -56px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 3px solid var(--wood);
  border-radius: 10px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 4px 5px 0 rgba(70, 38, 28, .35);
}

.budget-editor[hidden] { display: none; }
.budget-editor label { font-size: 12px; font-weight: 900; }
.budget-editor input { width: 130px; height: 34px; border: 2px solid var(--wood); border-radius: 7px; padding: 5px 8px; }
.budget-editor button { height: 34px; border: 0; border-radius: 7px; color: #fff6d6; background: #1f5651; font-weight: 900; }

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(360px, .9fr);
  grid-template-areas: "list form";
  align-items: start;
  gap: 22px;
  padding: 10px;
  border: 7px solid var(--wood);
  border-radius: 22px;
  background: #744630;
  box-shadow: inset 0 0 0 3px #c58452;
}

.ledger-panel {
  overflow: hidden;
  border: 5px solid #4f3028;
  border-radius: 15px;
  box-shadow: 5px 6px 0 rgba(67, 35, 26, .28);
}

.expense-list { grid-area: list; min-height: 560px; color: #fff0c5; background: #1f4142; }
.expense-form { grid-area: form; min-height: 440px; overflow: visible; background: var(--paper); }

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 14px 20px 12px;
  border-bottom: 4px solid #563529;
}

.panel-heading h2 { margin: 0; font-size: 24px; line-height: 1.2; }
.panel-heading p { margin: 7px 0 0; font-size: 13px; font-weight: 650; opacity: .72; }
.dark-heading { background: #25494a; }
.paper-heading { background: #fff0c4; }

.pan-icon,
.ticket-mark {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border: 3px solid #62392a;
  border-radius: 50%;
  color: #603b2d;
  background: #f4a537;
  box-shadow: 2px 3px 0 #3f2822;
}

.table-head,
.record {
  display: grid;
  grid-template-columns: 82px minmax(150px, 1fr) 100px 110px 34px;
  align-items: center;
  gap: 12px;
}

.table-head {
  min-height: 46px;
  padding: 0 18px;
  border-bottom: 2px dashed #6f8982;
  color: #bcd0c6;
  font-size: 12px;
  font-weight: 750;
}

.table-head > span:nth-child(4) { text-align: right; }

.records { padding-bottom: 8px; }

.record {
  min-height: 58px;
  padding: 8px 18px;
  border-bottom: 1px dashed #718b85;
  font-size: 14px;
}

.record:last-child { border-bottom: 0; }
.record .record-date { color: #c2d1c4; }
.record .record-purpose { overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.receipt-link {
  padding: 0;
  border: 0;
  color: #ff9d50;
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  text-decoration: underline dotted rgba(255, 157, 80, .8);
  text-underline-offset: 3px;
}
.receipt-link:hover { color: #ffc170; }
.record .record-amount { text-align: right; font-size: 16px; font-weight: 900; }

.records-message {
  margin: 0;
  padding: 42px 20px;
  color: rgba(255, 246, 214, .7);
  text-align: center;
  font-weight: 800;
}

button:disabled { cursor: wait; opacity: .72; }

.record-actions { display: flex; justify-content: flex-end; }
.more-button { width: 30px; height: 30px; padding: 0; border: 0; color: #b9cec4; background: transparent; font-size: 20px; font-weight: 900; }
.record-menu { display: none; gap: 4px; }
.record.is-open .more-button { display: none; }
.record.is-open .record-menu { display: flex; }
.record-menu button { padding: 4px 6px; border: 0; border-radius: 5px; color: #173536; background: #f6d68c; font-size: 11px; font-weight: 800; }
.record-menu .danger { color: #fff1d1; background: #b84d35; }

.form-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 12px;
  padding: 12px 18px 16px;
}

.form-fields label,
.form-label { display: grid; gap: 6px; font-size: 13px; font-weight: 900; }
.full-field { grid-column: 1 / -1; }

.form-fields input:not([type="file"]) {
  width: 100%;
  height: 38px;
  border: 3px solid var(--line);
  border-radius: 9px;
  padding: 7px 11px;
  outline: 0;
  color: var(--ink);
  background: #fffaf0;
  box-shadow: inset 0 2px 0 rgba(90, 53, 40, .08);
}

.form-fields input:focus { border-color: #1d6560; box-shadow: 0 0 0 3px rgba(31, 101, 96, .16); }

.date-shell {
  position: relative;
  display: block;
  cursor: pointer;
}

.date-shell input { padding-right: 31px !important; padding-left: 8px !important; font-size: 11px; cursor: pointer; }

.date-badge {
  position: absolute;
  top: 50%;
  right: 3px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 24px;
  height: 25px;
  border: 2px solid #60382b;
  border-radius: 7px;
  color: #573228;
  background: #f5a536;
  box-shadow: 0 2px 0 #60382b;
  font-size: 15px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  transform: translateY(-55%);
}

.date-picker {
  position: absolute;
  z-index: 30;
  top: calc(100% + 9px);
  right: 0;
  width: min(282px, calc(100vw - 32px));
  padding: 10px;
  border: 5px solid #5b382b;
  border-radius: 14px;
  color: #543328;
  background: #fff0c4;
  box-shadow: 7px 8px 0 rgba(72, 40, 30, .55), inset 0 0 0 2px #d39a58;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}
.date-picker[hidden] { display: none; }
.date-picker.opens-up { top: auto; bottom: calc(100% + 9px); }

.date-picker-head {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.date-picker-head strong { text-align: center; font-size: 14px; }
.date-picker-head button {
  width: 34px;
  height: 30px;
  padding: 0;
  border: 2px solid #5b382b;
  border-radius: 8px;
  color: #573228;
  background: #f4a33a;
  box-shadow: 0 2px 0 #5b382b;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.calendar-weekdays { margin-bottom: 4px; color: #8d6858; text-align: center; font-size: 10px; }
.calendar-days button,
.calendar-blank { min-width: 0; height: 29px; }
.calendar-days button {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  color: #543328;
  background: rgba(255,255,255,.56);
  font-size: 11px;
  font-weight: 800;
}
.calendar-days button:hover { border-color: #e78a32; background: #ffe09a; }
.calendar-days button.is-today { border-color: #2e6961; color: #24534e; }
.calendar-days button.is-selected {
  border-color: #59372b;
  color: #fff3d1;
  background: #d86732;
  box-shadow: 0 2px 0 #59372b;
}

.select-today {
  width: 100%;
  height: 29px;
  margin-top: 8px;
  padding: 0;
  border: 2px solid #5b382b;
  border-radius: 8px;
  color: #fff0c5;
  background: #1e5b55;
  font-size: 11px;
  font-weight: 900;
}

.upload-field {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 58px;
  padding: 7px;
  border: 3px dashed #688f83;
  border-radius: 10px;
  color: #315e57;
  text-align: center;
  background: rgba(255,255,255,.35);
  cursor: pointer;
}

.upload-field input { display: none; }
.upload-prompt {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 42px;
  cursor: pointer;
}
.upload-prompt span { font-size: 14px; }
.upload-field small { color: #6d7c70; font-size: 11px; font-weight: 650; }
.upload-prompt[hidden],
.upload-preview[hidden] { display: none; }

.upload-preview {
  position: relative;
  width: 100%;
  min-width: 0;
}

.preview-receipt {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  padding: 4px 38px 4px 5px;
  border: 0;
  color: #28564f;
  text-align: left;
  background: transparent;
}

.preview-receipt img {
  width: 42px;
  height: 42px;
  border: 2px solid #5b3a2d;
  border-radius: 7px;
  object-fit: cover;
  background: #fff9e9;
}

.preview-receipt span { overflow: hidden; font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.preview-receipt.is-placeholder::before {
  content: "▧";
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #5b3a2d;
  border-radius: 7px;
  color: #684133;
  background: #f2bc61;
  font-size: 24px;
}

.remove-receipt {
  position: absolute;
  top: -3px;
  right: -3px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 3px solid #61382d;
  border-radius: 50%;
  color: #fff1cf;
  background: #bd4c35;
  box-shadow: 0 2px 0 #61382d;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.form-actions { display: flex; gap: 9px; }
.save-button,
.secondary-button {
  min-height: 40px;
  border: 3px solid #4d3027;
  border-radius: 9px;
  font-weight: 900;
  box-shadow: 0 5px 0 #4d3027;
  transition: transform .12s ease, box-shadow .12s ease;
}

.save-button { flex: 1; color: #fff0c5; background: #1d5651; }
.secondary-button { color: #5b392b; background: #f0c16f; }
.save-button:active,
.secondary-button:active { transform: translateY(4px); box-shadow: 0 1px 0 #4d3027; }

.toast {
  position: fixed;
  z-index: 100;
  top: 50%;
  left: 50%;
  width: max-content;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 22px;
  border: 4px solid #4c3028;
  border-radius: 13px;
  color: #fff0c5;
  background: #1f4d49;
  box-shadow: 7px 8px 0 rgba(61, 35, 27, .5), inset 0 0 0 2px rgba(255, 213, 126, .25);
  text-align: center;
  font-size: 15px;
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.confirm-dialog {
  position: fixed;
  z-index: 70;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 39, 40, .76);
  backdrop-filter: blur(5px);
}
.confirm-dialog[hidden] { display: none; }

.confirm-card {
  position: relative;
  width: min(390px, calc(100vw - 40px));
  padding: 34px 26px 24px;
  border: 6px solid #59372b;
  border-radius: 18px;
  color: #573328;
  text-align: center;
  background: #fff0c4;
  box-shadow: 10px 12px 0 rgba(55, 31, 24, .48), inset 0 0 0 3px #d39a58;
}

.confirm-icon {
  position: absolute;
  top: -28px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 5px solid #59372b;
  border-radius: 50%;
  color: #fff1cd;
  background: #c95236;
  box-shadow: 0 4px 0 #3f2822;
  font-size: 28px;
  font-weight: 950;
  transform: translateX(-50%);
}

.confirm-card h2 { margin: 8px 0 9px; font-size: 22px; }
.confirm-card p { margin: 0 0 22px; color: #816152; font-size: 14px; font-weight: 750; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.confirm-actions button {
  min-height: 42px;
  border: 3px solid #4d3027;
  border-radius: 9px;
  font-weight: 900;
  box-shadow: 0 4px 0 #4d3027;
}
.confirm-cancel { color: #573328; background: #f1c16d; }
.confirm-delete { color: #fff1d1; background: #b84d35; }
.confirm-actions button:active { transform: translateY(3px); box-shadow: 0 1px 0 #4d3027; }

.receipt-lightbox {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 39, 40, .82);
  backdrop-filter: blur(6px);
}
.receipt-lightbox[hidden] { display: none; }

.receipt-viewer {
  position: relative;
  display: grid;
  place-items: center;
  width: min(780px, 92vw);
  max-height: 88vh;
  min-height: 260px;
  padding: 18px;
  border: 7px solid #603b2d;
  border-radius: 18px;
  background: #fff0c4;
  box-shadow: 12px 14px 0 rgba(31, 20, 18, .5), inset 0 0 0 3px #d59b58;
}

.receipt-viewer > img {
  display: block;
  max-width: 100%;
  max-height: calc(88vh - 50px);
  border-radius: 9px;
  object-fit: contain;
}

.close-lightbox {
  position: absolute;
  z-index: 2;
  top: -18px;
  right: -18px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 4px solid #4d3027;
  border-radius: 50%;
  color: #fff0c5;
  background: #c44f35;
  box-shadow: 0 4px 0 #4d3027;
  font-size: 26px;
  font-weight: 900;
}

.receipt-placeholder {
  display: grid;
  place-items: center;
  gap: 8px;
  color: #694235;
  text-align: center;
}
.receipt-placeholder[hidden] { display: none; }
.receipt-placeholder span { font-size: 68px; }
.receipt-placeholder strong { font-size: 24px; }
.receipt-placeholder small { color: #8c7060; }

@media (max-width: 760px) {
  .hero-stage {
    --sign-width: 60cqw;
    --sign-height: 20.2cqw;
    --roof-height: clamp(60px, 10.8cqw, 79px);
    --sign-overlap: clamp(14px, 3.2cqw, 23px);
  }
}

@media (max-width: 430px) {
  .hero-stage {
    --sign-width: 76cqw;
    --sign-height: 25.59cqw;
    --roof-height: clamp(45px, 12.5cqw, 54px);
    --sign-overlap: clamp(10px, 3.2cqw, 14px);
  }
}

@media (max-width: 1180px) {
  .budget-board { width: 86%; }
  .workbench { grid-template-columns: minmax(0, 1.45fr) minmax(285px, .85fr); gap: 16px; }
  .table-head,
  .record { grid-template-columns: 55px minmax(90px, 1fr) 52px 72px 24px; gap: 4px; padding-right: 12px; padding-left: 12px; }
}

@media (max-width: 760px) {
  :root { --truck-width: 100vw; }
  .truck-body { margin-bottom: 0; padding: 22px 12px 36px; border-right: 0; border-left: 0; border-bottom-width: 8px; border-radius: 0; }
  .rivets { display: none; }
  .budget-board { grid-template-columns: 1fr; gap: 12px; width: 100%; min-height: 0; margin-bottom: 16px; padding: 16px; border-width: 5px; }
  .budget-main > strong { font-size: 40px; }
  .budget-stats { grid-template-columns: 1fr 1fr; padding: 12px 0 0; border-top: 1px solid #6e8984; border-left: 0; text-align: center; }
  .budget-stats strong { font-size: 20px; }
  .budget-editor { right: 8px; bottom: -58px; }
  .workbench { grid-template-columns: 1fr; grid-template-areas: "form" "list"; gap: 16px; padding: 6px; border-width: 5px; }
  .expense-form { min-height: 0; }
  .expense-list { min-height: 0; }
  .panel-heading { min-height: 80px; padding: 15px 16px; }
  .panel-heading h2 { font-size: 22px; }
  .form-fields { padding: 14px; }
  .table-head { display: none; }
  .record { grid-template-columns: 56px minmax(0, 1fr) 68px 80px 28px; gap: 5px; padding: 8px 10px; font-size: 12px; }
  .record .record-amount { font-size: 13px; }
}

@media (min-width: 761px) and (max-height: 900px) {
  .truck-body { padding-top: 14px; }
  .budget-board { min-height: 116px; margin-bottom: 12px; padding-top: 8px; padding-bottom: 8px; }
  .budget-main > strong { font-size: 40px; }
  .panel-heading { min-height: 70px; padding-top: 10px; padding-bottom: 9px; }
  .form-fields { gap: 7px 11px; padding-top: 10px; padding-bottom: 13px; }
  .form-fields input:not([type="file"]) { height: 36px; }
  .upload-field { min-height: 52px; padding: 5px; }
  .save-button,
  .secondary-button { min-height: 38px; }
}

@media (min-width: 761px) and (max-height: 820px) {
  .hero-stage {
    --sign-width: clamp(390px, 45cqw, 540px);
    --sign-height: clamp(131px, 15.15cqw, 182px);
    --roof-height: clamp(69px, 7.6cqw, 85px);
    --sign-overlap: clamp(44px, 5.2cqw, 62px);
  }
  .truck-body { padding-top: 6px; }
  .budget-board { margin-bottom: 8px; }
  .panel-heading { min-height: 58px; padding: 6px 12px; }
  .form-fields { gap: 4px 10px; padding: 7px 12px 9px; }
  .form-fields input:not([type="file"]) { height: 32px; }
  .upload-field { min-height: 44px; padding: 3px; }
  .save-button,
  .secondary-button { min-height: 34px; }
}

@media (max-width: 430px) {
  .truck-body { padding-top: 18px; }
  .budget-main > strong { font-size: 36px; }
  .progress-meta { font-size: 11px; }
  .form-fields { grid-template-columns: 1fr; }
  .full-field { grid-column: auto; }
  .record { grid-template-columns: 48px minmax(0, 1fr) 68px 26px; }
  .record-submitter { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
