.status-table-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 178px);
}

.status-table-panel .panel-head {
  flex: 0 0 auto;
}

.status-table-wrap {
  max-height: clamp(360px, calc(100vh - 310px), 680px);
  overscroll-behavior: contain;
  border-bottom: 1px solid var(--line);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--table-head-text);
  background: var(--table-head-bg);
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
  letter-spacing: 0;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--line-strong);
}

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

th:first-child {
  z-index: 3;
  background: var(--table-head-bg);
}

.status-table-wrap th:first-child,
.status-table-wrap td:first-child {
  box-shadow:
    1px 0 0 var(--line-strong),
    14px 0 18px -18px rgba(0, 0, 0, 0.5);
}

.status-table-wrap tbody tr td:first-child {
  background: var(--table-row-bg);
}

.status-table-wrap tbody tr:nth-child(even) td:first-child {
  background: var(--table-row-alt);
}

.status-table-wrap tbody tr:hover td:first-child {
  background: var(--table-row-hover);
}

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

tbody tr {
  background: var(--table-row-bg);
}

tbody tr:nth-child(even) {
  background: var(--table-row-alt);
}

tbody tr:hover {
  background: var(--table-row-hover);
}

tbody td {
  transition: background-color 140ms ease;
}

.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: var(--status-bg);
  font-size: 12px;
  font-weight: 900;
}

.status.positive {
  color: var(--positive-ink);
  background: var(--positive-bg);
  border-color: var(--positive-border);
}

.status.negative {
  color: var(--negative-ink);
  background: var(--negative-bg);
  border-color: var(--negative-border);
}

.status.warning {
  color: var(--warning-ink);
  background: var(--warning-bg);
  border-color: var(--warning-border);
}

.nation-layout {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.nation-roster {
  position: sticky;
  top: 154px;
}

.nation-list {
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding: 8px;
}

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

.nation-roster-head h2 {
  margin-bottom: 3px;
}

.nation-roster-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

.nation-button:hover,
.nation-button:focus-visible {
  border-color: var(--blue);
  outline: 0;
}

.nation-button-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

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

.nation-button small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nation-button.is-selected {
  border-color: var(--blue);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--blue) 16%, transparent), transparent 70%),
    var(--table-row-bg);
  box-shadow: 0 0 0 3px var(--selected-ring);
}

.nation-dossier {
  --nation-color: var(--blue);
}

.nation-dossier-hero {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--nation-color) 18%, transparent), transparent 48%),
    linear-gradient(180deg, var(--panel), var(--subtle-bg));
}

.nation-dossier-title {
  display: flex;
  gap: 12px;
  min-width: 0;
  align-items: flex-start;
}

.nation-dossier-title h2 {
  margin: 0 0 6px;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.nation-dossier-title p {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.nation-dossier-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 320px;
}

.nation-stat-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.dossier-metric {
  min-width: 0;
  padding: 13px 14px;
}

.dossier-metric + .dossier-metric {
  border-left: 1px solid var(--line);
}

.dossier-metric span,
.dossier-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.dossier-metric strong {
  display: block;
  margin: 5px 0 3px;
  font-size: 22px;
  line-height: 1;
}

.dossier-metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.dossier-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--subtle-bg);
  overflow: hidden;
}

.dossier-section h3 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.dossier-rows {
  display: grid;
}

.dossier-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
}

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

.dossier-row strong {
  color: var(--ink);
  text-align: right;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.dossier-row strong.positive {
  color: var(--positive-ink);
}

.dossier-row strong.negative {
  color: var(--negative-ink);
}

.dossier-section-wide {
  grid-column: span 2;
  padding-bottom: 12px;
}

.dossier-section-wide .coverage {
  padding: 12px;
}

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

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

.coverage span.has-data {
  color: var(--coverage-data-ink);
  background: var(--coverage-data-bg);
}

.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 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  gap: 12px;
  align-items: start;
  padding: 12px;
}

.editor-sections {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.editor-rail {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.editor-rail {
  position: sticky;
  top: 178px;
}

.editor-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(96px, 1fr));
  gap: 10px;
  align-items: stretch;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, var(--hero-wash), transparent 42%),
    var(--subtle-bg);
}

.editor-summary .overview-fact {
  padding: 3px 0;
  border-top: 0;
  border-left: 0;
}

.editor-summary .overview-fact + .overview-fact {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.editor-summary .overview-fact strong {
  font-size: 15px;
}

.app-shell > .panel + .panel {
  margin-top: 12px;
}

.roster-manager {
  box-shadow: var(--metric-shadow);
}

.roster-tools-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(250px, 0.34fr) minmax(250px, 0.34fr);
  gap: 12px;
  padding: 12px;
  background:
    linear-gradient(135deg, var(--hero-wash), transparent 46%),
    var(--subtle-bg);
}

