:root {
  color-scheme: dark;
  --bg: #0f0f0f;
  --panel: #171717;
  --panel-2: #202020;
  --line: #383838;
  --line-strong: #535353;
  --text: #f6f6f6;
  --muted: #bdbdbd;
  --accent: #ff7417;
  --accent-2: #ff9b57;
  --success: #79d18b;
  --danger: #df5b4f;
  --warning: #ffd06b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(255, 116, 23, 0.22), transparent 28%),
    linear-gradient(180deg, #0c0c0c 0%, #121212 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
textarea,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 26px auto 44px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  margin-bottom: 18px;
  padding: 24px 26px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 116, 23, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)),
    var(--panel);
  box-shadow: var(--shadow);
}

.deck-header {
  align-items: stretch;
}

.deck-controls {
  display: grid;
  gap: 10px;
  justify-items: end;
  min-width: min(660px, 100%);
}

.deck-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: clamp(118px, 15vw, 185px);
  max-height: 118px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.38));
}

.brand-title > div {
  min-width: 0;
}

.section-label {
  display: inline-block;
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.02;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.flight-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 260px));
  gap: 10px;
  min-width: min(260px, 100%);
  justify-content: end;
}

.identity-card,
.api-light {
  min-height: 62px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.identity-card span,
.static-label,
dt,
label {
  display: block;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.identity-card strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.identity-card em {
  display: inline-block;
  margin-top: 8px;
  color: var(--success);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.identity-card[data-auth-state="blocked"] {
  border-color: rgba(223, 91, 79, 0.65);
}

.identity-card[data-auth-state="blocked"] em {
  color: var(--danger);
}

.api-light {
  display: flex;
  align-items: center;
  gap: 12px;
}

.api-light strong {
  color: var(--text);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.light-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 0 5px rgba(255, 208, 107, 0.12), 0 0 22px rgba(255, 208, 107, 0.65);
}

.api-light[data-state="connected"] .light-dot {
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(121, 209, 139, 0.12), 0 0 22px rgba(121, 209, 139, 0.65);
}

.api-light[data-state="offline"] .light-dot {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(223, 91, 79, 0.12), 0 0 22px rgba(223, 91, 79, 0.65);
}

.tool-layout {
  position: relative;
  display: grid;
  gap: 14px;
}

.tool-panel,
.diagnostics,
.notice {
  border: 1px solid var(--line);
  background: rgba(23, 23, 23, 0.96);
  box-shadow: var(--shadow);
}

.tool-panel {
  display: grid;
  gap: 18px;
  padding: 26px;
}

.field-group {
  display: grid;
  gap: 9px;
}

textarea {
  width: 100%;
  min-height: 238px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--text);
  padding: 16px;
  outline: none;
  resize: vertical;
  font-size: 21px;
  line-height: 1.35;
  letter-spacing: 0;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea::placeholder {
  color: #777;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input::placeholder {
  color: #777;
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible,
summary:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 116, 23, 0.14);
  outline: none;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.primary-action {
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #101010;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.primary-action:hover {
  filter: brightness(1.06);
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.78;
}

.ready-message {
  color: var(--muted);
  font-size: 14px;
}

.bin-status {
  padding: 13px 15px;
  border: 1px solid rgba(255, 208, 107, 0.5);
  background: rgba(255, 208, 107, 0.08);
  color: var(--warning);
  font-size: 14px;
  line-height: 1.45;
}

.bin-status[hidden] {
  display: none;
}

.download-location {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid rgba(121, 209, 139, 0.5);
  background: rgba(121, 209, 139, 0.08);
}

.download-location[hidden] {
  display: none;
}

.download-location span {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.download-location strong {
  color: var(--text);
  font-size: 15px;
}

.download-location code {
  display: block;
  width: 100%;
  color: var(--success);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.flight-progress {
  display: none;
  grid-template-columns: minmax(180px, 260px) minmax(240px, 1fr);
  gap: 22px;
  align-items: center;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.flight-progress.is-active {
  display: grid;
}

.flight-copy span {
  display: block;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.flight-copy strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
}

.island-hop {
  position: relative;
  height: 86px;
  overflow: hidden;
  border-top: 1px dashed rgba(255, 255, 255, 0.18);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
}

.island-hop::before {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 43px;
  border-top: 2px dotted rgba(255, 116, 23, 0.58);
}

.island {
  position: absolute;
  bottom: 12px;
  width: 42px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 116, 23, 0.5), rgba(255, 155, 87, 0.15));
}

.island-a {
  left: 6%;
}

.island-b {
  left: 45%;
}

.island-c {
  right: 6%;
}

.plane {
  position: absolute;
  left: -80px;
  top: 13px;
  width: 54px;
  height: 54px;
  fill: var(--accent);
  filter: drop-shadow(0 0 14px rgba(255, 116, 23, 0.5));
  animation: island-hop 3.8s cubic-bezier(0.42, 0, 0.24, 1) infinite;
}

@keyframes island-hop {
  0% {
    transform: translate(0, 24px) rotate(-8deg);
  }
  28% {
    transform: translate(34vw, -5px) rotate(5deg);
  }
  58% {
    transform: translate(58vw, 14px) rotate(-2deg);
  }
  100% {
    transform: translate(88vw, -12px) rotate(7deg);
  }
}

.diagnostics {
  width: min(760px, 100%);
  justify-self: end;
  opacity: 0.42;
  transition: opacity 0.16s ease;
}

.diagnostics:hover,
.diagnostics[open] {
  opacity: 1;
}

.diagnostics summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diagnostics summary b {
  color: var(--accent-2);
  font-size: 10px;
  font-weight: 900;
}

.diagnostic-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 12px 12px;
}

.diagnostic-section {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.025);
}

.diagnostic-section h2 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  line-height: 1.1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diagnostics dl {
  margin: 0;
  padding: 0 12px 10px;
}

.diagnostics dl > div {
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.diagnostics dl > div:first-child {
  border-top: 0;
}

.diagnostic-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 2px 0 0;
}

.ghost-action {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ghost-action:hover {
  border-color: var(--accent);
  color: var(--text);
}

.diagnostic-actions span {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.notice {
  margin: 0 0 14px;
  padding: 14px 16px;
  color: var(--danger);
  background: rgba(223, 91, 79, 0.08);
  font-size: 14px;
}

.notice-success {
  color: #d9ffe0;
  background: rgba(121, 209, 139, 0.1);
}

.auth-shell {
  width: min(620px, calc(100vw - 32px));
}

.login-panel {
  gap: 18px;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  text-decoration: none;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.module-select {
  width: min(230px, 100%);
  min-height: 38px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 30px 0 10px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.ghost-link:hover,
.nav-button:hover {
  border-color: var(--accent);
  color: var(--accent-2);
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.module-card {
  display: grid;
  gap: 10px;
  min-height: 130px;
  padding: 20px;
  border: 1px solid var(--line);
  background: rgba(23, 23, 23, 0.96);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.module-card:hover {
  border-color: var(--accent);
}

.module-card span,
.panel-title {
  margin: 0;
  color: var(--accent-2);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.module-card strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
}

.admin-layout {
  grid-template-columns: minmax(280px, 420px) 1fr;
  align-items: start;
}

.admin-form {
  gap: 16px;
}

.user-edit-panel {
  gap: 16px;
}

.admin-user-picker {
  max-width: 560px;
}

.user-card-grid {
  display: grid;
  gap: 14px;
}

.user-edit-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.user-edit-card[hidden] {
  display: none;
}

.user-edit-card.is-selected {
  border-color: rgba(255, 116, 23, 0.58);
}

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

.user-edit-head strong {
  display: block;
  color: var(--text);
  font-size: 16px;
}

.user-edit-head em {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  overflow-wrap: anywhere;
}

.field-hint {
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.check-grid {
  display: grid;
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 10px 11px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--accent-2);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fresh-listing-shell {
  width: min(1440px, calc(100vw - 32px));
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.metric-card {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(23, 23, 23, 0.96);
  box-shadow: var(--shadow);
}

.metric-card span {
  display: block;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  line-height: 1;
}

.fresh-grid {
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  align-items: start;
  margin-bottom: 14px;
}

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

.compact-panel {
  gap: 16px;
  padding: 20px;
}

.compact-panel input[type="text"],
.compact-panel input[type="number"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.compact-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 116, 23, 0.18);
}

.queue-panel {
  margin-bottom: 14px;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.download-item {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.download-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.notice-warning {
  color: #fff4cc;
  background: rgba(255, 208, 107, 0.1);
}

.fresh-two-col {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1.15fr);
  gap: 14px;
}

.store-write-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
  margin: 12px 0 16px;
}

.store-write-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.store-write-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.store-write-card input[type="text"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
}

.store-write-card input[type="text"]:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 116, 23, 0.18);
}

.danger-action {
  background: #b92618;
}

.subhead {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.queue-table td {
  max-width: 340px;
  overflow-wrap: anywhere;
}

.training-table td:nth-child(4) {
  min-width: 300px;
}

.training-actions {
  display: flex;
  justify-content: flex-end;
  margin: 12px 0;
}

.training-form {
  display: grid;
  gap: 10px;
}

.training-form label {
  display: grid;
  gap: 5px;
}

.training-form label span {
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.training-form input[type="text"] {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
}

.training-form input[type="text"]:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 116, 23, 0.18);
}

.fresh-working {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(10, 10, 10, 0.58);
  backdrop-filter: blur(3px);
}

.fresh-working.is-active {
  display: grid;
}

.fresh-working-card {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  width: min(420px, calc(100vw - 36px));
  min-height: 84px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 116, 23, 0.46);
  background: rgba(18, 18, 18, 0.98);
  box-shadow: var(--shadow);
}

.fresh-spinner {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: fresh-spin 0.9s linear infinite;
}

.fresh-working-copy {
  display: grid;
  gap: 4px;
}

.fresh-working-copy strong {
  color: var(--text);
  font-size: 16px;
  line-height: 1.2;
}

.fresh-working-copy em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.35;
}

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

@media (prefers-reduced-motion: reduce) {
  .fresh-spinner {
    animation-duration: 1.8s;
  }
}

.notice-hidden {
  display: none;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(calc(100vw - 20px), 720px);
    margin-top: 10px;
  }

  .masthead,
  .deck-controls,
  .flight-status,
  .flight-progress,
  .admin-layout,
  .fresh-grid,
  .fresh-grid.two-up,
  .fresh-two-col,
  .store-write-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .deck-controls,
  .deck-nav {
    justify-items: stretch;
    justify-content: stretch;
  }

  .nav-button,
  .module-select {
    width: 100%;
  }

  h1 {
    font-size: 30px;
  }

  .brand-title {
    align-items: flex-start;
    gap: 14px;
  }

  .brand-logo {
    width: 104px;
    max-height: 86px;
  }

  .tool-panel,
  .masthead {
    padding: 18px;
  }

  textarea {
    min-height: 210px;
    font-size: 18px;
  }

  .primary-action {
    width: 100%;
  }

  .diagnostics {
    justify-self: stretch;
  }

  .diagnostic-body {
    grid-template-columns: 1fr;
  }

  .diagnostic-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .plane {
    animation: none;
    left: auto;
    right: 18px;
    transform: rotate(3deg);
  }
}
