:root {
  --ink: #1b2a26;
  --muted: #5e6e69;
  --ground: #f3f6f4;
  --surface: #ffffff;
  --line: #d9e2de;
  --line-strong: #b9c8c2;
  --accent: #0e7c6b;
  --accent-ink: #0a5c50;
  --accent-soft: #ddf1ec;
  --warn: #b7791f;
  --warn-soft: #fbf1dc;
  --danger: #b93a2c;
  --danger-soft: #fae3df;
  --ok: #2e7d5b;
  --ok-soft: #dff2e8;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(27, 42, 38, 0.14);
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
}
h1, h2, h3 { margin: 0; text-wrap: balance; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
/* Tiền dùng dấu cách ngăn hàng nghìn nên phải cấm xuống dòng giữa số. */
.num-strong, .stat .value, .wallet-balance, .total-lines strong { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 6px;
  background: var(--accent); color: #fff;
  font-family: var(--mono); font-weight: 500; font-size: 13px;
  align-self: center;
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted); }
.nav { display: flex; gap: 4px; }
.nav a {
  white-space: nowrap;
  text-decoration: none; color: var(--ink);
  padding: 6px 12px; border-radius: 6px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav a:hover { background: var(--ground); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.unit-note { color: var(--muted); font-size: 12.5px; }
.link { font-size: 12.5px; }

/* ---------- Page ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 240px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.stat .eyebrow { margin-bottom: 4px; }
.stat .value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .value.warn { color: var(--warn); }
.stat .value.danger { color: var(--danger); }
.stat .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Controls ---------- */
input[type="text"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  height: 36px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
  min-width: 0;
}
textarea { height: auto; padding: 8px 10px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
.btn {
  height: 36px; padding: 0 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--ground); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg button { height: 34px; padding: 0 12px; border: 0; background: var(--surface); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* ---------- Forms ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.field.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .field.span-2 { grid-column: auto; } }
details.sub { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 12px; }
details.sub summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--ground); }
td.name { font-weight: 500; }
td.name .sub { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
tr.expired td { color: var(--muted); }
tr.expired td.name, tr.expired td .chip { color: inherit; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--ground); color: var(--muted);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--accent-soft); color: var(--accent-ink); }
.qty-pos { color: var(--ok); font-weight: 600; }
.qty-neg { color: var(--danger); font-weight: 600; }

/* ---------- Drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(27, 42, 38, 0.35); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(720px, 100%);
  background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 24px 14px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 20px 24px; overflow: auto; display: flex; flex-direction: column; gap: 20px; }
.drawer-body .table-wrap { border-radius: 6px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.inline-form .field { min-width: 120px; }
.note { background: var(--accent-soft); color: var(--accent-ink); border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.danger { background: var(--danger-soft); color: var(--danger); }
.alloc { margin: 8px 0 0; padding-left: 18px; }

/* ---------- Alerts page ---------- */
.alert-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.alert-section h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.alert-section h2 .count { font-size: 13px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.alert-section.danger h2 .count { background: var(--danger-soft); color: var(--danger); }
.alert-section.warn h2 .count { background: var(--warn-soft); color: var(--warn); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 6px;
  box-shadow: var(--shadow); max-width: 420px; font-size: 13px;
  animation: rise 160ms ease-out;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--accent-ink); }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .topbar-right { display: none; }
  .page { padding: 16px; }
}

