/* Geoinformatic Services - Model WebGIS for Housing Societies
 * Theme tokens: light (default) and dark ([data-theme="dark"] on <html>, set before first paint).
 * Brand colours sampled from the official logo (geoinformaticservices.com): purple #A3309F, orange #C2581F.
 */
:root {
  color-scheme: light;
  --brand-purple: #A3309F; --brand-orange: #C2581F; --brand-gold: #F2A71B;
  --brand-grad: linear-gradient(90deg, #F2A71B 0%, #E2701F 40%, #C2581F 60%, #A3309F 100%);
  --accent: #A3309F; --accent-hover: #8A2687; --accent-ink: #FFFFFF; --accent-soft: #F7EAF6; --accent-line: #E7C3E4;
  --accent2: #C2581F; --amber: #F4A300;
  --bg: #F3F5F8; --panel: #FFFFFF; --panel2: #FAFBFC; --panel3: #F6F8FA; --line: #E2E7ED; --line2: #EEF1F5;
  --text: #1C2733; --muted: #64768A; --heading: #0A2540; --chip: #EEF2F6; --hover: #F6EEF6; --sel-row: #FFF4D6;
  --input: #FFFFFF; --th: #F1F4F7; --code: #EEF2F6; --track: #E7EBF0; --strong: #0A2540; --strong-ink: #FFFFFF;
  --hdr-bg: #FFFFFF; --hdr-text: #0A2540; --hdr-muted: #5B6B7D; --hdr-ctl: #F3F5F8; --hdr-ctl-line: #D9E0E8;
  --legend-bg: rgba(255, 255, 255, .96); --float-bg: #FFFFFF; --float-ink: #0A2540; --coords-bg: rgba(10, 37, 64, .86);
  --answer-bg: #FFF8EC; --answer-ink: #4A3300; --qs-bg: #FBF4FA; --qs-line: #EACBE7;
  --doc-bg: #FFFDF5; --doc-line: #D9CBA0; --doc-ink: #3B2F12;
  --ok: #2B9348; --warn: #F8961E; --bad: #D00000;
  --hdr: 60px; --left: 340px; --right: 390px; --bottom: 250px;
  --shadow: 0 6px 22px rgba(10, 37, 64, .16);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #D777CF; --accent-hover: #E494DD; --accent-ink: #1A0E19; --accent-soft: #33202F; --accent-line: #5A3655;
  --accent2: #F08A3C; --amber: #F6B533;
  --bg: #0C1117; --panel: #131A22; --panel2: #171F29; --panel3: #1A232E; --line: #273240; --line2: #1E2833;
  --text: #DCE3EA; --muted: #8F9CAB; --heading: #F1F4F8; --chip: #1E2833; --hover: #261D2A; --sel-row: #3B3220;
  --input: #0F151C; --th: #19222C; --code: #1E2833; --track: #26313D; --strong: #E6ECF2; --strong-ink: #0C1117;
  --hdr-bg: #0F151C; --hdr-text: #EEF2F6; --hdr-muted: #93A1B2; --hdr-ctl: #18212B; --hdr-ctl-line: #2C3846;
  --legend-bg: rgba(19, 26, 34, .95); --float-bg: #1A232E; --float-ink: #E6ECF2; --coords-bg: rgba(0, 0, 0, .72);
  --answer-bg: #2A2214; --answer-ink: #F1DEB4; --qs-bg: #221923; --qs-line: #4A2F47;
  --doc-bg: #FFFDF5; --doc-line: #D9CBA0; --doc-ink: #3B2F12;
  --shadow: 0 8px 26px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.45 "Segoe UI", Inter, system-ui, -apple-system, Roboto, Arial, sans-serif; }
button, select, input { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: inline-block; }

/* ---------------------------------------------------------------- header */
.app { display: grid; grid-template-rows: var(--hdr) minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); height: 100vh; width: 100%; overflow: hidden; }
.main, section.bottom, header.top { min-width: 0; }
header.top { display: flex; align-items: center; gap: 14px; padding: 0 12px; color: var(--hdr-text); min-width: 0; position: relative;
  background: var(--hdr-bg); box-shadow: 0 2px 10px rgba(10, 37, 64, .08); z-index: 5; }
