/* Minimal dark theme. Layout-first, single palette via custom properties.
 * TODO: theme — richer IBKR-mobile polish (container queries, density tuning) later. */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --border-strong: #3d444d;
  --text: #e6edf3;
  --muted: #8b949e;
  --gain: #3fb950;
  --loss: #f85149;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}

/* totals card — the page header (grand total across all groups) */
.totals {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
}

.totals-item {
  display: flex;
  flex-direction: column;
}

.totals-item .label {
  font-size: 0.75rem;
  color: var(--muted);
}

.totals-item .value {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

/* position groups */
.group {
  margin-bottom: 1.5rem;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.25rem 0;
  border-bottom: 2px solid var(--border-strong);
}

.group-label {
  font-weight: 600;
}

.group-amounts {
  display: flex;
  gap: 1rem;
  font-variant-numeric: tabular-nums;
}

/* position rows */
.positions {
  list-style: none;
  margin: 0;
  padding: 0;
}

.position {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.position-id {
  display: flex;
  flex-direction: column;
}

.position-id .symbol {
  font-weight: 600;
}

.position-id .account {
  font-size: 0.75rem;
  color: var(--muted);
}

.position-amounts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
}

/* sync status footer */
.sync-status {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  font-size: 0.85rem;
}

.synced-at {
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.sync-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sync-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.15rem 0;
}

.sync-row .detail {
  color: var(--muted);
}

/* P&L / status coloring */
.gain {
  color: var(--gain);
}

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

.sync-row.ok .mark {
  color: var(--gain);
}

.sync-row.failed .mark {
  color: var(--loss);
}

/* loading / empty / error states */
.loading,
.empty,
.error {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

.error button {
  margin-top: 0.5rem;
  padding: 0.4rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
}