/* ---------- Bổ sung: nav nhóm, thanh hạn mức, bảng thông tin ---------- */
.nav { flex-wrap: wrap; align-items: center; }
.nav-group {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); padding: 0 4px 0 12px;
}
.nav-group:first-child { padding-left: 0; }
.drawer-panel.narrow { width: min(600px, 100%); }
label.check { display: inline-flex; align-items: center; gap: 8px; height: 36px; font-weight: 500; color: var(--ink); cursor: pointer; }
label.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.bar.warn > i { background: var(--warn); }
.bar.danger > i { background: var(--danger); }
.limit-cell { display: flex; flex-direction: column; gap: 2px; }
.limit-cell .bar { margin-top: 0; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.dl dt { color: var(--muted); font-size: 12.5px; font-weight: 600; padding-top: 1px; }
.dl dd { margin: 0; }
.stat .bar { margin-top: 8px; }

/* ---------- Bán hàng ---------- */
.order-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.order-main { display: flex; flex-direction: column; gap: 16px; }
.order-side { position: sticky; top: 72px; }
@media (max-width: 1000px) { .order-grid { grid-template-columns: 1fr; } .order-side { position: static; } }
.cust-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.num-strong { font-weight: 600; font-variant-numeric: tabular-nums; }
table.items td input { height: 30px; padding: 0 8px; }
table.items input.edited { border-color: var(--accent); }
tr.row-bad td { background: var(--danger-soft); }
tfoot td { border-top: 2px solid var(--line-strong); border-bottom: 0; font-variant-numeric: tabular-nums; }
.total-lines { display: flex; flex-direction: column; gap: 6px; }
.total-lines > div { display: flex; justify-content: space-between; align-items: baseline; }
.total-lines strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.radio-group { display: flex; gap: 6px; flex-wrap: wrap; }
.radio-group label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 6px; cursor: pointer; }
.radio-group label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.radio-group input { accent-color: var(--accent); }
.approve { margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--warn); border-radius: 6px; display: flex; flex-direction: column; gap: 8px; background: var(--warn-soft); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- In phiếu xuất ---------- */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  body { background: #fff; }
  #print-area { display: block; color: #000; font-size: 12px; line-height: 1.4; padding: 10mm; }
  .inv h1 { text-align: center; font-size: 18px; margin: 14px 0 12px; letter-spacing: 0.04em; }
  .inv-head { display: flex; justify-content: space-between; gap: 20px; }
  .inv-meta { text-align: right; }
  .inv table { width: 100%; border-collapse: collapse; margin-top: 8px; }
  .inv-info td { padding: 2px 6px 2px 0; vertical-align: top; }
  .inv-info td:nth-child(odd) { color: #444; white-space: nowrap; }
  .inv-items th, .inv-items td { border: 1px solid #000; padding: 4px 6px; vertical-align: top; }
  .inv-items th { background: #eee; font-size: 11px; }
  .inv .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  /* Bảng giá gửi khách: 3 dòng đầu + danh sách "tên — giá" */
  .pl-print { font-size: 13px; }
  .pl-date { font-size: 13px; }
  .pl-company { font-size: 16px; margin: 2px 0 10px; }
  .pl-sub { color: #444; margin-bottom: 8px; }
  .pl-lines { width: 100%; border-collapse: collapse; }
  .pl-lines td { padding: 3px 4px; border-bottom: 1px dotted #bbb; vertical-align: baseline; }
  .pl-lines .pl-name { width: 100%; }
  .pl-lines .pl-name small { color: #555; }
  .pl-lines .pl-dash { color: #888; padding: 3px 8px; }
  .pl-lines .pl-price { text-align: right; white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
  .pl-lines .pl-price small { font-weight: 400; color: #555; }
  .pl-note { margin-top: 10px; }
  .inv-simple .inv-items th, .inv-simple .inv-items td { font-size: 13px; padding: 5px 8px; }
  .inv-items tfoot td { font-weight: 500; }
  .inv-sign { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin-top: 28px; font-weight: 600; }
  .inv-sign small { font-weight: 400; color: #444; }
}

/* ---------- Công nợ ---------- */
tr.row-overdue td { background: var(--danger-soft); }
tr.row-overdue.clickable:hover td { background: #f5d6d1; }

/* ---------- Đăng nhập & người dùng ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--ground); z-index: 50; padding: 20px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 4px; }
.login-card h1 { font-size: 20px; }
.login-error { color: var(--danger); min-height: 1.4em; margin: 0; }
.login-card p { margin: 0; }
.login[hidden] { display: none; }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; }
.temp-pw { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.temp-pw code { font-size: 26px; letter-spacing: 0.08em; padding: 12px 16px; background: var(--ground); border-radius: 8px; border: 1px dashed var(--line-strong); user-select: all; }
#app-shell[hidden] { display: none; }

/* ---------- Trách nhiệm ---------- */
.static-field { height: 36px; display: flex; align-items: center; padding: 0 10px; border: 1px dashed var(--line-strong); border-radius: 6px; background: var(--ground); color: var(--muted); font-weight: 500; }
.check-list { display: flex; flex-direction: column; gap: 4px; }
.check-list .check { height: auto; padding: 6px 8px; border-radius: 6px; }
.check-list .check:hover { background: var(--ground); }

/* ---------- Sổ quỹ ---------- */
.wallet-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.wallet-card { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; font: inherit; color: inherit; }
.wallet-card:hover { border-color: var(--accent); }
.wallet-card.tien_mat { border-left: 4px solid var(--ok); }
.wallet-card.tai_khoan { border-left: 4px solid var(--accent); }
.wallet-card.total { border-left: 4px solid var(--ink); cursor: default; background: var(--ground); }
.wallet-name { font-weight: 600; margin-top: 2px; }
.wallet-balance { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }
.cat-row { margin-bottom: 10px; }
.cat-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 4px; }

/* ---------- Bang gia ---------- */
tr.group-row td { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

[hidden] { display: none !important; }

/* =====================================================================
   BỐ CỤC MỚI: sidebar dọc bên trái + header mỏng (thay thanh ngang cũ)
   ===================================================================== */
#app-shell { display: flex; min-height: 100vh; align-items: flex-start; }

/* ---------- Sidebar ---------- */
.sidebar {
  flex: 0 0 240px; width: 240px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: 14px 12px 20px;
  z-index: 40;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 14px; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.sidebar .brand-mark { width: 32px; height: 32px; font-size: 14px; }
.sidebar .brand-name { font-size: 17px; font-weight: 700; }

.nav { display: flex; flex-direction: column; gap: 2px; flex-wrap: nowrap; align-items: stretch; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px;
  color: var(--ink); text-decoration: none; font-weight: 500; font-size: 13.5px;
  white-space: nowrap; line-height: 1.3;
}
.nav a:hover { background: var(--ground); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav a.active .ic { color: var(--accent); }
.nav .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav .badge { margin-left: auto; }

.nav-section { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.nav-section-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); padding: 2px 10px 4px;
}

/* icon dùng chung */
.ic { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.nav a:hover .ic { color: var(--ink); }
.btn .ic { width: 15px; height: 15px; flex-basis: 15px; color: inherit; }

/* ---------- Vùng nội dung + header mỏng ---------- */
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 600; font-size: 15px; }
.user-menu { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-id { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; }
.nav-toggle { display: none; padding: 0 8px; }
.sidebar-backdrop { display: none; }

/* ---------- Điện thoại / tablet: sidebar xổ ra từ nút hamburger ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100dvh;
    transform: translateX(-100%); transition: transform 180ms ease-out;
    box-shadow: var(--shadow);
  }
  #app-shell.nav-open .sidebar { transform: none; }
  #app-shell.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(27, 42, 38, 0.35); z-index: 35; }
  .nav-toggle { display: inline-flex; }
  .app-main { min-height: 100dvh; }
  .user-id { flex-direction: column; align-items: flex-start; gap: 1px; line-height: 1.2; }
  .btn-label { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .quick-actions { gap: 4px; }
  .quick-actions .btn { padding: 0 9px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Tổng quan ---------- */
a.stat-link { text-decoration: none; color: inherit; }
a.stat-link:hover { border-color: var(--accent); }
.shortcut-list { display: flex; flex-direction: column; gap: 8px; }
.shortcut-list .btn { justify-content: flex-start; text-decoration: none; }

/* .page có margin:0 auto nên trong flex dọc nó tự co theo nội dung; ép về đúng bề ngang
   vùng nội dung để bảng rộng cuộn ngang bên trong .table-wrap thay vì kéo giãn cả trang. */
.app-main > .topbar, .app-main > .page { min-width: 0; }
.app-main > .page { width: 100%; }

/* Tên công ty trên sidebar: cho xuống tối đa 2 dòng, dài quá thì cắt bằng dấu … */
.sidebar .brand { align-items: flex-start; }
.sidebar .brand-mark { flex: 0 0 32px; }
.sidebar .brand-name {
  font-size: 14.5px; line-height: 1.25; font-weight: 700;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}

/* ---------- Báo cáo lãi lỗ ---------- */
.stat .value.ok { color: var(--ok); }
.chart-wrap { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 10px 12px 6px; }
.chart { width: 100%; height: auto; max-height: 260px; display: block; }
.chart .c-axis { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .c-rev { fill: var(--accent); opacity: .30; }
.chart .c-profit { fill: var(--ok); }
.chart .c-profit.neg { fill: var(--danger); }
.chart .c-label { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--ink); padding: 6px 2px 4px; }
.chart-legend i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart-legend .sw-rev { background: var(--accent); opacity: .30; }
.chart-legend .sw-profit { background: var(--ok); }

.money-truth { margin-bottom: 20px; }
.truth-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.truth-row .big { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; margin: 2px 0; white-space: nowrap; }
.truth-row .big.ok { color: var(--ok); }
.truth-row .big.warn { color: var(--warn); }
.truth-row .big.danger { color: var(--danger); }


/* ---------- Ô gợi ý (autocomplete) ---------- */
.ac-list {
  position: absolute; z-index: 60; max-height: 320px; overflow-y: auto; max-width: min(560px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 4px;
}
.ac-item { padding: 7px 10px; border-radius: 6px; cursor: pointer; line-height: 1.3; }
.ac-item.active { background: var(--accent-soft); }
.ac-item .ac-main { font-size: 14px; }
.ac-item .ac-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.ac-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }

/* ---------- Nút tắt: Bán hàng / Xuất hàng / Nhập hàng ---------- */
.quick-actions { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.quick-actions[hidden] { display: none; }
.quick-actions .btn { text-decoration: none; }
.quick-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.quick-btn {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color 120ms, background 120ms;
}
.quick-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.quick-btn .ic { width: 26px; height: 26px; flex: none; color: var(--accent-ink); }
.quick-btn span { display: flex; flex-direction: column; line-height: 1.25; }
.quick-btn strong { font-size: 16px; }
.quick-btn small { color: var(--muted); font-size: 12px; }
.quick-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.quick-btn.primary .ic, .quick-btn.primary small { color: rgba(255, 255, 255, 0.85); }
.quick-btn.primary:hover { filter: brightness(1.05); }

/* ---------- Bảng dòng hàng phiếu nhập ---------- */
.import-lines td { padding: 6px 6px; vertical-align: top; }
.import-lines th { padding: 8px 6px; }
.import-lines input { width: 100%; min-width: 0; height: 32px; padding: 0 8px; }
.import-lines input[type="date"] { min-width: 130px; }
.import-lines .line-hint { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; min-height: 13px; }
.import-lines .line-remove { padding: 0 8px; color: var(--muted); }
.import-lines .line-remove:hover { color: var(--danger); }
.import-lines tfoot td { padding: 10px 8px; }
td.nowrap { white-space: nowrap; }
