:root {
  --navy-0: #040910;
  --navy-1: #07121c;
  --navy-2: #0b1a2b;
  --navy-3: #102338;
  --navy-4: #163049;
  --line: rgba(201, 162, 39, 0.18);
  --line-soft: rgba(255, 255, 255, 0.06);
  --gold: #c9a227;
  --gold-2: #e0c36a;
  --gold-dim: rgba(201, 162, 39, 0.12);
  --text: #e8eef6;
  --muted: #8b9bb0;
  --up: #3dd68c;
  --down: #f07178;
  --warn: #e0a354;
  --crit: #e85d5d;
  --ok: #3dd68c;
  --info: #6cb6ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  background:
    linear-gradient(180deg, rgba(4, 9, 16, 0.2), rgba(4, 9, 16, 0.55)),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(201,162,39,0.035) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(201,162,39,0.035) 39px 40px),
    var(--navy-1);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--gold-2); text-decoration: none; }
button, input { font-family: inherit; }

/* Gate */
.gate {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(4, 9, 16, 0.92);
  display: none;
  align-items: center; justify-content: center;
}
.gate.show { display: flex; }
.gate-card {
  width: min(420px, 92vw);
  background: var(--navy-2);
  border: 1px solid var(--line);
  padding: 36px 32px;
  box-shadow: var(--shadow);
  text-align: center;
}
.gate-card h1 { font-family: var(--serif); font-weight: 500; margin: 12px 0 6px; font-size: 28px; }
.gate-card p { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.gate-card input {
  width: 100%; background: var(--navy-0); border: 1px solid var(--line);
  color: var(--text); padding: 12px 14px; margin-bottom: 12px; outline: none;
}
.gate-card input:focus { border-color: var(--gold); }
.gate-card button {
  width: 100%; background: var(--gold); color: #1a1404; border: 0;
  padding: 12px; font-weight: 700; letter-spacing: 0.08em; cursor: pointer;
}
.gate-err { color: var(--down); font-size: 13px; min-height: 18px; }

/* Shell */
.topbar {
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 18, 28, 0.92);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--gold);
  display: grid; place-items: center;
  color: var(--gold); font-family: var(--serif); font-size: 18px; font-weight: 600;
}
.brand-text { line-height: 1.15; }
.brand-text strong { display: block; font-size: 13px; letter-spacing: 0.12em; font-weight: 700; }
.brand-text span { display: block; font-size: 10px; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }
.title-block { text-align: center; }
.title-block h1 {
  margin: 0; font-family: var(--serif); font-weight: 500; font-size: 22px;
}
.title-block .sub {
  font-size: 11px; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase;
}
.live-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--up); box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.7);
  animation: pulse 1.8s infinite; margin-right: 6px; vertical-align: middle;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61,214,140,.55); }
  70% { box-shadow: 0 0 0 8px rgba(61,214,140,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,214,140,0); }
}
.clocks { display: flex; gap: 16px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.clocks b { display: block; color: var(--text); font-size: 12px; font-weight: 500; }

.ticker {
  display: flex; gap: 0; overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--navy-0);
  white-space: nowrap;
}
.ticker-track { display: flex; animation: marquee 42s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tick {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 22px; border-right: 1px solid var(--line-soft);
  font-size: 12px;
}
.tick .sym { color: var(--gold-2); letter-spacing: 0.08em; font-weight: 700; font-size: 11px; }
.tick .px { font-family: var(--mono); }
.tick .chg { font-family: var(--mono); font-size: 11px; }
.up { color: var(--up); }
.down { color: var(--down); }

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  gap: 14px;
  padding: 14px;
  min-height: calc(100vh - 64px - 37px);
}
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.panel {
  background: linear-gradient(180deg, rgba(16,35,56,.92), rgba(11,26,43,.92));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0; padding: 11px 14px;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold-2);
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600;
}
.panel h2 em { font-style: normal; color: var(--muted); letter-spacing: 0.06em; font-weight: 400; }
.pad { padding: 12px 14px; }

.asset {
  border: 1px solid var(--line-soft);
  background: rgba(4,9,16,.35);
  padding: 11px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.asset:hover, .asset.active { border-color: var(--gold); background: var(--gold-dim); }
.asset .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.asset .name { font-weight: 700; font-size: 14px; }
.asset .tag {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--gold); border: 1px solid var(--line); padding: 2px 6px;
}
.asset p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.meta { display: flex; gap: 10px; margin-top: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.pill {
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 7px; border: 1px solid;
}
.pill.watch { color: var(--info); border-color: rgba(108,182,255,.35); }
.pill.ops { color: var(--ok); border-color: rgba(61,214,140,.35); }
.pill.eval { color: var(--warn); border-color: rgba(224,163,84,.4); }
.pill.risk { color: var(--crit); border-color: rgba(232,93,93,.4); }

.map-wrap { position: relative; min-height: 420px; flex: 1; }
#map { height: 100%; min-height: 420px; background: #07111c; }
.map-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 400;
  background: rgba(7,18,28,.88); border: 1px solid var(--line); padding: 8px 10px;
  font-size: 11px; color: var(--muted);
}
.map-legend span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.brief {
  display: grid; grid-template-columns: 1.2fr .8fr; gap: 14px;
}
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kpi {
  border: 1px solid var(--line-soft); padding: 10px;
  background: rgba(4,9,16,.28);
}
.kpi .lbl { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.kpi .val { font-family: var(--mono); font-size: 18px; margin-top: 4px; }
.kpi .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }

.choke-row, .mkt-row, .tape-item {
  display: grid; gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft);
}
.choke-row { grid-template-columns: 1fr auto auto; font-size: 13px; }
.mkt-row { grid-template-columns: 1.1fr .8fr .7fr; font-size: 13px; font-family: var(--mono); }
.mkt-row .n { font-family: var(--sans); color: var(--muted); }
.status {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700;
}
.status.critical { color: var(--crit); }
.status.elevated { color: var(--warn); }
.status.watch { color: var(--info); }
.status.stable { color: var(--ok); }

.tape { max-height: 520px; overflow: auto; }
.tape-item { grid-template-columns: 64px 1fr; font-size: 13px; }
.tape-item .t { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tape-item .src { color: var(--gold); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.tape-item p { margin: 3px 0 0; line-height: 1.4; }

.note {
  font-size: 12px; color: var(--muted); line-height: 1.5;
}
.footer {
  padding: 10px 18px 18px; color: var(--muted); font-size: 11px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}

.leaflet-container { background: #07111c; font-family: var(--sans); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--navy-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 0;
}
.leaflet-popup-content { margin: 10px 12px; font-size: 12px; }
.leaflet-control-attribution { background: rgba(7,18,28,.7) !important; color: #6b7c90 !important; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .clocks { display: none; }
  .brief, .kpis { grid-template-columns: 1fr 1fr; }
  .map-wrap, #map { min-height: 360px; }
}
@media (max-width: 640px) {
  .title-block h1 { font-size: 16px; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
