:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: rgba(8, 16, 22, 0.76);
  --panel-strong: rgba(10, 24, 30, 0.92);
  --line: rgba(122, 255, 202, 0.24);
  --text: #e9fff7;
  --muted: #8ab8aa;
  --green: #43ff9b;
  --cyan: #55d7ff;
  --amber: #ffd166;
  --red: #ff4d6d;
  --violet: #a78bfa;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 8%, rgba(85, 215, 255, 0.12), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(255, 209, 102, 0.08), transparent 24%),
    linear-gradient(135deg, #05070a 0%, #07100f 46%, #0d0914 100%);
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 4px),
    linear-gradient(90deg, transparent, rgba(67, 255, 155, 0.06), transparent);
  mix-blend-mode: screen;
}

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#matrixRain {
  z-index: 0;
  opacity: 0.5;
}

#networkCanvas {
  z-index: 1;
  opacity: 0.75;
}

.ops-shell {
  position: relative;
  z-index: 2;
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  gap: 18px;
}

body:not(.is-authenticated) .ops-shell {
  display: none;
}

body.is-authenticated .login-gate {
  display: none;
}

.login-gate {
  position: relative;
  z-index: 3;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-shell {
  position: relative;
  width: min(980px, 100%);
  min-height: 600px;
  display: grid;
  place-items: center;
}

.login-orbit {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.login-orbit span {
  position: absolute;
  width: min(74vw, 620px);
  aspect-ratio: 1;
  border: 1px solid rgba(85, 215, 255, 0.16);
  border-radius: 50%;
  animation: spin 18s linear infinite;
}

.login-orbit span:nth-child(2) {
  width: min(62vw, 500px);
  border-style: dashed;
  border-color: rgba(67, 255, 155, 0.2);
  animation-duration: 13s;
  animation-direction: reverse;
}

.login-orbit span:nth-child(3) {
  width: min(48vw, 360px);
  border-color: rgba(255, 209, 102, 0.18);
  animation-duration: 9s;
}

.login-panel {
  position: relative;
  width: min(520px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  background: rgba(8, 16, 22, 0.82);
  box-shadow: 0 0 0 1px rgba(67, 255, 155, 0.08), 0 30px 100px rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(18px);
}

.login-copy {
  margin: 34px 0 20px;
}

.login-copy h1 {
  font-size: clamp(42px, 7vw, 82px);
}

.login-copy p:not(.kicker) {
  margin: 16px 0 0;
  color: #b8d7cf;
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.7;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
}

.login-form label span {
  color: var(--muted);
  font-size: 12px;
}

.login-form input {
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid rgba(85, 215, 255, 0.34);
  outline: 0;
  color: var(--text);
  background: rgba(7, 16, 24, 0.78);
}

.login-form input:focus {
  border-color: rgba(67, 255, 155, 0.72);
  box-shadow: 0 0 22px rgba(67, 255, 155, 0.14);
}

.login-feedback {
  min-height: 20px;
  margin: 0;
  color: var(--amber);
  font-size: 13px;
}

.command-bar,
.terminal-window,
.intel-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(67, 255, 155, 0.06), 0 24px 80px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(16px);
}

.command-bar {
  min-height: 72px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-lockup,
.signal-strip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-sigil {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(85, 215, 255, 0.55);
  background: rgba(85, 215, 255, 0.12);
  color: var(--cyan);
  font-weight: 900;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup strong {
  font-size: 18px;
}

.brand-lockup span,
.kicker,
.card-head span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.signal {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 18px currentColor;
}

.signal.warning {
  background: var(--amber);
}

.signal.danger {
  background: var(--red);
}

#clock {
  min-width: 86px;
  text-align: right;
  color: var(--cyan);
}

.logout-btn {
  min-height: 34px;
  padding: 0 10px;
  color: var(--cyan);
  border-color: rgba(85, 215, 255, 0.32);
  background: rgba(7, 16, 24, 0.62);
  font-size: 12px;
}

.hero-console {
  min-height: 540px;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.hero-copy {
  min-height: 100%;
  padding: clamp(26px, 6vw, 74px) 0 clamp(20px, 4vw, 42px);
  display: grid;
  align-content: center;
}

.kicker {
  margin: 0 0 12px;
  color: var(--amber);
  font-weight: 800;
}

h1 {
  max-width: 760px;
  margin: 0;
  color: #f2fff9;
  font-size: clamp(44px, 8vw, 104px);
  line-height: 0.95;
  letter-spacing: 0;
  text-shadow: 0 0 30px rgba(67, 255, 155, 0.28);
}

.brief {
  max-width: 680px;
  margin: 22px 0 0;
  color: #b8d7cf;
  font-family: Inter, "Noto Sans SC", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.75;
}

.action-dock {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.check-form {
  width: min(560px, 100%);
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.gateway-panel {
  width: min(760px, 100%);
  margin-top: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
  border: 1px solid rgba(85, 215, 255, 0.22);
  background: rgba(7, 16, 24, 0.7);
}

.gateway-panel[hidden] {
  display: none;
}

.gateway-panel span {
  display: block;
  color: var(--amber);
  font-size: 11px;
  margin-bottom: 4px;
}

.gateway-panel strong {
  color: #c8fff0;
  font-size: 13px;
  font-weight: 600;
}

.gateway-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px auto auto;
  gap: 8px;
  align-items: center;
}

.gateway-row input {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(85, 215, 255, 0.34);
  outline: 0;
  color: var(--text);
  background: rgba(7, 16, 24, 0.78);
}

.gateway-row img {
  width: 92px;
  height: 42px;
  object-fit: contain;
  border: 1px solid rgba(122, 255, 202, 0.2);
  background: #ffffff;
}

#yfxGatewayFeedback {
  min-height: 18px;
  margin: 0;
  color: var(--amber);
  font-size: 12px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 46px;
  border: 1px solid rgba(67, 255, 155, 0.42);
  color: var(--text);
  background: rgba(9, 28, 23, 0.82);
  cursor: pointer;
}

a.control-link {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.run-btn,
.ghost-btn {
  padding: 0 18px;
}

.run-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, rgba(67, 255, 155, 0.28), rgba(85, 215, 255, 0.16));
}

.btn-light {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
}

.ghost-btn {
  border-color: rgba(85, 215, 255, 0.38);
  color: var(--cyan);
  background: rgba(7, 16, 24, 0.62);
}

.check-form select {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(85, 215, 255, 0.34);
  outline: 0;
  color: var(--text);
  background: rgba(7, 16, 24, 0.78);
}

.terminal-window {
  min-height: 540px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.window-top {
  min-height: 42px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(122, 255, 202, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

.window-top span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
}

.window-top span:nth-child(2) {
  background: var(--amber);
}

.window-top span:nth-child(3) {
  background: var(--green);
}

.window-top b {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
}

#terminalLog {
  margin: 0;
  padding: 18px;
  overflow: hidden;
  white-space: pre-wrap;
  color: #baffd7;
  font-size: 14px;
  line-height: 1.7;
}

.command-input {
  min-height: 50px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(122, 255, 202, 0.18);
  background: var(--panel-strong);
}

.command-input span {
  color: var(--green);
  flex: 0 0 auto;
  font-size: 13px;
}

.command-input input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.intel-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
  gap: 18px;
}

.intel-card {
  min-height: 190px;
  padding: 16px;
  overflow: hidden;
}

.intel-card.wide {
  grid-row: span 2;
  min-height: 398px;
}

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

.card-head b {
  color: var(--green);
  font-size: 13px;
}

.map-stage {
  position: relative;
  height: 320px;
  border: 1px solid rgba(85, 215, 255, 0.12);
  background:
    linear-gradient(rgba(85, 215, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(85, 215, 255, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
}

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

.stat-block {
  min-height: 116px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  border: 1px solid rgba(85, 215, 255, 0.14);
  background: rgba(3, 10, 14, 0.54);
}

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

.stat-block strong {
  color: var(--text);
  font-size: clamp(18px, 2.2vw, 28px);
  overflow-wrap: anywhere;
}

.mini-meter {
  height: 8px;
  padding: 1px;
  border: 1px solid rgba(67, 255, 155, 0.24);
}

.mini-meter i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--amber));
  transition: width 500ms ease;
}

.core-ring {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 132px;
  height: 132px;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(67, 255, 155, 0.62);
  border-radius: 50%;
  color: var(--green);
  animation: pulse 2.2s infinite;
}

.core-ring span {
  position: absolute;
  inset: 18px;
  border: 1px dashed rgba(85, 215, 255, 0.55);
  border-radius: 50%;
  animation: spin 8s linear infinite;
}

.node {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  background: #061219;
  box-shadow: 0 0 20px rgba(85, 215, 255, 0.72);
}

.n1 { left: 12%; top: 22%; }
.n2 { right: 14%; top: 18%; border-color: var(--amber); }
.n3 { left: 20%; bottom: 18%; border-color: var(--violet); }
.n4 { right: 18%; bottom: 24%; }
.n5 { left: 50%; top: 8%; border-color: var(--red); }

.route {
  position: absolute;
  height: 1px;
  transform-origin: left center;
  background: linear-gradient(90deg, transparent, rgba(67, 255, 155, 0.8), transparent);
  animation: routeFlash 1.8s infinite;
}

.r1 { left: 16%; top: 27%; width: 34%; rotate: 19deg; }
.r2 { left: 50%; top: 49%; width: 34%; rotate: -31deg; animation-delay: 0.4s; }
.r3 { left: 23%; bottom: 24%; width: 30%; rotate: -18deg; animation-delay: 0.8s; }
.r4 { left: 52%; top: 21%; width: 24%; rotate: 38deg; animation-delay: 1.1s; }

.meter {
  height: 16px;
  padding: 3px;
  border: 1px solid rgba(67, 255, 155, 0.35);
  background: rgba(255, 255, 255, 0.04);
}

.meter span {
  display: block;
  width: 98%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--amber));
  box-shadow: 0 0 18px rgba(67, 255, 155, 0.36);
  transition: width 500ms ease;
}

#cipherKey {
  margin: 28px 0 0;
  color: var(--cyan);
  overflow-wrap: anywhere;
}

