:root {
  color-scheme: dark;
  --panel: rgba(0, 2, 7, 0.72);
  --panel-strong: rgba(0, 2, 7, 0.86);
  --line: rgba(255, 255, 255, 0.14);
  --text: #edf3ff;
  --muted: #a9b5c7;
  --gold: #f28a3a;
  --teal: #f28a3a;
  --blue: #8fb7df;
  --accent: #f28a3a;
  --accent-soft: rgba(242, 138, 58, 0.16);
  --accent-line: rgba(242, 138, 58, 0.46);
  --steel: #9fb8ce;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(rgba(0, 0, 0, 0.74), rgba(0, 0, 0, 0.74)),
    url("assets/star.png?v=1") center / cover fixed no-repeat,
    #000;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #000;
  cursor: grab;
}

canvas:active { cursor: grabbing; }

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.topbar,
.auth-window,
.drawer-panel,
.toast,
.side-panel,
.tooltip,
.register-panel,
.tutorial-panel,
.chat-panel,
.fleet-command-panel,
.build-modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
}

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

h1 {
  font-size: 18px;
  line-height: 1.15;
  font-weight: 750;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.metric {
  border-top: 1px solid var(--line);
  padding-top: 7px;
  min-width: 0;
}

.metric strong {
  display: block;
  font-size: 15px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
}

input,
button,
select {
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

select option {
  background: #151b27;
  color: #edf3ff;
}

input {
  width: 100%;
  padding: 0 10px;
  outline: none;
}

button,
select {
  padding: 0 11px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
select:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.13);
}

button:disabled {
  cursor: not-allowed;
  color: rgba(237, 243, 255, 0.42);
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.topbar {
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  z-index: 10000;
  min-height: 56px;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  background: var(--panel);
  border-color: rgba(170, 198, 225, 0.16);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
}

.stat-pill span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.stat-pill {
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 11px;
}

.top-stats {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.corner-brand {
  position: absolute;
  right: 16px;
  bottom: 14px;
  z-index: 0;
  color: rgba(220, 232, 241, 0.32);
  font-size: clamp(21px, 2.1vw, 34px);
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.18), 0 3px 12px rgba(0, 0, 0, 0.55);
}

.corner-brand span {
  color: rgba(242, 108, 40, 0.48);
  text-shadow: 0 0 9px rgba(255, 91, 20, 0.2);
}

.top-research {
  width: 260px;
  display: none;
  gap: 5px;
  padding: 6px 9px;
  border: 1px solid rgba(242, 138, 58, 0.32);
  border-radius: 7px;
  background: rgba(242, 138, 58, 0.08);
  box-shadow: inset 0 0 20px rgba(242, 138, 58, 0.04);
}

.top-research.active {
  display: grid;
}

.top-research-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.top-research-row strong {
  color: #fff4e9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#topFactory {
  border-color: rgba(108, 190, 255, 0.34);
  background: rgba(72, 158, 225, 0.1);
  box-shadow: inset 0 0 20px rgba(72, 158, 225, 0.05);
}

#topFactory .top-research-row strong {
  color: #d8efff;
}

#creditsPanelButton {
  cursor: pointer;
}

#creditsPanelButton:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.stat-pill strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  margin-top: 2px;
}

.top-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  z-index: 20;
}

.galaxy-search {
  position: relative;
  width: min(260px, 28vw);
  min-width: 170px;
}

.galaxy-search[hidden] {
  display: none;
}

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

.galaxy-search-form input {
  min-width: 0;
  border-color: rgba(88, 181, 255, 0.3);
  background: rgba(5, 12, 22, 0.72);
}

.galaxy-search-results {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  width: min(340px, calc(100vw - 24px));
  max-height: min(390px, calc(100vh - 100px));
  display: none;
  gap: 5px;
  overflow: visible;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(16px);
  z-index: 10002;
}

.galaxy-search-results.open {
  display: grid;
}

.galaxy-search-result {
  height: auto;
  min-height: 46px;
  padding: 7px 9px;
  display: grid;
  gap: 2px;
  text-align: left;
  white-space: normal;
}

.galaxy-search-result strong,
.galaxy-search-result span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.galaxy-search-result span,
.galaxy-search-empty {
  color: var(--muted);
  font-size: 11px;
}

.galaxy-search-empty {
  padding: 9px;
  line-height: 1.4;
}

@media (max-width: 900px) {
  .galaxy-search { width: 190px; }
  .galaxy-search-form button { padding: 0 8px; }
}

.colony-menu,
.notification-menu,
.account-menu {
  position: relative;
}

.territory-menu {
  position: relative;
  pointer-events: auto;
}

.territory-menu.hidden {
  display: none;
}

.region-map-button.hidden {
  display: none;
}

.colony-dropdown,
.notification-dropdown,
.account-dropdown,
.territory-dropdown {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  width: 280px;
  display: none;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
  z-index: 10001;
}

.notification-dropdown {
  width: min(360px, calc(100vw - 28px));
  max-height: min(520px, calc(100vh - 100px));
  overflow-y: auto;
}

.account-dropdown {
  width: 190px;
}

.settings-danger-zone {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid rgba(255, 92, 92, 0.42);
  border-radius: 8px;
  background: rgba(82, 12, 12, 0.22);
}

.settings-danger-zone strong { color: #ff9a9a; }
.settings-danger-zone p { margin: 5px 0 10px; }
.danger-button { border-color: rgba(255, 92, 92, 0.55) !important; color: #ffaaaa !important; }
.danger-button:hover { background: rgba(130, 20, 20, 0.38) !important; }

.territory-dropdown {
  width: min(350px, calc(100vw - 28px));
  max-height: min(520px, calc(100vh - 118px));
  overflow-y: auto;
  gap: 8px;
  padding: 10px;
}

.territory-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.territory-button::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(237, 243, 255, 0.42);
  background: rgba(237, 243, 255, 0.08);
}

.territory-button.active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: #ffd0a6;
}

.territory-button.active::before {
  border-color: #ffbd7c;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(242, 138, 58, 0.68);
}

.territory-filter-head {
  display: grid;
  gap: 9px;
  padding: 2px 2px 10px;
  border-bottom: 1px solid var(--line);
}

.territory-filter-title {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.territory-filter-title > div {
  display: grid;
  gap: 3px;
}

.territory-filter-count {
  flex: 0 0 auto;
  border: 1px solid rgba(88, 181, 255, 0.28);
  border-radius: 999px;
  padding: 4px 7px;
  background: rgba(88, 181, 255, 0.08);
  color: #9ed8ff;
  font-size: 10px;
  font-weight: 750;
}

.territory-filter-actions {
  display: flex;
  gap: 6px;
}

.territory-dropdown .territory-filter-actions button {
  width: auto;
  min-height: 28px;
  padding: 4px 9px;
  font-size: 11px;
  text-align: center;
}

.territory-owner-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.territory-owner-row:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.055);
}

.territory-owner-row.selected {
  border-color: rgba(88, 181, 255, 0.42);
  background: rgba(88, 181, 255, 0.09);
}

.territory-owner-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.territory-owner-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.territory-owner-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  box-shadow: 0 0 9px currentColor;
}

.colony-menu.open .colony-dropdown,
.notification-menu.open .notification-dropdown,
.account-menu.open .account-dropdown,
.territory-menu.open .territory-dropdown {
  display: grid;
}

.colony-dropdown button,
.notification-dropdown button,
.account-dropdown button,
.territory-dropdown button {
  width: 100%;
  height: auto;
  min-height: 40px;
  padding: 7px 9px;
  text-align: left;
  white-space: normal;
}

.colony-dropdown strong,
.colony-dropdown span,
.notification-row strong,
.notification-row span,
.territory-dropdown strong,
.territory-dropdown span {
  display: block;
}

.colony-dropdown span,
.notification-row span,
.territory-dropdown span {
  color: var(--muted);
  font-size: 11px;
}

.storage-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
}

.inventory-item {
  position: relative;
  min-height: 96px;
  display: grid;
  grid-template-rows: 50px auto;
  gap: 4px;
  align-items: start;
  justify-items: center;
  padding: 7px 6px 6px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(27, 35, 48, 0.92), rgba(10, 14, 22, 0.88));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.inventory-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  background: radial-gradient(circle at 50% 35%, rgba(242, 138, 58, 0.18), rgba(5, 8, 14, 0.72));
  overflow: hidden;
}

.inventory-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.inventory-icon.blueprint-orb {
  position: relative;
  overflow: visible;
  border-color: rgba(108, 190, 255, 0.28);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 26%, #d8f3ff, #58b8ff 48%, #102338 78%);
  box-shadow: 0 0 18px rgba(88, 184, 255, 0.26);
}

.inventory-icon.blueprint-orb::before,
.inventory-icon.blueprint-orb::after {
  content: "";
  position: absolute;
  inset: -10px;
  border: 1px solid rgba(108, 190, 255, 0.24);
  border-radius: 999px;
  transform: rotate(24deg) scaleY(0.36);
}

.inventory-icon.blueprint-orb::after {
  border-color: rgba(242, 138, 58, 0.2);
  transform: rotate(-28deg) scaleY(0.34);
}

.inventory-icon.blueprint-orb .inventory-fallback {
  position: relative;
  z-index: 1;
  color: #07131e;
  font-size: 14px;
  text-shadow: none;
}

.inventory-icon.blueprint-art {
  border-color: rgba(108, 190, 255, 0.28);
  background: rgba(5, 8, 14, 0.86);
  box-shadow: 0 0 16px rgba(88, 184, 255, 0.14);
}

.inventory-icon.blueprint-art img {
  object-fit: cover;
}

.inventory-fallback {
  color: #ffd0a6;
  font-size: 20px;
  font-weight: 850;
  letter-spacing: 0.02em;
  text-shadow: 0 0 14px rgba(242, 138, 58, 0.42);
}

.inventory-quantity {
  position: absolute;
  right: 7px;
  top: 44px;
  min-width: 26px;
  padding: 2px 5px;
  border: 1px solid rgba(255, 218, 190, 0.28);
  border-radius: 5px;
  background: rgba(2, 3, 5, 0.82);
  color: #edf3ff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.inventory-name {
  width: 100%;
  margin-top: 6px;
  color: #dfe8f8;
  font-size: 11px;
  line-height: 1.18;
  text-align: center;
  overflow-wrap: anywhere;
}

.storage-inventory-layout {
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr);
  gap: 12px;
  grid-column: 1 / -1;
  min-height: 0;
}

.storage-category-sidebar {
  display: grid;
  align-content: start;
  gap: 6px;
  padding-right: 10px;
  border-right: 1px solid rgba(237, 243, 255, 0.1);
}

.storage-category-button {
  width: 100%;
  height: auto;
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  text-align: left;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
}

.storage-category-button.active {
  border-color: var(--accent-line);
  background: rgba(242, 138, 58, 0.14);
  color: #fff4e9;
}

.storage-category-count {
  color: #ffd0a6;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.storage-inventory-content {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.storage-sidebar-actions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(237, 243, 255, 0.1);
}

.storage-trash-zone {
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 3px;
  border: 1px dashed rgba(255, 112, 96, 0.46);
  border-radius: 8px;
  background: repeating-linear-gradient(135deg, rgba(120, 22, 20, 0.18) 0 8px, rgba(8, 10, 16, 0.34) 8px 16px);
  color: #ffd5cf;
  font-size: 12px;
  text-align: center;
}

.storage-trash-zone.drag-over {
  border-color: rgba(255, 148, 132, 0.92);
  background: repeating-linear-gradient(135deg, rgba(156, 38, 32, 0.32) 0 8px, rgba(8, 10, 16, 0.42) 8px 16px);
}

.storage-trash-zone strong {
  font-size: 18px;
  line-height: 1;
}

.storage-confirm-panel,
.storage-empire-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.storage-confirm-panel {
  border-color: rgba(255, 112, 96, 0.52);
  background: rgba(80, 24, 24, 0.22);
}

.storage-empire-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
}

.inventory-item.draggable {
  cursor: grab;
}

.inventory-item.draggable:active {
  cursor: grabbing;
}

.inventory-volume {
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  text-align: center;
}

.notification-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.notification-badge {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 5px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.notification-button.has-unread .notification-badge {
  background: var(--accent);
  color: #111722;
  font-weight: 800;
}

.notification-row {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.notification-row.unread {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.region-map-button.active {
  border-color: #66d9ff;
  background: rgba(53, 167, 208, 0.18);
  color: #bcefff;
  box-shadow: inset 0 0 0 1px rgba(102, 217, 255, 0.12);
}

#mailPanel {
  width: min(900px, calc(100vw - 28px));
  height: min(640px, calc(100vh - 116px));
  min-width: 600px;
  left: 50%;
  top: 78px;
  bottom: auto;
  transform: translateX(-50%);
}

.mailbox {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.mailbox-toolbar,
.mailbox-category-toolbar,
.mail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mailbox-category-toolbar {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.mailbox-category-toolbar button {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 11px;
}

.mailbox-category-count {
  margin-left: 5px;
  color: var(--muted);
  font-size: 10px;
}

.mailbox-toolbar button.active,
.mailbox-category-toolbar button.active {
  border-color: var(--accent);
  color: #ffd2aa;
  background: var(--accent-soft);
}

.mailbox-toolbar .mail-delete-selected {
  border-color: rgba(255, 112, 96, 0.48);
  color: #ffc1b9;
  background: rgba(120, 28, 24, 0.22);
}

.mailbox-selection-count {
  align-self: center;
  color: #ffd2aa;
  font-size: 11px;
}

.mailbox-layout {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(310px, 0.9fr) minmax(0, 1.45fr);
  gap: 10px;
}

.mail-list,
.mail-detail {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(0, 5, 11, 0.38);
}

.mail-list {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

#mailPanel .mail-list-item {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  min-width: 0;
  width: 100%;
  height: auto;
  min-height: 76px;
  padding: 9px 10px;
  display: grid;
  gap: 4px;
  text-align: left;
  white-space: normal;
  overflow: hidden;
  overflow-wrap: anywhere;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
}

#mailPanel .mail-list-item > strong,
#mailPanel .mail-list-item > .muted {
  min-width: 0;
  line-height: 1.25;
}

#mailPanel .mail-list-item > .muted {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#mailList,
#mailPanel .drawer-body {
  min-height: 0;
}

.mail-list-item.unread {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}

.mail-list-item.selected {
  background: rgba(70, 188, 230, 0.12);
}

.mail-list-item.bulk-selected {
  border-left: 3px solid #ff9b52;
  background: rgba(242, 138, 58, 0.16);
  box-shadow: inset 0 0 0 1px rgba(242, 138, 58, 0.34);
}

.mail-list-item.bulk-selected::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f28a3a;
  color: #111722;
  font-size: 12px;
  font-weight: 900;
}

.mail-list-meta,
.mail-detail-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mail-list-meta {
  min-width: 0;
}

.mail-list-meta span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-list-meta span:last-child {
  flex: 0 0 auto;
}

.mail-detail {
  padding: 18px;
}

.mail-detail h3 {
  margin: 8px 0 4px;
  font-size: 20px;
}

.mail-message {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.035);
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  #mailPanel {
    min-width: 320px;
  }
  .mailbox-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(150px, 0.7fr) minmax(220px, 1.3fr);
  }
}

.account-divider {
  height: 1px;
  background: var(--line);
}

.bottom-tools {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: flex;
  gap: 4px;
  transform: translateX(-50%);
  pointer-events: auto;
  align-items: end;
}

.tool-icon {
  width: auto;
  min-width: 98px;
  height: 38px;
  min-height: 38px;
  padding: 0 15px;
  border-radius: 8px 8px 0 0;
  border-color: rgba(242, 138, 58, 0.34);
  border-bottom-color: rgba(242, 138, 58, 0.18);
  background: linear-gradient(180deg, rgba(26, 33, 47, 0.96), rgba(12, 16, 24, 0.96));
  color: #ffd0a6;
  font-weight: 750;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tool-icon:hover {
  transform: translateY(-2px);
  border-color: rgba(242, 138, 58, 0.72);
  background: linear-gradient(180deg, rgba(242, 138, 58, 0.2), rgba(18, 23, 34, 0.98));
}

.tool-stack {
  position: relative;
  display: grid;
  align-items: end;
}

.tool-menu {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 42px;
  display: none;
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(242, 138, 58, 0.28);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 -14px 30px rgba(0, 0, 0, 0.32);
  box-sizing: border-box;
  min-width: max(100%, 130px);
  transform: translateX(-50%);
}

.tool-stack.open .tool-menu,
.tool-stack:hover .tool-menu {
  display: grid;
}

.tool-menu button {
  width: 100%;
  box-sizing: border-box;
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  text-align: left;
}

#storageTools .tool-menu button {
  text-align: center;
}

#marketTools .tool-menu button {
  text-align: center;
}

.player-market-shell {
  display: grid;
  grid-template-columns: minmax(170px, 0.52fr) minmax(420px, 1.48fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.player-market-sidebar,
.player-market-main,
.player-market-order-entry {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(14, 19, 29, 0.74);
  overflow: hidden;
}

.player-market-sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr;
  align-content: start;
  min-height: 0;
}
.player-market-settings {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(119, 155, 169, 0.35);
  border-radius: 7px;
  background: rgba(19, 31, 36, 0.78);
}
.player-market-settings label { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.player-market-settings input { margin-top: 3px; }
.player-market-settings p { margin: 5px 0 0 25px; }

.player-market-title {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 18, 0.42);
}

.player-market-search {
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.player-market-search input {
  width: 100%;
}

.player-market-tree {
  padding: 8px;
  overflow: auto;
  min-height: 0;
  scrollbar-gutter: stable;
}

.market-tree-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 28px;
  margin: 4px 0;
  padding: 4px 7px;
  border-color: rgba(242, 138, 58, 0.16);
  background: rgba(242, 138, 58, 0.055);
  color: #ffd0a6;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
}

.market-tree-category:hover {
  border-color: rgba(242, 138, 58, 0.38);
  background: rgba(242, 138, 58, 0.11);
}

.market-tree-category-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
}

.market-tree-category-chevron {
  display: inline-block;
  color: #ffd0a6;
  transform: rotate(90deg);
  transition: transform 120ms ease;
}

.market-tree-category[aria-expanded="false"] .market-tree-category-chevron {
  transform: rotate(0deg);
}

.market-tree-category-items {
  display: grid;
  gap: 4px;
  padding-bottom: 3px;
}

.market-tree-category-items[hidden] {
  display: none;
}

.market-tree-item {
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 27px;
  text-align: left;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
  color: #dce7f5;
}

.market-tree-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-tree-order-counts {
  flex: 0 0 auto;
  color: #9fb1c6;
  font-size: 10px;
  white-space: nowrap;
}

.market-tree-item.active .market-tree-order-counts {
  color: #ffd2ad;
}

.market-tree-item.active {
  border-color: rgba(242, 138, 58, 0.78);
  background: linear-gradient(90deg, rgba(242, 138, 58, 0.24), rgba(21, 27, 39, 0.92));
  color: #fff3e6;
}

.player-market-main {
  display: grid;
  gap: 10px;
  padding: 10px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.player-market-hero {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(242, 138, 58, 0.22);
  border-radius: 7px;
  background:
    radial-gradient(circle at 15% 30%, rgba(94, 184, 255, 0.18), transparent 28%),
    radial-gradient(circle at 82% 62%, rgba(242, 138, 58, 0.16), transparent 32%),
    rgba(11, 16, 26, 0.86);
}

.player-market-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 1px solid rgba(242, 138, 58, 0.22);
  border-radius: 7px;
  background: radial-gradient(circle, rgba(255, 205, 159, 0.24), rgba(0, 0, 0, 0.54));
  color: #ffd0a6;
  font-weight: 900;
  font-size: 24px;
  letter-spacing: 0.03em;
  overflow: hidden;
}

.player-market-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.player-market-hero h3 {
  margin: 0;
  font-size: 22px;
}

.player-market-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
}

.player-market-stat {
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 11px;
  color: #dce7f5;
}

.player-market-order-entry {
  display: grid;
  grid-template-columns: 110px 1fr 1fr auto;
  gap: 8px;
  padding: 9px;
  align-items: end;
}

.player-market-order-entry label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.player-market-order-entry input,
.player-market-order-entry select {
  width: 100%;
  letter-spacing: 0;
  text-transform: none;
}

.player-market-books {
  display: grid;
  gap: 10px;
}

.player-market-book {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(7, 11, 18, 0.34);
}

.player-market-book h4 {
  margin: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.player-market-table {
  display: grid;
}

.player-market-row {
  display: grid;
  grid-template-columns: minmax(82px, 0.75fr) minmax(82px, 0.75fr) minmax(180px, 1fr) minmax(86px, auto);
  min-height: 31px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
  font-size: 11px;
}

.player-market-row:last-child {
  border-bottom: 0;
}

.player-market-row > div {
  padding: 6px 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.075);
}

.player-market-row > div:last-child {
  border-right: 0;
}

.player-market-head {
  background: rgba(8, 16, 29, 0.92);
  color: #edf3ff;
  font-weight: 800;
}

.player-market-empty {
  padding: 12px;
  color: var(--muted);
}

.copy-lab {
  display: grid;
  grid-template-columns: minmax(240px, 0.95fr) minmax(360px, 1.45fr);
  gap: 14px;
  grid-column: 1 / -1;
}

.copy-vault,
.copy-chamber {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(108, 190, 255, 0.2);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 10%, rgba(88, 184, 255, 0.16), transparent 30%),
    radial-gradient(circle at 86% 74%, rgba(242, 138, 58, 0.13), transparent 36%),
    rgba(12, 16, 24, 0.76);
  box-shadow: inset 0 0 28px rgba(88, 184, 255, 0.05);
}

.copy-vault {
  max-height: 430px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  overflow: auto;
}

.copy-bpo-card {
  width: 100%;
  height: auto;
  min-height: 70px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  text-align: left;
  white-space: normal;
  background: rgba(255, 255, 255, 0.045);
}

.copy-bpo-card.active {
  border-color: rgba(108, 190, 255, 0.72);
  background: rgba(88, 184, 255, 0.13);
  box-shadow: inset 0 0 22px rgba(88, 184, 255, 0.08);
}

.copy-bpo-card strong,
.copy-bpo-card span {
  display: block;
}

.copy-bpo-card small {
  color: #bde8ff;
  font-weight: 800;
}

.copy-chamber {
  min-height: 430px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 14px;
  border-color: rgba(242, 138, 58, 0.34);
  background:
    radial-gradient(circle at 18% 12%, rgba(88, 184, 255, 0.18), transparent 31%),
    radial-gradient(circle at 82% 68%, rgba(242, 138, 58, 0.2), transparent 38%),
    rgba(12, 16, 24, 0.8);
}

