:root {
  --nen: #f3f5f8; --the: #ffffff; --chu: #1c2430; --phu: #5f6b7a; --vien: #d9dee5;
  --chinh: #1f4e79; --chinh-nhat: #e6eef7; --do: #c62828; --xanh: #2e7d32; --vang: #fff4d6;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--nen); color: var(--chu); font-size: 15px; }
.an { display: none !important; }
h1, h2, h3 { margin: 0 0 10px; }
h2 { font-size: 18px; } h3 { font-size: 15px; margin-top: 16px; }

.the { background: var(--the); border: 1px solid var(--vien); border-radius: 10px; padding: 14px; margin: 12px 0; }
.dang-nhap { max-width: 360px; margin: 12vh auto; display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--phu); }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid var(--vien); border-radius: 8px; width: 100%; background: #fff; color: var(--chu); }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--chinh); border-color: transparent; }

.nut { font: inherit; padding: 9px 14px; border: 1px solid var(--vien); background: #fff; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.nut.chinh { background: var(--chinh); color: #fff; border-color: var(--chinh); font-weight: 600; }
.nut.nho { padding: 4px 10px; font-size: 13px; }
.nut:disabled { opacity: .5; cursor: default; }
.loi { color: var(--do); min-height: 1em; margin: 0; }
.tb { min-height: 1em; margin: 8px 0 0; }
.tb.ok { color: var(--xanh); } .tb.sai { color: var(--do); }
.nhan { color: var(--phu); font-size: 13px; }

.dau { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 16px; background: var(--chinh); color: #fff; }
.logo { font-weight: 700; }
#tab { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
#tab button { font: inherit; background: transparent; color: #dfe8f3; border: 0; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
#tab button.dang-chon { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.nguoi { font-size: 13px; }
main { max-width: 1200px; margin: 0 auto; padding: 0 16px 40px; }

.o-tim { position: relative; margin-top: 4px; }
.o-tim input { padding-right: 40px; }
.o-tim input.da-chon { background: var(--chinh-nhat); font-weight: 600; border-color: var(--chinh); }
.nut-xoa { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--phu); cursor: pointer; border-radius: 6px; }
.nut-xoa:hover { background: var(--nen); color: var(--chu); }
.thanh .o-tim-th { flex: 1; min-width: 220px; margin: 0; }
.thanh .o-tim-th input { width: 100%; min-width: 0; }
.goi-y.noi { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--vien); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); z-index: 20; max-height: 360px; }
.goi-y.noi:empty { display: none; }
.goi-y { list-style: none; margin: 6px 0 0; padding: 0; max-height: 50vh; overflow: auto; }
.goi-y li { padding: 10px; border-bottom: 1px solid var(--vien); cursor: pointer; }
.goi-y li:hover, .goi-y li:focus { background: var(--chinh-nhat); outline: none; }
.goi-y small { color: var(--phu); display: block; }

.sp-tieu-de h2 { margin: 4px 0 10px; }
.luoi-tt { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.luoi-tt > div { background: var(--nen); border-radius: 8px; padding: 8px 10px; display: grid; gap: 2px; }
.luoi-tt b { font-size: 16px; }
.luoi-nhap { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; margin-top: 14px; }
.o-tong { background: var(--vang); border-radius: 8px; padding: 8px 10px; display: grid; }
.o-tong b { font-size: 18px; }
.tong-sp { margin-top: 10px; }

.thanh { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.thanh input { flex: 1; min-width: 160px; width: auto; }
.thanh select { width: auto; }
.cuon { overflow: auto; max-height: 70vh; }
.bang { border-collapse: collapse; width: 100%; font-size: 14px; }
.bang th, .bang td { border-bottom: 1px solid var(--vien); padding: 6px 8px; text-align: left; vertical-align: top; }
.bang th { position: sticky; top: 0; background: var(--chinh-nhat); font-weight: 600; white-space: nowrap; z-index: 1; }
.bang td.so, .bang th.so { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bang tr.lech td { background: #fdecea; }
.bang tr.co-the-mo { cursor: pointer; }
.bang tr.co-the-mo:hover td { background: var(--chinh-nhat); }
.bang tr.chi-tiet td { background: #fafbfc; color: var(--phu); font-size: 13px; }
.am { color: var(--do); }
.bang input { padding: 5px 6px; }

dialog { border: 0; border-radius: 12px; padding: 16px; width: min(480px, 92vw); }
dialog .luoi-nhap { grid-template-columns: 1fr; margin: 0; }

.ten-dot { display: block; font-size: 12px; font-weight: 400; color: #cfdceb; margin-top: 2px; }
.canh-bao { background: var(--vang); border-color: #f0d48a; }
.luoi-tai { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.o-tai { border: 1px dashed var(--vien); border-radius: 8px; padding: 12px; display: grid; gap: 8px; align-content: start; }
.o-tai h3 { margin: 0; }
.o-tai p { margin: 0; }
.o-tai input[type=file] { padding: 6px; }
label.chon { display: flex; gap: 6px; align-items: center; color: var(--chu); font-size: 14px; }
label.chon input { width: auto; }
.nhan-mo { background: #e3f4e5; color: var(--xanh); border-radius: 10px; padding: 2px 8px; font-size: 12px; font-weight: 600; }

.luoi-ns { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; background: var(--nen); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.o-mk { display: flex; gap: 6px; }
.o-mk input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; }
.the-ket-qua { background: #e3f4e5; border: 1px solid #b9dfbd; border-radius: 8px; padding: 12px; margin: 8px 0; display: grid; gap: 6px; }
.the-ket-qua code { font-size: 15px; font-weight: 600; background: #fff; padding: 2px 6px; border-radius: 4px; }

/* Máy tính: menu dọc bên trái */
@media (min-width: 701px) {
  #man-app { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100vh; }
  .dau { position: sticky; top: 0; height: 100vh; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 18px; padding: 18px 12px; }
  .logo { font-size: 18px; padding: 0 8px; }
  #tab { flex-direction: column; flex-wrap: nowrap; flex: 1; gap: 4px; }
  #tab button { text-align: left; width: 100%; padding: 10px 12px; font-size: 15px; }
  .nguoi { display: grid; gap: 8px; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.2); }
  .nguoi .nut { justify-self: start; }
  main { max-width: none; margin: 0; padding: 4px 24px 40px; }
}

@media (max-width: 700px) {
  .dau { padding: 8px 10px; gap: 6px; }
  .nguoi { margin-left: auto; }
  #tab { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #tab::-webkit-scrollbar { display: none; }
  #tab button { white-space: nowrap; padding: 7px 10px; }
  .luoi-nhap { grid-template-columns: 1fr 1fr; }
  .luoi-nhap label:first-child { grid-column: 1 / -1; }
  .luoi-nhap button { grid-column: 1 / -1; padding: 12px; }
  main { padding: 0 10px 40px; }
}