header.top::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--brand-grad); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--hdr-text); min-width: 0; flex-shrink: 0; }
.brand img.brand-logo { height: 46px; width: auto; flex-shrink: 0; }
.brand .prod { border-left: 1px solid var(--hdr-ctl-line); padding-left: 12px; line-height: 1.15; }
.brand .t1 { font-weight: 800; font-size: 14px; letter-spacing: .02em; color: var(--hdr-text); }
.brand .t2 { font-size: 11.5px; color: var(--accent2); font-weight: 600; letter-spacing: .02em; }
.scheme-chip { background: var(--hdr-ctl); border: 1px solid var(--hdr-ctl-line); padding: 4px 10px; border-radius: 16px; font-size: 12px; white-space: nowrap; color: var(--hdr-muted); }
.scheme-chip b { color: var(--accent); }
.filters { display: flex; align-items: center; gap: 6px; }
.filters label, .role { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--hdr-muted); }
.filters select, .role select { background: var(--hdr-ctl); border: 1px solid var(--hdr-ctl-line); color: var(--hdr-text); border-radius: 6px; padding: 4px 6px; max-width: 128px; }
.icon-btn { background: var(--hdr-ctl); border: 1px solid var(--hdr-ctl-line); color: var(--hdr-text); border-radius: 6px; padding: 4px 9px; cursor: pointer; line-height: 1.2; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 30px; padding: 0; }
.theme-btn svg { width: 17px; height: 17px; }
.theme-btn .moon { display: inline; } .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: inline; }
.spacer { flex: 1; }
nav.nav { display: flex; gap: 2px; background: var(--hdr-ctl); border: 1px solid var(--hdr-ctl-line); border-radius: 9px; padding: 3px; }
nav.nav a { color: var(--hdr-text); text-decoration: none; padding: 5px 11px; border-radius: 6px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
nav.nav a:hover { color: var(--accent); }
nav.nav a.active { background: var(--brand-grad); color: #fff; }
#menuBtn { display: none; }

/* ---------------------------------------------------------------- layout */
.main { display: grid; grid-template-columns: var(--left) minmax(0, 1fr) var(--right); min-height: 0; }
.main.no-right { grid-template-columns: var(--left) minmax(0, 1fr) 0; }
.main.no-right aside.right { display: none; }
.main.no-left { grid-template-columns: 0 minmax(0, 1fr) var(--right); }
.main.no-left aside.left { display: none !important; }
.main.no-left.no-right { grid-template-columns: 0 minmax(0, 1fr) 0; }
.main.no-left.no-right aside.left,
.main.no-left.no-right aside.right { display: none !important; }
.app.embed-mode #bottom { display: none !important; }
.app.embed-mode .legend { display: none; }
.app.embed-mode .demo-chip,
.app.embed-mode .coords,
.app.embed-mode .tool-hint { display: none !important; }
.app.embed-mode #menuBtn { display: none !important; }
.app.embed-mode header.top {
  height: 44px;
  padding: 0 10px;
}
.app.embed-mode header.top .brand img {
  height: 22px;
}
.app.embed-mode header.top .scheme-chip,
.app.embed-mode header.top .prod,
.app.embed-mode header.top #helpBtn,
.app.embed-mode header.top .theme-btn {
  display: none !important;
}
.app.embed-mode header.top .filters {
  gap: 4px;
}
.app.embed-mode header.top .filters label select {
  font-size: 11px;
  padding: 2px 4px;
}
.app.embed-mode header.top nav.nav a {
  padding: 3px 8px;
  font-size: 11px;
}
.app.embed-mode .map-ctl {
  top: 8px;
  left: 8px;
  flex-direction: row;
  gap: 4px;
  z-index: 10;
}
.app.embed-mode .map-ctl button {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  background: rgba(255, 255, 255, 0.92);
}
.app.embed-mode aside.right {
  position: absolute;
  top: 44px;
  bottom: 0;
  right: 0;
  width: min(320px, 80%);
  z-index: 30;
  box-shadow: -4px 0 20px rgba(0,0,0,0.2);
}
aside.left, aside.right { background: var(--panel); min-height: 0; display: flex; flex-direction: column; }
aside.left { border-right: 1px solid var(--line); }
aside.right { border-left: 1px solid var(--line); }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--panel2); flex-shrink: 0; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px 4px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button:hover { color: var(--heading); }
.tabs button.active { color: var(--heading); border-bottom-color: var(--accent); background: var(--panel); }
.tabpane { overflow: auto; flex: 1; padding: 10px 12px 18px; min-height: 0; }
h3.sec { margin: 14px 0 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent2); }
h3.sec:first-child { margin-top: 2px; }
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.field > span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
select.inp, input.inp { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--input); color: var(--text); }
input.inp:focus, select.inp:focus { outline: 2px solid var(--accent-line); border-color: var(--accent); }
.row { display: flex; gap: 6px; align-items: center; }
.row > * { min-width: 0; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-weight: 600; color: var(--heading); text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.active { background: var(--strong); color: var(--strong-ink); border-color: var(--strong); }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* layer list */
.lyr { display: flex; align-items: center; gap: 7px; padding: 4px 2px; border-radius: 5px; }
.lyr:hover { background: var(--line2); }
.lyr input[type=checkbox] { accent-color: var(--accent); }
.lyr .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(127, 127, 127, .35); flex-shrink: 0; }
.lyr label { flex: 1; cursor: pointer; }
.opacity { width: 70px; accent-color: var(--accent); }
.basemaps { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.basemaps button { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 5px 7px; cursor: pointer; font-size: 12px; color: var(--text); }
.basemaps button:hover { border-color: var(--accent); }
.basemaps button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--heading); font-weight: 700; }