.bars {
  height: 112px;
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  align-items: end;
  gap: 5px;
}

.bars span {
  min-height: 12px;
  background: linear-gradient(180deg, var(--cyan), var(--green));
  opacity: 0.78;
}

.alert-card {
  grid-column: span 2;
}

.alert-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.alert-card li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(122, 255, 202, 0.13);
  color: #c8fff0;
}

.fleet-panel {
  border: 1px solid var(--line);
  background: rgba(8, 16, 22, 0.76);
  box-shadow: 0 0 0 1px rgba(67, 255, 155, 0.06), 0 24px 80px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(16px);
  padding: 16px;
}

.fleet-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

.fleet-head h2 {
  margin: 6px 0 0;
  font-size: clamp(22px, 3vw, 36px);
}

.fleet-head b {
  color: var(--cyan);
  font-size: 13px;
  text-align: right;
}

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

.empty-fleet {
  grid-column: 1 / -1;
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(85, 215, 255, 0.28);
  color: var(--muted);
}

.fleet-card {
  min-height: 286px;
  padding: 14px;
  border: 1px solid rgba(85, 215, 255, 0.18);
  background: rgba(3, 10, 14, 0.58);
}

.fleet-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.fleet-card-top span,
.fleet-card dt {
  color: var(--muted);
  font-size: 11px;
}

