/* Aether — professional multi-factor trading console */

:root {
  --bg-0: #05080f;
  --bg-1: #0a0f18;
  --bg-2: #0f1623;
  --bg-3: #151e2e;
  --bg-hover: #1a2436;
  --line: rgba(148, 163, 184, 0.12);
  --line-strong: rgba(148, 163, 184, 0.22);
  --text: #e8eef7;
  --text-secondary: #9aa8bc;
  --text-muted: #6b7a90;
  --accent: #5b9fd4;
  --accent-soft: rgba(91, 159, 212, 0.14);
  --accent-2: #3ecf8e;
  --accent-2-soft: rgba(62, 207, 142, 0.12);
  --danger: #f07178;
  --danger-soft: rgba(240, 113, 120, 0.12);
  --warn: #e0b45a;
  --warn-soft: rgba(224, 180, 90, 0.12);
  --good: #4ade80;
  --sidebar-w: 260px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --header-h: 76px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Ambient background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(91, 159, 212, 0.16), transparent 55%),
    radial-gradient(700px 420px at 90% 10%, rgba(62, 207, 142, 0.08), transparent 50%),
    linear-gradient(180deg, #070b14 0%, var(--bg-0) 40%, #04060b 100%);
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.35rem 1rem 1.1rem;
  background: linear-gradient(180deg, rgba(15, 22, 35, 0.96), rgba(8, 12, 20, 0.98));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.sidebar-brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0.25rem 0.5rem 1.35rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #041018;
  background: linear-gradient(145deg, #7eb8e8 0%, #5b9fd4 40%, #3ecf8e 100%);
  box-shadow: 0 8px 24px rgba(91, 159, 212, 0.28);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.1rem;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  text-align: left;
  padding: 0.72rem 0.85rem;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  border-color: rgba(91, 159, 212, 0.25);
  color: var(--text);
}

.nav-icon {
  width: 1.25rem;
  text-align: center;
  opacity: 0.85;
  font-size: 0.85rem;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.status-stack {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0 0.35rem;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(107, 122, 144, 0.15);
}

.dot.ok {
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

.dot.run {
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.18);
  animation: pulse 1.8s ease-in-out infinite;
}

.dot.err {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(240, 113, 120, 0.18);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- Main column ---------- */
.main-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.35rem 1.75rem 0.85rem;
  min-height: var(--header-h);
}

.eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.page-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.header-actions.hidden {
  display: none;
}

.content {
  padding: 0.5rem 1.75rem 1.5rem;
  flex: 1;
}

.panel {
  display: none;
  animation: fadeIn 0.25s ease;
}

.panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Cards & metrics ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

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

.metric-card {
  background: linear-gradient(165deg, rgba(21, 30, 46, 0.95), rgba(12, 18, 28, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(91, 159, 212, 0.45), transparent);
}

.metric-card.compact {
  padding: 0.85rem 0.95rem;
}

.metric-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.metric-value {
  display: block;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.metric-value-sm {
  font-size: 1.2rem;
}

.metric-hint {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card {
  background: linear-gradient(180deg, rgba(18, 26, 40, 0.92), rgba(12, 17, 27, 0.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.95rem;
}

.card-head h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.card-badge {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-2-soft);
  color: var(--accent-2);
  border: 1px solid rgba(62, 207, 142, 0.22);
}

.card-badge.muted {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-muted);
  border-color: var(--line);
}

.chart-box {
  position: relative;
  height: 240px;
}

.chart-box-lg {
  height: 280px;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: rgba(148, 163, 184, 0.35);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, #6aafe0, #4a9ad0 45%, #3bb88a);
  border-color: transparent;
  color: #041018;
  box-shadow: 0 8px 22px rgba(74, 154, 208, 0.28);
}

.btn-primary:hover {
  filter: brightness(1.05);
  background: linear-gradient(135deg, #6aafe0, #4a9ad0 45%, #3bb88a);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.03);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-danger-ghost {
  color: #f5a0a5;
  border-color: rgba(240, 113, 120, 0.35);
  background: var(--danger-soft);
}

.btn-block {
  width: 100%;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table th {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: rgba(91, 159, 212, 0.04);
}

.data-table .empty {
  color: var(--text-muted);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.88rem;
}

.pos { color: var(--good); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field span {
  letter-spacing: 0.02em;
}

.field input,
.select {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.select:focus {
  border-color: rgba(91, 159, 212, 0.55);
  box-shadow: 0 0 0 3px rgba(91, 159, 212, 0.15);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

.field-hint,
.meta-line {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-line {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.inline-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ---------- Logs & code ---------- */
.code-block,
.log-stream {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.55;
  background: #060a11;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.95rem 1rem;
  color: #a8b8cc;
  overflow: auto;
  max-height: 340px;
  white-space: pre-wrap;
  margin: 0;
}

.log-stream {
  max-height: min(65vh, 560px);
  min-height: 280px;
}

.log-line {
  padding: 0.28rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  color: #8fa0b5;
}

.log-line .lvl-INFO { color: var(--accent); font-weight: 500; }
.log-line .lvl-WARNING { color: var(--warn); font-weight: 500; }
.log-line .lvl-ERROR { color: var(--danger); font-weight: 500; }
.log-line .src { color: var(--accent-2); }

/* ---------- Universe ---------- */
.universe-list {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.universe-class h3 {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(91, 159, 212, 0.22);
  color: var(--text);
}

/* ---------- Alerts & modal ---------- */
.alert {
  margin: 0 1.75rem 0.75rem;
  padding: 0.85rem 1.05rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.alert-warn {
  background: var(--warn-soft);
  border: 1px solid rgba(224, 180, 90, 0.3);
  color: #f0d9a0;
}

.alert.hidden {
  display: none;
}

.alert code {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: #fff4d4;
}

.alert-link {
  display: inline;
  margin-left: 0.35rem;
  border: none;
  background: none;
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  width: min(420px, 100%);
  background: linear-gradient(180deg, #151e2e, #0d1320);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 1.4rem 1.45rem 1.3rem;
  box-shadow: var(--shadow);
}

.modal-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.modal-copy {
  margin: 0 0 1.1rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.modal-copy code {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.15rem;
}

.page-footer {
  padding: 0.5rem 1.75rem 1.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metric-grid-dense {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: none;
  }

  .nav-item {
    flex: 1 1 auto;
    min-width: 140px;
  }

  .sidebar-footer {
    display: none;
  }

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

  .page-header,
  .content,
  .alert,
  .page-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .alert {
    margin-left: 1rem;
    margin-right: 1rem;
  }
}

@media (max-width: 560px) {
  .metric-grid,
  .metric-grid-dense,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 1.3rem;
  }
}
