:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #617080;
  --line: #d9e0e7;
  --info: #2d6cdf;
  --success: #137a4b;
  --warning: #b26100;
  --danger: #bd2d2d;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 3vw, 36px);
  background: #101820;
  color: #fff;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.topbar h1 {
  font-size: 26px;
  line-height: 1.1;
}

.topbar p {
  margin-top: 4px;
  color: #b9c6d2;
}

button {
  border: 1px solid #7ea7d8;
  background: #e8f2ff;
  color: #113a66;
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

main {
  padding: 18px clamp(16px, 3vw, 36px) 36px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.control-panel {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.control-panel > div,
.status-strip > div,
.card,
.config-panel,
.paper-panel,
.review-panel,
.trade-ledger {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.control-panel > div,
.status-strip > div {
  padding: 12px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented button {
  background: #f3f6f8;
  color: #25313c;
  border-color: var(--line);
}

.segmented button.active {
  background: #101820;
  color: #ffffff;
  border-color: #101820;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.instrument-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.card {
  padding: 16px;
}

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

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

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}

.badge.info {
  background: var(--info);
}

.badge.success {
  background: var(--success);
}

.badge.warning {
  background: var(--warning);
}

.badge.danger {
  background: var(--danger);
}

.master-command {
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  background: #f8fafc;
}

.master-command.buy {
  border-left-color: var(--success);
}

.master-command.hold {
  border-left-color: var(--info);
}

.master-command.exit {
  border-left-color: var(--danger);
}

.command-line {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0;
}

.command-reason {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.decision-title {
  font-size: 20px;
  margin-bottom: 4px;
}

.summary {
  color: var(--muted);
  line-height: 1.45;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.lights {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.light {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  min-height: 76px;
}

.light span:not(.dot) {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.light strong {
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

.dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #97a2ad;
  box-shadow: 0 0 0 3px rgba(151, 162, 173, 0.15);
}

.dot.red {
  background: #d33a2c;
  box-shadow: 0 0 0 3px rgba(211, 58, 44, 0.15);
}

.dot.blue {
  background: #1d6fd6;
  box-shadow: 0 0 0 3px rgba(29, 111, 214, 0.15);
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.metric strong {
  display: block;
  margin-top: 2px;
}

.orders,
.reasons,
.strategy-list {
  margin-top: 12px;
}

.orders h4,
.reasons h4,
.strategy-list h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

ul {
  margin: 0;
  padding-left: 18px;
}

li {
  margin: 4px 0;
}

.strategy-list {
  display: grid;
  gap: 8px;
}

.strategy-row {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.config-panel {
  margin-top: 14px;
  padding: 16px;
}

.paper-panel,
.review-panel,
.trade-ledger {
  margin-bottom: 14px;
  padding: 16px;
}

.paper-main {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.paper-main > div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.paper-table {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.paper-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.paper-row.selected {
  border-color: #101820;
}

.profit {
  color: var(--success);
}

.loss {
  color: var(--danger);
}

.small-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.review-panel h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

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

.ledger-head h2 {
  font-size: 18px;
}

.ledger-pnl {
  font-size: 22px;
  font-weight: 900;
}

.ledger-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 12px;
}

.ledger-grid h3,
.closed-review h3 {
  font-size: 15px;
  margin: 0 0 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

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

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

th {
  color: var(--muted);
  font-weight: 800;
  background: #f8fafc;
}

tr:last-child td {
  border-bottom: 0;
}

.closed-review {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.config-panel p {
  margin: 6px 0 12px;
  color: var(--muted);
}

pre {
  overflow: auto;
  max-height: 360px;
  background: #0f1720;
  color: #d7e5f4;
  border-radius: 6px;
  padding: 12px;
}

.error {
  border: 1px solid #e5b5b5;
  background: #fff2f2;
  color: #8d1f1f;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.hidden {
  display: none;
}

@media (max-width: 860px) {
  .control-panel,
  .status-strip,
  .instrument-grid,
  .metrics,
  .paper-main,
  .paper-table,
  .ledger-grid {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
