:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1ea;
  --blue: #1769e0;
  --green: #0f7a55;
  --amber: #a45f05;
  --red: #bf2a2a;
  --shadow: 0 12px 28px rgba(23, 32, 51, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

.app {
  width: min(1360px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

.status-strip,
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.ok {
  border-color: rgba(15, 122, 85, 0.2);
  background: rgba(15, 122, 85, 0.06);
  color: var(--green);
}

.pill.warn {
  border-color: rgba(164, 95, 5, 0.22);
  background: rgba(164, 95, 5, 0.07);
  color: var(--amber);
}

.pill.danger {
  border-color: rgba(191, 42, 42, 0.22);
  background: rgba(191, 42, 42, 0.06);
  color: var(--red);
}

.command-bar,
.watchlist-panel,
.chart-list-panel,
.strategy-panel,
.metric-card,
.panel,
.chart-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.command-bar {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(240px, 1.5fr) minmax(220px, 1.3fr) minmax(140px, 0.8fr) 90px auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
}

.watchlist-panel {
  margin-bottom: 14px;
  padding: 16px;
}

.chart-list-panel {
  margin-bottom: 14px;
  padding: 16px;
}

.chart-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.mini-chart-card {
  min-width: 0;
}

.mini-chart-button {
  display: grid;
  gap: 8px;
  width: 100%;
  height: auto;
  border-color: var(--line);
  padding: 10px;
  text-align: left;
}

.mini-chart-button.selected {
  border-color: var(--blue);
  background: rgba(23, 105, 224, 0.05);
}

.mini-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mini-chart-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-chart-card canvas {
  height: 150px;
}

.quick-symbols {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.quick-symbols button {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.quick-symbols button.selected,
.quick-symbols button[aria-pressed="true"] {
  border-color: var(--blue);
  background: rgba(23, 105, 224, 0.1);
  color: var(--blue);
}

.watchlist-editor {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 10px;
}

.selected-symbols {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 8px;
}

.symbol-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid rgba(15, 122, 85, 0.25);
  border-radius: 999px;
  padding: 4px 5px 4px 11px;
  background: rgba(15, 122, 85, 0.07);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.symbol-chip button {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  padding: 0;
  color: var(--green);
  line-height: 1;
}

.selected-empty,
.watchlist-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.watchlist-help {
  margin-bottom: 10px;
}

.watchlist-table tbody tr {
  cursor: pointer;
}

.watchlist-table tbody tr:hover,
.watchlist-table tbody tr.selected {
  background: var(--surface-soft);
}

.watchlist-table tbody tr.loading {
  background: rgba(23, 105, 224, 0.06);
}

.watchlist-error td {
  color: var(--red);
}

.strategy-panel {
  margin-bottom: 14px;
  padding: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.config-grid label {
  align-content: start;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface-soft);
}

.config-grid small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

.toggle {
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  height: 38px;
  color: var(--text);
}

.toggle input {
  width: 18px;
  height: 18px;
}

button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 13px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.danger {
  border-color: rgba(191, 42, 42, 0.25);
  color: var(--red);
}

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 116px;
  padding: 16px;
}

.metric-card span,
.metric-card small,
.chart-panel p,
.table-panel p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  font-size: 26px;
  line-height: 1;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
  margin-bottom: 14px;
}

.side-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel,
.chart-panel,
.table-panel {
  padding: 16px;
}

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

.panel-header.compact {
  margin-bottom: 12px;
}

#clockText {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

canvas {
  width: 100%;
  height: 360px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(#ffffff, #fbfcfe);
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.account-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface-soft);
}

dt,
.health-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

dd,
.health-list strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  font-weight: 800;
  word-break: break-word;
}

.health-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.health-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.health-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  white-space: nowrap;
}

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

.empty-row td {
  color: var(--muted);
  white-space: normal;
}

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

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

@media (max-width: 1080px) {
  .command-bar,
  .watchlist-editor,
  .chart-list,
  .config-grid,
  .main-grid {
    grid-template-columns: 1fr;
  }

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

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .app {
    width: min(100% - 20px, 1360px);
    padding-top: 16px;
  }

  .topbar,
  .status-strip,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  .overview,
  .account-grid {
    grid-template-columns: 1fr;
  }

  .pill,
  .actions button {
    width: 100%;
    text-align: center;
  }

  canvas {
    height: 300px;
  }
}
