/* ──────────────────────────────────────────────────────────────
   vigil console · home page
   Map first, then numbers. Light theme, generous spacing.
   ────────────────────────────────────────────────────────────── */

.stage {
  padding: 16px clamp(12px, 2.4vw, 26px) 0;
  display: flex; flex-direction: column; gap: 14px;
  max-width: 1760px; margin: 0 auto;
}

/* ── map ─────────────────────────────────────────────────── */
.map-panel { display: flex; flex-direction: column; }
.map-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tool-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 3px; }

.map-wrap {
  position: relative;
  height: clamp(320px, 46vh, 560px);
  background: #fdf7ef;
}
@media (max-width: 720px) { .map-wrap { height: 300px; } }

#world-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; cursor: grab; touch-action: none;
}
#world-canvas.grabbing { cursor: grabbing; }

.map-loading {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: rgba(250, 246, 240, .84);
  color: var(--text-2); font-size: 13px;
  transition: opacity .35s;
}
.map-loading i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent-line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.map-loading.gone { opacity: 0; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.map-legend {
  position: absolute; left: 12px; top: 12px; z-index: 3;
  background: rgba(255, 255, 255, .93);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; min-width: 158px;
  box-shadow: var(--shadow); backdrop-filter: blur(6px);
  font-size: 12px;
}
.lg-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--text-2); }
.lg-row b { margin-left: auto; font-family: var(--mono); color: var(--text); font-weight: 600; }
.lg-row.small { font-size: 11px; color: var(--muted); }
.lg-sep { height: 1px; background: var(--line); margin: 6px 0; }
.sw { width: 18px; height: 3px; border-radius: 2px; flex: none; }
.sw-0 { background: linear-gradient(90deg, rgba(58, 122, 82, 0), #3a7a52); }
.sw-1 { background: linear-gradient(90deg, rgba(208, 64, 48, 0), #d04030); }
.sw-2 { background: linear-gradient(90deg, rgba(132, 30, 24, 0), #841e18); }

.map-readout {
  position: absolute; right: 12px; top: 12px; z-index: 3;
  background: rgba(255, 255, 255, .93);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; max-width: 330px;
  box-shadow: var(--shadow); backdrop-filter: blur(6px);
  transition: border-color .2s, box-shadow .2s;
}
.ro-title { font-size: 12.5px; color: var(--text); margin-bottom: 3px; font-weight: 500; }
.ro-body {
  font-size: 11.5px; color: var(--text-2); font-family: var(--mono);
  line-height: 1.65; white-space: pre-line; word-break: break-all;
}
.map-readout.hot { border-color: rgba(208, 64, 48, .5); box-shadow: 0 2px 14px rgba(208, 64, 48, .16); }
@media (max-width: 860px) { .map-readout { display: none; } }

/* ── KPI strip ───────────────────────────────────────────── */
.kpis {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
}
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 11px 15px 12px; position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: .85;
}
.k-label { display: block; font-size: 11px; color: var(--muted); letter-spacing: .1em; margin-bottom: 4px; }
.k-value {
  display: block; font-family: var(--mono); font-size: 19px; font-weight: 600;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.k-value.danger { color: var(--danger); }
.k-value.amber { color: var(--warn); }
.k-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; font-family: var(--mono); }

/* ── grids ───────────────────────────────────────────────── */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1240px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 880px) { .grid-3 { grid-template-columns: 1fr; } }

/* ── resource blocks ─────────────────────────────────────── */
.res-block { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.res-block:last-child { border-bottom: none; }
.res-head { display: flex; align-items: baseline; justify-content: space-between; }
.res-head span { font-size: 11.5px; color: var(--muted); letter-spacing: .1em; }
.res-head b { font-family: var(--mono); font-size: 18px; color: var(--text); font-weight: 600; }
.spark { width: 100%; height: 30px; display: block; margin: 5px 0 3px; }
.res-foot {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 11px; color: var(--muted); font-family: var(--mono);
  white-space: nowrap; overflow: hidden;
}
.res-meta {
  display: flex; justify-content: space-between; gap: 10px; margin-top: 6px;
  font-size: 11px; color: var(--muted);
}
.res-meta b { color: var(--text-2); font-weight: 600; font-family: var(--mono); }

/* ── event stream ────────────────────────────────────────── */
.stream {
  height: 430px; overflow: auto; padding: 4px 6px 8px;
  font-size: 12px; font-family: var(--mono);
}
.ev {
  display: grid; grid-template-columns: 54px 16px minmax(0, 1fr) auto;
  gap: 7px; align-items: center; padding: 5px 8px; border-radius: 7px;
  animation: evIn .3s ease;
}
@keyframes evIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.ev:hover { background: var(--surface-soft); }
.ev.lv1 { background: rgba(208, 64, 48, .07); }
.ev.lv2 { background: rgba(132, 30, 24, .10); }
.ev-time { color: var(--muted); }
.ev-flag { text-align: center; font-size: 12px; }
.ev-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.ev-ip { color: var(--text); }
.ev-path { color: #96703f; }
.ev-right { display: flex; align-items: center; gap: 6px; }
.ev-status { color: var(--muted); }
.ev-status.bad { color: var(--danger); font-weight: 600; }
.ev-status.warn { color: var(--warn); }
.ev-badge { font-size: 10px; padding: 1px 6px; border-radius: 999px; }
.ev-badge.red { color: #fff; background: var(--danger); }
.ev-badge.black { color: #fff; background: #7a1c14; }

/* ── tables ──────────────────────────────────────────────── */
.table-wrap { max-height: 430px; overflow: auto; }
table.data { font-size: 12.5px; }
table.data th {
  position: sticky; top: 0; z-index: 2; text-align: left;
  font-weight: 500; font-size: 11.5px; letter-spacing: .06em; color: var(--muted);
  padding: 9px 14px; background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}
table.data td {
  padding: 8px 14px; border-bottom: 1px solid #f4efe8;
  color: var(--text-2); vertical-align: middle;
}
table.data tr:hover td { background: var(--surface-soft); }
table.data td.ip { font-family: var(--mono); color: var(--text); }
table.data td.reason { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.time { font-family: var(--mono); color: var(--muted); white-space: nowrap; }
.flag-cell { font-size: 13px; }

/* ── distributions ───────────────────────────────────────── */
.dist { padding: 10px 16px 13px; display: flex; flex-direction: column; gap: 7px; max-height: 240px; overflow: auto; }
.dist.compact { max-height: 170px; }
.dist-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 9px; align-items: center; font-size: 12.5px; }
.dist-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-bar { height: 4px; border-radius: 3px; background: var(--surface-sunk); overflow: hidden; margin-top: 4px; }
.dist-bar i { display: block; height: 100%; background: linear-gradient(90deg, #e6b98a, var(--accent)); }
.dist-row b { font-family: var(--mono); color: var(--text); font-weight: 600; }

/* ── trend + lists ───────────────────────────────────────── */
.trend { width: 100%; height: 240px; display: block; padding: 6px 2px 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 12px 16px 16px; }
@media (max-width: 640px) { .split { grid-template-columns: 1fr; } }
.split h4 { font-size: 11.5px; color: var(--muted); letter-spacing: .08em; font-weight: 500; margin-bottom: 8px; }
.mini-list { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-family: var(--mono); }
.mini-row { display: grid; grid-template-columns: minmax(0, 1fr) 52px 54px; gap: 8px; align-items: center; }
.mini-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.mini-row .v { text-align: right; color: var(--text); }
.mini-row .v.hot { color: var(--warn); }
.mini-row .m { text-align: right; color: var(--muted); }

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stream, .table-wrap { height: 340px; max-height: 340px; }
  .map-legend { padding: 8px 10px; min-width: 142px; }
}
