/* AIM Platform prototype — design tokens and components.
   Layout: 56px global bar; the workspace fills everything beneath it.
   Floating panels sit over the map; nothing resizes the map except the window. */
:root {
  --navy: #043A57;
  --navy-700: #032d44;
  --navy-900: #021d2c;
  --navy-050: #EFF9FF;
  --accent: #63C7FF;
  --accent-ink: #0b6e9e;
  --deep: #21222B;
  --ink: #21222B;
  --ink-2: #55565e;
  --ink-3: #6b6c73;
  --line: #e1e9ee;
  --line-2: #c6d5de;
  --surface: #ffffff;
  --surface-2: #F2F5F7;
  --surface-3: #E8EEF2;
  --ok: #19934f;
  --warn: #c97a00;
  --bad: #c62a3c;
  --shadow-1: 0 1px 2px rgba(4, 58, 87, .06), 0 2px 8px rgba(4, 58, 87, .06);
  --shadow-2: 0 8px 24px rgba(4, 58, 87, .12), 0 2px 6px rgba(4, 58, 87, .06);
  --shadow-3: 0 24px 64px rgba(2, 29, 44, .24), 0 2px 6px rgba(4, 58, 87, .08);
  --shadow-dark: 0 20px 50px -12px rgba(0, 0, 0, .55);
  --glow: radial-gradient(ellipse 600px 400px at 12% 18%, rgba(99, 199, 255, .10) 0%, transparent 70%),
          radial-gradient(ellipse 520px 520px at 88% 70%, rgba(99, 199, 255, .07) 0%, transparent 70%);
  --r-ctrl: 6px;
  --r-panel: 12px;
  --r-lg: 14px;
  --bar-h: 56px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink);
  background: var(--surface-2); overflow: hidden; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; }
