/* Giao diện "Bút dạ quang" (25/11/2026; frontend-design + UI UX Pro Max)
   Ý tưởng: người phân tích thầu tô vàng con số quan trọng trên bảng kết quả → các số chính có vệt dạ quang.
   - Một họ chữ Archivo (có tiếng Việt): tiêu đề kéo rộng (font-stretch 125%), nội dung bản thường.
   - Thanh điều hướng dọc màu mực chàm; nội dung trên nền giấy, khung phẳng không bóng.
   - Chuyển động duy nhất: vệt dạ quang quét qua số liệu khi hiện ra (tắt khi người dùng chọn giảm chuyển động).
   - Màu chuỗi biểu đồ giữ nguyên bảng 8 màu đã kiểm định (dataviz). */
@import url("https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,100..900&display=swap");
:root {
  --ink: #1e1b4b;              /* mực chàm: chữ chính, thanh bên */
  --ink-2: #4b4a6b;            /* chữ phụ — 8:1 trên trắng */
  --muted: #6b6a88;            /* chú thích, trục — 5:1 */
  --paper: #f6f7fb;            /* nền trang */
  --surface: #ffffff;
  --line: #e4e2f3;
  --grid: #ecebf5;
  --axis: #cfcde3;
  --primary: #4338ca;          /* chàm sáng: nút, liên kết */
  --primary-2: #3730a3;
  --lilac: #eceafe;            /* đầu bảng, mục đang chọn */
  --lilac-2: #f5f4ff;          /* rê chuột */
  --hl: #ffe45c;               /* bút dạ quang */
  --up-bg: #e5effb;  --up-ink: #1c4fa0;     /* tăng: xanh dương */
  --down-bg: #fde8e7; --down-ink: #a12c2b;  /* giảm: đỏ (không dùng xanh lá – đỏ, khó với người mù màu) */
  --wide: 125%;
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3 { color: var(--ink); }
h1 { margin: 0; font-size: 28px; line-height: 1.02; font-weight: 800; font-stretch: var(--wide); letter-spacing: -.01em; }
h2 { margin: 0 0 4px; font-size: 19px; line-height: 1.2; font-weight: 750; font-stretch: 115%; }
h3 { margin: 0 0 6px; font-size: 14px; font-weight: 650; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
a, button, select, input, .chip, .link { transition: background-color .18s ease, border-color .18s ease, color .18s ease; }
button, select, .chip, .link, .tabs a { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---------- Khung trang: thanh bên + nội dung ---------- */
.layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 28px 22px 24px;
  background: var(--ink); color: #dcdaf7;
}
.rail h1 { color: #fff; font-size: 24px; text-wrap: balance; }
.rail .eyebrow { margin: 0 0 10px; color: #aeabe0; font-size: 12.5px; line-height: 1.4; }
.rail :focus-visible { outline-color: var(--hl); }
.tabs { display: flex; flex-direction: column; gap: 4px; }
.tabs a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #dcdaf7; text-decoration: none; font-weight: 600; font-size: 14.5px; }
.tabs a::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #8e8ad0; flex: none; }
.tabs a:hover { background: rgb(255 255 255 / 7%); color: #fff; }
.tabs a[aria-current="page"] { background: rgb(255 255 255 / 10%); color: #fff; }
.tabs a[aria-current="page"]::before { background: var(--hl); border-color: var(--hl); }
.rail-meta { margin: auto 0 0; padding-top: 16px; border-top: 1px solid rgb(255 255 255 / 14%); color: #aeabe0; font-size: 12.5px; line-height: 1.7; white-space: pre-line; font-variant-numeric: tabular-nums; }

.page { min-width: 0; }
.wrap { width: min(1180px, 100% - 56px); margin: 0 auto; }
main { padding: 28px 0 40px; }
footer { padding: 8px 0 40px; }

/* ---------- Bộ lọc, nút ---------- */
.filter-row { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end; margin-bottom: 10px; }
.field { display: grid; gap: 5px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.field.grow { flex: 1 1 220px; }
.field input, .field select { min-width: 190px; height: 40px; padding: 0 12px; border: 1px solid var(--axis); border-radius: 12px; background: var(--surface); font: inherit; font-size: 14px; font-weight: 400; color: var(--ink); }
.field-hospital .combo-input { min-width: 290px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgb(67 56 202 / 16%); }
.field select:disabled { background: var(--grid); color: var(--muted); }
.segmented { display: inline-flex; flex-wrap: wrap; padding: 4px; gap: 2px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.segmented button:hover { color: var(--ink); background: var(--lilac-2); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.button { height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--primary); background: var(--primary); font: inherit; font-size: 13.5px; font-weight: 650; color: #fff; }
.button:hover:not(:disabled) { background: var(--primary-2); border-color: var(--primary-2); }
.button.ghost { background: transparent; color: var(--primary); border-color: var(--axis); }
.button.ghost:hover:not(:disabled) { border-color: var(--primary); background: var(--lilac-2); }
.button:disabled { opacity: .45; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-weight: 600; text-align: left; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Ô chọn có gõ để lọc (public/combobox.js) ---------- */
.combo { position: relative; }
.combo-input { width: 100%; }
.combo-list { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 100%; width: max-content; max-width: min(460px, 90vw); max-height: 340px; overflow: auto; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgb(30 27 75 / 18%); }
.combo-list li { padding: 8px 12px; border-radius: 9px; color: var(--ink); font-size: 14px; font-weight: 400; cursor: pointer; }
.combo-list li:hover { background: var(--lilac-2); }
.combo-list li[aria-selected="true"] { background: var(--lilac); color: var(--primary-2); font-weight: 600; }
.combo-list .combo-empty { color: var(--muted); cursor: default; }
.combo-list .combo-empty:hover { background: none; }

/* ---------- Khung nội dung: phẳng, không bóng ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px 24px; margin-top: 18px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 4px; }
.card-note { margin: 14px 0 0; max-width: 92ch; color: var(--muted); font-size: 13px; line-height: 1.6; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card { margin-top: 0; }
.stack { display: grid; gap: 18px; margin-top: 18px; }

/* ---------- Dải số liệu: một khung, chia bằng vạch; số tô dạ quang ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.tile { background: var(--surface); padding: 20px 24px 18px; }
.tile .label { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.tile .value {
  width: fit-content; margin: 8px 0 4px -4px; padding: 0 6px 0 4px;
  font-size: 34px; line-height: 1.1; font-weight: 800; font-stretch: var(--wide); letter-spacing: -.01em; font-variant-numeric: tabular-nums;
  background: linear-gradient(transparent 56%, var(--hl) 56%, var(--hl) 92%, transparent 92%) no-repeat 0 0 / 100% 100%;
  animation: hl-swipe .7s cubic-bezier(.2, .7, .2, 1) both;
}
.tile:nth-child(2) .value { animation-delay: .12s; }
.tile:nth-child(3) .value { animation-delay: .24s; }
.tile:nth-child(4) .value { animation-delay: .36s; }
@keyframes hl-swipe { from { background-size: 0% 100%; } to { background-size: 100% 100%; } }
.tile .sub { font-size: 12.5px; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 4px; font-size: 12.5px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend-swatch.is-dashed { background: transparent !important; border: 2px dashed; border-radius: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { border: 1px solid var(--axis); background: var(--surface); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12.5px; color: var(--ink-2); }
.chip:hover { border-color: var(--primary); color: var(--ink); }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; font-weight: 600; }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
.data-table thead th { color: var(--ink); font-size: 12.5px; font-weight: 650; background: var(--lilac); position: sticky; top: 0; }
.data-table thead th:first-child { border-top-left-radius: 10px; }
.data-table thead th:last-child { border-top-right-radius: 10px; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table tbody tr:hover { background: var(--lilac-2); }
.data-table .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.data-table td.up { background: var(--up-bg); }
.data-table td.down { background: var(--down-bg); }
.delta { font-size: 11.5px; font-weight: 650; display: block; }
.delta.up { color: var(--up-ink); }
.delta.down { color: var(--down-ink); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--grid); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: #e2f6ee; color: #0d6e4c; }
.badge.warn { background: #fff3c4; color: #7a5300; }
.badge.new { background: var(--lilac); color: var(--primary-2); }
.badge.stop { background: var(--down-bg); color: var(--down-ink); }
.summary-line { margin: 12px 0; font-size: 13px; color: var(--ink-2); }
#view-tra-cuu > .table-wrap { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
#view-tra-cuu .data-table thead th { border-radius: 0; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.empty { color: var(--muted); padding: 18px 0; }

/* ---------- Biểu đồ (dùng chung charts.js / timeline.js của dashboard) ---------- */
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick, .timeline-svg .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .tick-sub, .timeline-svg .tick-sub { font-size: 10px; }
.chart .series-line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-dot { stroke: var(--surface); stroke-width: 2; }
.chart .direct-label { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-title { display: flex; align-items: center; gap: 6px; }
.chart-tooltip { position: absolute; z-index: 5; min-width: 190px; max-width: 320px; padding: 10px 12px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: 0 12px 30px rgb(30 27 75 / 25%); font-size: 12px; pointer-events: none; }
.chart-tooltip strong { display: block; margin-bottom: 6px; }
.tt-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2px 8px; padding: 3px 0; }
.tt-swatch { width: 9px; height: 9px; border-radius: 50%; }
.tt-label { overflow: hidden; color: #cfcdf0; text-overflow: ellipsis; white-space: nowrap; }
.tt-value { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.tt-note { grid-column: 2 / 4; color: #aeabe0; font-size: 11px; }
.trend-multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; }
.legend-mini { margin-top: 0; }
.trend-empty { color: var(--muted); }

.timeline-svg { display: block; overflow: visible; }
.timeline-svg .tl-year { stroke: var(--axis); stroke-width: 1; }
.timeline-svg .tl-quarter { stroke: var(--grid); stroke-width: 1; }
.timeline-svg .tl-now { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; }
.timeline-svg .tl-label { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline-svg .tl-qty { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }

.prose { max-width: 76ch; line-height: 1.65; font-size: 14.5px; }
.prose li { margin-bottom: 4px; }
.prose li::marker { color: var(--primary); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Máy tính bảng, điện thoại: thanh bên thành thanh trên */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }   /* minmax(0,…): bảng rộng không ép trang tràn ngang */
  .rail { position: static; height: auto; gap: 14px; padding: 18px 16px 12px; }
  .rail .eyebrow { margin-bottom: 6px; }
  .rail h1 { font-size: 22px; }
  .tabs { flex-direction: row; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
  .tabs a { white-space: nowrap; min-height: 44px; }
  .rail-meta { margin: 0; padding-top: 10px; line-height: 1.5; }
  .wrap { width: calc(100% - 28px); }
  main { padding-top: 18px; }
}
@media (max-width: 760px) {
  /* Điện thoại: chạm được (≥ 44px) */
  .button, .field input, .field select { height: 44px; }
  .segmented button, .chip { min-height: 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .trend-multiples { grid-template-columns: 1fr; }
  .field input, .field select, .field-hospital .combo-input { min-width: 0; width: 100%; }
  .field { flex: 1 1 100%; }
  .tile .value { font-size: 28px; }
}
