/* =====================================================================
   Ngôn ngữ thiết kế lấy từ mockup "Quản lý ao cá.dc.html":
   teal #0f7d99, nền #f4f6f7, viền #e5e9ec, Be Vietnam Pro + IBM Plex Mono.
   ===================================================================== */

:root {
  --teal: #0f7d99;
  --teal-dark: #0b6480;
  --teal-bg: #eaf4f7;
  --teal-border: #bcdbe4;
  --ok: #1f7a52;
  --ok-bg: #e6f3ec;
  --warn: #a9761b;
  --warn-bg: #fbf1de;
  --warn-fg: #7d5713;
  --bad: #b03a2e;
  --bad-bg: #fdeceb;
  --ink: #14181c;
  --ink-2: #46525a;
  --ink-3: #7b858e;
  --ink-4: #8a939b;
  --ink-5: #a0a9b0;
  --line: #e5e9ec;
  --line-2: #eef1f3;
  --line-3: #f1f4f5;
  --bg: #f4f6f7;
  --surface: #fff;
  --surface-2: #fafbfc;
  --surface-3: #fbfcfc;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  --font-app: 'Be Vietnam Pro', -apple-system, 'Segoe UI', Helvetica, sans-serif;
}

/* --------------------------------------------------- Font chữ toàn app
   Đổi biến --font-app theo lựa chọn trong menu "Aa" — chỉ dùng font đã
   có sẵn trên hệ điều hành, không tải thêm gì nên hoạt động offline. */
:root[data-font-family="he-thong"] { --font-app: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
:root[data-font-family="serif"] { --font-app: 'Times New Roman', Georgia, 'Cambria', serif; }
:root[data-font-family="mono"] { --font-app: var(--mono); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: var(--font-app);
  color: var(--ink);
  font-size: 15px;
}

/* ------------------------------------------------------- Cỡ chữ toàn app
   Phóng nguyên khối .shell (chữ + nút + khoảng cách cùng tỉ lệ đã thiết
   kế) thay vì đổi từng font-size — tránh vỡ layout khi chỉnh cỡ lớn.
   zoom: chuẩn thực tế trên mọi trình Chromium (Edge, Chrome).
   transform: scale: dự phòng cho trình duyệt không hỗ trợ zoom (Firefox). */
.shell { transform-origin: top left; }
:root[data-font-scale="nho"] .shell { zoom: 0.9; }
:root[data-font-scale="lon"] .shell { zoom: 1.15; }
:root[data-font-scale="rat-lon"] .shell { zoom: 1.3; }

@supports not (zoom: 1) {
  :root[data-font-scale="nho"] .shell { transform: scale(0.9); width: calc(100% / 0.9); }
  :root[data-font-scale="lon"] .shell { transform: scale(1.15); width: calc(100% / 1.15); }
  :root[data-font-scale="rat-lon"] .shell { transform: scale(1.3); width: calc(100% / 1.3); }
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }

/* Nút trông như link — dùng khi hành động là mở modal/dialog thay vì
   điều hướng trang, nên không thể là thẻ <a href>. */
.btn-link {
  border: 0; background: transparent; padding: 0; cursor: pointer;
  font-family: inherit; font-size: inherit; font-weight: inherit;
  color: var(--teal); text-decoration: none;
}
.btn-link:hover { color: var(--teal-dark); text-decoration: underline; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #d6dbdf; border-radius: 8px; border: 3px solid var(--bg);
}

.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px; flex: 0 0 244px; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand {
  padding: 22px 20px 18px; display: flex; align-items: center; gap: 11px;
}
.brand-logo { width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px; }
.brand-name { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px; }
.nav-group-label {
  font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-5); font-weight: 600; padding: 12px 12px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; border: 0; cursor: pointer; padding: 9px 12px;
  border-radius: 9px; font-family: inherit; font-size: 13.5px;
  font-weight: 500; background: transparent; color: var(--ink-2);
  text-decoration: none;
}
.nav-item:hover { background: #f0f3f5; color: var(--ink-2); }
.nav-item.active {
  background: var(--teal-bg); color: var(--teal-dark);
}
.nav-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px;
  background: #c9d1d6;
}
.nav-item.active .nav-dot { background: var(--teal); }
.nav-label { flex: 1; }
.nav-badge {
  font-family: var(--mono); font-size: 11px; color: var(--ink-4);
  background: #f0f3f5; padding: 1px 6px; border-radius: 6px;
}
.nav-badge.alert { background: var(--bad-bg); color: var(--bad); }

