:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17201b;
  --muted: #66736c;
  --line: #d9dfd8;
  --accent: #0b6b57;
  --warn: #c44536;
  --shadow: 0 16px 40px rgba(23, 32, 27, 0.16);
}

* { box-sizing: border-box; }
html, body, .app-shell, #map { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
.app-shell { display: grid; grid-template-columns: minmax(360px, 420px) 1fr; }
.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 14px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; line-height: 1.05; }
h2 { margin-bottom: 0; font-size: 16px; }
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.metrics div { padding: 14px 16px; border-right: 1px solid var(--line); }
.metrics div:last-child { border-right: 0; }
.metrics span { display: block; font-size: 22px; font-weight: 850; }
.metrics label { color: var(--muted); font-size: 12px; }
.filters {
  display: grid;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vcc-control {
  display: grid;
  gap: 10px;
}
.vcc-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.vcc-actions button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 8px 12px;
  white-space: nowrap;
}
.vcc-actions button:last-child {
  border-color: var(--line);
  background: #fff;
  color: var(--warn);
}
.address-status {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle-row input { width: 18px; min-height: 18px; }
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
}
.list-header select { width: 150px; }
.facility-list { min-height: 0; overflow: auto; padding: 0 12px 16px; }
.facility-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 12px 10px;
  text-align: left;
  cursor: pointer;
}
.facility-item:hover, .facility-item.active { border-color: var(--line); background: #f5f8f6; }
.facility-item h3 { margin-bottom: 5px; font-size: 15px; line-height: 1.25; }
.facility-meta, .facility-owner { color: var(--muted); font-size: 12px; line-height: 1.45; }
.facility-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge {
  border-radius: 999px;
  background: #e9efec;
  color: #27423a;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}
.badge.warn { background: #fbe8df; color: #8d3328; }
.map-stage { position: relative; min-width: 0; }
.detail-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 600;
  width: min(420px, calc(100% - 36px));
  max-height: calc(100% - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
  padding: 18px;
}
.detail-panel.minimized {
  width: min(300px, calc(100% - 36px));
  max-height: none;
  overflow: hidden;
  padding: 12px 14px;
}
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.detail-title {
  min-width: 0;
}
.detail-minimize {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  color: var(--accent);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}
.detail-panel.minimized .detail-body {
  display: none;
}
.detail-panel.minimized .detail-header h2 {
  margin-bottom: 0;
  font-size: 15px;
}
.detail-panel.minimized .facility-meta {
  display: none;
}
.detail-panel h2 { margin-bottom: 8px; font-size: 20px; line-height: 1.18; }
.detail-panel dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 14px 0; }
.detail-panel dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.detail-panel dd { margin: 0; font-size: 13px; }
.owners { display: grid; gap: 8px; margin-top: 12px; }
.owner-row { border-top: 1px solid var(--line); padding-top: 8px; }
.owner-row strong { display: block; font-size: 13px; }
.owner-row span { color: var(--muted); font-size: 12px; }
.popup-title { margin-bottom: 5px; font-weight: 850; }
.popup-meta { color: #53625a; font-size: 12px; line-height: 1.4; }
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: minmax(360px, 48vh) 1fr; }
  .sidebar { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .map-stage { order: 1; }
  .brand, .filters, .list-header { padding-left: 16px; padding-right: 16px; }
  .detail-panel { top: 12px; right: 12px; bottom: auto; width: calc(100% - 24px); max-height: calc(100% - 24px); }
}