.fleet-card-top strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.fleet-card em {
  height: 24px;
  padding: 4px 8px;
  color: var(--green);
  border: 1px solid rgba(67, 255, 155, 0.3);
  font-style: normal;
  font-size: 11px;
  text-transform: uppercase;
}

.fleet-card.is-warning em {
  color: var(--amber);
  border-color: rgba(255, 209, 102, 0.35);
}

.fleet-card.is-standby em,
.fleet-card.is-syncing em {
  color: var(--cyan);
  border-color: rgba(85, 215, 255, 0.35);
}

.fleet-card dl {
  margin: 0 0 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fleet-card dd {
  margin: 3px 0 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.resource-line {
  display: grid;
  grid-template-columns: 42px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}

.resource-line span,
.resource-line strong {
  color: var(--muted);
}

.resource-line i {
  height: 7px;
  border: 1px solid rgba(67, 255, 155, 0.22);
}

.resource-line b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--amber));
}

.fleet-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.fleet-actions button {
  min-height: 34px;
  padding: 0 8px;
  font-size: 11px;
  color: var(--cyan);
  border-color: rgba(85, 215, 255, 0.28);
  background: rgba(7, 16, 24, 0.62);
}

.alert-card em {
  color: var(--amber);
  font-style: normal;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 40px rgba(67, 255, 155, 0.34), inset 0 0 28px rgba(67, 255, 155, 0.16);
  }
}

@keyframes spin {
  to {
    rotate: 360deg;
  }
}

@keyframes routeFlash {
  50% {
    opacity: 0.25;
  }
}

@media (max-width: 980px) {
  .hero-console,
  .intel-grid,
  .fleet-grid {
    grid-template-columns: 1fr;
  }

  .hero-console,
  .terminal-window {
    min-height: auto;
  }

  .terminal-window {
    height: 460px;
  }

  .alert-card {
    grid-column: auto;
  }
}

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

  .command-bar,
  .signal-strip {
    align-items: flex-start;
  }

  .command-bar {
    flex-direction: column;
  }

  .login-panel {
    padding: 20px;
  }

  h1 {
    font-size: 42px;
  }

  .brief {
    font-size: 16px;
  }

  .check-form,
  .status-grid,
  .gateway-row {
    grid-template-columns: 1fr;
  }

  .fleet-head {
    align-items: start;
    flex-direction: column;
  }

  .fleet-head b {
    text-align: left;
  }

  .intel-card.wide {
    min-height: 330px;
  }

  .map-stage {
    height: 250px;
  }
}
