:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0e1114;
  color: #edf2f4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(38, 52, 60, 0.58), transparent 260px), #0e1114;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0.72rem 0.95rem;
  color: #edf2f4;
  background: #26313a;
  font-weight: 750;
  cursor: pointer;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #35434c;
  border-radius: 8px;
  padding: 0.8rem;
  color: #f5f7f8;
  background: #151b20;
}

select {
  appearance: none;
  min-height: 48px;
  padding-right: 2.5rem;
  background-color: #151b20;
  background-image:
    linear-gradient(45deg, transparent 50%, #7bd8c6 50%),
    linear-gradient(135deg, #7bd8c6 50%, transparent 50%);
  background-position:
    calc(100% - 1.05rem) 50%,
    calc(100% - 0.75rem) 50%;
  background-repeat: no-repeat;
  background-size: 0.32rem 0.32rem, 0.32rem 0.32rem;
}

select:invalid,
select option[value=""] {
  color: #8d9ca5;
}

label {
  display: grid;
  gap: 0.42rem;
  color: #aab7bf;
  font-size: 0.9rem;
  font-weight: 700;
}

main {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  background: rgba(14, 17, 20, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

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

.topbar h1 {
  font-size: 1rem;
}

.eyebrow {
  color: #7bd8c6;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button {
  width: 48px;
  min-width: 48px;
  padding: 0;
}

.primary {
  background: #0f8f7e;
}

.secondary {
  background: #26313a;
}

.ghost {
  background: #1a2228;
}

.danger-button,
.notice.danger {
  background: #8f2d3f;
}

.link-button {
  min-height: 0;
  border-radius: 0;
  padding: 0;
  color: #edf2f4;
  background: transparent;
  text-align: left;
}

.link-button:hover,
.link-button:focus {
  color: #7bd8c6;
}

.destination-link {
  font-size: 1.05rem;
  font-weight: 850;
}

.compact-button {
  min-height: 34px;
  padding: 0.42rem 0.6rem;
  font-size: 0.82rem;
}

.hero-panel,
.mode-header,
.card-header,
.session-card,
.assignment-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.hero-panel,
.mode-header {
  align-items: center;
  margin-bottom: 0.85rem;
}

.hero-panel h2,
.mode-header h2,
.empty-state h1 {
  max-width: 15ch;
  font-size: 1.65rem;
  line-height: 1.05;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.summary-grid article,
.card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(21, 27, 32, 0.94);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
}

.summary-grid article {
  display: grid;
  gap: 0.24rem;
  padding: 0.72rem;
}

.summary-grid span,
.muted {
  color: #aab7bf;
}

.summary-grid strong {
  font-size: 1.08rem;
}

.stack {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.card {
  padding: 0.85rem;
}

.contract.delivered {
  opacity: 0.62;
}

.pill {
  display: inline-flex;
  min-width: max-content;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  color: #091113;
  background: #f0cc6b;
  font-size: 0.78rem;
  font-weight: 850;
}

.contract-scu-pill {
  align-self: start;
  min-width: 4.5rem;
  justify-content: center;
  min-height: 0;
  padding: 0.28rem 0.62rem;
  line-height: 1;
  white-space: nowrap;
}

.zone-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: max-content;
  border: 1px solid var(--zone-color);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  color: #edf2f4;
  background: #10161b;
  font-size: 0.78rem;
  font-weight: 850;
}

.zone-pill.mini {
  padding: 0.22rem 0.42rem;
  font-size: 0.76rem;
}

.zone-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.zone-swatch {
  display: inline-block;
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 999px;
  background: var(--zone-color);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.zone-swatch.large {
  width: 1.1rem;
  height: 1.1rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0.7rem 0;
  color: #aab7bf;
  font-size: 0.82rem;
}

.meta-grid strong {
  display: block;
  color: #edf2f4;
}

.toolbar,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

.button-row {
  margin-top: 0.9rem;
  margin-bottom: 0;
}

.form-card {
  display: grid;
  gap: 0.8rem;
}

.field-group {
  display: grid;
  gap: 0.42rem;
}

.field-hint {
  color: #8d9ca5;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
}

.form-grid {
  display: grid;
  gap: 0.7rem;
}

.wide {
  grid-column: 1 / -1;
}

.cargo-lines,
.cargo-lines-editor {
  display: grid;
  gap: 0.65rem;
}

.cargo-line-editor {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.7rem;
  background: #10161b;
}

.cargo-line-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 0.65rem;
  color: #c7d0d5;
}

.add-line-button {
  justify-self: start;
  min-width: 44px;
  width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.deck-primary-action,
.deck-secondary-action {
  margin-top: 0;
}

.run-management-card {
  margin-top: 1rem;
}

.completed-contracts {
  margin-bottom: 0.8rem;
}

.completed-contracts summary {
  cursor: pointer;
  color: #c7d0d5;
  font-weight: 850;
}

.completed-contracts .stack {
  margin-top: 0.8rem;
  margin-bottom: 0;
}

.destinations-card {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.current-location-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 0.65rem;
}

.destination-list {
  display: grid;
  gap: 0.65rem;
}

.destination-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.75rem;
}

.destination-row.over-capacity {
  border-color: rgba(255, 154, 170, 0.5);
}

.destination-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.stop-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #091113;
  background: #7bd8c6;
  font-weight: 900;
}

.destination-metrics {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  color: #aab7bf;
  font-size: 0.82rem;
}

.destination-metrics strong {
  color: #edf2f4;
}

.capacity-ok {
  color: #7bd8c6;
}

.capacity-danger {
  color: #ff9aaa;
  font-weight: 850;
}

.destination-action {
  grid-column: 2;
  margin-top: 0.25rem;
}

.dependency-note {
  margin-top: 0.3rem;
  color: #f0cc6b;
  font-size: 0.86rem;
}

.load-section {
  gap: 0.85rem;
}

.action-contract-group {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(16, 22, 27, 0.92);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}

.contract-group-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.75rem;
  background: rgba(38, 49, 58, 0.72);
}

.contract-group-heading h3 {
  font-size: 1.05rem;
}

.contract-group-body {
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem;
}

.wide-row {
  grid-column: 1 / -1;
}

.contract-commodity-summary {
  grid-column: 1 / -1;
  color: #edf2f4;
  font-size: 0.92rem;
  font-weight: 800;
}

.unload-zone-group {
  display: grid;
  gap: 0.75rem;
  border-left: 4px solid var(--zone-color);
}

.unload-zone-group h3 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1.2rem;
}

.zone-accent-card {
  border-left: 4px solid var(--zone-color);
}

.zone-settings-card {
  border-left: 4px solid var(--zone-color);
}

.zone-settings-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: center;
}

