:root {
  color-scheme: dark;
  --page: #0a111d;
  --panel: #111c2b;
  --panel-high: #152335;
  --line: #28394e;
  --text: #e9f2f7;
  --muted: #abbad0;
  --soft: #859ab3;
  --accent: #69d9ea;
  --coalition: #ffe04f;
  --pirates: #ff4c5d;
  --swarm: #ba67ff;
  --unclaimed: #a3afc4;
  --success: #82dac1;
  --alert: #ffd29a;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  font-synthesis: none;
  background: var(--page);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, select, input { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .brand { font-family: Bahnschrift, 'Segoe UI', sans-serif; }
h2 { font-size: 20px; line-height: 1.2; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
small { font-size: 12px; color: var(--muted); }
.skip-link { position: fixed; z-index: 8; left: 16px; top: -50px; background: var(--panel-high); padding: 9px 14px; border-radius: 5px; }
.skip-link:focus { top: 10px; }

.topbar { display: flex; align-items: stretch; gap: 34px; min-height: 65px; padding: 0 max(26px, calc((100vw - 1480px) / 2)); background: #0e1725; border-bottom: 1px solid #24344a; }
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; font-size: 19px; font-weight: 650; font-stretch: condensed; letter-spacing: .025em; }
.brand img { object-fit: contain; }
.brand-subtitle { margin-left: 5px; color: #9eb6cf; font-weight: 450; }
.nav { display: flex; align-items: stretch; gap: 25px; }
.nav a { display: flex; align-items: center; position: relative; min-height: 46px; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--text); }
.nav a[aria-current='page']::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; }
.mode { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; margin-left: auto; color: #b9cfdf; font-size: 12px; }
.mode i { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: #7bc8c4; box-shadow: 0 0 10px #7bc8c454; }

.main { width: min(1480px, calc(100% - 64px)); margin: 29px auto 42px; }
.loading { color: var(--muted); padding: 25px 0; }
.page-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-end; margin-bottom: 21px; }
.page-head h1 { font-size: clamp(30px, 3.2vw, 48px); line-height: 1.03; font-weight: 690; letter-spacing: -.032em; }
.page-head p { margin-top: 8px; line-height: 1.45; color: var(--muted); font-size: 14px; }
.head-actions, .inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-actions { justify-content: flex-end; }
.control { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 37px; border: 1px solid #354a61; background: #172639; color: #e9f2f7; padding: 7px 11px; border-radius: 6px; font-size: 13px; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.control:hover { background: #20344a; border-color: #53718a; }
.control:disabled { opacity: .48; cursor: default; }
.control.primary { background: #a1e2ed; color: #112a39; border-color: #a1e2ed; }
.control.primary:hover { background: #c3f0f5; }
.control.quiet { background: transparent; border-color: transparent; color: #b0c8df; }
.control.quiet:hover { background: #25364a; }
select.control { padding-right: 8px; }
.inline-actions a.control { cursor: pointer; }

.score-strip, .metric-strip { display: grid; gap: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: #101b2a; border-radius: 9px; overflow: hidden; margin-bottom: 16px; }
.metric-strip { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.score, .metric { min-width: 0; min-height: 79px; padding: 12px 17px; border-right: 1px solid var(--line); }
.score:last-child, .metric:last-child { border-right: 0; }
.score-title, .metric-name { color: var(--muted); font-size: 12px; font-weight: 650; }
.score-title { display: flex; align-items: center; gap: 7px; }
.score-reading { color: var(--faction); }
.score-reading, .metric-reading { font-family: Bahnschrift, 'Segoe UI', sans-serif; font-size: 25px; font-variant-numeric: tabular-nums; font-weight: 650; line-height: 1.09; margin-top: 7px; overflow-wrap: anywhere; }
.score-reading small { margin-left: 5px; font-family: 'Segoe UI', sans-serif; color: var(--soft); font-weight: 500; }
.metric small { display: block; margin-top: 6px; line-height: 1.3; }
.mark { --faction: var(--unclaimed); width: 8px; height: 8px; flex: 0 0 8px; display: inline-block; border-radius: 2px; background: var(--faction); }
[data-faction='coalition'] { --faction: var(--coalition); }
[data-faction='pirates'] { --faction: var(--pirates); }
[data-faction='swarm'] { --faction: var(--swarm); }
[data-faction='unclaimed'] { --faction: var(--unclaimed); }
.mark[data-faction='pirates'] { transform: rotate(45deg); }
.mark[data-faction='swarm'] { border-radius: 50%; }
.mark[data-faction='unclaimed'] { background: transparent; border: 1px solid var(--faction); }

.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 360px); gap: 16px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 15px 17px; }
.panel-head p { color: var(--muted); font-size: 12px; line-height: 1.45; margin-top: 4px; }
.map-panel { overflow: hidden; }
.map-panel .panel-head { min-height: 63px; }
.map-tools { display: flex; gap: 7px; flex-wrap: wrap; }
.search { display: inline-flex; min-width: 0; position: relative; }
.search input { width: 170px; padding: 6px 9px; background: #0e1928; border: 1px solid #34485e; border-radius: 6px; font-size: 13px; min-height: 35px; }
.search input::placeholder { color: #a6b9d1; }
.suggestions { position: absolute; z-index: 6; padding: 5px; right: 0; top: 40px; min-width: 205px; background: #19283b; border: 1px solid #4a6580; border-radius: 7px; box-shadow: 0 8px 30px #0008; }
.suggestions button { display: block; width: 100%; text-align: left; padding: 7px 9px; background: transparent; border: 0; border-radius: 4px; }
.suggestions button:hover, .suggestions button:focus { background: #2b425c; }
.suggestions p { padding: 5px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 7px 19px; padding: 9px 17px; margin: 0; list-style: none; border-top: 1px solid #26364b; font-size: 12px; }
.map-legend li { display: flex; align-items: center; gap: 7px; }
.map-field { height: clamp(395px, 35vw, 550px); position: relative; isolation: isolate; overflow: hidden; border-top: 1px solid #2b3b52; background: #0a1524; }
.map-field::before { content: ''; position: absolute; inset: 0; z-index: -2; background-image: linear-gradient(90deg, #07132098, #070e1b43 52%, #080f1c7a), url('./art/galaxy.png'); background-size: cover; background-position: center; opacity: .82; }
.map-field::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: -1; background-image: linear-gradient(#b5d0fa0b 1px, transparent 1px), linear-gradient(90deg, #b5d0fa0b 1px, transparent 1px); background-size: 38px 38px; }
.map-stage { position: absolute; inset: 18px 24px 16px 19px; }
.map-lines { width: 100%; height: 100%; position: absolute; inset: 0; pointer-events: none; }
.node { position: absolute; left: var(--x); top: var(--y); z-index: 1; width: 26px; height: 26px; transform: translate(-50%, -50%); padding: 0; border: 0; background: transparent; border-radius: 50%; }
.node::before { content: ''; display: block; margin: auto; width: 9px; height: 9px; border-radius: 2px; background: var(--faction); box-shadow: 0 0 9px color-mix(in srgb, var(--faction), transparent 40%); }
.node[data-faction='swarm']::before { border-radius: 50%; }
.node[data-faction='pirates']::before { transform: rotate(45deg); }
.node[data-faction='unclaimed']::before { background: #131d2b; border: 1px solid var(--faction); }
.node.hq::after, .node.contested::after { content: ''; position: absolute; inset: 5px; border: 1px solid var(--faction); border-radius: 50%; pointer-events: none; }
.node.hq::after { border-style: dashed; }
.node.contested::after { border-color: #e6dcffa4; opacity: .65; }
.node.dim { opacity: .22; }
.node:focus-visible, .node:hover, .node.selected { z-index: 4; opacity: 1; }
.node.selected { border: 1px solid #d6f8ff; background: #c5e9ff22; box-shadow: 0 0 0 4px #87d9ff27; }
.node.selected::before { width: 11px; height: 11px; }
.node-name { position: absolute; left: 21px; top: 4px; color: #f0f7ff; white-space: nowrap; font-size: 10px; font-weight: 650; text-shadow: 0 1px 3px #000, 0 0 4px #000; background: #090f1b7a; padding: 1px 4px; border-radius: 3px; pointer-events: none; }
.node.label-left .node-name { left: auto; right: 21px; }
.node:not(.major, .selected):not(:hover, :focus-visible) .node-name, .node.dim:not(:hover, :focus-visible) .node-name { display: none; }
.node.selected .node-name { font-size: 11px; color: #fff; background: #1e344b; border: 1px solid #6085a4; }
.map-scale { position: absolute; left: 13px; bottom: 11px; color: #acc4dc; font-size: 11px; padding: 4px 7px; border-radius: 4px; background: #0a1425c0; pointer-events: none; }
.map-count { position: absolute; right: 13px; bottom: 11px; color: #acc4dc; font-size: 11px; padding: 4px 7px; border-radius: 4px; background: #0a1425c0; pointer-events: none; }
.timeline { padding: 8px 17px 11px; border-top: 1px solid #26364b; background: #0f1928; }
.timeline-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.timeline-title strong { font-size: 13px; font-weight: 650; }
.timeline-title output { color: #b8d7ee; font-size: 12px; text-align: right; }
.timeline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 11px; }
.timeline-row input { min-width: 100px; flex: 1; width: 100%; accent-color: #95dce8; cursor: pointer; }
.timeline-row .control { min-height: 31px; }
.timeline input:disabled { cursor: default; }

.sidebar { display: grid; gap: 14px; min-width: 0; }
.inspector { overflow: hidden; }
.inspector .panel-head { gap: 7px; padding-bottom: 11px; }
.inspector .system-title { margin-top: 8px; font-size: 27px; line-height: 1.05; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; align-self: start; gap: 6px; width: fit-content; color: var(--faction, var(--muted)); font-size: 12px; font-weight: 650; border: 1px solid color-mix(in srgb, var(--faction, var(--line)), transparent 68%); background: color-mix(in srgb, var(--faction, var(--line)), transparent 93%); padding: 4px 7px; border-radius: 5px; }
.system-body { padding: 0 17px 16px; }
.system-facts { display: flex; gap: 17px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 2px 0 14px; }
.system-facts b { color: var(--text); font-variant-numeric: tabular-nums; }
.pressure { margin-top: 10px; }
.pressure-label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.pressure-label b { color: var(--text); font-variant-numeric: tabular-nums; }
.bar { height: 5px; background: #2b3a4e; overflow: hidden; border-radius: 4px; }
.bar span { display: block; height: 100%; background: var(--faction); }
.inspection-note { color: #b6c4d5; font-size: 12px; margin-top: 11px; line-height: 1.45; }
.neighbor-block { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 12px; }
.neighbor-block h3 { color: var(--muted); font-size: 13px; }
.neighbors { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.neighbors button { min-height: 27px; font-size: 11px; padding: 4px 7px; }
.event-list { list-style: none; margin: 0; padding: 0; }
.event-row { display: flex; align-items: flex-start; gap: 10px; padding: 11px 17px; border-top: 1px solid #26364a; }
.event-row .mark { margin-top: 5px; }
.row-link { border: 0; background: none; text-align: left; padding: 0; color: inherit; min-width: 0; }
.row-link:hover strong { color: #b4e7f3; }
.row-link strong { display: block; font-size: 13px; font-weight: 650; line-height: 1.28; }
.row-link small { display: block; margin-top: 5px; color: var(--soft); }
.foot-note { font-size: 12px; line-height: 1.55; color: var(--muted); padding: 14px 0 0; }
.empty { padding: 14px 17px; font-size: 14px; line-height: 1.5; color: var(--muted); }

.columns { display: grid; grid-template-columns: minmax(0, 1.54fr) minmax(0, 1fr); gap: 15px; align-items: start; }
.columns.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 15px; min-width: 0; }
.chart-card { min-height: 267px; }
.chart { position: relative; height: 200px; margin: 0 17px 14px; }
.chart canvas { display: block; width: 100%; height: 100%; }
.chart-tooltip { position: absolute; top: 0; color: var(--text); background: #22364b; border: 1px solid #516e8b; border-radius: 5px; padding: 5px 7px; font-size: 11px; pointer-events: none; }
.chart-legend { display: flex; flex-wrap: wrap; column-gap: 14px; row-gap: 4px; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.money-rows { list-style: none; padding: 0 17px 14px; margin: 0; }
.money-rows li { margin-bottom: 13px; color: var(--muted); font-size: 13px; }
.money-rows li:last-child { margin-bottom: 1px; }
.money-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.money-label b { color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.scroll-table { overflow: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 15px; border-top: 1px solid #28394d; vertical-align: top; }
th { color: #b4c8da; font-size: 12px; font-weight: 650; white-space: nowrap; }
td strong { font-weight: 650; }
td small { display: block; margin-top: 4px; }
.numeric { text-align: right; white-space: nowrap; }
.economy-table { margin-top: 15px; }
.accent-value { color: var(--accent); }
.caution-value { color: var(--alert); }

.faction-card { position: relative; overflow: hidden; border-top: 2px solid var(--faction); }
.faction-card .panel-head { padding: 18px; }
.faction-card .panel-head h2 { color: var(--faction); }
.faction-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0 18px 15px; gap: 13px; }
.faction-details strong { display: block; font-family: Bahnschrift, sans-serif; font-size: 29px; line-height: 1.06; font-variant-numeric: tabular-nums; }
.faction-details small { display: block; margin-top: 5px; }
.faction-reserve { margin: 0 18px 17px; }
.faction-reserve .bar { margin-top: 7px; }
.command-panel { margin-top: 15px; }
.status { display: inline-block; border-radius: 4px; padding: 3px 6px; white-space: nowrap; font-size: 11px; font-weight: 650; background: #384556; color: #d8e2eb; }
.status[data-state='accepted'] { background: #1d3c3f; color: #97e5cb; }
.status[data-state='rejected'] { background: #533038; color: #ffc5bd; }
.status[data-state='held'] { background: #54442b; color: #ffe0a0; }
.decision { max-width: 62ch; }
.decision summary { cursor: pointer; }
.decision summary:hover { color: var(--accent); }
.decision p { color: var(--muted); margin-top: 8px; line-height: 1.45; }
.login-page { min-height: 100vh; background: linear-gradient(120deg, #080e1bed, #0e1828ca), url('./art/galaxy.png') center/cover; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(100%, 460px); padding: clamp(20px, 5vw, 35px); background: #111c2bef; }
.login-panel header h1 { font-size: clamp(28px, 6vw, 38px); margin-top: 13px; }
.login-panel header p { color: var(--muted); line-height: 1.55; margin: 7px 0 23px; }
.login-panel label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.login-panel input { display: block; width: 100%; cursor: text; margin-bottom: 14px; }
#login-status { color: var(--muted); font-size: 13px; min-height: 20px; margin-bottom: 8px; }

.news-workbench { grid-template-columns: minmax(0, 1fr) minmax(310px, 400px); }
.news-workbench .event-list { max-height: 690px; overflow: auto; }
.news-row { padding: 0; }
.news-row > button { width: 100%; padding: 13px 17px; display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 5px; }
.news-row > button[aria-pressed='true'] { background: #203349; border-left: 2px solid #a4e2ed; padding-left: 15px; }
.news-row .mark { margin-top: 0; }
.news-row strong { flex: 1 1 65%; }
.news-row small { flex: 1 0 calc(100% - 30px); margin: 0 0 0 17px; }
.bulletin { margin: 3px 17px 17px; padding: 17px; border: 1px solid #516b8a; border-top: 2px solid var(--faction); border-radius: 8px; background: #18283d; }
.bulletin h3 { margin: 12px 0 8px; font-size: 22px; line-height: 1.16; }
.bulletin p { color: #d5e1ed; font-size: 14px; line-height: 1.55; }
.bulletin small { display: block; margin-top: 11px; }
.bulletin-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 17px 16px; }

@media (max-width: 1090px) {
  .topbar { gap: 22px; }
  .nav { gap: 16px; }
  .main { width: calc(100% - 40px); }
  .workbench { grid-template-columns: minmax(0, 1fr) minmax(260px, 290px); }
  .search input { width: 130px; }
  .map-field { height: 455px; }
}

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 1px 17px; padding: 0 16px; }
  .brand { min-height: 51px; }
  .nav { order: 3; width: 100%; gap: 20px; overflow: auto; }
  .main { width: calc(100% - 28px); margin-top: 20px; }
  .page-head { align-items: flex-start; }
  .workbench, .columns, .columns.equal { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-field { height: clamp(330px, 59vw, 480px); }
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
}

@media (max-width: 545px) {
  .brand { gap: 6px; font-size: 15px; }
  .brand img { width: 38px; }
  .mode { font-size: 11px; gap: 5px; }
  .page-head { flex-direction: column; gap: 12px; margin-bottom: 15px; }
  .head-actions { justify-content: flex-start; }
  .page-head p { font-size: 13px; }
  .nav { gap: 16px; }
  .nav a { min-height: 39px; font-size: 13px; }
  .score-strip, .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score, .metric { min-height: 69px; padding: 9px 11px; border-bottom: 1px solid var(--line); }
  .score:nth-child(even), .metric:nth-child(even) { border-right: 0; }
  .metric:nth-child(3) { border-right: 1px solid var(--line); }
  .metric:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .score:nth-last-child(-n+2), .metric:last-child { border-bottom: 0; }
  .score-reading, .metric-reading { font-size: 23px; }
  .sidebar { grid-template-columns: 1fr; }
  .map-panel .panel-head { padding: 12px; }
  .map-tools { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .map-field { height: 350px; }
  .map-stage { inset: 15px 18px 18px 11px; }
  .map-scale, .map-count { font-size: 9px; }
  .node { width: 18px; height: 18px; }
  .node::before { width: 7px; height: 7px; }
  .node.hq::after, .node.contested::after { inset: 2px; }
  .node.major:not(.selected):not(:focus-visible):not(:hover) .node-name { display: none; }
  .node-name { left: 16px; top: 2px; }
  .node.label-left .node-name { right: 16px; }
  .timeline { padding-inline: 12px; }
  .timeline-row { gap: 6px; }
  .timeline-row .control { font-size: 11px; }
  th, td { padding: 10px; }
}
