/* Healthy Kalories — shared styles (customer pages are mobile-first; admin adds admin.css) */

:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #efece3;
  --text: #1b2a21;
  --muted: #5b6a61;
  --border: #e0dccf;
  --primary: #1f7a4d;
  --primary-strong: #17613c;
  --primary-soft: #e4f2e9;
  --on-primary: #ffffff;
  --accent: #d9652f;
  --accent-soft: #fcebe1;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warning: #8a5a00;
  --warning-soft: #fff3cf;
  --info: #25507a;
  --info-soft: #e8f0f8;
  --focus: #2b8a5c;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 35, 25, 0.05), 0 6px 20px rgba(20, 35, 25, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --tap: 48px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111814;
    --surface: #18211c;
    --surface-2: #1f2a24;
    --text: #e8efe9;
    --muted: #a3b2a8;
    --border: #2d3a33;
    --primary: #3fae78;
    --primary-strong: #57c28d;
    --primary-soft: #1d3527;
    --on-primary: #08130d;
    --accent: #f08a57;
    --accent-soft: #3a2519;
    --danger: #f2877e;
    --danger-soft: #3b1f1c;
    --warning: #f0c35a;
    --warning-soft: #372d14;
    --info: #8fb9e6;
    --info-soft: #1b2a3a;
    --focus: #57c28d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-strong); }
