:root {
  --left-col: 28%;
  --center-col: 44%;
  --right-col: 28%;
  --bg: #0a101b;
  --bg-soft: #0f1725;
  --line: #22344f;
  --text: #dce5f5;
  --muted: #8da0bf;
  --accent: #0de7a8;
  --accent-2: #4da3ff;
  --danger: #ff5f7a;
  --warn: #ffbe4d;
  --success: #15d87f;
  --shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-size: 14px;
  font-family: "IBM Plex Sans", sans-serif;
  background:
    radial-gradient(900px 500px at 0% -10%, #173052 0%, rgba(23, 48, 82, 0) 70%),
    radial-gradient(900px 500px at 100% -10%, #163549 0%, rgba(22, 53, 73, 0) 72%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
  color: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 14, 24, 0.95), rgba(7, 14, 24, 0.84));
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.brand-mark {
  width: 1.85rem;
  height: 1.85rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #00cb9a, #23e5b2);
  color: #052d21;
  font-weight: 800;
  font-family: "Space Grotesk", sans-serif;
}

.brand-text {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #75f6cf;
  font-size: 1.02rem;
}

.nav-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 0.48rem;
  padding: 0.34rem 0.62rem;
  cursor: pointer;
}

.tab.active,
.tab:hover {
  color: var(--text);
  border-color: var(--line);
  background: rgba(19, 33, 56, 0.75);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

#tickerSearch {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  height: 2rem;
  padding: 0 0.64rem;
  width: 10.2rem;
}

#tickerSearch:focus {
  outline: 1px solid var(--accent-2);
}

.layout-control {
  display: grid;
  grid-template-columns: auto 5.2rem auto;
  gap: 0.3rem;
  align-items: center;
  font-size: 0.76rem;
  color: var(--muted);
}

.layout-control label {
  white-space: nowrap;
}

.layout-control input[type="range"] {
  width: 5.2rem;
}

#centerWidthValue {
  min-width: 2.7rem;
  text-align: right;
  color: #9ac9ff;
}

.chip-button {
  border: 1px solid #2e4d75;
  border-radius: 0.45rem;
  background: #1a2a44;
  color: #b9cbe8;
  height: 1.95rem;
  padding: 0 0.62rem;
  cursor: pointer;
}

.chip-button.active,
.chip-button:hover {
  border-color: #38689f;
}

.data-pill {
  border: 1px solid #2a466d;
  border-radius: 999px;
  padding: 0.18rem 0.52rem;
  font-size: 0.74rem;
  color: #8fc3ff;
  background: rgba(24, 46, 72, 0.65);
  white-space: nowrap;
}

.icon-button {
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--bg-soft);
  cursor: pointer;
  width: 2rem;
  height: 2rem;
}

.user-pill {
  border-radius: 999px;
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  background: #78c352;
  color: #102604;
  font-weight: 700;
}

.pages-wrap {
  min-height: calc(100vh - 58px);
}

.page {
  display: none;
  height: calc(100vh - 58px);
}

.page.active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: var(--left-col) var(--center-col) var(--right-col);
  gap: 0.66rem;
  padding: 0.66rem;
  height: 100%;
}

.column {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.66rem;
}

.column-left,
.column-right,
.column-center {
  overflow-y: auto;
  padding-right: 0.12rem;
}

.feature-window,
.panel {
  background: linear-gradient(180deg, rgba(17, 30, 49, 0.96), rgba(12, 21, 36, 0.96));
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  box-shadow: var(--shadow);
}

.feature-window {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 11.8rem;
  max-height: 23rem;
}

.feature-header,
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.66rem 0.78rem;
  border-bottom: 1px solid rgba(36, 56, 87, 0.9);
}

.feature-header h3,
.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0.01em;
}

.panel-header h2 {
  font-size: 1.3rem;
}

.metric-main {
  font-weight: 700;
  color: #71c0ff;
}

.feature-body {
  padding: 0.74rem;
  overflow-y: auto;
}

.progress-track {
  width: 100%;
  height: 0.42rem;
  border-radius: 999px;
  background: #0a111d;
  border: 1px solid #1a2b47;
  overflow: hidden;
}