.copy-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.copy-preview-badge {
  padding: 4px 9px;
  border: 1px solid rgba(242, 138, 58, 0.5);
  border-radius: 999px;
  color: #ffd0a6;
  background: rgba(242, 138, 58, 0.12);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.copy-halo {
  position: relative;
  min-height: 160px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(237, 243, 255, 0.1);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 50%, rgba(88, 184, 255, 0.18), rgba(6, 10, 17, 0.22) 54%, rgba(2, 4, 8, 0.35));
  overflow: hidden;
}

.copy-halo::before,
.copy-halo::after {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  border: 1px solid rgba(108, 190, 255, 0.25);
  border-radius: 999px;
  transform: rotate(24deg) scaleY(0.42);
}

.copy-halo::after {
  border-color: rgba(242, 138, 58, 0.22);
  transform: rotate(-31deg) scaleY(0.38);
}

.copy-core {
  position: relative;
  z-index: 1;
  width: 94px;
  height: 94px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(108, 190, 255, 0.42);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #d8f3ff, #58b8ff 45%, #11263a 76%);
  color: #06111b;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 0 30px rgba(88, 184, 255, 0.32);
}

.copy-core.copy-art {
  width: 132px;
  height: 132px;
  border-radius: 8px;
  background: rgba(5, 8, 14, 0.86);
  overflow: hidden;
}

.copy-core.copy-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.copy-controls,
.copy-output-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.copy-output-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 980px) {
  .copy-lab {
    grid-template-columns: 1fr;
  }
}

.drawer-panel {
  position: absolute;
  left: 14px;
  top: 88px;
  bottom: 14px;
  z-index: 6;
  width: min(520px, calc(100vw - 28px));
  display: none;
  grid-template-rows: auto auto 1fr;
  border-radius: 8px;
  overflow: hidden;
  resize: both;
  min-width: 320px;
  min-height: 260px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  pointer-events: auto;
}

body.minimized-dock-active .drawer-panel:not(.right-drawer) {
  left: 112px;
  width: min(520px, calc(100vw - 126px));
}

.drawer-panel.open {
  display: grid;
}

.draggable-window.open {
  z-index: 10020;
}

.minimized-dock {
  position: absolute;
  left: 14px;
  top: 88px;
  z-index: 12;
  display: grid;
  gap: 7px;
  pointer-events: auto;
}

.minimized-tab {
  width: 86px;
  min-height: 42px;
  height: auto;
  padding: 6px;
  border-color: var(--accent-line);
  background: var(--panel-strong);
  color: #fff4e9;
  white-space: normal;
  line-height: 1.1;
}

.window-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.drawer-head .window-actions,
#marketPanel .drawer-head .window-actions {
  position: absolute;
  right: 12px;
}

.drawer-head .window-actions button,
#marketPanel .drawer-head .window-actions button {
  position: static;
  right: auto;
}

.drawer-panel.right-drawer {
  left: auto;
  right: 14px;
  width: min(420px, calc(100vw - 28px));
  z-index: 7;
}

#itemInfoPanel {
  width: min(580px, calc(100vw - 28px));
  height: min(460px, calc(100vh - 116px));
  bottom: auto;
}
#itemContextMenu {
  z-index: 30050;
}
#itemContextMenu.sector-market-order-prompt { width:280px; padding:10px; display:grid; gap:8px; }
#itemContextMenu.sector-market-order-prompt .sector-market-order-title { display:grid; gap:2px; padding-bottom:7px; border-bottom:1px solid var(--line); }
#itemContextMenu.sector-market-order-prompt label { display:grid; gap:4px; color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.04em; }
#itemContextMenu.sector-market-order-prompt input,
#itemContextMenu.sector-market-order-prompt select { width:100%; }
.item-info-hero { display:block; width:76px; }
.item-info-icon { width:76px; height:76px; display:grid; place-items:center; border:1px solid rgba(139,168,185,.2); border-radius:10px; background:rgba(10,18,27,.75); overflow:hidden; }
.item-info-icon img { width:100%; height:100%; object-fit:contain; }
.item-info-icon .inventory-fallback { font-size:22px; }
.item-info-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; margin:10px 0; }
.item-info-tabs button.active { border-color:#38bde7; background:rgba(34,133,168,.2); color:#dff8ff; }
.item-info-section { display:grid; grid-column:1 / -1; gap:8px; }
.item-info-entry { display:grid; grid-template-columns:1fr auto; gap:10px; align-items:start; padding:10px; border:1px solid rgba(139,168,185,.17); border-radius:8px; background:rgba(255,255,255,.025); }
.item-info-entry > div { display:grid; gap:3px; }
.item-info-recipe { display:flex; flex-wrap:wrap; gap:5px; justify-content:flex-end; }
.item-info-recipe span { padding:3px 6px; border:1px solid rgba(139,168,185,.18); border-radius:999px; color:#b8c7d7; font-size:11px; }
[data-item-key] { cursor:context-menu; }

#shipyardPanel,
#shipDesignPanel,
#shipFactoryPanel,
#blueprintCopyPanel,
#fleetPanel,
#fleetCreatePanel,
#barracksPanel,
#groundCommandPanel,
#formationsPanel {
  width: min(980px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 116px));
  bottom: auto;
  min-height: 340px;
  isolation: isolate;
}

#formationCargoModalHost,
#fleetCargoModalHost {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.formation-builder,
.formation-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(139, 168, 185, 0.24);
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(24, 36, 42, 0.96), rgba(10, 18, 25, 0.97));
}

.formation-card.focused {
  border-color: rgba(242, 138, 58, 0.78);
  box-shadow: 0 0 0 1px rgba(242, 138, 58, 0.24), 0 0 24px rgba(242, 138, 58, 0.12);
}

.formation-summary-card.active {
  border-color: rgba(242, 138, 58, 0.62);
  background: linear-gradient(135deg, rgba(242, 138, 58, 0.10), rgba(255, 255, 255, 0.04));
  box-shadow: 0 0 0 1px rgba(242, 138, 58, 0.12);
}

.formation-route-pill {
  border-color: rgba(57, 214, 239, .5);
  background: rgba(57, 214, 239, .1);
  color: #9cefff;
}

.formation-route-icon {
  display: inline-block;
  margin-left: 4px;
  color: #39d6ef;
  font-size: 14px;
  vertical-align: -1px;
}

.formation-card-section {
  display: grid;
  gap: 7px;
  min-width: 0;
  grid-column: 1 / -1;
}

.formation-card-section + .formation-card-section {
  margin-top: 5px;
  padding-top: 10px;
  border-top: 1px solid rgba(139, 168, 185, .16);
}

.formation-card-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 3px;
  color: #9aabb5;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.formation-card-section.routed .formation-card-section-title {
  color: #79dff0;
}

.formation-card-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(390px, 1fr));
  gap: 7px;
  min-width: 0;
}

.formation-management-layout .formation-card-section-grid {
  grid-template-columns: 1fr;
}

.formation-card-section-toggle {
  width: auto;
  height: 23px;
  min-height: 23px;
  padding: 2px 7px;
  border-color: rgba(57, 214, 239, .32);
  color: #a8eaf4;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}

.fleet-workspace-stack {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.formation-summary-card {
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.formation-summary-card:not(.expanded) {
  padding-block: 8px;
}

.formation-summary-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  box-shadow: none;
}

.formation-summary-toggle:hover,
.formation-summary-toggle:focus-visible {
  border: 0;
  background: transparent;
  color: #ffd0a6;
  outline: none;
}

.formation-summary-toggle-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.formation-summary-toggle-copy > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formation-summary-chevron {
  flex: 0 0 auto;
  color: #9aabb5;
  font-size: 18px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform .16s ease, color .16s ease;
}

.formation-summary-card.expanded .formation-summary-chevron {
  color: #ffb879;
  transform: rotate(90deg);
}

.formation-card-list {
  grid-template-columns: repeat(auto-fit, minmax(390px, 1fr));
  align-items: stretch;
}

.formation-management-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.formation-management-layout > * {
  min-width: 0;
}

.formation-management-layout .formation-card-list {
  grid-template-columns: 1fr;
  gap: 7px;
}

.formation-management-layout .formation-summary-card {
  grid-template-columns: 1fr;
  gap: 7px;
  padding: 9px;
}

.formation-management-layout .formation-summary-card .fleet-card-location,
.formation-management-layout .formation-summary-card .fleet-card-cargo,
.formation-management-layout .formation-summary-card .fleet-card-actions {
  grid-column: 1;
}

.formation-management-layout .formation-summary-card .fleet-card-location {
  grid-template-columns: auto 1fr;
  align-items: baseline;
}

.formation-management-layout .formation-summary-card .fleet-card-location > .muted:last-child {
  grid-column: 1 / -1;
}

.formation-management-layout .formation-summary-card .fleet-card-actions {
  gap: 4px;
}

.formation-management-layout .formation-summary-card .fleet-card-actions button {
  min-width: 0;
  padding: 6px 9px;
}

.formation-summary-card {
  grid-template-columns: minmax(0, 1.3fr) minmax(150px, .7fr);
  align-content: start;
  padding: 14px;
}

.formation-summary-card .fleet-card-cargo,
.formation-summary-card .fleet-card-actions {
  grid-column: 1 / -1;
}

.formation-summary-card .fleet-card-actions {
  justify-content: flex-start;
  padding-top: 2px;
}

.formation-summary-card:hover,
.formation-summary-card:focus-visible {
  border-color: rgba(242, 138, 58, 0.5);
  background: rgba(242, 138, 58, 0.075);
  outline: none;
}

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

.formation-stance-controls {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.formation-stance-option,
.formation-unit-detail {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(139, 168, 185, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  text-align: left;
}

.formation-stance-option.active {
  border-color: rgba(242, 138, 58, 0.72);
  background: rgba(242, 138, 58, 0.12);
  color: #ffd0a6;
}

.formation-stance-option {
  position: relative;
  display: flex;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

.formation-stance-option::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  z-index: 20;
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  border: 1px solid rgba(139, 168, 185, 0.34);
  border-radius: 6px;
  background: rgba(5, 12, 19, 0.98);
  color: #dce8f2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 3px);
  transition: opacity .12s ease, transform .12s ease;
}

.formation-stance-option:hover::after,
.formation-stance-option:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.formation-unit-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.formation-command-workspace {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 11px;
  border: 1px solid rgba(242, 138, 58, 0.28);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(24, 36, 42, 0.94), rgba(7, 13, 20, 0.97));
}

.formation-management-layout .formation-command-workspace {
  margin-top: 0;
  gap: 7px;
  padding: 9px;
}

.formation-management-layout .formation-command-workspace .data-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 0;
}

.formation-management-layout .formation-command-workspace .data-cell {
  padding: 7px;
}

.formation-compact-detail-row {
  display: grid;
  grid-template-columns: minmax(230px, .8fr) minmax(0, 1.2fr);
  gap: 7px;
}

.formation-management-layout .formation-order-block {
  gap: 5px;
  padding: 7px;
}

.formation-management-layout .formation-stance-option,
.formation-management-layout .formation-unit-detail {
  padding: 7px;
}

@media (max-width: 760px) {
  .formation-management-layout,
  .formation-compact-detail-row {
    grid-template-columns: 1fr;
  }

  .formation-management-layout .formation-command-workspace .data-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.formation-command-workspace > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.formation-cargo-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 10090;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 4, 9, 0.64);
  backdrop-filter: blur(2px);
  pointer-events: auto;
}

.formation-cargo-modal {
  width: min(420px, calc(100vw - 36px));
  display: grid;
  gap: 13px;
  padding: 16px;
  border: 1px solid rgba(242, 138, 58, 0.66);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(25, 38, 46, 0.99), rgba(5, 12, 19, 0.99));
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.72), 0 0 28px rgba(242, 138, 58, 0.12);
}

.formation-cargo-modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.formation-cargo-modal-resource {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 11px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.formation-cargo-modal-resource .inventory-icon {
  width: 54px;
  height: 54px;
}

.formation-cargo-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.formation-cargo-modal-actions [data-formation-cargo-confirm] {
  border-color: var(--accent);
  color: #ffd2aa;
  background: var(--accent-soft);
}

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

.formation-order-block {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(139, 168, 185, 0.17);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
}

.formation-order-block .formation-actions {
  align-items: end;
}

.formation-current-order {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid rgba(56, 189, 231, 0.24);
  border-radius: 7px;
  background: rgba(56, 189, 231, 0.06);
}

.cargo-transfer-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.cargo-zone {
  min-width: 0;
  min-height: 230px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 9px;
  overflow: hidden;
  border: 1px solid rgba(139, 168, 185, 0.20);
  border-radius: 8px;
  background: rgba(4, 10, 17, 0.48);
}

.cargo-zone[data-cargo-disabled="true"] {
  opacity: 0.62;
}

.cargo-zone-head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.cargo-zone-head > strong,
.cargo-zone-head > span {
  min-width: 0;
}

.cargo-zone-head > .muted {
  text-align: right;
}

.cargo-zone-head-meter {
  align-items: center;
}

.cargo-zone-meter {
  width: min(190px, 52%);
  display: grid;
  gap: 3px;
  text-align: right;
  font-size: 11px;
}

.cargo-zone > .inventory-grid {
  min-height: 0;
  max-height: 260px;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 3px;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
}

@media (max-width: 760px) {
  .formation-order-grid {
    grid-template-columns: 1fr;
  }

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

  .cargo-zone {
    min-height: 180px;
  }
}

.formation-delivery-status {
  display: grid;
  gap: 7px;
  margin-top: 9px;
  padding: 9px;
  border: 1px solid rgba(242, 138, 58, 0.28);
  border-radius: 7px;
  background: rgba(242, 138, 58, 0.07);
}

.formation-builder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.formation-unit-picker {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(139, 168, 185, 0.17);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
}

.formation-unit-picker span {
  display: grid;
  gap: 2px;
}

.formation-unit-picker input {
  width: 100%;
}

.formation-card header,
.formation-actions,
.formation-stat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.formation-stat-row span {
  padding: 4px 7px;
  border: 1px solid rgba(139, 168, 185, 0.18);
  border-radius: 999px;
  color: #c8d7e4;
  font-size: 11px;
}

.formation-actions select {
  min-width: 190px;
  flex: 1 1 210px;
}

.ground-unit-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  align-content: start;
  padding: 11px;
  border: 1px solid rgba(139, 168, 185, 0.24);
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(26, 39, 43, 0.94), rgba(13, 21, 27, 0.96));
}

.ground-unit-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 9px;
}

.ground-unit-card > header,
.ground-unit-train-row,
.ground-force-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ground-unit-card > header > div {
  display: grid;
  gap: 2px;
}

.ground-unit-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.ground-unit-stats span {
  padding: 5px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.ground-unit-card .data-grid {
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 0;
}

.ground-unit-card .data-cell,
.ground-unit-card .value,
.ground-unit-card .material-cost-list {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.ground-unit-card .material-cost-row {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
}

.ground-unit-card .material-cost-row strong {
  overflow-wrap: anywhere;
}

.ground-unit-train-row input {
  width: 74px;
  flex: 0 0 auto;
}

.ground-unit-train-row button {
  flex: 1;
}

.ground-force-summary {
  padding: 10px 12px;
  border: 1px solid rgba(85, 188, 222, 0.24);
  border-radius: 8px;
  background: rgba(35, 119, 146, 0.08);
}

.barracks-queue {
  display: grid;
  gap: 7px;
}

.barracks-queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
}

.barracks-queue-row > div {
  display: grid;
  gap: 3px;
}

.barracks-queue-status {
  align-self: center;
  min-width: 58px;
  margin-left: 0;
  padding: 5px 10px;
  border-radius: 6px;
  line-height: 1.15;
  text-align: center;
}

@media (max-width: 720px) {
  .ground-unit-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

#shipFactoryPanel {
  width: min(1180px, calc(100vw - 28px));
  height: min(680px, calc(100vh - 96px));
}

#researchPanel[data-mode="new"] #researchList .blueprint-history,
#researchPanel[data-mode="new"] #researchList .hull-card-grid {
  display: none;
}

#researchPanel[data-mode="known"] #activeResearch,
#researchPanel[data-mode="known"] #researchList .research-form,
#researchPanel[data-mode="known"] #researchList .hull-focus-panel {
  display: none;
}

.research-project-composer {
  margin-top: 14px; overflow: hidden;
  border: 1px solid rgba(85,188,222,.28); border-radius: 14px;
  background: linear-gradient(145deg,rgba(19,31,40,.98),rgba(12,19,27,.98));
}
.research-project-composer > header, .research-project-summary { display:flex; align-items:center; gap:12px; padding:14px 16px; background:rgba(71,144,171,.08); }
.research-project-composer > header { justify-content:space-between; border-bottom:1px solid rgba(137,182,201,.16); }
.research-project-composer .eyebrow { color:#73d6f3; font-size:10px; font-weight:800; letter-spacing:.12em; text-transform:uppercase; }
.research-readiness { padding:5px 9px; border:1px solid rgba(255,174,91,.45); border-radius:999px; color:#ffb66d; font-size:11px; }
.research-readiness.ready { border-color:rgba(85,224,169,.45); color:#65e1ad; }
.research-step { padding:15px 16px; border-bottom:1px solid rgba(137,182,201,.11); }
.research-step-label { display:flex; align-items:center; gap:9px; margin-bottom:10px; }
.research-step-label b { display:grid; width:23px; height:23px; place-items:center; border-radius:50%; background:rgba(50,178,218,.17); color:#7bddfa; }
.research-step-label div { display:grid; gap:1px; }
.research-step-label span, .research-choice-card span, .research-choice-card small, .research-pack-card span, .research-pack-card small { color:#a8b7c7; font-size:11px; line-height:1.35; }
.research-choice-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.research-choice-grid.compact { grid-template-columns:repeat(3,minmax(0,1fr)); }
#researchPanel button.research-choice-card, #researchPanel .research-pack-card > button:first-child {
  display:grid; min-width:0; height:auto; min-height:88px; align-content:start; gap:4px;
  padding:10px; text-align:left; line-height:1.3; white-space:normal; overflow:hidden;
  border-color:rgba(139,168,185,.25); background:rgba(255,255,255,.025);
}
#researchPanel .research-choice-card strong, #researchPanel .research-choice-card span, #researchPanel .research-choice-card small,
#researchPanel .research-pack-card strong, #researchPanel .research-pack-card span, #researchPanel .research-pack-card small { display:block; overflow-wrap:anywhere; }
#researchPanel .research-choice-grid.compact button.research-choice-card { min-height:78px; }
#researchPanel button.research-choice-card.active,
#researchPanel .research-pack-card.active > button:first-child {
  position: relative;
  border-color: #54d4ff;
  background: linear-gradient(145deg, rgba(35, 166, 210, 0.24), rgba(24, 112, 150, 0.14));
  box-shadow: inset 0 0 0 1px rgba(84, 212, 255, 0.28), 0 0 18px rgba(56, 189, 231, 0.12);
}
#researchPanel button.research-choice-card.active {
  padding-right: 38px;
}
#researchPanel button.research-choice-card.active::after {
  content: "✓";
  position: absolute;
  top: 9px;
  right: 9px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #38bde7;
  color: #07131b;
  font-size: 13px;
  font-weight: 900;
}
#researchPanel button.research-choice-card.active strong {
  color: #dff8ff;
}
.research-power-control { display:grid; grid-template-columns:1fr auto; align-items:center; gap:14px; padding:10px; border-radius:9px; background:rgba(255,255,255,.035); }
.research-power-control input { width:100%; accent-color:#38bde7; }
.research-pack-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.research-pack-card { display:grid; grid-template-columns:1fr auto; gap:5px; padding:5px; border:1px solid rgba(139,168,185,.14); border-radius:10px; }
.research-pack-card .pack-craft-button { height:auto; align-self:stretch; padding:7px; color:#79d9f5; }
.research-pack-card > small { grid-column:1/-1; padding:0 7px 5px; color:#91a4b6; line-height:1.35; }
.research-pack-card.locked { opacity:.68; }
.research-pack-fabrication { display:grid; gap:10px; margin-top:10px; padding:12px; border:1px solid rgba(56,189,231,.28); border-radius:10px; background:rgba(13,34,45,.62); }
.research-pack-fabrication > header, .research-pack-queue-row > header { display:flex; align-items:start; justify-content:space-between; gap:10px; }
.research-pack-fabrication h4, .research-pack-queue-row h4 { margin:0; }
.research-pack-fabrication-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
.research-pack-fabrication-grid .data-cell.materials { grid-column:1/-1; }
.research-pack-fabrication-actions { display:flex; justify-content:flex-end; gap:8px; }
.research-pack-queue { display:grid; gap:7px; margin-top:10px; }
.research-pack-queue-row { display:grid; gap:7px; padding:10px; border:1px solid rgba(139,168,185,.18); border-radius:9px; background:rgba(255,255,255,.025); }
.research-pack-queue-row.active { border-color:rgba(56,189,231,.38); }
.research-pack-queue-row .progress-track { height:5px; border-radius:999px; overflow:hidden; background:rgba(255,255,255,.08); }
.research-pack-queue-row .progress-track > span { display:block; height:100%; border-radius:inherit; background:#38bde7; }
.research-project-summary { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
.research-project-summary > div { display:grid; gap:2px; }
.research-project-summary > div span { color:#91a4b6; font-size:10px; text-transform:uppercase; }
.research-project-summary > button { grid-column:1/-1; min-height:42px; border-color:#bf6927; background:linear-gradient(135deg,#633016,#351b10); color:#ffe0bd; font-weight:800; }
.scientist-office { display:grid; gap:10px; margin-bottom:12px; padding:12px; border:1px solid rgba(86,180,213,.22); border-radius:11px; background:linear-gradient(135deg,rgba(25,46,57,.9),rgba(14,22,30,.9)); }
.scientist-office > header { display:flex; justify-content:space-between; gap:12px; align-items:start; }
.scientist-candidate-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.scientist-candidate { display:grid; grid-template-columns:1fr auto; gap:8px; align-items:center; padding:10px; border:1px solid rgba(139,168,185,.2); border-radius:8px; background:rgba(255,255,255,.025); }
.scientist-candidate > div { display:grid; gap:2px; min-width:0; }
.scientist-candidate span, .scientist-candidate small { color:#a8b7c7; line-height:1.35; }
#researchPanel .scientist-candidate button { height:auto; min-height:36px; white-space:nowrap; }
@media (max-width:720px) { .research-choice-grid, .research-choice-grid.compact, .research-pack-grid, .scientist-candidate-grid, .research-pack-fabrication-grid { grid-template-columns:1fr; } .research-pack-fabrication-grid .data-cell.materials { grid-column:auto; } }

#marketPanel {
  width: min(980px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 112px));
  bottom: auto;
  right: 14px;
}

#playerMarketPanel {
  width: min(1040px, calc(100vw - 28px));
  height: min(640px, calc(100vh - 112px));
  bottom: auto;
  right: 14px;
}

#playerMarketPanel .drawer-body {
  min-height: 0;
  overflow: hidden;
}

#playerMarketList {
  height: 100%;
  min-height: 0;
}

#productionPanel {
  width: min(860px, calc(100vw - 28px));
}

#buildingProductionPanel {
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  width: min(690px, calc(100vw - 28px));
  height: auto;
  max-height: min(800px, calc(100vh - 72px));
  min-width: min(520px, calc(100vw - 28px));
  transform: translate(-50%, -50%);
}

#buildingProductionPanel:has(.building-upgrade-review) {
  overflow: visible;
}

