:root {
  --forest: #315c4c;
  --forest-dark: #234538;
  --sage: #dce8dc;
  --sage-soft: #edf3ec;
  --cream: #f7f2e8;
  --paper: #fffdf8;
  --ink: #26342e;
  --muted: #6f7d76;
  --line: #dce3dc;
  --terracotta: #d87c5b;
  --danger: #b84b46;
  --shadow: 0 18px 50px rgba(35, 69, 56, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 3%, rgba(216, 124, 91, 0.13), transparent 25rem),
    linear-gradient(180deg, #f2eee5 0%, #f8f5ee 42%, #eef3eb 100%);
}

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

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 18px calc(30px + env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  color: white;
  background: var(--forest);
  box-shadow: 0 8px 20px rgba(49, 92, 76, 0.2);
  font-size: 21px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 24px; letter-spacing: -0.04em; }
h2 { margin: 0; font-size: 18px; letter-spacing: -0.025em; }

.status-dot {
  padding: 6px 9px;
  border: 1px solid #d5ddd5;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 750;
}

form { display: grid; gap: 14px; }

.machine-panel,
.quantity-panel,
.last-record {
  border: 1px solid rgba(73, 94, 83, 0.13);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.machine-panel { padding: 19px; }
.quantity-panel { padding: 19px 12px 12px; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-inline: 2px;
}

.section-heading > div { display: flex; align-items: center; gap: 9px; }

.step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  color: var(--forest);
  background: var(--sage-soft);
  font-size: 10px;
  font-weight: 850;
}

.required,
.section-hint {
  color: var(--terracotta);
  font-size: 11px;
  font-weight: 750;
}

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

.select-wrap { position: relative; display: block; }

select {
  width: 100%;
  min-height: 54px;
  appearance: none;
  border: 1.5px solid #cbd6ce;
  border-radius: 16px;
  padding: 0 44px 0 16px;
  color: var(--ink);
  background: white;
  font-weight: 700;
  outline: none;
}

select:focus { border-color: var(--forest); box-shadow: 0 0 0 4px rgba(49,92,76,.10); }
.select-arrow { position: absolute; top: 13px; right: 16px; color: var(--forest); font-size: 22px; pointer-events: none; }

.text-input {
  width: 100%;
  min-height: 54px;
  border: 1.5px solid #cbd6ce;
  border-radius: 16px;
  padding: 0 16px;
  color: var(--ink);
  background: white;
  font-size: 16px;
  font-weight: 700;
  outline: none;
}

.text-input::placeholder { color: #9aa59f; font-weight: 600; }
.text-input:focus { border-color: var(--forest); box-shadow: 0 0 0 4px rgba(49,92,76,.10); }

.column-labels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px 86px;
  gap: 8px;
  padding: 0 7px 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.column-labels span:first-child { text-align: left; }
.flavor-list { display: grid; gap: 7px; }

.flavor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px 86px;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 8px 7px;
  border: 1px solid #e3e8e2;
  border-radius: 17px;
  background: white;
}

.flavor-name {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.25;
}

.flavor-dot { flex: 0 0 auto; width: 10px; height: 34px; border-radius: 999px; background: var(--flavor-color); }

.number-control {
  display: grid;
  grid-template-columns: 23px 1fr 23px;
  align-items: center;
  min-height: 42px;
  border: 1px solid #d9e0da;
  border-radius: 13px;
  overflow: hidden;
  background: #f8faf7;
}

.number-control button {
  align-self: stretch;
  border: 0;
  padding: 0;
  color: var(--forest);
  background: transparent;
  font-size: 17px;
  font-weight: 800;
}

.number-control button:active { background: var(--sage); }

.number-control input {
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  text-align: center;
  font-size: 16px;
  font-weight: 820;
  outline: 0;
  -moz-appearance: textfield;
}

.number-control input::-webkit-outer-spin-button,
.number-control input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.number-control:focus-within { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(49,92,76,.09); }

.field-error {
  min-height: 0;
  margin: 8px 3px 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}
.field-error:empty { display: none; }

.summary-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  min-height: 68px;
  padding: 11px 20px;
  border: 1px solid rgba(49,92,76,.14);
  border-radius: 20px;
  background: var(--sage-soft);
}

.summary-strip > div:not(.divider) { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.summary-strip span { color: var(--muted); font-size: 11px; font-weight: 700; }
.summary-strip strong { color: var(--forest-dark); font-size: 22px; }
.summary-strip .divider { width: 1px; height: 34px; background: #cfdacf; }

.primary-button,
.secondary-button {
  min-height: 56px;
  border: 0;
  border-radius: 17px;
  padding: 0 19px;
  font-weight: 820;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  background: var(--forest);
  box-shadow: 0 12px 26px rgba(49,92,76,.24);
}

.primary-button:active { transform: translateY(1px); background: var(--forest-dark); }
.primary-button.compact { justify-content: center; min-height: 52px; box-shadow: none; }
.secondary-button { color: var(--forest); background: var(--sage-soft); }

.last-record { padding: 16px 18px; border-color: #bfcfbe; background: #f5faf3; box-shadow: none; }
.last-record h3 { margin: 0 0 5px; color: var(--forest-dark); font-size: 14px; }
.last-record p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

footer { padding: 21px 6px 0; text-align: center; }
.text-button { border: 0; padding: 10px; color: var(--forest); background: transparent; font-size: 13px; font-weight: 780; }
footer p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(26, 39, 33, .46);
  backdrop-filter: blur(3px);
}

.confirm-sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 11;
  width: min(100%, 500px);
  max-height: 88vh;
  margin: 0 auto;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--paper);
  box-shadow: 0 -18px 60px rgba(27, 43, 36, .22);
  overflow-y: auto;
}

.sheet-handle { width: 44px; height: 5px; margin: 0 auto 18px; border-radius: 99px; background: #d6ddd6; }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; color: var(--forest-dark); background: var(--sage-soft); font-size: 24px; }

.confirm-content { margin-top: 18px; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.confirm-machine { padding: 14px 16px; color: white; background: var(--forest); font-size: 15px; font-weight: 800; }
.confirm-item { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.confirm-item:last-child { border-bottom: 0; }
.confirm-values { display: flex; gap: 12px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.confirm-values strong { color: var(--ink); }
.confirm-total { display: flex; justify-content: space-between; padding: 14px 16px; background: var(--sage-soft); font-size: 13px; font-weight: 800; }
.timestamp-note { margin: 12px 2px 16px; color: var(--muted); font-size: 11px; text-align: center; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 20px;
  z-index: 20;
  width: fit-content;
  margin: 0 auto;
  padding: 12px 18px;
  border-radius: 999px;
  color: white;
  background: var(--forest-dark);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 780;
}

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

@media (max-width: 370px) {
  .app-shell { padding-inline: 12px; }
  .quantity-panel { padding-inline: 8px; }
  .column-labels, .flavor-row { grid-template-columns: minmax(0, 1fr) 80px 80px; gap: 5px; }
  .flavor-name { gap: 6px; font-size: 12px; }
  .number-control { grid-template-columns: 21px 1fr 21px; }
}

@media (min-width: 700px) {
  body { padding: 34px 0; }
  .app-shell { min-height: auto; border: 1px solid rgba(49,92,76,.12); border-radius: 34px; background: rgba(255,255,255,.28); }
}

@media (prefers-reduced-motion: no-preference) {
  .confirm-sheet { animation: sheet-up .22s ease-out; }
  .toast { animation: toast-in .2s ease-out; }
  @keyframes sheet-up { from { transform: translateY(25px); opacity: .5; } }
  @keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
}