.roster-create-card,
.roster-archive-card,
.roster-restore-card {
  display: grid;
  gap: 10px;
  align-items: end;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.roster-create-card {
  grid-template-columns: minmax(150px, 1fr) 66px minmax(160px, 0.85fr) auto;
  align-items: end;
}

.roster-archive-card,
.roster-restore-card {
  grid-template-columns: minmax(0, 1fr);
}

.roster-archive-card .command,
.roster-restore-card .command {
  width: 100%;
}

.roster-create-command {
  align-self: end;
  min-width: 124px;
}

.editor-panel-head {
  align-items: center;
}

.editor-head-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  min-width: min(100%, 460px);
}

.editor-nation-picker {
  min-width: min(380px, 100%);
  box-shadow: none;
}

.color-field {
  justify-items: start;
}

.control-field input[type="color"] {
  width: 46px;
  height: 40px;
  min-height: 40px;
  padding: 3px;
  border-color: var(--line-strong);
  cursor: pointer;
}

.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,
.control-field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
  padding: 8px 10px;
  outline: 0;
  font: inherit;
}

.control-field input:focus,
.control-field select:focus,
.control-field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.control-field textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.45;
}

.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: var(--button-bg);
  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: var(--primary-button-ink);
  background: var(--blue);
  border-color: var(--blue);
}

.command.accent {
  color: var(--on-gold);
  background: var(--gold);
  border-color: var(--gold);
}

.command.danger {
  color: var(--negative-ink);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.command.positive {
  color: var(--positive-ink);
  border-color: var(--positive-border);
  background: var(--positive-bg);
}

.command:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.command.is-active {
  color: var(--paper);
  background: var(--button-active-bg);
  border-color: var(--button-active-bg);
}

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

.change-history-panel {
  margin-top: 14px;
}

.snapshot-recovery-panel {
  margin-top: 0;
}

.snapshot-recovery-controls {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--subtle-bg);
}

.snapshot-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.snapshot-summary-strip .overview-fact {
  padding: 12px 16px;
}

.snapshot-summary-strip .overview-fact + .overview-fact {
  border-left: 1px solid var(--line);
}

.snapshot-table {
  min-width: 960px;
}

.change-impact,
.history-impact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.change-impact .status,
.history-impact .status {
  min-height: 26px;
  border-radius: 7px;
  font-size: 11px;
}

.history-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.history-list-head,
.history-list-row {
  display: grid;
  grid-template-columns: 132px minmax(180px, 0.9fr) 130px 190px minmax(220px, 1.1fr);
  gap: 12px;
  align-items: center;
}

.history-list-head {
  padding: 10px 16px;
  color: var(--table-head-text);
  background: var(--table-head-bg);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.history-list-row {
  min-height: 44px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: var(--table-row-bg);
  font-size: 14px;
}

.history-list-row:nth-child(odd) {
  background: var(--table-row-alt);
}

.history-time,
.history-edit {
  color: var(--muted);
  font-weight: 800;
}

.history-time,
.history-value {
  white-space: nowrap;
}

.history-value {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.history-impact.is-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-list-row .nation-cell {
  min-width: 0;
}

.editor-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 16px;
  align-content: start;
  padding: 12px 14px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--subtle-bg);
}

.editor-section-national,
.editor-section-military {
  grid-column: span 7;
}

.editor-section-trade,
.editor-section-intelligence {
  grid-column: span 5;
}

.editor-section-population,
.editor-section-industrial {
  grid-column: span 6;
}

.editor-section-civic {
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(230px, 1fr));
}

.editor-section h3 {
  grid-column: 1 / -1;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 16px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.editor-section .control-field {
  min-height: 46px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.editor-section .control-field:focus-within {
  border-color: var(--blue);
  box-shadow: none;
}

.editor-section .control-field input,
.editor-section .control-field select {
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  padding: 2px 4px;
  font-weight: 850;
}

.editor-section .control-field:hover input,
.editor-section .control-field:hover select {
  border-color: var(--line);
  background: var(--input-bg);
}

.editor-section .control-field input:focus,
.editor-section .control-field select:focus {
  border-color: var(--blue);
  background: var(--input-bg);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.editor-section-civic .control-field {
  min-width: 0;
}

.editor-rail-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--subtle-bg);
}

.editor-rail-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.editor-rail-head h3 {
  margin: 4px 0 0;
  font-size: 22px;
}

.editor-rail-head.compact h3 {
  margin: 0;
  font-size: 18px;
}

.rail-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.rail-detail-grid .detail-item {
  min-height: 66px;
  padding: 9px;
}

.rail-detail-grid .detail-item strong {
  font-size: 18px;
}

.rail-change-list {
  display: grid;
  gap: 8px;
}

.rail-change-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.rail-change-row strong {
  font-size: 13px;
}

.rail-change-row .change-impact {
  min-width: 0;
}

.rail-change-row .change-impact .status {
  max-width: 100%;
  justify-content: flex-start;
  white-space: normal;
  text-align: left;
  line-height: 1.25;
}

.derived-preview {
  background:
    linear-gradient(135deg, var(--hero-wash), transparent 48%),
    var(--subtle-bg);
}

.derived-preview .detail-item {
  background: var(--panel);
}