#buildingProductionPanel.open {
  display: flex;
  flex-direction: column;
}

#buildingProductionPanel .drawer-body {
  flex: 0 1 auto;
  min-height: 0;
  max-height: calc(100vh - 150px);
  overflow: auto;
}

#buildingProductionPanel:has(.building-upgrade-review) .drawer-body {
  overflow: visible;
}

#buildingProductionPanel .research-list {
  grid-template-columns: 1fr;
}

#buildingProductionPanel .research-list.with-upgrade-review {
  grid-template-columns: 1fr;
  align-items: start;
  position: relative;
}

#buildingProductionPanel .production-facility {
  margin: 0;
}

.building-production-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.building-production-context {
  margin-top: 10px;
}

.building-production-context .data-cell {
  min-height: 82px;
}

.building-construction-notice {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(255, 111, 118, 0.58);
  border-radius: 8px;
  background: rgba(96, 24, 28, 0.34);
  color: #ffd7d9;
  font-weight: 800;
}

.building-construction-notice span {
  color: #f5b9be;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.building-upgrade-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 10px 0 0;
  padding: 10px;
  border: 1px solid rgba(242, 138, 58, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(242, 138, 58, 0.14), rgba(88, 181, 255, 0.06)),
    rgba(9, 15, 25, 0.82);
}

.building-upgrade-strip h4 {
  margin: 0 0 3px;
  font-size: 14px;
}

.building-upgrade-strip p {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
}

.building-upgrade-review {
  display: grid;
  gap: 10px;
  position: absolute;
  left: calc(100% + 12px);
  top: 0;
  width: 320px;
  max-width: calc(100vw - 28px);
  z-index: 2;
  padding: 12px;
  border: 1px solid rgba(88, 181, 255, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(88, 181, 255, 0.1), rgba(242, 138, 58, 0.045)),
    rgba(9, 15, 25, 0.94);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

.building-upgrade-review header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.building-upgrade-review h4 {
  margin: 0 0 3px;
  font-size: 15px;
}

.building-upgrade-review .icon-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

.building-upgrade-review .data-grid {
  grid-template-columns: 1fr;
}

@media (max-width: 920px) {
  #buildingProductionPanel .research-list.with-upgrade-review {
    grid-template-columns: 1fr;
  }

  .building-upgrade-review {
    position: static;
    width: auto;
  }
}

#dysonPanel {
  width: min(520px, calc(100vw - 28px));
  height: min(760px, calc(100vh - 112px));
  min-width: min(420px, calc(100vw - 28px));
}

#storagePanel {
  left: 50%;
  right: auto;
  top: clamp(64px, 8vh, 90px);
  bottom: auto;
  width: min(1500px, calc(100vw - 48px));
  height: min(760px, calc(100vh - 104px));
  min-width: min(900px, calc(100vw - 28px));
  transform: translateX(-50%);
}

#storagePanel .drawer-body {
  overflow: hidden;
}

#storageDrawerList {
  display: block;
  grid-column: 1 / -1;
  width: 100%;
  height: 100%;
}

.storage-location-browser {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 2.8fr);
  gap: 10px;
}

.storage-location-nav,
.storage-location-main {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 5, 11, 0.38);
}

.storage-location-nav {
  padding: 8px;
  display: grid;
  align-content: start;
  gap: 6px;
}

.storage-location-main {
  padding: 12px;
}

.storage-location-button {
  width: 100%;
  height: auto;
  min-height: 54px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  text-align: left;
  white-space: normal;
  overflow: visible;
}

.storage-location-button strong,
.storage-location-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-location-button span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.storage-location-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.storage-location-sector {
  margin-left: 13px;
  width: calc(100% - 13px);
}

.storage-location-heading {
  margin: 7px 3px 1px;
  color: #9db0c2;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.storage-location-group {
  display: grid;
  gap: 5px;
}

.storage-location-group-toggle {
  width: 100%;
  height: auto;
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  text-align: left;
  white-space: normal;
  border-color: rgba(143, 183, 223, 0.2);
  background: rgba(92, 126, 151, 0.08);
}

.storage-location-group-toggle strong,
.storage-location-group-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-location-group-toggle span {
  color: var(--muted);
  font-size: 10px;
}

.storage-location-chevron {
  color: #d8e9f8 !important;
  font-size: 13px !important;
  grid-row: 1 / span 2;
}

.storage-location-group-toggle > span:last-child {
  grid-column: 2;
}

.storage-location-group-body {
  display: grid;
  gap: 5px;
}

.storage-location-group-body.collapsed {
  display: none;
}

.storage-browser-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 300px);
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.storage-browser-head h3,
.storage-browser-head p {
  margin: 0;
}

.storage-resource-ledger {
  display: grid;
  gap: 8px;
}

.storage-spot-list {
  display: grid;
  gap: 12px;
}

.storage-spot-card {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

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

.storage-spot-head h4,
.storage-spot-head p {
  margin: 0;
}

.storage-spot-capacity {
  flex: 0 0 auto;
  color: #c8d9e8;
  font-size: 11px;
  text-align: right;
}

.storage-spot-card .inventory-grid {
  grid-template-columns: repeat(auto-fill, minmax(96px, 116px));
  justify-content: start;
  margin-bottom: 10px;
}

.storage-spot-card .inventory-item {
  width: 100%;
}

.storage-discard-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
  padding: 11px;
  border: 1px solid rgba(255, 112, 96, 0.5);
  border-radius: 8px;
  background: rgba(80, 24, 24, 0.24);
}

.storage-discard-panel h4,
.storage-discard-panel p { margin: 0; }

.storage-discard-panel label { display: grid; gap: 5px; }

@media (max-width: 760px) {
  .storage-discard-panel { grid-template-columns: 1fr; }
}

.storage-resource-location-row {
  display: grid;
  grid-template-columns: 46px minmax(130px, 0.65fr) minmax(0, 1.8fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.storage-resource-location-row .inventory-icon {
  width: 42px;
  height: 42px;
}

.storage-resource-location-row > strong:last-child {
  text-align: right;
  color: #dff4ff;
}

.storage-location-pills {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.storage-location-pill {
  height: auto;
  min-height: 25px;
  padding: 4px 7px;
  font-size: 10px;
  white-space: normal;
  text-align: left;
}

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

@media (max-width: 760px) {
  .storage-location-browser { grid-template-columns: 1fr; grid-template-rows: minmax(150px, 0.6fr) minmax(260px, 1.4fr); }
  .storage-browser-head { grid-template-columns: 1fr; }
  .storage-resource-location-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .storage-location-pills { grid-column: 2 / -1; }
  .storage-location-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

#creditsPanel {
  width: min(760px, calc(100vw - 28px));
}

.drawer-head {
  justify-content: center;
  position: relative;
  text-align: center;
}

#marketPanel .drawer-head {
  justify-content: center;
  position: relative;
  text-align: center;
}

.drawer-head h2,
#marketPanel .drawer-head h2 {
  font-size: 22px;
}

.drawer-head button,
#marketPanel .drawer-head button {
  position: absolute;
  right: 12px;
}

.draggable-window.dragging {
  z-index: 30000 !important;
  user-select: none;
}

.drag-handle {
  cursor: move;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.drawer-body {
  overflow: auto;
  padding: 10px 12px 12px;
}

.ledger-table {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) repeat(4, minmax(88px, 1fr));
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.045);
}

.ledger-row {
  display: contents;
  font-size: 12px;
}

.ledger-row > div {
  min-width: 0;
  padding: 7px 8px;
  border-right: 1px solid rgba(237, 243, 255, 0.08);
  border-bottom: 1px solid rgba(237, 243, 255, 0.09);
  overflow-wrap: anywhere;
}

.ledger-row > div:last-child {
  border-right: 0;
}

.ledger-head > div {
  background: rgba(12, 22, 36, 0.86);
  color: #edf3ff;
  font-weight: 800;
}

.ledger-credit {
  color: #ffd0a6;
  font-weight: 800;
}

.ledger-debit {
  color: #ffb3a8;
  font-weight: 800;
}

.sector-modified-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 5px;
  margin-left: -5px;
  border-radius: 4px;
  cursor: help;
}

.sector-modified-value.beneficial {
  color: #83efb2;
  background: rgba(54, 190, 116, 0.12);
  box-shadow: inset 0 0 0 1px rgba(83, 220, 145, 0.2);
}

.sector-modified-value.harmful {
  color: #ff9d94;
  background: rgba(224, 75, 68, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 117, 105, 0.2);
}

.sector-modifier-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .02em;
}

.resource-node-recovering {
  color: #ffad5c;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
}

.ledger-row.clickable > div {
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ledger-row.clickable:hover > div,
.ledger-row.clickable.active > div {
  background: rgba(242, 138, 58, 0.075);
}

.resource-flow-detail {
  grid-column: 1 / -1;
  padding: 10px;
  border-bottom: 1px solid rgba(237, 243, 255, 0.09);
  background:
    radial-gradient(circle at 18% 12%, rgba(242, 138, 58, 0.10), transparent 34%),
    rgba(5, 9, 16, 0.50);
}

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

.resource-flow-section {
  min-width: 0;
  border: 1px solid rgba(237, 243, 255, 0.10);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.resource-flow-section h4 {
  margin: 0;
  padding: 8px 9px;
  border-bottom: 1px solid rgba(237, 243, 255, 0.08);
  color: #edf3ff;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.resource-flow-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  border-bottom: 1px solid rgba(237, 243, 255, 0.06);
  font-size: 12px;
}

.resource-flow-line:last-child {
  border-bottom: 0;
}

.resource-flow-line strong,
.resource-flow-line span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.resource-flow-line button {
  padding: 6px 9px;
  font-size: 11px;
}

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

.research-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

.research-tabs button {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 11px;
}

.research-tabs button.active {
  border-color: rgba(242, 138, 58, 0.82);
  background: var(--accent-soft);
  color: #fff4e9;
}

.research-category {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.research-category h3 {
  color: #dbe6f8;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.research-browser {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.research-rail {
  display: grid;
  gap: 6px;
  position: sticky;
  top: 0;
}

.research-rail button {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 48px;
  height: auto;
  padding: 7px 9px;
  text-align: left;
  border-radius: 6px;
  align-content: center;
  overflow: hidden;
}

.research-rail button strong,
.research-rail button span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.12;
}

.research-rail button.active {
  border-color: rgba(242, 138, 58, 0.82);
  background: var(--accent-soft);
  color: #fff4e9;
}

.research-rail button span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.research-detail {
  min-width: 0;
}

.research-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.055);
}

.research-item h4 {
  margin: 0 0 7px;
  font-size: 13px;
}

.production-facility {
  display: block;
}

.production-facility summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  cursor: pointer;
}

.production-facility summary::-webkit-details-marker {
  display: none;
}

.production-facility summary h4 {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0;
}

.production-facility summary::after {
  content: "Expand";
  color: #ffd0a6;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.production-facility[open] summary {
  margin-bottom: 8px;
}

.production-facility[open] summary::after {
  content: "Collapse";
}

.production-tabs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 0 10px;
  margin-bottom: 4px;
  background: linear-gradient(180deg, rgba(10, 16, 27, 0.96), rgba(10, 16, 27, 0.78));
  backdrop-filter: blur(8px);
}

.production-tabs button {
  min-height: 30px;
  padding: 5px 10px;
  border-color: rgba(242, 138, 58, 0.32);
  font-size: 12px;
}

.production-tabs button.active {
  background: rgba(242, 138, 58, 0.2);
  border-color: var(--accent-line);
  color: #fff1e4;
  box-shadow: 0 0 0 1px rgba(242, 138, 58, 0.18) inset;
}

.production-empty {
  padding: 8px 10px;
}

.production-empty h4,
.production-empty p {
  margin: 0;
}

.production-empty h4 {
  margin-bottom: 4px;
}

.production-status {
  align-self: center;
  color: #9fb0c6;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.production-status.paused {
  color: #ffb2a8;
}

.production-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(154px, 1fr));
  gap: 8px;
  margin: 6px 0 12px;
  grid-column: 1 / -1;
  align-items: stretch;
}

.production-overview-card {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 5px;
  text-align: left;
  min-height: 64px;
  padding: 8px;
  border-radius: 7px;
  border-color: rgba(242, 138, 58, 0.24);
  background:
    radial-gradient(circle at 84% 14%, rgba(242, 138, 58, 0.14), transparent 36%),
    rgba(255, 255, 255, 0.045);
}

.production-overview-card.active {
  border-color: var(--accent-line);
  background:
    radial-gradient(circle at 84% 14%, rgba(242, 138, 58, 0.24), transparent 38%),
    rgba(242, 138, 58, 0.1);
  box-shadow: 0 0 0 1px rgba(242, 138, 58, 0.14) inset;
}

#productionPanel .production-overview-card {
  height: auto;
  min-height: 72px;
}

#productionPanel .production-resource-card {
  height: auto;
  min-height: 58px;
  padding: 0;
}

.production-resource-category-grid {
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}

.production-overview-head,
.production-output-chips {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.production-overview-head {
  justify-content: space-between;
  margin-bottom: 0;
}

.production-overview-head strong {
  font-size: 12px;
  line-height: 1.1;
}

.production-overview-count {
  color: #ffd0a6;
  font-size: 12px;
  font-weight: 900;
}

.production-output-chips span {
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: #c9d5e6;
  font-size: 10px;
  background: rgba(0, 0, 0, 0.18);
}

.production-output-chips span {
  border-color: rgba(242, 138, 58, 0.22);
  color: #ffd9ba;
}

.production-output-chips {
  align-content: start;
  max-height: 24px;
  overflow: hidden;
}

.production-flow-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  grid-column: 1 / -1;
}

.production-flow-card,
.production-resource-card {
  border: 1px solid rgba(237, 243, 255, 0.12);
  background:
    linear-gradient(135deg, rgba(143, 183, 223, 0.08), rgba(255, 255, 255, 0.025)),
    rgba(10, 18, 28, 0.58);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  min-width: 0;
}

.production-flow-card {
  padding: 9px 10px;
}

.production-flow-card .label,
.production-resource-card .label {
  color: #aebbd0;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.production-flow-card .value {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 900;
  color: #edf3ff;
}

.production-category-section {
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
}

.production-category-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #edf3ff;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 4px;
}

.production-category-title span {
  color: #9fb0c6;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
}

.production-resource-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.production-resource-card {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) repeat(4, minmax(82px, 1fr));
  gap: 0;
  height: auto;
  min-height: 54px;
  align-items: stretch;
  padding: 0;
  color: #edf3ff;
  text-align: left;
  white-space: normal;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.production-resource-card:hover,
.production-resource-card.active {
  transform: none;
  border-color: var(--accent-line);
  background:
    linear-gradient(135deg, rgba(242, 138, 58, 0.14), rgba(143, 183, 223, 0.06)),
    rgba(10, 18, 28, 0.72);
}

.production-resource-cell {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 8px 10px;
  border-right: 1px solid rgba(237, 243, 255, 0.07);
}

.production-resource-cell:last-child {
  border-right: 0;
}

.production-resource-card h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.1;
}

.production-resource-net {
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.production-resource-table-head {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) repeat(4, minmax(82px, 1fr));
  min-height: 28px;
  border: 1px solid rgba(237, 243, 255, 0.09);
  border-radius: 7px;
  background: rgba(12, 22, 36, 0.82);
  color: #aebbd0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.production-resource-table-head span {
  min-width: 0;
  padding: 7px 10px;
  border-right: 1px solid rgba(237, 243, 255, 0.07);
}

.production-resource-table-head span:last-child {
  border-right: 0;
}

.production-resource-value {
  font-size: 13px;
  font-weight: 850;
  color: #edf3ff;
  overflow-wrap: anywhere;
}

.production-resource-detail-wrap {
  grid-column: 1 / -1;
}

@media (max-width: 720px) {
  .production-flow-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .production-resource-table-head {
    display: none;
  }

  .production-resource-card {
    grid-template-columns: 1fr;
  }

  .production-resource-cell {
    border-right: 0;
    border-bottom: 1px solid rgba(237, 243, 255, 0.07);
  }

  .production-resource-cell:last-child {
    border-bottom: 0;
  }

  .production-resource-grid {
    grid-template-columns: 1fr;
  }
}

.production-power {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  border-color: rgba(83, 220, 132, 0.55);
  background: rgba(83, 220, 132, 0.16);
  color: #a8ffc6;
  font-size: 15px;
  line-height: 24px;
  box-shadow: 0 0 0 1px rgba(83, 220, 132, 0.18) inset, 0 0 12px rgba(83, 220, 132, 0.14);
  vertical-align: middle;
}

.production-power.paused {
  border-color: rgba(255, 102, 86, 0.6);
  background: rgba(255, 102, 86, 0.14);
  color: #ffb0a8;
  box-shadow: 0 0 0 1px rgba(255, 102, 86, 0.18) inset, 0 0 12px rgba(255, 102, 86, 0.12);
}

.production-power:hover {
  transform: translateY(-1px);
}

.blueprint-history,
.build-details {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.blueprint-row {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 6px;
  background: rgba(6, 12, 20, 0.28);
}

.blueprint-row header,
.build-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px;
  transition: background 0.15s ease, color 0.15s ease;
}

.blueprint-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.blueprint-actions button {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 11px;
}

.blueprint-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.blueprint-name-row strong {
  font-size: 15px;
}

.blueprint-rename-label {
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffd0a6;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.blueprint-rename-label:hover {
  border: 0;
  background: transparent;
  color: #fff4e9;
}

.blueprint-mark {
  color: #9fd1ff;
  font-weight: 900;
}

.blueprint-purpose {
  color: #ffbd73;
  font-weight: 700;
}

.hull-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.hull-blueprint-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(237, 243, 255, 0.13);
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(25, 35, 52, 0.88), rgba(9, 13, 22, 0.78));
}

.hull-blueprint-card.active {
  border-color: var(--accent-line);
  background: linear-gradient(135deg, rgba(242, 138, 58, 0.18), rgba(24, 34, 52, 0.84));
  box-shadow: inset 0 0 0 1px rgba(242, 138, 58, 0.12);
}

.hull-blueprint-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.blueprint-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.blueprint-name-input {
  display: none;
  min-height: 26px;
  width: min(190px, 100%);
  padding: 4px 7px;
  font-size: 12px;
}

.hull-blueprint-card.editing .blueprint-name-input {
  display: block;
}

.hull-blueprint-card header strong,
.hull-blueprint-card header span {
  display: block;
}

.ship-proc-preview {
  position: relative;
  min-height: 118px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(143, 183, 223, 0.12);
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% 44%, rgba(143, 183, 223, 0.12), transparent 44%),
    radial-gradient(circle at 50% 50%, rgba(242, 138, 58, 0.07), transparent 64%),
    rgba(4, 9, 17, 0.42);
  overflow: hidden;
}

.ship-proc-preview.compact {
  min-height: 74px;
}

.ship-proc-preview.designer {
  width: min(76%, 300px);
  min-height: 230px;
  border: 0;
  background: transparent;
  overflow: visible;
  pointer-events: none;
}

.ship-proc-svg {
  width: 100%;
  max-width: 300px;
  height: auto;
  filter: drop-shadow(0 0 18px rgba(143, 183, 223, 0.16));
}

.ship-proc-preview.compact .ship-proc-svg {
  max-width: 140px;
}

.ship-proc-preview.designer .ship-proc-svg {
  max-width: 300px;
  filter: drop-shadow(0 0 26px rgba(143, 183, 223, 0.22));
}

.ship-preview-button {
  border-color: rgba(143, 209, 255, 0.35);
  color: #d8ecff;
  background:
    linear-gradient(135deg, rgba(69, 144, 205, 0.16), rgba(242, 138, 58, 0.08)),
    rgba(255, 255, 255, 0.04);
}

.ship-preview-stage {
  display: grid;
  gap: 12px;
}

.ship-preview-canvas-wrap {
  position: relative;
  min-height: 420px;
  border: 1px solid rgba(143, 183, 223, 0.16);
  border-radius: 9px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(60, 118, 165, 0.15), transparent 36%),
    radial-gradient(circle at 50% 50%, rgba(242, 138, 58, 0.08), transparent 58%),
    rgba(3, 7, 13, 0.82);
}

.ship-preview-canvas {
  display: block;
  width: 100%;
  height: 420px;
  cursor: grab;
}

.ship-preview-canvas:active {
  cursor: grabbing;
}

.ship-preview-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

.ship-preview-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 760px) {
  .ship-preview-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.hull-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.hull-stat-grid span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 6px;
  border: 1px solid rgba(237, 243, 255, 0.08);
  border-radius: 5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 11px;
}

.hull-stat-grid strong {
  color: #fff4e9;
}

.hull-focus-panel {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 9px;
  border: 1px solid rgba(242, 138, 58, 0.24);
  border-radius: 7px;
  background: rgba(242, 138, 58, 0.055);
}

.hull-focus-panel strong,
.hull-focus-panel span {
  display: block;
}

.hull-focus-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hull-focus-grid button {
  min-height: 28px;
  padding: 5px 9px;
  border-color: rgba(242, 138, 58, 0.28);
  font-size: 11px;
}

.hull-focus-grid button.active {
  border-color: var(--accent-line);
  background: rgba(242, 138, 58, 0.2);
  color: #fff1e4;
}

.blueprint-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.print-blueprint-button {
  border-color: rgba(242, 138, 58, 0.45);
  background: rgba(242, 138, 58, 0.12);
  color: #ffd0a6;
}