img, svg { max-width: 100%; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.visually-hidden {
  position: absolute !important; 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; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.pre-line { white-space: pre-line; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }
.stack-sm > * + * { margin-top: 0.5rem; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }

/* ---------- Layout (customer) ---------- */

.app-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header .inner {
  max-width: 640px; margin: 0 auto; padding: 0.6rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; color: var(--text); font-weight: 700; }
.brand img { width: 32px; height: 32px; }
.brand span { font-size: 1.05rem; letter-spacing: -0.01em; }

.page { max-width: 640px; margin: 0 auto; padding: 1.25rem 1rem 6rem; }
.page.narrow { max-width: 480px; }

.hero { text-align: center; padding: 1.5rem 0 0.5rem; }
.hero img { width: 72px; height: 72px; }
.hero h1 { margin-top: 0.75rem; font-size: 1.75rem; }
.hero p { color: var(--muted); }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card h2 { margin-bottom: 0.75rem; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.5rem; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:hover { border-color: var(--primary); }
.card-link:focus-visible { outline-offset: 0; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.notice {
  border-radius: var(--radius-sm); padding: 0.75rem 0.9rem; margin-bottom: 1rem;
  background: var(--info-soft); color: var(--info); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent);
}
.notice.warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.notice.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice.success { background: var(--primary-soft); color: var(--primary-strong); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.notice strong { display: block; margin-bottom: 0.15rem; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.2rem; line-height: 1; margin-bottom: 0.5rem; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--tap); padding: 0.7rem 1.2rem;
  border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 1rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; text-align: center;
  background: var(--surface-2); color: var(--text);
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: color-mix(in srgb, var(--surface-2) 80%, var(--text) 8%); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-strong); color: var(--on-primary); }
.btn.outline { background: transparent; border-color: var(--border); }
.btn.outline:hover { border-color: var(--primary); background: var(--primary-soft); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; padding-inline: 0.6rem; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 36px; padding: 0.4rem 0.8rem; font-size: 0.9rem; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 64px; font-size: 1.15rem; border-radius: 16px; }
.btn .spinner { width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.menu-buttons { display: grid; gap: 0.75rem; margin-top: 1.25rem; }
.menu-buttons .btn { justify-content: flex-start; padding-inline: 1.1rem; }
.menu-buttons .btn .icon { width: 28px; height: 28px; flex: none; }
.menu-buttons .btn small { display: block; font-weight: 400; font-size: 0.85rem; opacity: 0.85; }
.menu-buttons .btn .label { text-align: left; }

/* ---------- Forms ---------- */

.field { margin-bottom: 1rem; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.field .hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }
.field .req { color: var(--accent); margin-left: 0.15rem; }
.field .opt { color: var(--muted); font-weight: 400; font-size: 0.85rem; margin-left: 0.3rem; }

input[type="text"], input[type="tel"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="search"], select, textarea {
  width: 100%; min-height: var(--tap);
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
.error-text { color: var(--danger); font-size: 0.875rem; margin-top: 0.3rem; }
.error-text:empty { display: none; }
.form-error { margin-bottom: 1rem; }

.check { display: flex; align-items: center; gap: 0.6rem; min-height: 40px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }

.pin-input { letter-spacing: 0.4em; font-size: 1.2rem; }

.form-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.25rem; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.6rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; line-height: 1.4; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge.green { background: var(--primary-soft); color: var(--primary-strong); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.orange { background: var(--accent-soft); color: var(--accent); }

/* ---------- Order wizard ---------- */

.steps { display: flex; gap: 0.35rem; margin: 0.25rem 0 1rem; }
.steps span { flex: 1; height: 5px; border-radius: 999px; background: var(--border); }
.steps span.done { background: var(--primary); }
.step-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.6rem; }
.choice-list { display: grid; gap: 0.6rem; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.15rem;
  width: 100%; min-height: 64px; padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.choice:hover { border-color: var(--primary); }
.choice[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.choice[disabled] { opacity: 0.55; cursor: not-allowed; background: var(--surface-2); }
.choice .title { font-weight: 700; font-size: 1.05rem; }
.choice .sub { font-size: 0.85rem; color: var(--muted); }
.choice.date { align-items: center; text-align: center; min-height: 76px; }
.choice.date .day { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.choice.date .num { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.choice.date .mon { font-size: 0.8rem; color: var(--muted); }
.choice.date .tag { font-size: 0.7rem; font-weight: 700; color: var(--primary); }

.product {
  display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1rem; align-items: center;
  padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.product + .product { margin-top: 0.75rem; }
.product.selected { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.product .name { font-weight: 700; font-size: 1.05rem; }
.product .desc { grid-column: 1 / -1; color: var(--muted); font-size: 0.9rem; margin: 0; }
.product .price { font-weight: 700; color: var(--primary-strong); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.stepper button {
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--primary-strong);
  font-size: 1.4rem; font-weight: 700; cursor: pointer; line-height: 1;
}
.stepper button:hover:not([disabled]) { background: var(--primary-soft); }
.stepper button[disabled] { color: var(--border); cursor: not-allowed; }
.stepper output { min-width: 2.2rem; text-align: center; font-weight: 700; font-size: 1.05rem; }

.sticky-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -6px 20px rgba(20, 35, 25, 0.08);
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
}
.sticky-bar .inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; }
.sticky-bar .summary { flex: 1; line-height: 1.25; }
.sticky-bar .summary strong { font-size: 1.15rem; display: block; }

.lines { width: 100%; border-collapse: collapse; }
.lines td { padding: 0.45rem 0; border-bottom: 1px dashed var(--border); vertical-align: top; }
.lines tr:last-child td { border-bottom: 0; }
.lines .qty { color: var(--muted); white-space: nowrap; padding-left: 0.5rem; }
.lines .amt { text-align: right; white-space: nowrap; font-weight: 600; padding-left: 0.75rem; }
.total-row { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.15rem; padding-top: 0.75rem; margin-top: 0.5rem; border-top: 2px solid var(--border); }

.success-mark {
  width: 72px; height: 72px; border-radius: 50%; margin: 0.5rem auto 1rem;
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center;
}
.success-mark svg { width: 38px; height: 38px; }

.order-card .top { display: flex; justify-content: space-between; gap: 0.5rem; align-items: flex-start; }
.order-card .when { font-weight: 700; }
.order-card .meta { color: var(--muted); font-size: 0.9rem; }
.order-card .badges { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
.order-card .bottom { display: flex; justify-content: space-between; margin-top: 0.5rem; font-size: 0.95rem; }

.identifiers { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.identifiers .chip { background: var(--surface-2); border-radius: 8px; padding: 0.15rem 0.55rem; font-size: 0.9rem; }
.identifiers .chip b { font-weight: 600; color: var(--muted); margin-right: 0.3rem; }

/* ---------- Toast & dialog ---------- */

.toast-host { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 100; display: grid; gap: 0.5rem; width: min(92vw, 420px); pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg); padding: 0.8rem 1rem; border-radius: 12px;
  box-shadow: var(--shadow); font-weight: 500; animation: toast-in 0.2s ease-out; pointer-events: auto;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--primary-strong); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

dialog {
  border: 0; border-radius: var(--radius); padding: 0; width: min(94vw, 520px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(10, 20, 15, 0.45); }
dialog .dialog-body { padding: 1.25rem; max-height: 80vh; overflow: auto; }
dialog .dialog-actions { display: flex; gap: 0.6rem; justify-content: flex-end; padding: 0.9rem 1.25rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

.loading { display: flex; align-items: center; justify-content: center; gap: 0.6rem; color: var(--muted); padding: 2rem 0; }
.loading::before { content: ""; width: 20px; height: 20px; border: 2.5px solid var(--primary); border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }

.footer-note { text-align: center; color: var(--muted); font-size: 0.85rem; margin-top: 2rem; }

@media (min-width: 560px) {
  .page { padding-top: 2rem; }
  .menu-buttons { grid-template-columns: 1fr 1fr; }
  .menu-buttons .btn.primary { grid-column: 1 / -1; }
}

@media print {
  .app-header, .sticky-bar, .toast-host, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; }
}

.inline-badge { margin-left: 0.5rem; vertical-align: middle; }
.mt { margin-top: 0.9rem; }
.card .stack-sm + .stack-sm { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Icons inside buttons/links */
svg.icon { width: 1.25em; height: 1.25em; flex: none; }
.btn { white-space: nowrap; }
.menu-buttons .btn { white-space: normal; }
