/* Port Twin Cát Lái: bản xem trước. Mặc định nền tối màu xanh hải quân (không đen thuần); [data-theme="light"] là bản sáng.
   Vai trò màu tách riêng: thương hiệu/đang chọn = xanh dương; trạng thái = ok / chờ / chú ý / sự cố (luôn kèm icon). */
:root {
  --ink: #e6f0f8; --muted: #8fb0c8; --faint: #6f90a9;
  --line: rgba(150, 200, 240, .16);
  --brand: #4cb0ff; --brand-soft: rgba(76, 176, 255, .16); --brand-ink: #04223d;
  --navy: #2b7fd6; --on-navy: #fff;
  --ok: #3fd19a; --idle: #8aa5ba; --warn: #f2b24a; --fault: #ff6b5f;

  --glass: rgba(12, 36, 62, .56); --glass-strong: rgba(12, 36, 62, .9); --glass-edge: rgba(150, 200, 240, .22);
  --shadow: 0 12px 36px rgba(2, 10, 22, .45), inset 0 1px 0 rgba(190, 225, 255, .1);
  --surface: rgba(255, 255, 255, .06); --surface-hi: rgba(255, 255, 255, .14); --field: rgba(4, 18, 34, .45);
  --scrim: rgba(2, 10, 22, .55);

  /* màu bản đồ */
  --water-a: #0a2441; --water-b: #11406a; --land: #17314c; --apron: #1f3f5e; --road: #2a4a69; --block: #1b3a58;
  --quay: #5f87a8; --lane: rgba(200, 225, 245, .5); --hull: #3d5f7c; --hull-line: #8fb0c8; --bridge: #dfeaf3;
  --pill: rgba(8, 28, 50, .88); --pill-line: rgba(150, 200, 240, .35);
  --truck-cab: #cfe0ee; --base: #8fb0c8; --boom: #a9c4d8;
  --hatch: rgba(242, 178, 74, .35); --hatch-fill: rgba(242, 178, 74, .08);

  --font: "Be Vietnam Pro", system-ui, "Segoe UI", Roboto, sans-serif;
  --r: 14px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --ink: #0f2a3d; --muted: #4d6477; --faint: #5a6f80; --line: rgba(15, 42, 61, .14);
  --brand: #0b5cad; --brand-soft: rgba(11, 92, 173, .12); --brand-ink: #fff; --navy: #12395a; --on-navy: #fff;
  --ok: #1d9a6c; --idle: #6b8397; --warn: #a86400; --fault: #d3433b;
  --glass: rgba(255, 255, 255, .62); --glass-strong: rgba(255, 255, 255, .88); --glass-edge: rgba(255, 255, 255, .8);
  --shadow: 0 10px 34px rgba(15, 42, 61, .14), inset 0 1px 0 rgba(255, 255, 255, .7);
  --surface: rgba(255, 255, 255, .6); --surface-hi: #fff; --field: rgba(255, 255, 255, .7); --scrim: rgba(15, 42, 61, .28);
  --water-a: #bdd9ea; --water-b: #d9eaf4; --land: #ecf0ef; --apron: #d9dfe2; --road: #ced6da; --block: #e0e6e5;
  --quay: #8aa3b5; --lane: rgba(15, 42, 61, .35); --hull: #6b8397; --hull-line: #3c566b; --bridge: #fff;
  --pill: rgba(255, 255, 255, .92); --pill-line: rgba(15, 42, 61, .18);
  --truck-cab: #12395a; --base: #36546b; --boom: #8aa3b5;
  --hatch: rgba(217, 138, 11, .45); --hatch-fill: rgba(217, 138, 11, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 400 13px/1.5 var(--font); color: var(--ink); background: var(--water-a); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.app { position: fixed; inset: 0; }
.map { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
.map.panning { cursor: grabbing; }
.map text { font-family: var(--font); pointer-events: none; }

.glass { background: var(--glass); border: 1px solid var(--glass-edge); border-radius: var(--r); box-shadow: var(--shadow); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3); }

/* thanh trên */
.top { position: absolute; left: 16px; right: 84px; top: 14px; height: 60px; display: flex; align-items: center; gap: 18px; padding: 0 16px; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.mark { width: 26px; height: 26px; background: linear-gradient(135deg, var(--brand) 0 55%, #8fd0ff 55% 100%); clip-path: polygon(0 20%, 100% 0, 100% 80%, 0 100%); }
.brand strong { display: block; font-weight: 600; line-height: 1.2; }
.brand span { color: var(--muted); font-size: 12px; }
.search { position: relative; flex: 0 1 280px; min-width: 150px; }
.search .ic { position: absolute; left: 11px; top: 9px; width: 18px; height: 18px; color: var(--muted); }
.search input { width: 100%; height: 36px; padding: 0 12px 0 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); outline: none; }
.search input::placeholder { color: var(--faint); }
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.results { position: absolute; left: 0; right: 0; top: 42px; margin: 0; padding: 6px; list-style: none; background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 12px; box-shadow: var(--shadow); }
.results button { width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; }
.results button:hover { background: var(--brand-soft); }
.results small { display: block; color: var(--muted); }

.filters-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.filters-cap { color: var(--faint); font-size: 11px; padding-left: 4px; }
.filters { display: flex; gap: 6px; }
.fbtn { flex: 1 1 0; min-width: 0; padding: 3px 10px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; transition: background .15s, border-color .15s; }
.fbtn:hover { border-color: var(--faint); }
.fbtn[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
.fbtn b { display: block; font-size: 15px; font-weight: 500; line-height: 1.25; white-space: nowrap; }
.fbtn b i { font-style: normal; color: var(--ok); }
.fbtn b em { font-style: normal; color: var(--warn); }
.fbtn b em.z { color: var(--faint); }
.fbtn[aria-pressed="true"] b i { color: #9af0cb; }
.fbtn[aria-pressed="true"] b em { color: #ffe0a3; }
.fbtn[aria-pressed="true"] b em.z { color: #cfe0ee; }
.fbtn span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.fbtn[aria-pressed="true"] span { color: #d6e6f3; }
.live { display: flex; align-items: center; gap: 8px; color: var(--muted); flex: none; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 209, 154, .2); }
.live b { color: var(--ink); font-weight: 500; }

/* cột trái */
.left { position: absolute; left: 16px; top: 88px; bottom: 196px; width: 316px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-right: 2px; z-index: 4; scrollbar-width: thin; }
.block { flex: none; overflow: hidden; }
.bhead { width: 100%; display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: none; border: 0; text-align: left; font-weight: 500; }
.bhead svg { width: 16px; height: 16px; color: var(--muted); transition: transform .2s; }
.bhead[aria-expanded="false"] svg { transform: rotate(-90deg); }
.bhead span { flex: 1; }
.bbody { padding: 0 14px 14px; }
.bhead[aria-expanded="false"] + .bbody { display: none; }

.dtitle { display: flex; align-items: center; gap: 12px; padding: 14px 14px 10px; }
.dtype { width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.dtype svg { width: 22px; height: 22px; }
.dtitle h2 { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.2; }
.dtitle p { margin: 0; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 6px; border-radius: 12px; font-size: 12px; font-weight: 500; background: var(--surface); border: 1px solid var(--line); }
.chip svg { width: 14px; height: 14px; }
.s-run { color: var(--ok); } .s-idle { color: var(--idle); } .s-warn { color: var(--warn); } .s-fault { color: var(--fault); }
.dtask { padding: 0 14px 4px; color: var(--muted); }
.dtask strong { color: var(--ink); font-weight: 500; }
.dbig { display: flex; align-items: baseline; gap: 6px; padding: 6px 14px 0; }
.dbig b { font-size: 52px; font-weight: 300; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dbig span { color: var(--muted); }
.dspark { padding: 0 14px; }
.spark { width: 100%; height: 56px; }
.spark path.a { fill: var(--brand-soft); } .spark path.l { fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linejoin: round; }
.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 10px 14px 4px; background: var(--line); border-radius: 10px; overflow: hidden; }
.dgrid div { background: var(--surface); padding: 8px 10px; }
.dgrid span { color: var(--muted); font-size: 12px; display: block; }
.dgrid b { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.dbar { margin: 10px 14px 14px; }
.dbar > div { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .6s; }

.ship { padding: 4px 0 10px; }
.ship + .ship { border-top: 1px solid var(--line); padding-top: 10px; }
.ship h3 { margin: 0; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.ship h3 svg { width: 16px; height: 16px; color: var(--brand); }
.ship p { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.ship .row { display: grid; grid-template-columns: 38px 1fr 36px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.ship .row b { color: var(--ink); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }

/* thẻ cổng */
.gate { position: absolute; right: 84px; top: 88px; width: 252px; padding: 12px 14px 14px; z-index: 4; }
.gate h3 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.gate h3 svg { width: 18px; height: 18px; color: var(--brand); }
.gate .g2 { display: flex; gap: 18px; align-items: baseline; }
.gate .g2 b { font-size: 34px; font-weight: 300; font-variant-numeric: tabular-nums; line-height: 1.1; }
.gate .g2 span { color: var(--muted); font-size: 12px; display: block; }
.gate .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 4px; }
.gate .meta b { color: var(--ink); font-weight: 500; }

/* thanh icon phải */
.rail { position: absolute; right: 16px; top: 14px; padding: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 5; width: 54px; align-items: center; }
.ibtn { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 11px; background: none; color: var(--muted); transition: background .15s, color .15s; }
.ibtn svg { width: 20px; height: 20px; }
.ibtn:hover { background: var(--surface-hi); color: var(--ink); }
.ibtn[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 14px rgba(76, 176, 255, .3); }
.sep { width: 24px; height: 1px; background: var(--line); margin: 2px 0; }

/* dải thiết bị và thanh lệnh */
.dock { position: absolute; left: 348px; right: 84px; bottom: 16px; display: grid; gap: 10px; z-index: 4; }
.cmd { display: flex; align-items: center; gap: 8px; padding: 6px; width: max-content; max-width: 100%; margin: 0 auto; }
.cbtn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; transition: opacity .2s, background .15s; }
.cbtn svg { width: 17px; height: 17px; }
.cbtn:hover:not(:disabled) { background: var(--surface-hi); }
.cbtn:disabled { opacity: .4; cursor: not-allowed; }
.cbtn.danger { color: var(--fault); }
.lockbtn { margin-left: 4px; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.lockbtn svg { width: 19px; height: 19px; }
.lockbtn[aria-pressed="false"] { background: var(--fault); border-color: var(--fault); color: #fff; }
.strip { display: flex; gap: 8px; padding: 8px; overflow-x: auto; scrollbar-width: thin; }
.card { flex: none; width: 118px; padding: 8px 10px 10px; border-radius: 11px; border: 1.5px solid transparent; background: var(--surface); text-align: left; position: relative; overflow: hidden; transition: background .15s, border-color .15s; }
.card:hover { background: var(--surface-hi); }
.card[aria-selected="true"] { border-color: var(--brand); background: var(--surface-hi); box-shadow: 0 4px 16px rgba(76, 176, 255, .22); }
.card.dim { display: none; }
.card .t { display: flex; align-items: center; gap: 6px; font-weight: 500; font-size: 12px; color: var(--ink); }
.card .t svg { width: 15px; height: 15px; color: var(--muted); }
.card .b { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.card .b b { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; color: var(--ink); }
.card .b b small { font-size: 11px; font-weight: 400; color: var(--muted); }
.card .b svg { width: 17px; height: 17px; }
.card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: currentColor; }
.card.s-fault { background: rgba(255, 107, 95, .14); }

/* hộp thoại xác nhận */
.modal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: var(--scrim); backdrop-filter: blur(3px); }
.dialog { width: min(420px, 92vw); padding: 20px; background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.dialog h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.dialog p { margin: 0 0 16px; color: var(--muted); }
.dialog .row { display: flex; gap: 8px; justify-content: flex-end; }
.btn { padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
.btn.danger { background: var(--fault); border-color: var(--fault); color: #fff; }

/* bản đồ */
.m-pill { fill: var(--pill); stroke: var(--pill-line); }
.m-txt { font-size: 11px; font-weight: 500; fill: var(--ink); }
.dev { cursor: pointer; transition: opacity .25s; }
.dev.dim { opacity: .18; }
.zone-txt { font-size: 12px; font-weight: 500; }
@keyframes pulse { 0%, 100% { opacity: .6; } 50% { opacity: .18; } }
.sel-ring { animation: pulse 1.8s ease-in-out infinite; }

@media (max-width: 1180px) { .filters-cap, .brand span, .live span { display: none; } .fbtn:nth-child(n+4) { display: none; } }
@media (max-width: 920px) {
  .top { right: 16px; } .rail { top: 84px; flex-direction: row; width: auto; }
  .left { width: min(300px, calc(100vw - 32px)); bottom: 190px; } .gate { display: none; }
  .dock { left: 16px; right: 16px; } .filters-wrap, .live { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- hào quang (halo) cho icon đáng chú ý hoặc đang active ---------- */
:root { --halo-ok: rgba(63, 209, 154, .6); --halo-brand: rgba(76, 176, 255, .65); --halo-warn: rgba(242, 178, 74, .65); --halo-fault: rgba(255, 107, 95, .65); }
:root[data-theme="light"] { --halo-ok: rgba(29, 154, 108, .4); --halo-brand: rgba(11, 92, 173, .38); --halo-warn: rgba(217, 138, 11, .42); --halo-fault: rgba(211, 67, 59, .4); }
.st-run { --c: var(--ok); --h: var(--halo-ok); } .st-idle { --c: var(--idle); --h: transparent; }
.st-warn { --c: var(--warn); --h: var(--halo-warn); } .st-fault { --c: var(--fault); --h: var(--halo-fault); }
.chip svg, .card .b svg { filter: drop-shadow(0 0 4px currentColor) drop-shadow(0 0 9px var(--h, transparent)); }
.s-idle svg { filter: none !important; }
.dtype { box-shadow: 0 0 0 4px var(--brand-soft), 0 0 20px var(--halo-brand); }
.ibtn[aria-pressed="true"] { box-shadow: 0 0 0 4px var(--brand-soft), 0 0 18px var(--halo-brand); }
.lockbtn[aria-pressed="false"] { box-shadow: 0 0 0 4px rgba(255, 107, 95, .18), 0 0 16px var(--halo-fault); }
.card[aria-selected="true"] { box-shadow: 0 0 0 3px var(--brand-soft), 0 0 20px var(--halo-brand); }
.card[aria-selected="true"] .t svg { color: var(--brand); filter: drop-shadow(0 0 5px var(--halo-brand)); }
.fbtn[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--brand-soft), 0 0 16px var(--halo-brand); }
.fbtn b i { text-shadow: 0 0 10px var(--halo-ok); } .fbtn b em:not(.z) { text-shadow: 0 0 10px var(--halo-warn); }
.live .dot { box-shadow: 0 0 0 3px rgba(63, 209, 154, .2), 0 0 12px var(--halo-ok); }
.gate h3 svg, .ship h3 svg { filter: drop-shadow(0 0 6px var(--halo-brand)); }
.bbody.flush { padding: 0; }
.ctarget { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; margin-right: 2px; color: var(--muted); font-size: 12px; border-right: 1px solid var(--line); }
.ctarget b { color: var(--ink); font-weight: 500; }

/* ---------- thẻ container, mặt cắt bay, chỉ số bãi ---------- */
.cpanel { position: absolute; right: 84px; top: 88px; width: 396px; max-height: calc(100vh - 88px - 196px); overflow-y: auto; z-index: 6; scrollbar-width: thin; }
.cp-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 14px 6px; }
.cp-head h2 { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.2; letter-spacing: .01em; }
.cp-head p { margin: 0; color: var(--muted); font-size: 12px; }
.cp-head .grow { flex: 1; min-width: 0; }
.xbtn { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); flex: none; }
.xbtn svg { width: 16px; height: 16px; }
.xbtn:hover { background: var(--surface-hi); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; }
.chip.b { color: var(--brand); } .chip.b svg { filter: drop-shadow(0 0 5px var(--halo-brand)); }
.addr { margin: 4px 14px 10px; padding: 10px 12px; border-radius: 12px; background: var(--brand-soft); border: 1px solid var(--line); }
.addr b { display: block; font-size: 15px; font-weight: 600; line-height: 1.35; }
.addr span { color: var(--muted); font-size: 12px; }
.callout { margin: 0 14px 10px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; background: var(--surface); }
.callout svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.callout p { margin: 0; }
.callout small { display: block; color: var(--muted); margin-top: 2px; }
.callout.s-warn { box-shadow: 0 0 0 3px rgba(242, 178, 74, .12), 0 0 18px var(--halo-warn); border-color: var(--warn); }
.callout.s-run { box-shadow: 0 0 0 3px rgba(63, 209, 154, .1), 0 0 18px var(--halo-ok); border-color: var(--ok); }
.callout.s-fault { box-shadow: 0 0 0 3px rgba(255, 107, 95, .12), 0 0 18px var(--halo-fault); border-color: var(--fault); }
.callout p, .callout small { color: var(--ink); } .callout small { color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0 14px 10px; background: var(--line); border-radius: 10px; overflow: hidden; }
.kv div { background: var(--surface); padding: 7px 10px; }
.kv span { display: block; color: var(--muted); font-size: 12px; }
.kv b { font-weight: 500; font-variant-numeric: tabular-nums; }
.sec { border-top: 1px solid var(--line); }
.sec .bhead { padding: 10px 14px; font-size: 13px; }
.bayv { padding: 0 14px 12px; }
.baynav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.baynav b { font-weight: 500; font-variant-numeric: tabular-nums; }
.baynav .xbtn svg { transition: none; }
.baysvg { width: 100%; height: auto; }
.baysvg text { font-family: var(--font); pointer-events: none; }
.bc { cursor: pointer; }
.bc rect.c { stroke-width: 1; }
.bc:hover rect.c { stroke: var(--ink); }
.bc.dim { opacity: .5; }
.bc.tgt rect.c { stroke: var(--brand); stroke-width: 2.4; filter: drop-shadow(0 0 7px var(--halo-brand)); }
.bc.blk rect.c { stroke: var(--warn); stroke-width: 2; filter: drop-shadow(0 0 6px var(--halo-warn)); }
.bay-legend { display: flex; gap: 12px; color: var(--muted); font-size: 12px; margin-top: 6px; flex-wrap: wrap; }
.bay-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hist { list-style: none; margin: 0; padding: 0 14px 12px; }
.hist li { position: relative; padding: 0 0 10px 18px; font-size: 12px; color: var(--muted); }
.hist li::before { content: ""; position: absolute; left: 3px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 8px var(--halo-brand); }
.hist li::after { content: ""; position: absolute; left: 6.5px; top: 14px; bottom: -3px; width: 1px; background: var(--line); }
.hist li:last-child::after { display: none; }
.hist b { display: block; color: var(--ink); font-weight: 500; }
.cp-act { padding: 4px 14px 14px; display: grid; gap: 8px; }
.cp-act .btn { display: flex; justify-content: center; align-items: center; gap: 8px; }
.cp-act .btn:disabled { opacity: .45; cursor: not-allowed; }
.res-tags { display: inline-flex; gap: 6px; margin-left: 6px; color: var(--muted); font-size: 11px; }
.yk .row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.yk .row b { color: var(--ink); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.yk .bar { grid-column: 1 / -1; margin-bottom: 8px; }
.yk .note { color: var(--faint); font-size: 11px; margin: 4px 0 0; }
.yk .bar i.w { background: var(--warn); box-shadow: 0 0 8px var(--halo-warn); } .yk .bar i.f { background: var(--fault); }
@media (max-width: 920px) { .cpanel { right: 16px; width: min(396px, calc(100vw - 32px)); } }

/* ---------- cột mốc 1: danh sách, bộ lọc, thẻ cổng thu nhỏ, trạng thái dữ liệu ---------- */
.lpanel { position: absolute; right: 84px; top: 88px; width: 396px; max-height: calc(100vh - 88px - 196px); z-index: 6; display: flex; flex-direction: column; overflow: hidden; }
.lfilters { padding: 0 14px 8px; display: grid; gap: 8px; }
.ltext { width: 100%; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); outline: none; }
.ltext:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.fgrp { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fgrp > span { width: 62px; color: var(--muted); font-size: 12px; }
.fchip { padding: 3px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; }
.fchip:hover { background: var(--surface-hi); }
.fchip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 0 12px var(--halo-brand); }
.fsel { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 6px; }
.fsel select { height: 32px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); padding: 0 6px; font-size: 12px; min-width: 0; }
.lrows { overflow-y: auto; flex: 1; min-height: 120px; border-top: 1px solid var(--line); scrollbar-width: thin; }
.lrow { display: block; width: 100%; text-align: left; padding: 9px 14px; background: none; border: 0; border-bottom: 1px solid var(--line); }
.lrow:hover { background: var(--brand-soft); }
.lrow b { font-weight: 600; font-variant-numeric: tabular-nums; }
.lrow .tags { margin-left: 8px; color: var(--muted); font-size: 12px; }
.lrow small { display: block; color: var(--muted); margin-top: 1px; }
.kpirow { width: 100%; display: grid; grid-template-columns: 1fr auto 16px; gap: 8px; align-items: center; text-align: left; padding: 6px 8px; margin: 0 -8px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 12px; }
.kpirow:hover { background: var(--brand-soft); color: var(--ink); }
.kpirow b { color: var(--ink); font-weight: 500; }
.kpirow svg { width: 14px; height: 14px; }
.yk { display: grid; gap: 2px; }

/* thẻ cổng thu nhỏ khi mở thẻ container hoặc danh sách */
.gate.mini { width: 396px; padding: 8px 14px; }
.gm { display: flex; align-items: center; gap: 8px; }
.gm svg { width: 18px; height: 18px; color: var(--brand); filter: drop-shadow(0 0 6px var(--halo-brand)); flex: none; }
.gm b { font-weight: 600; }
.gate.mini ~ .cpanel, .gate.mini ~ .lpanel { top: 140px; max-height: calc(100vh - 140px - 196px); }

/* trạng thái dữ liệu: chip thụ động, số liệu cũ làm mờ */
.live.stale .dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(242, 178, 74, .2), 0 0 12px var(--halo-warn); }
.live.stale span { color: var(--warn); font-weight: 500; }
.live.off .dot { background: var(--fault); box-shadow: 0 0 0 3px rgba(255, 107, 95, .2), 0 0 12px var(--halo-fault); }
.live.off span { color: var(--fault); font-weight: 500; }
[data-feed="stale"] .fbtn b, [data-feed="off"] .fbtn b, [data-feed="stale"] .card .b b, [data-feed="off"] .card .b b,
[data-feed="stale"] .dbig b, [data-feed="off"] .dbig b, [data-feed="stale"] .gate b, [data-feed="off"] .gate b { opacity: .45; }
@media (max-width: 1180px) { .live span { display: inline !important; } .live:not(.stale):not(.off) span { display: none !important; } }
@media (max-width: 920px) { .lpanel { right: 16px; width: min(396px, calc(100vw - 32px)); } .gate.mini { display: none; } }

/* ---------- nền bản đồ thực tế: mặt nước, đất ngoài, bê tông bãi, nhựa đường, vạch sơn ---------- */
:root {
  --water-a: #06192f; --water-m: #0b3558; --water-b: #14507f; --foam: #bfe3ff;
  --outland: #1c3430; --veg: #2c5a44; --yard: #2b4963; --slab: rgba(190, 215, 235, .10);
  --apron: #3a5a74; --block: #1d3b56; --asphalt: #17232f; --asphalt2: #1f2e3c;
  --paint-w: #e9f0f5; --paint-y: #f2c94c; --paint-r: #e5584f; --bldg: #5f7a92; --bldg-line: #9db3be; --fence: #9db3be;
}
:root[data-theme="light"] {
  --water-a: #8fc0e0; --water-m: #a9d1ea; --water-b: #c4e2f3; --foam: #ffffff;
  --outland: #d6e3c8; --veg: #a9c78f; --yard: #d3d9dd; --slab: rgba(15, 42, 61, .08);
  --apron: #c3cbd1; --block: #bcc5cc; --asphalt: #5a646c; --asphalt2: #69737b;
  --paint-w: #ffffff; --paint-y: #e0b020; --paint-r: #d3433b; --bldg: #aeb9c2; --bldg-line: #6d7f8d; --fence: #6d7f8d;
}

/* ---------- giai đoạn 2: vai trò, bảng nổi, bảng dữ liệu, kịch bản, nạp tệp, kế hoạch đảo chuyển ---------- */
.rolesel { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; flex: none; }
.rolesel select { height: 30px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); padding: 0 6px; }
.fpanel { position: absolute; left: 348px; top: 88px; width: min(740px, calc(100vw - 348px - 100px)); max-height: calc(100vh - 88px - 196px); overflow-y: auto; z-index: 6; scrollbar-width: thin; }
.fp-body { padding: 0 14px 14px; display: grid; gap: 10px; }
.muted { color: var(--muted); margin: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.gantt { width: 100%; height: auto; } .gantt text { font-family: var(--font); }
.conf { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.conf li { display: flex; gap: 8px; align-items: flex-start; } .conf svg { width: 16px; height: 16px; flex: none; margin-top: 2px; filter: drop-shadow(0 0 5px var(--halo-warn)); }
.scens { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.scen { text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.scen b { display: block; font-weight: 500; } .scen small { color: var(--muted); }
.scen[aria-pressed="true"] { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(242, 178, 74, .12), 0 0 16px var(--halo-warn); }
.scen:disabled { opacity: .5; cursor: not-allowed; }
.dialog.wide { width: min(640px, 94vw); max-height: 86vh; overflow-y: auto; }
.drop { display: grid; place-items: center; padding: 22px; margin: 6px 0 10px; border: 1.5px dashed var(--line); border-radius: 12px; color: var(--muted); cursor: pointer; }
.drop.over, .drop:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--ink); }
.errs { max-height: 240px; overflow-y: auto; margin-bottom: 8px; }
.plan { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 12px; } .plan b { font-weight: 600; }
.plbody { padding: 0 14px 12px; display: grid; gap: 8px; } .plbody p { margin: 0; }
.row2 { display: flex; gap: 8px; } .bhead.static { cursor: default; padding: 10px 14px; font-size: 13px; font-weight: 500; }
@media (max-width: 920px) { .fpanel { left: 16px; width: calc(100vw - 32px); } .rolesel span { display: none; } }

/* ---------- khung 3D và góc nhìn POV ---------- */
.v3d { position: absolute; right: 84px; top: 88px; bottom: 196px; width: min(800px, 58vw); z-index: 8; display: flex; flex-direction: column; overflow: hidden; }
.v3d.full { left: 16px; width: auto; }
.v3d-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.v3d-head .grow { flex: 1; } .v3d-head select { height: 32px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); padding: 0 8px; }
.v3d-view { position: relative; flex: 1; min-height: 220px; overflow: hidden; background: var(--water-a); }
.v3d-load { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; color: var(--muted); z-index: 2; }
.hud { position: absolute; left: 12px; bottom: 12px; right: 12px; display: grid; gap: 6px; pointer-events: none; z-index: 3; }
.hud-box { display: inline-block; justify-self: start; padding: 4px 12px; border-radius: 10px; background: var(--pill); border: 1px solid var(--pill-line); box-shadow: 0 0 14px var(--halo-brand); }
.hud-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.hud-grid div { padding: 6px 10px; border-radius: 10px; background: var(--pill); border: 1px solid var(--pill-line); }
.hud-grid span { display: block; color: var(--muted); font-size: 11px; } .hud-grid b { font-weight: 500; font-variant-numeric: tabular-nums; }
.hud p { margin: 0; color: var(--ink); text-shadow: 0 1px 3px rgba(0,0,0,.6); } .hud .chip { justify-self: start; pointer-events: none; }
.povbtn { padding: 4px 10px; font-size: 12px; margin-left: 6px; }
@media (max-width: 920px) { .v3d { left: 16px; right: 16px; width: auto; } .hud-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- giai đoạn 4: màn hình cảm ứng, chế độ tài xế, giảm chuyển động ---------- */
@media (pointer: coarse) {
  .ibtn, .xbtn { width: 44px; height: 44px; } .cbtn, .btn, .fchip { min-height: 44px; } .lrow { padding: 14px; } .card { width: 132px; min-height: 64px; }
  .fchip { padding: 6px 14px; } .fsel select, .rolesel select, .ltext, .search input { min-height: 44px; }
}
html[data-mode="driver"] .left, html[data-mode="driver"] .gate, html[data-mode="driver"] .filters-wrap, html[data-mode="driver"] .rolesel,
html[data-mode="driver"] .dock .cmd, html[data-mode="driver"] .rail [data-panel], html[data-mode="driver"] #btnImport { display: none !important; }
html[data-mode="driver"] .top { right: 16px; } html[data-mode="driver"] .search { flex: 1 1 auto; }
html[data-mode="driver"] .search input { height: 48px; font-size: 17px; }
html[data-mode="driver"] .cpanel, html[data-mode="driver"] .lpanel { right: 16px; left: 16px; width: auto; max-height: calc(100vh - 88px - 110px); }
html[data-mode="driver"] .addr b { font-size: 26px; line-height: 1.25; } html[data-mode="driver"] .callout p { font-size: 16px; }
html[data-mode="driver"] .strip { display: none; }

/* ---------- định vị đa chứng cứ ---------- */
.locp { width: min(520px, calc(100vw - 348px - 100px)); }
.loclist { display: grid; gap: 4px; max-height: 190px; overflow-y: auto; scrollbar-width: thin; }
.locrow { display: grid; grid-template-columns: 1fr 70px; gap: 2px 8px; align-items: center; text-align: left; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.locrow:hover { background: var(--surface-hi); } .locrow[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), 0 0 14px var(--halo-brand); }
.locrow span { display: flex; align-items: center; gap: 6px; font-weight: 500; } .locrow span svg { width: 14px; height: 14px; }
.locrow small { grid-column: 1; color: var(--muted); } .locrow .confbar { grid-row: 1 / span 2; grid-column: 2; }
.confbar { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; } .confbar i { display: block; height: 100%; background: var(--ok); box-shadow: 0 0 8px var(--halo-ok); } .confbar i.w { background: var(--warn); box-shadow: 0 0 8px var(--halo-warn); } .confbar i.f { background: var(--fault); box-shadow: 0 0 8px var(--halo-fault); }
.locd h3 { margin: 4px 0 6px; font-size: 15px; font-weight: 600; } .locd .chips { padding: 0 0 8px; } .locd .kv { margin: 0 0 8px; }
.arearow { display: grid; grid-template-columns: 70px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; margin-top: 4px; } .arearow b { text-align: right; font-weight: 500; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; font-size: inherit; }
@media (max-width: 920px) { .locp { width: calc(100vw - 32px); } }

/* ---------- giao diện theo ECO: xám đen trong cảng, halo và quạt cảm biến xanh lá, thanh icon gọn ---------- */
:root {
  --yard: #1d2226; --apron: #272d32; --asphalt: #14181b; --asphalt2: #1a1f23; --block: #171b1e; --slab: rgba(255, 255, 255, .05);
  --bldg: #3a444c; --bldg-line: #6b7a85; --fence: #7d8b95; --outland: #18231f; --veg: #243d2e;
  --brand: #65eb76; --brand-soft: rgba(101, 235, 118, .14); --brand-ink: #06210b; --navy: #1d6b36; --on-navy: #fff; --halo-brand: rgba(101, 235, 118, .6);
  --glass: rgba(14, 19, 23, .5); --glass-strong: rgba(14, 19, 23, .9); --glass-edge: rgba(200, 225, 210, .16);
  --shadow: 0 12px 36px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(220, 240, 225, .08);
  --surface: rgba(255, 255, 255, .06); --surface-hi: rgba(255, 255, 255, .13); --field: rgba(0, 0, 0, .35);
  --line: rgba(200, 225, 210, .14); --pill: rgba(10, 14, 17, .86); --pill-line: rgba(200, 225, 210, .3);
  --truck-cab: #cfd8de; --base: #8d9aa3; --boom: #a3afb7; --ink: #e8efe9; --muted: #9bb0a4; --faint: #7f948a;
}
@media (min-width: 921px) {
  .left { width: 280px; } .dock { left: 312px; }
  .fpanel { left: 312px; width: min(740px, calc(100vw - 312px - 100px)); } .locp { width: min(520px, calc(100vw - 312px - 100px)); }
}
.dbig b, .gate .g2 b, .fbtn b, .hud-grid b, .card .b b { font-family: "Orbitron", var(--font); letter-spacing: .02em; }
.dbig b { font-size: 44px; font-weight: 500; } .gate .g2 b { font-size: 28px; font-weight: 500; } .fbtn b { font-size: 13px; font-weight: 500; } .card .b b { font-size: 13px; }
.rail { overflow: visible; }
.pop { position: absolute; right: 62px; width: 236px; padding: 6px; display: grid; gap: 2px; z-index: 9; }
.popitem { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; border: 1px solid transparent; background: none; text-align: left; color: var(--ink); }
.popitem svg { width: 18px; height: 18px; color: var(--muted); } .popitem:hover { background: var(--surface-hi); }
.popitem[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }
.popitem[aria-pressed="true"] svg { color: var(--brand); filter: drop-shadow(0 0 6px var(--halo-brand)); }
.dlab text { font-family: var(--font); }

/* ---------- cảm giác rê chuột: halo, nhấc nhẹ, gợn sóng, tooltip ---------- */
:is(.ibtn, .popitem, .card, .fbtn, .cbtn, .lrow, .locrow, .fchip, .btn, .xbtn, .kpirow, .scen, .lockbtn, .seg button):hover:not(:disabled) {
  border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), 0 0 18px var(--halo-brand);
}
.ibtn:hover:not(:disabled), .popitem:hover, .xbtn:hover { color: var(--brand); }
:is(.card, .lrow, .locrow, .scen, .kpirow):hover { transform: translateY(-1px); }
:is(.ibtn, .popitem, .card, .fbtn, .cbtn, .lrow, .locrow, .fchip, .btn, .xbtn, .kpirow, .scen, .lockbtn, .seg button):active:not(:disabled) { transform: scale(.97); box-shadow: 0 0 0 1px var(--brand), 0 0 26px var(--halo-brand); }
:is(.ibtn, .popitem, .card, .fbtn, .cbtn, .lrow, .locrow, .fchip, .btn, .xbtn, .kpirow, .scen, .lockbtn, .seg button) { transition: box-shadow .16s, border-color .16s, transform .12s, color .16s, background .16s; }
.dev:hover { filter: drop-shadow(0 0 7px var(--brand)); }
.hoverbox { fill: var(--brand); fill-opacity: .12; stroke: var(--brand); stroke-width: 1.5; filter: drop-shadow(0 0 5px var(--brand)); pointer-events: none; }
.hoverring { fill: none; stroke: var(--brand); stroke-width: 1.6; filter: drop-shadow(0 0 6px var(--brand)); pointer-events: none; }
.ripple { fill: none; stroke: var(--brand); stroke-width: 1.6; transform-box: fill-box; transform-origin: center; animation: ripple .55s ease-out forwards; pointer-events: none; }
@keyframes ripple { from { transform: scale(.5); opacity: .9; } to { transform: scale(2); opacity: 0; } }
.tip { position: fixed; z-index: 30; pointer-events: none; padding: 7px 10px; border-radius: 10px; max-width: 280px; font-size: 12px; line-height: 1.4; box-shadow: 0 0 16px var(--halo-brand), var(--shadow); }
.tip .muted { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .ripple { display: none; } :is(.card, .lrow, .locrow, .scen, .kpirow):hover, :is(.ibtn, .popitem, .card, .btn):active { transform: none !important; } }

/* ---------- kết nối máy chủ ---------- */
.srv { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 2px 9px; border: 1px solid var(--line); border-radius: 10px; white-space: nowrap; }
.srv i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--halo-ok); }
.srv.off { color: var(--fault); } .srv.off i { background: var(--fault); box-shadow: 0 0 8px var(--halo-fault); }
@media (max-width: 1180px) { .srv { display: none !important; } }