.inventory-item.blueprint-item {
  background: linear-gradient(180deg, rgba(35, 42, 62, 0.94), rgba(12, 16, 28, 0.9));
  border-color: rgba(242, 138, 58, 0.24);
}

.blueprint-info-summary {
  display: grid;
  gap: 8px;
}

.blueprint-info-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.blueprint-info-title h4 {
  margin: 0;
  font-size: 16px;
}

.build-details {
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 6px;
  padding: 7px;
  background: rgba(6, 12, 20, 0.28);
}

.build-details summary {
  list-style: none;
}

.build-details summary::-webkit-details-marker {
  display: none;
}

.build-quantity-row {
  display: grid;
  grid-template-columns: minmax(84px, 110px) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.build-quantity-row input {
  width: 100%;
}

.build-quantity-row .build-options,
.build-quantity-row .action-row {
  margin: 0;
}

.build-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 6px;
}

.build-choice-grid button.active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: #fff4e9;
}

.projection-list {
  display: grid;
  gap: 4px;
}

.projection-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 25px;
  padding: 4px 7px;
  border: 1px solid rgba(237, 243, 255, 0.1);
  border-radius: 6px;
  background: rgba(6, 12, 20, 0.24);
  font-size: 12px;
}

.projection-row.output {
  border-color: rgba(242, 138, 58, 0.28);
  background: rgba(242, 138, 58, 0.08);
}

.projection-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.projection-row span {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.production-process-visual {
  display: grid;
  grid-template-columns: minmax(135px, 1fr) 24px minmax(135px, 1.05fr) 24px minmax(135px, 1fr);
  align-items: center;
  gap: 6px;
  margin: 8px 0;
  padding: 8px;
  border: 1px solid rgba(255, 174, 93, 0.2);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 126, 35, 0.16), transparent 46%),
    rgba(5, 10, 17, 0.28);
}

.process-node {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-height: 104px;
  padding: 7px;
  border: 1px solid rgba(237, 243, 255, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(10, 16, 26, 0.78), rgba(4, 8, 14, 0.52));
  text-align: center;
}

.process-node-stack {
  align-self: stretch;
  align-content: start;
}

.process-resource-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: start;
  column-gap: 7px;
  row-gap: 2px;
  width: 100%;
  padding: 6px;
  border: 1px solid rgba(237, 243, 255, 0.08);
  border-radius: 7px;
  background: rgba(2, 6, 12, 0.22);
}

.process-node.facility {
  min-height: 126px;
  border-color: rgba(255, 174, 93, 0.24);
  background: radial-gradient(circle at 50% 65%, rgba(255, 119, 38, 0.18), rgba(4, 8, 14, 0.54) 68%);
}

.process-node img {
  width: min(96px, 100%);
  height: 82px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.42));
}

.process-node-stack img {
  grid-row: 1 / 3;
  width: 46px;
  height: 46px;
}

.process-node.facility img {
  width: min(110px, 100%);
  height: 74px;
}

.process-label {
  color: #9fd3ff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.process-name {
  font-weight: 900;
}

.process-resource-card .process-name,
.process-resource-card .process-rate {
  min-width: 0;
  text-align: left;
}

.process-rate {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.process-arrow {
  color: #ffb145;
  font-size: 25px;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 0 16px rgba(255, 148, 31, 0.72);
}

.process-fallback {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border: 1px dashed rgba(237, 243, 255, 0.28);
  border-radius: 12px;
  color: #c4d6ea;
  font-size: 18px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.05);
}

.process-node.facility .process-fallback {
  width: 90px;
  height: 68px;
}

.process-resource-card .process-fallback {
  grid-row: 1 / 3;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  font-size: 14px;
}

@media (max-width: 720px) {
  .production-process-visual {
    grid-template-columns: 1fr;
  }

  .process-arrow {
    transform: rotate(90deg);
    line-height: 1;
  }
}

.market-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.045);
}

.market-row {
  display: grid;
  grid-template-columns: minmax(125px, 1.15fr) minmax(70px, 0.62fr) minmax(118px, 0.95fr) minmax(96px, 0.78fr) minmax(76px, 0.62fr) minmax(86px, 0.68fr) minmax(76px, 0.62fr) minmax(58px, 0.48fr) minmax(52px, 0.45fr);
  align-items: center;
  min-height: 28px;
  border-bottom: 1px solid rgba(237, 243, 255, 0.09);
  font-size: 12px;
}

.market-row > div {
  min-width: 0;
  padding: 5px 7px;
  border-right: 1px solid rgba(237, 243, 255, 0.08);
  overflow-wrap: anywhere;
  overflow: hidden;
}

.market-row > div:last-child {
  border-right: 0;
  text-align: center;
}

.market-head {
  min-height: 26px;
  background: rgba(12, 22, 36, 0.86);
  color: #edf3ff;
  font-size: 11px;
  font-weight: 800;
}

.market-category {
  grid-template-columns: 1fr;
  min-height: 26px;
  background: rgba(242, 138, 58, 0.2);
  color: #fff4e9;
  font-weight: 800;
}

.market-category > button {
  width: 100%;
  min-height: 26px;
  border: 0;
  padding: 0 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.market-category > div,
.market-category > button {
  border-right: 0;
}

.market-product {
  color: #9fd1ff;
  padding-left: 18px !important;
}

.market-row[data-market-resource] {
  cursor: pointer;
}

.market-row[data-market-resource]:hover,
.market-row[data-market-resource].active {
  background: rgba(242, 138, 58, 0.08);
}

.market-row.market-locked {
  color: var(--muted);
  opacity: 0.74;
  cursor: default;
}

.market-row.market-locked .market-product {
  color: var(--muted);
}

.market-row.market-locked:hover {
  background: transparent;
}

.market-quantity-cell {
  display: block;
}

.market-quantity-cell input {
  height: 26px;
  padding: 0 5px;
  font-size: 11px;
}

.ledger-row[data-ship-id] {
  cursor: pointer;
}

.ledger-row[data-ship-id]:hover > div,
.ledger-row[data-ship-id].active > div {
  background: rgba(121, 168, 255, 0.09);
}

.ship-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 9px;
}

.ship-build-card,
.ship-owned-card {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.ship-build-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(130, 178, 255, 0.12), transparent 32%),
    linear-gradient(135deg, rgba(20, 30, 46, 0.96), rgba(10, 14, 24, 0.94));
}

.ship-build-card::before {
  content: "";
  position: absolute;
  inset: 9px auto auto 10px;
  width: 74px;
  height: 34px;
  border: 1px solid rgba(162, 204, 255, 0.32);
  border-radius: 50%;
  transform: skewX(-24deg);
  box-shadow: 34px 6px 0 -15px rgba(242, 138, 58, 0.55), inset 0 0 18px rgba(112, 165, 255, 0.08);
  opacity: 0.6;
  pointer-events: none;
}

.ship-build-card > * {
  position: relative;
  z-index: 1;
}

.ship-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.ship-build-card header,
.ship-owned-card header,
.ship-inspector-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.ship-build-card h4,
.ship-owned-card h4 {
  margin: 0;
  font-size: 14px;
}

.ship-stat-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ship-stat-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid rgba(237, 243, 255, 0.1);
  border-radius: 999px;
  background: rgba(6, 12, 20, 0.26);
  color: #dfe8f8;
  font-size: 11px;
  font-weight: 700;
}

.ship-materials {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.ship-owned-card {
  cursor: pointer;
}

.factory-hull-card {
  cursor: default;
  align-content: start;
}

.factory-part-card {
  cursor: default;
  align-content: start;
}

.factory-hull-card .data-grid,
.factory-part-card .data-grid {
  grid-template-columns: minmax(220px, 1fr) minmax(210px, 0.85fr);
  align-items: stretch;
}

.factory-hull-card .data-cell:nth-child(2),
.factory-part-card .data-cell:nth-child(2) {
  grid-row: span 2;
}

.factory-hull-card .material-cost-list,
.factory-part-card .material-cost-list {
  min-width: 0;
}

.factory-hull-card .material-cost-row,
.factory-part-card .material-cost-row {
  min-height: 32px;
}

.factory-hull-card .material-cost-row strong,
.factory-hull-card .material-cost-row span,
.factory-part-card .material-cost-row strong,
.factory-part-card .material-cost-row span {
  font-size: 12px;
}

.factory-hull-card select,
.factory-part-card select {
  width: 100%;
  min-width: 0;
}

.factory-manufacturing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.factory-manufacturing-grid .ship-owned-card {
  min-width: 0;
  overflow: hidden;
}

.factory-manufacturing-grid .factory-part-card,
.factory-manufacturing-grid .factory-hull-card {
  grid-template-columns: minmax(0, 1fr);
}

.factory-part-card h4,
.factory-hull-card h4 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.factory-part-card p,
.factory-hull-card p {
  margin: 0;
}

.factory-part-card .data-cell,
.factory-hull-card .data-cell {
  min-width: 0;
}

.factory-part-card .value,
.factory-hull-card .value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.factory-part-card button,
.factory-hull-card button {
  width: 100%;
}

@media (min-width: 900px) {
  .factory-manufacturing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

.factory-manufacturing-grid .factory-hull-card {
  grid-column: 1 / -1;
}
  }

.factory-assembly-bay {
  display: grid;
  grid-template-columns: minmax(220px, 0.62fr) minmax(420px, 1.38fr);
  gap: 12px;
  align-items: stretch;
  grid-column: 1 / -1;
}

.factory-design-preview,
.factory-parts-checklist {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(237, 243, 255, 0.13);
  border-radius: 8px;
  background:
    radial-gradient(circle at 24% 34%, rgba(242, 138, 58, 0.12), transparent 36%),
    linear-gradient(135deg, rgba(18, 27, 40, 0.94), rgba(9, 13, 22, 0.96));
}

.factory-design-preview {
  display: grid;
  gap: 10px;
  align-content: start;
}

.factory-design-preview header,
.factory-parts-checklist header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.factory-design-preview h4,
.factory-parts-checklist h4 {
  margin: 0;
  font-size: 15px;
}

.factory-preview-stage {
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(143, 183, 223, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 52%, rgba(143, 183, 223, 0.12), transparent 42%),
    rgba(3, 7, 13, 0.58);
  overflow: hidden;
}

.factory-preview-stage .ship-proc-preview {
  width: min(100%, 360px);
  min-height: 180px;
  background: transparent;
  border: 0;
}

.factory-architect-preview {
  width: min(100%, 340px);
  min-height: 190px;
  display: block;
}

.factory-preview-stats,
.factory-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

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

.factory-production-grid {
  display: grid;
  gap: 10px;
}

.factory-production-grid .factory-parts-checklist {
  padding: 10px;
}

.factory-part-requirement {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(237, 243, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.factory-part-requirement.ready {
  border-color: rgba(117, 255, 173, 0.22);
  background: rgba(117, 255, 173, 0.055);
}

.factory-part-requirement.missing {
  border-color: rgba(255, 144, 144, 0.24);
  background: rgba(255, 144, 144, 0.055);
}

.factory-part-requirement strong {
  display: block;
  color: #edf3ff;
  font-size: 13px;
}

.factory-part-count {
  min-width: 74px;
  padding: 5px 8px;
  border-radius: 999px;
  text-align: center;
  font-weight: 800;
  background: rgba(6, 12, 20, 0.44);
  border: 1px solid rgba(237, 243, 255, 0.12);
}

.factory-assembly-action {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 860px) {
  .factory-assembly-bay,
  .factory-preview-stats,
  .factory-control-grid {
    grid-template-columns: 1fr;
  }
}

.ship-owned-card:hover,
.ship-owned-card.active {
  border-color: rgba(143, 183, 223, 0.48);
  background: rgba(143, 183, 223, 0.08);
}

.factory-hull-card:hover,
.factory-part-card:hover {
  border-color: rgba(237, 243, 255, 0.12);
  background: rgba(255, 255, 255, 0.045);
}

@media (max-width: 720px) {
  .factory-hull-card {
    grid-column: 1 / -1;
  }

  .factory-hull-card .data-grid,
  .factory-part-card .data-grid {
    grid-template-columns: 1fr;
  }

  .factory-hull-card .data-cell:nth-child(2),
  .factory-part-card .data-cell:nth-child(2) {
    grid-row: auto;
  }
}

.ship-inspector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.shipyard-compact-note {
  border: 1px solid rgba(237, 243, 255, 0.1);
  border-radius: 8px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.035);
}

.ship-designer-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(242, 138, 58, 0.34);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 24%, rgba(242, 138, 58, 0.13), transparent 34%),
    linear-gradient(145deg, rgba(19, 25, 38, 0.98), rgba(7, 11, 19, 0.98));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.ship-designer-head,
.ship-designer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ship-designer-head h4 {
  margin: 0;
  font-size: 18px;
}

.ship-designer-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(340px, 1.15fr) minmax(260px, 0.9fr);
  gap: 10px;
}

.ship-slot-board,
.ship-module-bay,
.ship-loadout-bay {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 10px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.ship-slot {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 9px;
  border: 1px solid rgba(143, 183, 223, 0.18);
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(24, 34, 52, 0.9), rgba(12, 17, 27, 0.88));
}

.ship-slot strong,
.ship-module-card strong {
  font-size: 13px;
}

.ship-module-card {
  display: grid;
  gap: 5px;
  padding: 8px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 7px;
  background: rgba(6, 12, 20, 0.28);
}

.ship-designer-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.ship-loadout-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px;
  border: 1px solid rgba(237, 243, 255, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
}

.ship-designer-panel {
  max-width: 1160px;
  margin: 0 auto 10px;
}

.ship-designer-grid {
  grid-template-columns: minmax(390px, 1.2fr) minmax(260px, 0.8fr) minmax(240px, 0.72fr);
}

.ship-fitting-rig {
  min-height: 460px;
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(143, 183, 223, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 46%, rgba(143, 183, 223, 0.18), transparent 26%),
    radial-gradient(circle at 50% 50%, rgba(242, 138, 58, 0.09), transparent 52%),
    rgba(3, 8, 15, 0.46);
  overflow: hidden;
}

.ship-fitting-rig::before {
  content: "";
  position: absolute;
  width: 355px;
  height: 355px;
  border: 2px solid rgba(143, 183, 223, 0.12);
  border-radius: 50%;
  box-shadow: inset 0 0 0 18px rgba(143, 183, 223, 0.035), 0 0 32px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.ship-hull-silhouette {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 260px;
  height: 230px;
}

.ship-slot-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ship-slot {
  position: absolute;
  width: 54px;
  height: 54px;
  min-height: 54px;
  display: grid;
  place-items: center;
  padding: 4px;
  border: 1px dashed rgba(143, 183, 223, 0.42);
  border-radius: 7px;
  background: rgba(3, 8, 15, 0.72);
  box-shadow: inset 0 0 16px rgba(143, 183, 223, 0.08);
  pointer-events: auto;
}

.ship-slot.filled {
  border-style: solid;
  border-color: rgba(242, 138, 58, 0.58);
  background: linear-gradient(145deg, rgba(67, 46, 32, 0.88), rgba(11, 16, 25, 0.86));
}

.ship-slot.drop-hover {
  border-color: #9ed4ff;
  box-shadow: 0 0 18px rgba(117, 186, 255, 0.3);
}

.ship-slot strong {
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ship-slot span {
  display: none;
}

.ship-slot button {
  min-height: 18px;
  padding: 0 4px;
  font-size: 9px;
}

.ship-slot[data-slot-pos="engine"] { left: 50%; top: 18px; transform: translateX(-50%); }
.ship-slot[data-slot-pos="weapon"] { right: 58px; top: 88px; }
.ship-slot[data-slot-pos="armor"] { right: 58px; bottom: 88px; }
.ship-slot[data-slot-pos="shield"] { left: 58px; bottom: 88px; }
.ship-slot[data-slot-pos="utility"] { left: 58px; top: 88px; }
.ship-slot[data-slot-pos="custom"] {
  left: var(--slot-x);
  top: var(--slot-y);
  transform: translate(-50%, -50%);
}

.module-storage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 7px;
}

.ship-module-card {
  min-height: 54px;
  padding: 5px;
  border: 1px dashed rgba(237, 243, 255, 0.18);
  border-radius: 7px;
  background: rgba(3, 8, 15, 0.55);
  cursor: grab;
}

.ship-module-card:active {
  cursor: grabbing;
}

.ship-module-card strong {
  display: block;
  font-size: 10px;
  text-align: center;
}

.ship-module-card span {
  display: none;
}

.ship-module-card button {
  display: none;
}

.ship-defense-readout {
  display: grid;
  gap: 5px;
  padding: 8px;
  border: 1px solid rgba(237, 243, 255, 0.1);
  border-radius: 7px;
  background: rgba(3, 8, 15, 0.38);
}

.ship-defense-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.ship-defense-row span:last-child {
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(242, 138, 58, 0.85), rgba(143, 183, 223, 0.65));
  width: var(--hp-fill);
  max-width: 100%;
}

.ship-design-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.25fr);
  gap: 10px;
  grid-column: 1 / -1;
}

.ship-design-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.ship-design-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.9fr) minmax(0, 1.3fr);
  min-height: 33px;
  border-bottom: 1px solid rgba(237, 243, 255, 0.08);
}

.ship-design-row:last-child {
  border-bottom: 0;
}

.ship-design-row > div {
  padding: 7px 9px;
  overflow-wrap: anywhere;
}

.ship-design-row > div:first-child {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.ship-design-controls {
  display: grid;
  gap: 8px;
  align-content: start;
}

.ship-design-controls .data-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 980px) {
  .ship-design-layout {
    grid-template-columns: 1fr;
  }

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

.fleet-name-cell {
  display: grid;
  gap: 6px;
}

.fleet-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fleet-edit select {
  width: 116px;
  height: 28px;
  min-height: 28px;
  padding: 3px 7px;
  font-size: 11px;
}

.fleet-orders-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.fleet-orders-grid .data-cell {
  display: grid;
  gap: 5px;
  align-content: start;
}

.fleet-orders-grid select,
.fleet-orders-grid input {
  width: 100%;
}

.fleet-orders-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.cargo-route-builder {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(85, 190, 255, 0.25);
  border-radius: 8px;
  background: rgba(31, 104, 148, 0.08);
}

.cargo-route-stop {
  display: grid;
  grid-template-columns: 36px minmax(180px, 0.9fr) minmax(320px, 1.7fr) auto;
  gap: 7px;
  align-items: end;
  padding: 8px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 7px;
  background: rgba(4, 9, 16, 0.32);
}

.cargo-route-stop-number {
  align-self: center;
  color: #9edbff;
  font-size: 17px;
  font-weight: 900;
  text-align: center;
}

.cargo-route-stop label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.cargo-route-stop select,
.cargo-route-stop input {
  width: 100%;
}

.cargo-route-loads {
  display: grid;
  gap: 6px;
}

.cargo-route-load-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(90px, 0.5fr) auto;
  gap: 6px;
  align-items: end;
}

.cargo-route-load-row button,
.cargo-route-add-load {
  height: 36px;
}

.cargo-route-options {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.cargo-route-options label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.cargo-route-options input {
  width: auto;
}

.cargo-route-summary {
  display: grid;
  gap: 6px;
  margin-top: 9px;
  padding: 9px;
  border: 1px solid rgba(70, 211, 142, 0.22);
  border-radius: 7px;
  background: rgba(70, 211, 142, 0.06);
}

@media (max-width: 900px) {
  .cargo-route-stop {
    grid-template-columns: 32px 1fr;
  }

  .cargo-route-stop > :not(.cargo-route-stop-number) {
    grid-column: 2;
  }
}

.fleet-scan-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 7px;
}

.fleet-scan-actions button {
  height: 26px;
  min-height: 26px;
  padding: 2px 8px;
  font-size: 11px;
}

.fleet-status-button {
  width: 100%;
  height: 28px;
  min-height: 28px;
  margin-top: 6px;
  padding: 3px 7px;
  font-size: 11px;
}

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

.fleet-card {
  display: grid;
  grid-template-columns: minmax(180px, 1.15fr) minmax(180px, 1fr) minmax(180px, 1.2fr) minmax(220px, auto);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.fleet-card-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.fleet-card-main strong,
.fleet-card-location strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fleet-card-status {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.fleet-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(242, 138, 58, 0.36);
  border-radius: 999px;
  background: rgba(242, 138, 58, 0.11);
  color: #ffd0a6;
  font-size: 11px;
  font-weight: 800;
}

.fleet-card-location,
.fleet-card-cargo {
  display: grid;
  gap: 5px;
  min-width: 0;
  font-size: 12px;
}

.fleet-battle-log {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(255, 94, 94, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 94, 94, 0.10), rgba(9, 14, 24, 0.72));
}

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

.fleet-battle-side {
  display: grid;
  gap: 5px;
  padding: 7px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 6px;
  background: rgba(5, 9, 16, 0.42);
  font-size: 11px;
}

.fleet-battle-side header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.battle-hp-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 74px;
  align-items: center;
  gap: 7px;
  color: #aeb9c8;
}

.battle-hp-meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
}

.battle-hp-meter span {
  display: block;
  width: var(--battle-fill, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--battle-color, #8bd4ff);
}

.fleet-battle-events {
  display: grid;
  gap: 3px;
  color: #c3ccd9;
  font-size: 11px;
  line-height: 1.35;
}

.fleet-battle-details {
  border: 1px solid rgba(237, 243, 255, 0.10);
  border-radius: 7px;
  background: rgba(5, 9, 16, 0.34);
  overflow: hidden;
}

.fleet-battle-details summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  color: #ffd0a6;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  list-style: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.fleet-battle-details summary::-webkit-details-marker {
  display: none;
}

.battle-ship-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border-top: 1px solid rgba(237, 243, 255, 0.08);
}