.sidebar-foot {
  margin-top: auto; padding: 16px; border-top: 1px solid var(--line-2);
}
.side-card {
  background: #f7f9fa; border: 1px solid #e9edef; border-radius: 12px;
  padding: 13px 14px; display: flex; flex-direction: column; gap: 7px;
}
.side-card-label {
  font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 600;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 15px 28px;
  display: flex; align-items: center; gap: 18px;
}
.crumb { font-size: 11.5px; color: var(--ink-4); font-weight: 500; }
.page-title {
  margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.015em;
}
.topbar-right {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #dfe6e9;
  color: var(--ink-2); display: flex; align-items: center;
  justify-content: center; font-size: 12.5px; font-weight: 600;
  flex: 0 0 34px;
}
.role-chip {
  font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 7px;
  background: var(--teal-bg); color: var(--teal-dark);
}

.font-size-menu { position: relative; }
#fontSizeBtn { font-weight: 700; min-width: 40px; justify-content: center; }
.font-size-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(20,24,28,0.12);
  padding: 8px; display: flex; flex-direction: column; gap: 2px;
  min-width: 168px;
}
/* .font-size-pop { display: flex } thắng [hidden] của UA stylesheet vì
   nạp sau — phải khai báo lại display:none tường minh khi có [hidden]. */
.font-size-pop[hidden] { display: none; }
.font-size-pop-label {
  font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 600; padding: 6px 10px 4px;
}
.font-size-opt {
  border: 0; background: transparent; text-align: left; cursor: pointer;
  font-family: inherit; font-size: 13.5px; color: var(--ink-2);
  padding: 9px 10px; border-radius: 8px;
}
.font-size-opt:hover { background: #f0f3f5; }
.font-size-pop-divider { height: 1px; background: var(--line-2); margin: 6px 2px; }
.font-size-opt.active {
  background: var(--teal-bg); color: var(--teal-dark); font-weight: 600;
}

.content {
  padding: 22px 28px 48px; display: flex; flex-direction: column; gap: 18px;
}

/* ----------------------------------------------------------------- Card */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
}
.card-pad { padding: 18px; }
.card-head {
  padding: 15px 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line-2);
}

/* Khối "+ Thêm ..." dạng <details> đứng riêng phía trên bảng danh sách —
   đẩy nút bật/tắt sang phải thay vì chiếm hết chiều rộng card, để mắt
   người dùng đi thẳng từ tiêu đề trang xuống bảng dữ liệu ở giữa. */
