/* BHSoft 3D GIS Demo — style dùng chung. Demo app: tối mặc định (bản đồ 3D dễ nhìn hơn trên nền tối). */
/* Bảng màu đồng bộ bachasoftware.com (trang 3D GIS): nền navy rất tối, card #0d1829,
   màu chính xanh lá #5fb645, nhấn cam #ff8000, font Be Vietnam Pro, bo góc 12–16px. */
:root {
  --bg: #050810;
  --bg-2: #0d1829;
  --panel: rgba(9, 15, 27, .93);
  --panel-solid: #0a1322;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #fcfcfd;
  --muted: rgba(252, 252, 253, .62);
  --faint: rgba(252, 252, 253, .42);
  --accent: #5fb645;
  --accent-ink: #050810;
  --accent-soft: rgba(95, 182, 69, .15);
  --accent-2: #ff8000;
  --accent-2-soft: rgba(255, 128, 0, .14);
  --teal: #7dc540;
  --ok: #5fb645;
  --warn: #f5b400;
  --alarm: #ff5a4a;
  --info: #4b8cf5;
  --radius: 14px;
  --shadow: 0 16px 40px rgba(0, 0, 0, .45);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --topbar-h: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: .92em; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: rgba(5, 8, 16, .92); border-bottom: 1px solid var(--border); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #7dc540, #397b21); display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 800; }
.brand small { color: var(--muted); font-weight: 500; }
.brand-logo { height: 36px; width: auto; display: block; }          /* logo chính thức từ bachasoftware.com */
.brand-sep { width: 1px; height: 22px; background: var(--border-strong); }
.topbar .title { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .title b { color: var(--text); font-weight: 600; }
.topbar .spacer { flex: 1; }
.nav-demos { position: relative; }
.nav-demos > button { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.nav-demos > button:hover { border-color: var(--border-strong); }
.nav-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 300px; background: var(--panel-solid); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; display: none; }
.nav-demos.open .nav-menu { display: block; }
.nav-menu a { display: block; padding: 8px 10px; border-radius: 7px; color: var(--text); }
.nav-menu a:hover, .nav-menu a.active { background: var(--accent-soft); text-decoration: none; }
.nav-menu a small { display: block; color: var(--muted); }
.nav-menu { max-height: calc(100vh - var(--topbar-h) - 16px); overflow: auto; }
.nav-company { margin-top: 6px; padding: 10px 10px 6px; border-top: 1px solid var(--border); font-size: 11.5px; line-height: 1.5; color: var(--muted); display: flex; flex-direction: column; max-width: 340px; }
.nav-company > a:first-child { padding: 0; color: var(--text); font-weight: 600; }
.nav-company a { display: inline; padding: 0; color: var(--accent); }
.nav-company a:hover { background: none; text-decoration: underline; }

/* ---------- Footer pháp nhân (đồng nhất với bachasoftware.com) ---------- */
.site-footer { margin-top: 48px; padding: 36px 0 28px; border-top: 1px solid var(--border); background: var(--bg); color: var(--muted); font-size: 13px; line-height: 1.6; }
.footer-inner { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; }
.footer-col { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.footer-col b { color: var(--text); font-weight: 600; margin-bottom: 2px; }
.footer-col a { color: var(--muted); }
.footer-col a:hover { color: var(--accent); }
.footer-logo { height: 44px; width: auto; display: block; margin-bottom: 8px; }
.footer-social { display: flex; flex-direction: column; gap: 4px; }
.footer-note { margin-top: 22px; color: var(--faint); font-size: 12px; }
.footer-legal { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; }
.footer-legal a { color: var(--muted); }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; gap: 20px; } }
.perf-badge { font-family: var(--mono); font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.perf-badge b { color: var(--text); }

/* ---------- Stage + panels ---------- */
.stage { position: fixed; inset: var(--topbar-h) 0 0 0; }
#map { position: absolute; inset: 0; }
.panel {
  position: absolute; top: 12px; z-index: 10; width: 330px; max-height: calc(100% - 24px); overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.panel.left { left: 12px; }
.panel.right { right: 12px; }
.panel.bottom { top: auto; bottom: 12px; left: 50%; transform: translateX(-50%); width: min(760px, calc(100% - 700px)); min-width: 420px; }
.panel section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.panel section:last-child { border-bottom: 0; }
.panel h2 { font-size: 15px; }
.panel h3 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.panel p { margin: 0 0 8px; color: var(--muted); }
.panel .lead { color: var(--text); }
.hidden { display: none !important; }

.sheet-toggle { display: none; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--bg-2); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #7dc540; border-color: #7dc540; }
.btn.orange { background: var(--accent-2); border-color: var(--accent-2); color: #fff; font-weight: 600; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 5px 10px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--accent-soft); color: var(--text); }
label.check { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
label.check input { accent-color: var(--accent); }
.field { display: grid; gap: 4px; margin-bottom: 8px; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, select.input, input.input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: 7px; padding: 6px 8px;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }

/* ---------- Data display ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi canvas { display: block; width: 100%; height: 26px; margin-top: 4px; }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv td { padding: 4px 0; border-bottom: 1px dashed var(--border); vertical-align: top; }
.kv td:first-child { color: var(--muted); padding-right: 10px; white-space: nowrap; }
.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 6px; border-bottom: 1px solid var(--border); }
table.grid td { padding: 6px 6px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover td, table.grid tr.sel td { background: var(--accent-soft); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid currentColor; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.alarm { color: var(--alarm); } .pill.info { color: var(--info); } .pill.muted { color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.alarm { background: var(--alarm); }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.feed li { padding: 7px 9px; border-radius: 7px; background: var(--bg-2); border-left: 3px solid var(--border-strong); cursor: pointer; font-size: 13px; }
.feed li.alarm { border-left-color: var(--alarm); } .feed li.warn { border-left-color: var(--warn); } .feed li.ok { border-left-color: var(--ok); }
.feed li:hover { background: var(--accent-soft); }
.legend { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.legend .ramp { height: 8px; border-radius: 4px; }
.legend .ends { display: flex; justify-content: space-between; }
.empty { color: var(--faint); font-style: italic; }
.note { font-size: 12px; color: var(--faint); }

/* ---------- Pipeline steps (BIM, upload) ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.steps li .ic { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: 11px; }
.steps li.run { color: var(--text); } .steps li.run .ic { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.steps li.done { color: var(--text); } .steps li.done .ic { border-color: var(--ok); background: var(--ok); color: #08130c; }
.steps li.fail .ic { border-color: var(--alarm); background: var(--alarm); }
.steps li .t { font-family: var(--mono); font-size: 11px; color: var(--faint); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Overlays ---------- */
.toast-host { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; }
.toast { background: var(--panel-solid); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 14px; box-shadow: var(--shadow); }
.toast.alarm { border-color: var(--alarm); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 20; background: var(--bg); transition: opacity .4s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading .spinner { width: 34px; height: 34px; border: 3px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
.loading p { color: var(--muted); text-align: center; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.map-tooltip { position: absolute; z-index: 15; pointer-events: none; background: var(--panel-solid); border: 1px solid var(--border-strong); border-radius: 6px; padding: 4px 8px; font-size: 12px; white-space: nowrap; transform: translate(12px, 12px); }
.timebar { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.timebar .clock { font-family: var(--mono); font-size: 13px; min-width: 120px; text-align: right; }
.demo-badge { position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; z-index: 5; font-size: 11px; color: var(--faint); background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; pointer-events: none; }

/* Cesium */
.cesium-viewer-bottom { opacity: .7; }
.cesium-widget-credits { font-size: 10px !important; }
.cesium-infoBox { display: none !important; }

/* ---------- Mobile: panels thành bottom sheet ---------- */
@media (max-width: 860px) {
  .topbar .title, .perf-badge { display: none; }
  .panel, .panel.bottom { left: 8px !important; right: 8px !important; width: auto; min-width: 0; transform: none; top: auto; bottom: 8px; max-height: 48%; }
  .panel.collapsed { display: none; }
  .sheet-toggle { display: flex; position: absolute; top: 10px; right: 10px; z-index: 12; gap: 6px; }
  .demo-badge { display: none; }
}
