/* ============================================================
   DALI — styles.css  (giao diện làm mới 2026: font Inter, chiều sâu,
   bo góc & bóng mềm hiện đại — giữ nguyên toàn bộ tên class/cấu trúc)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Bảng màu thương hiệu DALI: xanh lá tươi + xanh lá đậm */
  --teal: #7cb342;        /* xanh lá DALI (nút chính, mục đang chọn) */
  --teal-d: #5a8e2e;      /* xanh lá đậm hơn khi hover */
  --teal-grad: linear-gradient(135deg, #8bc34a, #5a8e2e);
  --navy: #4a5d36;        /* xanh ô liu đậm (tiêu đề/logo) */
  --skyblue: #c5e1a5;     /* xanh lá nhạt */
  --orange: #f0b429;      /* nhấn phụ (vàng) */
  --bg: #f4f7ee;
  --card: #ffffff;
  --line: #e7eedd;
  --text: #2f3b27;
  --muted: #7b8568;
  --green: #27ae60;
  --red: #e74c3c;
  --blue: #3d9970;        /* dùng cho link & "text-blue" -> xanh lá */
  --sidebar: #ffffff;
  --brand-tint: #eef6e1;  /* nền nhạt cho mục đang chọn */

  /* Hệ thống bo góc */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  /* Hệ thống bóng đổ (soft, nhiều lớp) */
  --shadow-sm: 0 1px 2px rgba(47,59,39,.06);
  --shadow: 0 1px 3px rgba(47,59,39,.07), 0 1px 2px rgba(47,59,39,.05);
  --shadow-md: 0 6px 18px rgba(47,59,39,.09), 0 2px 6px rgba(47,59,39,.05);
  --shadow-lg: 0 16px 40px rgba(47,59,39,.16);
  --ring: 0 0 0 3px rgba(124,179,66,.20);

  --t-fast: .14s ease;
  --t: .2s ease;
}
html, body {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--blue); text-decoration: none; transition: color var(--t-fast); }
.hidden { display: none !important; }