.progress-track.green .progress-fill {
  background: linear-gradient(90deg, #0ee7a8, #28f0bd);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #4da3ff, #68bbff);
  transition: width 250ms ease;
}

.meter-scale {
  margin-top: 0.35rem;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  font-size: 0.72rem;
  color: var(--muted);
}

.bullet-list {
  margin: 0.7rem 0 0;
  padding-left: 0.95rem;
  display: grid;
  gap: 0.33rem;
  color: var(--muted);
}

.controls {
  display: grid;
  gap: 0.82rem;
}

.controls label {
  display: grid;
  gap: 0.32rem;
  font-size: 0.84rem;
  color: var(--muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-2);
}

.action-button {
  margin-top: 0.2rem;
  border: 1px solid #2b537f;
  border-radius: 0.52rem;
  height: 2.14rem;
  background: linear-gradient(180deg, #17355f, #10233f);
  cursor: pointer;
}

.action-button:hover {
  border-color: #3f77b5;
}

.compact-button {
  width: 12rem;
}

.chart-panel {
  min-height: 33rem;
  display: grid;
  grid-template-rows: auto 1fr;
}

.panel-header {
  padding: 0.72rem 0.9rem;
}

.panel-header.compact {
  align-items: center;
}

.panel-header.with-subhead {
  align-items: baseline;
}

.panel-header p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.symbol-switch {
  display: flex;
  gap: 0.42rem;
}

.symbol-btn {
  border: 1px solid var(--line);
  border-radius: 0.48rem;
  min-width: 3rem;
  height: 2.05rem;
  background: #1b2b44;
  cursor: pointer;
}

.symbol-btn.active {
  background: linear-gradient(180deg, #15d89f, #00b38a);
  color: #052718;
  border-color: transparent;
  font-weight: 700;
}

.tradingview-host {
  min-height: 28rem;
}

.panel {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
  padding: 0.43rem 0.65rem 0.74rem;
}

.table-wrap.small {
  max-height: 15rem;
  overflow-y: auto;
}

.table-wrap.stretch {
  height: calc(100% - 0.2rem);
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead th {
  text-align: left;
  color: #88a2c8;
  font-weight: 600;
  border-bottom: 1px solid #293f63;
  padding: 0.4rem;
  position: sticky;
  top: 0;
  background: #122034;
}

tbody td {
  border-bottom: 1px solid rgba(36, 56, 87, 0.8);
  padding: 0.4rem;
  color: #c5d6ee;
}

tbody tr:hover td {
  background: rgba(17, 44, 70, 0.45);
}

tbody tr.active-row td {
  background: rgba(24, 81, 118, 0.44);
}

.two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.two-up section + section {
  border-left: 1px solid rgba(36, 56, 87, 0.9);
}

.small-muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.stat-pill {
  border: 1px solid #26466f;
  border-radius: 0.45rem;
  padding: 0.45rem;
  display: grid;
  gap: 0.2rem;
  background: rgba(20, 37, 60, 0.7);
}

.stat-pill .label {
  color: var(--muted);
  font-size: 0.72rem;
}

.stat-pill .value {
  font-size: 0.94rem;
  font-weight: 700;
}

.value.up {
  color: var(--success);
}

.value.down {
  color: var(--danger);
}

.value.neutral {
  color: #8fc3ff;
}

.rs-grid {
  display: grid;
  grid-template-columns: 31% 49% 20%;
  gap: 0.66rem;
  padding: 0.66rem;
  height: 100%;
}

.rs-left,
.rs-center-panel,
.rs-right {
  min-height: 0;
  height: 100%;
}

.rs-left,
.rs-right {
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
}

.rs-right {
  grid-template-rows: 1fr;
}

.rs-mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.44rem;
  padding: 0.56rem 0.66rem 0.3rem;
}

.rs-center-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.rrg-controls {
  display: flex;
  gap: 0.52rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip-row {
  display: flex;
  align-items: center;
  gap: 0.34rem;
}

.rrg-wrap {
  padding: 0.66rem;
  min-height: 0;
}

#rsScatterCanvas {
  width: 100%;
  height: 100%;
}

.rrg-legend {
  border-top: 1px solid rgba(36, 56, 87, 0.9);
  padding: 0.54rem 0.74rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 0.88rem;
  height: 0.88rem;
  border-radius: 999px;
  margin-right: 0.28rem;
}

.dot.leading {
  background: #18d58b;
}

.dot.improving {
  background: #58a8ff;
}

.dot.weakening {
  background: #ffb018;
}

.dot.lagging {
  background: #ff5f67;
}

.placeholder-center {
  display: grid;
  place-items: center;
  color: var(--muted);
  height: 100%;
}

.rs-right-body {
  padding: 0.84rem;
  display: grid;
  gap: 0.72rem;
  overflow-y: auto;
}

.rs-right-body h4 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.1rem;
}

.rs-right-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.simple-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.66rem;
  padding: 0.66rem;
  height: 100%;
}

.simple-grid.one-col {
  grid-template-columns: 1fr;
}

.docs-body {
  display: grid;
  gap: 0.66rem;
  color: #c6d5eb;
  line-height: 1.45;
}

.light-mode {
  --bg: #e9f1f9;
  --bg-soft: #f6faff;
  --line: #c7d8ec;
  --text: #0f1f36;
  --muted: #4f6483;
  --shadow: 0 10px 24px rgba(24, 60, 112, 0.12);
}

@media (max-width: 1280px) {
  .page {
    height: auto;
  }

  .dashboard-grid,
  .rs-grid,
  .simple-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .column-left,
  .column-right,
  .column-center {
    overflow: visible;
    padding-right: 0;
  }

  .feature-window {
    max-height: none;
  }

  .two-up {
    grid-template-columns: 1fr;
  }

  .two-up section + section {
    border-left: none;
    border-top: 1px solid rgba(36, 56, 87, 0.9);
  }

  .rs-left,
  .rs-right,
  .rs-center-panel {
    height: auto;
  }

  .rrg-wrap {
    min-height: 30rem;
  }
}

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

  .topbar-right {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  #tickerSearch {
    width: 100%;
  }

  .layout-control {
    width: 100%;
    grid-template-columns: auto 1fr auto;
  }

  .symbol-switch {
    width: 100%;
    justify-content: flex-end;
  }

  .stat-grid,
  .rs-right-meta {
    grid-template-columns: 1fr;
  }
}
