/* Giao diện quản lý GPMB.
   Màu giao diện giữ trung tính (xám lá, xanh thông) để 7 màu trạng thái lấy từ CAD là thứ nổi bật nhất;
   đỏ chỉ dành cho chỉ giới thu hồi, lỗi và thao tác nguy hiểm.
   Máy tính: thanh trên + bảng bên trái bản đồ. Điện thoại: thanh tab dưới đáy + bảng kéo lên từ dưới. */
:root {
  --ground: #edf1ee;
  --paper: #ffffff;
  --paper-2: #f5f7f5;
  --ink: #17211d;
  --muted: #5b6a63;
  --line: #d6ddd8;
  --line-2: #e7ece8;
  --pine: #0d5c4a;
  --pine-hover: #0a4d3e;
  --pine-ink: #ffffff;
  --pine-soft: #dcede6;
  --red: #c8241b;
  --red-soft: #fbe5e2;
  --redline: #e01b12;
  --warn: #8a5100;
  --warn-bg: #fff0d4;
  --ok: #17702c;
  --ok-bg: #e2f3e5;
  --map-bg: #e9ece9;
  --cad: #6f7a74;
  --float: 0 1px 2px rgba(16, 32, 26, .08), 0 6px 20px rgba(16, 32, 26, .12);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --top-h: 56px;
  --nav-h: 0px;
  --side-w: 384px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f1513; --paper: #171f1c; --paper-2: #1d2622; --ink: #e3eae6; --muted: #98a59f;
    --line: #2c3632; --line-2: #232c28; --pine: #5cc6a4; --pine-hover: #74d3b4; --pine-ink: #06231b; --pine-soft: #183a30;
    --red: #ff7b6e; --red-soft: #3b1f1c; --warn: #ffc56b; --warn-bg: #3a2c12; --ok: #7fd893; --ok-bg: #16301d;
    --map-bg: #1b221f; --cad: #8d9993; --float: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0f1513; --paper: #171f1c; --paper-2: #1d2622; --ink: #e3eae6; --muted: #98a59f;
  --line: #2c3632; --line-2: #232c28; --pine: #5cc6a4; --pine-hover: #74d3b4; --pine-ink: #06231b; --pine-soft: #183a30;
  --red: #ff7b6e; --red-soft: #3b1f1c; --warn: #ffc56b; --warn-bg: #3a2c12; --ok: #7fd893; --ok-bg: #16301d;
  --map-bg: #1b221f; --cad: #8d9993; --float: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ---------- Nền tảng */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground); color: var(--ink); font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 600; }
h3 { font-size: 13.5px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* icon dùng <use>; không đụng tới SVG của Leaflet */
svg:has(> use) { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  min-height: 40px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); min-width: 0;
}
textarea { resize: vertical; }
input:not([type="checkbox"]):not([type="radio"]):hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--pine); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--pine); width: 16px; height: 16px; margin: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--ink); font-size: 14px; font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 400; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; text-decoration: none;
  white-space: nowrap; font-weight: 500; color: var(--ink);
}
.btn:hover { background: var(--paper-2); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--pine); border-color: var(--pine); color: var(--pine-ink); font-weight: 600; }
.btn.primary:hover { background: var(--pine-hover); border-color: var(--pine-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--paper-2); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.lg { min-height: 48px; font-size: 15px; }
.btn.icon { padding: 0; width: 40px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .55; cursor: default; }
.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 99px; white-space: nowrap; }
.chip.warn { color: var(--warn); background: var(--warn-bg); }
.chip.ok { color: var(--ok); background: var(--ok-bg); }
.form-err { color: var(--red); background: var(--red-soft); padding: 8px 12px; border-radius: 8px; font-size: 13.5px; }

