* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f6f8;
  color: #222;
}

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

.sidebar {
  width: 270px;
  background: #1F4E79;
  color: #e8f0f7;
  padding: 18px 10px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-title { font-size: 18px; font-weight: bold; color: #fff; padding: 6px 10px 14px; }
.menu-list { display: flex; flex-direction: column; margin-bottom: 10px; }
.menu-link {
  color: #e8f0f7; text-decoration: none; padding: 8px 10px; border-radius: 6px;
  font-size: 14px; margin: 1px 0;
}
.menu-link:hover { background: #2E86AB; color: #fff; }
.menu-link.active { background: #2E86AB; color: #fff; font-weight: 600; }

/* 21 mục gom thành từng nhóm có thể thu gọn/mở ra (<details>/<summary> có sẵn của
   trình duyệt, không cần JS riêng) - nhóm "Quản lý & Nhắc việc" luôn mở sẵn vì hay
   dùng nhất, các nhóm khác gọn lại, tự mở nếu đang đứng ở mục bên trong nhóm đó. */
.menu-group { margin-bottom: 2px; display: flex; flex-direction: column; }
.menu-group .menu-link { padding-left: 22px; font-size: 13px; display: block; }
.menu-group-title {
  cursor: pointer; padding: 7px 10px; border-radius: 6px; font-size: 11px; font-weight: bold;
  color: #b8cbe0; text-transform: uppercase; list-style: none; user-select: none;
}
.menu-group-title::-webkit-details-marker { display: none; }
.menu-group-title::before { content: '▸'; display: inline-block; width: 12px; font-size: 10px; transition: transform 0.15s ease; }
.menu-group[open] > .menu-group-title::before { transform: rotate(90deg); }
.menu-group-title:hover { background: rgba(255,255,255,0.08); color: #fff; }

.sidebar-section-label {
  font-size: 11px; font-weight: bold; color: #b8cbe0; text-transform: uppercase;
  padding: 12px 10px 4px;
}
.side-btn, a.side-btn {
  display: block; width: 100%; text-align: left; background: transparent; color: #e8f0f7;
  border: 1px solid #3d658a; border-radius: 6px; padding: 7px 10px; margin: 3px 0;
  font-size: 13px; cursor: pointer; text-decoration: none;
}
.side-btn:hover { background: #2E86AB; border-color: #2E86AB; }
.side-btn-file { margin-bottom: 0; }
.side-form { margin: 0; }
.logout-btn { background: #c0392b; border-color: #c0392b; color: #fff; margin-top: 10px; }
.logout-btn:hover { background: #a93226; }

.content { flex: 1; padding: 26px 32px; overflow-x: auto; }
.page-title { color: #1F4E79; font-size: 24px; margin: 0 0 20px; }

.flash-wrap { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; font-size: 14px; }
.flash-success { background: #eaf7e6; color: #2e7d32; border: 1px solid #b6e0ae; }
.flash-error { background: #fdecea; color: #c0392b; border: 1px solid #f3b6b0; }

.field-block { margin-bottom: 16px; max-width: 620px; }
.field-label { display: block; font-weight: bold; font-size: 13px; margin-bottom: 4px; color: #333; }
.field-hint { font-size: 12px; color: #777; margin: 2px 0 8px; }
.kv-input, .kv-textarea, input[type=text], input[type=password], select {
  width: 100%; padding: 8px 10px; border: 1px solid #d8dee5; border-radius: 6px;
  font-size: 14px; font-family: inherit;
}
.kv-textarea { resize: vertical; }

.ttc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; max-width: 900px; }
@media (max-width: 720px) { .ttc-grid { grid-template-columns: 1fr; } }

.table-block { margin-bottom: 28px; }
.table-title { color: #1F4E79; font-size: 16px; margin: 18px 0 8px; }
.section-title {
  color: #1F4E79; font-size: 19px; margin: 30px 0 6px; padding-top: 18px;
  border-top: 2px solid #d8dee5;
}
.section-title:first-of-type { margin-top: 4px; padding-top: 0; border-top: none; }

/* Danh sách xuất báo cáo/biên bản gom lại thu gọn (details/summary) trên trang
   nội dung chính (nền trắng) - khác màu với .menu-group của sidebar (nền xanh). */
.export-picker-group {
  border: 1px solid #e3e7eb; border-radius: 8px; margin-bottom: 16px; padding: 2px 16px; background: #fff;
}
.export-picker-group[open] { padding-bottom: 14px; }
.export-picker-summary {
  cursor: pointer; padding: 12px 4px; font-size: 15px; font-weight: bold; color: #1F4E79;
  list-style: none; user-select: none;
}
.export-picker-summary::-webkit-details-marker { display: none; }
.export-picker-summary::before { content: '▸'; display: inline-block; width: 14px; font-size: 12px; transition: transform 0.15s ease; }
.export-picker-group[open] > .export-picker-summary::before { transform: rotate(90deg); }
.export-picker-summary:hover { color: #2E86AB; }
.table-scroll { overflow-x: auto; border: 1px solid #e3e7eb; border-radius: 8px; }

table.data-table, table.stats-table {
  border-collapse: collapse; width: 100%; min-width: 600px; background: #fff; font-size: 13px;
}
table.data-table th, table.stats-table th {
  background: #e8f0f7; color: #1F4E79; text-align: left; padding: 8px 6px; white-space: nowrap;
}
table.data-table td, table.stats-table td { padding: 3px 6px; border-top: 1px solid #eef1f4; }
table.data-table input.cell-input, table.data-table select.cell-select {
  width: 100%; min-width: 90px; border: 1px solid transparent; padding: 6px 6px; border-radius: 4px; font-size: 13px;
}
table.data-table input.cell-input:hover, table.data-table select.cell-select:hover { border-color: #d8dee5; }
table.data-table input.cell-input:focus, table.data-table select.cell-select:focus {
  border-color: #2E86AB; outline: none; background: #f4faff;
}
.col-del { width: 34px; }
.col-stt { width: 40px; text-align: center; color: #888; font-size: 12px; }
th.col-stt { text-align: center; }

.hd-filter-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px;
}
.hd-filter-bar label { font-weight: bold; color: #333; }
.hd-filter-bar select { width: auto; min-width: 220px; }

.col-archive-link { width: 100px; text-align: center; white-space: nowrap; }
.link-archive { color: #2E86AB; font-size: 12px; text-decoration: none; }
.link-archive:hover { text-decoration: underline; }
.archive-link-empty { color: #ccc; }
.btn-del-row {
  background: #fbeaea; color: #c0392b; border: none; border-radius: 4px; width: 26px; height: 26px; cursor: pointer;
}
.btn-del-row:hover { background: #f0c4c4; }

.btn-add-row {
  margin-top: 8px; background: #f4f6f8; color: #1F4E79; border: 1px solid #1F4E79;
  border-radius: 6px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.btn-add-row:hover { background: #e8f0f7; }

.btn-primary { background: #1F4E79; color: #fff; border: none; border-radius: 6px; padding: 9px 16px; font-size: 14px; cursor: pointer; }
.btn-primary:hover { background: #163a5c; }
.btn-secondary { background: #2E86AB; color: #fff; border: none; border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn-secondary:hover { background: #256f8c; }
.btn-warn { background: #f39c12; color: #fff; border: none; border-radius: 6px; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.btn-danger { background: #c0392b; color: #fff; border: none; border-radius: 6px; padding: 6px 12px; font-size: 12px; cursor: pointer; }

.reload-banner {
  background: #fff8e1; border: 1px solid #ffe082; color: #8a6d00; padding: 8px 12px;
  border-radius: 6px; margin-bottom: 8px; font-size: 13px;
}
.reload-banner button { margin-left: 8px; background: #1F4E79; color: #fff; border: none; border-radius: 4px; padding: 4px 10px; cursor: pointer; }

.chart-img { max-width: 100%; border: 1px solid #e3e7eb; border-radius: 8px; margin-top: 16px; background: #fff; }

/* Cột "Phiên bản" (mục 19, bảng Hợp đồng bảo trì) - khi 1 Hệ thống/Thiết bị được gộp
   nhiều lần ký lại/gia hạn (đổi Số hợp đồng) vào cùng 1 dòng, ô này cho chọn đúng
   phiên bản đang xem/sửa (giống ô "File" ở trang Hợp đồng đã lưu) - xem
   _table_group.html + app.js (samcoHopDongVersionSelect).*/
.col-hd-version { width: 130px; }
select.hd-version-select { width: 100%; min-width: 110px; font-size: 12px; }
.hd-version-single { color: #999; }

/* Phụ lục gia hạn hợp đồng bảo trì (mục 19) - bảng con mở rộng ngay dưới mỗi dòng hợp đồng */
tr.phu-luc-toggle-row td { border-top: none; padding: 0 6px 6px !important; background: #fafbfc; }
.btn-phu-luc-toggle {
  background: none; border: none; color: #2E86AB; font-size: 12px; cursor: pointer;
  padding: 3px 4px; text-decoration: underline;
}
.btn-phu-luc-toggle:hover { color: #1F4E79; }
tr.phu-luc-content td { background: #fafbfc; padding: 8px 6px 14px 22px !important; border-top: none; }
.phu-luc-block { max-width: 420px; }
.phu-luc-block table.data-table { min-width: 0; }
.phu-luc-block .btn-add-row { font-size: 12px; padding: 4px 10px; }

.reminder-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.reminder-head h3 { color: #1F4E79; margin: 0; }
.reminder-list { margin-bottom: 24px; }
.reminder-item { padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; font-size: 13px; }
.reminder-item.overdue { background: #fbeaea; color: #c0392b; }
.reminder-item.soon { background: #fdf0e3; color: #b35c00; }
.reminder-item.ok { background: #eef6ea; color: #4b7f2c; }
.reminder-empty { color: #639922; font-size: 13px; }

.empty-row { color: #888; text-align: center; padding: 16px !important; }

.search-form { display: flex; gap: 8px; margin-bottom: 18px; max-width: 480px; }
.search-form input { flex: 1; }
/* Trang "Tra cứu ca trực" (mục 22) có thêm nút "Quay lại Ca trực" cạnh nút Tra cứu -
   480px của .search-form gốc quá chật khi có 2 nút, cho rộng hơn + tự xuống dòng nếu
   màn hình nhỏ thay vì bị ép co lại. */
.ct-search-form { max-width: none; flex-wrap: wrap; }
.ct-search-form input, .ct-search-form select { flex: none; }

/* Ca trực (mục 22): nút "Xem thêm N dòng cũ hơn" dưới mỗi bảng thu gọn */
.ct-toggle-collapse { margin-top: 8px; margin-right: 8px; }

/* Chỉ áp dụng flex-column cho layout THẺ cũ (div.archive-list, dùng ở Phụ lục/Biên
   bản/Hợp đồng cho thuê đã lưu) - trang "Hợp đồng đã lưu" dùng lại tên class này trên
   <tbody> (để JS lọc theo Đơn vị cung cấp dùng chung 1 hàm) nên PHẢI giới hạn rõ bằng
   thẻ div, nếu không sẽ phá layout bảng (tbody bị ép thành flex, các <tr>/<td> xếp dọc
   từng dòng thay vì thành cột như mục 19). */
div.archive-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.archive-item {
  background: #fff; border: 1px solid #e3e7eb; border-radius: 8px; padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
/* Các trường thông tin (Khoản thanh toán, Số tiền, Ngày...) xếp NGANG, tự xuống
   dòng khi hết chỗ, thay vì mỗi trường 1 dòng riêng - đỡ tốn chiều cao, đỡ phải
   cuộn nhiều khi danh sách hồ sơ dài. */
.archive-meta { display: flex; flex-direction: row; flex-wrap: wrap; column-gap: 20px; row-gap: 3px; font-size: 13px; color: #444; flex: 1; align-items: baseline; }
.meta-kv { white-space: nowrap; }
.meta-kv b { color: #1F4E79; }
.archive-stt { color: #888; font-size: 13px; font-weight: bold; min-width: 22px; }
/* Số thứ tự riêng cho từng FILE bên trong 1 bộ hồ sơ nhiều file (khác với số thứ tự
   của cả bộ hồ sơ) - tô màu xanh để phân biệt, file thêm sau luôn xếp số lớn hơn. */
.archive-file-no { color: #2E86AB; }

/* 1 bộ hồ sơ (nhiều file) gọn thành 1 THẺ - 1 DÒNG duy nhất: thông tin chung (Khoản
   thanh toán/Đơn vị/Số tiền/Ngày thanh toán...) + ô chọn "File" (nếu nhiều file thì
   chọn đúng file muốn thao tác) - không liệt kê riêng từng dòng cho mỗi file nữa. */
div.archive-group {
  background: #fff; border: 1px solid #e3e7eb; border-radius: 8px; padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.archive-group-title { white-space: nowrap; }
.archive-group-count { color: #888; font-weight: normal; font-size: 12px; }
.archive-file-select-wrap select.archive-file-select {
  width: auto; max-width: 260px; display: inline-block; padding: 3px 6px; font-size: 12px;
}

/* Trang "Hợp đồng đã lưu" dạng BẢNG (giống mục 19 - Hợp đồng bảo trì) - mỗi bộ hồ
   sơ/file lẻ 1 dòng, cột "File" là ô chọn, cột "Thao tác" gom các nút Xem/Tải/Sửa/
   Thay thế/Xoá + "+ File". Khung sửa (form) và dòng "+ Thêm file" nằm ở 1 <tr> riêng
   ẩn/hiện bằng JS (archive-edit-row/archive-add-row) vì <form> không được đặt trực
   tiếp làm con của <tbody>. */
table.archive-hd-table .archive-group td { vertical-align: middle; }
table.archive-hd-table .archive-actions-cell { padding-top: 6px; padding-bottom: 6px; }
table.archive-hd-table .archive-savedat { font-size: 12px; color: #888; white-space: nowrap; }
table.archive-hd-table .archive-group-count { color: #888; font-weight: normal; font-size: 12px; }

/* Trạng thái thanh toán (trang "Hồ sơ thanh toán") - suy ra từ Ngày thanh toán đã
   điền hay chưa, hiện dạng nhãn màu cho dễ nhận ra ngay không cần đọc kỹ ngày tháng. */
.pay-status { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 12px; white-space: nowrap; }
.pay-status-paid { background: #eef6ea; color: #4b7f2c; }
.pay-status-unpaid { background: #fdf0e3; color: #b35c00; }

/* Cột "Thao tác" gọn lại thành 1 nút "⋮ Thao tác" mở ra danh sách hành động (Xem/
   Tải/Sửa/Thay thế/Xoá/+File), thay vì hiện hết cùng lúc gây rối mắt. Khi mở, JS
   (attachArchiveActionsMenu trong app.js) chuyển .archive-actions-dropdown ra làm con
   trực tiếp của <body> và định vị bằng toạ độ thực (position: fixed) - tránh bị khung
   cuộn ngang của bảng (.table-scroll, overflow-x: auto) vô tình cắt mất phần tràn
   xuống dưới (theo chuẩn CSS, overflow-x khác "visible" kéo theo overflow-y cũng bị
   giới hạn nếu không được khai báo riêng). */
.archive-actions-menu { position: relative; display: inline-block; }
.archive-actions-dropdown {
  display: none; flex-direction: column; gap: 2px; min-width: 200px;
  background: #fff; border: 1px solid #e3e7eb; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.16); padding: 6px; z-index: 200;
}
.archive-actions-dropdown.archive-actions-dropdown-open { display: flex; }
.archive-actions-dropdown form { margin: 0; }
.archive-action-item {
  display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 6px;
  font-size: 13px; color: #1F4E79; text-decoration: none; background: none; border: none;
  cursor: pointer; text-align: left; width: 100%; box-sizing: border-box; font-family: inherit;
}
.archive-action-item:hover { background: #f0f5fa; }
.archive-action-danger { color: #c0392b; }
.archive-action-danger:hover { background: #fbeaea; }
.archive-actions-dropdown .btn-replace-file { margin: 0; }
.archive-actions-dropdown .btn-replace-file input[type=file] { display: none; }
/* Cột "Tên hợp đồng" - cắt gọn 1 dòng bằng dấu ... khi quá dài (giống cách hiện tên
   thiết bị ngắn gọn ở mục 19), trỏ chuột vào xem đủ tên qua tooltip (title). */
.archive-hd-name-cell { max-width: 260px; }
.archive-hd-title {
  display: inline-block; max-width: 240px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: middle; font-weight: bold; color: #1F4E79;
}
tr.archive-edit-row td, tr.archive-add-row td { background: #fafbfc; border-top: none; padding: 0 6px 10px !important; }
tr.archive-add-row .archive-group-add-form { margin-left: 0; }
.btn-toggle-add { background: #f4f6f8; color: #1F4E79; border: 1px solid #1F4E79; border-radius: 6px; padding: 6px 10px; font-size: 12px; cursor: pointer; }

.archive-item-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn-toggle-edit, .btn-cancel-edit { background: #f4f6f8; color: #1F4E79; border: 1px solid #1F4E79; border-radius: 6px; padding: 6px 10px; font-size: 12px; cursor: pointer; }
.btn-cancel-edit { border-color: #ccc; color: #666; }
.btn-replace-file {
  background: #f4f6f8; color: #1F4E79; border: 1px solid #1F4E79; border-radius: 6px; padding: 6px 10px;
  font-size: 12px; cursor: pointer; display: inline-block; margin: 0;
}
.btn-replace-file input[type=file] { display: none; }

.archive-edit-form {
  display: flex; flex-direction: column; gap: 6px; flex: 1; background: #f9fbfc; border: 1px dashed #cfd8e0;
  border-radius: 6px; padding: 10px; font-size: 12px;
}
.archive-edit-form label { display: flex; flex-direction: column; gap: 2px; font-weight: bold; color: #333; }
.archive-edit-form input[type=text] { font-weight: normal; }
.archive-edit-actions { display: flex; gap: 8px; margin-top: 4px; }

/* "Tài liệu cá nhân" (atype 'personal') - khung chọn tài khoản chia sẻ thêm, dưới mỗi
   tài liệu (xem archive.html render_share_form + app.js attachArchiveShareToggle). */
.archive-share-block { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; width: 100%; }
.archive-share-form {
  display: none; flex-direction: column; gap: 6px; width: 100%; background: #f9fbfc; border: 1px dashed #cfd8e0;
  border-radius: 6px; padding: 10px; font-size: 12px; margin-top: 4px;
}
.archive-share-checklist { display: flex; flex-wrap: wrap; gap: 4px 14px; max-height: 160px; overflow-y: auto; transition: opacity .15s; }
.archive-share-user { display: flex; align-items: center; gap: 4px; font-weight: normal; font-size: 12px; }
.archive-share-mode { display: flex; gap: 16px; font-size: 12px; font-weight: bold; color: #333; }
.archive-share-mode label { display: flex; align-items: center; gap: 4px; font-weight: normal; }
.archive-share-checklist.is-disabled { opacity: .4; pointer-events: none; }

.archive-group-add-form {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: 26px;
  background: #f9fbfc; border: 1px dashed #cfd8e0; border-radius: 6px; padding: 8px 10px;
}
.archive-group-add-form input { flex: 1; min-width: 140px; font-size: 12px; padding: 6px 8px; }

.archive-upload-form, .add-user-form {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 900px;
}
.archive-upload-form input, .add-user-form input, .add-user-form select { flex: 1; min-width: 160px; }

.chuc-danh-form { display: flex; gap: 6px; align-items: center; }
.chuc-danh-form input { font-size: 12px; padding: 4px 6px; min-width: 150px; border: 1px solid #dde3e9; border-radius: 5px; }
.chuc-danh-form button { font-size: 12px; padding: 4px 8px; }

.section-parts { display: flex; flex-direction: column; gap: 8px; max-width: 780px; }
.section-part-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; border: 1px solid #e3e7eb; border-radius: 8px; padding: 10px 14px; font-size: 14px;
}

/* Trang đăng nhập */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #1F4E79, #2E86AB);
}
.login-box {
  background: #fff; padding: 34px 32px; border-radius: 12px; width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-box h1 { color: #1F4E79; font-size: 22px; text-align: center; margin: 0 0 20px; }
.login-box label { display: block; font-size: 13px; font-weight: bold; margin: 10px 0 4px; }
.login-box .hint { font-size: 11px; color: #888; margin-top: 16px; line-height: 1.5; }

/* Phân quyền sửa mục theo tài khoản */
.perm-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; max-width: 900px;
  background: #fff; border: 1px solid #e3e7eb; border-radius: 8px; padding: 16px 18px;
}
@media (max-width: 720px) { .perm-grid { grid-template-columns: 1fr; } }
.perm-item { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }
.perm-item input { width: auto; }

/* Nhật ký thay đổi */
table.audit-table td { font-size: 12px; vertical-align: top; }
td.audit-value { max-width: 260px; word-break: break-word; color: #444; }

/* Hộp thoại đổi mật khẩu */
dialog.dialog { border: none; border-radius: 10px; padding: 22px; width: 320px; }
dialog.dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog.dialog h3 { color: #1F4E79; margin-top: 0; }
dialog.dialog label { display: block; font-size: 13px; font-weight: bold; margin: 8px 0 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-actions button[type=button] { background: #eee; border: none; border-radius: 6px; padding: 8px 14px; cursor: pointer; }

/* ==========================================================================
   GIAO DIỆN CHO ĐIỆN THOẠI / MÀN HÌNH NHỎ
   Sidebar (danh mục) mặc định ẩn, thu vào thanh trên cùng có nút ☰ - bấm vào
   mới trượt ra như ngăn kéo (drawer), tránh chiếm hết bề ngang màn hình nhỏ.
   ========================================================================== */
.mobile-topbar { display: none; }
.sidebar-close-btn { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  /* Thanh trên cùng thay cho sidebar cố định - luôn thấy được nút mở menu */
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    background: #1F4E79; color: #fff; padding: 10px 14px;
    position: sticky; top: 0; z-index: 40;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  }
  .mobile-menu-btn {
    background: rgba(255,255,255,0.15); color: #fff; border: none; border-radius: 6px;
    width: 38px; height: 38px; font-size: 20px; line-height: 1; cursor: pointer; flex-shrink: 0;
  }
  .mobile-topbar-title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .app-shell { display: block; min-height: auto; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 82vw; max-width: 300px;
    transform: translateX(-100%); transition: transform 0.25s ease; z-index: 50;
    box-shadow: 2px 0 12px rgba(0,0,0,0.25);
  }
  .sidebar.sidebar-open { transform: translateX(0); }
  .sidebar-close-btn {
    display: block; margin-left: auto; background: rgba(255,255,255,0.15); color: #fff;
    border: none; border-radius: 6px; width: 32px; height: 32px; font-size: 16px; cursor: pointer;
  }

  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    z-index: 45; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  }
  .sidebar-backdrop.sidebar-backdrop-visible { opacity: 1; pointer-events: auto; }

  .content { padding: 14px 12px 28px; overflow-x: hidden; }
  .page-title { font-size: 19px; }

  /* Bảng dữ liệu vẫn cuộn ngang trong khung riêng thay vì đẩy vỡ cả trang */
  .table-scroll { -webkit-overflow-scrolling: touch; }
  table.data-table, table.stats-table { font-size: 12px; }

  /* Input/select to hơn 1 chút và chữ đủ 16px để trình duyệt điện thoại (Safari)
     không tự phóng to màn hình khi bấm vào ô nhập liệu */
  .kv-input, .kv-textarea, input[type=text], input[type=password], select {
    font-size: 16px; padding: 10px 12px;
  }
  table.data-table input.cell-input, table.data-table select.cell-select { font-size: 14px; }

  /* Các form nhiều ô nằm ngang -> xếp dọc, mỗi ô/nút rộng hết hàng cho dễ bấm */
  .search-form, .archive-upload-form, .add-user-form, .archive-group-add-form,
  .hd-filter-bar, .section-part-row {
    flex-direction: column; align-items: stretch;
  }
  .hd-filter-bar select, .search-form input { width: 100%; min-width: 0; }

  .archive-item { flex-direction: column; align-items: stretch; }
  .archive-item-nested { margin-left: 10px; }
  .archive-item-actions { justify-content: flex-start; }
  .archive-group-add-form { margin-left: 10px; }

  .reminder-head { flex-direction: column; align-items: flex-start; gap: 8px; }

  .ttc-grid, .perm-grid { grid-template-columns: 1fr; }

  /* Nút bấm to hơn cho tay chạm - đỡ bấm nhầm trên màn hình nhỏ */
  .btn-primary, .btn-secondary, .btn-add-row, .side-btn, a.side-btn,
  .btn-toggle-edit, .btn-cancel-edit, .btn-replace-file {
    min-height: 40px; display: inline-flex; align-items: center; justify-content: center;
  }

  .login-box { width: 88vw; max-width: 360px; padding: 26px 18px; }

  dialog.dialog { width: 88vw; max-width: 320px; }
}

/* ==========================================================================
   IN TRANG (Ctrl+P / nút "In danh sách") - ẩn menu và các nút thao tác, chỉ in
   phần nội dung/bảng biểu đang xem (đã lọc sẵn thì chỉ in đúng phần đã lọc).
   ========================================================================== */
@media print {
  .sidebar, .mobile-topbar, .sidebar-backdrop, .sidebar-close-btn, .flash-wrap,
  .btn-add-row, .btn-del-row, .col-del, th.col-del, .search-form,
  .archive-item-actions, .archive-group-add-form, .archive-upload-form,
  .side-form, dialog.dialog {
    display: none !important;
  }
  .app-shell { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
  .hd-filter-bar button { display: none; }
}
