:root {
  --bg: #0b1017;
  --bg-soft: #121c28;
  --panel: rgba(12, 18, 26, 0.86);
  --panel-strong: rgba(16, 24, 35, 0.94);
  --panel-outline: rgba(167, 202, 255, 0.12);
  --text: #edf4ff;
  --text-muted: rgba(237, 244, 255, 0.68);
  --text-dim: rgba(237, 244, 255, 0.48);
  --accent: #ff8d59;
  --accent-cool: #73ebd3;
  --ok: #6be49b;
  --warn: #ffc86f;
  --danger: #ff6f7b;
  --shadow: 0 24px 80px rgba(2, 8, 15, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 141, 89, 0.16), transparent 24%),
    radial-gradient(circle at 80% 8%, rgba(115, 235, 211, 0.12), transparent 20%),
    linear-gradient(180deg, #091019 0%, #0c1520 38%, #091018 100%);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  color: inherit;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.backdrop-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 94%);
}

.backdrop-glow {
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 141, 89, 0.12), transparent 24%),
    radial-gradient(circle at 85% 25%, rgba(115, 235, 211, 0.14), transparent 22%);
  filter: blur(30px);
}

.shell {
  position: relative;
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.4rem 1.1rem 2.4rem;
  animation: fade-up 380ms ease-out;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, var(--panel) 0%, var(--panel-strong) 100%);
  border: 1px solid var(--panel-outline);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.9fr);
  gap: 1.3rem;
  padding: 1.45rem;
}

.brand-block h1,
.panel h2,
.panel h3,
.timeline-head strong,
.feed-head strong {
  margin: 0;
}

.brand-block h1 {
  font-size: clamp(2.35rem, 5vw, 4.8rem);
  line-height: 0.96;
  max-width: 11ch;
}

.eyebrow,
.label,
.chip,
.runtime-value,
.metric-subtext,
.monitor-meta,
.feed-meta,
.cell-subtext,
.progress-head,
.timeline-meta,
.timeline-subtext {
  font-family: "IBM Plex Mono", monospace;
}

.eyebrow {
  margin: 0 0 0.45rem;
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-cool);
}

.lede,
.thesis,
.timeline-text,
.feed-text,
#statusBanner {
  color: var(--text-muted);
  line-height: 1.6;
}

#modeBadge {
  display: inline-flex;
  padding: 0.08rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 141, 89, 0.16);
  color: #ffd8bf;
}

.status-strip,
.panel-badges,
.command-actions,
.button-row,
.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.status-strip {
  margin-top: 1.2rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.1rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.76rem;
}

.chip-ok {
  background: rgba(107, 228, 155, 0.12);
  color: #bff5d1;
}

.chip-warn {
  background: rgba(255, 200, 111, 0.14);
  color: #ffe1a8;
}

.command-block {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}

.monitor-box,
.progress-card,
.decision-card,
.feed-item,
.timeline-item,
.stacked-field input,
.stacked-field select {
  background: rgba(255, 255, 255, 0.04);
}

.monitor-box {
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 22px;
}

.stacked-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stacked-field span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stacked-field input,
.stacked-field select {
  min-height: 2.85rem;
  padding: 0.7rem 0.85rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  outline: 0;
}

.stacked-field input:focus,
.stacked-field select:focus {
  border-color: rgba(115, 235, 211, 0.4);
  box-shadow: 0 0 0 4px rgba(115, 235, 211, 0.08);
}

