/* Xe ôtô Net2 – giao diện chung. Không tải gì từ bên ngoài. */
:root {
  --nen: #f4f6f9; --the: #ffffff; --chu: #1d2430; --mo: #5b6577; --vien: #dde2e9; --nhat: #eef2f7;
  --chinh: #1f6feb; --chinh-dam: #1559c4; --nguy: #c62828; --tot: #15803d;
  --bl: #1f6feb; --cy: #0e8aa8; --yl: #eab308; --yl-chu: #3b2a05; --br: #9a7656; --rd: #d92d20;
  --bong: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --bo: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --nen: #11151c; --the: #1a2029; --chu: #e6eaf0; --mo: #9aa4b5; --vien: #2c3442; --nhat: #222a35;
    --chinh: #3b82f6; --chinh-dam: #2563eb; --nguy: #ef5350; --tot: #4ade80;
    --bl: #2f6fd6; --cy: #0f8fae; --yl: #d6a908; --yl-chu: #241903; --br: #7d6249; --rd: #c53a2e;
    --bong: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --nen: #11151c; --the: #1a2029; --chu: #e6eaf0; --mo: #9aa4b5; --vien: #2c3442; --nhat: #222a35;
  --chinh: #3b82f6; --chinh-dam: #2563eb; --nguy: #ef5350; --tot: #4ade80;
  --bl: #2f6fd6; --cy: #0f8fae; --yl: #d6a908; --yl-chu: #241903; --br: #7d6249; --rd: #c53a2e;
  --bong: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--nen); color: var(--chu); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--chinh); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
.mo { color: var(--mo); }
.nho { font-size: 13px; }

/* Đầu trang */
.dau { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px max(16px, env(safe-area-inset-left)); background: var(--the); border-bottom: 1px solid var(--vien); }
.ten-app { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--chu); text-decoration: none; }
.menu { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.menu a { padding: 6px 10px; border-radius: 8px; color: var(--mo); text-decoration: none; font-weight: 500; }
.menu a:hover { background: var(--nhat); color: var(--chu); }
.menu a[aria-current="page"] { background: var(--nhat); color: var(--chinh); }
.tai-khoan { display: flex; align-items: center; gap: 6px; }
.ten-nd { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mo); font-size: 14px; }

