/* ============================================
   PUGNA THEME — Oblivion Warden
   Deep nether violet, bone, decay, hellfire
   ============================================ */

:root {
  --bg-0: #0a0410;
  --bg-1: #14071f;
  --bg-2: #1a0a2a;
  --bg-3: #2a0a3e;
  --violet: #7a3fbf;
  --violet-dim: #4a2575;
  --violet-glow: rgba(122, 63, 191, 0.35);
  --bone: #e8d8b0;
  --bone-dim: #a89978;
  --bone-faint: #6b5f47;
  --decay: #4ade80;
  --decay-dim: #2d8a4f;
  --hellfire: #f87171;
  --hellfire-dim: #8a3838;
  --ghost: #60d3ff;
  --ghost-dim: #3a7c96;
  --line: rgba(122, 63, 191, 0.18);
  --line-strong: rgba(122, 63, 191, 0.35);
  --shadow-glow: 0 0 24px rgba(122, 63, 191, 0.15);
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-0);
  color: var(--bone);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(122, 63, 191, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 100% 100%, rgba(122, 63, 191, 0.04) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
  background-attachment: fixed;
}

/* Subtle scanlines for cinematic feel */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(122, 63, 191, 0.025) 0px,
    rgba(122, 63, 191, 0.025) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 1000;
  mix-blend-mode: overlay;
}

/* ============================================
   HEADER
   ============================================ */
.hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line-strong);
  background: linear-gradient(90deg, rgba(122, 63, 191, 0.06) 0%, transparent 50%, rgba(122, 63, 191, 0.06) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.sigil {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  letter-spacing: 0.18em;
}

.sigil .glyph {
  color: var(--violet);
  font-size: 22px;
  text-shadow: 0 0 16px var(--violet-glow);
  animation: nether-pulse 3.5s ease-in-out infinite;
}

@keyframes nether-pulse {
  0%, 100% { text-shadow: 0 0 12px var(--violet-glow); opacity: 0.85; }
  50% { text-shadow: 0 0 28px var(--violet), 0 0 8px var(--violet); opacity: 1; }
}

.sigil .brand {
  font-weight: 600;
  color: var(--bone);
  letter-spacing: 0.3em;
}

.sigil .sep { color: var(--violet-dim); }

.sigil .brand-sub {
  color: var(--bone-dim);
  font-size: 11px;
  letter-spacing: 0.25em;
}

.hdr-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
}

.meta-pill {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--bone-dim);
  background: rgba(20, 7, 31, 0.6);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.meta-pill.live {
  border-color: var(--violet-dim);
  color: var(--ghost);
}

.meta-pill.live::before {
  content: "●";
  color: var(--decay);
  margin-right: 6px;
  animation: live-blink 1.6s ease-in-out infinite;
}

@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============================================
   LAYOUT
   ============================================ */
main {
  padding: 18px 28px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: none;
}

.row { display: grid; gap: 18px; }
.row-2 { grid-template-columns: 2fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 1100px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: 1; }
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: linear-gradient(180deg, rgba(26, 10, 42, 0.7) 0%, rgba(20, 7, 31, 0.85) 100%);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 14px 18px;
  position: relative;
  box-shadow: var(--shadow-glow);
  min-height: 100px;
}

.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--violet), transparent);
  opacity: 0.5;
}

.span-2 { grid-column: span 1; }

.card-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}

.card-h.sub {
  border-bottom: none;
  padding-bottom: 4px;
  margin-top: 14px;
  margin-bottom: 6px;
}

.card-title {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--violet);
  text-transform: uppercase;
  font-weight: 600;
}

.card-title.sub {
  color: var(--bone-faint);
  font-size: 10px;
}

.card-hint {
  font-size: 10px;
  color: var(--bone-faint);
  letter-spacing: 0.15em;
}

/* ============================================
   POSITIONS
   ============================================ */
.positions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pos {
  background: rgba(42, 10, 62, 0.35);
  border: 1px solid var(--line);
  border-left: 2px solid var(--violet);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 14px;
  align-items: center;
  font-size: 12px;
  position: relative;
  overflow: hidden;
}

