:root {
  --nen: #11151b;
  --be-mat: #1a2029;
  --be-mat-2: #232b36;
  --vien: #2f3946;
  --chu: #e6e9ee;
  --chu-phu: #9aa5b4;
  --nhan: #4c9be8;
  --nhan-dam: #2f7fd0;
  --canh-bao: #f0a35e;
  --rong-thanh: 300px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--nen);
  color: var(--chu);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#khung3d {
  position: fixed;
  inset: 0 0 0 var(--rong-thanh);
}
#khung3d canvas { display: block; touch-action: none; }

#thanh-ben {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--rong-thanh);
  overflow-y: auto;
  background: var(--be-mat);
  border-right: 1px solid var(--vien);
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 5;
}

h1 { font-size: 17px; margin: 0; font-weight: 650; }
h2 {
  font-size: 12px;
  margin: 0 0 8px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--chu-phu);
}
.phu { margin: 2px 0 0; color: var(--chu-phu); font-size: 13px; }

button, select {
  font: inherit;
  color: var(--chu);
  background: var(--be-mat-2);
  border: 1px solid var(--vien);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
button:hover, select:hover { border-color: #46566a; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--nhan);
  outline-offset: 1px;
}
button[aria-pressed="true"] { background: var(--nhan-dam); border-color: var(--nhan); }

.nhom-nut { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.nhom-nut.nho { grid-template-columns: 1fr 1fr; margin-top: 8px; }
.nhom-nut button { padding: 6px 0; }
.nut-phu { width: 100%; margin-top: 6px; }

.chon {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  user-select: none;
}
.chon input { accent-color: var(--nhan); width: 16px; height: 16px; margin: 0; }
.o-mau {
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--mau);
  flex: none;
}
.ds-lop { margin-top: 6px; }
.ds-lop .chon { font-size: 13px; padding: 2px 0; }

.truot { display: block; margin: 6px 0; }
.truot span { display: block; font-size: 13px; color: var(--chu-phu); margin-bottom: 2px; }
.truot b { color: var(--chu); font-weight: 600; }
input[type="range"] { width: 100%; accent-color: var(--nhan); }

.o-chon { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--chu-phu); margin: 8px 0; }
.o-chon select { color: var(--chu); }

.chan {
  margin-top: auto;
  font-size: 12px;
  color: var(--chu-phu);
  border-top: 1px solid var(--vien);
  padding-top: 10px;
}
.chan p { margin: 0 0 4px; }
.gioi-han { margin: 4px 0 6px; }
.gioi-han summary { cursor: pointer; color: var(--chu); }
.gioi-han ul { margin: 6px 0 0; padding-left: 16px; }
.gioi-han li { margin-bottom: 4px; }