.ico { display: block; flex: none; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------- Global bar ----------------
   Navy bar with the white AIM logo, matching the AIM website header. */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar-h); z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  background: rgba(4, 58, 87, .97); backdrop-filter: saturate(160%) blur(12px); color: #fff;
  border-bottom: 1px solid rgba(99, 199, 255, .10); box-shadow: 0 8px 24px rgba(2, 29, 44, .18);
}
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-ctrl); display: grid; place-items: center; color: var(--ink-2); position: relative;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--surface-3); color: var(--navy); }
.topbar .icon-btn, .nav-panel .icon-btn { color: rgba(255, 255, 255, .88); }
.topbar .icon-btn:hover, .topbar .icon-btn[aria-expanded="true"],
.nav-panel .icon-btn:hover { background: rgba(99, 199, 255, .12); color: var(--accent); }
.icon-btn.has-dot::after {
  content: ""; position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%;
  background: #ff4d6a; box-shadow: 0 0 0 2px var(--navy);
}
.brand { display: flex; align-items: center; color: #fff; text-decoration: none; padding: 0 2px; border-radius: 50%; flex: none; }
.brand-logo { width: 40px; height: 40px; display: block; }
.proto-tag {
  flex: none; font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; line-height: 16px;
  color: var(--accent); border: 1px solid rgba(99, 199, 255, .45); border-radius: 4px; padding: 1px 6px; margin-left: 2px; cursor: default;
}
.workspace-ind { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #fff; white-space: nowrap; margin-left: 4px; }
.workspace-ind .sep { color: rgba(255, 255, 255, .28); font-weight: 400; font-size: 20px; }

.search { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.search input {
  width: 100%; height: 38px; border-radius: var(--r-ctrl); border: 1px solid rgba(99, 199, 255, .22); background: rgba(255, 255, 255, .08);
  color: #fff; padding: 0 36px 0 38px; outline: none; transition: border-color .15s, background .15s, box-shadow .15s, color .15s;
}
.search input::placeholder { color: rgba(255, 255, 255, .64); }
.search input:hover { border-color: rgba(99, 199, 255, .4); }
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { background: var(--surface); color: var(--ink); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 199, 255, .35); }
.search input:focus::placeholder { color: var(--ink-3); }
.search-icon { position: absolute; left: 11px; top: 9px; color: rgba(255, 255, 255, .7); pointer-events: none; }
.search:focus-within .search-icon { color: var(--ink-3); }
.search-kbd {
  position: absolute; right: 9px; top: 9px; font: 600 11px/18px var(--font); color: rgba(255, 255, 255, .7);
  border: 1px solid rgba(255, 255, 255, .28); border-radius: 4px; padding: 0 6px; background: transparent;
}
.search input:focus ~ .search-kbd { display: none; }

.top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.btn-create {
  height: 36px; display: flex; align-items: center; gap: 6px; padding: 0 14px 0 10px; margin-right: 6px;
  background: var(--accent); color: var(--navy); border-radius: var(--r-ctrl); font-weight: 600;
  box-shadow: 0 0 12px rgba(99, 199, 255, .3); transition: background .15s, box-shadow .15s;
}
.btn-create:hover, .btn-create[aria-expanded="true"] { background: #8fd7ff; box-shadow: 0 0 18px rgba(99, 199, 255, .5); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; margin-left: 6px; background: rgba(99, 199, 255, .14); color: #fff;
  font-weight: 700; font-size: 12px; letter-spacing: .04em; border: 1.5px solid rgba(99, 199, 255, .6);
}
.avatar:hover, .avatar[aria-expanded="true"] { border-color: var(--accent); background: rgba(99, 199, 255, .24); }
.topbar :focus-visible, .pop-dark :focus-visible, .ph-hero :focus-visible { outline-color: var(--accent); }

/* ---------------- Workspace ---------------- */
.workspace { position: fixed; inset: var(--bar-h) 0 0 0; }
.portfolio { position: absolute; inset: 0; }
.map, .map.maplibregl-map, .map.mapboxgl-map { position: absolute; inset: 0; background: #e8ecef; }
.portfolio[data-view="list"] .map, .portfolio[data-view="grid"] .map { visibility: hidden; }

/* Toolbar floats over the map; docks as a page header in list/grid */
.toolbar {
  position: absolute; z-index: 20; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; pointer-events: none;
}
.toolbar > * { pointer-events: auto; }
.toolbar-left { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; }
.toolbar-right { display: flex; gap: 10px; align-items: center; flex: none; }
.portfolio[data-view="list"] .toolbar, .portfolio[data-view="grid"] .toolbar {
  top: 0; left: 0; right: 0; padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.chip-select {
  height: 36px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; max-width: 260px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-1);
  font-weight: 500; color: var(--ink); white-space: nowrap;
}
.chip-select .lbl-k { color: var(--ink-3); font-weight: 500; }
.chip-select .lbl-v { overflow: hidden; text-overflow: ellipsis; }
.chip-select:hover, .chip-select[aria-expanded="true"] { border-color: var(--line-2); background: var(--surface-2); }
.chip-select.is-set { border-color: rgba(4, 58, 87, .35); background: var(--navy-050); }
.chip-select .ico { color: var(--ink-3); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--navy); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center;
}
.active-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 30px; display: inline-flex; align-items: center; gap: 4px; padding: 0 6px 0 11px; border-radius: 15px;
  background: var(--surface); border: 1px solid rgba(4, 58, 87, .25); color: var(--navy); font-weight: 500; font-size: 13px;
  box-shadow: var(--shadow-1);
}
.chip button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-3); }
.chip button:hover { background: var(--surface-3); color: var(--ink); }
.chip.ai { border-color: rgba(99, 199, 255, .8); background: #f1faff; }
.count {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px; box-shadow: var(--shadow-1); color: var(--ink-2); white-space: nowrap;
}
.count b { color: var(--ink); font-weight: 600; }
.portfolio[data-view="list"] .count, .portfolio[data-view="grid"] .count,
.portfolio[data-view="list"] .chip-select, .portfolio[data-view="grid"] .chip-select,
.portfolio[data-view="list"] .chip, .portfolio[data-view="grid"] .chip { box-shadow: none; }

.seg {
  display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px;
  box-shadow: var(--shadow-1); gap: 2px;
}
.seg button { width: 34px; height: 28px; border-radius: 5px; display: grid; place-items: center; color: var(--ink-3); }
.seg button:hover { color: var(--navy); background: var(--surface-2); }
.seg button[aria-selected="true"] { background: var(--navy); color: #fff; }

/* ---------------- Map controls ---------------- */
.map-controls {
  position: absolute; z-index: 15; right: 12px; bottom: 36px; display: flex; flex-direction: column; gap: 8px;
}
.portfolio:not([data-view="map"]) .map-controls,
.portfolio:not([data-view="map"]) .map-status,
.portfolio:not([data-view="map"]) .legend,
.portfolio:not([data-view="map"]) .preview,
.portfolio:not([data-view="map"]) .engine-note { display: none; }
.ctrl-group {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; overflow: hidden;
}
.ctrl-group button { width: 38px; height: 38px; display: grid; place-items: center; color: var(--ink-2); }
.ctrl-group button + button { border-top: 1px solid var(--line); }
.ctrl-group button:hover { background: var(--surface-2); color: var(--navy); }
.ctrl-group button.txt { font-weight: 700; font-size: 12px; letter-spacing: .04em; }
.ctrl-group button.on { color: var(--navy); background: var(--navy-050); }
#compassBtn .ico { transition: transform .1s linear; }

.map-status {
  position: absolute; z-index: 15; left: 12px; bottom: 34px; font-size: 12px; color: var(--ink-2);
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px); border-radius: 6px; padding: 4px 9px; box-shadow: var(--shadow-1);
}
.legend {
  position: absolute; z-index: 15; left: 12px; bottom: 68px; background: var(--surface); border-radius: 10px;
  box-shadow: var(--shadow-2); padding: 10px 12px; font-size: 12px; min-width: 150px;
}
.legend h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); font-weight: 600; }
.legend .row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.legend .sw { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .1); }
.engine-note {
  position: absolute; z-index: 16; left: 50%; transform: translateX(-50%); bottom: 34px; max-width: min(560px, calc(100% - 140px));
  background: var(--deep); color: #e6eef3; border-radius: 10px; padding: 8px 10px 8px 14px; font-size: 12.5px;
  display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow-2);
}
.engine-note button { color: var(--accent); font-weight: 600; white-space: nowrap; }
.engine-note .x { color: #9fb2c0; }
.pick-hint {
  position: absolute; z-index: 25; top: calc(var(--tb, 48px) + 22px); left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 9px 14px; border-radius: 8px; box-shadow: var(--shadow-2); font-weight: 500; display: flex; gap: 12px; align-items: center;
}
.pick-hint button { color: var(--accent); font-weight: 600; }

/* MapLibre / Mapbox control tweaks */
.mapboxgl-ctrl-scale, .maplibregl-ctrl-scale { border-color: var(--ink-3) !important; color: var(--ink-2); background: rgba(255,255,255,.7) !important; }
.mapboxgl-ctrl-logo { opacity: .55; }
.mapboxgl-ctrl-attrib.mapboxgl-compact, .maplibregl-ctrl-attrib.maplibregl-compact { opacity: .7; }

/* ---------------- Site preview ---------------- */
.preview {
  position: absolute; z-index: 22; top: calc(var(--tb, 48px) + 22px); left: 12px; width: 352px; max-height: calc(100% - var(--tb, 48px) - 70px); overflow: auto;
  background: var(--surface); border-radius: var(--r-panel); box-shadow: var(--shadow-3);
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.preview .thumb { position: relative; aspect-ratio: 16 / 9; background: var(--surface-3); border-radius: var(--r-panel) var(--r-panel) 0 0; overflow: hidden; }
.preview .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview .thumb .src-tag {
  position: absolute; left: 10px; bottom: 10px; font-size: 11.5px; font-weight: 600;
  background: rgba(33, 34, 43, .82); color: #fff; padding: 4px 9px; border-radius: 6px; backdrop-filter: blur(4px);
  display: inline-flex; align-items: center; gap: 6px;
}
.preview .close {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .92); color: var(--ink); box-shadow: var(--shadow-1);
}
.preview .body { padding: 14px 16px 16px; display: grid; gap: 12px; }
.eyebrow { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--navy); }
.eyebrow::before { content: ""; width: 18px; height: 2px; background: currentColor; border-radius: 2px; opacity: .6; flex: none; }
.preview h2 { margin: 2px 0 0; font-size: 18px; line-height: 1.3; font-weight: 700; color: var(--navy); letter-spacing: -.01em; text-wrap: balance; }
.preview .addr { color: var(--ink-2); margin-top: 2px; }
.meta-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--navy); white-space: nowrap;
}
.tag.epc { color: #fff; font-weight: 700; }
.avail { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.avail div {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 8px 7px; display: grid; gap: 4px; justify-items: start; font-size: 12px; color: var(--ink-2);
}
.avail div .ico { color: var(--navy); }
.avail div.off { color: var(--ink-3); background: var(--surface-2); border-style: dashed; }
.avail div.off .ico { color: var(--line-2); }
.avail b { font-weight: 600; color: var(--ink); font-size: 12px; }
.avail .off b { color: var(--ink-3); font-weight: 500; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; }
.btn {
  height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px;
  border-radius: var(--r-ctrl); font-weight: 600; border: 1px solid var(--line-2); background: var(--surface); color: var(--navy);
  white-space: nowrap;
}
.btn { transition: background-color .15s, border-color .15s, color .15s; }
.btn:hover { border-color: var(--navy); background: rgba(4, 58, 87, .04); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; flex: 1; }
.btn.primary:hover { background: var(--navy-700); }
.btn.sq { width: 38px; padding: 0; flex: none; }
.btn.ghost { border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.small-note { font-size: 12px; color: var(--ink-3); }

/* ---------------- Popovers / menus ---------------- */
.popover {
  position: fixed; z-index: 80; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow-3); padding: 6px; min-width: 220px; max-height: calc(100vh - 80px); overflow: auto;
  animation: pop .14s ease-out;
}
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }
.search-pop { position: absolute; top: 44px; left: 0; right: 0; }
.menu-h { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; text-align: left; color: var(--ink);
}
.menu-item:hover, .menu-item.kb { background: var(--surface-2); }
.menu-item .ico { color: var(--ink-3); }
.menu-item .sub { color: var(--ink-3); font-size: 12px; display: block; }
.menu-item .grow { flex: 1; min-width: 0; }
.menu-item .grow > span:first-child { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item.danger { color: var(--bad); }
.menu-item.danger .ico { color: var(--bad); }
.menu-item[aria-checked="true"] { font-weight: 600; color: var(--navy); }
.menu-item .tick { margin-left: auto; color: var(--navy); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-item mark { background: rgba(99, 199, 255, .35); color: inherit; border-radius: 2px; }
.menu-foot { padding: 8px 10px 4px; font-size: 12px; color: var(--ink-3); display: flex; justify-content: space-between; gap: 8px; }
.menu-foot button { color: var(--navy); font-weight: 600; }
.search-filterhint { background: #f1faff; border: 1px solid rgba(99, 199, 255, .55); }
.search-filterhint .ico { color: var(--accent-ink); }

/* Create menu */
.create-menu { width: 360px; padding: 8px; }
.create-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; padding: 4px; }
.create-tile {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 9px; border: 1px solid var(--line); text-align: left;
}
.create-tile:hover { border-color: var(--accent); background: var(--navy-050); }
.create-tile .ic { width: 32px; height: 32px; border-radius: 8px; background: var(--navy-050); color: var(--navy); display: grid; place-items: center; flex: none; }
.create-tile b { display: block; font-weight: 600; font-size: 13px; }
.create-tile span.d { display: block; font-size: 11.5px; color: var(--ink-3); line-height: 1.3; }

/* Filter + layers panels */
.panel { width: 340px; padding: 4px 4px 8px; }
.panel h3 { margin: 10px 10px 6px; font-size: 15px; font-weight: 700; color: var(--navy); letter-spacing: -.01em; }
.fgroup { padding: 8px 10px; border-top: 1px solid var(--line); }
.fgroup:first-of-type { border-top: 0; }
.fgroup .flabel { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); margin-bottom: 8px; display: flex; justify-content: space-between; }
.fgroup .flabel button { text-transform: none; letter-spacing: 0; color: var(--navy); font-weight: 600; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt {
  height: 30px; padding: 0 11px; border-radius: 15px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2);
}
.opt:hover { border-color: var(--navy); }
.opt[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.opt.epc-opt { min-width: 36px; justify-content: center; font-weight: 700; }
.opt.epc-opt[aria-pressed="true"] { box-shadow: inset 0 -3px 0 var(--epc); }
.panel-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px 2px; border-top: 1px solid var(--line); }
.style-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.style-card { border: 2px solid var(--line); border-radius: 9px; overflow: hidden; text-align: left; background: var(--surface); }
.style-card .sw { height: 54px; }
.style-card span { display: block; padding: 6px 8px; font-size: 12px; font-weight: 600; }
.style-card[aria-pressed="true"] { border-color: var(--navy); }
.sw-light { background: linear-gradient(135deg, #f3f1ec 0 40%, #dfe6ea 40% 46%, #f3f1ec 46% 70%, #cfe3ee 70%); }
.sw-dark { background: linear-gradient(135deg, #1c2633 0 40%, #33465a 40% 46%, #1c2633 46% 70%, #23384c 70%); }
.sw-sat { background: radial-gradient(circle at 30% 30%, #6d7f4e, #3f4f31 40%, #59623e 60%, #2d3a2a); }
.layer-opt { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; width: 100%; text-align: left; }
.layer-opt:hover { background: var(--surface-2); }
.layer-opt .radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; }
.layer-opt[aria-checked="true"] .radio { border: 5px solid var(--navy); }
.layer-opt .d { font-size: 12px; color: var(--ink-3); display: block; }
.soon { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px; margin-left: auto; }

/* ---------------- Overlay navigation ----------------
   Navy panel, like the AIM website's menus. */
.nav-overlay { position: fixed; inset: 0; z-index: 90; }
.nav-overlay .scrim { position: absolute; inset: 0; background: rgba(2, 29, 44, .36); animation: fade .18s; }
@keyframes fade { from { opacity: 0; } }
.nav-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: 300px; max-width: 86vw; background: var(--glow), var(--navy); color: #fff;
  box-shadow: var(--shadow-dark); display: flex; flex-direction: column; animation: slide .2s ease-out;
  padding-left: env(safe-area-inset-left); border-right: 1px solid rgba(99, 199, 255, .14);
}
@keyframes slide { from { transform: translateX(-100%); } }
.nav-head { height: var(--bar-h); display: flex; align-items: center; gap: 8px; padding: 0 8px; border-bottom: 1px solid rgba(99, 199, 255, .12); flex: none; }
.nav-title { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.nav-scroll { overflow: auto; padding: 8px; flex: 1; }
.nav-sec { padding: 14px 10px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.nav-sec .pill { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: rgba(255, 196, 77, .16); color: #ffd27a; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: 8px; text-align: left; color: rgba(255, 255, 255, .92); font-weight: 600; }
.nav-item:hover { background: rgba(99, 199, 255, .08); color: var(--accent); }
.nav-item .ico { color: rgba(255, 255, 255, .6); }
.nav-item:hover .ico { color: var(--accent); }
.nav-item[aria-current="page"] { background: rgba(99, 199, 255, .14); color: var(--accent); }
.nav-item[aria-current="page"] .ico { color: var(--accent); }
.nav-item .phase { margin-left: auto; font-size: 11px; color: rgba(255, 255, 255, .5); font-weight: 500; }
.nav-foot { border-top: 1px solid rgba(99, 199, 255, .12); padding: 10px 12px; font-size: 12px; color: rgba(255, 255, 255, .6); flex: none; }
.nav-panel :focus-visible { outline-color: var(--accent); }

/* ---------------- List view ---------------- */
.list-view, .grid-view { position: absolute; inset: var(--tb, 61px) 0 0 0; background: var(--surface); overflow: auto; }
.grid-view { background: var(--surface-2); padding: 16px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)); }
.tbl { min-width: 100%; width: max-content; position: relative; }
.tr { display: grid; align-items: center; height: 44px; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tr > div { padding: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.thead { position: sticky; top: 0; z-index: 3; background: var(--surface-2); height: 40px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.thead button.sort { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--ink-2); }
.thead button.sort:hover { color: var(--navy); }
.thead button.sort .ico { transform: rotate(0); opacity: .0; }
.thead button.sort.active .ico { opacity: 1; }
.thead button.sort.desc .ico { transform: rotate(180deg); }
.tbody .tr { position: absolute; left: 0; right: 0; background: var(--surface); }
.tbl { padding-bottom: 84px; }
.tbody .tr:hover { background: #f7fafc; }
.tbody .tr.is-checked { background: #f1f8fd; }
.tbody .tr.is-selected { box-shadow: inset 3px 0 0 var(--accent); }
.cell-name a { color: var(--navy); font-weight: 600; text-decoration: none; cursor: pointer; }
.cell-name a:hover { text-decoration: underline; }
.cell-name .sub { color: var(--ink-3); font-size: 12px; margin-left: 6px; font-weight: 400; }
.cb { width: 16px; height: 16px; accent-color: var(--navy); cursor: pointer; }
.row-more { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--ink-3); }
.row-more:hover { background: var(--surface-3); color: var(--ink); }
.ok-dot { display: inline-flex; align-items: center; gap: 6px; }
.ok-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.ok-dot.yes::before { background: #19b6e8; }
.cap-icons { display: inline-flex; gap: 4px; color: var(--navy); }
.cap-icons .off { color: var(--line-2); }
.epc-pill { display: inline-grid; place-items: center; min-width: 26px; height: 20px; border-radius: 4px; color: #fff; font-weight: 700; font-size: 11.5px; padding: 0 5px; }
.muted { color: var(--ink-3); }
.empty { padding: 60px 20px; text-align: center; color: var(--ink-3); }
.empty h3 { color: var(--ink); margin: 0 0 6px; font-size: 16px; }

.selection-bar {
  position: absolute; z-index: 30; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--deep); color: #fff; border-radius: 10px; box-shadow: var(--shadow-3); display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 16px;
  animation: rise .18s ease-out; max-width: calc(100% - 24px); overflow-x: auto;
}
.selection-bar .n { font-weight: 600; margin-right: 10px; white-space: nowrap; }
.selection-bar button { height: 34px; padding: 0 12px; border-radius: 7px; display: inline-flex; align-items: center; gap: 6px; color: #e6eef3; white-space: nowrap; }
.selection-bar button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.selection-bar button.danger { color: #ff9aa6; }

/* ---------------- Grid view ---------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card { background: var(--surface); border-radius: var(--r-panel); border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-1); transition: box-shadow .15s, border-color .15s, transform .15s; }
.card:hover { box-shadow: var(--shadow-2); border-color: var(--line-2); transform: translateY(-2px); }
.card .thumb img { transition: transform .4s ease; }
.card:hover .thumb img { transform: scale(1.04); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99, 199, 255, .4); }
.card .thumb { aspect-ratio: 16 / 10; background: var(--surface-3); position: relative; cursor: pointer; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb .src-tag { position: absolute; left: 8px; top: 8px; font-size: 11px; font-weight: 600; background: rgba(33, 34, 43, .82); color: #fff; padding: 3px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px; }
.src-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(99, 199, 255, .25); }
.card .thumb .cb-wrap { position: absolute; right: 8px; top: 8px; background: rgba(255,255,255,.92); border-radius: 5px; width: 26px; height: 26px; display: grid; place-items: center; }
.card .cbody { padding: 12px 12px 10px; display: grid; gap: 4px; }
.card h3 { margin: 0; font-size: 14.5px; font-weight: 600; color: var(--navy); line-height: 1.3; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card h3:hover { text-decoration: underline; }
.card .addr { color: var(--ink-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .cfoot { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 8px 12px; margin-top: auto; }
.placeholder-img { width: 100%; height: 100%; display: grid; place-items: center; background: linear-gradient(160deg, #eef2f5, #e2e8ed); color: #b3c0ca; }
.placeholder-img svg { width: 44%; height: auto; }

/* ---------------- Drawers & dialogs ---------------- */
.drawer-wrap { position: fixed; inset: 0; z-index: 95; }
.drawer-wrap .scrim { position: absolute; inset: 0; background: rgba(4, 30, 46, .22); }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100vw; background: var(--surface); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; animation: slideR .2s ease-out; padding-right: env(safe-area-inset-right);
}
@keyframes slideR { from { transform: translateX(100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; color: var(--navy); letter-spacing: -.01em; }
.drawer-body { padding: 16px; overflow: auto; flex: 1; display: grid; gap: 14px; align-content: start; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field input, .field select, .field textarea {
  height: 38px; border: 1px solid var(--line-2); border-radius: var(--r-ctrl); padding: 0 10px; background: var(--surface); outline: none; width: 100%;
}
.field textarea { height: auto; min-height: 80px; padding: 8px 10px; font-family: ui-monospace, monospace; font-size: 12px; }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 199, 255, .25); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.loc-box { border: 1px dashed var(--line-2); border-radius: 8px; padding: 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.callout { background: var(--navy-050); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.callout b { color: var(--navy); }
.dropzone { border: 2px dashed var(--line-2); border-radius: 10px; padding: 26px; text-align: center; color: var(--ink-3); display: grid; gap: 6px; justify-items: center; }
.dropzone .ico { color: var(--navy); }

.toast {
  position: fixed; z-index: 120; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--deep); color: #fff; max-width: calc(100vw - 24px); overflow-wrap: anywhere;
  padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-3); font-weight: 500; animation: rise .2s;
}

/* ---------------- Placeholder workspace ---------------- */
.placeholder { position: absolute; inset: 0; overflow: auto; background: var(--surface-2); }
.ph-hero {
  color: #fff; padding: 40px 0 44px;
  background: radial-gradient(ellipse 600px 400px at 15% 20%, rgba(99, 199, 255, .09) 0%, transparent 70%),
              radial-gradient(1200px 520px at 80% -10%, rgba(99, 199, 255, .18), transparent 60%),
              linear-gradient(180deg, var(--navy) 0%, var(--navy-900) 100%);
}
.ph-wrap { max-width: 760px; margin: 0 auto; padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left)); }
.ph-hero .back { display: inline-flex; align-items: center; gap: 6px; color: rgba(255, 255, 255, .76); font-weight: 600; margin-bottom: 22px; }
.ph-hero .back:hover { color: #fff; }
.ph-hero .eyebrow { color: var(--accent); }
.ph-hero h1 { font-size: clamp(26px, 3.4vw, 34px); line-height: 1.1; letter-spacing: -.02em; color: #fff; margin: 10px 0 10px; text-wrap: balance; }
.ph-hero p { color: rgba(255, 255, 255, .76); max-width: 62ch; margin: 0; font-size: 15px; }
.ph-inner { max-width: 760px; margin: 0 auto; padding: 8px max(20px, env(safe-area-inset-right)) 48px max(20px, env(safe-area-inset-left)); }
.ph-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 20px 24px; margin-top: 20px; box-shadow: var(--shadow-1); }
.ph-card h3 { margin: 0 0 8px; font-size: 15px; color: var(--navy); }
.ph-card ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.ph-card li { margin: 3px 0; }

/* ---------------- Responsive ---------------- */
@media (max-width: 820px) {
  .btn-create .lbl { display: none; }
  .btn-create { padding: 0 9px; margin-right: 2px; }
  #historyBtn { display: none; }
  .search-kbd { display: none; }
  .count { padding: 0 9px; font-size: 12.5px; }
  .count b + span, .count .of { display: none; }
  .active-chips { display: none; }
  .chip-select { max-width: 150px; padding: 0 10px; }
  .preview {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 62%;
    border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom);
  }
  .preview .thumb { aspect-ratio: 21 / 9; border-radius: 16px 16px 0 0; }
  .preview::before { content: ""; position: absolute; z-index: 2; top: 6px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.85); }
  .map-controls { bottom: 40px; }
  .map-status { display: none; }
  .mapboxgl-ctrl-bottom-left, .maplibregl-ctrl-bottom-left { left: 0 !important; }
  .engine-note { max-width: calc(100% - 80px); left: 12px; transform: none; }
  .create-menu, .panel { width: calc(100vw - 24px); }
}
@media (max-width: 560px) {
  .toolbar-left .chip-select#projectSelect { display: none; }
  .search { margin: 0 4px; position: static; }
  .search-pop { position: fixed; top: calc(var(--bar-h) - 4px); left: 8px; right: 8px; }
  .search input { padding-right: 10px; }
  /* Tapping search widens it across the bar */
  .search:focus-within { position: absolute; z-index: 5; left: 8px; right: 8px; top: calc((var(--bar-h) - 38px) / 2); margin: 0; max-width: none; }
  .selection-bar { left: 12px; right: 12px; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Fixes: keep map chrome out of list/grid; images never stretch their frames */
.portfolio[data-view="list"] .map *, .portfolio[data-view="grid"] .map * { visibility: hidden !important; }
.card .thumb, .preview .thumb { overflow: hidden; }
.card .thumb img, .preview .thumb img, .card .thumb .placeholder-img, .preview .thumb .placeholder-img { position: absolute; inset: 0; }
@media (max-width: 560px) {
  .legend { bottom: 40px; right: 64px; padding: 8px 10px; }
  .legend .row { display: inline-flex; margin-right: 8px; }
  .legend .small-note { display: none; }
}

/* ---------------- Real-data loading ---------------- */
.data-note { bottom: 80px; background: var(--navy); }
.avail.one { grid-template-columns: 1fr; }
.avail.one div { grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.avail.one div .ico { grid-row: span 2; }
.issues { display: grid; gap: 8px; }
.issue { display: grid; grid-template-columns: 74px 1fr; gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.issue b { font-weight: 600; font-size: 13px; }
.lvl { display: inline-block; text-align: center; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 4px; padding: 3px 0; }
.lvl-error { background: #fde8eb; color: #a3162b; }
.lvl-warn { background: #fff4e0; color: #8a5a00; }
.lvl-info { background: var(--navy-050); color: var(--navy); }

/* ---------------- Review fixes ---------------- */
.map-empty {
  position: absolute; z-index: 18; left: 50%; top: 42%; transform: translate(-50%, -50%); width: min(340px, calc(100% - 32px));
  background: var(--surface); border-radius: var(--r-panel); box-shadow: var(--shadow-3); padding: 18px 20px; display: grid; gap: 6px; justify-items: center; text-align: center;
}
.map-empty b { font-size: 15px; color: var(--navy); }
.map-empty span { color: var(--ink-2); font-size: 13px; }
.map-empty .btn { margin-top: 6px; }
.portfolio:not([data-view="map"]) .map-empty { display: none; }
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.btn.danger-fill { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-fill:hover { background: #a3162b; }
.btn.danger-fill:disabled { background: var(--bad); }
.topbar .search input:focus-visible { outline: none; }
@media (max-width: 820px) {
  .legend { bottom: 40px; }
  .portfolio:has(.preview:not([hidden])) .legend { display: none; }
}

/* ---------------- Menus that drop from the navy bar ----------------
   Same look as the website's navy drop-down menus. Panels over the map stay white. */
.popover.pop-dark {
  background: var(--glow), var(--navy); color: #fff; border: 1px solid rgba(99, 199, 255, .16); box-shadow: var(--shadow-dark); padding: 8px;
}
.pop-dark .menu-h { color: var(--accent); font-weight: 700; letter-spacing: .14em; font-size: 10.5px; }
.pop-dark .menu-item { color: rgba(255, 255, 255, .92); font-weight: 600; border-radius: 8px; }
.pop-dark .menu-item .sub, .pop-dark .muted { color: rgba(255, 255, 255, .62); font-weight: 400; }
.pop-dark .menu-item .ico { color: rgba(255, 255, 255, .6); }
.pop-dark .menu-item:hover, .pop-dark .menu-item.kb { background: rgba(99, 199, 255, .08); color: var(--accent); }
.pop-dark .menu-item:hover .ico { color: var(--accent); }
.pop-dark .menu-item[aria-checked="true"], .pop-dark .menu-item .tick { color: var(--accent); }
.pop-dark .menu-sep { background: rgba(255, 255, 255, .12); }
.pop-dark .menu-foot { color: rgba(255, 255, 255, .6); }
.pop-dark .menu-foot button { color: var(--accent); }
.pop-dark .create-tile { border-color: rgba(99, 199, 255, .16); background: rgba(255, 255, 255, .04); color: #fff; }
.pop-dark .create-tile:hover { border-color: var(--accent); background: rgba(99, 199, 255, .08); }
.pop-dark .create-tile .ic { background: rgba(99, 199, 255, .12); color: var(--accent); }
.pop-dark .create-tile span.d { color: rgba(255, 255, 255, .62); }
.card .thumb { overflow: hidden; }

/* Map style button: shows the current style, click to move to the next */
.map-status { display: none !important; }
#styleBtn .style-dot { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid rgba(4, 58, 87, .35); display: block; }
#styleBtn[data-style="light"] .style-dot { background: linear-gradient(135deg, #f3f1ec 0 45%, #cfe3ee 45%); }
#styleBtn[data-style="dark"] .style-dot { background: linear-gradient(135deg, #1c2633 0 45%, #33465a 45%); }
#styleBtn[data-style="satellite"] .style-dot { background: radial-gradient(circle at 30% 30%, #6d7f4e, #3f4f31 45%, #59623e 70%, #2d3a2a); }

/* List tools: Manage columns and Export to Excel (List view; Export also in Grid) */
.list-tools { display: none; gap: 8px; }
.portfolio[data-view="list"] .list-tools, .portfolio[data-view="grid"] .list-tools { display: flex; }
.portfolio[data-view="grid"] #colsBtn { display: none; }
.list-tools .chip-select svg { color: var(--navy); }
.cols-pop { padding: 4px; }
.col-fixed, .col-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; }
.col-fixed { color: var(--ink-3); }
.col-fixed span:nth-of-type(2) { color: var(--ink); font-weight: 500; }
.col-note { margin-left: auto; font-size: 11.5px; }
.col-grip { width: 16px; flex: none; display: grid; place-items: center; color: var(--ink-3); cursor: grab; }
.col-row label { flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.col-row:hover { background: var(--surface-2); }
.col-row.dragging { opacity: .5; background: var(--navy-050); }
.col-list { display: grid; gap: 1px; max-height: min(420px, 60vh); overflow: auto; }
.xl-body { padding: 2px 10px 10px; display: grid; gap: 6px; }
.xl-q { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-top: 6px; }
.xl-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.xl-opt:has(input:checked) { border-color: var(--navy); background: var(--navy-050); }
.xl-opt input { margin-top: 3px; accent-color: var(--navy); }
.xl-opt span { display: grid; gap: 2px; min-width: 0; }
.xl-opt small { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.xl-go { margin-top: 8px; justify-content: center; }
.xl-note { margin: 0; font-size: 12px; color: var(--ink-3); text-align: center; }
@media (max-width: 820px) { .list-tools .chip-select span:last-child { display: none; } }
