:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --ink: #1d2a1f;
  --muted: #6b776d;
  --line: #e3e8e1;
  --brand: #377a12;      /* xanh lá theo logo VHFresh, đậm hơn để chữ trắng dễ đọc */
  --brand-2: #ecf5e3;
  --leaf: #52a01a;       /* màu lá trong logo */
  --accent: #c8862b;
  --warn: #c2410c;
  --warn-bg: #fff1e8;
  --info: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 40, 20, .06), 0 4px 16px rgba(20, 40, 20, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 'Be Vietnam Pro', system-ui, sans-serif; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
#app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 232px; flex: none; background: #1c3810; color: #dfeee0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand b { display: block; color: #fff; }
.brand small { color: #9fc4a2; font-size: 12px; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: #fff; display: grid; place-items: center; flex: none; padding: 3px; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; color: #cfe3d0; }
.nav svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; }
.nav span { flex: 1; }
.nav em { font-style: normal; font-size: 11px; background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; }
.nav:hover { background: rgba(255,255,255,.06); }
.nav.active { background: #2e5e33; color: #fff; }
.side-foot { padding: 12px 16px; font-size: 11px; color: #8fb393; border-top: 1px solid rgba(255,255,255,.08); }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.top-actions { display: flex; gap: 12px; align-items: center; }
.role-pick { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; }
.role-pick select { min-width: 190px; }
.menu-btn { display: none; }
.content { padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 16px; }

/* Controls */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: #c5cfc3; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #276b2b; }
.btn.danger { color: var(--warn); }
.btn.ghost { border-color: transparent; background: none; color: var(--brand); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.more { margin: 8px auto; display: flex; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 16px; padding: 6px 8px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--bg); }
select, input, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a5d6a7; border-color: var(--brand); }
.search { flex: 1; min-width: 200px; }
.mini { padding: 3px 6px; font-size: 13px; border-radius: 6px; }
.mini-num { width: 72px; padding: 4px 6px; }
.mini-num.wide { width: 130px; }

/* Cards & KPIs */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.card h3 small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.card .pad, .pad { padding: 14px 18px 0; }
.card.empty { text-align: center; color: var(--muted); padding: 32px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; border-top: 3px solid var(--brand); }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { font-size: 24px; }
.kpi small { font-size: 12px; color: var(--muted); }
.kpi.warn { border-top-color: var(--warn); }
.kpi.click { cursor: pointer; }
.kpi.on { outline: 2px solid var(--brand); }
.up { color: var(--brand); } .down { color: var(--warn); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.span2 { grid-column: span 2; }
.muted { color: var(--muted); }
.hint { margin: 0; padding: 10px 14px; background: var(--brand-2); border-radius: 8px; color: #2f4d32; font-size: 13px; }

/* Charts */
.vchart { display: flex; align-items: flex-end; gap: 3px; height: 160px; }
.vchart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.vchart .col i { display: block; width: 100%; background: #81c784; border-radius: 3px 3px 0 0; min-height: 2px; }
.vchart .col:hover i { background: var(--brand); }
.vchart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 40%) 1fr 64px; gap: 8px; align-items: center; font-size: 13px; }
.hbar .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { background: var(--bg); border-radius: 99px; height: 10px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.hbar .val { text-align: right; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
.table-wrap table { min-width: 760px; }
td small { min-width: 0; }
td:has(> small:only-child) { min-width: 120px; }
th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbf9; white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
td small { display: block; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7faf6; }
.r { text-align: right; }
.link { color: var(--brand); cursor: pointer; font-weight: 500; }
.warn-t { color: var(--warn); font-weight: 600; }
table.plain th { background: none; padding: 6px 8px; }
table.plain td { padding: 6px 8px; border: 0; vertical-align: middle; }

/* Badges */
.tier, .status, .tag, .ttype, .out, .sync, .pill { display: inline-block; font-size: 12px; border-radius: 99px; padding: 1px 9px; white-space: nowrap; }
.tier { font-weight: 600; }
.t-thuong { background: #eef1ee; color: #4b5a4d; }
.t-bac { background: #e9eef5; color: #475569; }
.t-vang { background: #fdf3d7; color: #8a5a00; }
.t-kimcuong { background: #e7f0ff; color: #1d4ed8; }
.tag { background: var(--brand-2); color: #2f5d33; margin: 3px 4px 0 0; }
.tag i { cursor: pointer; font-style: normal; margin-left: 2px; opacity: .6; }
.status, select.mini { background: #f1f3f0; }
.s-moi { background: #fff4d6 !important; color: #8a5a00; }
.s-xacnhan { background: #e6efff !important; color: #1e40af; }
.s-danggiao { background: #ecebff !important; color: #4338ca; }
.s-hoantat, .s-xong { background: #e3f4e4 !important; color: #23652a; }
.s-huy { background: #f3f3f3 !important; color: #777; }
.s-mo { background: #ffe8e0 !important; color: var(--warn); }
.s-dangxuly { background: #e6efff !important; color: #1e40af; }
.ttype { background: #f0f4ef; color: #3e5a41; }
.ttype.miss { background: var(--warn-bg); color: var(--warn); }
.out.o-win { background: #e3f4e4; color: #23652a; }
.out.o-later { background: #e6efff; color: #1e40af; }
.out.o-miss { background: var(--warn-bg); color: var(--warn); }
.out.o-no { background: #f1f1f1; color: #666; }
.out.o-ok { background: #f0f4ef; color: #3e5a41; }
.sync.ok { background: #e3f4e4; color: #23652a; }
.pill { background: #f1f3f0; color: var(--muted); }

/* Toolbar & tabs */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.count { color: var(--muted); font-size: 13px; margin-left: auto; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 14px; cursor: pointer; }
.tabs button em { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 2px; }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs button.on em { color: #d6ecd7; }
.tab-filter { margin-left: auto; }

/* Lists & tasks */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; }
.list li:hover { background: var(--bg); }
.list li span { color: var(--muted); font-size: 13px; }
.tasks { display: flex; flex-direction: column; gap: 8px; }
.task { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); display: flex; gap: 12px; padding: 12px 14px; border-left: 4px solid #a5d6a7; align-items: center; }
.card .task { box-shadow: none; border: 1px solid var(--line); border-left-width: 4px; }
.task.late { border-left-color: var(--warn); }
.task-main { flex: 1; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.task-main small { color: var(--muted); }
.task-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.task.late .when { color: var(--warn); font-weight: 600; }

/* Drawer & modal */
.overlay { position: fixed; inset: 0; background: rgba(15, 30, 15, .35); z-index: 20; }
.overlay.top { z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); z-index: 30; display: flex; flex-direction: column; box-shadow: -8px 0 32px rgba(0,0,0,.12); }
.drawer-head, .modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2, .modal-head h2 { margin: 0; font-size: 18px; }
.drawer-head small { color: var(--muted); }
.drawer-body { padding: 16px 20px 32px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.drawer-body h3 { margin: 6px 0 0; font-size: 15px; }
.mini-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mini-kpis div { background: var(--bg); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.mini-kpis span { font-size: 12px; color: var(--muted); }
.mini-kpis b { font-size: 16px; }
.mini-kpis small { font-size: 11px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.kv > span { color: var(--muted); }
.kv b { font-weight: 500; }
.tag-input { width: 90px; padding: 1px 8px; font-size: 12px; border-radius: 99px; margin-top: 3px; }
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; padding: 8px 0 8px 18px; border-left: 2px solid var(--line); margin-left: 4px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: #a5d6a7; }
.timeline small { color: var(--muted); }
.timeline .amt { position: absolute; right: 0; top: 8px; font-weight: 600; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.modal { position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 24px)); max-height: calc(100vh - 32px); background: var(--surface); border-radius: 14px; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-body { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-body h3 { margin: 4px 0 0; font-size: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; }
.field input, .field select, .field textarea { color: var(--ink); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.title-field { flex: 0 0 90px; }
.item-row { display: flex; gap: 6px; align-items: center; }
.item-row select { flex: 1; min-width: 0; }
.item-row .qty { width: 64px; }
.cust-pill { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--brand-2); border-radius: 10px; padding: 10px 12px; }
.cust-pill span { color: var(--muted); font-size: 13px; }
.cust-pill .btn { margin-left: auto; }
.newcust { display: flex; flex-direction: column; gap: 8px; }
.sum { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; background: var(--bg); padding: 12px 14px; border-radius: 10px; font-size: 13px; }
.sum b { text-align: right; }
.sum .total { font-size: 16px; font-weight: 700; color: var(--brand); }
.script { background: #fffaf0; border: 1px dashed #e6c88f; border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.script p { margin: 4px 0 0; }
.conns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.conn { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.conn p { margin: 0; color: var(--muted); font-size: 13px; flex: 1; }
.conn .pill { align-self: flex-start; }

/* Bán tại quầy */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.pos-left { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.chips, .pay-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); min-height: 104px; }
.tile:hover { border-color: var(--brand); }
.tile b { font-weight: 600; font-size: 13px; line-height: 1.35; flex: 1; }
.tile span { color: var(--brand); font-weight: 700; }
.tile small { color: var(--muted); font-size: 12px; }
.tile.out { opacity: .5; }
.pos-cart { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 10px; }
.pos-cart h3 { margin: 0; }
.cart { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; }
.cart-line { display: grid; grid-template-columns: 1fr auto 90px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.cart-line small { display: block; color: var(--muted); }
.qty-btns { display: flex; align-items: center; gap: 2px; }
.qty-btns span { min-width: 22px; text-align: center; font-weight: 600; }
.qty-btns .icon-btn { border: 1px solid var(--line); width: 28px; height: 28px; padding: 0; color: var(--ink); }
.change { flex: 1; padding-bottom: 8px; font-size: 14px; }
.btn.big { justify-content: center; padding: 12px; font-size: 15px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.item-row .cost { width: 110px; }

/* Hóa đơn & sổ sách */
.modal.wide { width: min(720px, calc(100% - 24px)); }
.inv-doc { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.inv-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.inv-top small { display: block; color: var(--muted); }
.inv-buyer, .inv-foot { margin: 0; font-size: 13px; }
.inv-foot { color: var(--muted); }
.inv-lines td, .inv-lines th { border-bottom: 1px solid var(--line) !important; }
.stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-12deg); border: 3px solid var(--warn); color: var(--warn); font-weight: 700; font-size: 28px; padding: 4px 18px; border-radius: 8px; opacity: .55; pointer-events: none; }
.struck { text-decoration: line-through; color: var(--muted); }
.total-row td { font-weight: 700; border-top: 1px solid var(--line) !important; }
.warn-hint { background: var(--warn-bg); color: var(--warn); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.checklist { margin: 0 0 10px; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
table.plain { margin-bottom: 10px; }
table.plain th { white-space: normal; }

/* Hộp thư */
.inbox { display: grid; grid-template-columns: 300px minmax(0, 1fr) 300px; gap: 12px; height: calc(100vh - 190px); min-height: 520px; }
.ib-list { overflow-y: auto; display: flex; flex-direction: column; }
.ib-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.ib-filters select { padding: 4px 8px; font-size: 13px; }
.ib-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.ib-item:hover { background: #f7faf4; }
.ib-item.on { background: var(--brand-2); }
.ib-meta { min-width: 0; display: flex; flex-direction: column; }
.ib-meta small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
.ib-time { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ib-time em { font-style: normal; background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 11px; }
.av { position: relative; width: 38px; height: 38px; border-radius: 50%; background: #dfe9d6; color: var(--brand); font-weight: 700; display: grid; place-items: center; }
.av .ch { position: absolute; right: -6px; bottom: -4px; }
.ch { font-size: 9px; font-weight: 700; color: #fff; border-radius: 4px; padding: 0 3px; }
.ch-zalo { background: #0068ff; } .ch-fb { background: #1877f2; }
.ib-chat { display: flex; flex-direction: column; min-height: 0; }
.ib-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ib-head small { display: block; color: var(--muted); font-size: 12px; }
.ib-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #f8faf6; }
.msg { max-width: 75%; display: flex; flex-direction: column; }
.msg p { margin: 0; padding: 8px 12px; border-radius: 14px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.msg small { font-size: 11px; color: var(--muted); margin: 2px 6px 0; }
.msg.nv { align-self: flex-end; align-items: flex-end; }
.msg.nv p { background: var(--brand); color: #fff; }
.ib-quick { display: flex; gap: 6px; padding: 8px 12px 0; overflow-x: auto; }
.ib-quick .chip { white-space: nowrap; font-size: 12px; }
.ib-compose { display: flex; gap: 8px; padding: 10px 12px; }
.ib-compose input { flex: 1; }
.ib-side { overflow-y: auto; }
.ib-cust { display: flex; flex-direction: column; gap: 6px; }
.ib-cust h4 { margin: 8px 0 0; font-size: 13px; }
.ib-cust small { color: var(--muted); }
.mini-kpis.two { grid-template-columns: 1fr 1fr; }
.mini-kpis.three { grid-template-columns: repeat(3, 1fr); }
.timeline.compact li { padding: 5px 0 5px 14px; font-size: 12px; }
.timeline.compact li::before { width: 8px; height: 8px; left: -5px; top: 10px; }
.timeline.compact .amt { top: 5px; }

/* Tổng đài */
.callbar { position: fixed; right: 20px; bottom: 20px; z-index: 55; background: #1c3810; color: #fff; border-radius: 14px; padding: 12px 14px; display: flex; gap: 14px; align-items: center; box-shadow: 0 12px 32px rgba(0,0,0,.3); max-width: calc(100% - 24px); }
.callbar.incoming { background: #0b5cd6; animation: ring 1s infinite alternate; }
@keyframes ring { from { box-shadow: 0 0 0 0 rgba(11,92,214,.5); } to { box-shadow: 0 0 0 10px rgba(11,92,214,0); } }
.cb-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cb-info small { color: #d6e8cc; font-size: 12px; }
.callbar .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.callbar .btn.primary { background: #22c55e; }
.btn.danger-fill, .callbar .btn.danger, .callbar .btn.danger-fill { background: #dc2626; border-color: #dc2626; color: #fff; }

/* Giá thành, sàn, phân quyền */
.cost-table td, .cost-table th { padding: 8px 10px; font-size: 13px; }
.cost-table { min-width: 1100px !important; }
table.bom select { max-width: 260px; }
.mp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.mp-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.mp-top { display: flex; gap: 10px; align-items: center; }
.mp-top div { flex: 1; } .mp-top small { display: block; color: var(--muted); font-size: 12px; }
.mp-logo { width: 36px; height: 36px; border-radius: 10px; color: #fff; font-weight: 700; display: grid; place-items: center; }
.pill.ok { background: #e3f4e4; color: #23652a; }
table.matrix td, table.matrix th { text-align: center; }
table.matrix td:first-child, table.matrix th:first-child { text-align: left; }
table.matrix tr.sep td { background: #fafbf9; text-align: left; }
.steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.step { display: flex; gap: 12px; }
.step > div { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: grid; place-items: center; flex: none; }
.step textarea { width: 100%; font-size: 13px; }
.task-side .row-btns { justify-content: flex-end; gap: 6px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: #173a1c; color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Mobile */
@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr; }
  .pos-cart { position: static; }
  .inbox { grid-template-columns: 260px minmax(0, 1fr); height: auto; }
  .ib-side { grid-column: span 2; }
  .ib-chat { min-height: 480px; }
}
@media (max-width: 760px) {
  .inbox { grid-template-columns: 1fr; }
  .ib-side { grid-column: auto; }
  .ib-list { max-height: 320px; }
  .callbar { left: 12px; right: 12px; bottom: 12px; flex-wrap: wrap; }
}
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
@media print {
  body * { visibility: hidden; }
  .modal, .modal * { visibility: visible; }
  .modal { position: absolute; inset: 0 auto auto 0; transform: none; width: 100%; max-height: none; box-shadow: none; }
  .modal-head, .modal-foot { display: none; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; z-index: 25; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .scrim.show { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 24; }
  .menu-btn { display: block; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .top-actions { width: 100%; justify-content: space-between; }
  .role-pick select { min-width: 0; max-width: 180px; }
  .content { padding: 16px 16px 40px; }
  .mini-kpis { grid-template-columns: repeat(2, 1fr); }
  .task { flex-direction: column; align-items: stretch; }
  .task-side { flex-direction: row; justify-content: space-between; align-items: center; }
  .tab-filter { margin-left: 0; }
}

/* ---------- Nhóm menu, cảnh báo, phân nhóm khách ---------- */
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #86a98a; padding: 12px 10px 4px; }
.nav-group:first-child { padding-top: 2px; }
.nav { padding: 7px 10px; }
.alerts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; }
.alerts > b { margin-right: 4px; }
.alert { border: 1px solid var(--line); background: #f6f8f4; border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.alert.warn { background: var(--warn-bg); border-color: #f5cfb6; color: var(--warn); }
.alert.bad { background: #fde8e8; border-color: #f3c0c0; color: #b42318; font-weight: 600; }
.seg { display: inline-block; font-size: 12px; border-radius: 99px; padding: 1px 9px; white-space: nowrap; }
.seg-g { background: #e3f4e4; color: #23652a; }
.seg-b { background: #e6efff; color: #1d4fb8; }
.seg-y { background: #fff4d6; color: #8a5a00; }
.seg-r { background: #fde8e8; color: #b42318; }
.seg-x { background: #eef0ed; color: #5b665d; }
.auto-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag.auto { background: #eef0ed; color: #4a564c; }
.hbar.click { cursor: pointer; border-radius: 6px; }
.hbar.click:hover { background: var(--bg); }
.grid2.inner { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.ok-t { color: #23652a; font-weight: 600; }
td small.ok-t, td small.muted, td small.ship-t { display: block; }
.ship-t { color: var(--info); font-size: 12px; }
.small-note { font-size: 12px; margin: 0; }

/* ---------- Lô hàng ---------- */
.lot { display: inline-block; font-size: 12px; border-radius: 99px; padding: 1px 9px; white-space: nowrap; }
.lot-ok { background: #e3f4e4; color: #23652a; }
.lot-near { background: #fff4d6; color: #8a5a00; }
.lot-expired { background: #fde8e8; color: #b42318; font-weight: 600; }
.lot-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 12px; margin: -2px 0 8px 4px; }
.lot-row input { padding: 2px 6px; font-size: 12px; }

/* ---------- Giao hàng ---------- */
.mp-logo.carrier { background: var(--info); }
.carrier-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.carrier-opt { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; text-align: left; }
.carrier-opt span { color: var(--muted); font-size: 13px; }
.carrier-opt.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-2); }
.label-doc { border: 2px dashed #222; border-radius: 6px; padding: 14px; display: flex; flex-direction: column; gap: 10px; max-width: 420px; margin: 0 auto; background: #fff; }
.lb-top { display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
.lb-code { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .05em; }
.lb-bars { display: flex; height: 48px; justify-content: center; }
.lb-bars i { background: #111; display: block; }
.lb-bars i.gap { width: 2px; background: none; }
.lb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-top: 1px solid #ddd; padding-top: 8px; }
.lb-row div { display: flex; flex-direction: column; }
.lb-row small { color: #555; }
.lb-cod { font-size: 20px; }

/* ---------- Công nợ, KPI ---------- */
.meter { background: var(--bg); border-radius: 99px; height: 8px; overflow: hidden; min-width: 70px; flex: 1; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.good i { background: var(--brand); }
.meter.over i { background: #b42318; }
.meter-cell { min-width: 120px; }
.meter-cell > .meter { display: inline-block; width: calc(100% - 44px); vertical-align: middle; }
.meter-cell > small { display: inline-block; width: 40px; text-align: right; color: var(--muted); }
td > .meter { display: block; }
tr.me-row td { background: #f3f9ec; }
.mine-kpi { border: 2px solid var(--brand-2); }

/* ---------- QR, tin nhắn sản phẩm ---------- */
.qr { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.qr small { font-size: 11px; color: var(--muted); text-align: center; }
.qr-fallback { width: 120px; height: 120px; display: grid; place-items: center; background: var(--bg); color: var(--muted); }
.qr-box { display: flex; gap: 12px; align-items: center; }
.qr-box p { font-size: 12px; }
.msg .qr { margin-top: 6px; }
.pcard { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 220px; }
.pcard img { width: 44px; height: 44px; object-fit: contain; background: var(--brand-2); border-radius: 8px; padding: 4px; }
.pcard div { display: flex; flex-direction: column; }
.pcard span { color: var(--brand); font-weight: 600; }
.pcard small { color: var(--muted); font-size: 11px; }
.chip-select { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 10px; font-size: 13px; max-width: 220px; }
.ad-src { display: block; color: #1d4fb8; font-size: 12px; }
.modal-body.center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.big-ok { font-size: 18px; }
@media (max-width: 760px) { .grid2.inner, .lb-row { grid-template-columns: 1fr; } }
@media print { .label-doc { border-color: #000; } }

/* ---------- Trùng đơn, đóng gói hàng loạt, danh mục ---------- */
.dup-box { border: 1px solid #f3c0c0; background: #fff5f5; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #7a1d1d; }
.dup-box ul { margin: 4px 0 6px; padding-left: 18px; }
.dup-box p { margin: 6px 0 2px; }
tr.off-row td { opacity: .55; }
.inline-field { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.toolbar.pad { padding: 12px 16px 0; }
.toolbar.pad h3 { margin: 0; flex: 1; }
.pick-doc { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
.pick-doc h3 { margin-top: 0; }
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.label-grid .label-doc { margin: 0; max-width: none; }
.chips small { opacity: .7; }
@media print { .label-grid .label-doc { break-inside: avoid; } .pick-doc { break-after: page; } }

/* ---------- Người nhận, chính sách đại lý, sơ đồ nhân sự, phiếu đóng gói ---------- */
.recipient { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.recipient h3 { margin: 0; font-size: 14px; }
.policy { background: #f3f7ff; border: 1px solid #d6e2fb; border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.policy ul { margin: 4px 0 6px; padding-left: 18px; }
.lvl { display: inline-block; font-size: 11px; border-radius: 99px; padding: 0 8px; margin-left: 4px; }
.lvl-leader { background: #e6efff; color: #1d4fb8; }
.lvl-truongphong { background: #fff1d6; color: #8a5a00; font-weight: 600; }
.org-tree, .org-tree ul { list-style: none; margin: 0; padding-left: 22px; }
.org-tree { padding-left: 0; }
.org-tree ul { border-left: 2px solid var(--line); margin-left: 10px; }
.org-tree li { margin: 6px 0; }
.org-node { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; background: var(--bg); border-radius: 10px; padding: 8px 12px; }
.org-node > div:first-child { flex: 1; min-width: 200px; }
.org-node.lv-truongphong { background: #fff8e8; }
.org-node.lv-leader { background: #f0f5ff; }
.org-num { display: flex; flex-direction: column; font-size: 12px; min-width: 90px; }
.org-num small { color: var(--muted); }
.pack-list { width: 100%; border-collapse: collapse; font-size: 13px; border-top: 1px solid #ddd; }
.pack-list td { padding: 3px 4px; border-bottom: 1px dashed #ddd; }
.pack-hint { font-size: 12px; background: #f6f6f6; border-radius: 6px; padding: 4px 8px; }

/* ---------- Chính sách, đơn sàn trong hàng chờ ---------- */
.scope-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; font-size: 13px; }
.scope-grid > div { display: flex; flex-direction: column; gap: 3px; background: var(--bg); border-radius: 10px; padding: 8px 10px; max-height: 220px; overflow: auto; }
.mp-tag { display: inline-block; background: #ee4d2d; color: #fff; border-radius: 4px; padding: 0 5px; font-size: 11px; }
@media (max-width: 760px) { .scope-grid { grid-template-columns: 1fr; } }

/* ---------- Trợ lý AI ---------- */
.ai-box { border-top: 1px solid var(--line); padding: 8px 12px; background: #f6f9ff; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.ai-box.need { background: #fff5f5; }
.ai-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-head .btn:first-of-type { margin-left: auto; }
.ai-suggest { background: #fff; border: 1px dashed #b9c9ee; border-radius: 8px; padding: 8px 10px; max-height: 140px; overflow: auto; }
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.mode-card { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.mode-card.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-2); }
.mode-card small { color: var(--muted); }
.desc-input { width: 100%; min-width: 260px; font-size: 12px; }
.ai-test .ib-msgs { min-height: 240px; max-height: 420px; }
.msg p { white-space: pre-line; }
.pill.kn-mo { background: #fdecea; color: #a12a1f; }
.pill.kn-dangxuly { background: #fff4dc; color: #8a5a00; }
.pill.kn-xong { background: #e3f4e4; color: #23652a; }

/* Hộp thư: câu mẫu, AI gợi ý */
.ib-compose textarea { flex: 1; resize: vertical; min-height: 38px; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.ib-quick { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; padding: 6px 10px; border-top: 1px solid var(--line); }
.ib-q { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 8px; font-size: 13px; cursor: pointer; }
.ib-q:hover { background: #f3f7ef; }
.ib-q small { display: block; color: var(--muted, #777); font-size: 11px; }
.ai-note { background: #f4f0ff; border: 1px solid #d9cdfb; border-radius: 8px; padding: 6px 10px; margin: 6px 10px; font-size: 13px; }
.ar-rule { display: grid; grid-template-columns: auto 1fr 2fr auto; gap: 8px; align-items: end; border-bottom: 1px dashed var(--line); padding: 6px 0; }
@media (max-width: 760px) { .ar-rule { grid-template-columns: 1fr; } }
/* Chăm sóc nhiều mốc */
.ttype.zalo { background: #e8f1ff; color: #1d4ed8; }
.step-row { padding: 10px 12px; margin-bottom: 10px; }
.step-row .form-row { align-items: flex-end; flex-wrap: wrap; gap: 8px; }
.step-no { min-width: 60px; padding-bottom: 8px; }
.step-row textarea { width: 100%; }
