:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-strong: #f8fafb;
  --ink: #17202a;
  --muted: #66717f;
  --line: #d9e0e7;
  --blue: #2563eb;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #b91c1c;
  --green: #15803d;
  --violet: #6d28d9;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg);
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.sidebar,
.intel-panel,
.map-stage {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  min-width: 0;
  min-height: 0;
  padding: 20px;
  background: var(--panel);
  border-color: var(--line);
}

.sidebar {
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 30;
  flex-direction: row;
  align-items: center;
  gap: 18px;
  overflow: visible;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.intel-panel {
  grid-column: 2;
  grid-row: 2;
  border-left: 1px solid var(--line);
}

.map-stage {
  grid-column: 1;
  grid-row: 2;
  z-index: 10;
  min-width: 0;
  background: #f3f6f8;
}

.brand-bar,
.section-heading,
.top-panel,
.policy-strip,
.search-wrap,
.source-meta,
.asset-row,
.detail-title {
  display: flex;
  align-items: center;
}

.brand-bar,
.section-heading,
.top-panel {
  justify-content: space-between;
  gap: 14px;
}

.brand-bar {
  align-items: flex-start;
  flex-wrap: wrap;
}

.brand-bar > div {
  min-width: 0;
  flex: 1 1 170px;
}

.topbar .brand-bar {
  flex: 1 1 360px;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}

.topbar .brand-bar > div {
  flex: 1 1 230px;
}

.brand-bar h1,
.section-heading h2 {
  margin: 0;
}

.brand-bar h1 {
  font-size: 1.35rem;
  line-height: 1.18;
}

.topbar .brand-bar h1 {
  font-size: 1.12rem;
  line-height: 1.18;
}

.section-heading h2 {
  font-size: 1rem;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.status-pill,
.mini-label,
.tag,
.source-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  flex: 0 0 auto;
  color: var(--blue);
  background: #dbeafe;
}

.mini-label {
  color: var(--muted);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.control-block {
  display: grid;
  gap: 12px;
}

.topbar .control-block {
  flex: 0 1 280px;
  min-width: 220px;
  gap: 7px;
}

.field-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.select-input,
.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel-strong);
  outline: none;
}

.select-input {
  height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 700;
}

.select-input:focus,
.search-wrap input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.topbar .metrics-grid {
  flex: 0 0 270px;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 8px;
}

.metric {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.topbar .metric {
  min-height: 56px;
  padding: 9px 10px;
}

.metric-value {
  overflow-wrap: anywhere;
  font-size: 1.25rem;
  font-weight: 850;
}

.topbar .metric-value {
  font-size: 1.08rem;
}

.metric-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.icon-button,
.primary-button,
.layer-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  color: #ffffff;
  border-color: #1d4ed8;
  background: var(--blue);
  font-weight: 800;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.layer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.layer-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  text-align: center;
}

.layer-button svg,
.icon-button svg,
.primary-button svg,
.search-wrap svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.layer-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.layer-button small {
  display: none;
}

