:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --panel-border: #2d3a4f;
  --text: #e8edf4;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  height: 100vh;
}

#sidebar {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  overflow: hidden;
}

.brand {
  padding: 1.25rem 1rem 0.75rem;
  border-bottom: 1px solid var(--panel-border);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.audience {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  color: var(--accent);
  line-height: 1.35;
}

.legend-hint {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  color: var(--muted);
}

.search-box {
  padding: 0.75rem 1rem;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.search-box input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 1rem 0.75rem;
}

.filter-chip {
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  user-select: none;
}

.filter-chip input {
  margin-right: 0.25rem;
}

.stats {
  padding: 0 1rem 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.report-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.report-item {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.report-item:hover,
.report-item.active {
  border-color: var(--accent);
  background: #121a24;
}

.report-item h3 {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  line-height: 1.3;
}

.report-item .loc {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: #fff;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--panel-border);
  font-size: 0.72rem;
  color: var(--muted);
}

#btn-refresh {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  font-size: 0.72rem;
}

#map-wrap {
  position: relative;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
}

.detail {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: min(420px, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  overflow-y: auto;
  background: rgba(15, 20, 25, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem 1rem 1.25rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 1000;
}

.detail.hidden {
  display: none;
}

.detail-close {
  position: absolute;
  top: 0.5rem;
  right: 0.65rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.detail h2 {
  margin: 0 2rem 0.5rem 0;
  font-size: 1.05rem;
}

.detail .meta-line {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.detail .summary {
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  cursor: zoom-in;
}

.detail section {
  margin-bottom: 0.85rem;
}

.detail section h4 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.detail ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.detail .disclaimer {
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--panel-border);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

.severe-tag {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  background: rgba(234, 88, 12, 0.2);
  color: #fb923c;
  vertical-align: middle;
}

.engineer-referral {
  margin: 1rem 0;
  padding: 0.85rem;
  border-radius: 10px;
  border: 1px solid #7c2d12;
  background: rgba(124, 45, 18, 0.18);
}

.engineer-referral.severe h4 {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fb923c;
}

.engineer-note {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.45;
}

.engineer-note a {
  color: #7dd3fc;
}

.engineer-cards {
  display: grid;
  gap: 0.55rem;
}

.engineer-card {
  padding: 0.65rem 0.7rem;
  border-radius: 8px;
  background: rgba(15, 20, 25, 0.65);
  border: 1px solid var(--panel-border);
}

.engineer-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.25rem;
}

.engineer-card-head strong {
  font-size: 0.86rem;
}

.engineer-role {
  font-size: 0.68rem;
  color: #86efac;
  font-weight: 600;
}

.engineer-civ {
  display: inline-block;
  font-size: 0.68rem;
  font-family: ui-monospace, monospace;
  color: #cbd5e1;
  margin-bottom: 0.2rem;
}

.engineer-spec,
.engineer-zones {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.engineer-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.btn-wa,
.btn-tel {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid transparent;
}

.btn-wa {
  background: #166534;
  color: #ecfdf5;
  border-color: #15803d;
}

.btn-tel {
  background: transparent;
  color: var(--text);
  border-color: var(--panel-border);
}

.btn-rte,
.btn-rte-card {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid #0e7c6b;
  background: rgba(14, 124, 107, 0.15);
  color: #6ee7b7;
}

.btn-rte {
  margin-top: 0.65rem;
  width: 100%;
  text-align: center;
}

.btn-rte-card {
  border-color: var(--panel-border);
  background: transparent;
  color: #7dd3fc;
}

.severity-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.severity-dot-square {
  border-radius: 3px;
}

.source-tag {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  vertical-align: middle;
}

.source-tag.tilin {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.source-tag.tv {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}

.tv-alert {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #7f1d1d;
  background: rgba(127, 29, 29, 0.2);
  margin-bottom: 0.75rem;
}

.tv-alert h4 {
  margin: 0 0 0.35rem;
  color: #fca5a5;
}

.leaflet-container {
  background: #0d1117;
  font-family: inherit;
}

@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 42vh 1fr;
  }

  #sidebar {
    order: 2;
    max-height: 58vh;
  }

  #map-wrap {
    order: 1;
    min-height: 42vh;
  }

  .detail {
    left: 1rem;
    right: 1rem;
    width: auto;
  }
}
