:root {
  color-scheme: dark;
  --bg: #101419;
  --panel: #171e25;
  --panel-2: #202832;
  --panel-3: #121820;
  --line: #344250;
  --text: #d9dee5;
  --muted: #8f9aa7;
  --accent: #21b7ff;
  --good: #58d0a9;
  --bad: #ff6b6b;
  --warn: #ffe100;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}
body[data-br-theme="evetools"] { background: #181818; }
body[data-br-theme="warbeacon"] { background: #06090f; }
body[data-br-theme="zkillboard"] { background: #111; }
body[data-br-theme="killmail"] { background: #090b10; }
a { color: inherit; }
.wrap {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 16px 48px;
}
.report-shell {
  --team-a: #5db7ff;
  --team-b: #f2a36a;
  --team-a-soft: rgba(93, 183, 255, .16);
  --team-b-soft: rgba(242, 163, 106, .16);
  min-width: 0;
  color: var(--text);
}
.theme-evetools {
  --bg: #181818;
  --panel: #171717;
  --panel-2: #303030;
  --panel-3: #05020f;
  --line: #444;
  --text: #cfd2d8;
  --muted: #888;
  --accent: #35a7df;
  --warn: #ffe100;
}
.theme-warbeacon {
  --bg: #06090f;
  --panel: rgba(12, 12, 12, .86);
  --panel-2: #111923;
  --panel-3: rgba(12, 12, 12, .72);
  --line: rgba(70, 130, 180, .35);
  --text: #f2f5fb;
  --muted: #9ea8b7;
  --accent: #f0b84b;
  --warn: #ffffff;
  --team-a: #5a89ff;
  --team-b: #e8575e;
  --team-a-soft: rgba(90, 137, 255, .22);
  --team-b-soft: rgba(232, 87, 94, .22);
}
.theme-zkillboard {
  --bg: #111;
  --panel: #070707;
  --panel-2: #151515;
  --panel-3: #0c0c0c;
  --line: rgba(255,255,255,.14);
  --text: #ababab;
  --muted: #888;
  --accent: #77c900;
  --warn: #77c900;
  --team-a: #69bfff;
  --team-b: #ffb06f;
  --team-a-soft: rgba(105, 191, 255, .16);
  --team-b-soft: rgba(255, 176, 111, .16);
}
.theme-killmail {
  --bg: #090b10;
  --panel: #0b0d13;
  --panel-2: #11141c;
  --panel-3: #080a0f;
  --line: rgba(255,255,255,.10);
  --text: #f6f8ff;
  --muted: #737887;
  --accent: #00b7e8;
  --warn: #f6f8ff;
  --team-a: #00b7e8;
  --team-b: #ff3856;
  --team-a-soft: rgba(0, 183, 232, .14);
  --team-b-soft: rgba(255, 56, 86, .14);
}
.loading, .error-box {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
  color: var(--muted);
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 18px;
}
h1 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, auto));
  gap: 8px;
}
.stat {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 12px;
}
.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.stat-value {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}
.date-section { margin-top: 18px; }
.date-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.date-heading h2 {
  margin: 0;
  color: #fff;
  font-size: 17px;
}
.date-heading span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.report-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.report-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
}
.report-main { min-width: 0; }
.report-title {
  display: inline-block;
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.report-title:hover { text-decoration: underline; }
.report-meta {
  margin-top: 5px;
  color: #c8d0da;
  font-size: 13px;
}
.report-file {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.open-button, .back-link {
  border: 1px solid rgba(88, 208, 169, .45);
  background: rgba(88, 208, 169, .13);
  color: #d5fff2;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}
.viewer-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}
.viewer-title {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.viewer-subtitle {
  color: var(--muted);
  line-height: 1.5;
}
.theme-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px;
  margin-bottom: 12px;
}
.theme-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.theme-copy strong {
  color: #fff;
  font-size: 13px;
}
.theme-copy span {
  color: var(--muted);
  font-size: 12px;
}
.theme-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.theme-button {
  display: grid;
  gap: 2px;
  min-width: 108px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 9px;
  cursor: pointer;
  text-align: left;
}
.theme-button span {
  font-weight: 850;
  line-height: 1.1;
}
.theme-button small {
  color: var(--muted);
  font-size: 11px;
}
.theme-button.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.metric-card {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
  text-align: center;
}
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.metric-card strong {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-size: 24px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.efficiency-board {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px;
  margin-bottom: 10px;
}
.efficiency-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 56px;
  gap: 10px;
  align-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.efficiency-track {
  height: 9px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.efficiency-track div {
  height: 100%;
  background: var(--team-a);
}
.efficiency-row.enemy .efficiency-track div { background: var(--team-b); }
.external-links {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px;
  margin-bottom: 12px;
}
.external-title {
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  margin-bottom: 7px;
}
.external-list {
  display: grid;
  gap: 8px;
}
.external-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.external-system {
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.external-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.external-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--accent);
  padding: 6px 9px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.external-button:hover {
  border-color: var(--accent);
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
.tab-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
}
.tab-button.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.battle-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
}
.team-grid, .side-summary-grid, .damage-grid, .composition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}
.side-card, .damage-card, .composition-card, .team-panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}
.team-panel:first-child { border-top: 3px solid var(--team-a); }
.team-panel:last-child { border-top: 3px solid var(--team-b); }
.side-card, .damage-card, .composition-card { padding: 12px; }
.side-card h4, .damage-card h4, .composition-card h4 {
  margin: 0 0 10px;
  font-size: 15px;
}
.team-title {
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  color: #fff;
  text-align: center;
  font-weight: 800;
}
.team-stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.team-stats span:nth-child(even) {
  color: #fff;
  font-weight: 800;
  text-align: right;
}
.compact-list { display: grid; gap: 6px; font-size: 13px; }
.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding-bottom: 5px;
}
.compact-row:last-child { border-bottom: 0; padding-bottom: 0; }
.org-list {
  display: grid;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}
.org-row {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  color: #f0f4fa;
  font-size: 13px;
}
.org-count { color: #fff; font-weight: 800; }
.org-value { color: var(--muted); font-size: 12px; white-space: nowrap; }
.team-table, .detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.team-table th, .detail-table th {
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  color: var(--warn);
  font-weight: 700;
  padding: 6px;
  white-space: nowrap;
}
.team-table td, .detail-table td {
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding: 6px;
  vertical-align: middle;
}
.team-table tr.loss-row { background: rgba(120, 0, 0, .65); }
.pilot-cell {
  display: grid;
  grid-template-columns: 32px minmax(0,1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
}
.ship-icon {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border: 1px solid #333;
  background: #080808;
}
.pilot-name { color: var(--warn); font-weight: 800; overflow-wrap: anywhere; }
.ship-name { color: #dfe8ff; font-size: 12px; overflow-wrap: anywhere; }
.value-cell { color: #dfe8ff; text-align: right; white-space: nowrap; font-weight: 700; }
.muted { color: var(--muted); }
.text-end { text-align: right; }
.badge {
  display: inline-block;
  border: 1px solid rgba(105,183,255,.28);
  background: rgba(105,183,255,.13);
  color: #cfe9ff;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 800;
}
.badge-loss {
  border-color: rgba(255,107,107,.28);
  background: rgba(255,107,107,.15);
  color: #ffd8d8;
}
.badge-kill {
  border-color: rgba(88,208,169,.28);
  background: rgba(88,208,169,.15);
  color: #d5fff2;
}
.damage-row, .composition-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 6px 0;
  font-size: 13px;
}
.damage-row:last-child, .composition-row:last-child { border-bottom: 0; }
.row-main { min-width: 0; overflow-wrap: anywhere; font-weight: 720; }
.row-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-value { color: #dfe8ff; font-weight: 800; text-align: right; white-space: nowrap; }
.theme-warbeacon .viewer-head {
  border: 1px solid var(--line);
  background: var(--panel-3);
  padding: 14px;
}
.theme-warbeacon .metric-card strong {
  color: var(--accent);
  font-size: 30px;
}
.theme-warbeacon .team-panel {
  background: linear-gradient(180deg, var(--team-a-soft), var(--panel) 58%);
}
.theme-warbeacon .team-panel:last-child {
  background: linear-gradient(180deg, var(--team-b-soft), var(--panel) 58%);
}
.theme-warbeacon .tabs {
  border-bottom: 1px solid var(--line);
}
.theme-warbeacon .tab-button {
  border-color: transparent;
  background: transparent;
  text-transform: uppercase;
  letter-spacing: 0;
}
.theme-warbeacon .tab-button.active {
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.theme-zkillboard .viewer-title {
  color: #fff;
  font-size: clamp(24px, 3vw, 30px);
}
.theme-zkillboard .metric-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.theme-zkillboard .metric-card {
  text-align: left;
}
.theme-zkillboard .metric-card strong {
  color: var(--text);
  font-size: 16px;
}
.theme-zkillboard .open-button,
.theme-zkillboard .back-link,
.theme-zkillboard .external-button {
  border-color: #4f9f00;
  background: #3f8f00;
  color: #fff;
}
.theme-zkillboard .team-table th,
.theme-zkillboard .detail-table th {
  color: #d1d8df;
}
.theme-killmail .viewer-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.theme-killmail .viewer-title {
  color: #fff;
  font-size: 20px;
}
.theme-killmail .theme-picker,
.theme-killmail .external-links,
.theme-killmail .battle-summary,
.theme-killmail .side-card,
.theme-killmail .damage-card,
.theme-killmail .composition-card,
.theme-killmail .team-panel,
.theme-killmail .metric-card,
.theme-killmail .efficiency-board {
  background: transparent;
}
.theme-killmail .metric-card {
  text-align: left;
  border-left: 0;
  border-right: 0;
}
.theme-killmail .metric-card strong {
  font-size: 34px;
}
.theme-killmail .team-title {
  background: transparent;
  color: var(--accent);
  text-align: left;
  text-transform: uppercase;
}
.theme-killmail .team-panel:last-child .team-title {
  color: var(--team-b);
}
.footer {
  margin-top: 28px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.local-test-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
  margin-bottom: 14px;
}
.file-button {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(88, 208, 169, .45);
  background: rgba(88, 208, 169, .13);
  color: #d5fff2;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}
.file-button input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.local-preview {
  display: grid;
  gap: 10px;
}
@media (max-width: 820px) {
  .hero, .viewer-head, .battle-summary, .team-grid, .side-summary-grid, .damage-grid, .composition-grid, .theme-picker, .external-row {
    grid-template-columns: 1fr;
  }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-card { grid-template-columns: 1fr; }
  .open-button { justify-self: start; }
  .theme-buttons, .external-buttons { justify-content: flex-start; }
}
