:root {
  --ink: #17120b;
  --muted: #62574a;
  --line: #d9c7a2;
  --gold: #c98316;
  --gold-dark: #815009;
  --cream: #fffaf0;
  --paper: #fffdf8;
  --black: #090806;
  --danger: #a32f27;
  --ok: #18714f;
  --shadow: 0 22px 70px rgba(42, 28, 8, 0.16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color: var(--ink);
  background: var(--cream);
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html, body { overscroll-behavior-y: none; }
body {
  min-height: 100vh;
  margin: 0;
  padding-bottom: var(--safe-bottom);
  background:
    radial-gradient(circle at top right, rgba(201, 131, 22, .12), transparent 320px),
    linear-gradient(180deg, #fffdf8, var(--cream));
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--gold-dark); }
.hidden { display: none !important; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex="-1"]:focus-visible {
  outline: 3px solid rgba(201, 131, 22, .48);
  outline-offset: 3px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding:
    calc(12px + var(--safe-top))
    max(clamp(14px, 4vw, 38px), var(--safe-right))
    12px
    max(clamp(14px, 4vw, 38px), var(--safe-left));
  color: var(--ink);
  background: linear-gradient(145deg, #fffdf8, #f5ead6);
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 8px 28px rgba(80, 52, 12, .14);
}
.app-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo-crop {
  display: block;
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 49px;
  overflow: hidden;
}
.brand-logo-crop img {
  position: absolute;
  top: -1px;
  left: -3px;
  width: 70px;
  height: 70px;
  object-fit: contain;
}
.brand-copy { display: grid; min-width: 0; }
.brand-copy strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1.1;
}
.brand-copy small { color: var(--gold-dark); font-size: .78rem; white-space: nowrap; }
.menu-shell { position: relative; }
.menu-toggle {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  color: var(--ink);
  background: rgba(255, 253, 248, .72);
  border: 1px solid var(--gold);
  border-radius: 8px;
  font-weight: 800;
}
.menu-toggle span:first-child { color: var(--gold); font-size: 20px; }
.app-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(330px, calc(100vw - 28px));
  overflow: hidden;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.menu-status {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-bottom: 1px solid #eee4d0;
}
.menu-status span { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; }
.menu-status strong { font-size: 15px; }
.menu-status strong.offline { color: #8a5607; }
.menu-status strong.ok { color: var(--ok); }
.menu-action {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-bottom: 1px solid #eee4d0;
  font-weight: 800;
}
.menu-action:hover { background: var(--cream); }
.menu-action.danger { color: var(--danger); }

.app-shell {
  width: min(1120px, calc(100% - 28px - var(--safe-left) - var(--safe-right)));
  margin: 26px auto 80px;
}
.panel {
  padding: clamp(20px, 4vw, 36px);
  margin-bottom: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 45px rgba(42, 28, 8, .09);
}
.narrow { max-width: 620px; margin-inline: auto; }
h1, h2, h3 {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.08;
}
h1 { font-size: clamp(28px, 5vw, 44px); }
h2 { font-size: clamp(24px, 4vw, 34px); }
p { line-height: 1.5; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--gold-dark);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.stack { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 7px; color: #3d3329; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 54px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fffdfa;
  border: 1px solid #bca77e;
  border-radius: 8px;
}
input:focus, select:focus {
  outline: 3px solid rgba(201, 131, 22, .22);
  border-color: var(--gold);
}
input[readonly] { background: #f2ede3; }
.optional { color: var(--muted); font-size: 14px; font-weight: 500; }
.field-help { margin: 0; color: var(--muted); font-size: 15px; }
.checkbox {
  grid-template-columns: 26px 1fr;
  align-items: start;
  line-height: 1.4;
  font-weight: 650;
}
.checkbox input { width: 23px; min-height: 23px; margin: 0; }
.birth-date-field {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.birth-date-field legend { padding: 0 6px; font-weight: 800; }
.birth-date-selects { display: grid; grid-template-columns: .75fr 1.2fr 1fr; gap: 12px; }
.birth-date-selects label { font-size: 15px; }
.scanner-note {
  padding: 16px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.scanner-note p { margin: 10px 0 0; color: var(--muted); }
.privacy-header .app-brand { color: inherit; text-decoration: none; }
.privacy-shell { max-width: 820px; }
.privacy-content h2 { margin-top: 30px; color: var(--gold-dark); font-size: clamp(21px, 3.5vw, 28px); }
.privacy-content li { margin: 8px 0; line-height: 1.5; }
.privacy-back { margin-top: 34px; }

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  color: var(--black);
  background: #fff;
  border: 1px solid var(--gold);
  border-radius: 8px;
  font-weight: 800;
}
.button.primary {
  color: #fff;
  background: var(--black);
  box-shadow: inset 0 -3px 0 rgba(201, 131, 22, .45);
}
.button.primary:hover { background: #2b2114; }
.button.secondary { color: var(--gold-dark); background: #fff; border-color: var(--line); }
.button.sms { color: var(--black); background: linear-gradient(135deg, #fff7dc, #df9621); }
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.compact { min-height: 38px; padding: 7px 14px; }
.button.large { min-height: 60px; font-size: 17px; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.text-button {
  min-height: 44px;
  padding: 9px 7px;
  color: var(--gold-dark);
  background: transparent;
  border: 0;
  font-weight: 800;
}
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.status-pill {
  display: inline-flex;
  padding: 7px 11px;
  color: var(--gold-dark);
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}
.status-pill.ok { color: var(--ok); background: #edf8f1; border-color: #8fc3aa; }
.status-pill.offline { color: #7a4f0b; background: #fff2d9; border-color: #dab363; }

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 0 0 18px;
}
.stepper button {
  display: grid;
  min-height: 58px;
  place-items: center;
  gap: 2px;
  padding: 8px 4px;
  color: var(--muted);
  background: #f1e8d7;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 750;
}
.stepper button b { font-family: Georgia, "Times New Roman", serif; }
.stepper button.active { color: #fff; background: var(--black); border-color: var(--gold); }
.stepper button.completed { color: var(--gold-dark); background: #fff7e8; }
.stepper button:disabled { color: #766d60; cursor: default; opacity: .7; }
.step-error {
  padding: 15px 17px;
  margin: 0 0 18px;
  color: #7d1f19;
  background: #fff2f0;
  border: 2px solid #b9473e;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.45;
}
.invalid-section {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(163, 47, 39, .12);
}
[aria-invalid="true"] { border-color: var(--danger); }
.step-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 26px;
}
.step-actions.split { justify-content: space-between; }
.purchase-item { position: relative; padding: 18px; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 8px; }
.purchase-item legend { padding: 0 8px; color: var(--gold-dark); font-weight: 900; }
.remove-item { position: absolute; top: -26px; right: 18px; }
.item-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  margin-top: 18px;
  border-top: 1px dashed #bca77e;
}
.item-total strong { font-size: 22px; }
.grand-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  color: #fff;
  background: var(--black);
  border: 2px solid var(--gold);
  border-radius: 8px;
  font-size: 20px;
}
.grand-total strong { color: #f5b64d; font-size: 30px; }
.customer-summary {
  display: grid;
  gap: 8px;
  padding: 18px;
  margin: 18px 0;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 17px;
}
.summary-products {
  display: grid;
  gap: 9px;
  padding-top: 14px;
  margin-top: 6px;
  border-top: 1px solid var(--line);
}
.summary-product {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  background: #fffdf8;
  border: 1px solid #e4d7bd;
  border-radius: 7px;
  font-size: 14px;
}
.summary-product > strong { color: var(--gold-dark); text-align: right; font-size: 17px; }
.signature-wrap { position: relative; margin-top: 24px; }
.signature-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.signature-heading span { color: var(--muted); font-size: 15px; }
#signature {
  width: 100%;
  height: 220px;
  background: #fff;
  border: 2px solid #8f7b58;
  border-radius: 8px;
  touch-action: none;
}
.signature-wrap.locked #signature {
  opacity: .5;
  background:
    repeating-linear-gradient(135deg, #f5efe4, #f5efe4 12px, #ede2d0 12px, #ede2d0 24px);
}
.signature-wrap:not(.locked) .signature-heading span { color: var(--ok); }
.action-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .55fr); gap: 28px; }
.delivery-actions { display: grid; align-content: center; gap: 12px; }
.button-row { display: flex; gap: 12px; flex-wrap: wrap; }
.message, .danger-text { color: var(--danger); }
.ok-text { color: var(--ok); }
.test-banner {
  display: grid;
  gap: 6px;
  color: var(--danger);
  border: 3px solid var(--danger);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: min(560px, calc(100% - 28px));
  padding: 13px 18px;
  color: #fff;
  background: #17251f;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  transform: translateX(-50%);
}
.history-row, .payment-row, .batch-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.confirm-dialog {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.confirm-dialog::backdrop { background: rgba(9, 8, 6, .68); }
.confirm-dialog form { padding: 26px; }

.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.readiness-list { display: grid; gap: 7px; }
.readiness-item { display: flex; gap: 10px; align-items: center; }
.readiness-item::before { content: "×"; color: var(--danger); font-weight: 900; }
.readiness-item.ok::before { content: "✓"; color: var(--ok); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }

@media (max-width: 760px) {
  .app-header {
    min-height: calc(68px + var(--safe-top));
    padding:
      calc(9px + var(--safe-top))
      max(12px, var(--safe-right))
      9px
      max(12px, var(--safe-left));
  }
  .brand-logo-crop { width: 54px; height: 42px; }
  .brand-logo-crop img { width: 59px; height: 59px; }
  .brand-copy strong { font-size: 1.12rem; }
  .brand-copy small { display: none; }
  .menu-toggle span:last-child { display: none; }
  .menu-toggle { width: 46px; padding: 8px; justify-content: center; }
  .app-shell { width: min(100% - 18px, 1120px); margin-top: 14px; }
  .panel { padding: 18px 15px; }
  .form-grid, .admin-grid, .action-panel { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .section-title { flex-direction: column; }
  .stepper {
    position: sticky;
    top: calc(68px + var(--safe-top));
    z-index: 12;
    gap: 3px;
    padding: 5px 0;
    background: var(--cream);
  }
  .stepper button { min-height: 52px; font-size: 13px; }
  .birth-date-selects { grid-template-columns: .72fr 1.18fr .9fr; gap: 7px; }
  .step-actions, .step-actions.split { flex-direction: column-reverse; }
  .step-actions .button { width: 100%; }
  .signature-heading { display: grid; }
  .summary-product > strong { text-align: left; }
  #signature { height: 190px; }
  .remove-item { position: static; display: flex; margin: -8px 0 8px auto; }
  .history-row, .payment-row, .batch-row { grid-template-columns: 1fr; }
}