.battle-ship-list {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

.battle-ship-list h5 {
  margin: 0 0 2px;
  color: #edf3ff;
  font-size: 11px;
}

.battle-ship-row {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) 36px minmax(0, 1.2fr);
  gap: 7px;
  align-items: center;
  padding: 5px 6px;
  border: 1px solid rgba(237, 243, 255, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 10px;
}

.battle-ship-row.destroyed {
  border-color: rgba(255, 94, 94, 0.26);
  background: rgba(255, 94, 94, 0.08);
  color: #ffb2aa;
}

.battle-ship-row strong,
.battle-ship-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-mini-bars {
  display: grid;
  gap: 3px;
}

.battle-mini-bar {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
}

.battle-mini-bar span {
  display: block;
  width: var(--mini-fill, 0%);
  height: 100%;
  background: var(--mini-color, #8bd4ff);
  border-radius: inherit;
}

.cargo-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.cargo-meter span {
  display: block;
  height: 100%;
  width: var(--cargo-fill, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, #f28a3a, #ffd0a6);
}

.fleet-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.fleet-card-actions button {
  min-width: 70px;
}

.market-price {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.market-row .ticker {
  max-width: 100%;
  margin-left: 0;
  padding: 2px 5px;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.market-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

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

.research-energy-field {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.research-energy-field > span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
}

.progress-fill {
  height: 100%;
  width: var(--progress, 0%);
  background: var(--teal);
}

.research-progress-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(242, 138, 58, 0.28);
  background:
    radial-gradient(circle at 35% 0%, rgba(242, 138, 58, 0.16), transparent 42%),
    rgba(255, 255, 255, 0.055);
}

.research-progress-card h4 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.research-progress-card .progress-track,
.top-research .progress-track {
  height: 9px;
  border-color: rgba(242, 138, 58, 0.34);
  background: rgba(4, 7, 12, 0.72);
}

.research-progress-card .progress-fill,
.top-research .progress-fill {
  background: linear-gradient(90deg, #f28a3a, #ffd0a6);
  box-shadow: 0 0 16px rgba(242, 138, 58, 0.58);
}

#topFactory .progress-track {
  border-color: rgba(108, 190, 255, 0.36);
}

#topFactory .progress-fill {
  background: linear-gradient(90deg, #58b8ff, #bde8ff);
  box-shadow: 0 0 16px rgba(88, 184, 255, 0.5);
}

.auth-window {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  width: min(320px, calc(100vw - 28px));
  display: none;
  border-radius: 8px;
  padding: 12px;
  transform: translate(-50%, -50%);
  resize: both;
  min-width: 280px;
  min-height: 210px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  overflow: auto;
  pointer-events: auto;
}

.auth-window.open {
  display: grid;
  gap: 8px;
}

.auth-window h2 {
  cursor: move;
  text-align: center;
  font-size: 22px;
}

#authPanel {
  position: fixed;
  inset: 0;
  left: 0;
  top: 0;
  z-index: 20000;
  width: 100vw;
  height: 100vh;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
  resize: none;
  transform: none;
  backdrop-filter: none;
}

#authPanel .drag-handle,
#authPanel .auth-window h2 {
  cursor: default;
}

#authPanel::before {
  content: none;
}

#authPanel.open {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  justify-items: center;
}

.auth-page {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr;
  place-items: center;
  padding: clamp(18px, 3vw, 38px);
  background: #000;
}

.auth-hero {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  width: min(1420px, 116%);
  padding: 4px 0 0;
  cursor: default;
  grid-area: 1 / 1;
  align-self: start;
  margin-top: clamp(-82px, -6vh, -34px);
}

.auth-image-card {
  position: relative;
  width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 0;
  background: #000;
}

.auth-image-card img {
  position: relative;
  z-index: 2;
  display: none;
  width: 100%;
  height: auto;
  max-height: min(78vh, 900px);
  object-fit: contain;
}

.auth-image-card .auth-emblem {
  display: none;
}

.auth-image-card.has-photo img {
  display: block;
}

.auth-image-card.has-photo .auth-emblem {
  display: none;
}

.auth-emblem {
  position: relative;
  width: min(500px, 74vw);
  aspect-ratio: 1.75 / 1;
  display: grid;
  place-items: center;
}

.auth-emblem::before {
  content: "";
  position: absolute;
  width: 52%;
  aspect-ratio: 1;
  border: 4px solid rgba(196, 224, 245, 0.5);
  border-bottom-color: rgba(244, 113, 45, 0.74);
  border-radius: 50%;
  box-shadow: inset 0 0 24px rgba(80, 168, 255, 0.18), 0 0 38px rgba(80, 168, 255, 0.16);
}

.auth-spire {
  position: absolute;
  top: 4%;
  left: 50%;
  width: 18px;
  height: 44%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #75899d, #f4fbff 45%, #70849a);
  clip-path: polygon(50% 0, 82% 26%, 82% 100%, 18% 100%, 18% 26%);
  box-shadow: 0 0 24px rgba(160, 210, 255, 0.45);
}

.auth-mark {
  position: absolute;
  top: 43%;
  left: 50%;
  width: 33%;
  height: 8px;
  transform-origin: center;
  background: linear-gradient(90deg, transparent, #f5fbff 18%, #f4712d 52%, #f5fbff 84%, transparent);
  box-shadow: 0 0 18px rgba(244, 113, 45, 0.7);
}

.auth-mark.one { transform: translate(-50%, -50%) rotate(43deg); }
.auth-mark.two { transform: translate(-50%, -50%) rotate(-43deg); }

.auth-title {
  position: relative;
  z-index: 1;
  margin-top: 72px;
  font-size: clamp(54px, 12vw, 112px);
  line-height: 0.82;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f1f6fb;
  text-shadow: 0 2px 0 #748596, 0 0 28px rgba(120, 196, 255, 0.35), 0 0 52px rgba(244, 113, 45, 0.18);
}

.auth-title .x {
  color: #fff7ec;
  text-shadow: 0 0 14px rgba(244, 113, 45, 0.96), 0 0 34px rgba(244, 113, 45, 0.7);
}

.auth-tagline {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  color: #9fc0dc;
  font-size: 14px;
  letter-spacing: 0.46em;
  text-transform: uppercase;
  text-align: center;
}

.auth-form {
  position: relative;
  z-index: 4;
  grid-area: 1 / 1;
  align-self: end;
  margin-bottom: clamp(4px, 1.2vh, 18px);
  display: grid;
  gap: 10px;
  padding: 16px;
  width: min(470px, calc(100vw - 36px));
  justify-self: center;
  border: 1px solid rgba(160, 210, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.64);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
}

#authPanel.registering .auth-form,
#authPanel.registering .auth-server-status,
#authPanel.registering .auth-discord-link {
  display: none;
}

#authPanel.registering {
  pointer-events: none;
}

.auth-form h3 {
  margin: 0;
  color: #edf3ff;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

.auth-server-switcher {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 4px;
  width: fit-content;
  padding: 3px 5px;
  border: 1px solid rgba(160, 210, 255, 0.16);
  border-radius: 7px;
  background: rgba(7, 18, 29, 0.72);
}

.auth-server-switcher > span {
  padding: 0 3px;
  color: rgba(203, 222, 239, 0.72);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

.auth-server-choice {
  display: grid;
  place-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(160, 210, 255, 0.22);
  border-radius: 6px;
  color: #b7c8d8;
  background: rgba(237, 243, 255, 0.06);
  font-size: 10px;
  font-weight: 750;
  text-decoration: none;
}

.auth-server-choice:hover,
.auth-server-choice:focus-visible {
  border-color: rgba(160, 210, 255, 0.52);
  color: #fff;
  outline: none;
}

.auth-server-choice.active {
  border-color: rgba(116, 255, 155, 0.62);
  color: #b9ffcd;
  background: rgba(49, 151, 86, 0.18);
  box-shadow: inset 0 0 16px rgba(49, 151, 86, 0.1);
  pointer-events: none;
}

body.environment-test .auth-server-choice.active {
  border-color: rgba(255, 171, 76, 0.72);
  color: #ffd6a6;
  background: rgba(194, 91, 20, 0.2);
  box-shadow: inset 0 0 16px rgba(242, 138, 58, 0.14);
}

.environment-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(255, 163, 72, 0.78);
  border-radius: 6px;
  color: #fff0dd;
  background: linear-gradient(180deg, rgba(208, 92, 22, 0.9), rgba(123, 39, 11, 0.94));
  box-shadow: 0 0 18px rgba(242, 108, 40, 0.3);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.environment-badge[hidden] {
  display: none;
}

.auth-fields {
  display: grid;
  gap: 8px;
}

#authPanel input {
  height: 42px;
  border-color: rgba(160, 210, 255, 0.22);
  background: rgba(0, 0, 0, 0.62) !important;
  color: #edf3ff;
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.62);
}

#authPanel input:-webkit-autofill,
#authPanel input:-webkit-autofill:hover,
#authPanel input:-webkit-autofill:focus,
.register-panel input:-webkit-autofill,
.register-panel input:-webkit-autofill:hover,
.register-panel input:-webkit-autofill:focus {
  -webkit-text-fill-color: #edf3ff;
  caret-color: #edf3ff;
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.88);
  transition: background-color 9999s ease-in-out 0s;
}

#authPanel .auth-actions button {
  height: 42px;
  border-color: rgba(160, 210, 255, 0.24);
  background: rgba(237, 243, 255, 0.1);
}

#authPanel .auth-actions button:first-child {
  border-color: rgba(242, 138, 58, 0.72);
  background: linear-gradient(180deg, rgba(242, 138, 58, 0.28), rgba(131, 56, 22, 0.42));
  box-shadow: 0 0 18px rgba(242, 138, 58, 0.18), inset 0 1px 0 rgba(255, 231, 210, 0.16);
  color: #fff4e9;
}

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

.auth-server-status {
  position: relative;
  z-index: 4;
  grid-area: 1 / 1;
  align-self: end;
  margin-bottom: 2px;
  color: #74ff9b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 0 12px rgba(82, 255, 139, 0.3);
}

.auth-discord-link {
  position: relative;
  z-index: 5;
  grid-area: 1 / 1;
  align-self: end;
  justify-self: center;
  width: 168px;
  margin-bottom: 12px;
  transform: translateX(340px);
  opacity: 0.86;
  transition: opacity 160ms ease, transform 160ms ease, filter 160ms ease;
}

.auth-discord-link:hover,
.auth-discord-link:focus-visible {
  opacity: 1;
  transform: translateX(340px) translateY(-2px);
  filter: drop-shadow(0 0 12px rgba(88, 101, 242, 0.65));
  outline: none;
}

.auth-discord-link img {
  display: block;
  width: 100%;
  height: auto;
}

.register-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 20001;
  width: min(430px, calc(100vw - 32px));
  display: none;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(242, 138, 58, 0.35);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.62), 0 0 36px rgba(242, 138, 58, 0.14);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.register-panel.open {
  display: grid;
  pointer-events: auto;
}

.register-panel h3 {
  margin: 0;
  text-align: center;
  color: #edf3ff;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 15px;
}

.register-panel p {
  margin: 0;
}

.register-panel input {
  height: 42px;
  border-color: rgba(160, 210, 255, 0.22);
  background: rgba(0, 0, 0, 0.62) !important;
  color: #edf3ff;
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.62);
}

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

.register-actions button:first-child {
  border-color: rgba(242, 138, 58, 0.72);
  background: linear-gradient(180deg, rgba(242, 138, 58, 0.28), rgba(131, 56, 22, 0.42));
  color: #fff4e9;
}

@media (max-width: 620px) {
  .auth-page {
    padding: 12px;
  }

  .auth-image-card img {
    max-height: 42vh;
  }

  .auth-form {
    align-self: end;
    margin-bottom: 28px;
  }

  .auth-discord-link {
    align-self: start;
    justify-self: end;
    width: 136px;
    margin: 10px 4px 0 0;
    transform: none;
  }

  .auth-discord-link:hover,
  .auth-discord-link:focus-visible {
    transform: translateY(-2px);
  }
}

.sync-overlay {
  position: fixed;
  inset: 0;
  z-index: 30000;
  display: none;
  place-items: center;
  padding: 28px;
  background: #000;
  pointer-events: auto;
}

.sync-overlay.open {
  display: grid;
}

.sync-card {
  width: min(620px, calc(100vw - 48px));
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.sync-card img {
  width: min(520px, 86vw);
  height: auto;
  object-fit: contain;
}

.sync-black-hole {
  position: relative;
  isolation: isolate;
  width: 154px;
  height: 92px;
  filter: drop-shadow(0 0 22px rgba(255, 105, 30, 0.2));
  animation: syncBlackHolePulse 2.8s ease-in-out infinite;
}

.sync-disk {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 150px;
  height: 31px;
  border-radius: 50%;
  background:
    linear-gradient(90deg,
      transparent 0%,
      rgba(49, 119, 194, 0.16) 9%,
      rgba(255, 87, 20, 0.76) 27%,
      #ffd38a 42%,
      #fff9df 49%,
      #ffb14f 57%,
      rgba(238, 68, 18, 0.72) 75%,
      rgba(44, 116, 191, 0.14) 91%,
      transparent 100%);
  background-size: 210% 100%;
  transform: translate(-50%, -50%) rotate(-9deg);
  animation: syncAccretionFlow 1.55s linear infinite;
}

.sync-disk-back {
  z-index: 1;
  filter: blur(2px);
  box-shadow:
    0 0 10px rgba(255, 164, 72, 0.7),
    0 0 26px rgba(255, 75, 20, 0.42),
    0 0 38px rgba(45, 125, 207, 0.2);
}

.sync-lensing {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 68px;
  height: 68px;
  border: 2px solid rgba(255, 239, 195, 0.86);
  border-right-color: rgba(255, 112, 34, 0.42);
  border-bottom-color: rgba(86, 160, 226, 0.28);
  border-radius: 50%;
  box-shadow:
    0 0 5px rgba(255, 243, 210, 0.88),
    0 0 14px rgba(255, 117, 32, 0.62),
    inset 0 0 9px rgba(62, 133, 202, 0.24);
  transform: translate(-50%, -50%);
  animation: syncPhotonRing 3.2s linear infinite;
}

.sync-horizon {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: 61px;
  height: 61px;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 38%, #080a0d 0%, #010101 42%, #000 72%);
  box-shadow:
    inset -7px -5px 12px #000,
    0 0 0 2px rgba(0, 0, 0, 0.96),
    0 0 18px rgba(0, 0, 0, 0.96);
  transform: translate(-50%, -50%);
}

.sync-horizon::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #000;
  box-shadow: inset 3px 2px 8px rgba(16, 23, 31, 0.34);
}

.sync-disk-front {
  z-index: 4;
  clip-path: inset(49% 0 0 0);
  height: 25px;
  filter: blur(0.6px) brightness(1.15);
  opacity: 0.92;
  box-shadow: 0 5px 12px rgba(255, 105, 28, 0.48);
}

.sync-title {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff4e9;
}

.sync-status {
  color: var(--muted);
  font-size: 13px;
}

@keyframes syncBlackHolePulse {
  0%, 100% { transform: scale(0.98); filter: brightness(0.9); }
  50% { transform: scale(1.025); filter: brightness(1.1); }
}

@keyframes syncAccretionFlow {
  from { background-position: 100% 50%; }
  to { background-position: -90% 50%; }
}

@keyframes syncPhotonRing {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 9;
  max-width: min(520px, calc(100vw - 28px));
  min-height: 34px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast.show {
  display: flex;
}

.tutorial-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  z-index: 18;
  width: min(420px, calc(100vw - 32px));
  height: fit-content;
  transform: translate(-50%, -50%);
  display: none;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(242, 138, 58, 0.42);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38), inset 0 0 28px rgba(242, 138, 58, 0.05);
  backdrop-filter: blur(16px);
  overflow: visible;
  pointer-events: auto;
  resize: none;
}

.tutorial-panel.welcome {
  width: min(590px, calc(100vw - 32px));
  padding: 18px;
  min-height: 0;
  height: auto;
}

.tutorial-panel.tutorial-active {
  left: 18px;
  top: 86px;
  right: auto;
  width: min(390px, calc(100vw - 32px));
  transform: none;
  border-color: rgba(85, 210, 255, 0.5);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42), inset 0 0 28px rgba(85, 210, 255, 0.06);
}

.tutorial-panel.tutorial-console {
  right: auto;
  left: min(620px, calc(100vw - 408px));
  top: 96px;
}

.tutorial-panel.open {
  display: flex;
  flex-direction: column;
}

.tutorial-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.tutorial-head h3 {
  margin: 0;
  font-size: 26px;
  line-height: 1.08;
}

.tutorial-panel.tutorial-active .tutorial-head h3 {
  font-size: 24px;
}

.tutorial-panel .muted {
  font-size: 15px;
  line-height: 1.55;
}

.tutorial-keyword {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid rgba(85, 210, 255, 0.55);
  border-radius: 5px;
  background: rgba(85, 210, 255, 0.12);
  color: #c7f4ff;
  font-weight: 800;
  line-height: 1.25;
  vertical-align: baseline;
  white-space: nowrap;
}

.tutorial-close {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
}

.tutorial-steps {
  display: grid;
  gap: 7px;
  margin-top: 6px;
}