/* Biểu trưng: một thửa đất, cạnh giữa là chỉ giới thu hồi nét đứt đỏ */
.mark { width: 30px; height: 30px; stroke: none; }
.mark rect { fill: var(--pine); }
.mark .m-lot { fill: none; stroke: #fff; stroke-width: 1.7; }
.mark .m-red { stroke: #ff8a7f; stroke-width: 1.7; stroke-dasharray: 2.2 1.6; }
.mark.lg { width: 48px; height: 48px; }

/* Ô màu trạng thái */
.sw { width: 14px; height: 14px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); }
.sw.line { height: 0; border-top: 2.5px solid var(--redline); border-radius: 0; box-shadow: none; width: 18px; }
.sw.cad { height: 0; border-top: 1px solid var(--cad); border-radius: 0; box-shadow: none; width: 18px; }
.sw.txt { width: 18px; height: auto; box-shadow: none; font-size: 10.5px; font-weight: 700; text-align: center; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; line-height: 1.3; }
.status .sw { width: 12px; height: 12px; border-radius: 3px; }

/* Nhãn kiểu bản đồ địa chính: số thửa trên, diện tích dưới, loại đất bên cạnh */
.cad-label { display: inline-grid; grid-template-columns: auto auto; align-items: center; column-gap: 8px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.cad-label .fr { display: inline-flex; flex-direction: column; align-items: center; }
.cad-label .no { font-weight: 700; padding: 0 2px 2px; border-bottom: 1.5px solid currentColor; min-width: 100%; text-align: center; }
.cad-label .dt { padding-top: 2px; color: var(--muted); font-weight: 500; }
.cad-label .ld { font-weight: 600; color: var(--muted); font-size: .8em; }
.cad-label.xl .no { font-size: 30px; padding: 0 4px 4px; border-bottom-width: 2px; }
.cad-label.xl .dt { font-size: 15px; padding-top: 4px; }
.cad-label.xl .ld { font-size: 14px; }
.cad-label.sm .no { font-size: 15px; }
.cad-label.sm .dt { font-size: 12px; }

/* ---------- Đăng nhập */
.login { position: relative; min-height: 100%; display: grid; place-items: center; padding: 32px 16px; overflow: hidden; }
.login-art { position: absolute; inset: 0; width: 100%; height: 100%; color: color-mix(in srgb, var(--pine) 22%, transparent); }
.login-art .redline { stroke: color-mix(in srgb, var(--redline) 45%, transparent); }
.login-card {
  position: relative; width: min(400px, 100%); background: var(--paper); border-radius: 16px; padding: 32px 28px;
  display: flex; flex-direction: column; gap: 16px; box-shadow: var(--float);
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }

/* ---------- Khung ứng dụng */
.shell { height: 100%; height: 100dvh; display: grid; grid-template-rows: var(--top-h) minmax(0, 1fr); }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--paper); border-bottom: 1px solid var(--line);
  min-width: 0; position: relative; z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .02em; }
.proj { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 0 1 380px; }
.proj select { width: 100%; font-weight: 600; border-color: transparent; background: var(--paper-2); text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; margin: 0 auto; height: 100%; }
.tabs button {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0 12px; cursor: pointer;
  color: var(--muted); font-weight: 500; white-space: nowrap; position: relative;
}
.tabs button svg { width: 18px; height: 18px; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--pine); font-weight: 600; }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--pine); }
.user { display: flex; align-items: center; gap: 8px; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; border-radius: 99px; }
.menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--pine-soft); color: var(--pine);
  font-weight: 700; font-size: 14px;
}
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; display: flex; flex-direction: column; z-index: 1200; min-width: 230px; box-shadow: var(--float);
}
.menu-who { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.menu-who span { font-size: 12.5px; color: var(--muted); }
.mi { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; text-align: left; text-decoration: none; color: var(--ink); }
.mi svg { width: 18px; height: 18px; color: var(--muted); }
.mi:hover { background: var(--paper-2); }
#xlsx-m { display: none; }
.view { min-height: 0; overflow: auto; }

/* ---------- Bản đồ */
.view-map { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); overflow: hidden; position: relative; }
.map-wrap { position: relative; min-width: 0; min-height: 0; grid-column: 2; grid-row: 1; }
#map { position: absolute; inset: 0; background: var(--map-bg); }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); background: var(--map-bg); z-index: 900; }
.map-tools { position: absolute; top: 12px; right: 12px; z-index: 1000; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.fab {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--paper); color: var(--ink); display: grid; place-items: center;
  cursor: pointer; box-shadow: var(--float);
}
.fab:hover { color: var(--pine); }
.fab[aria-expanded="true"], .fab.on { background: var(--pine); color: var(--pine-ink); }
.layers-pop {
  position: absolute; top: 0; right: 52px; width: 260px; background: var(--paper); border-radius: 12px; box-shadow: var(--float);
  padding: 14px; display: flex; flex-direction: column; gap: 4px;
}
.layers-pop h3 { color: var(--muted); font-size: 12.5px; font-weight: 600; margin: 4px 0 4px; }
.layers-pop h3:not(:first-child) { margin-top: 12px; }
.base-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.base-pick label {
  flex-direction: row; align-items: center; justify-content: center; text-align: center; min-height: 40px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--ink); font-size: 13px; font-weight: 500; line-height: 1.25;
}
.base-pick input { position: absolute; opacity: 0; pointer-events: none; }
.base-pick label:has(input:checked) { border-color: var(--pine); background: var(--pine-soft); color: var(--pine); font-weight: 600; }
.base-pick label:has(input:focus-visible) { outline: 2px solid var(--pine); outline-offset: 1px; }
.tog { flex-direction: row; align-items: center; gap: 10px; color: var(--ink); font-weight: 400; font-size: 14px; padding: 7px 2px; cursor: pointer; }

