:root {
  --brand-red: #ED1B24;       /* đỏ nhận diện Bảo Minh, lấy từ logo */
  --brand-red-dark: #B8121A;  /* đỏ đậm hơn, dùng khi hover */
  --brand-red-soft: #FDECEC;  /* nền đỏ rất nhạt cho mục đang chọn */
  --brand-green: #00A652;     /* xanh lá trong logo, dùng cho trạng thái "đã ký" */
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --border: #E4E7EC;
  --text: #1F2328;
  --muted: #6B7280;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}
* { box-sizing: border-box; }
/* Thuộc tính hidden phải thắng mọi display:block/flex do CSS đặt — nếu không, phần tử
   "ẩn" vẫn hiện (VD: ô Người xem xét trên form trình ký từng bị lỗi này). */
[hidden] { display: none !important; }
body {
  font-family: "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--brand-red-dark); }

/* ---------- Thanh trên cùng: logo + menu + người dùng ---------- */
header.topbar {
  background: var(--surface);
  border-top: 3px solid var(--brand-red);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  padding: 0 24px;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 28px;
  /* Không để sticky: trang đặt con dấu có thanh công cụ sticky top:0 riêng, header dính sẽ che mất nó */
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.02em; letter-spacing: 0.1px; }
.brand-text small { font-size: 0.78em; color: var(--brand-red); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.topnav { display: flex; align-items: stretch; gap: 4px; align-self: stretch; }
.topnav a {
  display: flex; align-items: center; padding: 0 14px; text-decoration: none; color: #4B5563;
  font-size: 0.93em; font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.topnav a:hover { color: var(--brand-red); background: var(--surface-2); }
.topnav a.active { color: var(--brand-red); border-bottom-color: var(--brand-red); font-weight: 600; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-red); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta strong { font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 0.78em; color: var(--muted); white-space: nowrap; }
.user-meta small a { color: var(--muted); }
.user-meta small a:hover { color: var(--brand-red); }

main { padding: 24px; max-width: 1320px; margin: 0 auto; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card.narrow { max-width: 420px; margin: 40px auto; }
h1 { font-size: 1.35em; margin-top: 0; font-weight: 700; letter-spacing: -0.2px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
label { display: block; margin-bottom: 14px; font-size: 0.9em; color: #374151; }
input[type=text], input[type=password], input[type=file], input[type=date], input[type=email] {
  display: block; width: 100%; margin-top: 6px; padding: 8px 11px;
  border: 1px solid #D0D5DD; border-radius: 8px; font-size: 0.95em; font-family: inherit;
  background: #fff; color: var(--text);
}
input[type=text]:focus, input[type=password]:focus, input[type=date]:focus, input[type=email]:focus, select:focus {
  outline: none; border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(237, 27, 36, 0.12);
}
button, .button {
  background: var(--brand-red); color: #fff; border: 1px solid var(--brand-red); padding: 8px 16px;
  border-radius: 8px; cursor: pointer; font-size: 0.93em; font-weight: 500; text-decoration: none;
  display: inline-block; font-family: inherit; line-height: 1.3;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .button:hover { background: var(--brand-red-dark); border-color: var(--brand-red-dark); }
button:disabled, button:disabled:hover { background: #F2A4A7; border-color: #F2A4A7; cursor: not-allowed; }
button.secondary { background: #fff; color: #374151; border: 1px solid #D0D5DD; }
button.secondary:hover { background: var(--surface-2); }
.button.small { padding: 5px 10px; font-size: 0.84em; }
button.small { padding: 5px 10px; font-size: 0.84em; }
form.inline { display: inline-block; margin-right: 6px; }
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #EEF0F3; font-size: 0.9em; }
th { background: var(--surface-2); color: #475467; font-weight: 600; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.3px; }
/* Nhãn trạng thái: nền nhạt + chữ đậm màu, dễ đọc hơn nền đặc */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8em; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.badge.warn { background: #FEF3C7; color: #92400E; }
.badge.info { background: #FFF1E6; color: #B45309; }
.badge.ok { background: #DCFCE7; color: #166534; }
.badge.danger { background: var(--brand-red-soft); color: var(--brand-red-dark); }
.error { color: var(--brand-red); }
.actions { white-space: nowrap; }
.muted { color: var(--muted); font-size: 0.85em; }
select { display: block; margin-top: 6px; padding: 8px 11px; border: 1px solid #D0D5DD; border-radius: 8px; font-size: 0.95em; background: #fff; font-family: inherit; }

/* ---------- Trang danh sách: tiêu đề, thẻ thống kê, thanh lọc, bảng ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0 0 2px; }
.page-head p { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px 14px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); position: relative; overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #98A2B3; }
.stat-card.pending::before { background: #F59E0B; }
.stat-card.done::before { background: var(--brand-green); }
.stat-card.stopped::before { background: var(--brand-red); }
.stat-card:hover { border-color: #CDD2DA; box-shadow: 0 4px 10px rgba(16, 24, 40, 0.08); transform: translateY(-1px); }
.stat-card.active { border-color: var(--brand-red); box-shadow: 0 0 0 3px rgba(237, 27, 36, 0.12); }
.stat-num { font-size: 1.7em; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.85em; color: var(--muted); font-weight: 500; }
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px; margin: 14px 0 6px;
  padding: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.filter-bar label { margin: 0; font-size: 0.8em; font-weight: 600; color: #475467; }
.filter-bar label input { margin-top: 5px; min-width: 150px; }
.filter-bar .grow { flex: 1 1 260px; }
.filter-actions { display: flex; gap: 8px; }
.zip-bar { background: #F0FAF4; border: 1px solid #CDEBD8; border-radius: var(--radius); padding: 10px 14px; margin: 10px 0 0; }
.table-wrap { overflow-x: auto; }
.doc-table { margin-top: 12px; }
.doc-table tbody tr:hover td { background: #FAFBFC; }
.doc-table .idcell { color: var(--muted); font-variant-numeric: tabular-nums; }
.doc-table th.pickcol { width: 36px; }
.file-link { font-weight: 600; color: var(--text); text-decoration: none; word-break: break-word; }
.file-link:hover { color: var(--brand-red); text-decoration: underline; }
.file-ico {
  display: inline-block; font-size: 0.62em; font-weight: 700; color: #fff; background: var(--brand-red);
  border-radius: 3px; padding: 1px 4px; margin-right: 7px; vertical-align: 2px; letter-spacing: 0.3px;
}
td.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.place-toolbar-row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 0; }
.place-toolbar-row label { margin-bottom: 0; }
.place-jump { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px dashed #eee; font-size: 0.9em; }
.place-jump button { background: #fff; color: #444; border: 1px solid #ccc; padding: 6px 12px; border-radius: 6px; font-size: 0.85em; cursor: pointer; }
.place-jump button:hover { background: #f0f0f0; }
#viewingLabel { font-weight: 600; color: #333; }
.jump-goto { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; white-space: nowrap; }
.jump-goto input[type=number] { width: 64px; padding: 5px 8px; border: 1px solid #ccc; border-radius: 6px; margin: 0; display: inline-block; }
.jump-goto button { background: var(--brand-red); color: #fff; border: none; }
.jump-goto button:hover { background: var(--brand-red-dark); }
/* Khung con dấu: xám-nhạt khi KHÔNG phải đang chỉnh (có nhiều vị trí), đỏ khi đang chỉnh
   (chỉ 1 vị trí thì luôn "đang chỉnh" -> giữ đúng giao diện cũ). */
.stamp-box { position: absolute; box-sizing: border-box; border: 2px dashed #999; background: rgba(255,255,255,0.7); cursor: move; pointer-events: none; z-index: 2; }
.stamp-box.active { border-color: var(--brand-red); background: rgba(255,255,255,0.85); z-index: 3; }
.stamp-box img { width: 100%; height: 100%; display: block; }
/* Số thứ tự vị trí — góc trên-trái, bấm để chọn sửa vị trí này */
.stamp-badge {
  position: absolute; top: -9px; left: -9px; width: 20px; height: 20px; border-radius: 50%;
  background: #888; color: #fff; border: 2px solid #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; pointer-events: auto; z-index: 3; cursor: pointer;
}
.stamp-box.active .stamp-badge { background: var(--brand-red); }
/* Chấm kéo giãn ở góc trên-phải khung con dấu — to hơn bình thường để bấm/chạm dễ trên điện thoại */
.stamp-resize-handle {
  position: absolute; top: -9px; right: -9px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand-red); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--brand-red);
  cursor: nesw-resize; pointer-events: auto; touch-action: none; z-index: 3;
}
.stamp-resize-handle:hover { background: var(--brand-red-dark); }
/* Nút xoá vị trí phụ — góc dưới-phải, chỉ hiện khi vị trí đó đang được chọn */
.stamp-remove-btn {
  position: absolute; bottom: -9px; right: -9px; width: 20px; height: 20px; border-radius: 50%;
  background: #888; color: #fff; border: 2px solid #fff; font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center; pointer-events: auto; z-index: 3; cursor: pointer;
}
.stamp-remove-btn:hover { background: var(--brand-red-dark); }
/* Thanh chọn vị trí đóng dấu (khi tài liệu cần ký nhiều chỗ) */
.stamp-list-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed #eee; width: 100%; }
.stamp-list { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stamp-pill { background: #fff; color: #444; border: 1px solid #ccc; padding: 5px 12px; border-radius: 14px; font-size: 0.85em; cursor: pointer; }
.stamp-pill:hover { background: #f0f0f0; }
.stamp-pill.active { background: var(--brand-red); color: #fff; border-color: var(--brand-red); }
.stamp-pill-x { background: #fff; color: #999; border: 1px solid #ddd; border-radius: 50%; width: 22px; height: 22px; padding: 0; font-size: 0.75em; margin-left: -10px; cursor: pointer; }
.stamp-pill-x:hover { color: #fff; background: var(--brand-red-dark); border-color: var(--brand-red-dark); }
/* Trang đặt con dấu: mọi trang xếp dọc, cuộn xem hết, bấm thẳng vào trang muốn đóng dấu */
.place-toolbar.sticky { position: sticky; top: 0; z-index: 5; background: #fff; padding: 8px 0 10px; border-bottom: 1px solid #eee; margin-bottom: 10px; }
.place-info { flex-basis: 100%; }
.pages { user-select: none; }
.page-wrap {
  position: relative; max-width: 900px; margin: 0 auto 18px; background: #f3f3f3; border: 1px solid #ddd;
  cursor: crosshair; scroll-margin-top: 110px;
}
.page-wrap img { width: 100%; height: 100%; display: block; background: #fff; }
.page-wrap .page-label { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,0.55); color: #fff; font-size: 0.75em; padding: 2px 8px; border-radius: 10px; pointer-events: none; }
.page-wrap.has-stamp { outline: 3px solid var(--brand-red); }
.page-wrap.has-stamp .page-label { background: var(--brand-red); }
.badge:not(.ok):not(.warn):not(.danger):not(.info):not(.api) { background: #F2F4F7; color: #475467; }
.secondary-link { background: #fff; color: var(--brand-red); border: 1px solid var(--brand-red); margin-right: 6px; }
h2 { font-size: 1.05em; margin: 22px 0 6px; }
h3 { font-size: 0.95em; margin: 18px 0 6px; }
.warn-box { background: #FEF3F2; border: 1px solid #FBD5D2; border-left: 4px solid var(--brand-red); border-radius: 8px; padding: 9px 13px; font-size: 0.88em; }
.inline-check { display: flex; align-items: center; gap: 8px; font-size: 1em; color: #1a1a1a; }
.inline-check input { width: auto; margin: 0; }
.row-2 { display: flex; gap: 16px; }
.row-2 label { flex: 1; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 0.85em; }
.api-table th { width: 90px; vertical-align: top; color: #444; font-weight: 600; background: none; text-transform: none; font-size: 0.9em; letter-spacing: 0; }
.api-table td { word-break: break-word; }
.badge.api { background: #EEF2F6; color: #344054; border: 1px solid #D0D5DD; }
.ok-box { background: #F0FAF4; border: 1px solid #CDEBD8; border-left: 4px solid var(--brand-green); border-radius: 8px; padding: 9px 13px; font-size: 0.88em; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 0 4px; }
.tabs a { padding: 10px 16px; text-decoration: none; color: #4B5563; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 0.93em; font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--brand-red); }
.tabs a.active { color: var(--brand-red); border-bottom-color: var(--brand-red); font-weight: 600; }
.tabs .count { background: var(--brand-red); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 0.78em; margin-left: 4px; }
.bulk-bar { display: flex; align-items: center; gap: 14px; padding: 8px 0; flex-wrap: wrap; }
.bulk-bar .inline-check { margin: 0; }
.card.wide { max-width: 560px; }
fieldset.route { border: 1px solid #e3e3e3; border-radius: 6px; padding: 10px 14px; margin: 0 0 14px; }
fieldset.route legend { font-size: 0.9em; color: #444; padding: 0 6px; }
fieldset.route .inline-check { margin-bottom: 8px; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
table.flow td { vertical-align: top; padding: 12px 10px; border-bottom: 1px dashed #e5e5e5; }
table.flow td.who { width: 55%; }
table.flow td.state { text-align: right; }
.step { font-weight: 600; }
.step.done { color: var(--brand-green); }
.step.waiting { color: #b58900; }
.step.rejected { color: var(--brand-red); }
.review-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.review-form label { flex: 1 1 320px; margin-bottom: 0; }
.inline-input { display: inline-block; width: 220px; margin: 0 6px 0 0; padding: 7px 10px; border: 1px solid #ccc; border-radius: 6px; }
button.danger-text { color: var(--brand-red); }
.w-user { width: 130px; } .w-name { width: 190px; }
.tag { display: inline-block; background: #eef3f8; color: #2b4a6f; border-radius: 10px; padding: 1px 8px; font-size: 0.78em; margin-left: 4px; white-space: nowrap; }
td.pickcell input { width: 18px; height: 18px; }

/* ---------- Điện thoại / màn hình hẹp ---------- */
@media (max-width: 720px) {
  main { padding: 10px; }
  .card { padding: 14px; border-radius: 8px; }
  .card.narrow, .card.wide { margin: 10px auto; }
  h1 { font-size: 1.12em; }
  header.topbar { flex-wrap: wrap; gap: 6px 12px; padding: 8px 12px 0; min-height: 0; }
  .brand-logo { height: 34px; }
  .userbox { margin-left: auto; }
  .user-meta strong { max-width: 150px; }
  .user-meta small { white-space: normal; }
  .topnav { order: 3; flex-basis: 100%; overflow-x: auto; border-top: 1px solid var(--border); margin: 4px -12px 0; padding: 0 6px; }
  .topnav a { padding: 10px 10px; white-space: nowrap; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .button { text-align: center; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-num { font-size: 1.4em; }
  .filter-bar label, .filter-bar .grow { flex: 1 1 100%; }
  .filter-bar label input { min-width: 0; }
  .filter-actions { flex: 1 1 100%; }
  .filter-actions > * { flex: 1; text-align: center; }
  .row-between { flex-direction: column; align-items: stretch; gap: 8px; }
  .row-between .button { text-align: center; }
  .row-2 { flex-direction: column; gap: 0; }
  .tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .tabs a { padding: 8px 10px; font-size: 0.9em; }
  .bulk-bar { gap: 8px; }
  .bulk-bar .muted { flex-basis: 100%; }
  /* Bảng -> từng thẻ, mỗi ô có nhãn riêng (data-label) */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border: 1px solid #e5e5e5; border-radius: 8px; margin: 10px 0; padding: 8px 10px; background: #fff; }
  table.stack td { border: none; padding: 4px 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 0.92em; }
  table.stack td[data-label]::before { content: attr(data-label); color: #777; font-size: 0.8em; min-width: 84px; flex-shrink: 0; padding-top: 2px; align-self: flex-start; }
  table.stack td br { display: none; }                 /* xuống dòng do flex lo, không cần <br> */
  table.stack td small.badge { white-space: nowrap; }  /* nhãn cảnh báo giữ 1 dòng */
  table.stack td.pickcell::before { min-width: 84px; }
  table.stack td.pickcell.no-pick { display: none; }
  table.stack td.actions { flex-wrap: wrap; white-space: normal; }
  table.stack td.actions form, table.stack td.actions .button { margin: 3px 4px 3px 0; }
  table.stack td.actions::before { flex-basis: 100%; }
  table.stack td[colspan] { display: flex; }
  .inline-row { flex-wrap: wrap; }
  .inline-row input, .inline-row select { flex: 1 1 140px; width: auto; }
  .w-user, .w-name { width: auto; }
  button, .button { padding: 10px 14px; min-height: 40px; }   /* dễ bấm bằng ngón tay */
  .button.small, button.small, button.secondary.small { padding: 7px 10px; min-height: 34px; }
  .place-toolbar-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .place-toolbar-row select { width: 100%; }
  .place-toolbar.sticky { padding: 6px 0 8px; }
  .place-jump { gap: 6px; }
  #viewingLabel { flex-basis: 100%; order: 3; }
  .jump-goto { margin-left: 0; flex-basis: 100%; }
  .page-wrap { scroll-margin-top: 230px; margin-bottom: 12px; }
  table.flow td.who, table.flow td.state { display: block; width: 100%; text-align: left; padding: 8px 4px; }
  table.flow td.state { padding-top: 0; border-bottom: 1px dashed #e5e5e5; }
  table.flow td.who { border-bottom: none; }
  .review-form { flex-direction: column; align-items: stretch; }
  .review-form form.inline { display: block; margin: 0 0 8px; }
  .inline-input { width: 100%; margin: 0 0 6px; }
  .doc-actions .button { flex: 1 1 45%; text-align: center; }
  .thumbs .thumb-btn { width: 47%; } .thumbs img { width: 100%; }
  .viewer-bar { padding: 8px 10px; }
  .viewer-bar-btns { width: 100%; justify-content: space-between; }
  .viewer-bar button { flex: 1; padding: 9px 6px; font-size: 0.85em; }
  #viewerPageLabel { font-size: 0.85em; }
  .viewer-scroll { padding: 10px 6px 50px; gap: 10px; }
  .api-table th { width: 70px; }
  .mono { word-break: break-all; }
}
.thumbs { display: flex; gap: 12px; flex-wrap: wrap; }
.thumbs .thumb-btn {
  width: 150px; text-decoration: none; color: #444; font-size: 0.8em; text-align: center;
  background: none; border: none; padding: 0; font-family: inherit; cursor: pointer;
}
.thumbs img { width: 150px; border: 1px solid #ddd; background: #fff; display: block; margin-bottom: 4px; }
.thumbs .thumb-btn:hover img { border-color: var(--brand-red); }

/* ---------- Khung xem toàn bộ tài liệu (cuộn xem hết, không mở tab mới) ---------- */
.viewer-overlay {
  position: fixed; inset: 0; background: rgba(20, 20, 20, 0.94); z-index: 1000;
  display: flex; flex-direction: column;
}
.viewer-bar {
  position: sticky; top: 0; background: #1c1c1c; color: #fff; display: flex;
  justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid #333;
}
.viewer-bar-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.viewer-bar button {
  background: transparent; border: 1px solid rgba(255,255,255,0.4); color: #fff;
  padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 0.9em;
}
.viewer-bar button:hover { background: rgba(255,255,255,0.15); }
.viewer-scroll {
  /* Cố ý KHÔNG dùng display:flex ở đây: flex sẽ ép co chiều cao các trang vừa khung màn
     hình (flex-shrink) thay vì để chúng tràn ra và cuộn — làm mất hết tỉ lệ aspect-ratio.
     Dùng bố cục khối bình thường, mỗi trang tự canh giữa bằng margin. */
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 12px 60px;
}
/* aspect-ratio đặt bằng JS theo đúng tỉ lệ trang PDF -> khung giữ nguyên kích thước khi ảnh tải xong, không nhảy cuộn */
.viewer-page { max-width: 900px; width: 100%; margin: 0 auto 16px; background: #2a2a2a; min-height: 200px; }
.viewer-page img { width: 100%; height: 100%; display: block; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,0.5); object-fit: contain; }
/* ---------- File tham chiếu (kèm theo để xem xét, không ký) ---------- */
table.attach { margin-top: 8px; }
table.attach td { vertical-align: middle; }
.att-thumb { width: 64px; height: 64px; object-fit: cover; border: 1px solid #ddd; border-radius: 4px; display: block; background: #fff; }
.att-thumb:hover { border-color: var(--brand-red); }
.attach-add { margin-top: 10px; padding: 10px 12px; background: #fafafa; border: 1px dashed #ddd; border-radius: 6px; }
.attach-add input[type=file] { margin-top: 6px; }
.inline-row { display: inline-flex; gap: 6px; align-items: center; margin-right: 6px; }
.inline-row select, .inline-row input { margin-top: 0; padding: 5px 8px; font-size: 0.85em; width: auto; display: inline-block; }
button.small { padding: 5px 10px; font-size: 0.85em; }
tr.row-off td { color: #999; }
