:root {
  --green: #3d7a22;
  --green-dark: #2f5d1e;
  --green-deep: #244a16;
  --green-light: #e9f2e0;
  --cream: #f7f4e6;
  --rose: #e07a7a;
  --rose-light: #fbeaea;
  --gold: #d9a627;
  --gold-light: #faf1d8;
  --red: #c0392b;
  --blue: #2471a3;
  --bg: #f7f4e8;
  --card: #ffffff;
  --text: #26301f;
  --muted: #75816b;
  --border: #e4e4d5;
  --radius: 14px;
  --shadow: 0 1px 5px rgba(50, 70, 30, .10);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--green-deep), var(--green));
  color: #fff;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; }
.topbar .logo { font-size: 28px; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: .06em; }
.topbar .sub { margin: 0; font-size: 12px; opacity: .9; }

.container { max-width: 760px; margin: 0 auto; padding: 14px 12px 24px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; padding: 7px 2px 6px;
  font-size: 10.5px; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: inherit;
}
.tab .ticon { font-size: 20px; }
.tab.active { color: var(--green-dark); font-weight: 700; }

/* ---------- Cards & common ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.card h2 { font-size: 16px; margin: 0 0 8px; color: var(--green-dark); }
.card h3 { font-size: 14px; margin: 12px 0 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 4px 0; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 4px 8px; font-weight: 700; }

button.btn {
  background: var(--green); color: #fff; border: none; border-radius: 10px;
  padding: 10px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
button.btn.secondary { background: var(--green-light); color: var(--green-dark); }
button.btn.danger { background: #fbe9e7; color: var(--red); }
button.btn.gold { background: var(--gold); }
button.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
button.btn:active { opacity: .85; }
button.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  font-family: inherit; font-size: 15px; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 10px; background: #fff; width: 100%;
}
label.fld { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
label.fld input, label.fld select { margin-top: 4px; font-weight: 400; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 6px 12px; font-size: 13.5px; cursor: pointer; font-family: inherit;
  color: var(--text);
}
.chip.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.chip.cat { background: var(--green-light); border-color: transparent; color: var(--green-dark); font-weight: 600; }
.chip.plain { cursor: default; background: var(--bg); }

/* ---------- Segments (gói dịch vụ) ---------- */
.seg-card { border-left: 6px solid var(--green); position: relative; }
.seg-card.s60 { border-color: var(--green); }
.seg-card.s30 { border-color: var(--rose); }
.seg-card.s10 { border-color: var(--gold); }
.seg-pct { font-size: 26px; font-weight: 800; }
.s60 .seg-pct { color: var(--green); }
.s30 .seg-pct { color: var(--rose); }
.s10 .seg-pct { color: var(--gold); }
.seg-price {
  display: inline-block; border-radius: 999px; padding: 3px 12px;
  font-weight: 800; font-size: 14px; color: #fff; background: var(--green);
}
.s30 .seg-price { background: var(--rose); }
.s10 .seg-price { background: var(--gold); }
.seg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.seg-title { font-size: 16px; font-weight: 800; color: var(--text); }
ul.tick { margin: 8px 0 4px; padding: 0; list-style: none; font-size: 13.5px; }
ul.tick li { margin-bottom: 5px; padding-left: 22px; position: relative; }
ul.tick li::before { content: "✔"; position: absolute; left: 0; color: var(--green); font-weight: 700; }
.s30 ul.tick li::before { color: var(--rose); }
.s10 ul.tick li::before { color: var(--gold); }

