:root {
  --bg: #f6f7fb;
  --card: #fff;
  --muted: #6b7280;
  --bd: #e5e7eb;
  --bd2: #d1d5db;
  --accent: #2563eb;
  --accent-ghost: rgba(37, 99, 235, .08);
  --sticky: #fafbff;
  --blue:#005eb8;
}
html, body { height: 100%; overflow: hidden; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color: #111827;
}
/* .page {
  max-width: 1760px;
  margin: 6px auto;
  padding: 0 8px;
} */
.page {
  max-width: 1760px;
  margin: 4px auto;
  padding: 0 8px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.filter {
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 10px;
/*   padding: 7px 10px;
  margin-bottom: 8px; */
  flex: 0 0 auto;
  padding: 6px 10px;
  margin-bottom: 6px;
}
.filter .row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filter label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  min-width: 90px;
}
.filter input[type="text"] {
  width: 120px;
}

#fPatientName,
#fRequestingPhysician {
  width: 140px;
}

.filter input, .filter select {
  height: 32px;
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 0 8px;
  box-sizing: border-box;
}
#fStatus { width: 140px; }
#fReportStatus { width: 190px; }
.multi-check-source { display: none !important; }
.multi-check {
  position: relative;
  min-width: 120px;
}
.multi-check-toggle {
  width: 100%;
  height: 32px;
  border: 1px solid var(--bd);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: #111827;
  cursor: pointer;
}
.multi-check-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.multi-check-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 80;
  display: none;
  min-width: 100%;
  width: 100%;
  max-width: none;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  padding: 0;
  border: 1px solid var(--bd);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .12);
}
.multi-check.open .multi-check-menu { display: block; }
.filter .multi-check-option,
.multi-check-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 0;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.multi-check-option:hover { background: #eef4ff; }
.filter .multi-check-option input,
.multi-check-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  justify-self: start;
}
.filter .multi-check-option span,
.multi-check-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.multi-check-empty {
  padding: 8px;
  color: #6b7280;
  font-size: 13px;
}
.filter-btns {
  display: flex;
  gap: 10px;
  margin-left: auto;
}
.btn.primary { background: var(--accent); color:#fff; border:none; min-width: 110px; padding: 10px 20px; font-weight: 600; }
.btn.ghost { background:#fff; border:1px solid var(--bd); min-width: 110px; padding: 10px 20px; font-weight: 600; }
.btn.quick { background:#fff; border:1px solid var(--bd); }
.grid-card {
  position: relative;
  display: flex;
  flex-direction: column;
  /* height: calc(100vh - 134px); */
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 10px;
  overflow: hidden;
  
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
.topbar {
  display:flex;
  flex-wrap: wrap;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-bottom:1px solid var(--bd);
  background:#fff;
  z-index: 15;
}
.topbar .spacer { flex:1; }
.topbar-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.topbar-refresh { display: none !important; flex-wrap:wrap; }
.btn-column-chooser { margin-left:auto; }
.muted { color:var(--muted); }
.btn {
  height:35px;
  padding:0 12px;
  border:1px solid var(--bd);
  border-radius:8px;
  background:#fff;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  text-align: center;
  justify-content: center;
  gap:6px;
}

.btn.small { height:30px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity:.5; cursor:not-allowed; }
select, input[type="number"] {
  height: 32px;
  border:1px solid var(--bd);
  border-radius:8px;
  padding:0 8px;
  background:#fff;
}
.grid-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#grid { width:max-content; min-width:100%; table-layout:fixed; }
table { border-collapse: separate; border-spacing: 0; min-width:1200px; }
thead th, tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--bd);
  background: #fff;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  background: var(--sticky);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--bd2);
  user-select: none;
  background-clip: padding-box;
  isolation: isolate;
}
thead th.sortable:hover { background: var(--accent-ghost); z-index: 60; }
thead th .sort-ind { margin-left: 6px; font-size: 12px; color: var(--muted); }
.th-label { display:inline-block; max-width: calc(100% - 18px); overflow:hidden; text-overflow:ellipsis; vertical-align:bottom; }
tbody tr:nth-child(even) td { background: #fcfdff; }
tbody tr:hover td { background: #f8fbff; }
#grid tbody tr.selected td {
  background: #e5e7eb;
  border-color: #e5e7eb !important;
  box-shadow: none !important;
  outline: none !important;
}
th.sticky, td.sticky {
  position: sticky;
  background-clip: padding-box;
  box-shadow: 1px 0 0 var(--bd2);
}
th.sticky {
  background: var(--sticky);
}
td.sticky {
  z-index: 4;
}
th.sticky::after,
td.sticky::after {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  width: 1px;
  height: 100%;
  background: var(--bd2);
  pointer-events: none;
}

thead th.sticky:hover {
  background: #eef4ff;
  z-index: 80 !important;
}
.badge {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:1px 8px;
  border-radius:18px;
  border:1px solid var(--bd2);
  background:#fff;
  font-size:12px;
  line-height: 1.5;
}
.status-icon-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  overflow: visible;
}
.status-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 5px;
  background: #fff;
  color: #64748b;
  font: inherit;
  cursor: help;
}
button.status-icon { cursor: pointer; }
.status-icon:hover { box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.status-icon.is-muted { color:#94a3b8; background:#f8fafc; }
.status-icon.is-info { color:#2563eb; background:#eff6ff; }
.status-icon.is-success { color:#15803d; background:#f0fdf4; }
.status-icon.is-warning { color:#b45309; background:#fffbeb; }
.status-icon.is-purple { color:#6d28d9; background:#f5f3ff; }
.status-icon.is-danger { color:#dc2626; background:#fef2f2; }
.status-icons-hidden {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: #94a3b8;
}
.icon-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.icon-legend-label {
  margin-right: 3px;
  color: #581c87;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.pagination.topbar {
  flex: 0 0 auto;
  border-top: 1px solid var(--bd);
  border-bottom: 0;
}
.status-summary-header { padding-right: 42px; }
.status-summary-header .th-label { max-width: calc(100% - 28px); }
.status-filter-button {
  position: absolute;
  top: 50%;
  right: 11px;
  width: 25px;
  height: 25px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  z-index: 3;
}
.status-filter-button:hover,
.status-filter-button.has-filter {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}
.status-filter-button.has-filter::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #dc2626;
}
.status-popover {
  position: fixed;
  z-index: 900;
  width: min(330px, calc(100vw - 16px));
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .18);
  color: #1f2937;
}
.status-popover-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 4px 7px;
  border-bottom: 1px solid #e5e7eb;
}
.status-popover-title > i { width: 18px; color: #2563eb; text-align: center; }
.status-legend-list,
.status-filter-list {
  display: grid;
  gap: 3px;
  margin-top: 6px;
}
.status-legend-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 3px 4px;
  border-radius: 5px;
}
.status-legend-item:hover { background: #f8fafc; }
.status-legend-item > span:last-child { display: grid; min-width: 0; }
.status-legend-item strong { font-size: 12px; }
.status-legend-item small { color: #64748b; font-size: 11px; }
.status-filter-reset {
  margin-left: auto;
  padding: 3px 6px;
  border: 0;
  background: transparent;
  color: #2563eb;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.status-filter-list label {
  display: grid;
  grid-template-columns: 18px 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 2px 5px;
  border-radius: 5px;
  cursor: pointer;
}
.status-filter-list label:hover { background: #f8fafc; }
.status-filter-list input {
  width: 16px;
  height: 16px;
  margin: 0;
}
.status-filter-list .status-icon,
.status-legend-item .status-icon {
  width: 25px;
  height: 25px;
  flex-basis: 25px;
}
.status-SCHEDULED { background:#ecfdf5; border-color:#10b981; color:#065f46; }
.status-SCHEDULE { background:#f8fafc; border-color:#94a3b8; color:#334155; }
.status-IN_PROGRESS { background:#fffbeb; border-color:#f59e0b; color:#92400e; }
.status-CANCELLED { background:#fef2f2; border-color:#ef4444; color:#991b1b; }
.status-COMPLETED { background:#eff6ff; border-color:#3b82f6; color:#1e40af; }
.report-Rỗng { background:#f8fafc; border-color:#94a3b8; color:#334155; }
.report-Rỗng, .report-EMPTY { background:#f8fafc; border-color:#94a3b8; color:#334155; }
.report-Draft, .report-DRAFT { background:#fff7ed; border-color:#fb923c; color:#9a3412; }
.report-VTYT { background:#f0f9ff; border-color:#38bdf8; color:#075985; }
.report-Final, .report-FINAL, .report-COMPLETED { background:#ecfdf5; border-color:#22c55e; color:#166534; }
.report-FINAL_PENDING_SIGN, .report-FINAL_PENDING_SIGNED { background:#fff7ed; border-color:#fdba74; color:#9a3412; }
.report-FINAL_SIGNED, .report-SIGNED_FINAL { background:#dcfce7; border-color:#22c55e; color:#14532d; }
.nd-Y, .send-Đã-gửi { background:#ecfdf5; border-color:#22c55e; color:#166534; }
.nd-N, .send-Chưa-gửi { background:#fef2f2; border-color:#ef4444; color:#991b1b; }
.report-link{cursor:pointer;font:inherit}
.report-link:hover{box-shadow:0 0 0 2px rgba(37,99,235,.12);border-color:#60a5fa}
.ris-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}
.ris-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.ris-switch-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background-color: #ccc;
  border-radius: 999px;
  transition: 0.2s;
}
.ris-switch-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  top: 2px;
  background-color: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 0 2px rgba(0,0,0,.3);
}
.ris-switch input:checked + .ris-switch-slider {
  background-color: #0d6efd;
}
.ris-switch input:checked + .ris-switch-slider::before {
  transform: translateX(18px);
}
.column-panel {
  position: absolute;
  top: 62px;
  right: 12px;
  width: 360px;
  max-height: 70vh;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
  z-index: 30;
}
.column-panel__header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:12px 14px;
  border-bottom:1px solid var(--bd);
}
.column-panel__actions {
  display:flex;
  gap:8px;
}
.column-panel__list {
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:8px 10px;
  padding:12px 14px 14px;
  max-height: calc(70vh - 60px);
  overflow:auto;
}
.column-item {
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  color:#1f2937;
}
.column-item input { margin: 0; }
.column-item span {
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.empty-row td {
  text-align:center;
  color:#6b7280;
  padding:20px;
}
@media (max-width: 1200px) {
  .icon-legend { width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .topbar-actions { width: auto; order: 3; }
  .topbar-refresh { width: 100%; order: 4; margin-left: 0 !important; }
  .btn-column-chooser { order: 5; margin-left: auto; }
  .column-panel { width: min(92vw, 480px); }
}


.topbar .title{font-size:16px; font-weight:700; color:var(--blue); }
.filter .row{row-gap:8px;}
.filter label{gap:4px;}
.filter-btns{gap:8px;}
.btn.primary,.btn.ghost{min-width:96px;padding:8px 16px;}
#grid tbody td{padding-top:6px;padding-bottom:6px;line-height:1.25;}
#grid thead th{padding-top:8px;padding-bottom:8px;}
#grid tbody td, #grid thead th { border-right:1px solid #edf2f7; }
#grid thead th:last-child, #grid tbody td:last-child { border-right:none; }
#grid thead th:hover{ z-index: 120 !important; }
#grid thead th .th-label{pointer-events:none;}
.grid-wrap{ background:#fff; }
.btn-column-chooser{ margin-left: auto; background:#f8fafc; }


.th-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  z-index: 120;
}
.th-resizer::before {
  content: '';
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 4px;
  width: 2px;
  border-radius: 999px;
  background: transparent;
  transition: background .15s ease;
}
#grid thead th:hover .th-resizer::before,
#grid thead th.is-resizing .th-resizer::before,
#grid thead th .th-resizer:hover::before {
  background: #93c5fd;
}
body.col-resizing,
body.col-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
#grid thead th.is-resizing {
  background: #dbeafe !important;
}
#grid thead th { overflow: visible; }
#grid thead th .th-label { pointer-events: none; }
#grid thead th .sort-ind { pointer-events: none; }

    .quick-range { display:flex; flex-direction:column; gap:6px; min-width: 260px; }
    .quick-range .qr-label { font-size: 12px; color: #6b7280; margin-left: 2px; }
    .quick-range .qr-group { display:flex; flex-wrap:wrap; gap:6px; }
    .quick-range .btn.qr { height:28px; padding:0 10px; font-size:12px; border-radius:999px; }
    .quick-range .btn.qr.active { background: rgba(0,94,184,.10); border-color: rgba(0,94,184,.35); }
