/* Quản lý bếp - bản độc lập. Layout: one phone-width column, sticky name bar on top, four-tab bar fixed at the bottom;
   each meal is a "phiếu ăn" ticket, the cut list is a ruled roster sheet. Glaze-blue accent (men lam). */
:root {
  --bg: #EDF0F6;
  --surface: #FFFFFF;
  --surface-2: #F5F7FB;
  --ink: #16213A;
  --muted: #56637F;
  --line: #D3DAE8;
  --accent: #1D3F94;
  --accent-ink: #FFFFFF;
  --accent-soft: #E2E9F9;
  --good: #17734A;
  --good-soft: #DDF1E6;
  --ok: #9A5B00;
  --ok-soft: #FBEBCB;
  --bad: #B93127;
  --bad-soft: #FBE1DE;
  --shadow: 0 1px 2px rgba(22, 33, 58, .06), 0 6px 18px rgba(22, 33, 58, .06);
  /* Không tải phông từ Internet: ứng dụng phải chạy được trong mạng nội bộ không có Internet. */
  --font-display: "sans-serif-condensed", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 14px;
  --gut: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1321; --surface: #151D30; --surface-2: #1B2540; --ink: #E9EDF7; --muted: #9BA7C2;
    --line: #2A3555; --accent: #93ACF7; --accent-ink: #0D1321; --accent-soft: #212F5C;
    --good: #5CC692; --good-soft: #153527; --ok: #E8AA4B; --ok-soft: #3A2C10;
    --bad: #F2857B; --bad-soft: #41191A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1321; --surface: #151D30; --surface-2: #1B2540; --ink: #E9EDF7; --muted: #9BA7C2;
  --line: #2A3555; --accent: #93ACF7; --accent-ink: #0D1321; --accent-soft: #212F5C;
  --good: #5CC692; --good-soft: #153527; --ok: #E8AA4B; --ok-soft: #3A2C10;
  --bad: #F2857B; --bad-soft: #41191A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
img { max-width: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { max-width: 560px; margin: 0 auto; padding-inline: var(--gut); padding-block: 0 104px; }

/* ---- name bar ---- */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-inline: calc(var(--gut) * -1); padding: 12px var(--gut);
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { flex: none; }
.brand-text { min-width: 0; }
.brand h1 { font-family: var(--font-display); font-weight: 700; font-size: 21px; line-height: 1.1; letter-spacing: .02em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.badge {
  flex: none; font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.wait { background: var(--ok-soft); color: var(--ok); }
.badge.no { background: var(--bad-soft); color: var(--bad); }

/* ---- tabs ---- */
.tab { display: flex; flex-direction: column; gap: 16px; padding-top: 16px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px max(8px, calc((100% - 560px) / 2)) calc(6px + env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
}
.tabbar button {
  position: relative; border: 0; background: transparent; border-radius: 12px; padding: 7px 2px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 500; color: var(--muted); min-width: 0;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.tabbar .dot {
  position: absolute; top: 3px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: var(--surface); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* ---- blocks ---- */
.sec-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 1.2; letter-spacing: .03em; text-transform: uppercase; text-wrap: balance; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13.5px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 0; min-width: 0; }
.notice { border-radius: var(--r); padding: 12px 14px; background: var(--accent-soft); color: var(--ink); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.notice strong { font-weight: 600; }
.notice.warn { background: var(--ok-soft); }
.notice.bad { background: var(--bad-soft); }
.notice.good { background: var(--good-soft); }
.empty { text-align: center; color: var(--muted); padding: 22px 12px; border: 1px dashed var(--line); border-radius: var(--r); font-size: 14px; }

/* ---- controls ---- */
.btn {
  border: 1px solid transparent; border-radius: 12px; padding: 11px 16px; min-height: 46px;
  font-weight: 600; font-size: 15px; background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .lbl { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  padding: 11px 12px; font-size: 16px; min-height: 46px;
}
.field textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
.field .err { color: var(--bad); font-size: 13px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .two { grid-template-columns: 1fr; } }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.acc { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.seg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 13.5px; font-weight: 500; color: var(--muted); min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---- cut days ---- */
.day { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.day:first-child { border-top: 0; padding-top: 0; }
.day:last-child { padding-bottom: 0; }
.day-name { font-weight: 600; }
.day-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.meals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.meal-tg {
  border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 12px; min-height: 52px; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-weight: 600; font-size: 14.5px;
}
.meal-tg small { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.meal-tg[aria-pressed="true"] { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.meal-tg[aria-pressed="true"] small { color: var(--bad); }
.meal-tg:disabled { opacity: .55; cursor: not-allowed; }
.clock { font-family: var(--font-display); font-weight: 700; font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.savebar { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 10; }
.savebar .btn { box-shadow: 0 6px 20px rgba(13, 19, 33, .28); }

/* ---- meal ticket (phiếu ăn) ---- */
.ticket { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.ticket-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
.ticket-head h3 { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: .03em; text-transform: uppercase; line-height: 1; }
.ticket-cut { position: relative; border-top: 1.5px dashed var(--line); }
.ticket-cut::before, .ticket-cut::after {
  content: ""; position: absolute; top: -9px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line);
}
.ticket-cut::before { left: -9px; clip-path: inset(0 0 0 50%); }
.ticket-cut::after { right: -9px; clip-path: inset(0 50% 0 0); }
.ticket-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.lv { border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 12px; min-height: 48px; font-weight: 600; font-size: 14.5px; padding: 6px 4px; }
.lv[aria-pressed="true"].good { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.lv[aria-pressed="true"].ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.lv[aria-pressed="true"].bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.photo-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.photo-pick img, .thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.thumb-btn { padding: 0; border: 0; background: none; border-radius: 10px; line-height: 0; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; font-size: 0; }

/* ---- public boards ---- */
.bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.bar i { display: block; height: 100%; }
.bar .good { background: var(--good); } .bar .ok { background: var(--ok); } .bar .bad { background: var(--bad); }
.tally { display: flex; gap: 8px; flex-wrap: wrap; }
.review { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.review:first-child { border-top: 0; padding-top: 0; }
.review:last-child { padding-bottom: 0; }
.who { font-weight: 600; overflow-wrap: anywhere; }
.who small { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-left: 4px; }
.said { white-space: pre-wrap; overflow-wrap: anywhere; }
.when { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---- roster sheet ---- */
.counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.count { border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; background: var(--surface-2); text-align: center; min-width: 0; }
.count b { display: block; font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.count span { font-size: 12px; color: var(--muted); }
.count em { display: block; font-style: normal; font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.sheet-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.roster { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 14px; font-variant-numeric: tabular-nums; }
.roster th { font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: left; background: var(--surface-2); }
.roster th, .roster td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.roster tr:last-child td { border-bottom: 0; }
.roster td.c, .roster th.c { text-align: center; width: 46px; padding-inline: 2px; }
.roster td.n, .roster th.n { text-align: center; width: 34px; padding-inline: 2px; color: var(--muted); }
.roster td.x { color: var(--bad); font-weight: 700; }
.roster td.nm { font-weight: 600; overflow-wrap: anywhere; }
.roster td.nm small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.person { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.person:first-child { border-top: 0; padding-top: 0; }
.person:last-child { padding-bottom: 0; }
.person .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 14.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---- overlays ---- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  max-width: min(92vw, 480px); text-align: center; box-shadow: var(--shadow);
}
.toast.bad { background: var(--bad); color: var(--surface); }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 24, .62); display: flex; align-items: flex-end; justify-content: center; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.modal-box { background: var(--surface); border-radius: 18px; padding: 18px; width: 100%; max-width: 520px; max-height: 88%; overflow: auto; display: flex; flex-direction: column; gap: 14px; border: 1px solid var(--line); }
.modal-box img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
@media (min-width: 600px) { .modal { align-items: center; } }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .18s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
}

/* ---- bổ sung cho bản độc lập ---- */
.gap4 { gap: 4px; } .gap8 { gap: 8px; }
.center { text-align: center; }
.t19 { font-size: 17px; }
.block { display: block; }
.plain { font-family: var(--font-body); font-weight: 500; }
.net { margin-top: 12px; }
a.btn { text-decoration: none; }
.sub-title { font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; margin-top: 2px; }
.seg.full { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
.seg.full button { min-height: 44px; font-size: 15px; }
.pw { display: flex; gap: 8px; align-items: stretch; }
.pw input { flex: 1 1 0; min-width: 0; }
.pw-eye { flex: none; min-width: 58px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 0 12px; font-size: 13.5px; font-weight: 600; color: var(--accent); }
.person.as-btn { width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; color: inherit; font: inherit; align-items: center; flex-wrap: nowrap; }
.person.as-btn:first-child { border-top: 0; }
.person.as-btn .who, .person.as-btn .hint { display: block; }
.code-big { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace; font-size: 28px; font-weight: 700; letter-spacing: .08em; text-align: center; padding: 14px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; -webkit-user-select: all; user-select: all; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace; letter-spacing: .04em; }
.qr-wrap { display: flex; justify-content: center; }
/* Mã QR luôn đen trên nền trắng ở cả hai giao diện để máy ảnh đọc được. */
.qr { width: 220px; height: 220px; max-width: 100%; image-rendering: pixelated; border-radius: 10px; border: 1px solid var(--line); background: #FFFFFF; }
.tab > div:empty { display: none; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.roster td.w, .roster th.w { text-align: center; width: 78px; padding-inline: 2px; }