.tutorial-step {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.tutorial-step-dot {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(237, 243, 255, 0.16);
  border-radius: 999px;
  color: rgba(237, 243, 255, 0.72);
  font-size: 11px;
  font-weight: 800;
}

.tutorial-step.active {
  color: #fff4e9;
}

.tutorial-step.active .tutorial-step-dot {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: #ffd0a6;
}

.tutorial-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.tutorial-actions button {
  min-width: 124px;
  max-width: 100%;
}

.tutorial-actions button.primary {
  border-color: rgba(242, 138, 58, 0.78);
  background: linear-gradient(180deg, rgba(242, 138, 58, 0.24), rgba(242, 138, 58, 0.1));
  color: #fff4e9;
}

.tutorial-target-highlight {
  position: relative;
  border-color: rgba(85, 210, 255, 0.86) !important;
  box-shadow: 0 0 0 2px rgba(85, 210, 255, 0.26), 0 0 22px rgba(85, 210, 255, 0.28) !important;
  animation: tutorialPulse 1.45s ease-in-out infinite;
}

.tutorial-ui-region-highlight {
  outline: 2px solid rgba(85, 210, 255, 0.9) !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(85, 210, 255, 0.16), 0 0 28px rgba(85, 210, 255, 0.3) !important;
}

.tutorial-console-highlight {
  position: relative;
  outline: 2px solid rgba(103, 246, 255, 0.95) !important;
  border-color: rgba(103, 246, 255, 0.95) !important;
  background: linear-gradient(135deg, rgba(85, 210, 255, 0.18), rgba(255, 183, 92, 0.1)) !important;
  box-shadow: 0 0 0 4px rgba(85, 210, 255, 0.2), 0 0 34px rgba(85, 210, 255, 0.5) !important;
  animation: tutorialPulse 1.45s ease-in-out infinite;
}

.tutorial-console-highlight::before {
  content: "Tutorial focus";
  position: absolute;
  top: -11px;
  right: 10px;
  z-index: 2;
  padding: 2px 7px;
  border: 1px solid rgba(103, 246, 255, 0.88);
  border-radius: 999px;
  background: rgba(5, 12, 20, 0.96);
  color: #c7faff;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
}

@keyframes tutorialPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

.solar-orbit-view {
  position: relative;
  height: 230px;
  margin-bottom: 10px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 8px;
  background: radial-gradient(circle at 48% 42%, rgba(143, 183, 223, 0.16), rgba(242, 138, 58, 0.08) 34%, rgba(6, 10, 17, 0.72) 62%, rgba(2, 3, 5, 0.3));
  overflow: hidden;
  cursor: grab;
}

.solar-orbit-view:active {
  cursor: grabbing;
}

.solar-orbit-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.dyson-view {
  height: 320px;
  border: 1px solid rgba(160, 210, 255, 0.14);
  border-radius: 8px;
  background: radial-gradient(circle at center, rgba(242, 138, 58, 0.16), rgba(5, 8, 14, 0.92) 62%);
  overflow: hidden;
  box-shadow: inset 0 0 34px rgba(64, 142, 214, 0.08);
}

.dyson-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.dyson-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.dyson-controls input[type="range"] {
  width: 100%;
  min-height: 34px;
  cursor: grab;
  touch-action: pan-y;
}

.dyson-controls input[type="range"]:active {
  cursor: grabbing;
}

.chat-panel {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: min(340px, calc(100vw - 28px));
  height: 220px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 35;
  pointer-events: auto;
}

.chat-panel.minimized {
  display: none;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.chat-tabs {
  display: flex;
  gap: 4px;
}

.chat-tabs button {
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.chat-tabs button.active {
  border-color: rgba(242, 138, 58, 0.78);
  color: #ffd0a6;
  background: rgba(242, 138, 58, 0.18);
}

.chat-context {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-main {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 88px;
}

.chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 7px;
  border-right: 1px solid rgba(237, 243, 255, 0.08);
}

.chat-message {
  margin-bottom: 6px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chat-message strong {
  color: #ffd0a6;
  font-size: 12px;
}

.chat-message span {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

.chat-users {
  min-height: 0;
  overflow-y: auto;
  padding: 7px;
  background: rgba(255, 255, 255, 0.025);
}

.chat-users h4 {
  margin: 0 0 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-user {
  padding: 4px 0;
  font-size: 12px;
  color: var(--text);
  border-bottom: 1px solid rgba(237, 243, 255, 0.05);
  overflow-wrap: anywhere;
  cursor: context-menu;
  user-select: none;
}

.chat-user:hover {
  color: #ffd0a6;
}

.chat-context-menu {
  position: fixed;
  z-index: 240;
  display: none;
  min-width: 170px;
  padding: 6px;
  border: 1px solid rgba(242, 138, 58, 0.45);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.chat-context-menu.open {
  display: grid;
  gap: 5px;
}

.chat-context-menu button {
  justify-content: flex-start;
  min-height: 32px;
  padding: 6px 9px;
  text-align: left;
}

.contacts-shell {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 10px;
  min-height: 0;
  height: 100%;
}

#contactsPanel {
  width: min(720px, calc(100vw - 28px));
  height: min(500px, calc(100vh - 116px));
  min-width: min(560px, calc(100vw - 28px));
  min-height: 320px;
  bottom: auto;
}

#contactsPanel .drawer-body {
  min-height: 0;
  overflow: auto;
}

.contacts-sidebar {
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 10px;
  border-right: 1px solid rgba(237, 243, 255, 0.1);
}

.contacts-tabs,
.contacts-filter-list {
  display: grid;
  gap: 6px;
}

.contacts-tab,
.contacts-filter {
  justify-content: space-between;
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 12px;
}

.contacts-tab.active,
.contacts-filter.active {
  border-color: rgba(242, 138, 58, 0.75);
  background: rgba(242, 138, 58, 0.16);
  color: #ffd0a6;
}

.contacts-main {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.contacts-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.contacts-search {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 7px 9px;
}

.contacts-list {
  display: grid;
  gap: 6px;
  align-content: start;
}

@media (max-width: 640px) {
  #contactsPanel {
    width: calc(100vw - 28px);
    min-width: 0;
    height: min(520px, calc(100vh - 158px));
  }

  .contacts-shell {
    grid-template-columns: 120px minmax(0, 1fr);
  }
}

.contact-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(237, 243, 255, 0.13);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.contact-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(122, 190, 255, 0.28);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 25%, rgba(167, 216, 255, 0.45), transparent 34px),
    linear-gradient(135deg, rgba(31, 68, 92, 0.85), rgba(12, 16, 24, 0.88));
  color: #dff3ff;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.contact-name {
  font-weight: 800;
  color: var(--text);
}

.contact-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.contact-standing {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.standing-pill {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 999px;
  border-color: rgba(237, 243, 255, 0.18);
  font-size: 11px;
}

.standing-pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.standing-pill.active[data-standing-choice="friendly"],
.standing-badge.friendly {
  border-color: rgba(70, 211, 142, 0.75);
  background: rgba(70, 211, 142, 0.16);
  color: #9af0c8;
}

.standing-pill.active[data-standing-choice="neutral"],
.standing-badge.neutral {
  border-color: rgba(156, 170, 190, 0.62);
  background: rgba(156, 170, 190, 0.12);
  color: #d9e3ef;
}

.standing-pill.active[data-standing-choice="enemy"],
.standing-badge.enemy {
  border-color: rgba(255, 94, 94, 0.72);
  background: rgba(255, 94, 94, 0.14);
  color: #ffaaa2;
}

.standing-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid rgba(237, 243, 255, 0.18);
  border-radius: 999px;
  font-size: 11px;
  text-transform: capitalize;
}

.places-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.place-card {
  padding: 10px;
  border: 1px solid rgba(237, 243, 255, 0.13);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.place-card h4 {
  margin: 0 0 4px;
  font-size: 13px;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 6px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
}

.chat-compose input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 7px 8px;
  font-size: 12px;
}

.chat-compose button {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.chat-minimize {
  min-height: 28px;
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 6px;
}

.chat-restore {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 80;
  display: none;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(242, 138, 58, 0.55);
  background: var(--panel-strong);
  color: #ffd0a6;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.chat-restore.show {
  display: block;
}

.chat-empty {
  color: var(--muted);
  padding: 8px 0;
  font-size: 12px;
}

.side-panel {
  position: absolute;
  top: 68px;
  right: 14px;
  max-height: calc(100vh - 148px);
  width: min(320px, calc(100vw - 28px));
  border-radius: 8px;
  overflow: hidden;
  resize: both;
  min-width: 280px;
  min-height: 260px;
  pointer-events: auto;
  display: grid;
  grid-template-rows: auto 1fr;
}

.panel-head {
  position: relative;
  padding: 10px 12px;
  background: var(--panel-strong);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.panel-head .panel-minimize {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  line-height: 1;
}

#detailsPanel.collapsed {
  height: auto !important;
  min-height: 0;
  resize: none;
  grid-template-rows: auto;
}

#detailsPanel.collapsed .panel-head {
  border-bottom: 0;
  padding-right: 44px;
}

#detailsPanel.collapsed .panel-head .muted,
#detailsPanel.collapsed .panel-head .star-class,
#detailsPanel.collapsed .panel-body {
  display: none;
}

.panel-head h2 {
  font-size: 22px;
  line-height: 1.15;
  margin-bottom: 4px;
}

.star-class {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(242, 138, 58, 0.14);
  color: #ffd0a6;
  border: 1px solid rgba(242, 138, 58, 0.36);
  font-size: 12px;
  margin-top: 6px;
}

.panel-body {
  overflow: auto;
  padding: 10px 12px 12px;
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.warp-gate-dashboard {
  display: grid;
  gap: 14px;
}

.warp-gate-hero {
  border: 1px solid rgba(242, 138, 58, 0.34);
  border-radius: 8px;
  padding: 12px;
  background:
    radial-gradient(circle at 18% 12%, rgba(242, 138, 58, 0.16), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025));
}

.warp-gate-title-row,
.warp-gate-section-row,
.warp-gate-material-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.warp-gate-title-row h4,
.warp-gate-fleet-card h4 {
  margin: 0;
}

.warp-gate-status-pill {
  flex: 0 0 auto;
  padding: 3px 8px;
  border: 1px solid rgba(242, 138, 58, 0.52);
  border-radius: 999px;
  color: #ffd0a6;
  background: rgba(242, 138, 58, 0.14);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.warp-gate-progress {
  height: 8px;
  margin: 12px 0 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.warp-gate-progress span {
  display: block;
  width: var(--fill, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f28a3a, #ffd0a6);
  box-shadow: 0 0 14px rgba(242, 138, 58, 0.44);
}

.warp-gate-section-row {
  margin-top: 2px;
}

.warp-gate-section-row h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.warp-gate-manifest-grid,
.warp-gate-contribution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.warp-gate-material-card,
.warp-gate-fleet-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: 9px;
  min-width: 0;
}

.warp-gate-material-card.complete {
  border-color: rgba(74, 216, 145, 0.36);
  background: rgba(74, 216, 145, 0.06);
}

.warp-gate-material-name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.warp-gate-material-count {
  color: #ffd0a6;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.warp-gate-material-meter {
  height: 6px;
  margin: 8px 0 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.warp-gate-material-meter span {
  display: block;
  width: var(--fill, 0%);
  height: 100%;
  background: linear-gradient(90deg, #5fb3ff, #ffd0a6);
}

.warp-gate-fleet-card {
  background:
    radial-gradient(circle at 0 0, rgba(95, 179, 255, 0.10), transparent 30%),
    rgba(255, 255, 255, 0.045);
}

.warp-gate-contribution-card {
  border: 1px solid rgba(237, 243, 255, 0.11);
  border-radius: 7px;
  padding: 7px;
  background: rgba(0, 0, 0, 0.12);
}

.warp-gate-contribution-card input {
  margin-top: 6px;
}

.data-cell,
.slot,
.planet {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
}

.data-cell {
  padding: 7px;
  min-width: 0;
}

.population-cell {
  width: 100%;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
  min-height: 0;
  line-height: 1.25;
}

.population-cell:hover {
  border-color: var(--accent-line);
  background: rgba(242, 138, 58, 0.09);
}

.colony-power-card h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.colony-power-card h4:hover {
  background: rgba(242, 138, 58, 0.09);
  color: #ffd0a6;
}

.colony-power-card h4::after {
  content: "+";
  margin-left: auto;
  color: var(--muted);
  font-weight: 900;
}

.colony-power-card.open h4::after {
  content: "-";
}

.population-label-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.population-label-line span:last-child {
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0;
  text-transform: none;
}

.population-breakdown {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(242, 138, 58, 0.32);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 0, rgba(242, 138, 58, 0.13), transparent 38%),
    rgba(255, 255, 255, 0.04);
}

.population-breakdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.population-breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 6px 7px;
  border: 1px solid rgba(237, 243, 255, 0.09);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.12);
}

.label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.value {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.inline-action {
  display: inline;
  width: auto;
  min-width: 0;
  height: auto;
  min-height: 0;
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffd0a6;
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.inline-form input {
  min-width: 0;
  flex: 1;
}

.inline-form button {
  width: auto;
  min-width: 70px;
}

.ticker {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  color: #ffd0a6;
  background: rgba(242, 138, 58, 0.09);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: 1px;
}

.ticker.down {
  border-color: rgba(242, 138, 58, 0.52);
  color: #ffd0a6;
  background: rgba(242, 138, 58, 0.1);
}

.ticker.up {
  border-color: rgba(255, 116, 116, 0.45);
  color: #ff9b9b;
  background: rgba(255, 116, 116, 0.1);
}

.section-title {
  margin: 14px 0 8px;
  font-size: 13px;
  color: #dbe6f8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.action-row {
  display: flex;
  gap: 8px;
  margin: 10px 0 4px;
}

.action-row button {
  width: 100%;
}

.outpost-deployment-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 10px 0 4px;
  padding: 9px;
  border: 1px solid rgba(242, 138, 58, 0.35);
  border-radius: 8px;
  background: rgba(8, 14, 22, 0.72);
}

.outpost-deployment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.outpost-deployment-head strong {
  color: #e7edf7;
  font-size: 13px;
}

.outpost-deployment-head span {
  flex: 0 0 auto;
  color: #ffd0a6;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.outpost-requirements {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.outpost-requirement {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.outpost-requirement-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(4, 9, 15, 0.8);
}

.outpost-requirement-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.outpost-requirement-copy {
  min-width: 0;
}

.outpost-requirement-copy strong,
.outpost-requirement-copy span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.outpost-requirement-copy strong {
  margin-bottom: 2px;
  color: #e4ecf8;
  font-size: 11px;
}

.outpost-requirement-copy span,
.outpost-deployment-status {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.outpost-deployment-status {
  margin: 0;
  padding: 6px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.outpost-deployment-status.ready {
  color: #9de2bd;
  background: rgba(77, 184, 125, 0.09);
}

.outpost-deployment-card > button {
  width: 100%;
}

.planet-market-button {
  border-color: rgba(121, 168, 255, 0.5);
  background: rgba(121, 168, 255, 0.16);
  color: #d9e6ff;
}

.planet-market-button:hover {
  border-color: rgba(121, 168, 255, 0.82);
  background: rgba(121, 168, 255, 0.24);
}

.build-group {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  margin: 10px 0 4px;
  background: rgba(255, 255, 255, 0.045);
}

.build-group strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: #dbe6f8;
}

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

.build-options button {
  width: 100%;
  min-height: 36px;
}

.sector-ops-list {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.sector-ops-row {
  display: grid;
  grid-template-columns: minmax(86px, 0.65fr) minmax(0, 1.25fr) minmax(92px, 0.75fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
}

.sector-ops-row.output-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.sector-building-row {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "main actions"
    "upkeep power";
  gap: 8px;
  align-items: stretch;
  background:
    linear-gradient(135deg, rgba(88, 181, 255, 0.06), rgba(242, 138, 58, 0.035)),
    rgba(255, 255, 255, 0.04);
}

.sector-building-main,
.sector-building-stat,
.sector-building-actions {
  min-width: 0;
}

.sector-building-main {
  display: grid;
  gap: 2px;
  align-content: center;
  grid-area: main;
}

.sector-building-main strong,
.sector-building-main .muted,
.sector-building-main .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sector-building-stat {
  display: grid;
  gap: 2px;
  align-content: center;
  padding: 5px 7px;
  border: 1px solid rgba(237, 243, 255, 0.09);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.sector-building-stat:nth-of-type(2) {
  grid-area: upkeep;
}

.sector-building-stat:nth-of-type(3) {
  grid-area: power;
}

.sector-building-stat strong {
  font-size: 11px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.sector-building-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  align-self: center;
}

.sector-ops-row strong {
  display: block;
  color: #edf3ff;
  font-size: 13px;
  font-weight: 750;
}

.sector-ops-row .muted,
.sector-ops-row span {
  min-width: 0;
}

.sector-ops-row button {
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
}

.sector-ops-row:not(.output-row) > div:last-child {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.sector-ops-row .production-power {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  flex: 0 0 28px;
}

.danger-button {
  border-color: rgba(255, 99, 99, 0.55);
  color: #ffd3d3;
  background:
    repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.34) 0 6px, rgba(120, 18, 18, 0.34) 6px 12px),
    rgba(120, 24, 24, 0.62);
}

.danger-button:hover {
  border-color: rgba(255, 130, 130, 0.85);
  background:
    repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.42) 0 6px, rgba(170, 30, 30, 0.42) 6px 12px),
    rgba(150, 28, 28, 0.72);
}

.build-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(3, 7, 12, 0.54);
  pointer-events: auto;
}

.build-modal.open {
  display: grid;
}

.click-choice-menu,
.sector-context-menu {
  position: fixed;
  z-index: 42;
  display: none;
  min-width: 180px;
  max-width: 260px;
  padding: 6px;
  border: 1px solid rgba(242, 138, 58, 0.45);
  border-radius: 7px;
  background: var(--panel-strong);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.46);
  pointer-events: auto;
}

.click-choice-menu {
  width: 168px;
  min-width: 168px;
  max-width: 168px;
  padding: 4px;
}

.click-choice-menu.open,
.sector-context-menu.open {
  display: grid;
  gap: 4px;
}

.click-choice-menu button,
.sector-context-menu button {
  min-height: 30px;
  justify-content: flex-start;
  text-align: left;
  border-color: rgba(237, 243, 255, 0.12);
  background: rgba(255, 255, 255, 0.045);
}

.sector-context-menu button {
  padding: 5px 8px;
}

.click-choice-menu button {
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 29px;
  padding: 5px 7px;
  overflow: hidden;
  box-sizing: border-box;
  white-space: normal;
}

.click-choice-menu button strong,
.click-choice-menu .click-choice-branch-trigger strong,
.click-choice-menu button .muted,
.click-choice-menu .click-choice-branch-trigger .muted {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.click-choice-menu button strong,
.click-choice-menu .click-choice-branch-trigger strong {
  font-size: 11px;
  line-height: 1.15;
}

.click-choice-menu button .muted,
.click-choice-menu .click-choice-branch-trigger .muted {
  margin-top: 2px;
  font-size: 9px;
  line-height: 1.1;
}

.click-choice-menu button:hover,
.sector-context-menu button:hover {
  border-color: rgba(242, 138, 58, 0.72);
  background: rgba(242, 138, 58, 0.14);
  color: #ffd0a6;
}

.click-choice-menu .click-choice-branch,
.sector-context-menu .sector-context-branch {
  position: relative;
}

.click-choice-menu .click-choice-branch::after,
.sector-context-menu .sector-context-branch::after {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 100%;
}

.click-choice-menu.submenu-left .click-choice-branch::after,
.sector-context-menu.submenu-left .sector-context-branch::after {
  right: auto;
  left: -8px;
}

.click-choice-menu .click-choice-branch-trigger,
.sector-context-menu .sector-context-branch-trigger {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 29px;
  padding: 5px 24px 5px 7px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-align: left;
  box-sizing: border-box;
}

.click-choice-menu .click-choice-branch-trigger::after,
.sector-context-menu .sector-context-branch-trigger::after {
  content: "›";
  position: absolute;
  right: 10px;
  top: 50%;
  color: #ffad66;
  font-size: 16px;
  line-height: 1;
  transform: translateY(-52%);
}

.click-choice-menu .click-choice-branch:hover > .click-choice-branch-trigger,
.click-choice-menu .click-choice-branch:focus-within > .click-choice-branch-trigger,
.sector-context-menu .sector-context-branch:hover > .sector-context-branch-trigger,
.sector-context-menu .sector-context-branch:focus-within > .sector-context-branch-trigger {
  border-color: rgba(242, 138, 58, 0.72);
  background: rgba(242, 138, 58, 0.14);
  color: #ffd0a6;
}

.click-choice-submenu,
.sector-context-submenu {
  position: absolute;
  left: calc(100% + 7px);
  top: -6px;
  z-index: 2;
  display: none;
  width: 184px;
  max-height: min(420px, calc(100vh - 20px));
  padding: 4px;
  overflow: visible;
  border: 1px solid rgba(242, 138, 58, 0.45);
  border-radius: 7px;
  background: var(--panel-strong);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.46);
  box-sizing: border-box;
}

.sector-context-submenu {
  width: 168px;
}

.click-choice-submenu::before,
.sector-context-submenu::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -8px;
  width: 8px;
}

.click-choice-menu.submenu-left .click-choice-submenu,
.sector-context-menu.submenu-left .sector-context-submenu {
  right: calc(100% + 7px);
  left: auto;
}

/* Each level chooses its own opening direction. Deep unit/action trees can
   otherwise fit their first submenu while later levels leave the screen. */
.click-choice-menu:not(.submenu-left) .click-choice-branch.submenu-open-left > .click-choice-submenu,
.sector-context-menu:not(.submenu-left) .sector-context-branch.submenu-open-left > .sector-context-submenu {
  right: calc(100% + 7px);
  left: auto;
}

.click-choice-menu:not(.submenu-left) .click-choice-branch.submenu-open-left > .click-choice-submenu::before,
.sector-context-menu:not(.submenu-left) .sector-context-branch.submenu-open-left > .sector-context-submenu::before {
  right: -8px;
  left: auto;
}

.click-choice-menu.submenu-left .click-choice-branch.submenu-open-right > .click-choice-submenu,
.sector-context-menu.submenu-left .sector-context-branch.submenu-open-right > .sector-context-submenu {
  right: auto;
  left: calc(100% + 7px);
}

.click-choice-menu.submenu-left .click-choice-branch.submenu-open-right > .click-choice-submenu::before,
.sector-context-menu.submenu-left .sector-context-branch.submenu-open-right > .sector-context-submenu::before {
  right: auto;
  left: -8px;
}

.click-choice-menu.submenu-left .click-choice-submenu::before,
.sector-context-menu.submenu-left .sector-context-submenu::before {
  right: -8px;
  left: auto;
}

.click-choice-branch:hover > .click-choice-submenu,
.click-choice-branch:focus-within > .click-choice-submenu,
.sector-context-branch:hover > .sector-context-submenu,
.sector-context-branch:focus-within > .sector-context-submenu {
  display: grid;
  gap: 4px;
}

#colonyPanel.sector-console-mode {
  width: min(520px, calc(100vw - 24px));
  height: min(575px, calc(100vh - 116px));
  bottom: auto;
}
#sectorLogisticsPanel {
  width: min(1050px, calc(100vw - 28px));
  height: min(610px, calc(100vh - 116px));
  bottom: auto;
}
#sectorLogisticsPanel .drawer-body,
#colonyPanel.sector-console-mode .drawer-body { min-height: 0; overflow: auto; }
.sector-console-shell { display: grid; gap: 10px; }
.sector-console-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.035); }
.sector-console-header h4 { margin: 0 0 3px; font-size: 16px; }
.sector-console-name { display:flex; align-items:center; gap:8px; }
.sector-console-name h4 { margin:0; }
.sector-console-name button { height:25px !important; min-height:25px !important; padding:0 8px !important; font-size:10px !important; }
.sector-rename-row { display:grid; grid-template-columns:minmax(150px,1fr) auto auto; gap:6px; margin-bottom:4px; }
.sector-rename-row input, .sector-rename-row button { height:30px !important; min-height:30px !important; }
.sector-status-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.sector-status-chip { padding: 4px 7px; border: 1px solid rgba(242,138,58,.38); border-radius: 999px; background: rgba(242,138,58,.1); font-size: 10px; }
.sector-console-tabs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; }
.sector-console-tabs button.active { border-color: #f28a3a; background: rgba(242,138,58,.17); color: #ffd6ae; }
.sector-summary-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.sector-summary-grid > article { display:grid; align-content:start; gap:4px; min-width:0; }
.sector-summary-grid > article > .label,
.sector-summary-grid > article > strong,
.sector-summary-grid > article > .muted { display:block; min-width:0; overflow-wrap:anywhere; }
.sector-summary-grid > article > strong { font-size:14px; line-height:1.25; }
.sector-storage-progress { display:grid; gap:7px; padding:10px; border:1px solid var(--line); border-radius:8px; background:rgba(255,255,255,.025); }
.sector-storage-progress > div:first-child { display:flex; justify-content:space-between; gap:10px; }
.sector-storage-progress .progress-track { height:8px; }
.sector-storage-progress p { margin:0; }
.sector-resource-groups { display:grid; gap:9px; }
.sector-resource-group { padding:9px; border:1px solid var(--line); border-radius:8px; background:rgba(255,255,255,.025); }
.sector-resource-group h5 { margin:0 0 7px; color:#b8c7da; text-transform:uppercase; letter-spacing:.08em; font-size:10px; }
.sector-resource-cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(112px,1fr)); gap:6px; }
.sector-resource-card { display:grid; grid-template-columns:34px minmax(0,1fr); gap:7px; align-items:center; padding:7px; border:1px solid rgba(237,243,255,.11); border-radius:7px; background:rgba(7,13,22,.72); }
.sector-resource-card .inventory-icon { width:34px; height:34px; }
.sector-resource-card strong,.sector-resource-card span { min-width:0; overflow-wrap:anywhere; }
.sector-building-card { padding:9px; border:1px solid var(--line); border-radius:8px; background:rgba(255,255,255,.025); }
.sector-building-card summary { cursor:pointer; list-style:none; display:flex; justify-content:space-between; gap:10px; }
.sector-building-card summary::-webkit-details-marker { display:none; }
.sector-building-card .sector-building-details { margin-top:9px; }
.sector-construction-warning {
  margin: 9px 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 82, 82, 0.52);
  border-radius: 6px;
  background: rgba(150, 24, 24, 0.16);
  color: #ff7373;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}