.layer-button.active {
  border-color: color-mix(in srgb, var(--layer-color) 65%, var(--line));
  background: color-mix(in srgb, var(--layer-color) 10%, #ffffff);
}

.asset-list,
.source-list {
  display: grid;
  gap: 10px;
}

.strength-block {
  padding-top: 2px;
}

.strength-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.strength-item {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  text-align: left;
}

.strength-item strong {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.strength-item span,
.note-text {
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.35;
}

.note-text {
  margin: 0;
}

.strength-item.selected {
  border-color: var(--blue);
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.strength-detail {
  display: grid;
  gap: 9px;
  max-height: 290px;
  overflow-y: auto;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.strength-detail:empty {
  display: none;
}

.strength-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.strength-detail-head strong,
.inventory-detail-row strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
}

.strength-detail-head span,
.inventory-detail-row span,
.strength-detail p,
.inventory-counts small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.strength-detail-head a {
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 850;
  text-decoration: none;
}

.strength-detail p {
  margin: 0;
}

.inventory-detail-list {
  display: grid;
  gap: 6px;
}

.inventory-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.inventory-counts {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
  text-align: right;
}

.inventory-counts b {
  display: block;
  color: var(--ink);
  font-size: 0.82rem;
}

.inventory-counts small {
  display: block;
}

.asset-row {
  min-width: 0;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.asset-button {
  width: 100%;
  text-align: left;
}

.asset-button.selected {
  border-color: var(--blue);
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.asset-name {
  min-width: 0;
}

.asset-title-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: space-between;
}

.asset-name strong,
.source-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.asset-name small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.asset-status {
  flex: 0 0 auto;
  max-width: 78px;
  overflow: hidden;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--green);
  background: #dcfce7;
  font-size: 0.65rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-status.tahmini {
  color: var(--amber);
  background: #fef3c7;
}

.source-link {
  display: block;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.source-link:hover {
  color: var(--blue);
  text-decoration: underline;
}

.asset-name span,
.source-item p,
.detail-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.asset-range {
  flex: 0 0 auto;
  max-width: 82px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: right;
}

.map-summary-panel,
.data-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(23, 32, 42, 0.08);
}

.map-summary-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
}

.map-viewport {
  position: relative;
  min-width: 0;
  min-height: 240px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe7ef;
}

#map {
  width: 100%;
  height: clamp(250px, 32vh, 360px);
}

.top-panel {
  position: static;
  align-items: flex-start;
  flex-wrap: wrap;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.top-panel strong {
  font-size: 1.02rem;
}

.map-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 220px;
}

.map-title-row > div {
  min-width: 0;
}

.top-panel > div:first-child {
  min-width: 220px;
}

.range-readout {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.policy-strip {
  display: grid;
  flex: 1 1 340px;
  min-width: 0;
  grid-template-columns: repeat(3, minmax(100px, 1fr));
  gap: 8px;
}

.policy-item {
  display: grid;
  gap: 2px;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
  color: #0f3b5f;
  background: rgba(224, 242, 254, 0.88);
}

.policy-item strong {
  font-size: 0.75rem;
  font-weight: 850;
  line-height: 1.15;
}

.policy-item small {
  color: #475569;
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1.25;
}

.policy-delay {
  border-color: #c7d2fe;
  border-left-color: #4f46e5;
  background: rgba(238, 242, 255, 0.9);
}

.policy-approx {
  border-color: #fed7aa;
  border-left-color: #f97316;
  background: rgba(255, 247, 237, 0.92);
}

.map-legend {
  position: absolute;
  z-index: 500;
  left: 12px;
  bottom: 12px;
  display: grid;
  gap: 8px;
  min-width: 170px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(23, 32, 42, 0.1);
  backdrop-filter: blur(12px);
}

.map-empty-note {
  position: absolute;
  z-index: 500;
  right: 12px;
  bottom: 12px;
  display: grid;
  gap: 2px;
  max-width: min(320px, calc(100% - 210px));
  padding: 9px 11px;
  border: 1px solid rgba(107, 114, 128, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 22px rgba(23, 32, 42, 0.1);
  backdrop-filter: blur(8px);
}

.map-empty-note[hidden] {
  display: none;
}

.map-empty-note strong {
  font-size: 0.78rem;
}

.map-empty-note span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.legend-dot {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--dot);
}

.detail-panel {
  padding: 14px;
}

.data-panels {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.data-panel {
  min-width: 0;
  padding: 16px;
}

.inventory-heading {
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inventory-heading h2 {
  flex: 0 0 auto;
}

.inventory-filters {
  flex: 1 1 170px;
  justify-content: flex-start;
}

.inventory-heading .mini-label {
  margin-left: auto;
  white-space: nowrap;
}

.inventory-detail-panel {
  margin: 12px 0;
  padding: 10px 0 12px;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.inventory-panel .asset-list {
  max-height: 560px;
  overflow-y: auto;
  padding-right: 2px;
}

.detail-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.detail-title h3 {
  margin: 0;
  font-size: 0.98rem;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.detail-row strong {
  color: var(--ink);
}

.detail-source-link {
  display: inline-flex;
  margin-top: 12px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 850;
  text-decoration: none;
}

.detail-source-link:hover {
  text-decoration: underline;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 9px;
  min-height: 118px;
  text-align: center;
}

.empty-state p {
  margin: 0;
}

.search-wrap {
  gap: 8px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.search-wrap input {
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
}

.source-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.source-meta {
  justify-content: space-between;
  gap: 8px;
}

.source-date {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.source-state.pending {
  color: var(--amber);
  background: #fef3c7;
}

.source-state.verified {
  color: var(--green);
  background: #dcfce7;
}

.source-state.review {
  color: var(--violet);
  background: #ede9fe;
}

.source-state.candidate {
  color: var(--amber);
  background: #fef3c7;
}

.source-state.loading {
  color: var(--blue);
  background: #dbeafe;
}

.source-state.error {
  color: var(--red);
  background: #fee2e2;
}

.source-state.fallback {
  color: var(--muted);
  background: #edf2f7;
}

.tag {
  color: var(--muted);
  background: #edf2f7;
}

.leaflet-container {
  font: inherit;
}

/* Guard the critical Leaflet layout rules so a CDN CSS integrity/cache issue
   cannot leave tiles and vector panes in normal document flow. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  overflow: hidden;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-top.leaflet-right {
  top: 10px;
  right: 10px;
}

.leaflet-tile {
  border: 0;
  user-select: none;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.oda-marker {
  border: 2px solid #ffffff;
  box-shadow: 0 7px 18px rgba(23, 32, 42, 0.22);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  color: var(--ink);
  border-radius: 8px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar,
  .map-stage,
  .intel-panel {
    grid-column: 1 / -1;
    grid-row: auto;
    height: auto;
    max-height: none;
  }

  .intel-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .source-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 940px) {
  .data-panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar,
  .intel-panel,
  .map-stage {
    height: auto;
    padding: 16px;
    border: 0;
  }

  .sidebar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .topbar .brand-bar,
  .topbar .control-block,
  .topbar .metrics-grid {
    width: 100%;
    min-width: 0;
  }

  #map {
    height: 280px;
  }

  .top-panel {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
  }

  .policy-strip {
    flex: none;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: flex-start;
  }

  .source-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .metrics-grid,
  .policy-strip {
    grid-template-columns: 1fr;
  }

  .topbar .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .top-panel > div:first-child {
    min-width: 0;
    width: 100%;
  }

  .policy-item {
    min-height: 44px;
    padding: 6px 7px;
    border-left-width: 3px;
  }

  .policy-item strong {
    font-size: 0.68rem;
  }

  .policy-item small {
    font-size: 0.61rem;
  }

  .map-legend {
    right: 12px;
    min-width: 0;
  }
}
