/* Self-hosted fonts (latin subset) — no third-party requests. */
@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/chakra-petch-500.woff2") format("woff2");
}
@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/chakra-petch-600.woff2") format("woff2");
}
@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/chakra-petch-700.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-500.woff2") format("woff2");
}

:root {
  --bg: #101419;
  --panel: #161C23;
  --panel-2: #1B222B;
  --line: #2A333D;
  --text: #D8DEE4;
  --muted: #7E8A96;
  --amarr: #C9A227;
  --caldari: #6B93BD;
  --gallente: #3FA98C;
  --minmatar: #BF5B3D;
  --danger: #C4574A;
  --pirate: #9B6CC8;
  --font-display: "Chakra Petch", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Reserve the scrollbar's width on every page, whether or not that page's
   content is tall enough to need one — otherwise .wrap (centered, max-width)
   shifts a few px left/right on tab switches depending on scrollbar presence. */
html { scrollbar-gutter: stable; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px 64px; }

/* ---------- Header ---------- */
header { padding: 20px 0 16px; }

.header-top,
.header-bottom {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.header-bottom { margin-top: 6px; }

.header-top h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.header-top h1 span { color: var(--muted); font-weight: 500; }
.subtitle { color: var(--muted); font-size: 13px; }

.controls { display: flex; align-items: center; gap: 12px; }

.lang-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.lang-toggle button {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
}
.lang-toggle button.active { background: var(--panel-2); color: var(--text); }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }

button:focus-visible, select:focus-visible {
  outline: 2px solid var(--caldari);
  outline-offset: 2px;
}

.timestamp { font-family: var(--font-mono); font-size: 12px; color: var(--muted); min-width: 104px; display: inline-block; }

/* ---------- Tab navigation ---------- */
nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
  flex-wrap: wrap;
}
nav a {
  display: inline-block;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 10px 16px;
  cursor: pointer;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); border-bottom-color: var(--caldari); }

/* ---------- Section titles ---------- */
.section-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 32px 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-title:first-child { margin-top: 0; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Warzone cards ---------- */
.warzones { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .warzones { grid-template-columns: 1fr; } }

.wz-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px;
}
.wz-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 4px;
}
.wz-counts {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Front bar: one segment per system, colored by occupier */
.front-bar {
  display: flex;
  gap: 1px;
  height: 26px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
}
.front-bar .seg {
  flex: 1;
  min-width: 2px;
  opacity: 0.92;
  transition: opacity 0.15s ease, transform 0.15s ease;
  cursor: default;
}
.front-bar .seg.contested-flag { box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.55); }
.front-bar .seg:hover { opacity: 1; transform: scaleY(1.15); }

.front-legend {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.front-legend .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 6px;
}

.wz-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.stat {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
}
.stat .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stat .vals {
  font-family: var(--font-mono);
  font-size: 13px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 720px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
thead th {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
tbody td { padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }

td.mono { font-family: var(--font-mono); font-size: 13px; }
td .sub { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
td.strong, .strong { color: #fff; font-weight: 500; }
td.req { font-size: 13px; color: var(--muted); max-width: 280px; }
td.rank { color: var(--muted); width: 32px; }
td.sys-cell { white-space: nowrap; }

/* System links to external references */
.sys-link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
}
.sys-link:hover { color: #fff; border-bottom-color: var(--text); }
.ext-link {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 5px;
  vertical-align: 1px;
}
.ext-link:hover { color: var(--text); border-color: var(--muted); }

.fac-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 3px;
  border: 1px solid;
  white-space: nowrap;
}

.vp-bar {
  position: relative;
  height: 10px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  min-width: 120px;
}
.vp-bar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 2px; }

.status-pill { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.status-pill.hot { color: var(--danger); }
.status-pill.dim { opacity: 0.6; }

/* ---------- Warzone maps ---------- */
.wz-maps { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .wz-maps { grid-template-columns: 1fr; } }

.map-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px 8px;
}
.map-head {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.map-frame { position: relative; }
.wz-map {
  width: 100%;
  height: auto;
  display: block;
  cursor: grab;
  touch-action: none;
}
.wz-map.panning { cursor: grabbing; }
.map-edges line { stroke: var(--line); stroke-width: calc(1px * var(--fk, 1)); }
.map-node {
  opacity: 0.95;
  cursor: default;
  stroke: var(--bg);
  stroke-width: calc(1.5px * var(--fk, 1));
}
.map-sys:hover .map-node { opacity: 1; stroke: var(--text); }
.map-node.contested { stroke: rgba(255, 255, 255, 0.85); stroke-width: calc(2px * var(--fk, 1)); }
.map-node.vulnerable { stroke: var(--danger); stroke-width: calc(2.5px * var(--fk, 1)); }
.map-halo { opacity: 0.18; pointer-events: none; }
.map-code {
  fill: var(--bg);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: calc(8.5px * var(--fk, 1));
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.map-label-minor { display: none; }
.wz-map.zoomed .map-label-minor { display: block; }
.map-ins {
  fill: none;
  stroke: var(--pirate);
  stroke-width: calc(1.5px * var(--fk, 1));
  opacity: 0.85;
}
.map-ins.fob { stroke-width: calc(3px * var(--fk, 1)); }
.map-sys { cursor: pointer; }

.map-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.map-controls button {
  width: 26px;
  height: 26px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.map-controls button:hover { border-color: var(--muted); }
.map-label {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: calc(10px * var(--fk, 1));
  text-anchor: middle;
  pointer-events: none;
}

/* ---------- System role tags ---------- */
.class-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.class-tag.class-frontline { border-color: var(--danger); color: var(--danger); }
.class-tag.class-command { border-color: var(--caldari); color: var(--caldari); }

.depth-thin { color: var(--danger); }

/* ---------- Contested trend column ---------- */
.delta-up { color: var(--danger); }
.delta-down { color: var(--gallente); }
.delta-flip {
  color: var(--amarr);
  font-weight: 600;
  letter-spacing: 0.08em;
}

/* ---------- History charts ---------- */
.hist-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .hist-charts { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
}
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 0.5; }
.chart .line { fill: none; stroke-width: 1.8; }
.chart .ytick {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-anchor: end;
  dominant-baseline: middle;
}
.chart .xtick {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-anchor: middle;
}
.chart-legend {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.chart-legend .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 6px;
}

/* ---------- Campaign objectives ---------- */
.cmp-objectives { margin-top: 10px; }
.cmp-objectives summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.cmp-objectives ul { margin: 8px 0 0 18px; font-size: 13px; }
.cmp-objectives li { margin-bottom: 6px; }
.obj-career {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 6px;
}
.obj-reward { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ---------- Toolbar rows ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar label { font-size: 13px; color: var(--muted); }
.mode-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.btn.active-mode { border-color: var(--caldari); color: var(--caldari); }
.btn:disabled { opacity: 0.5; cursor: wait; }

.toolbar select,
.toolbar input[type="text"] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 10px;
}
.toolbar input[type="text"] { width: 150px; }
.toolbar input[type="text"]:focus-visible {
  outline: 2px solid var(--caldari);
  outline-offset: 2px;
}

.dlabel { color: var(--muted); margin-right: 6px; }

/* ---------- Leaderboards ---------- */
.boards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}
.board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.board-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.board-table { border: none; border-radius: 0; }

/* ---------- Campaign cards ---------- */
.campaigns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .campaigns { grid-template-columns: 1fr; } }

.cmp-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 6px;
  padding: 18px 20px;
}
.cmp-card .empire {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cmp-card h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 4px 0 8px;
}
.cmp-card p { font-size: 14px; }
.cmp-card .goal { color: var(--muted); font-size: 13px; margin-top: 8px; }

.notice {
  margin-top: 16px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
}
.notice.pre-table { margin: 0 0 14px; }

/* ---------- Insurgency cards ---------- */
.ins-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
@media (max-width: 860px) { .ins-cards { grid-template-columns: 1fr; } }
.ins-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--pirate);
  border-radius: 6px;
  padding: 10px 14px;
}
.ins-head {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pirate);
}
.ins-body { font-size: 13px; color: var(--muted); margin-top: 3px; }

