:root {
  --bg: oklch(0.985 0.003 250);
  --surface: oklch(1 0 0);
  --surface-alt: oklch(0.965 0.004 250);
  --border: oklch(0.89 0.006 250);
  --border-strong: oklch(0.78 0.01 250);
  --text: oklch(0.20 0.012 250);
  --text-secondary: oklch(0.46 0.01 250);
  --text-tertiary: oklch(0.64 0.008 250);
  --accent: oklch(0.47 0.13 250);
  --accent-hover: oklch(0.40 0.13 250);
  --accent-soft: oklch(0.93 0.035 250);
  --positive: oklch(0.5 0.13 155);
  --positive-soft: oklch(0.94 0.05 155);
  --negative: oklch(0.52 0.18 25);
  --negative-soft: oklch(0.95 0.045 25);
  --warning-text: oklch(0.5 0.12 75);
  --warning-soft: oklch(0.95 0.05 80);
  --radius-sm: 6px;
  --radius-md: 12px;
  --font-ui: 'IBM Plex Sans', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.container { max-width: 640px; margin: 0 auto; padding: 0 16px; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg); position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -0.01em; }
.topbar .sub { font-size: 12px; color: var(--text-secondary); }
.icon-btn {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text-secondary); background: none; border: none; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface-alt); }

.content { padding: 16px; display: flex; flex-direction: column; gap: 12px; max-width: 640px; margin: 0 auto; }
.tabbar { display: flex; border-bottom: 1px solid var(--border); max-width: 640px; margin: 0 auto; }
.tab { flex: 1; text-align: center; padding: 12px 0; font-size: 14px; font-weight: 600; color: var(--text-tertiary); border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-color: var(--accent); }

.section-label { font-size: 12px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .04em; margin: 6px 2px -2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; }

.account-card { display: flex; align-items: center; gap: 14px; }
.account-avatar { width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: 0 0 auto; }
.account-main { flex: 1; min-width: 0; }
.account-name { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.account-sub { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.account-pnl { text-align: right; flex: 0 0 auto; }
.account-pnl .amount { font-family: var(--font-mono); font-weight: 600; font-size: 15px; }
.account-pnl .label { font-size: 11px; color: var(--text-tertiary); }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--positive-soft); color: var(--positive); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }

.pos { color: var(--positive); }
.neg { color: var(--negative); }

.step-card { display: flex; flex-direction: column; gap: 8px; }
.step-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.step-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.step-name { font-size: 14.5px; font-weight: 600; margin: 0 0 2px; }
.step-dates { font-size: 12px; color: var(--text-secondary); }
.step-bottom { display: flex; align-items: center; justify-content: space-between; }
.step-meta { font-size: 12.5px; color: var(--text-secondary); }
.step-pnl { font-family: var(--font-mono); font-weight: 600; font-size: 14.5px; }
.rollback-note { font-size: 11.5px; color: var(--text-tertiary); border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 2px; }

.btn { min-height: 48px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; cursor: pointer; padding: 0 18px; }
.btn-primary { background: var(--accent); color: var(--surface); }
.btn-primary:hover { background: var(--accent-hover); color: var(--surface); }
.btn-secondary { background: var(--surface); color: var(--text-secondary); border-color: var(--border-strong); }
.btn-new { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-radius: var(--radius-md); border: 1.5px dashed var(--border-strong); color: var(--text-secondary); font-size: 14px; font-weight: 600; background: transparent; cursor: pointer; width: 100%; }
.btn-block { width: 100%; }

.pnl-hero { display: flex; flex-direction: column; gap: 2px; }
.pnl-hero .label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.pnl-hero .value { font-family: var(--font-mono); font-size: 30px; font-weight: 600; letter-spacing: -0.01em; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; }
.stat-card .label { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-card .value { font-family: var(--font-mono); font-size: 17px; font-weight: 600; }

.asset-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.asset-row:last-child { border-bottom: none; }
.asset-name { font-weight: 600; }
.asset-pnl { font-family: var(--font-mono); font-weight: 600; }

.proj-card { border-color: var(--accent); background: var(--accent-soft); }
.capital-switch { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
.capital-switch a { flex: 1; text-align: center; padding: 6px 0; font-size: 12px; font-weight: 600; color: var(--text-tertiary); border-radius: 6px; }
.capital-switch a.sel { background: var(--accent); color: var(--surface); }
.proj-net { text-align: center; padding: 10px 0 4px; }
.proj-net .label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.proj-net .value { font-family: var(--font-mono); font-size: 32px; font-weight: 700; color: var(--accent); letter-spacing: -0.01em; }
.proj-caption { font-size: 11px; color: var(--text-tertiary); text-align: center; margin-top: 4px; }
.proj-ref { font-size: 11.5px; color: var(--text-secondary); text-align: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.proj-link { font-size: 12px; font-weight: 600; text-align: center; margin-top: 8px; }

.day-label { font-size: 12px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .04em; margin: 10px 2px 3px; }
.day-label:first-child { margin-top: 2px; }
.day-empty { display: flex; align-items: baseline; gap: 6px; margin: 3px 2px; opacity: 0.55; }
.day-empty span { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.trade-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.trade-time { font-family: var(--font-mono); font-size: 12px; color: var(--text-tertiary); width: 44px; flex: 0 0 auto; }
.trade-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.trade-asset { font-size: 14px; font-weight: 600; }
.pos-tag { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--surface-alt); color: var(--text-secondary); }
.exit-tag { font-size: 11px; color: var(--text-tertiary); }
.trade-pnl { font-family: var(--font-mono); font-weight: 600; font-size: 14px; flex: 0 0 auto; text-align: right; }
.fab { position: fixed; right: 20px; bottom: 20px; width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: var(--surface); display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px oklch(0.47 0.13 250 / 0.35); border: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input, select.input, textarea.input {
  height: 48px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 0 14px; font-size: 15px; color: var(--text); background: var(--surface); font-family: var(--font-ui);
  width: 100%;
}
.input:focus, select.input:focus, textarea.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; min-height: 64px; padding: 12px 14px; }
.segmented { display: flex; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; height: 48px; }
.segmented label { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.segmented label + label { border-left: 1.5px solid var(--border-strong); }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented label.seg-long:has(input:checked) { background: var(--positive-soft); color: var(--positive); }
.segmented label.seg-short:has(input:checked) { background: var(--negative-soft); color: var(--negative); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 44px; box-sizing: border-box; display: inline-flex; align-items: center; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--border-strong); font-size: 13px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--surface); }

.reglages-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.reglages-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); gap: 12px; }
.reglages-row:last-child { border-bottom: none; }
.reglages-row-label { font-size: 14.5px; font-weight: 500; }
.reglages-row-hint { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }
.reglages-row input { width: 90px; text-align: right; font-family: var(--font-mono); font-size: 15px; border: 1px solid var(--border-strong); border-radius: 6px; height: 36px; padding: 0 8px; }

.messages { list-style: none; padding: 0; margin: 12px 16px 0; }
.messages li { background: var(--positive-soft); color: var(--positive); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 8px; }

.login-shell { max-width: 360px; margin: 15vh auto 0; padding: 0 16px; }
.login-shell h1 { font-size: 20px; margin-bottom: 20px; }

@media (min-width: 720px) {
  .content { max-width: 720px; }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
