:root {
  --bg: #0f1218;
  --surface: #171b22;
  --surface-2: #1f2530;
  --line: #2c3442;
  --line-soft: #242b36;
  --text: #edf1f7;
  --muted: #9aa5b5;
  --green: #2fd27b;
  --red: #ff6673;
  --amber: #f2b84b;
  --blue: #6aa6ff;
  --ink: #07090d;
  --radius: 8px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

button,
select,
input[type="number"] {
  font: inherit;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar,
.command-panel,
.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.topbar {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
}

.brand,
.runtime,
.actions,
.status-pill {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: var(--ink);
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

p,
small,
.metric span,
label span,
.runtime-clock,
.uptime,
.section-head span {
  color: var(--muted);
}

p,
small {
  font-size: 13px;
}

.runtime {
  gap: 12px;
}

.status-pill {
  height: 34px;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(255, 102, 115, 0.35);
  border-radius: 999px;
  color: var(--red);
  background: rgba(255, 102, 115, 0.09);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.running {
  color: var(--green);
  border-color: rgba(47, 210, 123, 0.35);
  background: rgba(47, 210, 123, 0.1);
}

.status-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.runtime-clock,
.uptime,
.mono {
  font-family: var(--mono);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.metric {
  min-height: 116px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  font-family: var(--mono);
  font-size: clamp(20px, 2vw, 27px);
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

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

.neutral {
  color: var(--text);
}

.command-panel {
  margin-top: 14px;
  padding: 18px;
}

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

.section-head.compact {
  align-items: center;
  margin-bottom: 12px;
}

.section-head.compact span {
  font-size: 12px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(140px, 0.8fr) minmax(180px, 1fr) minmax(210px, 0.9fr);
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  font-size: 12px;
  font-weight: 700;
}

select,
input[type="number"] {
  width: 100%;
  height: 42px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  outline: none;
}

select:focus,
input[type="number"]:focus {
  border-color: var(--blue);
}

select:disabled,
input[type="number"]:disabled {
  opacity: 0.72;
}

.actions {
  gap: 10px;
}

button {
  height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

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

.primary {
  flex: 1;
  color: var(--ink);
  background: var(--green);
}

.danger {
  flex: 1;
  color: var(--red);
  background: rgba(255, 102, 115, 0.08);
  border-color: rgba(255, 102, 115, 0.35);
}

.ghost {
  height: 34px;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.tables {
  display: grid;
  gap: 14px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #131820;
  font-size: 12px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.strong {
  font-weight: 700;
}

.tag {
  display: inline-flex;
  min-width: 42px;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(106, 166, 255, 0.12);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.empty {
  height: 72px;
  color: var(--muted);
  text-align: center;
}

.terminal {
  height: 610px;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.terminal-head {
  min-height: 68px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.terminal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-actions .ghost {
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.terminal-body {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  background: #090c11;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

.log {
  color: #d8dee9;
  overflow-wrap: anywhere;
  margin-bottom: 4px;
}

.log.system {
  color: var(--blue);
}

.log.warn {
  color: var(--amber);
}

.log.error {
  color: var(--red);
}

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

  .controls,
  .workspace {
    grid-template-columns: 1fr;
  }

  .terminal {
    height: 420px;
  }
}

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

  .topbar,
  .section-head,
  .runtime {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .actions {
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}

.session-status { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background-color: transparent; display: inline-block; transition: all 0.3s ease; }
.pulse-dot.active { background-color: #00e676; box-shadow: 0 0 10px #00e676; animation: pulse-green 1.5s infinite; }
@keyframes pulse-green { 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7); } 70% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(0, 230, 118, 0); } 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); } }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.checkbox-options { display: flex; flex-direction: column; gap: 6px; }
.check-option { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-main); transition: all 0.2s ease; }
.check-option:hover { background: rgba(255, 255, 255, 0.08); border-color: #00e676; }
.check-option input[type="checkbox"] { width: 16px; height: 16px; accent-color: #00e676; cursor: pointer; }

.session-container { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.running-strat-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-main); }
.running-strat-line span { color: var(--muted); }

/* --- Tab Navigation --- */
.tab-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.tab-btn {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: #fff;
  background: #252e3d;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.badge-pulse {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 800;
  color: #000;
  background: var(--green);
  border-radius: 4px;
  letter-spacing: 0.5px;
  animation: pulse-green 1.5s infinite;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

/* --- Screener Layout & Adaptive Controls --- */
.screener-controls {
  display: grid;
  grid-template-columns: minmax(200px, 1.3fr) minmax(130px, 0.9fr) minmax(130px, 0.9fr) auto;
  gap: 14px;
  align-items: end;
}

.screener-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.screener-btn-group button {
  height: 42px;
  white-space: nowrap;
  padding: 0 16px;
  min-width: 130px;
}

.btn-scan-run {
  background: var(--green) !important;
  color: #000 !important;
  font-weight: 700 !important;
}

.btn-scan-run:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-scan-stop {
  background: var(--red) !important;
  color: #fff !important;
  font-weight: 700 !important;
}

.btn-scan-stop:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

@media (max-width: 1024px) {
  .screener-controls {
    grid-template-columns: 1fr 1fr;
  }

  .screener-btn-group {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    width: 100%;
  }

  .screener-btn-group button {
    flex: 1 1 0;
    width: 100%;
  }
}

@media (max-width: 680px) {
  .screener-controls {
    grid-template-columns: 1fr;
  }

  .screener-btn-group {
    grid-column: 1 / -1;
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .screener-btn-group button {
    width: 100% !important;
    min-width: 100%;
  }
}

.screener-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  margin-top: 12px;
}

.screener-controls label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-val {
  color: var(--green);
  font-family: var(--mono);
}

input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  outline: none;
  accent-color: var(--green);
  cursor: pointer;
}

.field-group-inline {
  display: flex;
  align-items: center;
  height: 42px;
}

.screener-check {
  margin: 0;
  height: 42px;
  white-space: nowrap;
}

.tag-count {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(47, 210, 123, 0.12);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.workspace.full-width {
  grid-template-columns: 1fr;
}

/* --- Badges for Screener Table --- */
.vol-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  background: rgba(47, 210, 123, 0.1);
  color: var(--green);
  border: 1px solid rgba(47, 210, 123, 0.25);
}

.vol-badge.high {
  background: rgba(47, 210, 123, 0.2);
  color: #00ff88;
  border-color: rgba(0, 255, 136, 0.5);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.25);
}

.vol-badge.ultra {
  background: rgba(242, 184, 75, 0.2);
  color: var(--amber);
  border-color: rgba(242, 184, 75, 0.5);
  box-shadow: 0 0 10px rgba(242, 184, 75, 0.35);
}

.rsi-pill {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.rsi-pill.strong {
  background: rgba(106, 166, 255, 0.15);
  color: var(--blue);
}

.rsi-pill.overbought {
  background: rgba(255, 102, 115, 0.15);
  color: var(--red);
}

.rsi-pill.neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.btn-mini {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
}

.btn-mini:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* ============================================================
   AUTHENTICATION & LOGIN OVERLAY
   ============================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 18, 24, 0.85);
  backdrop-filter: blur(12px);
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(106, 166, 255, 0.1);
  animation: modal-fade-in 0.3s ease-out;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand .brand-mark {
  width: 48px;
  height: 48px;
  font-size: 22px;
}

.login-brand h2 {
  font-size: 17px;
  font-weight: 700;
}

.login-brand p {
  font-size: 12px;
  margin-top: 3px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form label span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  height: 44px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 10px rgba(106, 166, 255, 0.2);
}

.login-error {
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(255, 102, 115, 0.12);
  border: 1px solid rgba(255, 102, 115, 0.35);
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
}

.login-btn {
  height: 46px;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
}

/* --- User Pill Header --- */
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
}

.user-icon {
  font-size: 14px;
}

.logout-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.logout-btn:hover {
  color: var(--red);
  background: rgba(255, 102, 115, 0.15);
}

/* ============================================================
   MULTI-SELECT UNIVERSE COMPONENT
   ============================================================ */
.field-group-custom {
  display: flex;
  flex-direction: column;
  gap: 7px;
  position: relative;
}

.field-group-custom > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.custom-multiselect {
  position: relative;
  width: 100%;
}

.multiselect-trigger {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.multiselect-trigger:hover {
  border-color: var(--blue);
}

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  max-height: 70px;
  overflow-y: auto;
}

.tag-placeholder {
  color: var(--muted);
  font-size: 13px;
}

.universe-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(106, 166, 255, 0.18);
  border: 1px solid rgba(106, 166, 255, 0.35);
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
}

.tag-close {
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
}

.tag-close:hover {
  color: var(--red);
}

.dropdown-caret {
  font-size: 10px;
  color: var(--muted);
  margin-left: 8px;
}

.multiselect-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  animation: dropdown-fade 0.15s ease-out;
}

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

.multi-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.multi-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.multi-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

.multi-option span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

