.shell { display: flex; flex-wrap: wrap; min-height: 100dvh; }
.side { flex: 1 1 220px; max-width: 240px; background: var(--pine); color: var(--cream); display: flex; flex-direction: column; gap: 18px; padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand img { width: 44px; }
.brand .display { font-size: 18px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--cream); text-align: left; padding: 0 12px; font-size: 14px; }
.nav .home { min-height: 44px; display: flex; align-items: center; padding: 0 12px; border-radius: 10px; color: var(--cream); text-decoration: none; font-size: 14px; border: 1px solid rgba(245,239,230,.3); margin-bottom: 6px; white-space: nowrap; flex: none; }
.nav button[aria-current="page"] { background: var(--cream); color: var(--pine); font-weight: 700; }
.me { margin-top: auto; font-size: 12px; opacity: .9; display: flex; justify-content: space-between; align-items: center; padding: 0 6px; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; min-height: 40px; font-size: 13px; }
.main { flex: 999 1 560px; min-width: 0; padding: 22px 26px 60px; display: flex; flex-direction: column; gap: 16px; max-width: 1280px; }
h1 { margin: 0; font-family: var(--font-display); font-size: 26px; letter-spacing: .04em; color: var(--pine); text-transform: uppercase; }
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bar .grow { flex: 1; }
.muted { color: var(--ink-2); font-size: 13px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; color: var(--ink-2); font-weight: 600; }

/* Ô số liệu */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .k { font-size: 12px; color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; font-weight: 600; }
.kpi .v { font-size: 26px; font-weight: 700; color: var(--pine); }
.kpi .s { font-size: 12px; color: var(--ink-2); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }

/* Biểu đồ cột theo giờ */
.hours { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--line-strong); position: relative; }
.hours .b { flex: 1; background: var(--pine); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.hours .b.zero { background: var(--line); }
.hours .b:hover { background: var(--cedar); }
.hlabels { display: flex; gap: 2px; font-size: 10px; color: var(--ink-2); }
.hlabels span { flex: 1; text-align: center; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 6px; z-index: 90; white-space: nowrap; }
.hbar { display: grid; grid-template-columns: minmax(110px, 1.2fr) 3fr auto; gap: 8px; align-items: center; font-size: 13px; padding: 4px 0; }
.hbar .track { height: 12px; }
.hbar .fill { height: 12px; background: var(--pine); border-radius: 0 4px 4px 0; min-width: 2px; }

/* Bảng */
.tbl-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--ink-2); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--cream); }
td.r, th.r { text-align: right; }
tr.off td { color: var(--muted); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: #E3EDE1; color: var(--pine); }
.badge.warn { background: var(--sand); color: var(--cedar); }
.badge.bad { background: #F6DAD7; color: var(--danger); }
.badge.mute { background: var(--line); color: var(--ink-2); }

/* Form trong hộp thoại */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; font-size: 14px; color: var(--ink); }
.checks input { width: 18px; height: 18px; }
.lines { display: flex; flex-direction: column; gap: 8px; }
.ln { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; align-items: center; }
.ln select, .ln input { min-height: 42px; border-radius: 9px; border: 1px solid var(--line-strong); padding: 0 10px; background: #fff; font-size: 14px; width: 100%; }
.ln .x { width: 42px; height: 42px; border-radius: 9px; border: 1px solid var(--line-strong); background: #fff; color: var(--danger); font-size: 18px; }
.sum { display: flex; justify-content: space-between; font-size: 14px; padding: 10px 12px; background: var(--cream); border-radius: 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch b { display: block; font-size: 14px; }
.switch small { color: var(--ink-2); font-size: 12px; }
.switch input[type="checkbox"] { width: 22px; height: 22px; flex: none; }
.switch select, .switch input[type="time"], .switch input[type="number"] { min-height: 40px; border-radius: 9px; border: 1px solid var(--line-strong); padding: 0 10px; background: #fff; }

/* Bàn */
.zone { display: flex; flex-direction: column; gap: 10px; }
.zone-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zone-h b { font-size: 16px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.tcell { min-height: 72px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 0 12px; text-align: left; }
.tcell b { font-family: var(--font-display); font-size: 18px; letter-spacing: .03em; color: var(--pine); }
.tcell small { color: var(--ink-2); font-size: 12px; }
.tcell.off { opacity: .5; border-style: dashed; }
.qrprev { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qrprev canvas { width: 200px; height: 200px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; }
.url { font-size: 12px; word-break: break-all; background: var(--cream); padding: 8px 10px; border-radius: 8px; }

@media (max-width: 820px) {
  .shell { flex-direction: column; flex-wrap: nowrap; }
  .side { max-width: none; flex: none; padding: 12px; gap: 10px; }
  .brand img { width: 32px; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .nav button { white-space: nowrap; flex: none; }
  .me { display: none; }
  .main { padding: 16px 14px 60px; }
  .ln { grid-template-columns: 1fr 1fr; }
  .ln select { grid-column: 1 / -1; }
}

/* Cảnh báo trên Tổng quan */
.notes { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; }
.note-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.note-row .grow { flex: 1; }
.stock-alert { display: flex; flex-direction: column; gap: 12px; }
.sa-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sa-head .grow { flex: 1; }
.sa-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.sa-chip { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 0; font-size: 13px; font-weight: 700; }
.sa-chip.bad { background: #F6DAD7; color: var(--danger); }
.sa-chip.warn { background: var(--sand); color: var(--cedar); }
.sa-chip.mute { background: var(--line); color: var(--ink-2); }
.srows { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0 24px; }
.srow { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name badge" "meter qty"; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.srow.extra { display: none; }
.stock-alert.open .srow.extra { display: grid; }
.stock-alert.open .more { display: none; }
.sname { grid-area: name; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .badge { grid-area: badge; justify-self: end; }
.meter { grid-area: meter; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 3px; }
.meter .bad { background: var(--danger); }
.meter .warn { background: var(--ochre); }
.sqty { grid-area: qty; font-size: 13px; text-align: right; white-space: nowrap; }
.sqty small { color: var(--ink-2); font-size: 12px; }
.more { align-self: flex-start; color: var(--cedar); }
.sa-new { margin: 0; line-height: 1.5; }

.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; display: block; background: var(--line); }
.thumb.empty { background: repeating-linear-gradient(45deg, var(--cream), var(--cream) 4px, var(--line) 4px, var(--line) 8px); }
.imgpick { display: flex; gap: 14px; align-items: center; }
.imgbox { width: 120px; height: 120px; border-radius: 12px; border: 1px dashed var(--line-strong); background: var(--cream); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--ink-2); font-size: 12px; flex: none; }
.imgbox img { width: 100%; height: 100%; object-fit: cover; }
label.btn { cursor: pointer; }

.nbadge { display: inline-flex; min-width: 20px; height: 20px; border-radius: 10px; background: var(--ochre); color: var(--ink); font-size: 11px; font-weight: 800; align-items: center; justify-content: center; padding: 0 6px; margin-left: 4px; }
.simgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.simg { display: flex; flex-direction: column; gap: 6px; }
.simg .imgbox { width: 100%; height: 110px; }

.subh { margin: 14px 0 4px; font-size: 14px; color: var(--pine); }

.fe-top { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.fe-top .field { min-width: 220px; }
.fe-mode { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 12px; padding: 3px; background: var(--paper); }
.fe-mode button { border: 0; background: transparent; min-height: 38px; padding: 0 16px; border-radius: 9px; font-weight: 600; color: var(--ink-2); }
.fe-mode button[aria-pressed="true"] { background: var(--pine); color: var(--cream); }
