/* ────────────────────────────────────────────────────────────────────────────
   ORB RELAY — terminal / financial-data aesthetic
   Inspired by Bloomberg, kraken pro, ascii order books.
   Dense. Monospace. Sharp. No rounded corners. No gradients.
   ──────────────────────────────────────────────────────────────────────────── */

:root {
  --bg-0: #08090b;          /* pure black-ish background */
  --bg-1: #0e1014;          /* card/panel surface */
  --bg-2: #14171c;          /* hover/elevated */
  --bg-3: #1c2026;          /* table row stripe */
  --line: #1f242c;          /* borders */
  --line-bright: #2c333d;   /* hover borders */

  --ink-0: #e8eaed;         /* primary text */
  --ink-1: #a8aeb8;         /* secondary text */
  --ink-2: #6b7280;         /* tertiary / labels */
  --ink-3: #3d4350;         /* faint */

  --accent: #d4ff3a;        /* electric yellow-green — primary brand */
  --accent-dim: #8da325;
  --pos: #4ade80;           /* longs / wins */
  --pos-bg: rgba(74, 222, 128, 0.08);
  --neg: #f87171;           /* shorts / losses */
  --neg-bg: rgba(248, 113, 113, 0.08);
  --warn: #fbbf24;
  --info: #60a5fa;

  --font-mono: 'JetBrains Mono', 'SFMono-Regular', 'Menlo', monospace;
  --font-display: 'Bebas Neue', 'Impact', sans-serif;
}

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

html, body {
  background: var(--bg-0);
  color: var(--ink-0);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  letter-spacing: 0.01em;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input {
  font-family: inherit;
  font-size: inherit;
}

/* ── Background grain texture overlay ──────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 0%, rgba(212, 255, 58, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(96, 165, 250, 0.025) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ────────────────────────────────────────────────────────────────────────────
   LOGIN PAGE
   ──────────────────────────────────────────────────────────────────────────── */
.login-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 1;
}

.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  opacity: 0.35;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
          mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}

.login-card {
  position: relative;
  width: min(440px, 100%);
  background: var(--bg-1);
  border: 1px solid var(--line-bright);
  padding: 36px 40px 28px;
  z-index: 2;
}

.login-card::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan-line 4s linear infinite;
}

@keyframes scan-line {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.login-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 0.18em;
  color: var(--ink-0);
}

.brand-mark {
  color: var(--accent);
  font-size: 24px;
  letter-spacing: 0;
  transform: translateY(-2px);
}

.login-meta {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 10px;
  letter-spacing: 0.25em;
}

.login-error {
  margin-top: 24px;
  padding: 10px 14px;
  border-left: 2px solid var(--neg);
  background: var(--neg-bg);
  color: var(--neg);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.login-form {
  margin-top: 28px;
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 6px;
}

.login-form label span {
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--ink-2);
}

.login-form input {
  background: var(--bg-0);
  border: 1px solid var(--line);
  color: var(--ink-0);
  padding: 11px 12px;
  outline: none;
  transition: border-color 0.15s;
  font-size: 13px;
}

.login-form input:focus {
  border-color: var(--accent);
}

.login-form button {
  margin-top: 8px;
  background: var(--accent);
  color: var(--bg-0);
  border: 0;
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 12px;
  transition: filter 0.15s, transform 0.05s;
}

.login-form button:hover { filter: brightness(1.1); }
.login-form button:active { transform: translateY(1px); }

.login-foot {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ink-3);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.login-pulse {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--accent); }
  50% { opacity: 0.4; box-shadow: 0 0 0 6px transparent; }
}

/* ────────────────────────────────────────────────────────────────────────────
   DASHBOARD SHELL
   ──────────────────────────────────────────────────────────────────────────── */
.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.15em;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.2em;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
}

.separator {
  color: var(--ink-3);
  font-weight: 300;
}

.page-name {
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--ink-1);
  font-family: var(--font-mono);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line-bright);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pos);
  box-shadow: 0 0 8px var(--pos);
  animation: pulse 1.8s ease-in-out infinite;
}

.status-pill.disconnected .status-dot {
  background: var(--neg);
  box-shadow: 0 0 8px var(--neg);
}

.status-pill.disconnected {
  border-color: var(--neg);
}

.meta-clock {
  font-variant-numeric: tabular-nums;
  color: var(--ink-1);
  font-size: 11px;
}

.meta-user {
  color: var(--ink-2);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.topnav-link {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-1);
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}

.topnav-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.topnav-link.logout:hover {
  color: var(--neg);
  border-bottom-color: var(--neg);
}

/* ── Hero strip ────────────────────────────────────────────────────────────── */
.hero-strip {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.hero-cell {
  padding: 18px 24px;
  border-right: 1px solid var(--line);
  background: var(--bg-1);
  position: relative;
}

.hero-cell:last-child { border-right: 0; }

.hero-pnl {
  background: linear-gradient(135deg, var(--bg-1) 0%, #0c1014 100%);
}

.cell-label {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--ink-2);
  margin-bottom: 8px;
}

.cell-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 400;
  color: var(--ink-0);
  letter-spacing: 0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.cell-value.big {
  font-size: 56px;
}

.cell-value.pos { color: var(--pos); }
.cell-value.neg { color: var(--neg); }

.cell-sub {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-2);
  margin-top: 8px;
}

/* ── Grid main ─────────────────────────────────────────────────────────────── */
.grid-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  grid-template-rows: minmax(260px, 0.9fr) minmax(280px, 1.1fr);
  gap: 1px;
  background: var(--line);
  padding: 1px;
}