/* Thanh cuộn mảnh, hiện đại */
* { scrollbar-width: thin; scrollbar-color: #cdd8bf transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #cfd9c1; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b6c5a1; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* Focus rõ ràng cho điều hướng bàn phím */
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---------- Hệ thống icon SVG ---------- */
svg.icon { width: 1.18em; height: 1.18em; display: inline-block; vertical-align: -.22em; flex: 0 0 auto; }
/* Icon trong menu trái */
.nav a.item .ic { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; font-size: 0; }
.nav a.item .ic svg.icon { width: 19px; height: 19px; vertical-align: 0; }
/* Icon đứng đầu tiêu đề thẻ — tô màu thương hiệu để tạo điểm nhấn */
.ic-inline { display: inline-flex; align-items: center; color: var(--teal-d); }
.ic-inline svg.icon { width: 19px; height: 19px; vertical-align: 0; }
body.dark .ic-inline { color: #a5d76e; }
.card-title.has-ic, .btn.has-ic { display: inline-flex; align-items: center; gap: 8px; }
.card-title.has-ic { display: flex; }
/* Icon trong badge KPI (nền màu, icon trắng) */
.ic-badge svg.icon { width: 20px; height: 20px; vertical-align: 0; }
/* Icon trong cảnh báo */
.alert-bar .a-ic { display: inline-flex; align-items: center; }
.alert-bar .a-ic svg.icon { width: 20px; height: 20px; vertical-align: 0; }
/* Icon thẻ KPI gradient (trang Phân tích) — trắng trên nền màu */
.kpi-fancy .kf-ic svg.icon { width: 24px; height: 24px; vertical-align: 0; }
/* Icon node sơ đồ quy trình — to & xanh thương hiệu */
.flow-node .flow-ic { color: var(--teal-d); line-height: 0; }
.flow-node.primary .flow-ic { color: var(--teal-d); }
.flow-node .flow-ic svg.icon { width: 30px; height: 30px; vertical-align: 0; }
body.dark .flow-node .flow-ic { color: #a5d76e; }
/* Icon trong nút */
.btn svg.icon { width: 16px; height: 16px; vertical-align: -.2em; }
.btn.sm svg.icon { width: 15px; height: 15px; }
#theme-toggle { display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px; }
#theme-toggle svg.icon { width: 17px; height: 17px; vertical-align: 0; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 234px; background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.brand {
  padding: 18px 16px 16px; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #f3f9ea, #ffffff);
}
.brand-logo { width: 190px; max-width: 100%; height: auto; display: block; }
.nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav .group-label {
  font-size: 11px; text-transform: uppercase; color: var(--muted);
  padding: 14px 20px 6px; letter-spacing: .6px; font-weight: 700;
}
.nav a.item {
  display: flex; align-items: center; gap: 11px;
  margin: 1px 10px; padding: 9px 12px; color: var(--text); font-size: 14px;
  border-radius: var(--radius-sm); position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav a.item .ic { width: 20px; text-align: center; font-size: 16px; opacity: .9; }
.nav a.item:hover { background: #f1f5ea; }
.nav a.item.active {
  background: var(--brand-tint); color: var(--teal-d); font-weight: 600;
}
.nav a.item.active::before {
  content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--teal); border-radius: 0 3px 3px 0;
}
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 58px; background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 22px; gap: 16px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.topbar h1 { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.topbar .spacer { flex: 1; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
  box-shadow: var(--shadow-sm);
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: #f3f6f9; border-color: #d8e2c9; }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--teal-grad); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(90,142,46,.28); }
.btn.primary:hover { filter: brightness(1.04); box-shadow: 0 4px 14px rgba(90,142,46,.34); }
.btn.orange { background: var(--orange); color: #fff; border-color: var(--orange); box-shadow: 0 2px 8px rgba(240,180,41,.3); }
.btn.orange:hover { filter: brightness(.96); }
.btn.danger { color: var(--red); border-color: #f3c2bd; }
.btn.danger:hover { background: #fdecea; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: #f1f5ea; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card .card-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; letter-spacing: -.1px; }
.grid { display: grid; gap: 18px; }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2,1fr); } }

/* KPI */
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  transition: box-shadow var(--t), transform var(--t);
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi .label { color: var(--muted); font-size: 13px; display:flex; align-items:center; gap:8px; font-weight: 500; }
.kpi .value { font-size: 25px; font-weight: 800; margin-top: 7px; letter-spacing: -.5px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi .ic-badge { width: 36px; height: 36px; border-radius: 10px; display:flex; align-items:center; justify-content:center; font-size:18px; color:#fff; box-shadow: var(--shadow-sm); }

/* Dashboard "tình hình tài chính" rows */
.fin-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.fin-row:last-child { border-bottom: none; }
.fin-row .k { color: var(--text); }
.fin-row .v { font-weight: 700; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-blue { color: var(--blue); }
.text-muted { color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--line); }
table.tbl th { background: #f4f7ee; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
table.tbl tbody tr { transition: background var(--t-fast); }
table.tbl tbody tr:hover { background: #f5f9ee; }
table.tbl tbody tr.row-sel, table.tbl tbody tr.row-sel:hover { background: #fff3d6; box-shadow: inset 3px 0 0 var(--teal); }
body.dark table.tbl tbody tr.row-sel { background: #3a3320; }
table.tbl td.num, table.tbl th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.tbl td.center, table.tbl th.center { text-align: center; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag.green { background: #e6f7ee; color: var(--green); }
.tag.red { background: #fdecea; color: var(--red); }
.tag.orange { background: #fef3e0; color: #c77f0a; }
.tag.gray { background: #eef1f4; color: var(--muted); }

/* Toolbar above tables */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
input.search, input.inp, select.inp, textarea.inp {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 11px; font-size: 14px;
  font-family: inherit; color: var(--text); background: #fff;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input.search { min-width: 240px; padding-left: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b8568' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center; background-size: 16px 16px; }
input.inp:focus, select.inp:focus, textarea.inp:focus, input.search:focus { outline: none; border-color: var(--teal); box-shadow: var(--ring); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(24,32,18,.5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 720px;
  box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.16,1,.3,1);
}
.modal.wide { max-width: 920px; }
@keyframes pop { from { transform: translateY(-12px) scale(.98); opacity: 0; } }
.modal .m-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal .m-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.modal .m-head .x { margin-left: auto; font-size: 22px; color: var(--muted); background: none; border: none; line-height: 1; border-radius: 6px; padding: 2px 6px; transition: background var(--t-fast), color var(--t-fast); }
.modal .m-head .x:hover { background: #f1f5ea; color: var(--text); }
.modal .m-body { padding: 22px; }
.modal .m-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; font-size: 14px; font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--teal); box-shadow: var(--ring); }
.req { color: var(--red); }

/* Line items table in invoice form */
.items-tbl { width: 100%; border-collapse: collapse; margin-top: 6px; }
.items-tbl th, .items-tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.items-tbl th { background: #f4f7ee; color: var(--muted); text-align: left; }
.items-tbl input, .items-tbl select { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.items-tbl td.num { text-align: right; }
/* Ẩn nút tăng/giảm (spinner) của ô số — tránh bấm/lăn chuột làm sai số lượng */
input.no-spin::-webkit-outer-spin-button, input.no-spin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.no-spin { -moz-appearance: textfield; appearance: textfield; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #2c3a47; color: #fff; padding: 12px 22px; border-radius: var(--radius-sm);
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 200; font-size: 14px;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #1f9d57; }
.toast.error { background: var(--red); }

/* Bars (mini chart) */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 60%; background: linear-gradient(var(--teal), #aed581); border-radius: 6px 6px 0 0; min-height: 2px; position: relative; transition: height .3s ease; }
.bars .bar .val { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.bars .bar-col .lbl { font-size: 11px; color: var(--muted); }

/* Sơ đồ quy trình bán hàng */
.flow-grid { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; justify-content: center; padding: 10px 0; }
.flow-node {
  flex: 1 1 130px; min-width: 120px; max-width: 170px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 10px; text-align: center;
  background: #fbfdfd; transition: all .15s; box-shadow: var(--shadow-sm);
}
.flow-node:hover { border-color: var(--teal); box-shadow: 0 8px 20px rgba(90,142,46,.18); transform: translateY(-3px); }
.flow-node.primary { background: var(--brand-tint); border-color: var(--teal); }
.flow-node .flow-ic { font-size: 30px; }
.flow-node .flow-lbl { font-size: 13px; margin-top: 8px; font-weight: 600; color: var(--text); }
.flow-arrow { display: flex; align-items: center; color: #b6c2cd; font-size: 22px; }
@media (max-width: 900px) { .flow-arrow { display: none; } }
.rep-link { display: block; padding: 11px 4px; border-bottom: 1px dashed var(--line); color: var(--text); transition: color var(--t-fast), padding var(--t-fast); }
.rep-link:hover { color: var(--teal-d); padding-left: 4px; }

/* Biểu đồ cột */
.col-chart { display: flex; align-items: flex-end; gap: 12px; height: 220px; padding: 10px 0; }
.col-group { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.col-bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.col-bar { width: 14px; border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s; }
.col-lbl { font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend { display: flex; gap: 18px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* Thanh xếp hạng */
.rank { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.rank-row { display: flex; align-items: center; gap: 10px; }
.rank-label { width: 150px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.rank-track { flex: 1; background: #eef1f4; border-radius: 8px; height: 16px; overflow: hidden; }
.rank-fill { height: 100%; border-radius: 8px; min-width: 2px; transition: width .4s ease; }
.rank-val { width: 110px; text-align: right; font-size: 13px; font-weight: 600; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* Thanh tuổi nợ */
.aging-bar { width: 100%; height: 14px; background: #e6f7ee; border-radius: 7px; overflow: hidden; }
.aging-fill { height: 100%; border-radius: 7px 0 0 7px; min-width: 0; transition: width .4s ease; }

/* Banner thương hiệu */
.hero-banner { width: 100%; height: auto; display: block; border-radius: var(--radius-lg); margin-bottom: 18px;
  box-shadow: var(--shadow-md); }

/* Thẻ KPI gradient (trang Phân tích) */
.kpi-fancy { border-radius: var(--radius-lg); padding: 18px 20px; color: #fff; box-shadow: var(--shadow-md);
  position: relative; overflow: hidden; transition: transform var(--t), box-shadow var(--t); }
.kpi-fancy:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-fancy .kf-top { display: flex; justify-content: space-between; align-items: center; }
.kpi-fancy .kf-label { font-size: 13px; opacity: .96; font-weight: 600; letter-spacing: .3px; }
.kpi-fancy .kf-ic { font-size: 22px; opacity: .92; }
.kpi-fancy .kf-value { font-size: 26px; font-weight: 800; margin: 10px 0 8px; letter-spacing: .3px; }
.kpi-fancy .kf-trend { font-size: 12px; }
.trend { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.22);
  padding: 3px 10px; border-radius: 20px; font-weight: 700; }
.trend.down { background: rgba(0,0,0,.16); }

/* Cảnh báo tồn kho trên dashboard */
.alert-bar { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: var(--radius);
  background: #fff6e5; border: 1px solid #f3d79b; color: #8a5a00; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
body.dark .alert-bar { background: #2e2812; border-color: #5a4a1e; color: #e0c97a; }
.alert-bar .a-ic { font-size: 20px; }
.alert-bar a { margin-left: auto; font-weight: 700; }

/* Trang Danh mục (hub) */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px 32px; margin-top: 8px; }
@media (max-width: 900px) { .cat-grid { grid-template-columns: 1fr 1fr; } }
.cat-group-title { font-weight: 700; color: var(--navy); border-bottom: 2px solid var(--brand-tint); padding-bottom: 6px; margin-bottom: 8px; }
.cat-link { display: block; padding: 7px 0 7px 14px; color: var(--blue); position: relative; transition: color var(--t-fast), padding var(--t-fast); }
.cat-link:before { content: '•'; position: absolute; left: 0; color: var(--skyblue); }
.cat-link:hover { color: var(--teal-d); padding-left: 18px; }

/* Tabs trong form */
.tabs { margin-top: 18px; }
.tab-nav { display: flex; gap: 2px; border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.tab-btn { border: none; background: none; padding: 9px 16px; font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; font-weight: 600; transition: color var(--t-fast), border-color var(--t-fast); }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--teal-d); border-bottom-color: var(--teal); }
.tab-panel { padding-top: 16px; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); cursor: pointer; }
.radio input { width: auto; margin: 0; }

/* Phân trang */
.pager { display: flex; align-items: center; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pager .spacer { flex: 1; }
.pager .btn.sm { min-width: 32px; justify-content: center; }

/* Thanh người dùng + đăng nhập */
.userbar { display: flex; align-items: center; gap: 10px; }
.userbar.hidden { display: none; }
.userbar-name { font-size: 13px; }
.userbar-role { color: var(--muted); }
/* Thanh chọn cơ sở kinh doanh (đa cơ sở) */
.workspacebar { display: flex; align-items: center; gap: 6px; margin-right: 4px; }
.workspacebar.hidden { display: none; }
.workspacebar .ws-ico { font-size: 15px; line-height: 1; }
.ws-select { font-size: 13px; font-weight: 600; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--card); color: var(--text); max-width: 190px; cursor: pointer; }
.ws-select:hover { border-color: var(--brand); }
body.login-mode .app { filter: blur(2px); pointer-events: none; }
.login-overlay { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #d8edbf, #eef7e0); padding: 20px; }
.login-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 32px 32px; width: 100%; max-width: 380px; }
.login-logo { width: 200px; max-width: 80%; display: block; margin: 0 auto 4px; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 18px; font-size: 13px; }
.login-err { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0; }

.empty { text-align: center; padding: 44px; color: var(--muted); }
.right { text-align: right; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; }
.pill-row { display:flex; gap:8px; flex-wrap: wrap; }
.section-sub { font-size:13px; color: var(--muted); margin-bottom: 10px; }
@media print {
  .sidebar, .topbar, .toolbar, .btn { display: none !important; }
  .content { padding: 0; overflow: visible; }
  .card { border: none; box-shadow: none; }
}

/* ====================== CHỌN TÍNH CHẤT HÀNG HÓA (như MISA) ====================== */
.kind-list { display: flex; flex-direction: column; }
.kind-row { display: flex; align-items: center; gap: 14px; padding: 12px 10px; border-bottom: 1px solid var(--line);
  cursor: pointer; border-radius: 8px; transition: background var(--t-fast); }
.kind-row:hover { background: var(--brand-tint); }
.kind-row:last-child { border-bottom: none; }
.kind-ic { width: 44px; height: 44px; border-radius: 10px; background: var(--brand-tint); color: var(--teal-d);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kind-ic svg.icon { width: 24px; height: 24px; }
.kind-ic.sm { width: 26px; height: 26px; border-radius: 7px; }
.kind-ic.sm svg.icon { width: 16px; height: 16px; }
.kind-title { font-weight: 600; }
.kind-desc { font-size: 12.5px; color: var(--muted); }
.qa-kind { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 10px;
  background: var(--brand-tint); border-radius: 8px; font-size: 13px; }
body.dark .kind-ic, body.dark .qa-kind { background: #2e3b22; }

/* ====================== BỘ CHỌN HÀNG HÓA (tìm kiếm) ====================== */
.pp-wrap { position: relative; flex: 1; min-width: 0; }
.pp-btn { width: 100%; text-align: left; background: #fff; cursor: pointer; display: flex; align-items: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-btn.pp-empty { color: var(--muted); }
.pp-panel { position: fixed; z-index: 150; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 360px; }
.pp-top { padding: 8px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.pp-top .inp { flex: 1; }
.pp-only { font-size: 12px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.pp-only input { width: auto; margin: 0; }
.pp-head, .pp-row { display: grid; grid-template-columns: 96px 1fr 64px 92px; gap: 8px; align-items: center; padding: 6px 10px; font-size: 13px; }
.pp-head { background: #f4f7ee; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: .3px; }
.pp-list { overflow-y: auto; }
.pp-row { cursor: pointer; border-bottom: 1px solid var(--line); }
.pp-row:hover, .pp-row.pp-active { background: var(--brand-tint); }
.pp-code { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-stock { text-align: right; color: var(--muted); }
.pp-price { text-align: right; }
.pp-foot button { width: 100%; border: none; border-top: 1px solid var(--line); background: none; padding: 10px;
  color: var(--teal-d); font-weight: 600; cursor: pointer; text-align: left; }
.pp-foot button:hover { background: var(--brand-tint); }
.pp-empty-row { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }
body.dark .pp-btn { background: #1b2214; }
body.dark .pp-head { background: #2a3320; }

/* ====================== VIỆC CẦN LÀM (Action Center) ====================== */
.todo-hero-ic { width: 52px; height: 52px; border-radius: 14px; background: var(--teal-grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow-md); flex-shrink: 0; }
.todo-gic { display: inline-flex; align-items: center; color: var(--teal-d); }
.todo-gic svg.icon { width: 18px; height: 18px; }
body.dark .todo-gic { color: #a5d76e; }
.todo-list { display: flex; flex-direction: column; }
.todo-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.todo-row:last-child { border-bottom: none; }
.todo-main { flex: 1; min-width: 0; }
.todo-text { font-size: 14px; display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.todo-text.urgent { font-weight: 600; }
.todo-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.todo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex-shrink: 0; display: inline-block; }

/* ====================== TRỢ LÝ AI (chat nổi) ====================== */
#ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 90;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--teal-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(90,142,46,.4); transition: transform var(--t), box-shadow var(--t);
}
#ai-fab svg.icon { width: 26px; height: 26px; }
#ai-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 10px 26px rgba(90,142,46,.5); }
#ai-panel {
  position: fixed; right: 22px; bottom: 86px; z-index: 95;
  width: 400px; max-width: calc(100vw - 32px); height: min(640px, calc(100vh - 120px));
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
  animation: pop .18s cubic-bezier(.16,1,.3,1);
}
.ai-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); background: var(--brand-tint); }
.ai-head-ic { display: inline-flex; color: var(--teal-d); }
.ai-head-ic svg.icon { width: 20px; height: 20px; }
.ai-head-sub { font-size: 12px; color: var(--muted); }
.ai-hbtn { border: none; background: none; color: var(--muted); padding: 4px 6px;
  border-radius: 6px; display: inline-flex; }
.ai-hbtn:hover { background: rgba(0,0,0,.06); color: var(--text); }
.ai-hbtn svg.icon { width: 16px; height: 16px; }
.ai-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 86%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.5;
  word-break: break-word; }
.ai-msg.me { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: #f1f5ea; color: var(--text); border-bottom-left-radius: 4px; }
.ai-msg code { background: rgba(0,0,0,.08); border-radius: 4px; padding: 0 4px; font-size: 12.5px; }
.ai-msg .ai-li { display: block; padding-left: 6px; }
.ai-thinking { color: var(--muted); font-style: italic; animation: aiPulse 1.2s ease infinite; }
@keyframes aiPulse { 50% { opacity: .45; } }
.ai-tool-note { align-self: flex-start; font-size: 11.5px; color: var(--muted); padding: 0 6px; }
/* Bảng lịch sử các đoạn chat */
#ai-history { border-bottom: 1px solid var(--line); max-height: 45%; overflow-y: auto; background: var(--card); }
.ai-h-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .4px; padding: 10px 14px 4px; }
.ai-h-empty { padding: 8px 14px 12px; font-size: 13px; color: var(--muted); }
.ai-h-row { display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 14px; cursor: pointer;
  border-left: 3px solid transparent; transition: background var(--t-fast); }
.ai-h-row:hover { background: var(--brand-tint); }
.ai-h-row.cur { border-left-color: var(--teal); background: var(--brand-tint); }
.ai-h-main { flex: 1; min-width: 0; }
.ai-h-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-h-date { font-size: 11px; color: var(--muted); }
body.dark .ai-h-row:hover, body.dark .ai-h-row.cur { background: #2e3b22; }

.ai-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.ai-chip { border: 1px solid var(--line); background: #fff; color: var(--teal-d);
  border-radius: 16px; padding: 6px 12px; font-size: 12.5px; transition: background var(--t-fast); }
.ai-chip:hover { background: var(--brand-tint); }
.ai-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: flex-end; }
#ai-input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  font-size: 13.5px; font-family: inherit; resize: none; max-height: 90px; }
#ai-input:focus { outline: none; border-color: var(--teal); box-shadow: var(--ring); }
.ai-send { width: 38px; height: 38px; border-radius: 10px; border: none; background: var(--teal-grad);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ai-send svg.icon { width: 17px; height: 17px; }
.ai-send:hover { filter: brightness(1.05); }
@media (max-width: 600px) {
  #ai-panel { right: 8px; left: 8px; width: auto; bottom: 80px; height: calc(100vh - 100px); }
}
@media print { #ai-fab, #ai-panel { display: none !important; } }

/* ====================== CHẾ ĐỘ TỐI ====================== */
body.dark {
  --bg: #161b11; --card: #212a1a; --line: #333d27; --text: #e4e9d8;
  --muted: #9aa589; --sidebar: #1c2315; --brand-tint: #2e3b22;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 1px 3px rgba(0,0,0,.35);
  --shadow-md: 0 6px 18px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
  scrollbar-color: #3b452c transparent;
}
body.dark *::-webkit-scrollbar-thumb { background: #3b452c; background-clip: content-box; }
body.dark .topbar, body.dark .sidebar, body.dark .brand { background: var(--sidebar); }
body.dark .topbar { background: rgba(28,35,21,.85); }
body.dark .card, body.dark .kpi, body.dark .modal, body.dark .login-card { background: var(--card); }
body.dark table.tbl th { background: #2a3320; color: #aab695; }
body.dark table.tbl tbody tr:hover { background: #29331f; }
body.dark .btn { background: #2a3320; color: var(--text); border-color: #3b452c; }
body.dark .btn:hover { background: #333e26; }
body.dark .btn.primary { background: var(--teal-grad); color: #16210c; border-color: transparent; }
body.dark .btn.ghost { background: transparent; }
body.dark .btn.ghost:hover { background: #29331f; }
body.dark input, body.dark select, body.dark textarea,
body.dark .field input, body.dark .field select, body.dark .field textarea,
body.dark input.inp, body.dark select.inp, body.dark textarea.inp, body.dark input.search,
body.dark .items-tbl input, body.dark .items-tbl select {
  background-color: #1b2214; color: var(--text); border-color: #3b452c;
}
body.dark .nav a.item { color: var(--text); }
body.dark .nav a.item:hover { background: #29331f; }
body.dark .modal .m-head, body.dark .modal .m-foot, body.dark .topbar { border-color: var(--line); }
body.dark .modal .m-head .x:hover { background: #29331f; }
body.dark .tag.gray { background: #313b26; color: #aab695; }
body.dark .rank-track, body.dark .aging-bar { background: #313b26; }
body.dark .col-chart .col-bar { opacity: .92; }
body.dark .login-overlay { background: linear-gradient(135deg, #1d2614, #11160d); }
body.dark table.tbl th { text-transform: uppercase; }
body.dark .ai-head { background: #2a3320; }
body.dark .ai-msg.bot { background: #2a3320; }
body.dark .ai-chip { background: #1b2214; }
body.dark .ai-chip:hover { background: #2e3b22; }
body.dark #ai-input { background: #1b2214; color: var(--text); border-color: #3b452c; }
body.dark .ai-hbtn:hover { background: rgba(255,255,255,.08); }

/* ====================== RESPONSIVE ĐIỆN THOẠI ====================== */
.menu-toggle { display: none; background: none; border: none; font-size: 22px; color: var(--text); padding: 4px 8px; margin-right: 4px; }
.menu-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
@media (max-width: 820px) {
  .menu-toggle { display: inline-flex; align-items: center; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 50;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .menu-backdrop.show { display: block; }
  #company-name { display: none; }
  .topbar { padding: 0 12px; }
  .topbar h1 { font-size: 16px; }
  .content { padding: 16px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  .modal, .modal.wide { max-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .userbar-name { display: none; }
}

/* ====================== TỐI ƯU CHO ĐIỆN THOẠI (≤560px) ====================== */
@media (max-width: 560px) {
  .content { padding: 12px; }
  .card { padding: 14px; border-radius: var(--radius-md); }

  /* Vùng chạm to hơn cho ngón tay */
  .btn { padding: 10px 14px; font-size: 14px; min-height: 42px; }
  .btn.sm { padding: 7px 11px; min-height: 36px; font-size: 13px; }
  .field input, .field select, .field textarea,
  input.inp, select.inp, textarea.inp, input.search { min-height: 44px; font-size: 16px; } /* 16px: iOS không tự zoom */

  /* Thanh công cụ: ô tìm full dòng, nút tạo mới trải rộng */
  .toolbar { gap: 8px; }
  .toolbar .search, .toolbar input { flex: 1 1 100%; }
  .toolbar .field { flex: 1 1 100%; margin: 0; }   /* mỗi ô lọc xuống dòng full trên điện thoại */
  .toolbar .field select, .toolbar .field input { width: 100%; }
  .toolbar .spacer { display: none; }
  .toolbar .btn.primary { flex: 1 1 100%; justify-content: center; }

  /* Danh sách dạng BẢNG -> THẺ xếp dọc (dễ đọc, hết kéo ngang) */
  .tbl-cards { font-size: 14px; }
  .tbl-cards thead { display: none; }
  .tbl-cards, .tbl-cards tbody { display: block; width: 100%; }
  .tbl-cards tr { display: block; border: 1px solid var(--line); border-radius: 12px;
    padding: 6px 12px; margin-bottom: 10px; background: var(--card); box-shadow: var(--shadow-sm); }
  .tbl-cards tbody tr:hover { background: var(--card); }
  .tbl-cards td { display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: 7px 0; border: none; border-bottom: 1px dashed var(--line); text-align: right; white-space: normal; }
  .tbl-cards tr td:last-child { border-bottom: none; }
  .tbl-cards td::before { content: attr(data-label); font-weight: 600; color: var(--muted);
    font-size: 11px; text-transform: uppercase; letter-spacing: .3px; text-align: left; flex-shrink: 0; }
  .tbl-cards td.num { font-weight: 600; }
  /* Ô không nhãn (cột nút thao tác, checkbox) -> trải cả dòng, ẩn nhãn */
  .tbl-cards td[data-label=""] { padding-top: 8px; }
  .tbl-cards td[data-label=""]::before { display: none; }
  .tbl-cards td[data-label=""] .pill-row { width: 100%; }
  .tbl-cards td[data-label=""] .pill-row .btn { flex: 1; min-width: 0; }
  /* Dòng "chưa có dữ liệu" (colspan) */
  .tbl-cards td[colspan] { justify-content: center; text-align: center; }
  .tbl-cards td[colspan]::before { display: none; }

  /* Modal = tấm trượt gần full màn hình, nút đáy dính */
  .modal-back { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { width: 100%; max-width: 100%; max-height: 96vh; height: auto;
    border-radius: 18px 18px 0 0; display: flex; flex-direction: column; }
  .modal .m-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
  .modal .m-head { padding: 14px 16px; }
  .modal .m-foot { padding: 12px 16px; position: sticky; bottom: 0; background: var(--card); }
  .modal .m-foot .btn { flex: 1; justify-content: center; }

  /* Bảng nhập dòng hàng trong chứng từ: thu gọn padding */
  .items-tbl th, .items-tbl td { padding: 6px 5px; }

  /* Hero banner thấp lại cho gọn */
  .hero-banner img, .hero-banner svg { max-height: 120px; }

  /* Biểu đồ cột: cuộn ngang gọn trong thẻ thay vì tràn/ép bẹp */
  .col-chart { height: 175px; gap: 7px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .col-chart .col-group { min-width: 30px; }

  /* Thanh xếp hạng (top hàng/khách): thu nhãn + số cho vừa màn */
  .rank-label { width: 92px; font-size: 12px; }
  .rank-val { width: 76px; font-size: 12px; }

  /* Bảng nhập dòng hàng: cho phép cuộn ngang mượt, ô nhỏ gọn */
  .items-tbl input, .items-tbl select { font-size: 13px; padding: 8px 6px; }

  /* Biểu đồ tròn: căn giữa cho cân đối */
  .donut { justify-content: center; }
}

/* ====================== BẢNG PHÍM TẮT (B4) ====================== */
.kbd-help-back { position: fixed; inset: 0; z-index: 160; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; }
.kbd-help { background: var(--card, #fff); color: var(--text, #222); width: 380px; max-width: 92vw;
  border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.3); overflow: hidden; }
.kbd-help-head { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line, #e6e9ed); font-size: 15px; }
.kbd-help-head .x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text, #222);
  width: 30px; height: 30px; border-radius: 8px; }
.kbd-help-head .x:hover { background: rgba(0,0,0,.06); }
.kbd-help-body { padding: 8px 16px 16px; }
.kbd-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.kbd-row kbd { flex-shrink: 0; min-width: 92px; text-align: center; font-family: inherit; font-size: 12px;
  font-weight: 700; padding: 4px 8px; border-radius: 7px; background: #eef2f6; border: 1px solid #d4dae1;
  box-shadow: 0 1px 0 #c7ced6; color: #2b3a2f; }
.kbd-row span { font-size: 13px; color: var(--muted, #6b7785); }
body.dark .kbd-help { background: #1f2817; }
body.dark .kbd-help-head .x:hover { background: #29331f; }
body.dark .kbd-row kbd { background: #2a3320; border-color: #3b452c; box-shadow: 0 1px 0 #161d10; color: #d6e0c6; }