.is-readonly input {
  color: var(--text-dim);
  cursor: not-allowed;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.toggle input {
  accent-color: var(--accent);
}

.action,
.preset {
  min-height: 3rem;
  padding: 0.85rem 1.05rem;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.action:hover:not(:disabled),
.preset:hover {
  transform: translateY(-1px);
}

.action:disabled {
  opacity: 0.6;
  cursor: progress;
}

.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #ffb26b 100%);
  color: #10171f;
  box-shadow: 0 12px 24px rgba(255, 141, 89, 0.22);
}

.secondary {
  background: linear-gradient(135deg, rgba(115, 235, 211, 0.18), rgba(115, 235, 211, 0.08));
  color: #dffcf5;
  border: 1px solid rgba(115, 235, 211, 0.18);
}

.quiet {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.danger {
  background: linear-gradient(135deg, rgba(255, 111, 123, 0.18), rgba(255, 111, 123, 0.08));
  color: #ffd4d8;
  border: 1px solid rgba(255, 111, 123, 0.18);
}

.preset {
  flex: 1 1 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.metrics-grid,
.activity-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

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

.metric-card {
  padding: 1.2rem;
}

.metric-hero {
  background:
    radial-gradient(circle at top left, rgba(255, 141, 89, 0.18), transparent 40%),
    linear-gradient(180deg, rgba(255, 141, 89, 0.08), rgba(16, 24, 35, 0.96));
}

.metric-value {
  margin: 0.25rem 0;
  font-size: clamp(1.7rem, 2.6vw, 2.55rem);
  font-weight: 700;
}

.metric-subtext {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.95fr);
  gap: 1rem;
  margin-top: 1rem;
}

.column-main,
.column-side {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.market-panel,
.intelligence-panel,
.positions-panel,
.command-panel,
.settings-panel,
.runtime-panel,
.activity-grid > .panel,
.statusbar {
  padding: 1.3rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

#sparkline {
  display: block;
  width: 100%;
  height: 220px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    radial-gradient(circle at top, rgba(255, 141, 89, 0.16), transparent 55%);
}

#sparkline .spark-grid {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.market-board,
.console-grid,
.runtime-grid,
.decision-grid,
.progress-grid,
.form-grid {
  display: grid;
  gap: 0.9rem;
}

.market-board,
.console-grid,
.runtime-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.decision-card,
.progress-card {
  padding: 0.95rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.decision-value,
.board-value,
.console-value {
  margin: 0.25rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.thesis {
  margin: 1rem 0 0.8rem;
}

.flag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.flag-list li {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 111, 123, 0.12);
  color: #ffd4d8;
  font-size: 0.83rem;
}

.flag-list .flag-safe {
  background: rgba(107, 228, 155, 0.12);
  color: #d6ffe5;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.76rem;
  margin-bottom: 0.65rem;
  color: var(--text-muted);
}

.progress-track {
  height: 0.72rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-cool) 100%);
  transition: width 220ms ease;
}

.table-shell {
  margin-top: 1rem;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.data-table th,
.data-table td {
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  vertical-align: top;
}

.data-table thead th {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.table-body.empty-state {
  color: var(--text-muted);
}

.position-footer {
  margin-top: 1rem;
  color: var(--text-muted);
}

.stack-form,
.settings-form {
  display: grid;
  gap: 1rem;
}

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

.form-cluster h3 {
  font-size: 1rem;
}

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

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

.timeline,
.table-feed {
  display: grid;
  gap: 0.8rem;
}

.timeline-item,
.feed-item {
  padding: 0.95rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.timeline-head,
.feed-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
}

.timeline-meta,
.timeline-subtext,
.feed-meta,
.cell-subtext {
  margin: 0.25rem 0 0;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.feed-text,
.timeline-text {
  margin: 0.5rem 0 0;
}

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

.runtime-value {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-word;
}

.statusbar {
  margin-top: 1rem;
}

#statusBanner {
  margin: 0;
}

#statusBanner[data-tone="success"] {
  color: #d8ffea;
}

#statusBanner[data-tone="warning"] {
  color: #ffe6bb;
}

#statusBanner[data-tone="danger"] {
  color: #ffd1d6;
}

.label {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.positive {
  color: var(--ok);
}

.negative {
  color: var(--danger);
}

.empty-state {
  color: var(--text-muted);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .decision-grid,
  .market-board,
  .console-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .topbar,
  .main-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .shell {
    padding: 1rem 0.85rem 2rem;
  }

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

  .decision-grid,
  .market-board,
  .console-grid,
  .runtime-grid {
    grid-template-columns: 1fr;
  }

  .command-actions,
  .button-row,
  .preset-grid {
    flex-direction: column;
  }

  .metric-value {
    font-size: 1.55rem;
  }
}
