/* Sữa Kids CRM — làm việc chủ yếu trên máy tính (bố cục kiểu Gà Võ), tông xanh dương. Điện thoại vẫn dùng được. */
:root {
  --blue: #1d6fe0;
  --blue-dark: #1158c2;
  --blue-deep: #0b3a82;
  --blue-soft: #e8f1fd;
  --blue-line: #c9dcf7;
  --side: #0d1d38;
  --side-2: #13284a;
  --side-text: #b9c7dd;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #13233d;
  --muted: #64748b;
  --line: #e3e9f2;
  --line-2: #eef2f8;
  --green: #12865a;
  --green-soft: #e1f5ec;
  --orange: #b45f00;
  --orange-soft: #fff2de;
  --red: #c62f3a;
  --red-soft: #fde7e9;
  --gray-soft: #eef1f5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 35, 63, .05);
  --side-w: 236px;
  --nav-h: 62px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ===== Khung: menu trái tối + thanh trên mỏng ===== */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--side); color: var(--side-text); padding: 14px 10px 12px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 10px; }
.sidebar .logo { width: 40px; height: 40px; border-radius: 11px; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 16px; flex: none; }
.sidebar .brand b { color: #fff; font-size: 16px; display: block; line-height: 1.2; }
.sidebar .brand small { font-size: 11.5px; opacity: .7; }
.sidebar .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .5; padding: 12px 12px 4px; }
.sidebar a {
  display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 8px 12px; border-radius: 9px;
  font-weight: 500; margin-bottom: 1px;
}
.sidebar a .ic { width: 18px; text-align: center; opacity: .9; }
.sidebar a:hover { background: var(--side-2); color: #fff; }
.sidebar a.on { background: var(--blue); color: #fff; }
.sidebar a .cnt { margin-left: auto; background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }
.sidebar a .cnt.blue { background: #3b82f6; }
.sidebar .grow { flex: 1; }
.sidebar .ver { font-size: 11px; opacity: .45; padding: 8px 12px 0; }

.topstrip {
  position: sticky; top: 0; z-index: 20; height: 44px; display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: #fff; border-bottom: 1px solid var(--line);
}
.topstrip .shop { font-weight: 600; color: var(--blue-dark); }
.topstrip .shop small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.topstrip .sp { flex: 1; }
.topstrip .who { font-size: 13px; color: var(--muted); }
.topstrip .who b { color: var(--text); }
.topstrip .back { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 0 4px; display: none; }
main { padding: 20px 28px 48px; min-width: 0; }

/* Đầu trang: tiêu đề trái, nút phải */
.ph { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.ph .t { flex: 1; min-width: 200px; }
.ph .crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.ph .crumb a { color: var(--muted); }

.bottomnav { display: none; }

/* ===== Thẻ, lưới ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card > .hd { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card > .hd h2 { flex: 1; }
.card.p0 { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 14px; }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.grid.main-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid.half { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.sticky { position: sticky; top: 60px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }
.neg { color: var(--red); font-weight: 700; }

/* KPI */
.kpi-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi-card .lb { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-card .vl { font-size: 22px; font-weight: 700; margin: 2px 0 4px; letter-spacing: -.01em; }
.kpi-card .sub { font-size: 11.5px; color: var(--muted); }
.delta { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 6px; }
.delta.up { background: var(--green-soft); color: var(--green); }
.delta.down { background: var(--red-soft); color: var(--red); }
.delta.flat { background: var(--gray-soft); color: var(--muted); }

/* Cần chú ý */
.attn { border-left: 4px solid var(--orange); }
.attn .it { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); color: var(--text); }
.attn .it:last-child { border-bottom: 0; }
.attn .it .dot { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.attn .it .dot.red { background: var(--red-soft); color: var(--red); }
.attn .it .dot.orange { background: var(--orange-soft); color: var(--orange); }
.attn .it .go { margin-left: auto; color: var(--muted); font-size: 12.5px; }

/* Biểu đồ cột */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .b i { display: block; width: 100%; max-width: 46px; background: linear-gradient(180deg, #4b93ef, var(--blue)); border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .b span { font-size: 10.5px; color: var(--muted); margin-bottom: 3px; white-space: nowrap; }
.bars-x { display: flex; gap: 6px; }
.bars-x span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); padding-top: 4px; min-width: 0; overflow: hidden; }

/* ===== Nút ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--text);
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--blue-line); color: var(--blue-dark); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); color: #fff; }
.btn.dark { background: var(--side); border-color: var(--side); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: #f2c2c6; color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--blue-dark); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { min-height: 46px; font-size: 15px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }

/* ===== Ô nhập ===== */
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.inp, select.inp, textarea.inp {
  width: 100%; min-height: 38px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 14px;
}
textarea.inp { min-height: 64px; resize: vertical; }
.inp:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 111, 224, .14); }
.inp.sm { min-height: 32px; padding: 4px 8px; font-size: 13.5px; }
input[type=date].inp { width: auto; }
.seg { display: inline-flex; background: var(--gray-soft); border-radius: 9px; padding: 3px; gap: 3px; }
.seg.full { display: flex; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 7px; min-height: 32px; padding: 0 12px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--blue-dark); box-shadow: 0 1px 3px rgba(16, 35, 63, .12); }
.search { position: relative; }
.search .inp { padding-left: 34px; }
.search::before { content: "⌕"; position: absolute; left: 11px; top: 6px; font-size: 18px; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.filters .search { flex: 1; min-width: 240px; }

/* Nhãn */
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--gray-soft); color: var(--muted); white-space: nowrap; }
.tag.cho_dong { background: var(--orange-soft); color: var(--orange); }
.tag.da_gui { background: var(--blue-soft); color: var(--blue-dark); }
.tag.da_giao { background: var(--green-soft); color: var(--green); }
.tag.hoan, .tag.huy { background: var(--red-soft); color: var(--red); }
.tag.loyal { background: #fdf0c4; color: #8a5a00; }
.tag.new { background: #ede9fe; color: #6d28d9; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 4px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--blue-line); }
.chip.on { background: var(--side); border-color: var(--side); color: #fff; }
.chip .n { background: var(--gray-soft); color: var(--muted); border-radius: 10px; padding: 0 6px; font-size: 11px; }
.chip.on .n { background: rgba(255,255,255,.18); color: #fff; }
.chip.out { opacity: .45; }
.chip.pick.on { background: var(--blue); border-color: var(--blue); }

/* ===== Bảng ===== */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafcff; white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f6f9ff; }
.tbl tr.day td { background: #f3f7fd; font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tbl tr.day td .muted { font-weight: 500; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl td.c, .tbl th.c { text-align: center; }
.tbl .code { font-weight: 700; color: var(--blue-dark); }
.tbl .sub { font-size: 12px; color: var(--muted); }
.tbl .clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tbl tr.off td { opacity: .5; }
.tbl-foot { padding: 10px 14px; font-size: 12.5px; color: var(--muted); }

/* Sản phẩm */
.thumb { background: var(--blue-soft) center/cover no-repeat; display: grid; place-items: center; color: var(--blue); font-weight: 700; width: 44px; height: 44px; border-radius: 9px; flex: none; font-size: 13px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.pc { border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; background: #fff; display: flex; gap: 10px; align-items: center; }
.pc:hover, .pc.on { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(29, 111, 224, .12); }
.pc .nm { font-weight: 600; font-size: 13px; line-height: 1.3; }
.vars { border: 1px dashed var(--blue-line); background: #f8fbff; border-radius: 10px; padding: 10px; margin-top: 10px; }
.stock-table { width: 100%; border-collapse: collapse; }
.stock-table th, .stock-table td { padding: 6px 6px; border-bottom: 1px solid var(--line-2); text-align: left; }
.stock-table th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.stock-table td.num, .stock-table th.num { text-align: center; width: 110px; }
.stock-table input { width: 80px; text-align: center; }

/* Tạo đơn */
.sec-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--blue-soft); color: var(--blue-dark); font-size: 12px; font-weight: 700; margin-right: 6px; }
.cart-tbl td { vertical-align: middle; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty button { width: 28px; height: 28px; border: 0; background: var(--gray-soft); font-size: 16px; cursor: pointer; }
.qty span { width: 30px; text-align: center; font-weight: 600; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.kv .k { color: var(--muted); }
.kv.big { font-size: 18px; font-weight: 700; padding-top: 6px; }
.kv.big span:last-child { color: var(--blue-dark); }
.hint { background: var(--blue-soft); color: var(--blue-deep); border-radius: 9px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }
.hint.warn { background: var(--orange-soft); color: var(--orange); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 10px 18px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.timeline li::after { content: ""; position: absolute; left: 6.5px; top: 17px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.qr { width: 100%; max-width: 240px; border-radius: 10px; display: block; margin: 6px auto; }

/* Đăng nhập */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(150deg, var(--side), var(--blue-deep) 55%, var(--blue)); }
.auth .box { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 26px 24px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.auth .logo { width: 52px; height: 52px; border-radius: 14px; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; margin-bottom: 12px; }
.auth h1 { margin-bottom: 4px; font-size: 22px; }
.auth p { color: var(--muted); margin: 0 0 16px; font-size: 13.5px; }
.auth .inp { min-height: 44px; font-size: 16px; }
.err { color: var(--red); font-size: 13px; min-height: 20px; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 99;
  background: var(--side); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--red); }

/* ===== Màn hẹp (điện thoại / máy tính bảng) ===== */
@media (max-width: 1280px) { .grid.kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .grid.main-side, .grid.half { grid-template-columns: 1fr; } .sticky { position: static; } }
@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .topstrip { padding: 0 14px; background: var(--blue); border: 0; color: #fff; padding-top: env(safe-area-inset-top); height: calc(48px + env(safe-area-inset-top)); }
  .topstrip .shop { color: #fff; }
  .topstrip .shop small, .topstrip .who { display: none; }
  .topstrip .back { display: block; color: #fff; }
  main { padding: 14px 14px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.k3 { grid-template-columns: 1fr; }
  .bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--line);
  }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 500; }
  .bottomnav a .ic { font-size: 19px; line-height: 1; }
  .bottomnav a.on { color: var(--blue); }
  .bottomnav a.plus .ic { width: 42px; height: 42px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 24px; margin-top: -16px; }
  .inp, select.inp, textarea.inp { font-size: 16px; min-height: 42px; }
  #toast { bottom: calc(var(--nav-h) + 16px); }
}

/* Phiếu in kèm hàng — khổ A6 */
.slip { display: none; }
@media print {
  @page { size: A6; margin: 6mm; }
  body { background: #fff; }
  .shell, .bottomnav, #toast { display: none !important; }
  .slip { display: block !important; font: 12px/1.4 Arial, sans-serif; color: #000; }
  .slip h2 { font-size: 15px; }
  .slip .cod { font-size: 18px; font-weight: 700; border: 2px solid #000; padding: 4px 8px; margin: 6px 0; display: inline-block; }
  .slip table { width: 100%; border-collapse: collapse; margin: 6px 0; }
  .slip td { border-bottom: 1px dashed #999; padding: 3px 0; }
}
