:root {
  --bg: #050814;
  --panel: rgba(15, 22, 46, 0.52);
  --panel-strong: rgba(24, 34, 68, 0.66);
  --line: rgba(147, 192, 255, 0.18);
  --line-strong: rgba(185, 225, 255, 0.34);
  --text: #eef6ff;
  --muted: #a9bddb;
  --bright: #7dff8d;
  --mild: #c8ffd2;
  --accent: #9ed0ff;
  --button: rgba(31, 54, 118, 0.88);
  --button-strong: rgba(38, 142, 112, 0.92);
  --shadow: 0 22px 60px rgba(1, 6, 20, 0.42);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background: transparent;
  overflow-x: hidden;
  position: relative;
}

body.app-loading .shell {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
}

body.app-loading .video-scrim {
  opacity: 0;
}

body.app-loading .bg-video {
  opacity: 1;
  filter: none;
}

body.app-ready .shell {
  opacity: 1;
  transform: none;
  transition: opacity 700ms ease, transform 700ms cubic-bezier(.2,.8,.2,1);
}

body.login-page {
  min-height: 100vh;
  background: transparent;
}

.bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  opacity: 1;
  filter: saturate(1.12) contrast(1.08) brightness(0.9);
  background: transparent;
}

.video-scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at 14% 18%, rgba(72, 170, 255, 0.16), transparent 24%),
    radial-gradient(circle at 82% 14%, rgba(126, 97, 255, 0.16), transparent 24%),
    radial-gradient(circle at 70% 76%, rgba(76, 255, 188, 0.14), transparent 26%),
    linear-gradient(180deg, rgba(4, 8, 18, 0.1), rgba(4, 8, 18, 0.26));
}

.shell {
  width: min(1600px, calc(100vw - 32px));
  margin: 24px auto;
  position: relative;
  z-index: 2;
}

.shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.16) 0 1px, transparent 1.5px),
    radial-gradient(circle at 74% 18%, rgba(255,255,255,0.13) 0 1px, transparent 1.6px),
    radial-gradient(circle at 68% 74%, rgba(255,255,255,0.1) 0 1px, transparent 1.4px),
    radial-gradient(circle at 32% 82%, rgba(255,255,255,0.12) 0 1px, transparent 1.4px);
  opacity: 0.9;
  animation: star-drift 18s linear infinite;
}

.panel {
  background:
    linear-gradient(180deg, rgba(18, 31, 66, 0.58), rgba(10, 16, 38, 0.4)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 rgba(236, 246, 255, 0.06),
    inset 0 -1px 0 rgba(66, 122, 255, 0.06),
    var(--shadow);
  backdrop-filter: blur(24px) saturate(1.15);
}

.hero {
  background: #131734;
  padding: 28px 32px;
  margin-bottom: 20px;
  position: relative;
  display: block;
  border-color: rgba(135, 160, 255, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(228, 238, 255, 0.08),
    0 18px 40px rgba(7, 11, 31, 0.42);
  backdrop-filter: none;
  text-align: center;
}

.brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.brand-mark img {
  display: block;
  width: min(540px, 48vw);
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 16px 26px rgba(0, 0, 0, 0.28));
}

.brand-subtitle {
  margin: 0;
  color: #e8d3ad;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.logout-form {
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
}

.ghost-button {
  background: rgba(14, 16, 12, 0.74);
}

.hero-tools {
  position: absolute;
  right: 164px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  width: 62px;
  height: 62px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 1.65rem;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.header-icon {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #fff0c4;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 10px rgba(255, 220, 145, 0.18));
}

.ornate-button,
.launch-card,
.ghost-button,
#build-cache-btn,
#analyze-btn,
#experimental-btn,
#edit-view-btn,
#delete-view-btn,
#save-view-btn,
#create-user-btn {
  background:
    linear-gradient(180deg, rgba(163, 120, 56, 0.96), rgba(84, 53, 21, 0.98));
  border: 1px solid rgba(255, 222, 160, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 244, 216, 0.12), 0 10px 30px rgba(0, 0, 0, 0.18);
}

.icon-button.ornate-button {
  background:
    radial-gradient(circle at 28% 24%, rgba(157, 219, 255, 0.32), transparent 30%),
    linear-gradient(180deg, rgba(53, 88, 186, 0.98), rgba(21, 35, 82, 0.98));
  border: 1px solid rgba(178, 214, 255, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(239, 247, 255, 0.18),
    0 0 0 1px rgba(16, 24, 56, 0.45),
    0 12px 26px rgba(3, 9, 29, 0.34),
    0 0 22px rgba(92, 145, 255, 0.2);
}

.icon-button.ornate-button:hover {
  transform: translateY(-2px) scale(1.03);
}

.primary {
  background:
    linear-gradient(180deg, rgba(75, 153, 71, 0.96), rgba(30, 96, 35, 0.98));
}

.ghost-button {
  min-width: 116px;
}

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

.control,
.content {
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.control::before,
.content::before,
.editor-card::before,
.loading-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(167, 215, 255, 0.07), transparent 24%),
    radial-gradient(circle at top right, rgba(96, 177, 255, 0.1), transparent 28%);
}

.panel-heading h2,
.tab-panel h2 {
  margin: 0 0 6px;
  font-family: Georgia, serif;
  color: #ffe6b3;
}

.panel-heading p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  color: #f4ddb0;
  font-weight: 600;
}

