:root {
  --green-950: #073b27;
  --green-800: #0f5132;
  --green-700: #16663f;
  --green-100: #dcefe5;
  --green-50: #eff8f3;
  --gold-600: #b97714;
  --gold-500: #d69022;
  --gold-100: #f8e8c9;
  --ink: #17221d;
  --muted: #66736d;
  --border: #dce3df;
  --surface: #ffffff;
  --canvas: #f4f3ed;
  --danger: #ae302f;
  --danger-soft: #fff0ef;
  --shadow: 0 10px 32px rgba(20, 45, 33, .08);
  --radius: 18px;
  --nav-height: 76px;
}

* { box-sizing: border-box; }
html { background: var(--canvas); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--canvas); padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; }
button, label[for], select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.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; }
[hidden] { display: none !important; }

.topbar { height: 72px; padding: env(safe-area-inset-top) 18px 0; background: var(--green-950); color: #fff; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--gold-500); color: var(--green-950); font: 800 14px/1 "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.03em; }
.brand div { display: grid; gap: 1px; }
.brand strong { font: 700 15px/1.1 "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.brand span:not(.brand-mark) { font-size: 11px; opacity: .72; }
.status-pill { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; font-size: 11px; font-weight: 700; }
.status-pill > span { width: 7px; height: 7px; background: #f1b84c; border-radius: 50%; }
.status-pill.online > span { background: #66d998; }
.status-pill.offline > span { background: #f1b84c; }

main { width: min(1180px, 100%); margin: 0 auto; padding: 24px 16px 32px; }
.view { animation: view-in .2s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h1 { margin: 3px 0 4px; font: 800 clamp(26px, 6vw, 38px)/1.05 "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.04em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.eyebrow, .modal-kicker { color: var(--green-700); font: 800 11px/1 "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: .13em; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 14px; }
.card-heading h2, .danger-zone h2, .data-card h2 { margin: 0 0 4px; font: 700 17px/1.2 "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.02em; }
.card-heading p, .danger-zone p, .data-card p { margin: 0; color: var(--muted); font-size: 13px; }
.local-badge, .count-badge { flex: 0 0 auto; background: var(--green-50); color: var(--green-800); border: 1px solid var(--green-100); padding: 6px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.count-badge { display: grid; place-items: center; min-width: 30px; font-size: 12px; }

.order-layout { display: grid; gap: 16px; }
.scanner-column { display: grid; gap: 16px; align-content: start; }
.camera-stage { margin: 0 12px; position: relative; background: #10251c; border-radius: 15px; overflow: hidden; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.camera-stage video { width: 100%; height: 100%; object-fit: cover; display: none; }
.camera-stage.active video { display: block; }
.camera-placeholder { color: #fff; display: grid; place-items: center; text-align: center; gap: 8px; padding: 20px; }
.camera-placeholder svg { width: 38px; height: 38px; color: var(--gold-500); }
.camera-placeholder strong { font: 700 15px "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.camera-placeholder span { color: rgba(255,255,255,.65); font-size: 12px; }
.camera-stage.active .camera-placeholder { display: none; }
.scan-guide { display: none; position: absolute; left: 8%; right: 8%; top: 35%; bottom: 35%; background: rgba(7,59,39,.08); }
.camera-stage.active .scan-guide { display: block; }
.scan-guide span { position: absolute; width: 25px; height: 25px; border-color: var(--gold-500); border-style: solid; }
.scan-guide span:nth-child(1) { left: 0; top: 0; border-width: 3px 0 0 3px; border-radius: 6px 0 0; }
.scan-guide span:nth-child(2) { right: 0; top: 0; border-width: 3px 3px 0 0; border-radius: 0 6px 0 0; }
.scan-guide span:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 6px; }
.scan-guide span:nth-child(4) { right: 0; bottom: 0; border-width: 0 3px 3px 0; border-radius: 0 0 6px; }
.scan-guide b { position: absolute; left: 50%; bottom: -32px; transform: translateX(-50%); color: #fff; background: rgba(0,0,0,.66); border-radius: 6px; padding: 4px 9px; font-size: 11px; white-space: nowrap; }
.ocr-progress { position: absolute; inset: 0; z-index: 4; display: grid; align-content: center; gap: 12px; background: rgba(7, 26, 18, .88); color: #fff; padding: 24px; text-align: center; }
.ocr-progress > div { height: 6px; border-radius: 999px; background: rgba(255,255,255,.2); overflow: hidden; }
.ocr-progress > div span { display: block; height: 100%; width: 10%; background: var(--gold-500); transition: width .2s; }
.ocr-progress strong { font-size: 13px; }
.scanner-actions { display: flex; gap: 9px; padding: 12px 12px 4px; }
.form-help { color: var(--muted); font-size: 11px; margin: 8px 16px 16px; }
.grow { flex: 1; }
.icon-button { flex: 0 0 48px; padding-inline: 0 !important; }

.button { min-height: 46px; border: 0; border-radius: 12px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink); background: #edf0ee; font-weight: 700; font-size: 13px; transition: transform .12s, background .12s, opacity .12s; }
.button:active { transform: scale(.98); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button.primary { background: var(--green-800); color: #fff; }
.button.accent { background: var(--gold-500); color: var(--green-950); }
.button.secondary { background: #fff; border: 1px solid var(--border); }
.button.ghost { background: transparent; }
.button.danger { color: var(--danger); background: var(--danger-soft); border: 1px solid #f3ccca; }

.manual-card form { padding: 0 16px 17px; }
label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; }
label small { color: var(--muted); font-weight: 500; }
input, select, textarea { width: 100%; border: 1px solid #cfd9d4; border-radius: 11px; background: #fff; color: var(--ink); min-height: 46px; padding: 10px 12px; outline: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(22,102,63,.12); }
.input-action { display: flex; gap: 8px; }
.input-action input { flex: 1; min-width: 0; font-size: 17px; text-transform: uppercase; letter-spacing: .04em; }
.suggestions { margin-top: 7px; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.suggestion { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: #fff; padding: 10px 12px; display: flex; justify-content: space-between; text-align: left; }
.suggestion:last-child { border-bottom: 0; }
.suggestion b { color: var(--green-800); }
.suggestion span { font-weight: 700; }

.cart-card { min-height: 340px; display: flex; flex-direction: column; overflow: hidden; }
.cart-heading { border-bottom: 1px solid var(--border); }
.empty-state { flex: 1; display: grid; place-items: center; align-content: center; text-align: center; padding: 38px 22px; }
.empty-state h3 { margin: 14px 0 5px; font: 700 16px "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.empty-state p { margin: 0; color: var(--muted); max-width: 310px; font-size: 13px; }
.empty-illustration { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 19px; background: var(--green-50); color: var(--green-700); transform: rotate(-3deg); }
.empty-illustration svg { width: 30px; height: 30px; }
.cart-list { display: grid; }
.cart-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cart-item-main { display: flex; gap: 11px; min-width: 0; }
.team-token { flex: 0 0 45px; height: 45px; border-radius: 12px; display: grid; place-items: center; background: var(--green-50); color: var(--green-800); font: 800 11px "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.cart-item h3 { margin: 2px 0 3px; font-size: 14px; }
.cart-item p { margin: 0; color: var(--muted); font-size: 12px; }
.cart-item aside { display: grid; justify-items: end; gap: 7px; }
.cart-item aside > strong { font-size: 14px; }
.quantity-control { display: flex; align-items: center; gap: 2px; background: #f2f4f3; border-radius: 10px; padding: 2px; }
.quantity-control button { width: 34px; height: 34px; border: 0; background: transparent; color: var(--green-800); display: grid; place-items: center; }
.quantity-control button svg { width: 16px; }
.quantity-control span { min-width: 23px; text-align: center; font-weight: 800; font-size: 13px; }
.remove-item { color: var(--danger); border: 0; background: transparent; padding: 3px; font-size: 11px; font-weight: 700; }
.cart-footer { margin-top: auto; border-top: 1px solid var(--border); background: #fbfcfb; padding: 15px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; bottom: 0; }
.cart-footer > div { display: grid; }
.cart-footer span { color: var(--muted); font-size: 11px; }
.cart-footer strong { font: 800 22px "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--green-800); }
.cart-footer small { color: var(--muted); font-size: 10px; }

.toolbar { display: flex; gap: 9px; padding: 15px; border-bottom: 1px solid var(--border); }
.search-field { flex: 1; position: relative; }
.search-field svg { position: absolute; left: 12px; top: 12px; width: 19px; color: var(--muted); }
.search-field input { padding-left: 40px; }
.toolbar select { width: auto; max-width: 160px; }
.orders-list { display: grid; }
.order-row { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: #fff; padding: 15px 17px; display: grid; grid-template-columns: 1fr auto; gap: 6px 15px; text-align: left; }
.order-row:last-child { border-bottom: 0; }
.order-row h3 { margin: 0; font-size: 14px; }
.order-row p { margin: 0; color: var(--muted); font-size: 12px; }
.order-row strong { grid-column: 2; grid-row: 1; font: 800 16px "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--green-800); }
.order-row .status { justify-self: end; font-size: 10px; font-weight: 800; text-transform: uppercase; padding: 4px 7px; border-radius: 99px; background: var(--green-50); color: var(--green-800); }
.order-row .status.cancelled { color: var(--danger); background: var(--danger-soft); }

.report-filter { padding: 13px; margin-bottom: 14px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.preset-buttons { display: flex; gap: 6px; overflow-x: auto; }
.chip { min-height: 40px; border: 1px solid var(--border); border-radius: 999px; background: #fff; padding: 0 15px; white-space: nowrap; font-weight: 700; font-size: 12px; }
.chip.active { background: var(--green-800); color: #fff; border-color: var(--green-800); }
.date-fields { display: flex; gap: 8px; }
.date-fields label { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.date-fields input { min-height: 40px; padding: 6px 8px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.metric { background: #fff; border: 1px solid var(--border); border-radius: 15px; padding: 15px; display: grid; gap: 3px; }
.metric.highlight { background: var(--green-950); color: #fff; border-color: var(--green-950); }
.metric span { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric.highlight span, .metric.highlight small { color: rgba(255,255,255,.7); }
.metric strong { font: 800 clamp(21px, 6vw, 30px)/1.1 "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.04em; }
.metric small { color: var(--muted); font-size: 10px; }
.report-grid { display: grid; gap: 14px; }
.rank-list, .payment-list { display: grid; padding: 0 16px 16px; }
.rank-row, .payment-row { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.rank-row:last-child, .payment-row:last-child { border-bottom: 0; }
.rank-number { width: 27px; height: 27px; border-radius: 8px; background: var(--gold-100); color: var(--gold-600); display: grid; place-items: center; font-weight: 800; font-size: 11px; }
.rank-row h3, .payment-row h3 { margin: 0; font-size: 13px; }
.rank-row p, .payment-row p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.rank-row > strong, .payment-row > strong { color: var(--green-800); font-size: 13px; }
.list-empty { padding: 20px 0; color: var(--muted); text-align: center; font-size: 13px; }

.data-grid { display: grid; gap: 12px; margin-bottom: 14px; }
.data-card { padding: 18px; display: flex; align-items: center; gap: 14px; }
.data-card small { color: var(--muted); font-size: 11px; }
.data-icon { width: 49px; height: 49px; flex: 0 0 49px; border-radius: 14px; display: grid; place-items: center; }
.data-icon.green { color: var(--green-700); background: var(--green-50); }
.data-icon.gold { color: var(--gold-600); background: var(--gold-100); }
.backup-card { margin-bottom: 14px; padding-bottom: 16px; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px; }
.backup-note { margin: 14px 16px 0; padding: 10px 12px; border-left: 3px solid var(--gold-500); background: #fffbf2; color: var(--muted); font-size: 12px; }
.danger-zone { padding: 18px; border-color: #efd0ce; display: flex; align-items: center; justify-content: space-between; gap: 16px; box-shadow: none; }

.bottom-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--nav-height) + env(safe-area-inset-bottom)); padding: 7px 8px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255,255,255,.96); border-top: 1px solid var(--border); box-shadow: 0 -6px 24px rgba(30,50,40,.08); }
.nav-item { position: relative; border: 0; background: transparent; color: #738079; display: grid; justify-items: center; align-content: center; gap: 3px; border-radius: 11px; min-height: 58px; font-size: 10px; font-weight: 700; }
.nav-item svg { width: 23px; height: 23px; }
.nav-item.active { color: var(--green-800); background: var(--green-50); }
.nav-item b { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 4px; background: var(--gold-500); color: var(--green-950); border: 2px solid #fff; border-radius: 999px; display: grid; place-items: center; font-size: 9px; }

.modal { border: 0; border-radius: 22px; width: min(92vw, 460px); padding: 0; color: var(--ink); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.modal::backdrop { background: rgba(4, 20, 13, .72); backdrop-filter: blur(3px); }
.modal > form { position: relative; padding: 28px 22px 22px; }
.modal-close { position: absolute; right: 12px; top: 12px; width: 42px; height: 42px; border: 0; border-radius: 50%; display: grid; place-items: center; background: #f1f3f2; }
.modal h2 { margin: 10px 0 5px; font: 800 24px/1.15 "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.03em; }
.modal p { color: var(--muted); font-size: 13px; }
.modal label { margin-top: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.detected-code { margin-top: 23px; display: inline-block; background: var(--green-50); color: var(--green-800); border: 1px solid var(--green-100); border-radius: 11px; padding: 9px 12px; font: 800 20px "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: .06em; }
.detected-price { display: block; color: var(--green-800); font: 800 30px "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.checkout-summary { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--green-50); display: flex; justify-content: space-between; align-items: center; }
.checkout-summary strong { color: var(--green-800); font: 800 21px "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.order-detail-header { padding-right: 44px; }
.order-detail-header .status { display: inline-block; margin-top: 8px; font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--green-800); background: var(--green-50); padding: 5px 8px; border-radius: 99px; }
.order-detail-header .status.cancelled { color: var(--danger); background: var(--danger-soft); }
.order-detail-items { margin: 16px 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.order-detail-item { padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--border); font-size: 12px; }
.order-detail-item:last-child { border-bottom: 0; }
.order-detail-total { display: flex; justify-content: space-between; align-items: center; }
.order-detail-total strong { font: 800 25px "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--green-800); }
.small-modal { width: min(90vw, 400px); }

.toast-region { position: fixed; z-index: 100; left: 12px; right: 12px; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 10px); display: grid; gap: 8px; pointer-events: none; }
.toast { margin: auto; width: min(100%, 480px); background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.25); font-size: 13px; animation: toast-in .2s ease-out; }
.toast.success { background: var(--green-800); }
.toast.error { background: var(--danger); }
.toast svg { flex: 0 0 auto; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .topbar { height: 78px; padding-inline: 28px; }
  main { padding: 34px 26px 56px; }
  .bottom-nav { position: sticky; top: 78px; bottom: auto; height: 58px; padding: 0 max(24px, calc((100vw - 1180px)/2)); grid-template-columns: repeat(4, max-content); justify-content: start; gap: 6px; border-top: 0; border-bottom: 1px solid var(--border); box-shadow: none; }
  .nav-item { min-width: 122px; grid-auto-flow: column; gap: 8px; min-height: 46px; padding: 0 14px; font-size: 12px; }
  .nav-item svg { width: 19px; }
  .nav-item b { top: 3px; left: 29px; }
  .order-layout { grid-template-columns: minmax(360px, .9fr) minmax(420px, 1.1fr); align-items: start; }
  .cart-card { min-height: 596px; max-height: calc(100vh - 230px); position: sticky; top: 154px; }
  .cart-list { overflow-y: auto; }
  .camera-stage { aspect-ratio: 16 / 10; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .report-grid, .data-grid { grid-template-columns: repeat(2, 1fr); }
  .toast-region { bottom: 20px; }
}

@media (max-width: 460px) {
  .brand span:not(.brand-mark) { display: none; }
  .section-heading { align-items: flex-start; }
  .section-heading > .button { padding-inline: 10px; }
  .input-action .button { padding-inline: 12px; }
  .input-action .button svg { display: none; }
  .cart-footer { align-items: stretch; }
  .cart-footer .button { padding-inline: 12px; }
  .toolbar { flex-direction: column; }
  .toolbar select { max-width: none; width: 100%; }
  .report-filter { display: grid; }
  .date-fields { display: grid; grid-template-columns: 1fr 1fr; }
  .date-fields label { display: grid; }
  .danger-zone { align-items: flex-start; flex-direction: column; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
