:root {
  --green: #22c55e;
  --green-dark: #16a34a;
  --green-deep: #15803d;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --orange: #f97316;
  --yellow: #eab308;
  --red: #ef4444;
  --navy: #0f172a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; height: 100%; overflow-x: hidden; }
body {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: #0b1220;
  color: var(--ink);
  display: flex;
  justify-content: center;
}
button, input { font: inherit; }
input, select, textarea { font-size: 16px; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.phone {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 480px) {
  body { padding: 16px; box-sizing: border-box; }
  .phone {
    height: calc(100dvh - 32px);
    min-height: calc(100dvh - 32px);
    border-radius: 36px;
    box-shadow: 0 0 0 10px #020617, 0 24px 80px rgba(0, 0, 0, .55);
  }
}
.screen { flex: 1; overflow: auto; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.screen.no-tabs { padding-bottom: 24px; }

.hero {
  flex: 1;
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(8, 20, 12, .35) 0%, rgba(8, 20, 12, .72) 55%, rgba(8, 20, 12, .88) 100%),
    radial-gradient(circle at 30% 20%, #f59e0b 0%, transparent 40%),
    radial-gradient(circle at 80% 40%, #16a34a 0%, #0b3d22 70%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
}
.hero-logo {
  width: 72px; height: 72px; border-radius: 50%; background: #fff; color: var(--green-dark);
  display: grid; place-items: center; margin-bottom: 18px;
}
.hero h1 { font-size: 42px; margin: 0 0 6px; letter-spacing: -0.04em; }
.hero p { margin: 0 0 28px; color: #d1fae5; }
.hero-actions { display: grid; gap: 12px; }
.fine { text-align: center; color: #bbf7d0; font-size: 13px; margin-top: 18px; }

.auth-page .phone { background: #f7f3ea; }
.auth-poster {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top)) 18px 0;
  background-color: #f7f3ea;
  background-image: url("../images/auth-leaves.svg");
  background-repeat: no-repeat;
  background-size: 100% 220px;
  background-position: center top;
  position: relative;
}
.auth-head { text-align: center; padding: 0 4px 8px; flex: none; }
.auth-poster .auth-logo {
  width: 64px; height: 64px; background: #16a34a; color: #fff;
  margin: 0 auto 8px; box-shadow: 0 12px 24px rgba(22, 163, 74, .28);
}
.auth-poster .auth-logo svg { width: 30px; height: 30px; }
.auth-poster .brand-name { color: #15803d; font-size: 23px; margin: 0; letter-spacing: -0.03em; }
.auth-step { margin: 8px 0 0; color: var(--muted); font-weight: 700; }
.auth-card {
  background: #fff;
  border-radius: 28px;
  padding: 18px 18px 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .12);
  position: relative;
  z-index: 2;
  flex: none;
}
.auth-banner {
  flex: 1 1 160px;
  min-height: 150px;
  margin: -22px -18px 0;
  background: url("../images/bg-banner.png") left center / cover no-repeat;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
}
.auth-banner::after {
  content: "";
  position: absolute;
  inset: 35% 0 0;
  background: linear-gradient(180deg, transparent, rgba(12, 24, 16, .72));
  pointer-events: none;
}
.auth-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 18px 16px calc(14px + env(safe-area-inset-bottom));
}
.auth-tag { margin: 0; color: #d9f99d; font-weight: 700; font-size: 13px; }
.auth-tag span { color: #fdba74; }
.auth-script {
  margin: 6px 0 0; color: #fff;
  font-family: Georgia, "Palatino Linotype", serif;
  font-style: italic; font-size: 16px; font-weight: 600;
}
.auth-script::after {
  content: "";
  display: block;
  width: 72px; height: 3px;
  margin: 6px auto 0;
  border-radius: 99px;
  background: #fb923c;
  opacity: .85;
}
.auth-poster .wizard-top { margin-bottom: 6px; }
.auth-poster .wizard-top .back { color: #15803d; font-weight: 800; }
.auth-poster .step-count { color: #16a34a; }
.auth-poster .wizard-stage { min-height: 108px; }
.input-wrap {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: #fff;
}
.input-wrap svg { width: 20px; height: 20px; color: #9ca3af; flex: none; }
.input-wrap input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 12px 0; }
.or {
  text-align: center; color: #9ca3af; font-weight: 800; font-size: 12px;
  letter-spacing: .14em; margin: 10px 0 6px;
}
.btn-cta { background: #16a34a !important; color: #fff !important; gap: 8px; }
.auth-poster .link { color: #16a34a; margin-top: 12px; }
.auth-poster .switch { margin-top: 0; }
.auth-poster .mpin input { background: #fff; width: 54px; height: 54px; border-radius: 16px; }
.auth-poster .field { margin-bottom: 10px; }
.id-tabs { margin-bottom: 2px; }
.id-tabbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  background: #f3f4f6;
  border-radius: 14px;
}
.id-tab {
  border: 0;
  background: transparent;
  color: #6b7280;
  min-height: 40px;
  border-radius: 11px;
  font-weight: 800;
  cursor: pointer;
  padding: 8px 10px;
}
.id-tab.is-on {
  background: #fff;
  color: #15803d;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .08);
}
.id-panel[hidden] { display: none !important; }

.auth {
  padding: 20px 22px calc(24px + env(safe-area-inset-bottom));
  background: #fff;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.auth-logo { width: 56px; height: 56px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; margin: 0 auto 8px; align-self: center; flex: none; }
.auth-logo svg { width: 28px; height: 28px; }
.auth h1 { text-align: center; margin: 0; font-size: 26px; }
.auth h1.brand-name { font-size: 22px; line-height: 1.2; letter-spacing: -0.03em; }
.auth .sub { text-align: center; color: var(--muted); margin: 4px 0 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-weight: 700; }
.field input {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  background: #f9fafb; font-weight: 600;
}
.phone-box {
  display: flex; align-items: stretch;
  border: 1px solid var(--line); border-radius: 14px; background: #f9fafb; overflow: hidden;
}
.phone-cc {
  display: grid; place-items: center;
  padding: 0 12px; font-weight: 800; background: #eef2f7; border-right: 1px solid var(--line);
}
.phone-box input {
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
}
.phone-box input:focus {
  border: 0; box-shadow: none; background: transparent;
}
.mpin { display: flex; gap: 10px; justify-content: center; }
.mpin input {
  width: 48px; height: 52px; text-align: center; font-size: 22px; font-weight: 800;
  border-radius: 14px; border: 1px solid var(--line); background: #f9fafb;
}
.error { color: var(--red); font-weight: 700; font-size: 13px; margin: 0 0 12px; text-align: center; }
.field .error, [data-mpin] .error, .error.under-field {
  display: block;
  text-align: left;
  margin: 6px 0 0;
  font-size: 12px;
}
.field.is-invalid input,
.field.is-invalid .input-wrap,
.field.is-invalid .phone-box {
  border-color: var(--red);
}
.field.is-invalid .mpin input,
[data-mpin].is-invalid .mpin input {
  border-color: var(--red);
}
.ok { color: var(--green-deep); font-weight: 700; font-size: 13px; margin: 0 0 12px; text-align: center; }
.link { display: block; text-align: center; color: var(--green-dark); font-weight: 800; margin-top: 14px; }
.switch { text-align: center; color: var(--muted); margin-top: 18px; }
.switch a { color: var(--green-dark); font-weight: 800; }

.field input:focus, .mpin input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .18);
  background: #fff;
}
.mpin input.is-filled {
  border-color: var(--green);
  background: #f0fdf4;
}
.auth-logo { animation: pop .55s cubic-bezier(.22, 1, .36, 1); }
@keyframes pop {
  from { transform: scale(.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 52px; border: 0; border-radius: 999px;
  font-weight: 800; cursor: pointer; padding: 12px 16px;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease, opacity .15s ease;
}
.btn-green { background: var(--green); color: #052e16; box-shadow: 0 10px 22px rgba(34, 197, 94, .32); }
.btn-green:hover { filter: brightness(1.04); }
.btn-green:active { transform: scale(.98); }
.btn-green:disabled { opacity: .45; box-shadow: none; transform: none; }
.btn-white { background: #fff; color: var(--green-deep); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.wizard { display: flex; flex-direction: column; }
.wizard-top { display: grid; grid-template-columns: 72px 1fr 72px; align-items: center; margin-bottom: 8px; }
.wizard-top .back { margin: 0; grid-column: 1; grid-row: 1; justify-self: start; background: none; border: 0; padding: 0; font-size: 14px; cursor: pointer; }
.stepper { grid-column: 2; grid-row: 1; display: flex; align-items: center; justify-content: center; gap: 0; }
.stepper-dot {
  width: 8px; height: 8px; border-radius: 999px; background: #e5e7eb;
  transition: width .28s ease, background .28s ease;
}
.stepper-dot.is-on { width: 22px; background: var(--green); }
.stepper-dot.is-done { background: var(--green); }
.stepper-line {
  width: 28px; height: 3px; background: #e5e7eb; margin: 0 6px; border-radius: 99px;
  transition: background .28s ease;
}
.stepper-line.is-on { background: var(--green); }
.step-count { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 12px; font-weight: 800; margin: 8px 0 0; }
.wizard-form { display: flex; flex-direction: column; flex: 1; }
.wizard-stage { position: relative; min-height: 168px; margin-bottom: 8px; overflow: hidden; }
.wizard-step { display: none; }
.wizard-step.is-on {
  display: block;
  animation: stepIn .34s cubic-bezier(.22, 1, .36, 1);
}
.wizard-step.is-on.is-back { animation-name: stepInBack; }
@keyframes stepIn {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}
@keyframes stepInBack {
  from { opacity: 0; transform: translateX(-28px); }
  to { opacity: 1; transform: none; }
}
.is-shake { animation: shake .42s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.btn-white { background: #fff; color: var(--green-deep); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.head {
  background: var(--green);
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 20px 22px;
  border-radius: 0 0 28px 28px;
}
.head.navy { background: var(--navy); }
.head h1 { margin: 0; font-size: 28px; letter-spacing: -0.03em; }
.head p { margin: 4px 0 0; opacity: .9; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.icon-round {
  width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.16);
  display: grid; place-items: center; color: #fff; border: 0;
}

.pad { padding: 16px; }
.section-title { margin: 8px 4px 12px; font-size: 18px; }
.meal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.meal {
  background: var(--card); border-radius: 22px; padding: 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
  min-height: 132px;
}
.meal h3 { margin: 10px 0 4px; font-size: 18px; }
.meal p { margin: 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.meal .tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; margin-top: 10px; }
.tag.taken { color: var(--green-deep); }
.tag.open { color: var(--orange); }
.m-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: #fff; }
.m-icon svg { width: 22px; height: 22px; }
.m-breakfast { background: #f97316; }
.m-lunch { background: #22c55e; }
.m-tea { background: #eab308; }
.m-dinner { background: #ef4444; }

.scan-cta { margin: 16px 0 8px; }

.tabs {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #9ca3af; font-size: 11px; font-weight: 800; padding: 6px 0; }
.tab svg { width: 22px; height: 22px; }
.tab.is-on { color: var(--green-dark); }
.cashier .tab.is-on { color: var(--navy); }

.scan-stage {
  background: #111; color: #fff; flex: 1; min-height: 100%; display: flex; flex-direction: column;
}
.scan-top { display: flex; align-items: center; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 16px 12px; }
.scan-top h1 { margin: 0; font-size: 20px; }
.preview { position: relative; flex: 1; overflow: hidden; background: #000; }
.preview video, .preview canvas { width: 100%; height: 100%; object-fit: cover; }
.frame {
  position: absolute; inset: 18% 14%; border: 3px solid #fff; border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.35);
}
.scan-help { text-align: center; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
.manual { display: flex; gap: 8px; margin-top: 12px; }
.manual input { flex: 1; border-radius: 12px; border: 0; padding: 12px; }

.success { flex: 1; min-height: 100%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; text-align: center; }
.success-mark {
  width: 96px; height: 96px; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: 44px; margin-bottom: 18px;
}
.success h1 { margin: 0 0 8px; }
.meta { color: var(--muted); font-weight: 700; margin: 4px 0; }

.day { background: #fff; border-radius: 20px; padding: 14px; margin-bottom: 12px; box-shadow: 0 8px 20px rgba(15,23,42,.05); }
.day h3 { margin: 0 0 10px; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid #f3f4f6; }
.badge { border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 800; }
.badge-on { background: #dcfce7; color: #166534; }
.badge-off { background: #ffedd5; color: #9a3412; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: #fff; border-radius: 22px; padding: 16px; box-shadow: 0 8px 20px rgba(15,23,42,.05); }
.stat strong { display: block; font-size: 32px; margin: 8px 0 0; }
.stat span { color: var(--muted); font-weight: 800; font-size: 13px; }
.stat .m-icon { color: #fff; }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; margin-top: 16px; }
.chart-col { flex: 1; text-align: center; }
.chart-bars { height: 110px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar { width: 8px; border-radius: 8px 8px 2px 2px; min-height: 4px; }
.bar.breakfast { background: #22c55e; }
.bar.lunch { background: #f97316; }
.bar.tea { background: #eab308; }
.bar.dinner { background: #ef4444; }
.chart-label { font-size: 10px; color: var(--muted); font-weight: 700; }
.chart-bars.single { justify-content: center; }
.chart-bars.single .bar { width: 18px; }
.served { margin: 14px 0 0; font-weight: 800; color: var(--muted); }

.qr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qr-card { background: #fff; border-radius: 22px; padding: 14px; text-align: center; box-shadow: 0 8px 20px rgba(15,23,42,.05); }
.qr-card .qr-preview svg { width: 120px; height: 120px; margin: 8px auto; }
.qr-card h3 { margin: 6px 0 2px; }
.qr-card p { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.list { background: #fff; border-radius: 20px; overflow: hidden; }
.list-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; padding: 12px; border-bottom: 1px solid #f3f4f6; font-size: 13px; align-items: center; }
.chips { display: flex; gap: 8px; overflow: auto; padding: 0 0 12px; }
.chip { white-space: nowrap; border-radius: 999px; padding: 8px 12px; background: #fff; font-weight: 800; font-size: 13px; border: 1px solid var(--line); }
.chip.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.profile-card { background: #fff; border-radius: 24px; padding: 22px; text-align: center; margin-top: 16px; }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 24px; }
.print-page { min-height: 100dvh; background: #fff; padding: 24px; text-align: center; }
.print-page svg { width: 240px; height: 240px; margin: 16px auto; }

@media print {
  body { background: #fff; display: block; padding: 0; }
  .phone { width: 100%; max-width: none; height: auto; min-height: 0; border-radius: 0; box-shadow: none; overflow: visible; }
  .no-print { display: none !important; }
}
