:root {
  color-scheme: dark;
  --bg: #070b14;
  --panel: rgba(10, 16, 28, 0.88);
  --panel-solid: #0c1424;
  --line: rgba(148, 163, 184, 0.18);
  --text: #e8eef8;
  --muted: #8a9bb8;
  --accent: #22d3ee;
  --accent-2: #3b82f6;
  --glass: blur(14px) saturate(1.2);
  --rail-w: 48px;
}

* { box-sizing: border-box; }
html, body, #app {
  margin: 0;
  height: 100%;
  background: #05080f;
  color: var(--text);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------- immersive map shell ---------- */
.layout {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #05080f;
}
.layout.is-app {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 320px);
  gap: 16px;
  padding: 16px;
  align-items: stretch;
  background:
    radial-gradient(ellipse at 40% 30%, rgba(34, 211, 238, 0.1), transparent 55%),
    #05080f;
}
.layout.is-app .app-stage { position: relative; inset: auto; }
.layout.is-app .status-badge { display: none; }

.stage { position: absolute; inset: 0; min-height: 0; }
#map, #cesiumContainer { position: absolute; inset: 0; width: 100%; height: 100%; }

/* floating case panel */
.side {
  position: absolute;
  z-index: 5;
  top: 16px;
  left: calc(12px + var(--rail-w) + 10px);
  width: min(300px, calc(100% - var(--rail-w) - 36px));
  max-height: calc(100% - 32px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.side.is-collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
}
.layout.is-app .side {
  position: static;
  width: min(360px, 92vw);
  max-height: none;
  background: var(--panel-solid);
}

.cat { margin: 0; font-size: 11px; color: var(--accent); font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: .08em; }
h1 { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.35; }
.hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.65; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 10px; padding: 3px 7px; border-radius: 5px; border: 1px solid rgba(59,130,246,.25); background: rgba(59,130,246,.1); color: #93c5fd; font-family: "JetBrains Mono", ui-monospace, monospace; }
label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
select, input, textarea, button, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
select, input, textarea { width: 100%; background: rgba(5, 10, 20, 0.7); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 12px; }
textarea { min-height: 72px; resize: vertical; line-height: 1.5; }
.row { display: grid; gap: 6px; }
.actions { display: grid; gap: 8px; }
button { border: 0; border-radius: 8px; padding: 10px 12px; font-size: 12px; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--accent); color: #001018; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button { padding: 8px 6px; background: rgba(5, 10, 20, 0.7); border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.seg button.active { border-color: var(--accent); color: var(--accent); background: rgba(34,211,238,.08); }
.log { flex: 1; min-height: 90px; background: rgba(5, 10, 20, 0.65); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 11px; color: var(--muted); white-space: pre-wrap; overflow: auto; line-height: 1.55; }
.log b, .log strong { color: var(--accent); font-weight: 600; }
.warn-tk { border: 1px solid rgba(251,191,36,.35); background: rgba(251,191,36,.08); color: #fbbf24; border-radius: 8px; padding: 10px; font-size: 11px; line-height: 1.55; }
.list { display: grid; gap: 6px; }
.list button { text-align: left; background: rgba(5, 10, 20, 0.7); border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.list button.active, .list button:hover { border-color: var(--accent); color: var(--accent); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: rgba(5, 10, 20, 0.65); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.kpi .n { font-size: 18px; font-weight: 700; color: var(--accent); }
.kpi .l { font-size: 11px; color: var(--muted); margin-top: 2px; }
.note { font-size: 11px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: auto; line-height: 1.55; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; max-height: 200px; }
table { width: 100%; border-collapse: collapse; font-size: 10px; font-family: "JetBrains Mono", ui-monospace, monospace; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; color: var(--muted); }
th { color: var(--accent); position: sticky; top: 0; background: #0a1225; }
.bad { color: #f87171; background: rgba(248,113,113,.12); padding: 1px 4px; border-radius: 3px; }

/* left icon rail */
.rail {
  position: absolute;
  z-index: 6;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  width: var(--rail-w);
}
.rail button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  border: 0;
}
.rail button:hover { color: var(--text); background: rgba(34, 211, 238, 0.08); }
.rail button.is-on { color: #001018; background: var(--accent); }
.rail button svg { width: 18px; height: 18px; display: block; }
.rail-sep { height: 1px; margin: 4px 6px; background: var(--line); }

.basemap-pop {
  position: absolute;
  z-index: 7;
  left: calc(12px + var(--rail-w) + 10px);
  top: 50%;
  transform: translateY(-20%);
  display: none;
  flex-direction: column;
  gap: 0;
  min-width: 108px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}
.basemap-pop.is-open { display: flex; }
.basemap-pop button {
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.basemap-pop button:last-child { border-bottom: 0; }
.basemap-pop button:hover { color: var(--text); background: rgba(34,211,238,.06); }
.basemap-pop button.active { color: #001018; background: var(--accent); }

.status-badge {
  position: absolute;
  z-index: 4;
  right: 12px;
  bottom: 12px;
  background: rgba(7, 11, 20, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 11px;
  color: var(--muted);
  backdrop-filter: blur(8px);
  max-width: min(320px, 70%);
  pointer-events: none;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.status-badge b { color: var(--accent); }

/* legacy ids kept for JS */
.badge { display: none; }
.map-tools { display: none; }
.map-seg { display: none; }

.app-stage { position: absolute; inset: 0; display: grid; place-items: center; }
.app-card { text-align: center; padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-solid); max-width: 320px; }
.app-card h2 { margin: 0 0 8px; font-size: 18px; }
.app-card p { margin: 0; color: var(--muted); font-size: 13px; }

@media (max-width: 720px) {
  .side {
    left: 12px;
    right: 12px;
    width: auto;
    top: auto;
    bottom: 12px;
    max-height: 42vh;
  }
  .side.is-collapsed { transform: translateY(8px); }
  .rail { top: 12px; transform: none; }
  .basemap-pop { top: 64px; transform: none; left: calc(12px + var(--rail-w) + 10px); }
}
