:root {
  color-scheme: dark;
  --bg: #08090a;
  --panel: #111317;
  --panel-soft: #171a1f;
  --line: #272b31;
  --line-strong: #353a42;
  --text: #f3f5f7;
  --muted: #8d96a3;
  --muted-strong: #b7bec8;
  --green: #00c46a;
  --green-soft: rgba(0, 196, 106, 0.14);
  --red: #ff4d5e;
  --red-soft: rgba(255, 77, 94, 0.14);
  --amber: #f5b942;
  --cyan: #4cc9f0;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(76, 201, 240, 0.10), transparent 30rem),
    linear-gradient(180deg, #0c0d0f 0%, var(--bg) 42rem);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 19, 23, 0.92);
  box-shadow: var(--shadow);
}

.brand,
.topbar-meta,
.instrument-title,
.panel-header,
.chart-controls,
.ticker-item,
.watch-row,
.activity-row,
.insight-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(0, 196, 106, 0.55);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(0, 196, 106, 0.22), rgba(76, 201, 240, 0.10));
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 18px;
}

h2 {
  font-size: 16px;
}

.topbar-meta {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.status-pill,
.clock,
.mode-chip,
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(0, 196, 106, 0.12);
}

.ghost-button,
.danger-button,
.tool-button,
.segmented button,
.action-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 700;
}

.ghost-button,
.danger-button {
  padding: 0 12px;
}

.danger-button {
  border-color: rgba(255, 77, 94, 0.35);
  color: #ffb8c0;
}

.terminal-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 340px;
  gap: 14px;
  margin-top: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 19, 23, 0.94);
  box-shadow: var(--shadow);
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

.panel-header.compact {
  padding-bottom: 10px;
}

.watchlist-panel {
  min-height: calc(100vh - 122px);
  overflow: hidden;
}

.live-dot {
  min-height: 26px;
  border-color: rgba(0, 196, 106, 0.35);
  color: var(--green);
}

.search-box {
  display: grid;
  gap: 6px;
  margin: 0 14px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-box input,
.field input,
.field select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c0e11;
  color: var(--text);
  outline: none;
  padding: 0 11px;
}

.search-box input:focus,
.field input:focus,
.field select:focus {
  border-color: rgba(76, 201, 240, 0.65);
  box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.12);
}

.watchlist {
  display: grid;
  gap: 6px;
  padding: 0 8px 12px;
}

.watch-row {
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.watch-row:hover,
.watch-row.active {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.watch-main {
  min-width: 0;
}

.watch-symbol {
  display: block;
  font-size: 13px;
  font-weight: 800;
}

.watch-name {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watch-price {
  display: grid;
  gap: 2px;
  text-align: right;
}

.watch-price strong {
  font-size: 13px;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.chart-workspace {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.ticker-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}

.ticker-item {
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 19, 23, 0.9);
}

.ticker-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.ticker-item strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.ticker-item small {
  font-size: 12px;
  font-weight: 800;
}

.chart-panel {
  min-height: 562px;
  overflow: hidden;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.instrument-title {
  gap: 12px;
  min-width: 220px;
}

.asset-badge {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #0c0e11;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 900;
}

.instrument-title h2 {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: baseline;
  font-size: 22px;
}

.price-change {
  font-size: 13px;
  font-weight: 800;
}

.chart-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.segmented button {
  min-width: 48px;
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
  background: #0c0e11;
  color: var(--muted-strong);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active,
.tool-button.active {
  background: var(--green-soft);
  color: var(--green);
}

.tool-button {
  min-width: 48px;
  padding: 0 10px;
}

.canvas-wrap {
  position: relative;
  height: 500px;
  min-height: 360px;
}

#chartCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.crosshair-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 164px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(8, 9, 10, 0.94);
  color: var(--text);
  font-size: 12px;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 14px;
}

.table-panel {
  min-height: 260px;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  color: var(--muted-strong);
}

.empty-state {
  padding: 28px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.action-button {
  min-height: 28px;
  padding: 0 9px;
  color: var(--muted-strong);
}

.activity-feed {
  display: grid;
  gap: 8px;
  max-height: 216px;
  overflow: auto;
  padding: 0 12px 12px;
}

.activity-row {
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c0e11;
}

.activity-row strong {
  display: block;
  font-size: 12px;
}

.activity-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.trade-column {
  display: grid;
  align-content: start;
  gap: 14px;
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 0 14px 14px;
}

.account-grid div,
.estimate-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c0e11;
}

.account-grid div {
  padding: 11px;
}

.account-grid span,
.estimate-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.account-grid strong,
.estimate-box strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
}

.order-panel {
  padding-bottom: 14px;
}

.side-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 14px 14px;
}

.side-switch button,
.place-order {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c0e11;
  color: var(--muted-strong);
  font-weight: 800;
}

.side-switch button.buy.active,
.place-order.buy {
  border-color: rgba(0, 196, 106, 0.42);
  background: var(--green-soft);
  color: var(--green);
}

.side-switch button.sell.active,
.place-order.sell {
  border-color: rgba(255, 77, 94, 0.45);
  background: var(--red-soft);
  color: var(--red);
}

.field {
  display: grid;
  gap: 6px;
  padding: 0 14px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.two-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.two-fields .field:first-child {
  padding-right: 6px;
}

.two-fields .field:last-child {
  padding-left: 6px;
}

.is-hidden {
  display: none;
}

.estimate-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 2px 14px 12px;
}

.estimate-box div {
  padding: 11px;
}

.estimate-box div:first-child {
  border-right: 1px solid var(--line);
}

.place-order {
  width: calc(100% - 28px);
  margin: 0 14px;
  font-size: 14px;
}

.order-note {
  margin: 10px 14px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.insights {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.insight-row {
  align-items: flex-start;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c0e11;
}

.insight-row b {
  display: grid;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--cyan);
  font-size: 12px;
}

.insight-row strong {
  display: block;
  font-size: 12px;
}

.insight-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(17, 19, 23, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .terminal-layout {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .trade-column {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

@media (max-width: 980px) {
  .terminal-layout,
  .lower-grid,
  .trade-column {
    grid-template-columns: 1fr;
  }

  .watchlist-panel {
    min-height: auto;
  }

  .ticker-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .chart-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-meta,
  .chart-controls {
    justify-content: flex-start;
  }

  .ticker-strip,
  .account-grid,
  .estimate-box,
  .two-fields {
    grid-template-columns: 1fr;
  }

  .estimate-box div:first-child {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .two-fields .field:first-child,
  .two-fields .field:last-child {
    padding-right: 14px;
    padding-left: 14px;
  }

  .canvas-wrap {
    height: 420px;
  }
}
