:root {
  color-scheme: light;
  --ink: #151718;
  --muted: #687076;
  --line: #dfe3e5;
  --surface: #ffffff;
  --surface-alt: #f6f7f8;
  --green: #13795b;
  --green-soft: #e9f6f1;
  --red: #c62a2f;
  --red-soft: #fff0f0;
  --amber: #9a6700;
  --amber-soft: #fff8e6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

.topbar {
  min-height: 104px;
  padding: 24px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.account-actions { display: flex; align-items: center; gap: 8px; }
.account-panel { margin-bottom: 20px; }
.account-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.account-form label { display: flex; flex-direction: column; gap: 5px; min-width: 220px; color: var(--muted); font-size: 12px; }
.account-form input { padding: 9px 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
.account-form button, .account-controls button { padding: 9px 12px; color: var(--surface); background: var(--ink); border: 0; border-radius: 5px; cursor: pointer; }
.account-form button.secondary, .account-controls button.secondary { color: var(--ink); background: var(--line); }
.account-form button.danger, .account-controls button.danger { background: var(--red); }
.account-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
body.auth-locked main > section:not(.account-panel) { display: none; }

h1, h2, p { margin: 0; }

h1 {
  margin-top: 3px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  margin-top: 3px;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.live { background: var(--green); }
.status-dot.error { background: var(--red); }

main { padding: 0 clamp(20px, 5vw, 72px) 44px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  border-bottom: 1px solid var(--line);
}

.metric {
  min-height: 92px;
  padding: 20px 18px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.metric:first-child { border-left: 0; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-size: 22px; font-variant-numeric: tabular-nums; }

.panel { padding-top: 34px; }

.paper-panel { padding: 28px 0 0; }
.paper-metrics { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.paper-metric { min-height: 76px; padding: 14px; border-left: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; gap: 5px; }
.paper-metric:first-child { border-left: 0; }
.paper-metric span { color: var(--muted); font-size: 11px; }
.paper-metric strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.paper-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.paper-overview-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-alt); }
.overview-label { color: var(--muted); font-size: 11px; }
.overview-value { display: flex; align-items: baseline; gap: 5px; margin-top: 5px; font-variant-numeric: tabular-nums; }
.overview-value strong { font-size: 20px; }
.overview-value span { color: var(--muted); font-size: 12px; }
.overview-pnl { margin-top: 5px; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.overview-note { min-height: 18px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.meter { height: 7px; margin-top: 10px; overflow: hidden; border-radius: 5px; background: var(--line); }
.meter span { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: var(--amber); transition: width .25s ease; }
.meter span.over { background: var(--red); }
.pnl-split { display: flex; height: 7px; gap: 2px; margin-top: 10px; overflow: hidden; border-radius: 5px; background: var(--line); }
.pnl-split span { display: block; min-width: 2px; transition: width .25s ease; }
.pnl-split span.positive { background: var(--green); }
.pnl-split span.negative { background: var(--red); }
.positions-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-top: 24px; margin-bottom: 10px; }
.positions-heading h3 { margin: 3px 0 0; font-size: 16px; }
.position-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.position-card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.position-card.is-positive { border-top: 3px solid var(--green); }
.position-card.is-negative { border-top: 3px solid var(--red); }
.position-card-header, .position-pnl, .track-labels, .position-card footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.position-card-header strong { font-size: 15px; letter-spacing: .1px; }
.position-card-header .side { margin-left: 7px; vertical-align: 2px; }
.position-mode { color: var(--muted); font-size: 11px; }
.position-pnl { margin-top: 13px; color: var(--muted); font-size: 11px; }
.position-pnl strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.position-track-wrap { margin: 17px 2px 11px; }
.position-track { position: relative; height: 7px; border-radius: 5px; background: var(--line); }
.position-track > span { position: absolute; top: 50%; transform: translate(-50%, -50%); }
.track-progress { height: 5px; border-radius: 5px; opacity: .65; }
.track-progress.positive { background: var(--green); }
.track-progress.negative { background: var(--red); }
.track-stop, .track-target, .track-entry, .track-current { width: 9px; height: 9px; border-radius: 50%; }
.track-stop { background: var(--red); }
.track-target { background: var(--green); }
.track-entry { width: 2px !important; height: 15px !important; border-radius: 0 !important; background: var(--ink); }
.track-current { width: 13px; height: 13px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px currentColor; }
.track-current.positive { background: var(--green); color: var(--green); }
.track-current.negative { background: var(--red); color: var(--red); }
.track-labels { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.position-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.position-values div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.position-values span { color: var(--muted); font-size: 10px; }
.position-values strong { overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.position-card footer { margin-top: 13px; color: var(--muted); font-size: 10px; }
.position-empty { grid-column: 1 / -1; padding: 32px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 6px; }
.paper-positions { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.paper-details { margin-top: 16px; border-top: 1px solid var(--line); }
.paper-details summary { padding: 12px 2px; color: var(--muted); cursor: pointer; font-size: 12px; }
.paper-notes { display: grid; gap: 7px; padding: 0 2px 4px; }
.paper-notes p { line-height: 1.5; }

.section-heading {
  min-height: 44px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading time,
.muted { color: var(--muted); font-size: 12px; }

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

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 820px;
}

th, td {
  height: 44px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th:first-child, td:first-child,
th:nth-child(2), td:nth-child(2) { text-align: left; }

th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfb; }

.side, .state {
  display: inline-flex;
  min-width: 52px;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.long, .won, .tp1 { color: var(--green); background: var(--green-soft); }
.short, .stopped { color: var(--red); background: var(--red-soft); }
.active { color: var(--amber); background: var(--amber-soft); }
.watching { color: var(--amber); background: var(--amber-soft); }
.positive { color: var(--green); }
.negative { color: var(--red); }
.empty { height: 80px; color: var(--muted); text-align: center !important; }

footer {
  padding: 18px clamp(20px, 5vw, 72px) 26px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 760px) {
  .topbar { min-height: 88px; padding-top: 18px; padding-bottom: 18px; }
  h1 { font-size: 20px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .paper-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .paper-overview, .position-grid { grid-template-columns: 1fr; }
  .positions-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .paper-metric:nth-child(odd) { border-left: 0; }
  .metric { min-height: 76px; border-bottom: 1px solid var(--line); }
  .metric:nth-child(odd) { border-left: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
}