.assignment-zone-current {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.3rem;
  color: #aab7bf;
  font-size: 0.82rem;
}

.unload-line-list {
  display: grid;
  gap: 0.45rem;
}

.unload-line {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.55rem;
}

.unload-line:first-child {
  border-top: 0;
  padding-top: 0;
}

.unload-line-controls {
  display: grid;
  grid-template-columns: 34px 68px 34px 48px;
  gap: 0.3rem;
  align-items: center;
}

.unload-line-controls input {
  min-height: 34px;
  padding: 0.35rem;
  text-align: center;
}

.unload-all-button {
  min-width: 48px;
}

.cargo-elevator-popup {
  position: sticky;
  top: 4.8rem;
  z-index: 2;
  display: grid;
  gap: 0.25rem;
  margin-bottom: 0.8rem;
  border: 1px solid rgba(123, 216, 198, 0.34);
  border-radius: 8px;
  padding: 0.75rem 3.1rem 0.75rem 0.8rem;
  background: rgba(21, 33, 38, 0.97);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
  color: #c7d0d5;
}

.hint-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 34px;
}

.compact-empty {
  padding: 0.7rem 0;
}

.compact-empty h2 {
  font-size: 1.1rem;
}

.cargo-line-summary:first-child {
  border-top: 0;
  padding-top: 0;
}

.toggle {
  display: inline-flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
}

.toggle input {
  width: 20px;
  height: 20px;
}

.notice {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  border-radius: 8px;
  padding: 0.8rem;
  background: #28323a;
}

.notice.warning {
  background: #5c4721;
}

.notice.info {
  background: #263b4c;
}

.notice span {
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 0.75rem;
  padding: 2rem 0;
  color: #c7d0d5;
}

.section-title {
  color: #f0cc6b;
}

.progress-line {
  display: grid;
  gap: 0.4rem;
  margin: 0.85rem 0;
  color: #aab7bf;
}

progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #25313a;
}

progress::-webkit-progress-bar {
  background: #25313a;
}

progress::-webkit-progress-value,
progress::-moz-progress-bar {
  background: #0f8f7e;
}

.stepper {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  gap: 0.55rem;
  align-items: end;
}

.stepper label span {
  display: block;
  margin-bottom: 0.4rem;
}

.stepper input {
  text-align: center;
}

.full-width {
  width: 100%;
  margin-top: 0.85rem;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding-top: 0.7rem;
  background: linear-gradient(180deg, transparent, rgba(21, 27, 32, 0.98) 35%);
}

@media (min-width: 720px) {
  main {
    padding-bottom: 2.5rem;
  }

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

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

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

  .cargo-line-editor .card-header {
    grid-column: 1 / -1;
  }

  .cargo-line-summary {
    grid-template-columns: 1fr auto auto;
  }

  .hero-panel h2,
  .mode-header h2 {
    font-size: 2.4rem;
  }

  .destination-row {
    grid-template-columns: auto 1fr auto;
    align-items: center;
  }

  .destination-metrics {
    grid-column: auto;
    justify-content: end;
    text-align: right;
  }

  .destination-action {
    grid-column: 2 / -1;
  }
}

@media (max-width: 430px) {
  .current-location-card {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0.75rem 0.85rem;
  }

  main {
    padding: 0.75rem 0.75rem 6.5rem;
  }
}