.than { max-width: 1200px; margin: 0 auto; padding: 16px; }
.tieu-de-trang { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* Nút, ô nhập */
.nut, .nut-nho { font: inherit; border: 1px solid var(--vien); background: var(--the); color: var(--chu); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.nut-nho { padding: 4px 9px; min-height: 30px; font-size: 14px; }
.nut:hover, .nut-nho:hover { background: var(--nhat); }
.nut-chinh { background: var(--chinh); border-color: var(--chinh); color: #fff; font-weight: 600; }
.nut-chinh:hover { background: var(--chinh-dam); }
.nut-nguy { color: var(--nguy); border-color: var(--nguy); }
.nut-to { padding: 12px 20px; font-size: 16px; }
.nut:focus-visible, .nut-nho:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--chinh); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--chu); background: var(--the); border: 1px solid var(--vien); border-radius: 8px; padding: 7px 9px; min-height: 36px; }
textarea { resize: vertical; }
.thanh-loc { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.thanh-loc label { display: flex; align-items: center; gap: 6px; color: var(--mo); font-size: 14px; }
.o-chon { display: flex; align-items: center; gap: 6px; }
.o-chon input { min-height: 0; width: 18px; height: 18px; }

.khung { background: var(--the); border: 1px solid var(--vien); border-radius: var(--bo); padding: 14px; margin: 14px 0; box-shadow: var(--bong); }
.bao-loi { color: var(--nguy); background: color-mix(in srgb, var(--nguy) 10%, transparent); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }

/* Thẻ tổng hợp */
.luoi-the { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.the { border-radius: var(--bo); padding: 12px; color: #fff; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--bong);
  -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.the.bl { background: var(--bl); } .the.cy { background: var(--cy); } .the.br { background: var(--br); }
.the.yl { background: var(--yl); color: var(--yl-chu); }
.the button { font: inherit; color: inherit; background: none; border: 0; text-align: left; cursor: pointer; border-radius: 6px; padding: 2px 6px; margin: 0 -6px; width: calc(100% + 12px); }
.the button:hover, .the button[aria-pressed="true"] { background: rgba(255, 255, 255, .22); }
.the .the-ten { font-weight: 600; font-size: 14px; }
.the .the-so { font-size: 34px; font-weight: 800; line-height: 1.1; }
.the .dong-nhom { display: flex; justify-content: space-between; font-size: 14px; }
.the .dong-nhom b { font-variant-numeric: tabular-nums; }
.luoi-thue { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
.the.rd { background: var(--rd); }

.chi-tiet { margin-top: 12px; }
.chi-tiet-dau { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.chi-tiet-dau h2 { margin: 0; }

/* Bảng */
.cuon-ngang { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bang { width: 100%; border-collapse: collapse; background: var(--the); font-size: 14px; }
.bang th, .bang td { padding: 7px 9px; border-bottom: 1px solid var(--vien); text-align: left; vertical-align: top; }
.bang th { background: var(--nhat); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
.co-sap-xep th[data-k] { cursor: pointer; user-select: none; }
.co-sap-xep th[data-k]::after { content: " ⇅"; color: var(--mo); font-weight: 400; }
.co-sap-xep th[aria-sort="ascending"]::after { content: " ▲"; color: var(--chinh); }
.co-sap-xep th[aria-sort="descending"]::after { content: " ▼"; color: var(--chinh); }
.bang tr.mo-di td { color: var(--mo); }
.bang td b { white-space: nowrap; }
.bang td.so { text-align: right; font-variant-numeric: tabular-nums; }
.nhan { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 13px; background: var(--nhat); white-space: nowrap; }
.nhan.D { background: color-mix(in srgb, var(--cy) 22%, transparent); }
.nhan.P { background: color-mix(in srgb, var(--yl) 28%, transparent); }
.nhan.loi { background: color-mix(in srgb, var(--nguy) 18%, transparent); color: var(--nguy); }
.nhan.tot { background: color-mix(in srgb, var(--tot) 18%, transparent); }
.trong { text-align: center; color: var(--mo); padding: 24px; }

/* Biểu đồ thanh ngang */
.bieu-do { display: grid; gap: 4px; }
.cot-bd { display: grid; grid-template-columns: minmax(110px, 220px) 1fr 32px; align-items: center; gap: 8px; font-size: 13px; }
.cot-bd .ten { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cot-bd .thanh { background: var(--nhat); border-radius: 5px; height: 12px; }
.cot-bd .thanh i { display: block; height: 12px; border-radius: 5px; background: var(--bl); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.cot-bd b { text-align: right; font-variant-numeric: tabular-nums; }
.chua-dung { margin-top: 12px; font-size: 13px; color: var(--nguy); }
.chua-dung span { display: inline-block; background: var(--rd); color: #fff; border-radius: 5px; padding: 1px 7px; margin: 3px 4px 0 0;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* Hộp thoại */
.hop { border: 1px solid var(--vien); border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--the); color: var(--chu); }
.hop::backdrop { background: rgba(0, 0, 0, .45); }
.bieu-mau { display: grid; gap: 10px; padding: 18px; }
.bieu-mau label { display: grid; gap: 4px; font-size: 14px; color: var(--mo); }
.bieu-mau label.o-chon { display: flex; color: var(--chu); }
.bieu-mau input, .bieu-mau select, .bieu-mau textarea { width: 100%; }
.bieu-mau .o-chon input { width: 18px; }
.hai-cot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nhom-chon { border: 1px solid var(--vien); border-radius: 8px; display: flex; gap: 16px; flex-wrap: wrap; }
.hang-nut { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.gian { flex: 1; }

.hop-dang-nhap { max-width: 420px; margin: 8vh auto; text-align: center; background: var(--the); border: 1px solid var(--vien);
  border-radius: 14px; padding: 28px 22px; box-shadow: var(--bong); display: grid; gap: 12px; justify-items: center; }

.thong-bao { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; background: var(--chu); color: var(--nen);
  padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.thong-bao.loi { background: var(--nguy); color: #fff; }
pre.json { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; max-width: 360px; }

/* Điện thoại */
@media (max-width: 860px) {
  .luoi-the { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .than { padding: 12px; }
  .luoi-the, .luoi-thue { grid-template-columns: 1fr; }
  .the .the-so { font-size: 28px; }
  .hai-cot { grid-template-columns: 1fr; }
  .ten-nd { display: none; }
  .dau { gap: 6px 10px; }
  .tai-khoan { margin-left: auto; }
  .menu { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
  .menu a { white-space: nowrap; }
  .cot-bd { grid-template-columns: 110px 1fr 28px; }
}

/* In A4 */
@page { size: A4 portrait; margin: 12mm; }
@media print {
  :root { --nen: #fff; --the: #fff; --chu: #000; --mo: #444; --vien: #bbb; --nhat: #eee; color-scheme: light; }
  body { font-size: 11pt; background: #fff; }
  .noprint, .dau, .thanh-loc, .thong-bao, .hop { display: none !important; }
  .than { max-width: none; padding: 0; }
  .luoi-the { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .the { padding: 8px; box-shadow: none; }
  .the .the-so { font-size: 22pt; }
  .the .dong-nhom { font-size: 9pt; }
  .khung { box-shadow: none; break-inside: avoid; padding: 8px; margin: 8px 0; }
  .bang { font-size: 9pt; }
  .bang th { position: static; white-space: normal; }
  .cuon-ngang { overflow: visible; }
  .bang th, .bang td { padding: 3px 4px; }
  .nhan { white-space: normal; padding: 0 4px; }
  .cot-bd { grid-template-columns: 150px 1fr 26px; font-size: 9pt; }
  tr, .cot-bd { break-inside: avoid; }
}