.panel {
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-equity { grid-column: 1 / 2; grid-row: 1 / 2; }
.panel-feed   { grid-column: 2 / 3; grid-row: 1 / 3; }
.panel-daily  { grid-column: 1 / 2; grid-row: 2 / 3; }
.panel-stats {
  grid-column: 1 / 3;
  grid-row: 3 / 4;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
}

@media (max-width: 1100px) {
  .grid-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .panel-equity, .panel-feed, .panel-daily, .panel-stats {
    grid-column: 1 / 2;
    grid-row: auto;
  }
  .hero-strip { grid-template-columns: 1fr 1fr; }
  .hero-cell:nth-child(2) { border-right: 0; }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-0);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.25em;
  color: var(--ink-0);
}

.panel-meta {
  font-size: 9px;
  letter-spacing: 0.25em;
  color: var(--ink-2);
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.panel-equity .panel-body {
  padding: 12px 16px 16px;
  position: relative;
}

#equityChart {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ── Signal feed ───────────────────────────────────────────────────────────── */
.feed-body {
  padding: 4px 0;
  font-size: 12px;
}

.feed-row {
  display: grid;
  grid-template-columns: 60px 60px 70px 1fr;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px dashed var(--line);
  align-items: center;
  font-variant-numeric: tabular-nums;
  animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
  from { transform: translateX(8px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.feed-time { color: var(--ink-2); font-size: 10px; }
.feed-action {
  font-size: 10px;
  letter-spacing: 0.15em;
  font-weight: 600;
  text-align: center;
  padding: 2px 0;
  border: 1px solid;
}
.feed-action.OPEN { color: var(--accent); border-color: var(--accent-dim); }
.feed-action.CLOSE { color: var(--ink-1); border-color: var(--line-bright); }

.feed-side {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-align: center;
}
.feed-side.LONG { color: var(--pos); }
.feed-side.SHORT { color: var(--neg); }

.feed-detail {
  color: var(--ink-1);
  font-size: 11px;
}
.feed-detail .px {
  color: var(--ink-0);
  font-weight: 500;
}
.feed-detail .session {
  color: var(--ink-2);
  font-size: 10px;
  margin-left: 6px;
}
.feed-detail .latency {
  color: var(--info);
  margin-left: 6px;
  font-size: 10px;
}
.feed-detail .latency.warn { color: var(--warn); }
.feed-detail .latency.neg { color: var(--neg); }
.feed-detail .flag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 4px;
  font-size: 9px;
  letter-spacing: 0.1em;
  border: 1px solid var(--line-bright);
  color: var(--ink-2);
}
.feed-detail .flag.rrev { color: var(--warn); border-color: var(--warn); }
.feed-detail .flag.wick { color: var(--info); border-color: var(--info); }

.feed-empty {
  padding: 32px 18px;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-align: center;
}

/* ── Data tables ───────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  text-align: left;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--ink-2);
  font-weight: 500;
  padding: 10px 14px;
  background: var(--bg-0);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th.num { text-align: right; }

.data-table td {
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-1);
}

.data-table td.num { text-align: right; }

.data-table tbody tr:hover {
  background: var(--bg-2);
}

.data-table .empty-row {
  padding: 32px;
  text-align: center;
  color: var(--ink-3);
  font-style: italic;
  letter-spacing: 0.1em;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }

/* Trade rows */
.trade-row.row-pos td.num.pos { font-weight: 600; }
.trade-row.row-neg td.num.neg { font-weight: 600; }

.side-long { color: var(--pos); font-weight: 600; }
.side-short { color: var(--neg); font-weight: 600; }

.mono-cell { color: var(--ink-1); font-size: 11px; }
.mono-cell.tiny { color: var(--ink-2); font-size: 10px; }

.exit-cell {
  color: var(--ink-2);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.flags-cell { display: flex; gap: 4px; }

.flag {
  display: inline-block;
  padding: 1px 5px;
  font-size: 9px;
  letter-spacing: 0.1em;
  border: 1px solid var(--line-bright);
  color: var(--ink-2);
  font-weight: 600;
}
.flag-rrev { color: var(--warn); border-color: var(--warn); }
.flag-wick { color: var(--info); border-color: var(--info); }
.flag-reentry { color: var(--ink-1); }

/* ── Stats grid ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  padding: 0;
}

.stat-cell {
  padding: 16px 20px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  font-size: 9px;
  letter-spacing: 0.25em;
  color: var(--ink-2);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.05em;
  color: var(--ink-0);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.footbar {
  padding: 8px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
}

/* ── Trades page ───────────────────────────────────────────────────────────── */
.page-body {
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--ink-2);
}

.page-hint {
  font-style: italic;
  color: var(--ink-3);
  text-transform: lowercase;
  letter-spacing: 0.1em;
}

.trades-table-wrap {
  background: var(--bg-1);
  border: 1px solid var(--line);
  overflow: auto;
  max-height: calc(100vh - 180px);
}

.data-table-trades th {
  white-space: nowrap;
}

.data-table-trades td {
  white-space: nowrap;
}

/* ── Scrollbar styling ─────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-0);
}

::-webkit-scrollbar-thumb {
  background: var(--line-bright);
  border: 2px solid var(--bg-0);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-3);
}

/* ── Selection ─────────────────────────────────────────────────────────────── */
::selection {
  background: var(--accent);
  color: var(--bg-0);
}