section { position: relative; }

/* LP store: controls column on the left, trend chart on the right */
.lp-top {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.lp-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-width: 240px;
  max-width: 300px;
  flex: 0 0 auto;
}
.lp-controls label { font-size: 13px; color: var(--muted); }
.lp-controls select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 10px;
}
.lp-controls .mode-badge { font-size: 12px; line-height: 1.5; }
#lp-trend { flex: 1 1 380px; min-width: 0; }

/* ---------- Map popover ---------- */
.map-pop {
  position: absolute;
  z-index: 10;
  width: 270px;
  background: var(--panel-2);
  border: 1px solid var(--muted);
  border-radius: 6px;
  padding: 12px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
}
.pop-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}
.pop-head .det-close { margin-left: auto; }
.pop-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}
.pop-more {
  margin-top: 10px;
  width: 100%;
}

/* ---------- System detail panel ---------- */
.sys-detail { margin-top: 16px; }
.det-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 18px;
}
.det-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.det-head h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}
.det-close {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  padding: 3px 8px;
  cursor: pointer;
}
.det-close:hover { color: var(--text); border-color: var(--muted); }
.det-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 28px;
  margin-top: 14px;
}
.det-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.spark { width: 100%; max-width: 280px; height: auto; display: block; margin-top: 6px; }
.spark path { fill: none; stroke: var(--caldari); stroke-width: 1.5; }
.spark-scale { font-size: 10px; color: var(--muted); margin-top: 2px; }
.det-neighbors {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  background: transparent;
  border: 1px solid;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 8px;
  cursor: pointer;
}
.chip:hover { background: var(--panel-2); }
.sys-row { cursor: pointer; }

/* ---------- FAQ ---------- */
.faq { display: flex; flex-direction: column; gap: 10px; max-width: 860px; }
.faq-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 16px;
}
.faq-item summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.faq-item summary:hover { color: #fff; }
.faq-item p {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

/* ---------- States ---------- */
.error-box {
  padding: 32px 20px;
  text-align: center;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 13px;
}
.hidden { display: none !important; }

footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
footer .mono { font-family: var(--font-mono); }
footer a { color: var(--muted); }
footer a:hover { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .front-bar .seg { transition: none; }
  .front-bar .seg:hover { transform: none; }
}

/* ---------- Small screens ---------- */
@media (max-width: 700px) {
  .wrap { padding: 0 12px 48px; }
  header { padding: 14px 0 12px; }
  .header-top h1 { font-size: 20px; }
  nav button { padding: 8px 10px; font-size: 12px; }
  thead th { padding: 8px 8px; font-size: 11px; }
  tbody td { padding: 7px 8px; font-size: 12.5px; }
  td.mono { font-size: 11.5px; }
  .vp-bar { min-width: 70px; }
  td.req { max-width: 180px; }
  .wz-stats { grid-template-columns: 1fr; gap: 6px; }
}
