:root {
  --ink: #14171a;
  --muted: #5e6773;
  --paper: #f4f6f8;
  --panel: #ffffff;
  --line: #d9dee5;
  --line-strong: #aeb6c2;
  --blue: #0d65d9;
  --gold: #f0c33b;
  --green: #287b46;
  --red: #c93f32;
  --violet: #674aa4;
  --shadow: 0 18px 42px rgba(31, 40, 51, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(13, 101, 217, 0.07), transparent 240px),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--gold) 0 42%, transparent 42%),
    linear-gradient(315deg, var(--blue) 0 44%, transparent 44%),
    var(--ink);
  border: 1px solid rgba(20, 23, 26, 0.18);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.16);
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 2px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
  margin-bottom: 14px;
}

h3 {
  font-size: 14px;
  line-height: 1.25;
  margin-bottom: 10px;
}

.source-pill {
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px clamp(16px, 4vw, 44px);
  background: #262a30;
  scrollbar-width: thin;
}

.tab {
  color: #f5f7fa;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 850;
}

.tab:hover,
.tab:focus-visible {
  border-color: rgba(255, 255, 255, 0.5);
}

.tab.is-active {
  color: #111;
  background: var(--gold);
  border-color: var(--gold);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(260px, 1fr) minmax(220px, 320px);
  gap: 12px;
  padding: 16px clamp(16px, 4vw, 44px) 0;
}

.search,
.select-shell,
.view-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(31, 40, 51, 0.05);
}

.search span,
.select-shell span,
.view-shell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search input,
.select-shell select,
.view-shell select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.app-shell {
  padding: 18px clamp(16px, 4vw, 44px) 36px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(31, 40, 51, 0.06);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin: 8px 0 5px;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1;
}

.metric small {
  color: var(--muted);
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 14px;
}

.bar-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.bar-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 800;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex: 0 0 auto;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e9edf2;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  width: var(--bar-width);
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.bar-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #fff;
  background: #222831;
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
  letter-spacing: 0;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: inherit;
}

th:first-child {
  z-index: 3;
  background: #222831;
}

td.numeric,
th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr {
  background: #fff;
}

tbody tr:nth-child(even) {
  background: #fbfcfe;
}

tbody tr:hover {
  background: #f6f9ff;
}

.nation-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 190px;
  font-weight: 900;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  background: #f7f8fa;
  font-size: 12px;
  font-weight: 900;
}

.status.positive {
  color: #185a2d;
  background: #eaf7ef;
  border-color: #bee6ca;
}

.status.negative {
  color: #8e2118;
  background: #fff0ee;
  border-color: #f3c0ba;
}

.status.warning {
  color: #7b5300;
  background: #fff7dd;
  border-color: #f1d57d;
}

.nation-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.nation-list {
  display: grid;
  gap: 8px;
  max-height: 72vh;
  overflow: auto;
}

.nation-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.nation-button strong {
  overflow-wrap: anywhere;
}

.nation-button.is-selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(13, 101, 217, 0.12);
}

.coverage {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.coverage span {
  border-radius: 999px;
  padding: 3px 7px;
  background: #edf1f5;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.coverage span.has-data {
  color: #123;
  background: #dcecff;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.detail-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 78px;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-item strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.control-grid,
.editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.control-field {
  display: grid;
  gap: 7px;
  align-content: start;
}

.control-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.control-field input,
.control-field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: 0;
}

.control-field input:focus,
.control-field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(13, 101, 217, 0.14);
}

.command-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 16px 16px;
}

.command {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 900;
}

.command.compact {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.command:hover,
.command:focus-visible {
  border-color: var(--blue);
}

.command.primary {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.command.danger {
  color: #8e2118;
  border-color: #f0b9b2;
  background: #fff4f2;
}

.command.is-active {
  color: #fff;
  background: #262a30;
  border-color: #262a30;
}

.table-note {
  padding: 10px 16px;
  color: var(--muted);
  background: #fbfcfe;
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.editor-section {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.editor-section h3 {
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 15px;
}

.simulation-notes {
  margin: 14px 0;
}

.naval-grid,
.equipment-grid,
.audit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.fleet {
  padding: 16px;
}

.fleet + .fleet {
  border-top: 1px solid var(--line);
}

.fleet-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.fleet-total {
  font-size: 28px;
  font-weight: 950;
}

.ship-category {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.ship-category h3 {
  margin: 0;
  color: var(--blue);
}

.ship-list {
  display: grid;
  gap: 6px;
}

.ship-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.ship-row span:first-child {
  overflow-wrap: anywhere;
}

.ship-row span:last-child {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.footer {
  padding: 18px clamp(16px, 4vw, 44px) 34px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .dashboard-grid,
  .split,
  .nation-layout,
  .naval-grid,
  .equipment-grid,
  .audit-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-grid,
  .editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .source-pill {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .dashboard-grid,
  .detail-grid,
  .control-grid,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr auto;
  }

  .bar-track {
    grid-column: 1 / -1;
  }

  .ship-category {
    grid-template-columns: 1fr;
  }
}