/* ---------------------------------------------------------------- map */
#mapWrap { position: relative; min-width: 0; min-height: 0; }
#map { position: absolute; inset: 0; }
.map-ctl { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.map-ctl button { background: var(--float-bg); border: 0; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); padding: 6px 9px; cursor: pointer;
  font-weight: 700; font-size: 12px; color: var(--float-ink); text-align: left; }
.map-ctl button.on { background: var(--brand-grad); color: #fff; }
.legend { position: absolute; left: 10px; bottom: 34px; background: var(--legend-bg); border-radius: 8px; box-shadow: var(--shadow); color: var(--text);
  padding: 8px 10px; max-height: 52%; overflow: auto; min-width: 190px; max-width: 260px; z-index: 2; font-size: 12px; }
.legend h4 { margin: 4px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent2); }
.legend .li { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.legend .sw { width: 16px; height: 11px; border-radius: 2px; border: 1px solid rgba(127, 127, 127, .4); flex-shrink: 0; }
.legend .sw.line { height: 4px; border: 0; }
.legend details > summary { cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent2); font-weight: 700; margin: 6px 0 2px; }
.legend .head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 700; color: var(--heading); }
.legend.min .body { display: none; }
.coords { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); background: var(--coords-bg); color: #E8F4F8;
  font: 11.5px/1.2 Consolas, "Cascadia Mono", monospace; padding: 5px 10px; border-radius: 14px; white-space: nowrap; z-index: 2; pointer-events: none; }