.field select,
.field input[type="text"],
.field input[type="password"] {
  width: 100%;
  border: 1px solid rgba(174, 210, 255, 0.24);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(227, 241, 255, 0.9);
  color: #101a2f;
  font-size: 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.field input[readonly] {
  opacity: 0.78;
  cursor: default;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox span {
  margin: 0;
}

.checkbox input {
  width: 18px;
  height: 18px;
}

.launch-card,
button {
  border: 1px solid rgba(168, 208, 255, 0.26);
  border-radius: 18px;
  padding: 15px 18px;
  cursor: pointer;
  color: var(--text);
  background: var(--button);
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

button:hover,
.launch-card:hover {
  transform: translateY(-1px);
  border-color: rgba(196, 229, 255, 0.52);
  box-shadow: 0 14px 28px rgba(9, 20, 49, 0.26);
}

.launch-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0 18px;
  background:
    linear-gradient(180deg, rgba(31, 53, 116, 0.86), rgba(15, 24, 61, 0.9));
  padding: 18px 20px;
}

.launch-card img {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  flex: 0 0 auto;
}

.ornate-link {
  text-decoration: none;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.secondary {
  width: 100%;
}

.status-line {
  margin-top: 18px;
  padding: 14px 16px;
  background: rgba(10, 18, 42, 0.36);
  border-radius: 16px;
  color: #dff3ff;
  min-height: 52px;
  line-height: 1.5;
  border: 1px solid rgba(156, 199, 255, 0.14);
}

.account-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stack-form {
  margin-top: 14px;
}

.account-modal-body {
  margin-top: 12px;
}

.mini-status {
  min-height: 22px;
  color: #b9f4b5;
  font-size: 0.92rem;
}

.mini-status.is-error {
  color: #ffd1d1;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  position: relative;
  z-index: 2;
}

.login-card {
  width: min(560px, calc(100vw - 32px));
  padding: 34px;
}

.login-card input,
.login-card button {
  position: relative;
  z-index: 3;
}

.login-form {
  margin-top: 24px;
}

.login-submit {
  width: 100%;
}

.login-error {
  margin: 18px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(90, 15, 15, 0.45);
  border: 1px solid rgba(255, 132, 132, 0.28);
  color: #ffd8d8;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.view-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
}

.view-actions h2 {
  margin: 0;
  font-family: Georgia, serif;
  color: #e7f2ff;
}

.view-actions-group {
  display: flex;
  gap: 10px;
}

.tab {
  background: rgba(14, 24, 52, 0.72);
  color: #bdd5f4;
}

.tab.is-active {
  background:
    linear-gradient(180deg, rgba(53, 88, 186, 0.94), rgba(23, 38, 96, 0.96));
  color: #f5fbff;
  box-shadow: 0 10px 24px rgba(13, 23, 59, 0.24);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.table-wrap {
  overflow: auto;
  border-radius: 20px;
  border: 1px solid rgba(255, 214, 145, 0.2);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(8, 15, 36, 0.46);
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(19, 32, 75, 0.88);
  color: #ddecff;
  text-align: left;
  padding: 14px 16px;
  font-size: 0.92rem;
}

tbody td {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

tbody tr.top {
  background: rgba(20, 88, 36, 0.82);
  color: var(--bright);
}

tbody tr.rest {
  background: rgba(14, 58, 25, 0.74);
  color: var(--mild);
}

tbody tr.loss {
  background: rgba(80, 18, 32, 0.54);
  color: #ffb8c2;
}

.signal-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.signal-cell img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.signal-arrow {
  display: inline-block;
  width: 16px;
  color: var(--bright);
  font-size: 1rem;
}

.signal-arrow.top {
  animation: pulse-arrow 900ms ease-in-out infinite alternate;
}

.signal-arrow.rest {
  color: var(--mild);
  animation: drift-arrow 1200ms ease-in-out infinite alternate;
}

.signal-arrow.loss {
  color: #ff8ea0;
  animation: drift-arrow 1200ms ease-in-out infinite alternate;
}

.route-plan {
  min-height: 520px;
  margin: 0;
  padding: 18px;
  white-space: pre-wrap;
  line-height: 1.6;
  color: #eff6ff;
  background: rgba(13, 25, 58, 0.42);
  border: 1px solid rgba(120, 167, 230, 0.24);
  border-radius: 20px;
}

.loading-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 32px;
  background: transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
  z-index: 50;
}

.loading-modal.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: none;
}

body.app-loading .loading-modal {
  background: transparent;
}

body.app-loading .shell::before {
  opacity: 0;
}

.loading-card {
  width: min(360px, calc(100vw - 64px));
  margin: 0;
  padding: 28px 24px;
  border: 1px solid rgba(147, 192, 255, 0.18);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(14, 24, 52, 0.42), rgba(8, 14, 34, 0.3)),
    rgba(10, 16, 38, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(236, 246, 255, 0.06),
    0 18px 42px rgba(1, 6, 20, 0.2);
  text-align: left;
  backdrop-filter: blur(18px) saturate(1.08);
  pointer-events: none;
}

.loading-card h2 {
  margin: 18px 0 8px;
  color: #eef6ff;
  font-family: Georgia, serif;
}

.loading-card p {
  margin: 0;
  color: #c8d8f0;
  line-height: 1.5;
}

.loading-ring {
  width: 78px;
  height: 78px;
  margin: 0;
  border-radius: 999px;
  border: 6px solid rgba(111, 255, 124, 0.18);
  border-top-color: #59ff61;
  border-right-color: #d0ff9e;
  box-shadow: 0 0 24px rgba(89, 255, 97, 0.24);
  animation: spin-ring 900ms linear infinite;
}

.editor-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 8, 22, 0.4);
  backdrop-filter: blur(10px);
}

.editor-modal[hidden] {
  display: none;
}

.editor-card {
  width: min(980px, calc(100vw - 32px));
  padding: 26px;
  background:
    linear-gradient(180deg, rgba(16, 28, 66, 0.72), rgba(8, 14, 34, 0.66)),
    rgba(9, 15, 34, 0.54);
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}

.editor-list h3 {
  margin: 0 0 10px;
  color: #f0dbb0;
  font-family: Georgia, serif;
}

.result-list {
  min-height: 260px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid rgba(255, 214, 145, 0.18);
  border-radius: 18px;
  background: rgba(9, 16, 38, 0.52);
  padding: 10px;
}

.result-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 214, 145, 0.12);
  background: rgba(19, 31, 69, 0.62);
  color: #eef7ff;
}

.result-row.static {
  cursor: default;
}

.result-row-main {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.result-row-main img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.tiny-button {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.86rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

@keyframes pulse-arrow {
  from { transform: translateY(1px) scale(1); opacity: 0.84; }
  to { transform: translateY(-2px) scale(1.1); opacity: 1; }
}

@keyframes drift-arrow {
  from { transform: translateY(1px); opacity: 0.72; }
  to { transform: translateY(-1px); opacity: 1; }
}

@keyframes spin-ring {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes star-drift {
  from { transform: translateY(0); }
  to { transform: translateY(20px); }
}

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

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

  .hero-tools {
    position: static;
    transform: none;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 14px;
  }

  .brand-mark {
    position: static;
    transform: none;
  }

  .logout-form {
    position: static;
    transform: none;
    margin-top: 14px;
  }

  .view-actions {
    flex-direction: column;
    align-items: flex-start;
  }

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