.sector-console-footer { position:sticky; bottom:0; display:flex; gap:6px; padding:8px; border:1px solid var(--line); border-radius:8px; background:rgba(5,9,16,.96); z-index:2; }
.logistics-route-grid { display:grid; grid-template-columns:minmax(270px,.7fr) minmax(560px,1.5fr); gap:12px; align-items:start; }
.logistics-route-card { padding:10px; border:1px solid var(--line); border-radius:8px; background:rgba(255,255,255,.03); }
.logistics-route-card.focused-route { border-color:#39d6ef; box-shadow:0 0 0 1px rgba(57,214,239,.2),0 0 18px rgba(57,214,239,.12); }
.logistics-route-card.active { border-color:rgba(242,138,58,.55); }
.logistics-route-card.active { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 10px; }
.logistics-route-card.active > h4,
.logistics-route-card.active > p,
.logistics-route-card.active > .section-title,
.logistics-route-card.active > .logistics-resource-picker,
.logistics-route-card.active > [data-logistics-create] { grid-column:1 / -1; }
.logistics-route-card.active > h4,
.logistics-route-card.active > p { margin:0; }
.logistics-route-card.active > label { display:grid; gap:4px; color:#c9d5e5; font-size:11px; text-transform:uppercase; letter-spacing:.04em; }
.logistics-route-card.active > label select { width:100%; }
.logistics-route-card.active > [data-logistics-map-destination] { align-self:end; width:100%; }
.logistics-route-card.active > [data-logistics-create] { justify-self:start; }
.logistics-resource-picker { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:5px; }
.logistics-resource-picker label { display:flex; align-items:center; gap:6px; padding:6px; border:1px solid var(--line); border-radius:6px; }
.logistics-route-list-title { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.logistics-resource-select { grid-column:1 / -1; border:1px solid var(--line); border-radius:7px; padding:8px; }
.logistics-resource-select summary { cursor:pointer; color:#dbe7f4; font-size:12px; font-weight:750; }
.logistics-resource-select[open] summary { margin-bottom:8px; }
.logistics-resource-row { display:grid !important; grid-template-columns:auto minmax(0,1fr); }
.logistics-resource-row.quantity-mode { grid-template-columns:auto minmax(0,1fr) 88px; }
.logistics-resource-row input[type="number"] { min-width:0; height:32px; }
.logistics-order-list { display:grid; gap:5px; margin:8px 0; }
.logistics-order-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:center; padding:7px; border:1px solid var(--line); border-radius:6px; background:rgba(0,0,0,.16); }
.logistics-order-row span { min-width:0; }
.logistics-order-row strong,.logistics-order-row small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.logistics-order-row small { color:var(--muted); margin-top:2px; }
.logistics-order-actions { display:flex; align-items:center; gap:5px; }
.logistics-cargo-progress { display:grid; gap:4px; margin:5px 0 2px; }
.logistics-cargo-progress-head { display:flex; justify-content:space-between; gap:8px; color:var(--muted); font-size:10px; }
.logistics-cargo-progress-head strong { color:#dbe7f4; font-weight:700; }
.logistics-editor-actions { grid-column:1 / -1; display:flex; justify-content:flex-end; gap:8px; padding-top:3px; }
.logistics-editor-actions [data-logistics-create] { border-color:var(--accent); color:#ffd0ac; }
.route-tool-control { position:relative; display:grid; align-items:end; }
.route-tool-control .route-overlay-button { padding-right:34px; }
.route-visibility-toggle { position:absolute; z-index:2; right:8px; top:11px; display:grid; place-items:center; width:16px; height:16px; cursor:pointer; }
.route-visibility-toggle input { position:absolute; width:1px; height:1px; opacity:0; pointer-events:none; }
.route-visibility-check { width:14px; height:14px; border:1px solid rgba(126,232,255,.65); border-radius:3px; background:rgba(4,12,20,.92); box-shadow:inset 0 0 0 2px rgba(4,12,20,.92); }
.route-visibility-toggle input:checked + .route-visibility-check { background:#39d6ef; }
.route-visibility-toggle input:focus-visible + .route-visibility-check { outline:2px solid #fff; outline-offset:2px; }
@media (max-width:900px) { .logistics-route-grid { grid-template-columns:1fr; } .logistics-resource-picker { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media (max-width:760px) { #colonyPanel.sector-console-mode,#sectorLogisticsPanel { width:calc(100vw - 28px); height:min(620px,calc(100vh - 154px)); } .logistics-route-card.active { grid-template-columns:1fr; } .logistics-route-card.active > * { grid-column:1 !important; } .logistics-resource-picker { grid-template-columns:repeat(2,minmax(0,1fr)); } .sector-summary-grid { grid-template-columns:1fr; } .sector-console-tabs { grid-template-columns:repeat(2,minmax(0,1fr)); } }

.click-choice-menu {
  max-height: min(420px, calc(100vh - 20px));
  overflow: visible;
}

.sector-context-menu {
  z-index: 44;
  width: min(168px, calc(100vw - 20px));
  min-width: 0;
  max-width: 168px;
  padding: 4px;
  max-height: calc(100vh - 20px);
  overflow: visible;
  box-sizing: border-box;
}

.sector-context-menu button {
  width: 100%;
  height: auto;
  min-height: 29px;
  min-width: 0;
  padding: 5px 7px;
  box-sizing: border-box;
  white-space: normal;
  overflow: hidden;
}

.sector-context-menu button br { display: none; }

.sector-context-menu button strong,
.sector-context-menu button .muted {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sector-context-menu button strong { font-size: 11px; line-height: 1.15; }
.sector-context-menu button .muted { margin-top: 2px; font-size: 9px; line-height: 1.1; }

.fleet-command-panel {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: 18;
  width: min(330px, calc(100vw - 36px));
  max-height: min(46vh, 420px);
  display: none;
  grid-template-rows: auto 1fr;
  border: 1px solid rgba(237, 243, 255, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.fleet-command-panel.open {
  display: grid;
}

.fleet-command-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(237, 243, 255, 0.12);
  background: var(--panel-strong);
}

.fleet-command-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.fleet-command-title strong {
  font-size: 13px;
}

.fleet-command-title span {
  font-size: 10px;
  color: var(--muted);
}

.fleet-command-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fleet-command-actions button[data-minimize-panel] {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.fleet-command-list {
  display: grid;
  gap: 7px;
  max-height: 330px;
  padding: 8px;
  overflow: auto;
}

.fleet-command-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 8px 9px;
  border: 1px solid rgba(237, 243, 255, 0.14);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  text-align: left;
}

.fleet-command-card:hover,
.fleet-command-card.selected {
  border-color: rgba(242, 138, 58, 0.68);
  background: linear-gradient(115deg, rgba(242, 138, 58, 0.16), rgba(67, 167, 255, 0.04));
}

.fleet-command-card .fleet-meta {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.fleet-command-status {
  min-width: 76px;
  padding: 4px 8px;
  border: 1px solid rgba(242, 138, 58, 0.5);
  border-radius: 999px;
  color: var(--accent-soft);
  background: rgba(242, 138, 58, 0.12);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.fleet-command-menu {
  position: fixed;
  z-index: 43;
  display: none;
  min-width: 210px;
  max-width: 280px;
  padding: 6px;
  border: 1px solid rgba(88, 181, 255, 0.42);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.48);
  pointer-events: auto;
}

.fleet-command-menu.open {
  display: grid;
  gap: 4px;
}

.fleet-command-menu button {
  min-height: 36px;
  justify-content: flex-start;
  text-align: left;
  border-color: rgba(237, 243, 255, 0.12);
  background: rgba(255, 255, 255, 0.045);
}

.fleet-command-menu button:hover {
  border-color: rgba(88, 181, 255, 0.72);
  background: rgba(88, 181, 255, 0.14);
  color: #ccecff;
}

.build-modal-card {
  width: min(760px, calc(100vw - 32px));
  max-height: min(82vh, 720px);
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid rgba(237, 243, 255, 0.22);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-strong);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.build-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(88, 181, 255, 0.1), transparent 42%),
    var(--panel-strong);
}

.build-modal-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.build-modal-body {
  overflow: auto;
  padding: 12px;
}

.build-context-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(237, 243, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.build-context-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.build-context-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 800;
  color: #edf3ff;
}

.build-context-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.build-stat-chip,
.build-status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid rgba(237, 243, 255, 0.14);
  border-radius: 999px;
  color: #dfe9f8;
  background: rgba(255, 255, 255, 0.055);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.build-status-chip.ready {
  border-color: rgba(92, 226, 157, 0.36);
  color: #a9f3ca;
  background: rgba(92, 226, 157, 0.11);
}

.build-status-chip.warn {
  border-color: rgba(255, 196, 97, 0.42);
  color: #ffd79b;
  background: rgba(255, 196, 97, 0.12);
}

.build-status-chip.locked {
  border-color: rgba(255, 130, 130, 0.35);
  color: #ffb4b4;
  background: rgba(255, 130, 130, 0.1);
}

.build-section {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.build-section:first-child {
  margin-top: 0;
}

.build-section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.build-section-header strong {
  color: #f4f8ff;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.build-section-header span {
  max-width: 58%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.build-empty-note {
  padding: 10px;
  border: 1px dashed rgba(237, 243, 255, 0.16);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
}

.build-resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.build-choice-card {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-height: 72px;
  padding: 8px;
  border-color: rgba(237, 243, 255, 0.15);
  background:
    linear-gradient(90deg, rgba(88, 181, 255, 0.08), transparent 34%),
    rgba(255, 255, 255, 0.045);
  text-align: left;
}

.build-choice-card:hover:not(:disabled) {
  border-color: rgba(88, 181, 255, 0.58);
  background:
    linear-gradient(90deg, rgba(88, 181, 255, 0.16), rgba(242, 138, 58, 0.05)),
    rgba(255, 255, 255, 0.065);
  color: #eef8ff;
}

.build-choice-card:disabled {
  opacity: 0.62;
}

.build-choice-card.locked {
  background:
    linear-gradient(90deg, rgba(255, 130, 130, 0.08), transparent 40%),
    rgba(255, 255, 255, 0.03);
}

.build-choice-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(237, 243, 255, 0.16);
  border-radius: 8px;
  color: #dcecff;
  background: rgba(88, 181, 255, 0.11);
  font-size: 11px;
  font-weight: 900;
}

.build-choice-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.build-choice-copy strong,
.build-choice-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.build-choice-copy strong {
  font-size: 11px;
}

.build-choice-copy span {
  color: var(--muted);
  font-size: 9px;
}

.build-choice-tags {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}

.build-choice-tags .build-stat-chip,
.build-choice-tags .build-status-chip {
  max-width: 122px;
  min-height: 19px;
  padding: 2px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 8px;
}


.build-category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.build-category-card {
  min-height: 112px;
  padding: 12px;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
}

.build-category-card .build-choice-icon {
  width: 42px;
  height: 42px;
  font-size: 12px;
}

.build-category-card .build-choice-copy strong {
  font-size: 15px;
}

.build-category-card.extraction { background: linear-gradient(135deg, rgba(84, 212, 255, 0.13), rgba(255, 255, 255, 0.035)); }
.build-category-card.civic { background: linear-gradient(135deg, rgba(92, 226, 157, 0.13), rgba(255, 255, 255, 0.035)); }
.build-category-card.production { background: linear-gradient(135deg, rgba(255, 196, 97, 0.13), rgba(255, 255, 255, 0.035)); }
.build-category-card.power { background: linear-gradient(135deg, rgba(242, 138, 58, 0.16), rgba(255, 255, 255, 0.035)); }
.build-blueprint-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(237, 243, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  margin-bottom: 8px;
}

details.build-blueprint-card summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  list-style: none;
  border-radius: 6px;
  padding: 5px 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

details.build-blueprint-card summary::-webkit-details-marker {
  display: none;
}

details.build-blueprint-card summary:hover,
.build-details summary:hover {
  background: rgba(242, 138, 58, 0.1);
  color: #ffd0a6;
}

details.build-blueprint-card summary:hover h4,
.build-details summary:hover strong,
.build-details summary:hover .ticker {
  color: #ffd0a6;
}

details.build-blueprint-card[open] {
  background:
    linear-gradient(180deg, rgba(242, 138, 58, 0.08), rgba(255, 255, 255, 0.025)),
    rgba(255, 255, 255, 0.035);
  border-color: rgba(242, 138, 58, 0.36);
}

.build-blueprint-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.build-blueprint-card h4 {
  margin: 0;
  font-size: 14px;
}

.build-modal-card .data-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.build-details {
  gap: 10px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid rgba(242, 138, 58, 0.26);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(242, 138, 58, 0.07), rgba(255, 255, 255, 0.025)),
    rgba(255, 255, 255, 0.035);
}

.build-modal-body > .build-details,
.build-modal-body > .build-blueprint-card {
  gap: 7px;
  padding: 10px;
  margin-bottom: 7px;
  border-color: rgba(242, 138, 58, 0.32);
  background:
    linear-gradient(135deg, rgba(242, 138, 58, 0.09), rgba(88, 181, 255, 0.035) 48%, rgba(255, 255, 255, 0.025)),
    rgba(9, 15, 25, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055), 0 12px 28px rgba(0, 0, 0, 0.22);
}

.build-modal-body > .build-details[open],
.build-modal-body > .build-blueprint-card[open] {
  display: grid;
  align-content: start;
}

.build-modal-body > .build-details > p.muted {
  margin: 2px 0 0;
  font-size: 10px;
  line-height: 1.25;
}

.build-modal-body > .build-details .data-grid,
.build-modal-body > .build-blueprint-card .data-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 6px;
  margin: 5px 0 0;
}

.build-modal-body > .build-details .data-cell,
.build-modal-body > .build-blueprint-card .data-cell {
  min-height: 0;
  padding: 7px 8px;
  border-color: rgba(237, 243, 255, 0.13);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022)),
    rgba(16, 23, 35, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.build-modal-body > .build-details .build-materials-cell,
.build-modal-body > .build-blueprint-card .build-materials-cell {
  order: 20;
  grid-column: 1 / -1;
  min-width: 0;
  border-color: rgba(88, 181, 255, 0.18);
  background:
    linear-gradient(135deg, rgba(88, 181, 255, 0.075), rgba(242, 138, 58, 0.035)),
    rgba(18, 25, 37, 0.78);
}

.build-modal-body > .build-details .data-cell .value,
.build-modal-body > .build-blueprint-card .data-cell .value {
  font-size: 12px;
  line-height: 1.2;
}

.build-modal-body > .build-details .data-cell .muted,
.build-modal-body > .build-blueprint-card .data-cell .muted {
  font-size: 10px;
  line-height: 1.15;
}

.build-modal-body > .build-details .material-cost-list,
.build-modal-body > .build-blueprint-card .material-cost-list {
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 5px;
}

.build-modal-body > .build-details .material-cost-row,
.build-modal-body > .build-blueprint-card .material-cost-row {
  min-width: 0;
  padding: 5px 7px;
  gap: 6px;
  align-items: center;
  border-color: rgba(237, 243, 255, 0.11);
  background: rgba(255, 255, 255, 0.04);
}

.build-modal-body > .build-details .material-cost-row strong,
.build-modal-body > .build-blueprint-card .material-cost-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.05;
}

.build-modal-body > .build-details .material-cost-row strong .muted,
.build-modal-body > .build-blueprint-card .material-cost-row strong .muted {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.build-modal-body > .build-details .material-cost-row > span,
.build-modal-body > .build-blueprint-card .material-cost-row > span {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(237, 243, 255, 0.08);
  color: #f2f7ff;
  font-size: 11px;
  line-height: 1.2;
}

@media (max-width: 720px) {
  .build-modal-body > .build-details .data-grid,
  .build-modal-body > .build-blueprint-card .data-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .build-modal-body > .build-details .material-cost-list,
  .build-modal-body > .build-blueprint-card .material-cost-list {
    grid-template-columns: 1fr;
  }
}

.build-details summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 5px 6px;
}

.build-modal-body > .build-details summary,
.build-modal-body > .build-blueprint-card summary {
  padding: 6px 8px;
  border: 1px solid rgba(237, 243, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
}

.build-details summary strong,
details.build-blueprint-card summary h4 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.build-details .blueprint-use-label,
.build-blueprint-card .blueprint-use-label {
  padding: 3px 7px;
  border: 1px solid rgba(242, 138, 58, 0.32);
  border-radius: 999px;
  background: rgba(242, 138, 58, 0.11);
}

.build-quantity-row {
  grid-template-columns: 128px minmax(180px, 1fr);
  gap: 10px;
  align-items: end;
}

.build-modal-body > .build-details .build-quantity-row,
.build-modal-body > .build-blueprint-card .build-quantity-row {
  grid-template-columns: 118px minmax(220px, 1fr);
  gap: 8px;
  margin-top: 7px;
}

.build-quantity-row .action-row button,
.build-quantity-row .modal-actions button {
  flex: 0 1 260px;
  min-height: 42px;
}

.build-modal-body > .build-details .build-quantity-row .action-row,
.build-modal-body > .build-blueprint-card .build-quantity-row .modal-actions {
  margin: 0;
}

.build-modal-body > .build-details .build-quantity-row .action-row button,
.build-modal-body > .build-blueprint-card .build-quantity-row .modal-actions button {
  min-height: 34px;
}

.build-quantity-row .action-row,
.build-quantity-row .modal-actions {
  justify-content: flex-start;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-actions button {
  flex: 1 1 130px;
}

.build-back-button {
  justify-content: center;
  font-weight: 700;
}

.blueprint-use-label {
  color: #ffd0a6;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.market-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: #dbe6f8;
  font-size: 13px;
  user-select: none;
}

.market-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.material-cost-list {
  display: grid;
  gap: 4px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.material-cost-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid rgba(237, 243, 255, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  min-width: 0;
  box-sizing: border-box;
}

.material-cost-row.missing {
  border-color: rgba(255, 116, 116, 0.45);
  background: rgba(255, 116, 116, 0.08);
  color: #ffb3a8;
}

.material-cost-row strong,
.material-cost-row > span {
  min-width: 0;
}

.material-cost-row strong {
  overflow-wrap: anywhere;
}

.material-cost-row strong .muted {
  display: block;
  text-align: left;
  margin-top: 3px;
}

.material-cost-row > span {
  text-align: right;
  font-weight: 800;
  font-size: 14px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(237, 243, 255, 0.08);
}

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

.sector-output-row {
  width: 100%;
  height: auto;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 7px 9px;
  text-align: left;
  white-space: normal;
}

.sector-output-row span {
  color: var(--muted);
  font-size: 11px;
}

.sector-output-row .value {
  text-align: right;
  font-size: 13px;
}

#colonyPanel button.sector-output-row {
  height: auto;
  min-height: 48px;
  padding: 8px 10px;
  align-items: center;
}

#colonyPanel button.sector-output-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

#colonyPanel button.sector-output-row strong span {
  display: block;
  margin-top: 2px;
  line-height: 1.25;
}

#colonyPanel button.sector-output-row .value {
  white-space: nowrap;
}

#colonyPanel button.income-resource-cell {
  width: 100%;
  height: auto;
  min-height: 0;
  display: block;
  padding: 7px;
  color: var(--text);
  font: inherit;
  line-height: 1.25;
  text-align: left;
  white-space: normal;
}

#colonyPanel button.income-resource-cell:hover,
#colonyPanel button.income-resource-cell.active {
  border-color: var(--accent-line);
  background: rgba(242, 138, 58, 0.11);
}

#colonyPanel button.income-resource-cell .label,
#colonyPanel button.income-resource-cell .value {
  display: block;
}

.sector-list {
  display: grid;
  gap: 7px;
}

.sector {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  padding: 8px;
}

.sector-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.sector strong {
  font-size: 13px;
}

.sector span,
.sector p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.sector button {
  width: 100%;
  margin-top: 8px;
  height: 30px;
  font-size: 12px;
}

.sector.colony {
  border-color: rgba(242, 138, 58, 0.58);
  background: rgba(242, 138, 58, 0.09);
}

.slot {
  min-height: 58px;
  padding: 8px;
  display: grid;
  align-content: center;
  gap: 4px;
}

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

.slot span {
  font-size: 11px;
  color: var(--muted);
}

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

.planet { padding: 10px; }

.planet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.planet h3 {
  font-size: 14px;
  min-width: 0;
}

.planet-type {
  flex: 0 0 auto;
  font-size: 11px;
  color: #ffd0a6;
}

.planet-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.planet-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.planet-slots span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  color: #dce7f8;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.055);
}

.tooltip {
  position: fixed;
  z-index: 20;
  min-width: 180px;
  max-width: min(320px, calc(100vw - 28px));
  border-radius: 7px;
  padding: 8px 10px;
  transform: translate(14px, 14px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.tooltip.visible { opacity: 1; }

.tooltip strong {
  display: block;
  font-size: 13px;
}

.tooltip span {
  color: var(--muted);
  font-size: 11px;
}

.tooltip .fleet-hover-details {
  display: grid;
  gap: 3px;
  margin-top: 2px;
}

.tooltip .fleet-hover-details .progress-track {
  height: 6px;
  margin: 2px 0;
}

.tooltip .fleet-hover-details span strong {
  display: inline;
  color: #eaf6ff;
  font-size: inherit;
}

.tooltip .sector-hover-dwell {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
}

.tooltip .sector-hover-dwell-ring {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  padding: 2px;
  border-radius: 50%;
  background: conic-gradient(#63ddf4 var(--sector-hover-progress, 0%), rgba(255,255,255,.14) 0);
}

.tooltip .sector-hover-dwell-ring::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #071019;
}

.tooltip .sector-hover-storage {
  display: grid;
  gap: 5px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.tooltip .sector-hover-storage-head,
.tooltip .sector-hover-storage-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.tooltip .sector-hover-storage-head strong { color: #7fe8ff; font-size: 11px; }
.tooltip .sector-hover-storage-row span:last-child { color: #e8f2ff; }

.tooltip .sector-hover-planned {
  display: grid;
  gap: 5px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 111, 118, 0.38);
}

.tooltip .sector-hover-planned strong {
  color: #ff858c;
  font-size: 11px;
}

.tooltip .sector-hover-planned-row {
  display: grid;
  gap: 2px;
}

.tooltip .sector-hover-planned-row span {
  color: #f5b9be;
  line-height: 1.25;
}

.tooltip .sector-hover-defense-progress {
  height: 6px;
  margin: 2px 0 1px;
  border-color: rgba(255, 133, 140, 0.38);
}

.fortification-progress .progress-fill {
  background: linear-gradient(90deg, #ff8a4c, #ffc078);
}

.tooltip .foc-supply-summary {
  display: grid;
  gap: 4px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.tooltip .foc-supply-summary > strong {
  color: #ffbe73;
  font-size: 11px;
}

.tooltip .foc-supply-summary span {
  display: block;
}

.tooltip .formation-hover-details {
  display: grid;
  gap: 7px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(242, 138, 58, 0.38);
}

.tooltip .formation-hover-card {
  display: grid;
  gap: 3px;
  padding: 6px 7px;
  border: 1px solid rgba(237, 243, 255, 0.10);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.tooltip .formation-hover-card > strong {
  color: #ffc078;
  font-size: 11px;
}

.tooltip .formation-hover-statline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 10px;
}

.tooltip .formation-hover-statline span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tooltip .survey-node-list {
  display: grid;
  gap: 7px;
  margin-top: 7px;
}

.tooltip .survey-node {
  display: block;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip .survey-node:first-child {
  padding-top: 0;
  border-top: 0;
}

.tooltip .survey-node.focused strong {
  color: #7fe8ff;
}

.tooltip .survey-node.focused strong::after {
  content: "Hovered node";
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid rgba(86, 222, 255, 0.45);
  border-radius: 999px;
  color: #9cecff;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: 1px;
}

.tooltip .survey-node strong {
  margin-bottom: 2px;
  color: #dbe8f8;
  line-height: 1.2;
}

.tooltip .survey-node-detail {
  display: block;
  line-height: 1.35;
}

.planet-ownership-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.planet-ownership-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, auto);
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.planet-ownership-row strong,
.planet-ownership-row span {
  min-width: 0;
}

.planet-ownership-owner {
  text-align: right;
  color: #dce7f5;
  font-size: 12px;
}

.planet-ownership-owner.unclaimed {
  color: var(--muted);
}

.planet-population-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(102, 178, 255, 0.08);
  margin-top: 8px;
}

.planet-population-total strong {
  color: #eaf3ff;
  font-size: 18px;
}

/* Compact panel density. Top bar and bottom tools keep their current scale. */
.drawer-panel,
.side-panel,
.build-modal-card,
.chat-panel,
.tooltip {
  font-size: 12px;
}

.drawer-panel {
  width: min(500px, calc(100vw - 28px));
}

body.minimized-dock-active .drawer-panel:not(.right-drawer) {
  width: min(500px, calc(100vw - 126px));
}

.drawer-panel.right-drawer {
  width: min(390px, calc(100vw - 28px));
}

.drawer-head,
#marketPanel .drawer-head,
.panel-head,
.build-modal-head {
  padding: 8px 10px;
}

.drawer-body,
.panel-body,
.build-modal-body {
  padding: 8px 10px 10px;
}

.drawer-head h2,
#marketPanel .drawer-head h2,
.panel-head h2 {
  font-size: 20px;
  line-height: 1.1;
}

.drawer-head .muted,
.panel-head .muted {
  font-size: 11px;
  line-height: 1.25;
}

.drawer-panel button,
.drawer-panel select,
.drawer-panel input,
.side-panel button,
.side-panel select,
.side-panel input,
.build-modal-card button,
.build-modal-card select,
.build-modal-card input,
.chat-panel button,
.chat-panel input {
  height: 32px;
  min-height: 32px;
  padding-left: 9px;
  padding-right: 9px;
  font-size: 12px;
  border-radius: 6px;
}

.build-modal-card .build-choice-card {
  height: auto;
  min-height: 76px;
  padding: 8px;
  white-space: normal;
  overflow: hidden;
}

.build-modal-card .build-choice-card .build-choice-copy,
.build-modal-card .build-choice-card .build-choice-tags {
  min-width: 0;
}

.drawer-head .window-actions button,
#marketPanel .drawer-head .window-actions button,
.drawer-head > button,
#marketPanel .drawer-head > button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.research-list,
.fleet-card-list,
.planet-list,
.sector-list,
.sector-ops-list,
.storage-list {
  gap: 6px;
}

.research-item,
.ship-build-card,
.ship-owned-card,
.fleet-card,
.planet,
.sector,
.slot,
.build-group,
.build-blueprint-card,
.ship-designer-panel,
.ship-slot-board,
.ship-module-bay,
.ship-loadout-bay,
.storage-confirm-panel,
.storage-empire-card {
  padding: 8px;
  border-radius: 7px;
}

.research-item h4,
.ship-build-card h4,
.ship-owned-card h4,
.planet h3,
.build-blueprint-card h4,
.build-group strong {
  font-size: 13px;
  line-height: 1.15;
}

.data-grid,
.slot-grid,
.ship-inspector-grid,
.ship-designer-stats,
.fleet-orders-grid,
.copy-controls,
.copy-output-strip {
  gap: 5px;
  margin-bottom: 6px;
}

.data-cell {
  padding: 6px;
  border-radius: 6px;
}

.label {
  font-size: 10px;
  margin-bottom: 3px;
  letter-spacing: 0.075em;
}

.value {
  font-size: 13px;
  line-height: 1.25;
}

.muted {
  font-size: 11px;
}

.section-title {
  margin: 11px 0 6px;
  font-size: 12px;
}

.action-row {
  gap: 6px;
  margin: 8px 0 3px;
}

.ledger-row {
  font-size: 11px;
}

.ledger-row > div {
  padding: 6px 7px;
}

.market-row {
  min-height: 26px;
  font-size: 11px;
}

.market-row > div {
  padding: 4px 6px;
}

.market-head,
.market-category {
  min-height: 24px;
}

.production-tabs {
  gap: 5px;
  padding: 6px 0 8px;
}

.production-tabs button,
.research-tabs button,
.hull-focus-grid button {
  min-height: 27px;
  padding: 4px 8px;
  font-size: 11px;
}

.research-rail button {
  height: auto;
  min-height: 46px;
  padding: 6px 8px;
  align-content: center;
}

.research-rail button strong,
.research-rail button span {
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.production-facility summary::after {
  font-size: 10px;
}

.production-power {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  font-size: 13px;
}

.fleet-card {
  grid-template-columns: minmax(160px, 1.1fr) minmax(160px, 1fr) minmax(160px, 1.1fr) minmax(190px, auto);
  gap: 9px;
}

.fleet-card-main,
.fleet-card-location,
.fleet-card-cargo {
  gap: 4px;
}

.fleet-card-actions {
  gap: 5px;
}

.fleet-card-actions button {
  min-width: 64px;
}

.fleet-status-pill,
.ship-stat-pill,
.star-class {
  min-height: 21px;
  padding: 2px 7px;
  font-size: 10px;
}

.sector-ops-row {
  min-height: 38px;
  padding: 6px 7px;
  gap: 6px;
  font-size: 11px;
}

.sector-ops-row strong {
  font-size: 12px;
}

.sector-ops-row .production-power {
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
}

.inventory-grid {
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
}

.inventory-item {
  min-height: 84px;
  grid-template-rows: 42px auto;
  padding: 6px 5px;
}

.inventory-icon {
  width: 42px;
  height: 42px;
}

.inventory-fallback {
  font-size: 17px;
}

.inventory-quantity {
  top: 37px;
  right: 5px;
  min-width: 23px;
  font-size: 10px;
}

.inventory-name {
  font-size: 10px;
  line-height: 1.15;
}

.ship-designer-panel {
  gap: 9px;
}

.ship-architect-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 10px;
  min-height: 590px;
}

.ship-architect-stage,
.ship-architect-side,
.ship-architect-saves {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.58);
  border-radius: 8px;
  padding: 10px;
}

.ship-architect-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.ship-architect-toolbar .span-2 {
  grid-column: span 2;
}

.ship-architect-canvas {
  height: 455px;
  border: 1px solid rgba(242, 138, 58, 0.35);
  border-radius: 8px;
  background: radial-gradient(circle at center, rgba(52, 211, 153, 0.09), rgba(2, 6, 23, 0.96) 62%);
  overflow: hidden;
  position: relative;
  cursor: grab;
}

.ship-architect-overlay {
  position: absolute;
  top: 10px;
  z-index: 2;
  min-width: 190px;
  max-width: min(300px, 42%);
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: rgba(6, 10, 18, 0.72);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.26), inset 0 0 18px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.ship-architect-overlay.left {
  left: 10px;
}

.ship-architect-overlay.right {
  right: 10px;
}

.ship-architect-overlay h4 {
  margin: 0;
  color: #fff4e9;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.architect-mini-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}

.architect-mini-row strong {
  color: #edf3ff;
  font-variant-numeric: tabular-nums;
}

.architect-mini-row.has-help {
  cursor: help;
}

.architect-mini-row.has-help span {
  text-decoration: underline dotted rgba(184, 201, 224, 0.7);
  text-underline-offset: 3px;
}

.architect-delta {
  margin-left: 5px;
  font-size: 10px;
  font-weight: 800;
}

.architect-delta.good {
  color: #7dffad;
}

.architect-delta.bad {
  color: #ff9c9c;
}

.architect-material-row {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 5px;
}

.architect-material-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.ship-architect-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.ship-architect-canvas:active {
  cursor: grabbing;
}

.ship-architect-note {
  position: absolute;
  left: 10px;
  bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

.ship-architect-message {
  min-height: 28px;
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
}

.ship-architect-message.error {
  color: #ff9c9c;
}

.architect-stat-grid,
.architect-slot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.architect-slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 7px;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
}

.architect-slot-row strong {
  color: #fbd3aa;
}

.architect-adjust-panel {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding: 9px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.architect-adjust-panel h4 {
  margin: 0;
}

.architect-adjust-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.architect-adjust-grid button {
  min-width: 0;
  height: 30px;
  padding: 0 6px;
  font-size: 11px;
}

.architect-module-list,
.architect-save-list {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.architect-module-select-row {
  display: grid;
  gap: 5px;
  padding: 8px;
  border: 1px solid rgba(237, 243, 255, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.architect-module-select-row.active {
  border-color: rgba(242, 138, 58, 0.82);
  background: rgba(242, 138, 58, 0.12);
}

.architect-module-select-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.architect-module-select-row select {
  width: 100%;
}

.architect-module-card,
.architect-save-card {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  padding: 8px;
  background: rgba(17, 24, 39, 0.74);
}

.architect-module-card.active {
  border-color: rgba(242, 138, 58, 0.9);
  background: linear-gradient(135deg, rgba(242, 138, 58, 0.2), rgba(17, 24, 39, 0.7));
}

.architect-save-card header,
.architect-module-card header {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.architect-module-card strong {
  min-width: 0;
}

.architect-module-meta {
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .ship-architect-shell,
  .ship-architect-toolbar {
    grid-template-columns: 1fr;
  }

  .ship-architect-toolbar .span-2 {
    grid-column: span 1;
  }
}

.ship-designer-head h4 {
  font-size: 16px;
}

.ship-designer-grid {
  gap: 8px;
}

.ship-fitting-rig {
  min-height: 390px;
}

.ship-fitting-rig::before {
  width: 310px;
  height: 310px;
}

.ship-hull-silhouette {
  width: 132px;
  height: 90px;
}

.warp-gate-dashboard {
  gap: 10px;
}

.warp-gate-hero {
  padding: 9px;
}

.warp-gate-section-row h3 {
  font-size: 13px;
}

.warp-gate-progress {
  height: 6px;
  margin: 9px 0 8px;
}

.warp-gate-manifest-grid,
.warp-gate-contribution-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
}

.warp-gate-material-card,
.warp-gate-fleet-card,
.warp-gate-contribution-card {
  padding: 7px;
  border-radius: 7px;
}

.warp-gate-material-count {
  font-size: 11px;
}

.copy-chamber,
.copy-vault {
  min-height: 380px;
}

.copy-core {
  width: 82px;
  height: 82px;
  font-size: 24px;
}

#shipyardPanel,
#shipDesignPanel,
#shipArchitectPanel,
#shipFactoryPanel,
#blueprintCopyPanel,
#fleetPanel {
  height: min(540px, calc(100vh - 116px));
}

#shipArchitectPanel {
  width: min(1180px, calc(100vw - 28px));
  height: min(720px, calc(100vh - 86px));
}

#shipFactoryPanel {
  width: min(1080px, calc(100vw - 28px));
  height: min(640px, calc(100vh - 96px));
}

#marketPanel {
  width: min(930px, calc(100vw - 28px));
  height: min(580px, calc(100vh - 112px));
}

#playerMarketPanel {
  width: min(960px, calc(100vw - 28px));
  height: min(600px, calc(100vh - 112px));
}

#productionPanel {
  width: min(820px, calc(100vw - 28px));
}

#storagePanel {
  width: min(1500px, calc(100vw - 48px));
  height: min(760px, calc(100vh - 104px));
}

#storagePanel .storage-location-button {
  height: auto !important;
  min-height: 56px !important;
  padding: 8px 10px !important;
  overflow: visible;
}

#storagePanel .storage-location-group-toggle {
  height: auto !important;
  min-height: 48px !important;
  padding: 7px 9px !important;
  overflow: visible;
}

#storagePanel .storage-location-button strong,
#storagePanel .storage-location-button span,
#storagePanel .storage-location-group-toggle strong,
#storagePanel .storage-location-group-toggle span {
  line-height: 1.25;
}

#creditsPanel {
  width: min(700px, calc(100vw - 28px));
}

body #researchPanel {
  width: min(920px, calc(100vw - 28px));
  height: min(720px, calc(100vh - 96px));
  min-height: 420px;
}

@media (max-width: 880px) {
  .topbar {
    right: 4px;
    flex-wrap: wrap;
  }

  .fleet-card {
    grid-template-columns: 1fr;
  }

  .fleet-card-actions {
    justify-content: stretch;
  }

  .fleet-card-actions button {
    flex: 1;
  }

  .top-stats {
    position: static;
    transform: none;
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .side-panel {
    top: 130px;
    left: 14px;
    height: min(48vh, 430px);
    max-height: calc(100vh - 214px);
  }

  .corner-brand {
    right: 10px;
    bottom: 10px;
  }

  .drawer-panel {
    top: 130px;
  }

  .build-resource-grid {
    grid-template-columns: 1fr;
  }

  .build-context-panel {
    grid-template-columns: 1fr;
  }

  .build-choice-card {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .build-choice-tags {
    grid-column: 2;
  }

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

  .sector-building-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "upkeep"
      "power"
      "actions";
  }

  .sector-building-actions {
    justify-content: flex-start;
  }

  .sector-ops-row.output-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}
  .survey-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    margin: 12px 0 8px;
    padding: 9px 10px;
    border: 1px solid rgba(85, 210, 255, 0.34);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(40, 180, 215, 0.12), rgba(255, 153, 69, 0.08));
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(85, 210, 255, 0.05), 0 0 18px rgba(85, 210, 255, 0.08);
  }

  .survey-section-title:hover,
  .survey-section-title.collapsed {
    border-color: rgba(85, 210, 255, 0.58);
    background: linear-gradient(135deg, rgba(40, 180, 215, 0.18), rgba(255, 153, 69, 0.12));
  }

  .survey-section-title .survey-toggle-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
  }

  .survey-resource-row {
    flex-wrap: wrap;
    gap: 6px;
  }

  .survey-resource-row button {
    min-height: 28px;
    padding: 5px 8px;
    font-size: 11px;
  }

  .survey-resource-row button.active {
    border-color: rgba(84, 212, 255, 0.86);
    background: rgba(56, 189, 231, 0.18);
    color: #dff8ff;
  }

  .survey-legend {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    height: 7px;
    margin: 6px 0 5px;
    overflow: hidden;
    border: 1px solid rgba(237, 243, 255, 0.12);
    border-radius: 999px;
  }

  .survey-legend span:nth-child(1) { background: #1547d6; }
  .survey-legend span:nth-child(2) { background: #00a6c8; }
  .survey-legend span:nth-child(3) { background: #20a94a; }
  .survey-legend span:nth-child(4) { background: #d8b21f; }
  .survey-legend span:nth-child(5) { background: #d94b1f; }
  .survey-legend span:nth-child(6) { background: #f2ead2; }

  .survey-slider {
    display: grid;
    gap: 5px;
    margin-top: 7px;
  }

  .survey-slider span {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .survey-slider strong {
    color: var(--text);
  }

  .survey-slider input {
    width: 100%;
    accent-color: #54d4ff;
  }

  /* Colony market dashboard */
  #marketPanel {
    width: min(1080px, calc(100vw - 28px));
    height: min(720px, calc(100vh - 72px));
  }

  #marketTransactionsPanel {
    left: 50%;
    right: auto;
    top: 118px;
    bottom: auto;
    width: min(820px, calc(100vw - 44px));
    height: min(500px, calc(100vh - 156px));
    transform: translateX(-50%);
  }

  #marketTransactionsPanel .drawer-body {
    min-height: 0;
    padding: 10px;
    background:
      radial-gradient(circle at 10% 0%, rgba(39, 180, 150, 0.1), transparent 38%),
      linear-gradient(180deg, rgba(8, 19, 25, 0.99), rgba(5, 12, 17, 0.99));
  }

  #marketTransactionsList {
    min-height: 100%;
  }

  #marketPanel .drawer-body {
    padding: 0;
    background:
      radial-gradient(circle at 10% 0%, rgba(39, 180, 150, 0.1), transparent 34%),
      linear-gradient(180deg, rgba(8, 19, 25, 0.98), rgba(5, 12, 17, 0.98));
  }

  #marketList.market-dashboard {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .market-command-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(260px, auto);
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid rgba(84, 212, 255, 0.18);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(24, 48, 47, 0.92), rgba(14, 27, 33, 0.94));
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
  }

  .market-command-title {
    display: grid;
    gap: 4px;
  }

  .market-command-title h3 {
    margin: 0;
    color: #f3f7fa;
    font-size: 17px;
  }

  .market-command-title p {
    margin: 0;
    color: #8fa8b5;
  }

  .market-target-tabs {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
  }

  #marketPanel .market-target-tabs button {
    min-height: 34px;
    border-color: rgba(154, 178, 190, 0.25);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    color: #aebfca;
  }

  #marketPanel .market-target-tabs button.active {
    border-color: rgba(242, 138, 58, 0.85);
    background: linear-gradient(135deg, rgba(117, 57, 22, 0.92), rgba(65, 34, 20, 0.94));
    color: #ffe3c7;
    box-shadow: 0 0 18px rgba(242, 138, 58, 0.14);
  }

  .market-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .market-summary-card {
    display: grid;
    gap: 3px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(139, 168, 185, 0.16);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.025);
  }

  .market-summary-card span {
    color: #8298a6;
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .market-summary-card strong {
    overflow: hidden;
    color: #eaf2f6;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .market-summary-card.positive strong { color: #78dfb2; }
  .market-summary-card.negative strong { color: #ff9f91; }

  .market-catalog {
    display: grid;
    gap: 8px;
  }

  #marketPanel .market-table {
    display: grid;
    gap: 8px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  #marketPanel .market-category-block {
    overflow: hidden;
    border: 1px solid rgba(139, 168, 185, 0.16);
    border-radius: 10px;
    background: rgba(15, 28, 32, 0.78);
  }

  #marketPanel .market-category {
    display: block;
    min-height: 0;
    border: 0;
    background: linear-gradient(90deg, rgba(102, 57, 27, 0.72), rgba(50, 38, 29, 0.4));
  }

  #marketPanel .market-category > button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    padding: 7px 11px;
  }

  .market-category-heading {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .market-category-heading .market-chevron {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.22);
    color: #ffc28d;
    font-size: 10px;
  }

  .market-category-meta {
    color: #c5aa91;
    font-size: 10px;
    font-weight: 600;
  }

  .market-product-list {
    display: grid;
  }

  #marketPanel .market-row[data-market-resource] {
    display: grid;
    grid-template-columns: minmax(185px, 1.35fr) minmax(118px, 0.78fr) minmax(130px, 0.85fr) minmax(124px, 0.8fr) minmax(130px, 0.85fr) minmax(150px, 1fr);
    gap: 0;
    min-height: 72px;
    border: 0;
    border-top: 1px solid rgba(237, 243, 255, 0.07);
    background: rgba(255, 255, 255, 0.012);
    font-size: 11px;
  }

  #marketPanel .market-row[data-market-resource]:hover,
  #marketPanel .market-row[data-market-resource].active {
    background: linear-gradient(90deg, rgba(242, 138, 58, 0.095), rgba(67, 195, 207, 0.035));
  }

  #marketPanel .market-row[data-market-resource].active {
    box-shadow: inset 3px 0 #f28a3a;
  }

  #marketPanel .market-row[data-market-resource] > div {
    display: grid;
    align-content: center;
    gap: 3px;
    padding: 9px 10px;
    border-right: 1px solid rgba(237, 243, 255, 0.055);
    overflow: visible;
  }

  #marketPanel .market-row[data-market-resource] > div:last-child {
    border-right: 0;
    text-align: left;
  }

  .market-product-cell {
    grid-template-columns: 42px minmax(0, 1fr) !important;
    align-items: center;
    align-content: center !important;
    gap: 9px !important;
  }

  .market-product-icon {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(84, 212, 255, 0.18);
    border-radius: 8px;
    background: rgba(2, 10, 14, 0.68);
    color: #79dff4;
    font-weight: 900;
  }

  .market-product-icon img {
    width: 34px;
    height: 34px;
    object-fit: contain;
  }

  .market-product-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .market-product-copy strong {
    overflow: hidden;
    color: #dff7ff;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .market-cell-label {
    color: #718995;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
  }

  .market-cell-value {
    color: #e1e9ed;
    font-size: 12px;
    font-weight: 700;
  }

  #marketPanel .market-quote-line {
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
    flex-wrap: wrap;
  }

  #marketPanel .market-current-price {
    color: #f1f6f8;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
  }

  #marketPanel .market-current-price small {
    margin-left: 2px;
    color: #869ca7;
    font-size: 9px;
    font-weight: 700;
  }

  #marketPanel .market-move-quote {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
  }

  #marketPanel .market-move-quote.up { color: #65dba5; }
  #marketPanel .market-move-quote.down { color: #ff817c; }
  #marketPanel .market-move-quote.flat { color: #7f929c; }

  #marketPanel .market-move-arrow {
    font-size: 8px;
    line-height: 1;
  }

  #marketPanel .market-move-percent {
    opacity: 0.78;
  }

  .market-cell-subvalue {
    color: #8ba0ab;
    font-size: 10px;
  }

  #marketPanel .market-row .ticker {
    justify-self: start;
    width: auto;
    max-width: 100%;
    padding: 3px 6px;
    border-radius: 999px;
  }

  #marketPanel .market-quantity-cell input {
    width: 100%;
    height: 30px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.045);
  }

  .market-policy-controls {
    display: flex !important;
    align-items: center;
    align-content: center !important;
    gap: 7px !important;
    flex-wrap: wrap;
  }

  .market-policy-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 4px 8px;
    border: 1px solid rgba(139, 168, 185, 0.2);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.025);
    color: #9eb0ba;
    cursor: pointer;
    user-select: none;
  }

  .market-policy-toggle:has(input:checked) {
    border-color: rgba(70, 208, 165, 0.55);
    background: rgba(40, 146, 113, 0.14);
    color: #a9efd6;
  }

  .market-policy-toggle.buy:has(input:checked) {
    border-color: rgba(84, 212, 255, 0.55);
    background: rgba(42, 135, 166, 0.14);
    color: #b5efff;
  }

  .market-policy-toggle input {
    width: 14px !important;
    height: 14px !important;
    margin: 0;
  }

  #marketPanel .market-row.market-locked {
    opacity: 0.56;
  }

  #marketPanel .market-row.market-locked:hover {
    background: rgba(255, 255, 255, 0.012);
  }

  .market-lock-pill {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    min-height: 22px;
    padding: 2px 7px;
    border: 1px solid rgba(242, 138, 58, 0.35);
    border-radius: 999px;
    color: #e9ad79;
    font-size: 9px;
    font-weight: 800;
  }

  .market-ledger-shell {
    display: grid;
    gap: 7px;
    padding: 11px;
    border: 1px solid rgba(84, 212, 255, 0.16);
    border-radius: 10px;
    background: rgba(9, 21, 27, 0.82);
  }

  .market-ledger-shell > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .market-ledger-shell h4 { margin: 0; }

  @media (max-width: 900px) {
    .market-command-bar { grid-template-columns: 1fr; }
    .market-target-tabs { justify-content: flex-start; }
    .market-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #marketPanel .market-row[data-market-resource] { grid-template-columns: minmax(180px, 1.3fr) repeat(3, minmax(112px, 0.8fr)) minmax(124px, 0.8fr) minmax(150px, 1fr); overflow-x: auto; }
  }

  @media (max-width: 650px) {
    #marketPanel .market-row[data-market-resource] {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      padding: 4px;
    }
    #marketPanel .market-row[data-market-resource] > div { border-right: 0; }
    .market-product-cell, .market-policy-controls { grid-column: 1 / -1; }
  }