.toggle-form { padding: 10px 14px; }
.toggle-form > summary {
  display: flex; justify-content: flex-end; list-style: none;
}
.toggle-form > summary::-webkit-details-marker { display: none; }
.toggle-form > summary::before {
  content: '+ '; font-weight: 600;
}
.toggle-form[open] > summary::before { content: '− '; }
.toggle-form > form { padding: 0 4px 4px; }
.card-title { font-size: 14px; font-weight: 600; }
.card-note { font-size: 12px; color: var(--ink-4); }
.card-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.grid { display: grid; gap: 14px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.split { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 9px;
}
.kpi-label { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.kpi-val {
  display: flex; align-items: baseline; gap: 7px;
}
.kpi-num {
  font-family: var(--mono); font-size: 25px; font-weight: 600;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.kpi-unit { font-size: 12px; color: var(--ink-4); }
.kpi-delta { font-size: 12px; font-weight: 500; color: var(--ink-4); }

/* ---------------------------------------------------------------- Table */

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead th {
  text-align: left; padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line-2); font-size: 11px;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-4);
  font-weight: 600; white-space: nowrap;
}
/* table.tbl thead th (3 phần tử) đặc hiệu hơn .t-r/.t-c (1 class) nên
   luôn đè text-align:left lên header nhóm cột (vd <th colspan="2"
   class="t-c">Ca sáng</th> trong bảng nhập liệu hao hụt) — tiêu đề nhóm
   bị dạt sang trái thay vì nằm giữa 2 cột con bên dưới. */
table.tbl thead th.t-r { text-align: right; }
table.tbl thead th.t-c { text-align: center; }
table.tbl tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--line-3);
  vertical-align: middle;
}
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tfoot td {
  padding: 12px 14px; background: var(--surface-2); font-weight: 600;
  border-top: 1px solid var(--line);
}
.t-r { text-align: right; }
.t-c { text-align: center; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.sub { font-size: 11.5px; color: var(--ink-4); }

.empty {
  padding: 44px 18px; text-align: center; color: var(--ink-4); font-size: 13px;
}

/* --------------------------------------------------------------- Badges */

.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 7px; white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-teal { background: var(--teal-bg); color: var(--teal-dark); }
.badge-mute { background: #f0f3f5; color: var(--ink-4); }

.pos { color: var(--ok); font-weight: 600; }
.neg { color: var(--bad); font-weight: 600; }

/* Dropdown trạng thái inline trong bảng — trông như badge, đổi là chạy
   ngay (onchange submit), không cần mở form/modal riêng. */
select.status-select {
  appearance: none; -webkit-appearance: none; border: 0; min-height: 0;
  padding: 3px 22px 3px 9px; font-family: inherit; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237b858e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
select.status-select:focus {
  box-shadow: 0 0 0 2px rgba(15,125,153,0.25); background-color: var(--surface);
}

/* -------------------------------------------------------------- Buttons */

.btn {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 9px; padding: 9px 13px; font-family: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2);
  text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
  line-height: 1.4;
}
.btn:hover { background: #f5f7f8; color: var(--ink-2); }
.btn-primary {
  border: 0; background: var(--teal); color: #fff; font-weight: 600;
  padding: 10px 15px;
}
.btn-primary:hover { background: var(--teal-dark); color: #fff; }
.btn-danger { border-color: #f0c8c3; color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; }
.btn-lg { padding: 12px 20px; font-size: 13.5px; min-height: 46px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- Forms */

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
label.lbl { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.req::after { content: ' *'; color: var(--bad); }

input[type=text], input[type=number], input[type=date], input[type=password],
select, textarea {
  border: 1px solid #e0e5e8; border-radius: 10px; padding: 11px 12px;
  font-family: inherit; font-size: 13.5px; background: var(--surface-3);
  color: var(--ink); outline: none; width: 100%; min-height: 44px;
}
input.num-in, .num-in { font-family: var(--mono); font-weight: 500; }
input:focus, select:focus, textarea:focus {
  border-color: var(--teal-border); background: #fff;
  box-shadow: 0 0 0 3px rgba(15,125,153,0.09);
}

/* Ẩn nút tăng/giảm mặc định của <input type="number"> — khi ô hẹp (bảng
   nhập liệu hằng ngày, hh[]/ca_an[] dùng max-width ~110px) trình duyệt vẽ
   spinner đè lên lúc focus, bóp phần hiển thị số lại trông như lệch cột
   so với các ô chưa focus khác cùng cột. */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
input[type=number] { -moz-appearance: textfield; }
textarea { min-height: 74px; resize: vertical; }
select { cursor: pointer; }
.hint { font-size: 11.5px; color: var(--ink-4); }
.hint-warn { color: var(--warn); }

.filters {
  display: flex; flex-direction: row; gap: 10px; flex-wrap: wrap;
  align-items: flex-end;
}
.filters .field { min-width: 150px; }

/* ------------------------------------------------- Select có tìm kiếm
   Thay thế <select> gốc bằng ô nhập lọc + danh sách gợi ý, dùng cho mọi
   dropdown trong app (xem select-search.js). Vẫn giữ <select> gốc trong
   DOM (ẩn bằng opacity, không display:none) để form submit + validate
   required hoạt động bình thường như select thường. */
.ss { position: relative; display: block; width: 100%; }
.ss select {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; z-index: 0; pointer-events: none; margin: 0;
}
.ss-input { position: relative; z-index: 1; cursor: pointer; }
.ss-input.open {
  border-color: var(--teal-border); background: #fff;
  box-shadow: 0 0 0 3px rgba(15,125,153,0.09);
}
.ss-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(20,24,28,0.14);
  max-height: 260px; overflow-y: auto; padding: 6px;
}
.ss-opt {
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px; cursor: pointer;
  color: var(--ink);
}
.ss-opt:hover, .ss-opt.active { background: var(--teal-bg); color: var(--teal-dark); }
.ss-opt.selected { font-weight: 600; }
.ss-empty { padding: 10px; font-size: 13px; color: var(--ink-4); text-align: center; }

/* --------------------------------------------------------------- Alerts */

.alert {
  border-radius: 11px; padding: 13px 15px; font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start; line-height: 1.5;
}
.alert-err { background: var(--bad-bg); color: #8e2f25; border: 1px solid #f3cdc8; }
.alert-ok { background: var(--ok-bg); color: #155f3f; border: 1px solid #c3e2d1; }
.alert-warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid #ecd9ae; }
.alert-info { background: var(--teal-bg); color: var(--teal-dark); border: 1px solid var(--teal-border); }

/* ----------------------------------------------------------------- Bars */

.bar-track {
  height: 7px; border-radius: 5px; background: var(--line-2); overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 5px; background: var(--teal); }

.cost-row { display: flex; flex-direction: column; gap: 6px; }
.cost-head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.cost-head .pct {
  font-family: var(--mono); font-size: 12px; color: var(--ink-5);
  width: 46px; text-align: right;
}

/* ---------------------------------------------------------------- Login */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 396px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 30px;
  display: flex; flex-direction: column; gap: 18px;
}

/* ----------------------------------------------------------- Line items */

.line-items { display: flex; flex-direction: column; gap: 10px; }
.line-item {
  border: 1px solid var(--line-2); border-radius: 12px; padding: 13px;
  background: var(--surface-3); display: grid; gap: 11px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: end;
}
.line-item .rm { align-self: end; }

/* --------------------------------------------------------------- Detail */

.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 13px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; font-weight: 500; }

.stat-row { display: flex; gap: 26px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-size: 11.5px; color: var(--ink-4); }
.stat-val {
  font-family: var(--mono); font-size: 17px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: flex; gap: 8px; flex-wrap: wrap; border-bottom: 1px solid var(--line);
  padding-bottom: 0; margin-bottom: 2px;
}
.tab {
  padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--ink-2);
  border: 1px solid transparent; border-bottom: 2px solid transparent;
  background: transparent; cursor: pointer; text-decoration: none;
  border-radius: 8px 8px 0 0;
}
.tab:hover { background: #f0f3f5; color: var(--ink-2); }
.tab.active {
  color: var(--teal-dark); border-bottom-color: var(--teal);
  background: var(--teal-bg);
}

.section-title {
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  padding-top: 6px;
}

/* ---------------------------------------------------------------- Modal
   <dialog> native — mọi form Sửa/Quản lý trong bảng đều mở bằng modal:
   nội dung mở ra trong <td> sẽ đẩy chiều cao hàng và làm bảng giãn lệch.
   ::backdrop chỉ áp dụng khi mở qua showModal(). */
dialog.modal {
  border: 1px solid var(--line); border-radius: 16px; padding: 0;
  box-shadow: 0 20px 48px rgba(20,24,28,0.22); max-width: 480px; width: 92vw;
  max-height: 88vh;
}
dialog.modal::backdrop { background: rgba(20,24,28,0.4); }
.modal-body {
  display: flex; flex-direction: column; gap: 14px; padding: 20px;
  max-height: 88vh; overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 2px;
}

/* Biến thể rộng — modal xem nội dung dài (vd Chi tiết ao) thay vì form ngắn. */
dialog.modal-lg { max-width: 1080px; width: 94vw; }

.acct-code {
  font-family: var(--mono); font-size: 12px; background: #f0f3f5;
  padding: 2px 7px; border-radius: 6px; color: var(--ink-2);
  white-space: nowrap;
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar-foot { display: none; }
  .nav {
    flex-direction: row; overflow-x: auto; padding: 8px;
    -webkit-overflow-scrolling: touch;
    /* Fade 2 bên báo hiệu còn mục menu ẩn ngoài vùng nhìn thấy. */
    -webkit-mask-image: linear-gradient(to right, transparent, #000 14px, #000 calc(100% - 14px), transparent);
            mask-image: linear-gradient(to right, transparent, #000 14px, #000 calc(100% - 14px), transparent);
  }
  .nav-item { flex: 0 0 auto; }
  .nav-group-label { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 13px 16px; flex-wrap: wrap; }

  /* Cỡ chữ điều chỉnh qua zoom/transform không đáng tin trên mobile
     (viewport không đổi theo, cộng dồn lỗi với overflow-x của bảng) —
     trình duyệt mobile đã có pinch-zoom native nên ẩn riêng mục cỡ chữ.
     Chọn font chữ không dùng zoom nên vẫn giữ được trên mobile. */
  .font-size-pop [data-scale], .font-size-pop-divider,
  .font-size-pop-label:has(+ [data-scale]) { display: none; }
  :root[data-font-scale] .shell { zoom: 1; transform: none; width: auto; }
}

/* ---------------------------------------- Bảng dạng thẻ trên điện thoại
   Ẩn phần đầu bảng, mỗi <tr> thành 1 thẻ dọc, nhãn cột lấy từ
   data-label (gắn tự động bằng JS trong layout.php từ chính <th>). */
@media (max-width: 640px) {
  .table-wrap { overflow-x: visible; }
  table.tbl thead { display: none; }
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td {
    display: block; width: 100%;
  }
  table.tbl tr {
    border: 1px solid var(--line-2); border-radius: 12px;
    padding: 4px 12px; margin-bottom: 10px; background: var(--surface);
  }
  table.tbl tbody tr:hover { background: var(--surface); }
  table.tbl td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; text-align: right; padding: 9px 2px;
    border-bottom: 1px solid var(--line-3);
  }
  table.tbl td:last-child { border-bottom: 0; }
  table.tbl td::before {
    content: attr(data-label); font-size: 11px; font-weight: 600;
    letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-4);
    text-align: left; flex: 0 0 auto;
  }
  table.tbl td:empty::before { content: none; }
  table.tbl tfoot, table.tbl tfoot tr, table.tbl tfoot td {
    display: block; width: 100%;
  }
  table.tbl tfoot td {
    background: var(--surface-2); display: flex; justify-content: space-between;
  }
}

/* --------------------------------- Chi tiết/thống kê trên điện thoại nhỏ */
@media (max-width: 480px) {
  .dl { grid-template-columns: 1fr; gap: 3px 0; }
  .dl dt { padding-top: 6px; }
  .dl dd { padding-bottom: 2px; }

  .stat-row { gap: 14px; }
  .stat { flex: 1 1 45%; }

  .line-item { grid-template-columns: 1fr; }
  .line-item .rm { grid-column: 1 / -1; }
  .line-item .rm .btn { width: 100%; justify-content: center; }

  .topbar-right { gap: 7px; }
  .role-chip { display: none; }

  .kpi-num { font-size: 21px; }
  .page-title { font-size: 17px; }
}

@media print {
  .sidebar, .topbar, .btn, .filters { display: none !important; }
  .content { padding: 0; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}