/* ---------- Urine swatches ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.swatch {
  border: 2px solid var(--border); border-radius: 12px; padding: 8px 6px;
  text-align: center; cursor: pointer; background: #fff; font-family: inherit; font-size: 11.5px;
  color: var(--text); line-height: 1.25;
}
.swatch .dot { display: block; width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 6px; border: 1px solid rgba(0,0,0,.12); }
.swatch.active { border-color: var(--green); background: var(--green-light); font-weight: 700; }

/* ---------- Guidance result ---------- */
.rescode { display: inline-block; background: var(--gold-light); color: #8a5a00; font-weight: 700; border-radius: 8px; padding: 3px 10px; font-size: 13px; margin-bottom: 8px; }
.mealbox { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.mealbox h4 { margin: 0 0 6px; font-size: 14px; color: var(--green-dark); }
.mealbox .water { font-size: 13px; color: var(--blue); font-weight: 600; margin: 6px 0; }
.mealbox .thuc { font-size: 12.5px; color: var(--muted); white-space: pre-line; }
.warnbox { background: var(--gold-light); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-top: 8px; }

/* ---------- Customer card ---------- */
.profile-card { border: 2px solid transparent; }
.profile-card.active { border-color: var(--green); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; margin-top: 10px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.stat .v { font-size: 16px; font-weight: 700; color: var(--green-dark); }
.stat .l { font-size: 11px; color: var(--muted); }
.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 11.5px; font-weight: 700; }
.badge.g60 { background: var(--green-light); color: var(--green-dark); }
.badge.g30 { background: var(--rose-light); color: var(--rose); }
.badge.g10 { background: var(--gold-light); color: #8a5a00; }
.badge.the-amhan { background: #e3edf7; color: var(--blue); }
.badge.the-honhop { background: linear-gradient(90deg, #fdeaea 50%, #e3edf7 50%); color: #8a4a1e; }
.badge.the-duonghoa { background: #fdeaea; color: var(--red); }
.badge.the-canbang { background: var(--green-light); color: var(--green-dark); }
.siglog { font-size: 12.5px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 6px; margin-top: 8px; }

/* ---------- Menu (thực đơn xuất bản) ---------- */
.daytabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.daytab {
  border: 1px solid var(--border); background: #fff; border-radius: 10px;
  padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.daytab.active { background: var(--green); color: #fff; border-color: var(--green); font-weight: 700; }

.menu-sheet {
  background: #fffdf5; border: 1px solid #e7e2c8; border-radius: 14px;
  padding: 16px; margin-bottom: 12px;
}
.menu-sheet .m-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border-bottom: 3px solid var(--green); padding-bottom: 8px; margin-bottom: 4px;
}
.menu-sheet .m-brand { font-weight: 800; color: var(--green-dark); font-size: 15px; letter-spacing: .04em; }
.menu-sheet .m-brand small { display: block; font-weight: 600; color: var(--muted); font-size: 10.5px; letter-spacing: 0; }
.menu-sheet .m-day { text-align: right; }
.menu-sheet .m-day .d1 { font-weight: 800; font-size: 16px; color: var(--green-dark); }
.menu-sheet .m-day .d2 { font-size: 11.5px; color: var(--muted); }
.menu-sheet .m-person { font-size: 12.5px; color: var(--muted); margin: 4px 0 10px; }
.mslot { border-bottom: 1px dashed #ddd6b8; padding: 9px 0; }
.mslot:last-child { border-bottom: none; }
.mslot .s-time {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px;
}
.mslot .s-time b { color: var(--green-dark); font-size: 13.5px; }
.mslot .s-time span { font-size: 11px; color: var(--muted); }
.mslot.star { background: var(--gold-light); margin: 0 -8px; padding: 9px 8px; border-radius: 10px; }
.mitem { display: flex; gap: 8px; font-size: 13px; margin: 3px 0; align-items: baseline; }
.mitem .mi-role { flex-shrink: 0; width: 66px; font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.mitem .mi-name { flex: 1; }
.mitem .mi-amt { flex-shrink: 0; font-size: 11.5px; color: var(--green-dark); font-weight: 700; white-space: nowrap; }
.mnote { font-size: 11px; color: #8a5a00; background: var(--gold-light); border-radius: 8px; padding: 5px 8px; margin-top: 5px; }
.m-foot { font-size: 10.5px; color: var(--muted); text-align: center; border-top: 1px solid #e7e2c8; padding-top: 6px; margin-top: 10px; }

/* Tổng quan sheet */
.ov-row { display: flex; gap: 8px; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed #ddd6b8; }
.ov-row .k { flex-shrink: 0; width: 118px; font-weight: 700; color: var(--green-dark); font-size: 12px; }
.ov-sec { font-weight: 800; color: #8a5a00; font-size: 12.5px; margin-top: 10px; text-transform: uppercase; letter-spacing: .03em; }

/* Export container (ẩn, cỡ cố định để chụp ảnh) */
#print-root { position: absolute; left: -9999px; top: 0; }
#print-root .menu-sheet { width: 800px; font-size: 17px; }
#print-root .mitem { font-size: 16px; }
#print-root .mitem .mi-role { width: 92px; font-size: 12.5px; }
#print-root .mitem .mi-amt { font-size: 14px; }
#print-root .mslot .s-time b { font-size: 17px; }
#print-root .mslot .s-time span { font-size: 13px; }
#print-root .ov-row { font-size: 15.5px; }
#print-root .ov-row .k { width: 150px; font-size: 14px; }
#print-root .mnote { font-size: 13px; }
#print-root .m-foot { font-size: 12.5px; }
#print-root .menu-sheet .m-brand { font-size: 19px; }
#print-root .menu-sheet .m-brand small { font-size: 12px; }
#print-root .menu-sheet .m-day .d1 { font-size: 19px; }
#print-root .menu-sheet .m-day .d2 { font-size: 13px; }
#print-root .menu-sheet .m-person { font-size: 14.5px; }

/* ---------- Food list / search ---------- */
.searchbox { position: relative; margin-bottom: 10px; }
.searchbox input { padding-left: 36px; }
.searchbox::before { content: "🔎"; position: absolute; left: 10px; top: 9px; font-size: 15px; }
.foodrow {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.foodrow:last-child { border-bottom: none; }
.foodrow .n { font-size: 14.5px; }
.foodrow .g { font-size: 11.5px; color: var(--muted); }
.foodrow .k { font-size: 13px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.foodrow .pfc { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(25, 40, 15, .5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; border-radius: 18px 18px 0 0; width: 100%; max-width: 760px;
  max-height: 88vh; overflow-y: auto; padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 18px; max-height: 82vh; }
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.modal-head h2 { margin: 0; font-size: 17px; color: var(--green-dark); }
.modal-close { border: none; background: var(--bg); border-radius: 50%; width: 32px; height: 32px; font-size: 16px; cursor: pointer; flex-shrink: 0; }
.nutri-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.nutri-table td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.nutri-table td:last-child { text-align: right; font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 24px 10px; font-size: 14px; }
.disclaimer { background: #fff8e6; border: 1px solid #f2dfa8; border-radius: 12px; padding: 12px; font-size: 13px; margin-bottom: 12px; }
.footer-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }
.prewrap { white-space: pre-line; }
ul.tight { margin: 6px 0; padding-left: 20px; font-size: 14px; }
ul.tight li { margin-bottom: 4px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- In (print) ---------- */
@media print {
  .topbar, .tabbar, #modal-root, .no-print { display: none !important; }
  body { background: #fff; padding: 0; }
  .container { max-width: none; padding: 0; }
  .menu-sheet { break-inside: avoid; page-break-inside: avoid; border: 1px solid #999; margin-bottom: 8mm; }
  .print-only-show { display: block !important; }
}