.demo-chip { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(244, 163, 0, .95); color: #1d1300;
  font-size: 11.5px; font-weight: 700; padding: 4px 12px; border-radius: 14px; z-index: 2; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.tool-hint { position: absolute; top: 44px; left: 50%; transform: translateX(-50%); background: var(--strong); color: var(--strong-ink); padding: 7px 14px;
  border-radius: 8px; z-index: 3; box-shadow: var(--shadow); font-weight: 600; display: flex; gap: 10px; align-items: center; }
.tool-hint .btn { padding: 2px 8px; }
.loading-3d { position: absolute; top: 44px; left: 50%; transform: translateX(-50%); background: var(--float-bg); color: var(--float-ink); padding: 6px 14px;
  border-radius: 8px; z-index: 3; box-shadow: var(--shadow); font-weight: 600; }
.maplibregl-ctrl-group button { width: 30px; height: 30px; }
.maplibregl-popup-content { padding: 8px 10px; border-radius: 8px; font: 12px "Segoe UI", sans-serif; background: var(--float-bg); color: var(--text); box-shadow: var(--shadow); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--float-bg); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--float-bg); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--float-bg); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--float-bg); }
:root[data-theme="dark"] .maplibregl-ctrl-group { background: #1A232E; box-shadow: 0 0 0 1px #2C3846; }
:root[data-theme="dark"] .maplibregl-ctrl-group button + button { border-top-color: #2C3846; }
:root[data-theme="dark"] .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1) hue-rotate(180deg); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib, :root[data-theme="dark"] .maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(19, 26, 34, .85); color: #C9D3DD; }
:root[data-theme="dark"] .maplibregl-ctrl-attrib a { color: #C9D3DD; }
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }
:root[data-theme="dark"] .maplibregl-ctrl-scale { background: rgba(19, 26, 34, .8); color: #DCE3EA; border-color: #DCE3EA; }

/* ---------------------------------------------------------------- right / identify */
.right-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--panel2); font-weight: 700; color: var(--heading); flex-shrink: 0; }
.right-head button { border: 0; background: none; cursor: pointer; font-size: 15px; color: var(--muted); }
.id-body { overflow: auto; flex: 1; padding: 10px 12px 24px; min-height: 0; }
.empty { color: var(--muted); padding: 18px 6px; text-align: center; }
.empty b { color: var(--heading); }
.hits { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.hits button { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 2px 9px; font-size: 11.5px; cursor: pointer; color: var(--text); }
.hits button.active { background: var(--strong); color: var(--strong-ink); border-color: var(--strong); }
.card-title { font-size: 18px; font-weight: 800; color: var(--heading); line-height: 1.2; }
.card-sub { color: var(--muted); margin: 2px 0 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 8px; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 12px; padding: 2px 9px; font-size: 11.5px; font-weight: 600;
  background: var(--chip); color: var(--heading); border: 1px solid var(--line2); }
.badge i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.kpi { background: var(--panel3); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 9px; }
.kpi .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.kpi .v { font-size: 15px; font-weight: 800; color: var(--heading); }
.kpi .s { font-size: 11px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 10px; }
details.grp { border: 1px solid var(--line); border-radius: 8px; margin: 7px 0; background: var(--panel); }
details.grp > summary { cursor: pointer; padding: 7px 10px; font-weight: 700; color: var(--heading); list-style: none; display: flex; justify-content: space-between; }
details.grp > summary::after { content: '▾'; color: var(--muted); }
details.grp:not([open]) > summary::after { content: '▸'; }
details.grp > summary .lock { font-weight: 600; font-size: 11px; color: var(--muted); }
table.kv { width: 100%; border-collapse: collapse; font-size: 12.3px; }
table.kv td { padding: 4px 10px; border-top: 1px solid var(--line2); vertical-align: top; }
table.kv td:first-child { color: var(--muted); width: 44%; }
table.kv td:last-child { font-weight: 600; word-break: break-word; }
table.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
table.mini th { text-align: left; font-size: 10.5px; color: var(--muted); text-transform: uppercase; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.mini td { padding: 4px 6px; border-bottom: 1px solid var(--line2); }
table.mini tr.click { cursor: pointer; }
table.mini tr.click:hover { background: var(--hover); }
.restricted { font-size: 12px; color: var(--muted); padding: 6px 10px 9px; }
.bar { height: 8px; background: var(--track); border-radius: 5px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.prog-row { display: grid; grid-template-columns: 110px 1fr 42px; gap: 8px; align-items: center; margin: 3px 0; font-size: 12px; }
.stepper { display: flex; gap: 2px; margin: 8px 0; }
.stepper div { flex: 1; height: 8px; border-radius: 2px; background: var(--track); }
.stepper div.on { background: var(--accent); }
.stepper div.cur { background: var(--amber); }
.chart-box { position: relative; height: 150px; margin: 6px 0 4px; }

/* search / query */
.result-list { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.result-list button { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 8px; cursor: pointer; color: var(--text); }
.result-list button:hover { border-color: var(--accent); background: var(--hover); }
.result-list .r1 { font-weight: 700; color: var(--heading); }
.result-list .r2 { font-size: 11.5px; color: var(--muted); }
.q-aud { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 7px; overflow: hidden; }
.q-aud > summary { padding: 8px 10px; font-weight: 700; cursor: pointer; background: var(--panel2); color: var(--heading); list-style: none; }
.q-aud > summary .cnt { float: right; color: var(--muted); font-weight: 600; font-size: 11.5px; }
.q-item { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line2); background: var(--panel); padding: 7px 10px;
  cursor: pointer; font-size: 12.5px; color: var(--text); }
.q-item:hover { background: var(--hover); color: var(--accent); }
.q-item.active { background: var(--accent-soft); font-weight: 700; color: var(--heading); }
.q-summary { border: 1px solid var(--qs-line); background: var(--qs-bg); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.q-summary .qt { font-weight: 800; color: var(--heading); margin-bottom: 4px; }
.cond { display: grid; grid-template-columns: 1fr; gap: 4px; border: 1px dashed var(--line); padding: 7px; border-radius: 7px; margin-bottom: 6px; }

/* ---------------------------------------------------------------- bottom panel */
section.bottom { height: var(--bottom); border-top: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
section.bottom.collapsed { height: 36px; }
section.bottom.collapsed .bottom-body { display: none; }
.bottom-head { display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 36px; border-bottom: 1px solid var(--line); background: var(--panel2); flex-shrink: 0; }
.bottom-head .tabs { border: 0; background: none; }
.bottom-head .tabs button { flex: none; padding: 8px 12px; }
.bottom-head select, .bottom-head input { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; background: var(--input); color: var(--text); font-size: 12px; }
.bottom-body { flex: 1; min-height: 0; display: flex; }
.bottom-body > div { flex: 1; min-height: 0; min-width: 0; }
#tablePane { display: flex; flex-direction: column; }
.tbl-wrap { overflow: auto; flex: 1; min-height: 0; }
table.attr { border-collapse: separate; border-spacing: 0; font-size: 12px; width: max-content; min-width: 100%; }
table.attr th { position: sticky; top: 0; background: var(--th); text-align: left; padding: 6px 9px; border-bottom: 1px solid var(--line);
  cursor: pointer; white-space: nowrap; font-size: 11.5px; color: var(--heading); z-index: 1; }
table.attr th.sorted::after { content: ' ▾'; color: var(--accent); }
table.attr th.sorted.asc::after { content: ' ▴'; }
table.attr td { padding: 4px 9px; border-bottom: 1px solid var(--line2); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
table.attr tr:hover td { background: var(--hover); cursor: pointer; }
table.attr tr.sel td { background: var(--sel-row); }
.tbl-foot { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); flex-shrink: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
#summaryPane { display: grid; grid-template-columns: 300px repeat(4, minmax(0, 1fr)); gap: 10px; padding: 8px 10px; overflow: auto; }
.kgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-content: start; }
.kgrid .kpi .v { font-size: 14px; }
.chart-card { border: 1px solid var(--line2); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.chart-card h5 { margin: 0 0 2px; font-size: 11.5px; color: var(--heading); }
.chart-card .cv { position: relative; flex: 1; min-height: 150px; }

/* ---------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; background: rgba(5, 10, 20, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--panel); color: var(--text); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); width: min(880px, 100%); max-height: 90vh; display: flex; flex-direction: column; border: 1px solid var(--line); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 800; color: var(--heading); font-size: 15px; }
.modal-head button { border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 14px 18px 20px; overflow: auto; }
.modal-body h4 { color: var(--heading); }
.doc { border: 2px solid #C9B98A; background: var(--doc-bg); color: var(--doc-ink); padding: 22px 26px; position: relative; font-family: Georgia, "Times New Roman", serif; }
.doc h2 { text-align: center; margin: 0 0 4px; color: var(--doc-ink); }
.doc .doc-sub { text-align: center; color: #6B5B32; margin-bottom: 14px; }
.doc table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.doc td, .doc th { border: 1px solid var(--doc-line); padding: 5px 8px; text-align: left; font-size: 13px; }
.doc .wm { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 64px; color: rgba(208, 0, 0, .08);
  font-weight: 900; transform: rotate(-22deg); pointer-events: none; font-family: Arial, sans-serif; }
.doc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.doc-head img { height: 40px; }

/* ---------------------------------------------------------------- dashboard & data pages */
.page { max-width: 1480px; width: 100%; min-width: 0; margin: 0 auto; padding: 16px 18px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; font-size: 22px; color: var(--heading); }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.dtabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0 14px; }
.dtabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 13px; cursor: pointer; font-weight: 700; color: var(--heading); }
.dtabs button:hover { border-color: var(--accent); }
.dtabs button.active { background: var(--brand-grad); color: #fff; border-color: transparent; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi-row .kpi { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 12px; }
.kpi-row .kpi .v { font-size: 20px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.card h4 { margin: 0 0 8px; font-size: 13px; color: var(--heading); display: flex; justify-content: space-between; gap: 8px; }
.card h4 span { font-weight: 600; color: var(--muted); font-size: 11.5px; }
.card .cv { position: relative; height: 260px; }
.card .minimap { height: 330px; border-radius: 8px; overflow: hidden; position: relative; }
.answer { border-left: 4px solid var(--amber); background: var(--answer-bg); padding: 9px 12px; border-radius: 6px; margin-bottom: 12px; color: var(--answer-ink); }
.scroll-table { max-height: 330px; overflow: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 12.2px; }
table.dt th { position: sticky; top: 0; background: var(--th); text-align: left; padding: 6px 8px; font-size: 11.5px; color: var(--heading); }
table.dt td { padding: 5px 8px; border-bottom: 1px solid var(--line2); }
table.dt td.num, table.dt th.num { text-align: right; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
.foot img { height: 46px; }
.dict-layer { margin-bottom: 18px; }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

@media (max-width: 1720px) { .scheme-chip { display: none; } .role > span { display: none; } }
@media (max-width: 1500px) { .brand .prod { display: none; } }
@media (max-width: 1440px) { .filters label span.fl { display: none; } nav.nav a { padding: 5px 8px; } }
@media (max-width: 1280px) { :root { --left: 300px; --right: 340px; } #summaryPane { grid-template-columns: 260px repeat(3, minmax(0, 1fr)); } #summaryPane .chart-card:nth-child(5) { display: none; } }
@media (max-width: 1020px) {
  :root { --right: 0px; }
  .filters label span.fl { display: none; }
  .main, .main.no-right { grid-template-columns: minmax(0, 1fr); }
  aside.left { position: absolute; z-index: 20; top: var(--hdr); bottom: 0; left: 0; width: min(340px, 92vw); box-shadow: var(--shadow); transform: translateX(-105%); transition: transform .2s; }
  .main.show-left aside.left { transform: none; }
  aside.right { position: absolute; z-index: 21; top: var(--hdr); bottom: 0; right: 0; width: min(380px, 94vw); box-shadow: var(--shadow); }
  #menuBtn { display: inline-block; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  #summaryPane { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .filters, .role, nav.nav { display: none; }
  .legend { max-height: 34%; }
  .brand img.brand-logo { height: 32px; }
}
@media (max-width: 600px) {
  :root { --bottom: 230px; }
  #summaryPane { grid-template-columns: 1fr; }
  .page { padding: 12px 10px 30px; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .demo-chip { font-size: 10.5px; padding: 3px 8px; top: 8px; }
  .legend { min-width: 0; max-width: 62%; }
}
@media print {
  header.top nav, .filters, .role, #helpBtn, .theme-btn, aside.left, section.bottom, .map-ctl, .maplibregl-ctrl, .demo-chip { display: none !important; }
  .main { grid-template-columns: 1fr 340px !important; }
  .app { height: auto; }
  #mapWrap { height: 92vh; }
}