/* Bảng thông tin: máy tính là cột trái, điện thoại là tấm kéo lên từ dưới */
.sheet { grid-column: 1; grid-row: 1; background: var(--paper); border-right: 1px solid var(--line); min-height: 0; display: flex; flex-direction: column; z-index: 1001; }
.sheet-grip { display: none; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 16px; flex: 1; min-height: 0; }
.overview { display: flex; flex-direction: column; gap: 16px; }

.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.search input { width: 100%; padding-left: 38px !important; background: var(--paper-2) !important; border-color: transparent !important; min-height: 44px !important; border-radius: 10px !important; }
.search input:focus-visible { border-color: var(--pine) !important; background: var(--paper) !important; }

.q-res { list-style: none; margin: -8px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 10px; max-height: 320px; overflow: auto; }
.q-res li button { width: 100%; display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; padding: 8px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.q-res li button:hover, .q-res li button:focus-visible { background: var(--paper-2); }
.q-res .who { min-width: 0; font-size: 13.5px; }
.q-res .who span { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-res .empty { padding: 10px; color: var(--muted); font-size: 13.5px; }

/* Tiến độ: một dải màu duy nhất cho toàn bộ diện tích thu hồi */
.prog { display: flex; flex-direction: column; gap: 10px; }
.prog-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.prog-top b { font-size: 28px; line-height: 1; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.prog-top span { color: var(--muted); font-size: 13.5px; }
.ribbon { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line-2); }
.ribbon i { display: block; min-width: 2px; }
.prog-sub { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.prog-sub b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sec-h span { font-size: 12px; color: var(--muted); }
.st-rows { display: flex; flex-direction: column; }
.st-row {
  position: relative; display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 10px; padding: 8px 6px;
  border-radius: 8px; cursor: pointer; color: var(--ink); font-size: 13.5px; font-weight: 400; line-height: 1.3;
}
.st-row:hover { background: var(--paper-2); }
.st-row input { position: absolute; opacity: 0; pointer-events: none; }
.st-row .sw { width: 16px; height: 16px; display: grid; place-items: center; }
.st-row .sw::after { content: ""; width: 8px; height: 4px; border: solid #fff; border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); filter: drop-shadow(0 0 1px rgba(0, 0, 0, .6)); }
.st-row:has(input:not(:checked)) { color: var(--muted); }
.st-row:has(input:not(:checked)) .sw { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--line); }
.st-row:has(input:not(:checked)) .sw::after { display: none; }
.st-row:has(input:not(:checked)) .cnt { opacity: .6; }
.st-row:has(input:focus-visible) { outline: 2px solid var(--pine); }
.cnt { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cnt small { display: block; font-size: 12px; color: var(--muted); }
.warn-tog {
  flex-direction: row; align-items: center; gap: 10px; margin-top: 8px; padding: 10px; border-radius: 10px; background: var(--warn-bg);
  color: var(--warn); font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.warn-tog svg { width: 18px; height: 18px; }
.warn-tog span { flex: 1; }
.warn-tog b { font-variant-numeric: tabular-nums; }

/* Thửa đang chọn */
.detail { display: flex; flex-direction: column; gap: 16px; }
.d-head { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; }
.d-head .who { min-width: 0; padding-top: 2px; }
.d-head .who b { display: block; font-size: 16px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.d-head .who .sub { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.d-head .status { margin-top: 8px; }
.d-close { margin: -4px -6px 0 0; }
.cad-note { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-2); border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; margin: 0; }
.facts div { background: var(--paper); padding: 8px 12px; min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.warns { display: flex; flex-direction: column; gap: 6px; }
.warns div { display: flex; gap: 8px; font-size: 13px; color: var(--warn); background: var(--warn-bg); padding: 8px 10px; border-radius: 8px; }
.warns svg { width: 16px; height: 16px; margin-top: 2px; }

.upd { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 12px; background: var(--paper-2); }
.upd h3 { font-size: 14px; }
.st-pick { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.st-pick legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.st-opt {
  position: relative; flex-direction: row; align-items: center; gap: 8px; min-height: 44px; padding: 8px 10px; border-radius: 8px;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink); font-size: 13px; font-weight: 500; line-height: 1.25; cursor: pointer;
}
.st-opt input { position: absolute; opacity: 0; pointer-events: none; }
.st-opt:has(input:checked) { border-color: var(--pine); box-shadow: inset 0 0 0 1px var(--pine); background: var(--pine-soft); }
.st-opt:has(input:focus-visible) { outline: 2px solid var(--pine); outline-offset: 1px; }
.st-opt.cur::after { content: "hiện tại"; position: absolute; top: -7px; right: 8px; font-size: 10.5px; font-weight: 600; padding: 0 5px; border-radius: 4px; background: var(--paper-2); color: var(--muted); }
.upd .two { display: grid; grid-template-columns: 1fr; gap: 10px; }
.hist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.hist li { position: relative; padding: 0 0 14px 20px; font-size: 13.5px; }
.hist li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--line)); box-shadow: 0 0 0 2px var(--paper); }
.hist li::after { content: ""; position: absolute; left: 7.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.hist li:last-child::after { display: none; }
.hist .when { color: var(--muted); font-size: 12.5px; }
.hist .note { margin-top: 2px; }

.leaflet-container { font-family: var(--font); background: var(--map-bg); }
.leaflet-bar { border: 0 !important; box-shadow: var(--float) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-bar a { background: var(--paper); color: var(--ink); border-bottom-color: var(--line-2); width: 44px !important; height: 44px !important; line-height: 44px !important; }
.leaflet-top.leaflet-right { top: 116px; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--paper) 80%, transparent) !important; color: var(--muted); font-size: 10.5px; }
.leaflet-control-attribution a { color: var(--ink); }
.leaflet-control-scale-line { background: color-mix(in srgb, var(--paper) 80%, transparent); color: var(--ink); border-color: var(--ink); }
/* bảng cắm số thửa: tấm bảng trắng trên cọc, viền dưới mang màu (và texture) trạng thái */
.pin { cursor: pointer; }
.pin.off { display: none; }
.pin-p { position: absolute; left: -.75px; bottom: 0; width: 1.5px; height: 8px; background: #1b2420; }
.pin-p::after { content: ""; position: absolute; left: -1.5px; bottom: -2px; width: 4.5px; height: 4.5px; border-radius: 50%; background: #1b2420; box-shadow: 0 0 0 1px #fff; }
.pin-b {
  position: absolute; left: 0; bottom: 8px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center;
  padding: 1px 5px 4px; border-radius: 4px; background: #fff; color: #17211d; white-space: nowrap; overflow: hidden;
  font: 700 11px/1.2 var(--font); font-variant-numeric: tabular-nums; box-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 0 0 .5px rgba(0, 0, 0, .25);
}
.pin-b::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--st); }
.pin-b i { display: none; font-style: normal; font-weight: 500; font-size: 10.5px; color: #4b5852; border-top: 1px solid #17211d; margin-top: 1px; padding: 0 1px; }
.pin.full .pin-b i { display: block; }
.pin.ks .pin-b { font-size: 10px; font-weight: 500; color: #5b6a63; }
.pin:hover .pin-b { box-shadow: 0 2px 6px rgba(0, 0, 0, .45), 0 0 0 1px #17211d; }
.pin.sel .pin-b { background: #17211d; color: #fff; }
.pin.sel .pin-b i { color: #c9d3ce; border-top-color: #fff; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26, 115, 232, .25); }

/* ---------- Danh sách */
.view-list { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.list-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.list-head .search { flex: 1 1 280px; max-width: 440px; }
.list-head .count { margin-left: auto; font-size: 13px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); min-height: 0; }
.list-wrap { flex: 1; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th {
  position: sticky; top: 0; background: var(--paper); text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1;
}
.grid th[data-sort] { cursor: pointer; user-select: none; }
.grid th[data-sort]:hover { color: var(--ink); }
.grid th.sorted { color: var(--ink); }
.grid th.sorted::after { content: " ↓"; }
.grid th.sorted.asc::after { content: " ↑"; }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--paper-2); }
.grid tbody tr.sel { background: var(--pine-soft); }
.grid .c-chk { width: 44px; }
.grid td.thon { min-width: 130px; }
.grid .note { color: var(--muted); max-width: 320px; font-size: 13px; }
.ltable .go { border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink); }
.ltable .go:hover .no { color: var(--pine); }
.ltable .ma { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.ltable .upd-by { display: block; color: var(--muted); font-size: 12px; }
.bulk {
  display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--paper);
  box-shadow: var(--float); border: 1px solid var(--pine);
}
.bulk-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bulk-form { display: flex; flex-wrap: wrap; gap: 8px; }
.bulk-form select { flex: 1 1 220px; }
.bulk-form #bulk-note { flex: 2 1 220px; }
.bulk-form #bulk-date { flex: 1 1 150px; }

/* ---------- Báo cáo */
.view-report { padding: 24px 16px 32px; }
.report { max-width: 1160px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.report-head p { color: var(--muted); margin-bottom: 4px; }
.hero { background: var(--paper); border-radius: 16px; padding: 24px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px 32px; align-items: end; }
.hero-num b { display: block; font-size: 56px; line-height: 1; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--pine); }
.hero-num span { display: block; margin-top: 8px; color: var(--muted); font-size: 15px; }
.hero-facts { display: grid; grid-template-columns: repeat(2, auto); gap: 10px 32px; margin: 0; }
.hero-facts dt { font-size: 12.5px; color: var(--muted); }
.hero-facts dd { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hero .ribbon { grid-column: 1 / -1; height: 20px; border-radius: 6px; }
.hero .ribbon i { cursor: default; }
.card { background: var(--paper); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(150px, 220px) 1fr 132px; gap: 12px; align-items: center; font-size: 13.5px; }
.bar-row .lab { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-row .lab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; position: relative; }
.bar { height: 14px; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; }
.bar-row .val small { color: var(--muted); margin-left: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.tl { display: flex; flex-direction: column; gap: 6px; }
.tl-row { display: grid; grid-template-columns: 88px 1fr; gap: 12px; align-items: center; font-size: 12.5px; }
.tl-row .d { color: var(--muted); font-variant-numeric: tabular-nums; }
.stack { display: flex; gap: 2px; height: 16px; }
.stack div { height: 100%; min-width: 1px; }
.stack div:first-child { border-radius: 4px 0 0 4px; }
.stack div:last-child { border-radius: 0 4px 4px 0; }
.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; font-size: 13.5px; }
.recent li { padding: 10px 0; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.recent li:last-child { border-bottom: 0; }
.recent .when { color: var(--muted); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.recent .what { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.tip { position: fixed; z-index: 3000; pointer-events: none; background: var(--ink); color: var(--ground); padding: 7px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.45; max-width: 280px; }

/* ---------- Bản vẽ, người dùng */
.view-import, .view-users { padding: 24px 16px 32px; }
.page { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.drop {
  position: relative; border: 2px dashed var(--line); border-radius: 12px; padding: 28px 16px; cursor: pointer; color: var(--ink);
  flex-direction: row; align-items: center; justify-content: center; gap: 14px; font-size: 14px; font-weight: 400;
}
.drop > svg { width: 40px; height: 40px; padding: 9px; border-radius: 50%; background: var(--pine-soft); color: var(--pine); }
.drop #drop-txt { display: flex; flex-direction: column; }
.drop #drop-txt b { color: var(--pine); font-size: 15px; }
.drop:hover, .drop.over { border-color: var(--pine); background: color-mix(in srgb, var(--pine-soft) 50%, transparent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:has(input:focus-visible) { outline: 2px solid var(--pine); outline-offset: 2px; }
.progress { height: 8px; border-radius: 4px; background: var(--line-2); position: relative; overflow: visible; margin-bottom: 18px; }
.progress div { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--pine); border-radius: 4px; transition: width .2s; }
.progress.busy { overflow: hidden; margin-bottom: 0; }
.progress.busy div { width: 40% !important; animation: slide 1.1s infinite ease-in-out; }
.progress span { position: absolute; right: 0; top: 12px; font-size: 12.5px; color: var(--muted); }
@keyframes slide { from { left: -40%; } to { left: 100%; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--line-2); border-radius: 12px; overflow: hidden; border: 1px solid var(--line-2); }
.tile { background: var(--paper); padding: 12px 14px; }
.tile b { display: block; font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 13px; }
.diff { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.diff details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.diff summary { cursor: pointer; list-style: none; }
.diff summary::-webkit-details-marker { display: none; }
.diff summary b { font-size: 20px; font-weight: 700; display: block; font-variant-numeric: tabular-nums; }
.diff ul { margin: 8px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; font-size: 13px; }
#pmap { height: 380px; border-radius: 12px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.form-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.roles { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13.5px; }
.roles dt { font-weight: 600; }
.roles dd { margin: 0; color: var(--muted); }
.utable td.acts { white-space: nowrap; text-align: right; }
.utable td.acts .btn { margin-left: 4px; }

dialog { border: 0; border-radius: 16px; padding: 0; background: var(--paper); color: var(--ink); width: min(480px, calc(100vw - 32px)); box-shadow: var(--float); }
dialog::backdrop { background: rgba(10, 20, 16, .45); }
dialog form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--nav-h) + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--ground);
  padding: 12px 18px; border-radius: 12px; z-index: 4000; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: var(--float);
}
.toast.err { background: var(--red); color: #fff; }

/* ---------- Màn hình vừa */
@media (max-width: 1180px) {
  .tabs button { padding: 0 10px; }
  .tabs button svg { display: none; }
  #xlsx span { display: none; }
  #xlsx { padding: 0; width: 40px; }
}
@media (max-width: 1000px) {
  :root { --side-w: 340px; }
  .cols { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .form-row .btn { grid-column: 1 / -1; }
}

/* ---------- Điện thoại và máy tính bảng dọc */
@media (max-width: 760px) {
  :root { --top-h: 56px; --nav-h: 64px; }
  body { font-size: 15px; }
  .shell { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .topbar { gap: 8px; padding: 0 8px 0 12px; }
  .brand-txt, #xlsx { display: none; }
  #xlsx-m { display: flex; }
  .proj { flex: 1 1 auto; }
  .proj select { font-size: 15px; }
  #proj-new, #proj-edit { width: 36px; }

  /* thanh tab dưới đáy */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1150; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom); margin: 0; background: var(--paper); border-top: 1px solid var(--line); gap: 0;
  }
  .tabs button { flex: 1; flex-direction: column; justify-content: center; gap: 3px; padding: 0 2px; font-size: 11.5px; min-width: 0; }
  .tabs button svg { display: block; width: 22px; height: 22px; }
  .tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tabs button[aria-selected="true"]::after { left: 30%; right: 30%; top: 0; bottom: auto; height: 3px; border-radius: 0 0 3px 3px; }

  /* bản đồ toàn màn, bảng thông tin kéo lên từ dưới */
  .view-map { display: block; }
  .map-wrap { position: absolute; inset: 0; }
  .sheet {
    position: absolute; left: 0; right: 0; bottom: 0; height: var(--sheet-h, 178px); border-right: 0; border-radius: 18px 18px 0 0;
    box-shadow: 0 -2px 16px rgba(16, 32, 26, .16); transition: height .28s cubic-bezier(.3, .7, .2, 1);
  }
  .sheet[data-state="peek"] { --sheet-h: 178px; }
  .sheet[data-state="half"] { --sheet-h: 56%; }
  .sheet[data-state="full"] { --sheet-h: calc(100% - 8px); }
  .sheet.dragging { transition: none; }
  .sheet-grip { display: grid; place-items: center; flex: none; height: 24px; border: 0; background: none; cursor: grab; touch-action: none; padding: 0; }
  .sheet-grip span { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
  .sheet-body { padding: 0 16px 16px; }
  .sheet[data-state="peek"] .sheet-body { overflow: hidden; }
  .map-tools { top: 10px; right: 10px; }
  .layers-pop { right: 0; top: 104px; width: min(280px, calc(100vw - 20px)); }
  .leaflet-bottom { bottom: 178px; }
  .leaflet-control-scale, .leaflet-control-zoom { display: none; }
  .overview { gap: 14px; }
  .prog-top b { font-size: 24px; }

  .st-pick { display: flex; flex-wrap: wrap; gap: 6px; }
  .st-pick legend { width: 100%; }
  .st-opt { min-height: 40px; padding: 6px 12px; border-radius: 99px; }
  .st-opt.cur::after { top: -8px; right: 12px; }
  .d-head .cad-label.xl .no { font-size: 26px; }

  /* danh sách thành thẻ */
  .view-list { padding: 12px 12px 0; gap: 10px; }
  .list-head { gap: 8px; }
  .list-head .search { flex-basis: 100%; max-width: none; }
  .list-head select { flex: 1 1 0; min-width: 0; }
  .list-head .check { white-space: nowrap; }
  .list-head .count { flex-basis: 100%; margin: 0; }
  .list-wrap { border: 0; background: none; border-radius: 0; }
  .ltable thead { display: none; }
  .ltable, .ltable tbody { display: block; }
  .ltable tr {
    display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "chk no dt" "chk who who" "chk st thon" "chk note note";
    gap: 4px 12px; align-items: center; padding: 10px 14px; margin-bottom: 6px; background: var(--paper); border-radius: 12px; border: 1px solid var(--line-2);
  }
  .ltable tr.sel { border-color: var(--pine); }
  .ltable td { display: block; padding: 0; border: 0 !important; min-width: 0 !important; }
  .ltable td.c-chk { grid-area: chk; width: auto; padding-top: 4px; }
  .ltable td.c-chk input { width: 20px; height: 20px; }
  .ltable td.c-no { grid-area: no; }
  .ltable td.c-who { grid-area: who; font-weight: 500; }
  .ltable td.thon { grid-area: thon; color: var(--muted); font-size: 13px; text-align: right; }
  .ltable td.c-no .ma { display: inline; margin-left: 8px; }
  .ltable td.num { grid-area: dt; font-weight: 600; }
  .ltable td.num::after { content: " m²"; font-weight: 400; color: var(--muted); }
  .ltable td.c-st { grid-area: st; }
  .ltable td.c-chk { align-self: start; }
  .ltable td.c-upd { display: none; }
  .ltable td.note { grid-area: note; max-width: none; }
  .ltable td:empty:not(.c-chk) { display: none; }
  .ltable td.empty-row { grid-column: 1 / -1; }
  .bulk { position: sticky; bottom: 8px; margin: 0 0 8px; }

  .view-report, .view-import, .view-users { padding: 16px 12px 24px; }
  .report-head h1 { font-size: 20px; }
  .report-head .btn { display: none; }
  .hero { grid-template-columns: 1fr; padding: 20px; }
  .hero-num b { font-size: 44px; }
  .hero-facts { grid-template-columns: 1fr 1fr; gap: 10px 16px; }
  .card { padding: 16px; border-radius: 14px; }
  .bar-row { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .tl-row { grid-template-columns: 74px 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .roles { grid-template-columns: 1fr; gap: 0; }
  .roles dd { margin-bottom: 8px; }
  .drop { flex-direction: column; text-align: center; padding: 24px 16px; }
  .drop #drop-txt { align-items: center; }
  #pmap { height: 300px; }
  .actions .btn { flex: 1; }

  .utable thead { display: none; }
  .utable, .utable tbody { display: block; }
  .utable tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
  .utable td { display: block; padding: 0; border: 0; }
  .utable td.c-name { grid-column: 1; font-weight: 600; }
  .utable td.c-active { grid-column: 2; grid-row: 1; }
  .utable td.c-full { grid-column: 1 / -1; color: var(--muted); }
  .utable td.c-role { grid-column: 1 / -1; }
  .utable td.c-role select { width: 100%; }
  .utable td.acts { grid-column: 1 / -1; text-align: left; display: flex; gap: 8px; }
  .utable td.acts .btn { margin: 0; flex: 1; }
  .table-wrap:has(.utable) { border: 0; }

  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92dvh; }
  dialog form { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .dlg-actions .btn { flex: 1; }
}
/* Màn hình cảm ứng: chữ trong ô nhập 16px để iOS không tự phóng to */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { font-size: 16px !important; min-height: 44px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet { transition: none; }
  .progress.busy div { animation: none; }
  .leaflet-zoom-anim .leaflet-zoom-animated { transition: none !important; }
}
