:root {
  --ink: #183331;
  --muted: #647875;
  --line: #dce7e5;
  --soft: #f3f8f7;
  --teal: #087f78;
  --teal-dark: #05645f;
  --white: #fff;
  --shadow: 0 12px 36px rgba(24, 51, 49, .14);
}

* { box-sizing: border-box; }
html, body, .app-shell { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--ink); background: #eef4f3; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(8, 127, 120, .22); outline-offset: 1px; }
.hidden { display: none !important; }
.mobile-only { display: none; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; min-width: 242px; }
.brand img { width: 39px; height: 39px; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 14px; letter-spacing: .01em; }
.brand small { color: var(--teal); font-size: 12px; margin-top: 4px; font-weight: 600; }
.search-wrap { max-width: 650px; flex: 1; position: relative; }
.search-wrap > span { position: absolute; z-index: 2; left: 14px; top: 10px; color: var(--muted); font-size: 22px; transform: rotate(-15deg); }
.search-wrap input {
  width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 9px;
  padding: 0 42px; color: var(--ink); background: var(--soft);
}
.search-wrap input:focus { background: #fff; border-color: var(--teal); }
.search-results {
  position: absolute; top: 48px; left: 0; right: 0; max-height: 330px; overflow: auto;
  background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 50;
}
.search-results button { width: 100%; border: 0; background: white; text-align: left; padding: 12px 14px; border-bottom: 1px solid #edf2f1; color: var(--ink); }
.search-results button:hover { background: var(--soft); }
.search-results button strong, .search-results button small { display: block; }
.search-results button small { color: var(--muted); margin-top: 3px; }
.demo-badge { color: #75550b; background: #fff5d5; border: 1px solid #f3dfa1; border-radius: 999px; padding: 6px 10px; font-size: 11px; white-space: nowrap; }
.contact-link { color: white; background: var(--teal); border-radius: 8px; padding: 11px 15px; text-decoration: none; font-weight: 700; font-size: 12px; white-space: nowrap; }
.contact-link:hover { background: var(--teal-dark); }

.workspace { height: calc(100% - 68px); display: flex; position: relative; }
.side-panel {
  width: 326px; min-width: 326px; height: 100%; background: white; border-right: 1px solid var(--line);
  overflow-y: auto; z-index: 11;
}
.panel-head { padding: 20px 19px 15px; display: flex; align-items: start; justify-content: space-between; }
.eyebrow, .field-label { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.panel-head h1 { font-size: 20px; margin: 5px 0 0; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0 13px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 3px solid transparent; padding: 11px 3px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.tabs button.active { color: var(--teal); border-bottom-color: var(--teal); }
.tab-panel { display: none; padding: 17px 18px 25px; }
.tab-panel.active { display: block; }
.tab-panel select, .tab-panel input[type="text"], .tab-panel input:not([type]) {
  width: 100%; height: 39px; border: 1px solid var(--line); border-radius: 7px; background: white; padding: 0 10px; color: var(--ink);
}
.field-label { margin: 12px 0 7px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 21px 0 10px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.section-title button { border: 0; color: var(--teal); background: transparent; font-size: 11px; text-transform: none; }

.layer-list { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.layer-row { padding: 11px; border-bottom: 1px solid var(--line); }
.layer-row:last-child { border-bottom: 0; }
.layer-main { display: flex; align-items: center; gap: 9px; }
.layer-main input { accent-color: var(--teal); }
.layer-main span { flex: 1; font-size: 13px; font-weight: 650; }
.layer-main b { font-size: 10px; color: var(--muted); font-weight: 500; }
.layer-row input[type="range"] { display: block; width: calc(100% - 28px); margin: 9px 0 0 28px; accent-color: var(--teal); height: 3px; }
.filter-card, .chart-card { background: var(--soft); border-radius: 10px; padding: 1px 12px 13px; margin-top: 16px; }
.filter-card .section-title { margin-top: 12px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 11px; color: var(--muted); }
.legend .section-title { grid-column: 1 / -1; margin-bottom: 1px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.water { background: #2389da; } .power { background: #efad23; } .health { background: #df5361; } .transport { background: #7a62d3; }
.legend-diamond { display: inline-block; width: 10px; height: 10px; margin: 0 7px 0 2px; transform: rotate(45deg); background: #e64a39; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.metric-grid article { border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: #fff; }
.metric-grid span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .07em; }
.metric-grid strong { display: block; font-size: 25px; margin: 6px 0 3px; color: var(--teal-dark); }
.metric-grid small { font-size: 9px; color: var(--muted); }
.chart-card { background: white; border: 1px solid var(--line); padding: 0 12px 13px; }
.chart-card .section-title { margin-top: 13px; }
.bar-row { display: grid; grid-template-columns: 65px 1fr 22px; gap: 8px; align-items: center; margin: 10px 0; font-size: 10px; }
.bar-track { height: 8px; border-radius: 5px; background: var(--soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--teal); }
.donut-layout { display: flex; align-items: center; gap: 18px; padding: 6px 0; }
.donut { width: 92px; height: 92px; border-radius: 50%; position: relative; background: conic-gradient(#1a9c8e 0 60%, #efa929 60% 82%, #dc5261 82%); }
.donut::after { content: ""; position: absolute; inset: 17px; border-radius: 50%; background: white; }
.donut-legend { flex: 1; }
.donut-legend div { font-size: 10px; color: var(--muted); margin: 8px 0; display: flex; justify-content: space-between; }
.donut-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.tool-intro { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0 0 14px; }
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tool-grid button { min-height: 65px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); }
.tool-grid button b, .tool-grid button span { display: block; }
.tool-grid button b { color: var(--teal); font-size: 20px; margin-bottom: 4px; }
.tool-grid button span { font-size: 10px; font-weight: 700; }
.tool-grid button.active { color: white; background: var(--teal); border-color: var(--teal); }
.tool-grid button.active b { color: white; }
.drawing-notice { min-height: 39px; margin: 13px 0; padding: 10px; background: var(--soft); border-radius: 7px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.primary { border: 0 !important; background: var(--teal) !important; color: white !important; }
.wide { width: 100%; padding: 10px; border-radius: 7px; }
button:disabled { opacity: .43; cursor: not-allowed; }
.drawing-list { margin-top: 15px; }
.drawing-item { display: flex; align-items: center; gap: 8px; width: 100%; border: 1px solid var(--line); border-radius: 7px; background: white; padding: 9px; margin: 6px 0; text-align: left; font-size: 11px; }
.drawing-item.selected { border-color: var(--teal); background: #ecf8f6; }
.drawing-item i { width: 10px; height: 10px; border-radius: 50%; }
.drawing-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 13px; }
.drawing-actions button, .editor button { border: 1px solid var(--line); border-radius: 6px; background: white; padding: 8px; color: var(--ink); font-size: 10px; }
.drawing-actions button:last-child { grid-column: auto; }
.drawing-actions + .wide { margin-top: 8px; }
.editor { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 5px; }
.editor input[type="color"] { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 6px; background: white; padding: 3px; }
.editor > div { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }

.map-region { flex: 1; min-width: 0; height: 100%; position: relative; }
#map { position: absolute; inset: 0 0 30px; background: #e9efed; }
.maplibregl-ctrl-top-right { top: 12px; right: 12px; }
.maplibregl-ctrl-group { border-radius: 8px !important; box-shadow: 0 2px 10px rgba(24,51,49,.13) !important; }
.map-tools { position: absolute; right: 13px; top: 127px; z-index: 5; display: grid; gap: 6px; }
.map-tools button, .icon-button { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--ink); box-shadow: 0 2px 9px rgba(24,51,49,.12); }
.capability-tools { position: absolute; z-index: 5; top: 14px; left: 15px; display: flex; gap: 7px; }
.capability-tools button { border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); box-shadow: 0 2px 9px rgba(24,51,49,.12); padding: 9px 11px; font-size: 11px; font-weight: 700; }
.capability-tools button:hover, .capability-tools button.active { border-color: var(--teal); color: var(--teal); }
.capability-tools span { color: var(--teal); margin-right: 5px; }
.offline-notice { position: absolute; z-index: 6; top: 14px; left: 50%; transform: translateX(-50%); border: 1px solid #e4c878; background: #fff6d9; color: #74580d; border-radius: 7px; padding: 9px 13px; font-size: 11px; box-shadow: var(--shadow); }
.feature-panel { position: absolute; z-index: 7; top: 58px; left: 15px; width: 290px; max-height: calc(100% - 108px); overflow: auto; background: white; border-radius: 11px; padding: 17px; box-shadow: var(--shadow); }
.feature-panel:not(.hidden) ~ .analysis-panel { left: 320px; }
.feature-panel > button { position: absolute; top: 9px; right: 9px; border: 0; background: transparent; font-size: 20px; color: var(--muted); }
.feature-panel h2 { font-size: 18px; margin: 7px 25px 14px 0; }
.detail-row { border-top: 1px solid var(--line); padding: 8px 0; display: grid; grid-template-columns: 40% 1fr; gap: 6px; font-size: 11px; }
.detail-row span { color: var(--muted); }
.analysis-panel { position: absolute; z-index: 8; top: 58px; left: 15px; width: 300px; background: white; border-radius: 11px; padding: 17px; box-shadow: var(--shadow); }
.analysis-panel > button[aria-label] { position: absolute; right: 9px; top: 8px; border: 0; background: transparent; color: var(--muted); font-size: 20px; }
.analysis-panel h2 { margin: 6px 22px 15px 0; font-size: 18px; }
.analysis-panel select { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; background: white; }
.analysis-panel input[type="range"] { width: 100%; accent-color: var(--teal); }
.analysis-panel output { float: right; color: var(--teal); }
.analysis-panel .wide { margin-top: 12px; padding: 10px; border-radius: 7px; }
.secondary { background: white; color: var(--ink); border: 1px solid var(--line); }
.analysis-result { background: var(--soft); border-radius: 8px; padding: 11px; margin-top: 12px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.analysis-result strong { color: var(--teal-dark); font-size: 20px; display: block; margin-bottom: 3px; }
.attribute-drawer { position: absolute; z-index: 10; bottom: 30px; left: 0; right: 0; height: 310px; background: white; border-top: 1px solid var(--line); box-shadow: 0 -10px 28px rgba(24,51,49,.13); display: flex; flex-direction: column; }
.attribute-drawer header { min-height: 62px; padding: 9px 13px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); gap: 12px; }
.attribute-drawer h2 { font-size: 15px; margin: 3px 0 0; }
.table-controls { display: flex; gap: 7px; align-items: center; }
.table-controls select, .table-controls input, .table-controls button, .import-button { height: 34px; border: 1px solid var(--line); border-radius: 6px; background: white; padding: 0 9px; color: var(--ink); font-size: 10px; display: inline-flex; align-items: center; }
.table-controls input { width: 160px; }
.import-button { cursor: pointer; }
.import-button input { display: none; }
.table-controls button[aria-label] { width: 34px; font-size: 18px; justify-content: center; }
.table-scroll { flex: 1; overflow: auto; }
.attribute-drawer table { width: 100%; border-collapse: collapse; font-size: 10px; }
.attribute-drawer th { position: sticky; top: 0; z-index: 1; background: var(--soft); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; text-align: left; }
.attribute-drawer th, .attribute-drawer td { padding: 8px 11px; border-bottom: 1px solid #edf2f1; white-space: nowrap; }
.attribute-drawer tbody tr { cursor: pointer; }
.attribute-drawer tbody tr:hover, .attribute-drawer tbody tr.selected { background: #e9f7f5; }
.attribute-drawer footer { height: 28px; display: flex; justify-content: space-between; align-items: center; padding: 0 11px; color: var(--muted); font-size: 9px; border-top: 1px solid var(--line); }
.print-summary { display: none; }
.vertex-marker { width: 15px; height: 15px; border: 3px solid var(--teal); background: #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: move; }
.statusbar { height: 30px; position: absolute; bottom: 0; left: 0; right: 0; display: flex; align-items: center; gap: 24px; padding: 0 13px; background: #fff; border-top: 1px solid var(--line); font-size: 10px; color: var(--muted); }
.status-ready { margin-left: auto; color: var(--teal); font-weight: 700; }
.status-ready i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; background: #22a975; border-radius: 50%; }
.maplibregl-popup-content { border-radius: 8px !important; padding: 10px 12px !important; color: var(--ink); font-size: 11px; }

@media (max-width: 1050px) {
  .demo-badge { display: none; }
  .contact-link { padding: 10px; }
}
@media (max-width: 780px) {
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { height: 61px; padding: 0 10px; gap: 9px; }
  .workspace { height: calc(100% - 61px); }
  .brand { min-width: 0; }
  .brand img { width: 34px; height: 34px; }
  .brand strong { display: none; }
  .brand small { font-size: 11px; margin: 0; }
  .contact-link { display: none; }
  .search-wrap input { height: 38px; font-size: 12px; padding-left: 35px; }
  .search-wrap > span { left: 10px; top: 8px; }
  .side-panel { position: absolute; left: -340px; top: 0; transition: left .22s ease; box-shadow: var(--shadow); }
  .side-panel.open { left: 0; }
  #map { bottom: 26px; }
  .statusbar { height: 26px; gap: 10px; }
  #featureStatus, #zoomStatus { display: none; }
  .feature-panel { left: 10px; right: 10px; top: auto; bottom: 37px; width: auto; max-height: 45%; }
  .capability-tools { left: 10px; top: 10px; max-width: calc(100% - 62px); }
  .capability-tools button { padding: 8px; }
  .capability-tools button span { margin: 0; }
  .capability-tools button { font-size: 0; }
  .capability-tools button span { font-size: 15px; }
  .analysis-panel { left: 10px; right: 10px; top: 52px; width: auto; }
  .attribute-drawer { height: 58%; bottom: 26px; }
  .attribute-drawer header { align-items: flex-start; }
  .table-controls { flex-wrap: wrap; }
  .table-controls input { width: 130px; }
  .attribute-drawer header > div:first-child { display: none; }
}
@media (max-width: 430px) {
  .brand { display: none; }
  .search-wrap { max-width: none; }
  .side-panel { width: min(326px, calc(100vw - 34px)); min-width: 0; }
  .statusbar { font-size: 9px; }
}

@media print {
  @page { size: landscape; margin: 10mm; }
  .topbar, .side-panel, .capability-tools, .map-tools, .offline-notice, .feature-panel, .analysis-panel, .attribute-drawer, .statusbar, .maplibregl-ctrl-container { display: none !important; }
  html, body, .app-shell, .workspace, .map-region { width: 100% !important; height: 100% !important; overflow: visible; }
  .workspace, .map-region { display: block !important; }
  #map { position: absolute !important; top: 76px !important; left: 0 !important; right: 0 !important; bottom: 0 !important; width: 100% !important; height: calc(100% - 76px) !important; border: 1px solid #bbb; }
  #map .maplibregl-canvas, #map .maplibregl-canvas-container { width: 100% !important; height: 100% !important; }
  .print-summary { display: block; position: absolute; top: 0; left: 0; right: 0; height: 68px; color: #183331; }
  .print-summary h1 { font-size: 20px; margin: 0 0 3px; }
  .print-summary p { margin: 0 0 8px; font-size: 10px; color: #647875; }
  .print-summary div { display: flex; gap: 22px; font-size: 11px; font-weight: 700; }
}