/* ---------- huyệt ---------- */
.o-tim {
  width: 100%;
  margin: 6px 0;
  font: inherit;
  color: var(--chu);
  background: var(--be-mat-2);
  border: 1px solid var(--vien);
  border-radius: 6px;
  padding: 6px 9px;
}
.ds-huyet {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--vien);
  border-radius: 6px;
}
.ds-huyet h3 {
  position: sticky;
  top: 0;
  margin: 0;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--chu-phu);
  background: #1e2530;
}
.muc-huyet {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 5px 9px;
}
.muc-huyet:hover { background: var(--be-mat-2); }
.muc-huyet[aria-current="true"] { background: #24405e; }
.muc-huyet .ma { min-width: 42px; font-size: 12px; color: var(--chu-phu); font-variant-numeric: tabular-nums; }
.muc-huyet .cham { margin-left: auto; }
.ds-huyet .rong { padding: 10px; color: var(--chu-phu); font-size: 13px; }
.cham { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cham-cb { background: #f0a35e; }
.cham-tt { background: #3fc1b0; }
.chu-thich { font-size: 12px; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.chu-thich > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

#the-huyet {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 340px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: var(--be-mat);
  border: 1px solid var(--vien);
  border-radius: 10px;
  padding: 14px 16px;
  z-index: 4;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
#the-huyet[hidden] { display: none; }
.the-dau { display: flex; justify-content: space-between; gap: 10px; }
.th-ma { margin: 0; font-size: 12px; color: var(--chu-phu); letter-spacing: .03em; }
#the-huyet h3 { margin: 2px 0 0; font-size: 18px; font-weight: 650; }
.nut-dong { width: 30px; height: 30px; padding: 0; flex: none; }
.nhom-nut.hai { grid-template-columns: 1fr 1fr; margin: 10px 0 4px; }
.nhom-nut.ba { grid-template-columns: repeat(3, 1fr); margin: 6px 0; }
.qt-tong { font-size: 12px; margin: 0 0 4px; }
.qt-bmi { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; font-size: 13px; }
.qt-bmi input { width: 90px; }
.qt-chon input[type=number] { background: var(--be-mat-2); color: var(--chu); border: 1px solid var(--vien); border-radius: 6px; padding: 5px 7px; font: inherit; }
.qt-pham-vi { font-size: 12px; margin: 0 0 4px; }
.qt-tinh { font-size: 13px; margin: 4px 0; }
.qt-tinh summary { cursor: pointer; color: var(--chu-phu); }
.qt-hai { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.qt-hai label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--chu-phu); }
.qt-hai input { width: 100%; }
.qt-bao { font-size: 12px; color: var(--canh-bao); margin: 4px 0; }
.qt-nhom { font-size: 12px; margin: 4px 0 0; }
.qt-ket-qua { margin: 6px 0; padding: 6px 8px; font-size: 13px; background: var(--be-mat-2); border-left: 3px solid var(--nhan); border-radius: 4px; }
.qt-ket-qua.nguy { border-left-color: #ff7a6b; }
.bd-nguon { margin: 0 0 6px; }
.canh-bao-hop {
  margin: 10px 0 2px;
  padding: 8px 10px;
  border-left: 3px solid var(--canh-bao);
  background: rgba(240, 163, 94, .1);
  border-radius: 4px;
  font-size: 13px;
}
.th-muc { margin: 10px 0 0; font-size: 13px; }
.th-muc dt { color: var(--chu-phu); font-size: 12px; margin-top: 9px; }
.th-muc dd { margin: 2px 0 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 4px 2px 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--be-mat-2);
  font-size: 12px;
}
.th-thuoc {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: #141a22;
  border: 1px solid var(--vien);
  border-radius: 8px;
}
.th-thuoc h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--chu-phu); }
/* khung kết quả chỉ giãn chứ không co trong lúc xem một huyệt, để thanh trượt và bản đồ bên dưới không nhảy */
.tt-bang { display: flow-root; }
.tt-ket-qua { margin: 0 0 6px; font-size: 15px; }
.tt-ket-qua.nguy b { color: #ff7a6b; }
.tt-xuong { margin: 0 0 6px; font-size: 12px; color: var(--canh-bao); }
.tt-lop { list-style: none; margin: 0 0 6px; padding: 0; font-size: 13px; }
.tt-lop li { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.tt-lop .tt-mm { margin-left: auto; color: var(--chu-phu); font-variant-numeric: tabular-nums; }
.tt-meo { font-size: 12px; margin: 6px 0 0; }
input[type="range"]:disabled { opacity: .4; }
.bd-tom-tat { margin: 0 0 6px; font-size: 13px; min-height: 4.4em; }   /* đủ 3 dòng: đổi ca mẫu/nhóm bản đồ không nhảy */
.bd-tom-tat.nguy b { color: #ff7a6b; }
.bd-ve { display: block; margin: 0 auto; cursor: crosshair; }
.bd-chi { font-size: 12px; min-height: 2.9em; margin: 4px 0; }
.bd-thang { margin: 4px 0; }
.bd-dai { height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgb(215,48,31), rgb(252,141,89) 25%, rgb(254,224,139) 50%, rgb(145,207,96) 75%, rgb(26,152,80)); }
.bd-so { display: flex; justify-content: space-between; font-size: 11px; color: var(--chu-phu); margin-top: 2px; }
.bd-chu-thich { font-size: 12px; display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.bd-gach { display: inline-block; width: 14px; height: 10px; border-radius: 2px; background: repeating-linear-gradient(135deg, rgba(255,255,255,.75) 0 1px, #1a9850 1px 4px); }
.nhan-thuoc {
  position: fixed;
  z-index: 3;
  pointer-events: none;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, .8);
  border: 1px solid #6b7686;
}
.nhan-thuoc.nguy { border-color: #ff7a6b; color: #ffb3aa; }

.ghi-chu { margin: 10px 0 0; font-size: 12px; color: var(--chu-phu); border-top: 1px solid var(--vien); padding-top: 8px; }
.nhan-di, .nhan-chon {
  position: fixed;
  z-index: 3;
  pointer-events: none;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  transform: translate(-50%, -150%);
}
.nhan-di { background: rgba(0, 0, 0, .78); }
.nhan-chon { background: #24405e; border: 1px solid #4c9be8; font-weight: 600; }

.huong-dan {
  position: fixed;
  left: calc(var(--rong-thanh) + 12px);
  bottom: 10px;
  margin: 0;
  font-size: 12px;
  color: var(--chu-phu);
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

#man-tai {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(17, 21, 27, .92);
  z-index: 20;
}
#man-tai[hidden] { display: none; }
.hop-tai { width: min(320px, 80vw); text-align: center; }
.thanh-tai { height: 6px; background: var(--be-mat-2); border-radius: 3px; overflow: hidden; }
#tien-tai { height: 100%; width: 0; background: var(--nhan); transition: width .15s; }
.loi { color: var(--canh-bao); }

.nut-tron {
  display: none;
  position: fixed;
  top: 10px; left: 10px;
  z-index: 6;
  width: 40px; height: 40px;
  padding: 0;
  font-size: 18px;
}

/* lát cắt ngang qua huyệt */
.lat-hop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 8, 12, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.lat-khung {
  width: min(1180px, 100%); max-height: 100%; overflow-y: auto;
  background: var(--be-mat); border: 1px solid var(--vien); border-radius: 10px;
  padding: 14px 16px 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.lat-dau { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.lat-dau h3 { margin: 0; font-size: 17px; font-weight: 650; }
.lat-quy-uoc { margin: 2px 0 0; font-size: 12px; }
.lat-cong-cu { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 16px; margin: 8px 0 6px; }
.lat-cong-cu .o-chon { margin: 0; }
.lat-cong-cu .chon { margin: 0 0 6px; }
.lat-truot { flex: 1 1 260px; margin: 0; }
.nut-nho { padding: 5px 10px; font-size: 13px; margin-bottom: 2px; }
.lat-ve-hop { width: 100%; }
#lat-ve { display: block; border-radius: 6px; cursor: crosshair; touch-action: pinch-zoom; }
.lat-chi { margin: 6px 0 2px; font-size: 14px; font-weight: 600; min-height: 1.45em; }
.lat-ghi { margin: 0; font-size: 12px; }
.lat-ds { columns: 2; column-gap: 16px; margin: 8px 0 0; padding-left: 22px; font-size: 13px; }
.lat-ds li { break-inside: avoid; padding: 1px 0; }
@media (max-width: 800px) {
  .lat-hop { padding: 0; }
  .lat-khung { border-radius: 0; height: 100%; padding: 12px; }
}

@media (max-width: 800px) {
  :root { --rong-thanh: 0px; }
  #thanh-ben {
    width: min(300px, 88vw);
    transform: translateX(-100%);
    transition: transform .2s;
    box-shadow: 4px 0 16px rgba(0, 0, 0, .4);
  }
  body.mo-thanh #thanh-ben { transform: none; }
  .nut-tron { display: block; }
  body.mo-thanh .nut-tron { left: calc(min(300px, 88vw) + 10px); }
  .huong-dan { left: 12px; }
  #the-huyet { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 46vh; }
}