.pos.active::after {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 2px solid var(--violet);
  animation: nether-edge 2.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes nether-edge {
  0%, 100% { box-shadow: inset 2px 0 12px rgba(122, 63, 191, 0.35); }
  50% { box-shadow: inset 4px 0 24px rgba(122, 63, 191, 0.6); }
}

.pos .name {
  font-size: 14px;
  color: var(--bone);
  font-weight: 500;
  letter-spacing: 0.05em;
}

.pos .name .strat {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 10px;
  border: 1px solid var(--violet-dim);
  color: var(--ghost);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  vertical-align: middle;
}

.pos .label {
  font-size: 9px;
  color: var(--bone-faint);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}

.pos .val { font-size: 13px; color: var(--bone); }
.pos .val.pos-pnl { color: var(--decay); }
.pos .val.neg-pnl { color: var(--hellfire); }
.pos .val.warn { color: var(--hellfire); }
.pos .val.ghost { color: var(--ghost); }

.empty {
  padding: 24px;
  text-align: center;
  color: var(--bone-faint);
  font-size: 11px;
  letter-spacing: 0.2em;
  border: 1px dashed var(--line);
  background: rgba(20, 7, 31, 0.4);
}

/* ============================================
   PERFORMANCE GRID
   ============================================ */
.perf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.perf-grid .stat {
  padding: 8px 0;
  border-bottom: 1px dotted var(--line);
}

.perf-grid .stat .lbl {
  font-size: 9px;
  color: var(--bone-faint);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}

.perf-grid .stat .val {
  font-size: 18px;
  color: var(--bone);
  font-weight: 500;
}

.perf-grid .stat .val.pos-pnl { color: var(--decay); }
.perf-grid .stat .val.neg-pnl { color: var(--hellfire); }
.perf-grid .stat .val.ghost { color: var(--ghost); }

/* ============================================
   LISTS (closes, decisions, lessons)
   ============================================ */
.list {
  display: flex;
  flex-direction: column;
  max-height: 380px;
  overflow-y: auto;
}

.list.compact { max-height: 320px; }

.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-track { background: transparent; }
.list::-webkit-scrollbar-thumb { background: var(--violet-dim); border-radius: 3px; }

.list-row {
  padding: 8px 0;
  border-bottom: 1px dotted var(--line);
  font-size: 12px;
  display: grid;
  gap: 4px;
}

.list-row:last-child { border-bottom: none; }

.list-row .top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.list-row .top .l { color: var(--bone); font-weight: 500; }
.list-row .top .r { font-size: 10px; color: var(--bone-faint); letter-spacing: 0.1em; white-space: nowrap; }
.list-row .sub-line { font-size: 11px; color: var(--bone-dim); }

.tag {
  display: inline-block;
  padding: 1px 7px;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border: 1px solid var(--violet-dim);
  color: var(--bone-dim);
  margin-right: 6px;
}

.tag.deploy { border-color: var(--decay-dim); color: var(--decay); }
.tag.no_deploy { border-color: var(--bone-faint); color: var(--bone-faint); }
.tag.close { border-color: var(--ghost-dim); color: var(--ghost); }
.tag.reject { border-color: var(--hellfire-dim); color: var(--hellfire); }
.tag.pinned { border-color: var(--violet); color: var(--violet); }

.pnl-pos { color: var(--decay); }
.pnl-neg { color: var(--hellfire); }

/* ============================================
   CONFIG GRID
   ============================================ */
.config-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
}

.config-grid::-webkit-scrollbar { width: 6px; }
.config-grid::-webkit-scrollbar-track { background: transparent; }
.config-grid::-webkit-scrollbar-thumb { background: var(--violet-dim); }

.config-section .config-h {
  font-size: 9px;
  color: var(--violet);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding-bottom: 4px;
  border-bottom: 1px dotted var(--line);
  margin-bottom: 6px;
}

.config-section .kv {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
}

.config-section .kv .k { color: var(--bone-dim); }
.config-section .kv .v { color: var(--bone); font-weight: 500; }
.config-section .kv .v.evolved { color: var(--ghost); }
.config-section .kv .v.evolved::after {
  content: "↻";
  margin-left: 6px;
  color: var(--violet);
}

/* ============================================
   SIGNAL WEIGHTS
   ============================================ */
.signals-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 500px;
  overflow-y: auto;
}

.signal-bar {
  display: grid;
  grid-template-columns: 1fr 80px 50px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--line);
}

.signal-bar .name { color: var(--bone-dim); }
.signal-bar .bar-track {
  height: 6px;
  background: rgba(122, 63, 191, 0.1);
  border: 1px solid var(--line);
  position: relative;
}
.signal-bar .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--violet-dim), var(--violet));
  box-shadow: 0 0 6px var(--violet-glow);
}
.signal-bar .bar-val {
  text-align: right;
  font-size: 10px;
  color: var(--ghost);
}

/* ============================================
   PROCESS LOGS
   ============================================ */
.logs-h {
  flex-wrap: wrap;
  gap: 12px;
}

.log-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 10px;
}

.log-tab, .log-stream {
  background: rgba(20, 7, 31, 0.6);
  border: 1px solid var(--line);
  color: var(--bone-dim);
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
}

.log-tab:hover, .log-stream:hover {
  border-color: var(--violet-dim);
  color: var(--bone);
}

.log-tab.active, .log-stream.active {
  background: rgba(122, 63, 191, 0.2);
  border-color: var(--violet);
  color: var(--bone);
  box-shadow: 0 0 8px var(--violet-glow);
}

.log-stream.active[data-stream="err"] {
  background: rgba(248, 113, 113, 0.15);
  border-color: var(--hellfire-dim);
  color: var(--hellfire);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.3);
}

.log-sep {
  color: var(--bone-faint);
  padding: 0 4px;
}

.log-follow {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--bone-dim);
  cursor: pointer;
}

.log-follow input {
  accent-color: var(--violet);
  cursor: pointer;
}

.log-view {
  background: #050108;
  border: 1px solid var(--line);
  border-left: 2px solid var(--violet-dim);
  color: var(--bone);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  padding: 12px 16px;
  margin: 0;
  height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  scroll-behavior: smooth;
}

.log-view::-webkit-scrollbar { width: 8px; }
.log-view::-webkit-scrollbar-track { background: rgba(122, 63, 191, 0.05); }
.log-view::-webkit-scrollbar-thumb { background: var(--violet-dim); border-radius: 2px; }
.log-view::-webkit-scrollbar-thumb:hover { background: var(--violet); }

.log-line {
  display: block;
}
.log-line.err { color: #ff6b8a; font-weight: 500; }
.log-line.warn { color: #fcd34d; }
.log-line.info { color: var(--ghost); }
.log-line.dim { color: var(--bone-dim); }
.log-line.ts { color: var(--violet); }
