:root {
  color-scheme: dark;
  --bg: #07110e;
  --panel: #0d1b17;
  --panel-2: #12251f;
  --line: rgba(178, 255, 221, 0.12);
  --text: #f1f7f4;
  --muted: #8ea79c;
  --green: #38e39f;
  --cyan: #67dbe4;
  --amber: #f2c66d;
  --red: #ff7f87;
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -10%, rgba(56, 227, 159, .13), transparent 30rem),
    radial-gradient(circle at 90% 5%, rgba(103, 219, 228, .08), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}
.topbar, main { width: min(1500px, calc(100% - 36px)); margin-inline: auto; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 34px 0 22px; border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: clamp(2.4rem, 6vw, 4.7rem); letter-spacing: -.065em; line-height: .95; }
h2 { margin: 4px 0 8px; font-size: 1.18rem; letter-spacing: -.02em; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: .69rem; font-weight: 800; letter-spacing: .18em; }
.subtitle, .connection p, li { color: var(--muted); }
.status-wrap { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 18px currentColor; }
.dot.live { background: var(--green); }
main { padding: 22px 0 50px; }
.notice {
  display: flex; align-items: center; gap: 16px; padding: 13px 16px; margin-bottom: 18px;
  border: 1px solid rgba(56, 227, 159, .28); border-radius: 14px; background: rgba(56, 227, 159, .06);
  color: var(--muted); font-size: .9rem;
}
.notice strong { color: var(--green); white-space: nowrap; }
.history-notice { border-color: rgba(242, 198, 109, .4); background: rgba(242, 198, 109, .06); }
.history-notice[hidden] { display: none; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.card, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(18, 37, 31, .95), rgba(10, 24, 20, .96)); }
.card { position: relative; overflow: hidden; padding: 20px; min-height: 170px; }
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.card .name { color: var(--muted); font-size: .84rem; }
.capital { margin: 20px 0 4px; font-size: 2.2rem; font-weight: 750; letter-spacing: -.05em; }
.profit { color: var(--muted); font-size: .85rem; }
.cash { margin-top: 5px; color: var(--muted); font-size: .75rem; }
.stats { display: flex; gap: 18px; margin-top: 18px; color: var(--muted); font-size: .75rem; }
.stats strong { color: var(--text); display: block; font-size: .95rem; }
.panel { padding: 20px; margin-bottom: 14px; }
.health { display: flex; align-items: center; justify-content: space-between; gap: 24px; border-color: rgba(56, 227, 159, .35); }
.health.warning { border-color: rgba(255, 127, 135, .55); background: linear-gradient(145deg, rgba(55, 24, 25, .94), rgba(23, 15, 15, .96)); }
.health p { margin: 0; color: var(--muted); font-size: .85rem; }
.health-metrics { display: flex; align-items: center; gap: 26px; color: var(--muted); font-size: .72rem; }
.health-metrics span { min-width: 125px; }
.health-metrics strong { display: block; margin-bottom: 4px; color: var(--text); font-size: .84rem; }
.connection { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.connection p { margin: 0; max-width: 680px; font-size: .85rem; }
#keyForm[hidden] { display: none; }
form { display: flex; gap: 8px; width: min(560px, 100%); }
input, button { border-radius: 10px; border: 1px solid var(--line); font: inherit; }
input { flex: 1; min-width: 0; padding: 12px 14px; color: var(--text); background: rgba(4, 12, 9, .75); outline: none; }
input:focus { border-color: rgba(56, 227, 159, .55); box-shadow: 0 0 0 3px rgba(56, 227, 159, .1); }
button { padding: 11px 16px; background: var(--green); color: #04110c; font-weight: 800; cursor: pointer; }
button.ghost { background: transparent; color: var(--text); padding: 8px 11px; }
button:disabled { opacity: .55; cursor: wait; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-note { margin: 6px 0 0; color: var(--muted); font-size: .8rem; }
.pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.pill, .tag { display: inline-flex; padding: 5px 8px; border-radius: 99px; background: rgba(103, 219, 228, .09); color: var(--cyan); font-size: .68rem; font-weight: 700; }
.position-count-open { color: var(--green); background: rgba(56, 227, 159, .1); }
.position-count-pending { color: var(--amber); background: rgba(242, 198, 109, .1); }
.table-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; min-width: 1120px; }
th { position: sticky; top: 0; z-index: 1; background: #12231e; color: var(--muted); font-size: .67rem; letter-spacing: .1em; text-transform: uppercase; text-align: left; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td { font-size: .79rem; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.question { display: block; max-width: 430px; color: var(--text); font-weight: 650; text-decoration: none; line-height: 1.35; }
.question:hover { color: var(--green); }
.price { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 750; }
.waiting { color: var(--muted); font-size: .72rem; }
.decision { font-weight: 800; }
.decision.BUY_YES { color: var(--green); }
.decision.BUY_NO { color: var(--red); }
.decision.NO_TRADE { color: var(--amber); }
.positions-table-wrap { max-height: 430px; }
.positions-table { min-width: 1080px; }
.positions-table td:nth-child(2) { max-width: 440px; }
.positions-table small { display: block; margin-top: 4px; color: var(--muted); font-size: .68rem; line-height: 1.35; }
.portfolio-name { color: var(--text); }
.side, .position-status { display: inline-flex; align-items: center; border-radius: 99px; padding: 4px 8px; font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.side.yes { color: var(--green); background: rgba(56, 227, 159, .1); }
.side.no { color: var(--red); background: rgba(255, 127, 135, .1); }
.position-status.open { color: var(--green); background: rgba(56, 227, 159, .1); }
.position-status.pending { color: var(--amber); background: rgba(242, 198, 109, .12); }
.position-status.won { color: var(--green); background: rgba(56, 227, 159, .1); }
.position-status.lost { color: var(--red); background: rgba(255, 127, 135, .1); }
.position-row.position-pending { background: rgba(242, 198, 109, .025); }
.position-profit { display: block; font-weight: 800; }
.position-profit.positive { color: var(--green); }
.position-profit.negative { color: var(--red); }
.waiting-result { display: block; max-width: 210px; color: var(--amber); font-size: .7rem; line-height: 1.35; }
.empty-state { padding: 26px; text-align: center; color: var(--muted); }
.bottom-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 14px; }
ul { margin: 12px 0 0; padding-left: 20px; line-height: 1.75; font-size: .84rem; }
.activity-panel { margin-bottom: 0; }
#activity { display: grid; gap: 9px; max-height: 180px; overflow: auto; }
.activity-item { display: flex; gap: 12px; color: var(--muted); font-size: .78rem; }
.activity-item time { color: var(--green); min-width: 128px; font-variant-numeric: tabular-nums; }
@media (max-width: 850px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 20px; }
  .cards, .bottom-grid { grid-template-columns: 1fr; }
  .connection { align-items: flex-start; flex-direction: column; }
  .health { align-items: flex-start; flex-direction: column; }
  .health-metrics { align-items: flex-start; flex-direction: column; gap: 12px; }
  form { flex-direction: column; }
  .notice { align-items: flex-start; flex-direction: column; gap: 5px; }
}
