:root {
  color-scheme: light;
  --bg: #eef1f3;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #64717d;
  --line: #d9e0e5;
  --teal: #117a7a;
  --teal-dark: #0c5d5e;
  --amber: #c77c1a;
  --red: #b94d42;
  --blue: #2d6f9f;
  --shadow: 0 12px 36px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
a.ghost-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover,
a.ghost-btn:hover {
  border-color: #aebbc4;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 122, 122, 0.14);
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  min-height: 112px;
  margin-bottom: 18px;
  padding: 8px 14px 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-logo {
  width: 220px;
  height: 88px;
  flex: 0 0 220px;
  display: block;
  object-fit: contain;
  object-position: left center;
}

.topbar h1,
.summary-head h2,
.chart-panel h3,
.table-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.top-actions {
  flex: 0 0 auto;
  min-width: 42px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 7px;
}

.status-light {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: block;
  background: #d6a222;
  box-shadow: 0 0 0 4px rgba(214, 162, 34, 0.16), 0 0 12px rgba(214, 162, 34, 0.42);
}

.status-light.ok {
  background: #1ca765;
  box-shadow: 0 0 0 4px rgba(28, 167, 101, 0.16), 0 0 12px rgba(28, 167, 101, 0.45);
}

.status-light.warning {
  background: #d6a222;
  box-shadow: 0 0 0 4px rgba(214, 162, 34, 0.16), 0 0 12px rgba(214, 162, 34, 0.42);
}

.status-light.bad {
  background: #c74f45;
  box-shadow: 0 0 0 4px rgba(199, 79, 69, 0.16), 0 0 12px rgba(199, 79, 69, 0.42);
}

.icon-btn {
  width: 42px;
  min-width: 42px;
  padding: 0;
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
  font-size: 22px;
  line-height: 1;
}

.icon-btn:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.icon-btn.busy {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.mode-tabs {
  display: inline-flex;
  gap: 6px;
  margin: 0 0 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.mode-tabs button {
  min-width: 112px;
  border-color: transparent;
  background: transparent;
}

.mode-tabs button.active {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.ships-view {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid rgba(217, 224, 229, 0.9);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 18px;
  padding: 16px;
}

.control-group + .control-group {
  margin-top: 18px;
}

.label,
.section-title {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.region-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.region-tabs button {
  padding: 0 8px;
}

.region-tabs button.active {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.primary-btn {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.primary-btn:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.ghost-btn {
  background: #f8fafb;
}

.result-list,
.tracked-list {
  display: grid;
  gap: 8px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
}

.result-item,
.tracked-item {
  width: 100%;
  min-height: 50px;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  text-align: left;
  background: #f8fafb;
}

.result-item strong,
.tracked-item strong {
  display: block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-item span,
.tracked-item span {
  color: var(--muted);
  font-size: 12px;
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.message {
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff6df;
  color: #704800;
  border: 1px solid #efd9a7;
}

.message.error {
  background: #f8e2df;
  color: #842c25;
  border-color: #ecc1bc;
}

.hidden {
  display: none !important;
}

.summary-head {
  min-height: 86px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.summary-head h2 {
  font-size: 23px;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.muted {
  margin: 8px 0 0;
  color: var(--muted);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
}

.header-metrics {
  min-width: 0;
  flex: 1 1 auto;
  grid-template-columns:
    minmax(142px, 1.12fr)
    repeat(2, minmax(118px, 1fr))
    minmax(86px, 0.72fr)
    minmax(104px, 0.82fr);
  gap: 8px;
}

.metric {
  min-height: 114px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.header-metrics .metric {
  min-height: 78px;
  padding: 10px 12px;
  box-shadow: none;
  background: #fbfcfc;
}

.metric-clickable {
  padding: 0;
  overflow: hidden;
}

.metric-link {
  width: 100%;
  min-height: 114px;
  border: 0;
  border-radius: 8px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  justify-items: start;
  text-align: left;
  background: transparent;
}

.header-metrics .metric-link {
  min-height: 78px;
  padding: 10px 12px;
}

.metric-link:hover,
.metric-link:focus {
  border-color: transparent;
  background: #f8fafb;
}

.metric-link:disabled {
  opacity: 1;
  cursor: default;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  margin-top: 12px;
  font-size: 28px;
  line-height: 1.05;
}

.header-metrics .metric strong {
  margin-top: 6px;
  font-size: 25px;
}

.metric small {
  min-height: 18px;
  color: var(--teal-dark);
}

.header-metrics .metric-label,
.header-metrics .metric small {
  font-size: 12px;
}

.chart-panel,
.table-panel {
  padding: 18px;
}

.section-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.table-toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafb;
}

.table-summary-line {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.table-summary-title {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.table-summary-line .eyebrow {
  margin: 0;
  flex: 0 0 auto;
  color: var(--muted);
}

.table-summary-line h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.legend span {
  display: inline-flex;
  align-items: center;
  min-height: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.table-controls {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.page-size-switch {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.page-size-btn,
.pager-btn {
  min-height: 30px;
  border-radius: 6px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  background: transparent;
}

.page-size-btn {
  border-color: transparent;
}

.page-size-btn.active {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pager-btn {
  width: 30px;
  padding: 0;
  font-size: 18px;
}

.line {
  width: 20px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.line.battles {
  background: var(--blue);
}

.line.winrate {
  background: var(--teal);
}

.line.damage {
  background: var(--amber);
}

canvas {
  width: 100%;
  height: 320px;
  display: block;
}

.table-scroll {
  overflow-x: auto;
}

.ship-filters {
  padding: 16px;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(220px, 1.6fr) repeat(4, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}

.compare-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  width: min(680px, calc(100vw - 36px));
  padding: 14px;
  box-shadow: 0 18px 60px rgba(23, 33, 43, 0.18);
}

.compare-head,
.compare-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compare-head h3 {
  margin: 2px 0 0;
  font-size: 20px;
}

.compare-actions {
  justify-content: flex-end;
}

.compare-frame-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compare-mode {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  display: inline-flex;
  gap: 4px;
  background: #f8fafb;
}

.compare-mode-btn {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.compare-mode-btn.active {
  color: #fff;
  background: var(--teal);
}

.compare-chips {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 94px;
  overflow: auto;
}

.compare-chip {
  min-height: 38px;
  border-color: var(--line);
  border-radius: 999px;
  padding: 4px 9px 4px 5px;
  gap: 7px;
  background: #fff;
}

.compare-chip img {
  width: 46px;
  height: 28px;
  object-fit: contain;
  border-radius: 999px;
  background: #eef1f3;
}

.compare-chip span {
  font-weight: 800;
}

.compare-chip small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.compare-chip b {
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}

.compare-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compare-table {
  min-width: 760px;
}

.compare-table th,
.compare-table td {
  min-width: 190px;
  vertical-align: top;
}

.compare-table th:first-child,
.compare-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 180px;
  background: #fff;
}

.compare-table thead th {
  background: #f8fafb;
}

.compare-table thead th:first-child {
  z-index: 2;
  background: #f8fafb;
}

.compare-group-row th {
  position: static;
  color: var(--teal-dark);
  background: #eef6f5;
  font-size: 12px;
}

.compare-ship-head {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-transform: none;
}

.compare-ship-head img,
.compare-ship-head span {
  width: 54px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
  background: #eef1f3;
}

.compare-ship-head strong,
.compare-ship-head small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-ship-head strong {
  color: var(--ink);
  font-size: 13px;
  text-transform: none;
}

.compare-ship-head small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  text-transform: none;
}

.compare-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: #fff;
}

.compare-dialog {
  width: min(2300px, calc(100vw - 8px));
  max-height: calc(100vh - 8px);
  padding: 10px;
  overflow: auto;
  box-shadow: 0 24px 80px rgba(23, 33, 43, 0.26);
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 34px 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 122, 122, 0.14);
}

.ship-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 230px;
}

.ship-thumb {
  width: 56px;
  height: 38px;
  flex: 0 0 56px;
  object-fit: contain;
  border-radius: 6px;
  background: #eef1f3;
}

.ship-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.badge {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  background: #e8f0ef;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
}

.badge.new {
  background: #fff0d4;
  color: #8a560d;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.ship-row {
  cursor: pointer;
}

.ship-row:hover,
.ship-row:focus {
  background: #f4f8f8;
  outline: none;
}

.ship-row.selected {
  background: #e8f3f2;
}

.compare-add-cell {
  width: 42px;
  padding-right: 0;
}

.compare-add-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--teal-dark);
  background: #f7fbfb;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
}

.compare-add-btn.active {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
  font-size: 14px;
}

.detail-open {
  overflow: hidden;
}

.ship-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 4px;
  display: grid;
  place-items: center;
  background: rgba(23, 33, 43, 0.48);
}

.ship-detail-overlay.hidden {
  display: none;
}

.ship-detail {
  width: min(2300px, calc(100vw - 8px));
  max-height: calc(100vh - 8px);
  padding: 10px;
  overflow: auto;
  box-shadow: 0 24px 80px rgba(23, 33, 43, 0.26);
}

.change-dialog {
  width: min(1120px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  padding: 18px;
  overflow: auto;
  box-shadow: 0 24px 80px rgba(23, 33, 43, 0.26);
}

.ship-detail-head {
  position: sticky;
  top: -10px;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: -10px -10px 12px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
}

.ship-detail-title {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.ship-detail-title h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.ship-title-id,
.ship-title-status {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
}

.ship-title-id {
  color: var(--muted);
  background: #eef1f3;
}

.ship-title-status {
  color: var(--teal-dark);
  background: #e8f0ef;
}

.ship-detail-image {
  width: 112px;
  height: 76px;
  flex: 0 0 112px;
  object-fit: contain;
  border-radius: 8px;
  background: #eef1f3;
}

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

.change-history {
  max-height: 640px;
  padding-right: 2px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.change-date {
  width: 100%;
  min-height: 66px;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #f8fafb;
}

.change-date.active {
  border-color: var(--teal);
  background: #e8f3f2;
}

.change-date.has-change b {
  color: #fff;
  background: var(--teal);
}

.change-date strong,
.change-date small {
  display: block;
  min-width: 0;
}

.change-date small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.change-date b {
  min-width: 34px;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  background: #e8edf0;
  text-align: center;
  font-size: 12px;
}

.change-items {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

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

.change-items-head h4 {
  margin: 0;
  font-size: 18px;
}

.change-items-head span {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--teal-dark);
  background: #e8f0ef;
  font-size: 12px;
  font-weight: 700;
}

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

.change-ship {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
}

.change-ship-image {
  width: 64px;
  height: 42px;
  flex: 0 0 64px;
  object-fit: contain;
  border-radius: 6px;
  background: #eef1f3;
}

.change-ship-main {
  min-width: 0;
  flex: 1 1 auto;
}

.change-ship-main strong,
.change-ship-main small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.change-ship-main small,
.change-ship-id,
.change-empty {
  color: var(--muted);
  font-size: 12px;
}

.change-ship-id {
  flex: 0 0 auto;
  font-weight: 700;
}

.change-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.detail-loading {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #f8fafb;
}

.detail-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-metrics-column {
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

.detail-metric {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  align-content: space-between;
  background: #f8fafb;
}

.detail-metric span,
.detail-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-metric strong {
  margin-top: 10px;
  font-size: 22px;
  line-height: 1.1;
}

.detail-metrics-column .detail-metric {
  min-height: 62px;
}

.score-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 14px;
  background: #f8fafb;
}

.score-panel h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.score-panel-column {
  margin-bottom: 0;
}

.score-panel-column .score-grid {
  grid-template-columns: 1fr;
}

.score-card {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  align-content: space-between;
  background: #fff;
}

.score-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-card strong {
  margin-top: 8px;
  color: var(--teal-dark);
  font-size: 28px;
  line-height: 1;
}

.score-panel-column .score-card {
  min-height: 62px;
}

.score-panel-column .score-card strong {
  font-size: 24px;
}

.ship-description {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 14px;
  background: #fbfcfc;
}

.ship-description h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.ship-description-text {
  color: #263541;
  font-size: 14px;
  line-height: 1.55;
}

.ship-description-text p {
  margin: 0 0 10px;
}

.ship-description-text p:last-child,
.ship-description-text ul:last-child,
.ship-description-text ol:last-child {
  margin-bottom: 0;
}

.ship-description-text ul,
.ship-description-text ol {
  margin: 0 0 10px;
  padding-left: 22px;
}

.detail-grid {
  --detail-card-width: 260px;
  --wide-detail-card-width: 310px;
  --weapon-card-width: 380px;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
}

.detail-block {
  flex: 0 0 var(--detail-card-width);
  min-width: 0;
  scroll-snap-align: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.wide-detail-block {
  flex-basis: var(--wide-detail-card-width);
}

.detail-block h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.detail-rows {
  display: grid;
  gap: 6px;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(82px, 1fr);
  gap: 10px;
  align-items: baseline;
  min-width: 0;
}

.detail-row span {
  min-width: 0;
  overflow-wrap: break-word;
  font-size: 12px;
  line-height: 1.25;
}

.detail-row strong {
  min-width: 0;
  overflow-wrap: break-word;
  text-align: right;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 700;
}

.detail-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.weapon-detail-block {
  flex-basis: var(--weapon-card-width);
  align-content: start;
}

.weapon-slot-list {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 8px;
  display: grid;
  gap: 7px;
}

.weapon-slot {
  border: 0;
  border-radius: 0;
  padding: 0;
  display: grid;
  gap: 3px;
  background: transparent;
}

.weapon-slot strong,
.weapon-slot span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.weapon-slot strong {
  font-size: 13px;
}

.weapon-slot span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.modules-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
  padding: 14px;
  background: #fbfcfc;
}

.modules-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modules-panel-head h4 {
  margin: 0;
  font-size: 15px;
}

.modules-panel-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.module-tree-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  grid-template-columns: none;
  gap: 12px;
  align-items: start;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 8px;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.module-column {
  min-width: 220px;
}

.module-column-head {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #eef6f5;
}

.module-column-head h5 {
  margin: 0;
  color: var(--teal-dark);
  font-size: 13px;
}

.module-column-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.module-column-list {
  display: grid;
  gap: 36px;
  overflow: visible;
}

.module-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 46px 12px 12px;
  background: #fff;
  cursor: pointer;
}

.module-card.selected {
  border-color: rgba(17, 122, 122, 0.58);
  box-shadow: inset 0 0 0 1px rgba(17, 122, 122, 0.22);
}

.module-card.selected .module-name {
  color: var(--teal-dark);
}

.module-selected-check {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--teal);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.module-info-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--teal-dark);
  background: #f7fbfb;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.module-card.selected .module-info-btn {
  top: 38px;
}

.module-info-btn:hover,
.module-info-btn:focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 3px rgba(17, 122, 122, 0.12);
}

.module-card:focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 3px rgba(17, 122, 122, 0.14);
}

.module-card.linked-next::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -30px;
  width: 2px;
  height: 26px;
  background: var(--line);
  transform: translateX(-50%);
}

.module-card.linked-next::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -36px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}

.module-card-top {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.module-visual {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
}

.module-image {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 8px;
  background: #eef1f3;
}

.module-card-main {
  min-width: 0;
  flex: 1 1 auto;
  padding-top: 4px;
}

.module-name {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.module-default-badge {
  max-width: 72px;
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--teal-dark);
  background: #e8f0ef;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.module-info-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 33, 43, 0.22);
}

.module-info-overlay.hidden {
  display: none;
}

.module-info-dialog {
  position: relative;
  width: min(520px, calc(100vw - 48px));
  max-height: min(560px, calc(100vh - 96px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.99);
  box-shadow: 0 24px 70px rgba(23, 33, 43, 0.24);
  font-size: 12px;
}

.module-info-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 0;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.module-info-close:hover,
.module-info-close:focus {
  color: var(--ink);
  outline: none;
  box-shadow: none;
}

.module-info-content {
  display: grid;
  gap: 10px;
  padding-right: 26px;
}

.module-info-content strong {
  color: var(--ink);
  font-size: 13px;
}

.module-info-content dl {
  margin: 0;
  display: grid;
  gap: 7px;
}

.module-info-content dl div {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(100px, auto);
  gap: 10px;
  align-items: baseline;
}

.module-info-content dt,
.module-info-content dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.module-info-content dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.module-info-content dd {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.ship-detail-overlay.module-info-open .ship-detail {
  overflow: hidden;
}

.module-card p {
  margin: 8px 0 0;
  color: #263541;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.next-ships {
  margin-top: 10px;
  display: grid;
  gap: 7px;
}

.next-ships > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.next-ship-btn {
  width: 100%;
  min-height: 48px;
  padding: 7px;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
  background: #f8fafb;
}

.next-ship-btn img {
  width: 44px;
  height: 30px;
  flex: 0 0 44px;
  object-fit: contain;
  border-radius: 6px;
  background: #eef1f3;
}

.next-ship-btn span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.next-ship-btn strong,
.next-ship-btn small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.next-ship-btn small {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .topbar {
    flex-wrap: wrap;
  }

  .header-metrics {
    order: 3;
    flex-basis: 100%;
    grid-template-columns: repeat(5, minmax(112px, 1fr));
  }

  .detail-metrics {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .detail-overview {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    --detail-card-width: min(300px, 54vw);
    --wide-detail-card-width: min(330px, 62vw);
    --weapon-card-width: min(380px, 72vw);
  }

  .change-layout {
    grid-template-columns: 1fr;
  }

  .change-history {
    max-height: 260px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .summary-head,
  .section-row,
  .compare-head,
  .compare-frame-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .compare-panel {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
  }

  .compare-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions > * {
    flex: 1 1 auto;
  }

  .brand-logo {
    width: min(220px, 100%);
    height: 88px;
    flex: 0 0 auto;
  }

  .top-actions .icon-btn {
    flex: 0 0 42px;
  }

  .region-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

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

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

  .header-metrics {
    order: initial;
    flex-basis: auto;
    grid-template-columns: 1fr;
  }

  .ship-detail-head,
  .ship-detail-title {
    align-items: stretch;
    flex-direction: column;
  }

  .ship-detail-overlay {
    padding: 4px;
    place-items: stretch;
  }

  .ship-detail {
    width: 100%;
    max-height: calc(100vh - 8px);
  }

  .change-dialog {
    width: 100%;
    max-height: calc(100vh - 20px);
  }

  .ship-detail-image {
    width: 100%;
    max-width: 220px;
  }

  .detail-metrics,
  .score-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    --detail-card-width: 86vw;
    --wide-detail-card-width: 86vw;
    --weapon-card-width: 86vw;
  }

  .detail-overview {
    grid-template-columns: 1fr;
  }

  .module-tree-grid {
    grid-auto-columns: minmax(240px, 82vw);
  }

  .module-column {
    min-width: 240px;
  }

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

  .change-items-head {
    flex-direction: column;
  }

  .change-ship {
    align-items: flex-start;
  }
}
