:root {
  color-scheme: light;
  --background: #f3f0e9;
  --surface: #fffdf9;
  --surface-strong: #ffffff;
  --ink: #172620;
  --muted: #66736e;
  --line: #d9ded9;
  --primary: #155f4d;
  --primary-dark: #0e493b;
  --primary-soft: #dcece6;
  --accent: #e99b37;
  --danger: #a22d2d;
  --danger-soft: #fbeaea;
  --shadow: 0 16px 40px rgb(34 54 47 / 9%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgb(21 95 77 / 10%), transparent 28rem),
    var(--background);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  color: white;
  background: var(--primary-dark);
  border-radius: 0.5rem;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 76rem;
  margin: auto;
  padding: 1.25rem clamp(1rem, 5vw, 3rem);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.language-button {
  min-width: 2.8rem;
  min-height: 2.8rem;
  color: var(--primary-dark);
  background: var(--surface-strong);
  border: 1px solid var(--primary);
  border-radius: 0.8rem;
  font-weight: 900;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  color: white;
  background: var(--primary);
  border-radius: 0.9rem 0.9rem 0.9rem 0.25rem;
  box-shadow: 0 8px 18px rgb(21 95 77 / 22%);
  place-items: center;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.local-badge,
.demo-label {
  padding: 0.45rem 0.65rem;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.app-shell {
  width: min(100% - 2rem, 70rem);
  margin: 1rem auto 4rem;
}

.section-heading,
.list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading {
  margin-bottom: 1.5rem;
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  align-items: center;
}

.compact-button {
  min-height: 2.6rem;
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: -0.055em;
  line-height: 1;
}

h2 {
  letter-spacing: -0.025em;
}

.eyebrow {
  margin-bottom: 0.4rem;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.status-message {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  background: var(--primary-soft);
  border: 1px solid #b8d6cc;
  border-radius: 0.85rem;
}

.status-message.error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #efbaba;
}

.trip-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.trip-button {
  min-height: 5.5rem;
  padding: 1rem;
  color: inherit;
  text-align: left;
  background: rgb(255 253 249 / 70%);
  border: 1px solid var(--line);
  border-radius: 1rem;
  transition:
    border-color 150ms ease,
    transform 150ms ease;
}

.trip-button:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.trip-button[aria-pressed="true"] {
  background: var(--surface-strong);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow);
}

.trip-button strong,
.trip-button span {
  display: block;
}

.trip-button span {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.summary-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.25rem;
  padding: clamp(1.25rem, 4vw, 2rem);
  background: var(--surface);
  border: 1px solid rgb(21 95 77 / 14%);
  border-radius: 1.4rem;
  box-shadow: var(--shadow);
}

.summary-card h2 {
  margin-bottom: 0.25rem;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
}

.summary-metrics {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.summary-metrics div {
  display: flex;
  min-width: 5.5rem;
  flex-direction: column;
}

.summary-metrics strong {
  font-size: 1.4rem;
}

.summary-metrics span {
  color: var(--muted);
  font-size: 0.8rem;
}

.primary-button {
  min-height: 3.25rem;
  padding: 0.8rem 1.2rem;
  color: white;
  background: var(--primary);
  border: 0;
  border-radius: 0.9rem;
  font-weight: 800;
  box-shadow: 0 8px 18px rgb(21 95 77 / 18%);
}

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

.primary-button:focus-visible,
.back-button:focus-visible,
.trip-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(233 155 55 / 60%);
  outline-offset: 2px;
}

.summary-card .primary-button {
  grid-column: 1 / -1;
  width: 100%;
}

.receipts-section {
  margin-top: 2rem;
}

.list-heading {
  margin-bottom: 0.75rem;
}

.list-heading h2 {
  margin-bottom: 0;
}

.count-pill {
  display: grid;
  min-width: 1.8rem;
  height: 1.8rem;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 999px;
  place-items: center;
  font-weight: 800;
}

.receipt-list {
  display: grid;
  gap: 0.7rem;
}

.receipt-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.9rem;
  align-items: center;
  padding: 1rem;
  background: rgb(255 253 249 / 82%);
  border: 1px solid var(--line);
  border-radius: 1rem;
}

.receipt-icon {
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  color: #70420a;
  background: #f9e3c7;
  border-radius: 0.8rem;
  place-items: center;
  font-weight: 900;
}

.receipt-main strong,
.receipt-main span {
  display: block;
}

.receipt-main span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.attachment-button {
  margin-top: 0.55rem;
  padding: 0;
  color: var(--primary);
  background: transparent;
  border: 0;
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 0.2rem;
}

.receipt-amount {
  text-align: right;
  font-weight: 900;
}

.empty-state {
  padding: 2rem 1rem;
  color: var(--muted);
  text-align: center;
  background: rgb(255 253 249 / 55%);
  border: 1px dashed #bdc7c2;
  border-radius: 1rem;
}

.form-view {
  width: min(100%, 42rem);
  margin: auto;
}

.back-button {
  margin-bottom: 1.5rem;
  padding: 0.5rem 0;
  color: var(--primary);
  background: transparent;
  border: 0;
  font-weight: 800;
}

.form-heading {
  margin-bottom: 1.5rem;
}

.form-heading h1 {
  margin-bottom: 0.65rem;
}

.form-heading > p:last-child {
  color: var(--muted);
}

form {
  display: grid;
  gap: 1.15rem;
  padding: clamp(1rem, 4vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  box-shadow: var(--shadow);
}

.attachment-picker {
  min-width: 0;
  margin: 0;
  padding: 1rem;
  background: #f5faf8;
  border: 1px solid #c7dbd3;
  border-radius: 1rem;
}

.attachment-picker legend {
  padding: 0 0.3rem;
  font-weight: 900;
}

.attachment-picker legend span,
.attachment-help {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.attachment-picker legend > span:first-child {
  color: var(--ink);
  font-size: inherit;
  font-weight: 900;
}

.attachment-help {
  margin-bottom: 0.8rem;
}

.attachment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.secondary-button {
  display: inline-flex;
  min-height: 2.8rem;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  color: var(--primary-dark);
  background: white;
  border: 1px solid var(--primary);
  border-radius: 0.8rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.secondary-button:hover {
  background: var(--primary-soft);
}

.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;
}

.attachment-preview {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 0.85rem;
  align-items: center;
  margin-top: 0.8rem;
  padding: 0.75rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.attachment-preview img,
.file-preview {
  width: 5rem;
  height: 5rem;
  border-radius: 0.6rem;
}

.attachment-preview img {
  object-fit: cover;
}

.file-preview {
  display: grid;
  color: #7d2626;
  background: #fae5e5;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 900;
}

.attachment-preview-details strong,
.attachment-preview-details > span {
  display: block;
  overflow-wrap: anywhere;
}

.attachment-preview-details > span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.text-button {
  margin-top: 0.55rem;
  padding: 0;
  color: var(--danger);
  background: transparent;
  border: 0;
  font-size: 0.8rem;
  font-weight: 800;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem;
  color: var(--ink);
  background: white;
  border: 1px solid #b9c3be;
  border-radius: 0.7rem;
}

textarea {
  resize: vertical;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.amount-input {
  position: relative;
}

.amount-input input {
  padding-right: 2.3rem;
}

.amount-input > span {
  position: absolute;
  top: 50%;
  right: 0.8rem;
  color: var(--muted);
  transform: translateY(-50%);
}

.field-error,
.field-hint {
  display: block;
  min-height: 1rem;
  margin-top: 0.3rem;
  font-size: 0.75rem;
}

.field-error {
  color: var(--danger);
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
}

.form-submit {
  width: 100%;
  margin-top: 0.4rem;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.attachment-dialog {
  width: min(92vw, 54rem);
  max-height: 90vh;
  padding: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: 1.2rem;
  box-shadow: 0 24px 70px rgb(10 28 22 / 32%);
}

.attachment-dialog::backdrop {
  background: rgb(8 22 18 / 68%);
  backdrop-filter: blur(3px);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dialog-heading h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 2.7rem;
  height: 2.7rem;
  color: var(--ink);
  background: var(--background);
  border: 0;
  border-radius: 999px;
  place-items: center;
  font-size: 1.5rem;
}

.attachment-viewer {
  display: grid;
  min-height: 14rem;
  max-height: 62vh;
  overflow: auto;
  background: #e7ebe8;
  border-radius: 0.8rem;
  place-items: center;
}

.attachment-viewer img {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  object-fit: contain;
}

.attachment-viewer iframe {
  width: 100%;
  min-height: 60vh;
  border: 0;
}

.download-button {
  width: 100%;
  margin-top: 0.8rem;
}

[hidden] {
  display: none !important;
}

@media (max-width: 620px) {
  .local-badge {
    max-width: 8rem;
    text-align: center;
  }

  .header-actions {
    gap: 0.4rem;
  }

  .app-shell {
    width: min(100% - 1.25rem, 70rem);
    margin-top: 0.5rem;
  }

  .section-heading {
    align-items: flex-end;
  }

  .heading-actions {
    max-width: 11rem;
  }

  .summary-card {
    grid-template-columns: 1fr;
  }

  .summary-metrics {
    justify-content: space-between;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .attachment-actions .secondary-button {
    width: 100%;
  }

  .attachment-dialog {
    width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
    margin: 0.5rem;
  }

  .receipt-card {
    grid-template-columns: auto 1fr;
  }

  .receipt-amount {
    grid-column: 2;
    text-align: left;
  }
}
