:root {
  --bg: #08111d;
  --bg-2: #0d1726;
  --panel: #101b2c;
  --panel-2: #132138;
  --line: #20314b;
  --text: #d9e3f3;
  --muted: #8ea1bc;
  --green: #33d17a;
  --red: #ff6b6b;
  --blue: #3d8bff;
  --amber: #f5b84c;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(61, 139, 255, 0.08), transparent 18%),
    radial-gradient(circle at top left, rgba(62, 207, 142, 0.08), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", sans-serif;
}

body {
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(8, 14, 23, 0.92);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand h1,
.panel-head h2,
.ticker-symbol {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0;
}

.brand p,
.panel-head p,
.ticker-change,
.small-label,
.clock {
  margin: 0;
  color: var(--muted);
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.brand-mark span {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #89d9ff, #3d8bff);
}

.brand-mark span:nth-child(1) { height: 14px; }
.brand-mark span:nth-child(2) { height: 21px; }
.brand-mark span:nth-child(3) { height: 27px; }

.nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  color: var(--text);
  text-decoration: none;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(61, 139, 255, 0.08);
  border-color: rgba(61, 139, 255, 0.18);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.small-value {
  margin-top: 6px;
  font-weight: 600;
}

.main {
  padding: 18px;
  display: grid;
  gap: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: stretch;
}

.ticker,
.metric-tile,
.panel,
.ghost-button {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 27, 44, 0.98), rgba(12, 20, 33, 0.98));
  border-radius: 6px;
}

.ticker {
  padding: 16px;
  display: grid;
  gap: 6px;
}

.ticker-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--green);
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
}

.metric-tile {
  padding: 14px 16px;
  display: grid;
  gap: 8px;
}

.metric-tile span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metric-tile strong {
  font-size: 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  font-weight: 600;
}

.live-pill span,
.status-line .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(51, 209, 122, 0.08);
}

.ghost-button {
  color: var(--text);
  padding: 12px 16px;
  cursor: pointer;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 18px;
}

.panel {
  padding: 16px;
}

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

.stat-list,
.rule-list {
  display: grid;
  gap: 10px;
}

.stat-list div,
.open-position .row,
.rule-list .rule-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(32, 49, 75, 0.6);
}

.stat-list span,
.open-position span,
.rule-row span {
  color: var(--muted);
}

.chart-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chart-head {
  align-items: center;
}

.chart-surface {
  min-height: 480px;
  height: 480px;
  max-height: 480px;
  width: 100%;
  display: block;
  flex: 0 0 480px;
}

.segmented {
  display: inline-flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(5, 12, 22, 0.5);
}

.tf-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.tf-button.active {
  background: var(--blue);
  color: white;
}

.status-card,
.position-box {
  padding: 14px;
  border: 1px solid rgba(32, 49, 75, 0.8);
  border-radius: 6px;
  background: rgba(8, 15, 25, 0.55);
}

.status-card {
  margin-bottom: 16px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.status-card p,
.notes p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.hidden {
  display: none;
}

.history-panel {
  padding-bottom: 8px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(32, 49, 75, 0.7);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(61, 139, 255, 0.04);
}

.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.pnl-pos,
.result-pos {
  color: var(--green);
}

.pnl-neg,
.result-neg {
  color: var(--red);
}

.pnl-flat {
  color: var(--amber);
}

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

  .metrics-strip {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .chart-surface {
    min-height: 420px;
    height: 420px;
    max-height: 420px;
    flex-basis: 420px;
  }
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .chart-surface {
    min-height: 340px;
    height: 340px;
    max-height: 340px;
    flex-basis: 340px;
  }
}
