/* Journal de trading — written for iOS 12 Safari (iPad Mini 2): no flex gap, no backdrop blur,
   rgba() colors, -webkit-sticky, light DOM. Dark theme. */
:root {
  --bg: #07090d;
  --surface: #0f131b;
  --surface-2: #151a24;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --fg: #e8edf4;
  --muted: #8a94a6;
  --faint: #5b6476;
  --accent: #4cc9f0;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --neutral: #6b7383;
  --gain: #2fd18b;
  --loss: #ff5c70;
  --warn: #f5b84b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); text-decoration: none; }
/* iOS Safari only sends click events to elements that look clickable */
[data-a] { cursor: pointer; -webkit-tap-highlight-color: rgba(76, 201, 240, 0.15); }
button, select, input { font: inherit; color: inherit; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.warn { color: var(--warn); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.bold { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* ---------- header */
.top {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 20;
  background: #0a0d13; border-bottom: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  padding: 10px 14px 0; padding-top: calc(10px + env(safe-area-inset-top));
}
.top-row { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; }
.top-row > * + * { margin-left: 10px; }
.brand { font-size: 16.5px; font-weight: 700; letter-spacing: -0.2px; -webkit-flex: 1; flex: 1; min-width: 0; }
.logo { display: block; width: 34px; height: 34px; -webkit-flex: none; flex: none; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.status { font-size: 11px; color: var(--muted); text-align: right; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 4px; margin-right: 5px; vertical-align: 1px; background: var(--gain); }
.dot.stale { background: var(--warn); }
.dot.off { background: var(--loss); }
.btn {
  display: inline-block; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 9px;
  padding: 7px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; -webkit-appearance: none;
}
.btn:active { background: #1f2633; }
.btn.primary { background: #1c5cab; border-color: #256abf; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.tabs { display: -webkit-box; display: -webkit-flex; display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px -14px 0; padding: 0 8px; }
.tab { padding: 9px 12px 10px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; font-weight: 500; font-size: 13.5px; }
.tab.on { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- filters */
.filters { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-align-items: center; align-items: center; padding: 10px 14px 4px; }
.filters > * { margin: 0 8px 8px 0; }
.seg { display: -webkit-inline-box; display: -webkit-inline-flex; display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; }
.seg span { padding: 6px 10px; font-size: 12.5px; cursor: pointer; color: var(--muted); border-left: 1px solid var(--line); }
.seg span:first-child { border-left: 0; }
.seg span.on { background: #1c2a40; color: var(--fg); }
select, input[type="text"], input[type="number"], input[type="date"], input[type="month"] {
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 9px; padding: 6px 8px; font-size: 13px; max-width: 100%;
  -webkit-appearance: none; color: var(--fg);
}
select { padding-right: 22px; background-image: linear-gradient(45deg, transparent 50%, #8a94a6 50%), linear-gradient(135deg, #8a94a6 50%, transparent 50%); background-position: calc(100% - 12px) 50%, calc(100% - 8px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
label.field { display: block; margin-bottom: 10px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }

/* ---------- layout */
main { padding: 6px 14px 30px; }
.grid { display: -ms-grid; display: grid; grid-gap: 12px; gap: 12px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.grid.g3 { grid-template-columns: 1fr 1fr 1fr; }
.grid.g4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.grid.g1 { grid-template-columns: 1fr; }
@media (max-width: 700px) { .grid.g3, .grid.g4 { grid-template-columns: 1fr 1fr; } .grid { grid-template-columns: 1fr; } .grid.kpis { grid-template-columns: 1fr 1fr; } }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.025); }
.grid > .card { margin-bottom: 0; }
.card h2 { font-size: 13.5px; font-weight: 600; margin: 0 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); color: var(--fg); letter-spacing: 0.1px; }
.card h2 .meta { float: right; font-size: 12px; font-weight: 400; color: var(--muted); }
.card h2 .meta b { font-weight: 600; }
@media (max-width: 600px) { .card h2 .meta { float: none; display: block; margin-top: 4px; } }
.card h2 .muted { font-weight: 400; }
.card h3 { font-size: 12px; font-weight: 600; margin: 12px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin: 18px 2px 8px; font-weight: 600; }
.kpi .label, .hero .label, .metric .label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.kpi .value { font-size: 21px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 3px; letter-spacing: -0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.kv { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); padding-right: 10px; }
.kv > span:last-child { font-variant-numeric: tabular-nums; text-align: right; font-weight: 550; }
.note { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 8px 0 0; }
.banner { border: 1px solid rgba(245, 184, 75, 0.35); background: rgba(245, 184, 75, 0.08); color: #f3d9a6; border-radius: 10px; padding: 8px 12px; margin: 10px 0 0; font-size: 13px; }
.banner.bad { border-color: rgba(255, 92, 112, 0.4); background: rgba(255, 92, 112, 0.08); color: #ffc2ca; }
.banner.good { border-color: rgba(47, 209, 139, 0.35); background: rgba(47, 209, 139, 0.07); color: #b8f0d6; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; font-size: 13px; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); vertical-align: 1px; }
.badge.long { color: var(--gain); border-color: rgba(47, 209, 139, 0.35); }
.badge.short { color: var(--loss); border-color: rgba(255, 92, 112, 0.35); }
.badge.warn { color: var(--warn); border-color: rgba(245, 184, 75, 0.35); }

/* ---------- tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; padding: 6px 6px 7px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
th[data-sort] { cursor: pointer; }
th.sorted { color: var(--fg); }
td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tablewrap table:not(.heat) tr:last-child > td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:active td { background: #182030; }
tr.excluded td { opacity: 0.5; }
.bar { position: relative; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.06); min-width: 60px; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.bar i.pos { background: var(--gain); }
.bar i.neg { background: var(--loss); }
.progress { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; border-radius: 3px; background: var(--s1); }
.progress i.done { background: var(--gain); }
.progress i.over { background: var(--loss); }

/* ---------- charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: #8a94a6; font-size: 10px; font-family: -apple-system, Helvetica, Arial, sans-serif; }
/* half-width cards scale the 600-wide charts down: keep their labels readable */
.grid:not(.g1) > .card .chart text { font-size: 17px; }
@media (max-width: 700px) { .grid:not(.g1) > .card .chart text { font-size: 11px; } }
.legend { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.legend span { margin-right: 12px; white-space: nowrap; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 3px; }
.tip { position: absolute; pointer-events: none; background: #1b2230; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 8px; font-size: 11.5px; color: var(--fg); white-space: nowrap; z-index: 5; display: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); }
.tip b { font-weight: 600; }

/* ---------- calendar */
.cal { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.cal th { border: 0; text-align: center; padding: 2px 0; }
.cal td { border: 0; padding: 0; height: 58px; vertical-align: top; border-radius: 8px; background: rgba(255, 255, 255, 0.03); cursor: pointer; }
.cal td.out { background: transparent; cursor: default; }
.cal td.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .d { font-size: 11px; color: var(--muted); padding: 4px 6px 0; }
.cal .v { font-size: 12px; font-weight: 600; padding: 2px 6px 0; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .t { font-size: 10px; color: var(--muted); padding: 0 6px; }
.yearcal { display: -ms-grid; display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 10px; gap: 10px; }
@media (max-width: 700px) { .yearcal { grid-template-columns: repeat(2, 1fr); } }
.mini { font-size: 10px; }
.mini .mt { font-size: 12px; font-weight: 600; margin-bottom: 4px; cursor: pointer; }
.mini table { border-collapse: separate; border-spacing: 2px; width: 100%; table-layout: fixed; }
.mini td { height: 14px; border-radius: 3px; padding: 0; border: 0; background: rgba(255, 255, 255, 0.04); }
.mini td.out { background: transparent; }
.heat td { text-align: center; font-size: 10px; padding: 0; height: 26px; border: 1px solid var(--bg); font-variant-numeric: tabular-nums; }
.heat th { font-size: 10px; text-align: center; padding: 2px; }

/* ---------- detail sheet */
.sheet-back { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); z-index: 50; }
.sheet { position: fixed; top: 4%; left: 50%; width: 94%; max-width: 900px; -webkit-transform: translateX(-50%); transform: translateX(-50%); bottom: 4%; background: #0d1118; border: 1px solid var(--line-strong); border-radius: 16px; z-index: 51; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-orient: vertical; -webkit-flex-direction: column; flex-direction: column; }
.sheet-head { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sheet-head .title { -webkit-flex: 1; flex: 1; font-weight: 650; font-size: 16px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px 20px; -webkit-flex: 1; flex: 1; }

.report { background: #fff; color: #1a1f29; border-radius: 12px; padding: 18px; }
.report h1 { font-size: 19px; margin: 0 0 2px; }
.report .sub { color: #6b7280; font-size: 12px; margin-bottom: 12px; }
.report h2 { color: #1e6bd9; font-size: 14px; border-bottom: 1px solid #1e6bd9; padding-bottom: 3px; margin: 16px 0 8px; }
.report .kv { border-color: #e5e7eb; }
.report .kv > span:first-child { color: #6b7280; }
.report table { color: #1a1f29; }
.report th { color: #6b7280; border-color: #d1d5db; }
.report td { border-color: #eceef1; }
.report .gain { color: #0b8a4c; }
.report .loss { color: #c4262f; }
.report .note { color: #6b7280; }
.report .chart text { fill: #6b7280; }
.boot { padding: 60px 20px; text-align: center; color: var(--muted); }
.row { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-align-items: center; align-items: center; }
.row > * { margin: 0 8px 8px 0; }
.widget-row { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.widget-row .name { -webkit-flex: 1; flex: 1; }
.widget-row .btn { margin-left: 6px; }
input[type="checkbox"] { width: 20px; height: 20px; margin: 0 10px 0 0; vertical-align: middle; }

/* Monitoring (home page): the AK dashboard's key figures, positions and P&L calendar */
.grid.g5 { grid-template-columns: 1fr 1fr 1fr 1fr 1fr; }
@media (max-width: 900px) { .grid.g5 .kpi .value { font-size: 19px; } }
@media (max-width: 700px) { .grid.g5 { grid-template-columns: 1fr 1fr; } }
table.positions td, table.positions th { white-space: nowrap; }
.calnav { margin-bottom: 10px; line-height: 30px; }
.calnav b { display: inline-block; min-width: 130px; text-align: center; margin: 0 4px; }
.calnav .btn { margin-right: 4px; }
.calsum { float: right; font-size: 12px; color: var(--muted); }
.calsum b { font-size: 15px; margin-left: 8px; }
@media (max-width: 700px) { .calsum { float: none; display: block; } }
.btn.disabled { opacity: 0.3; pointer-events: none; }
.cal .d.today { color: var(--accent); font-weight: 700; }
.kv.picked { margin-top: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
@media (max-width: 800px) { table.positions .opt { display: none; } }
.badge.part { color: var(--accent); border-color: rgba(76, 201, 240, 0.35); }
.grid.g7 { grid-template-columns: repeat(7, 1fr); }
.grid.g7 .kpi .value { font-size: 18px; }
@media (max-width: 800px) { .grid.g7 { grid-template-columns: 1fr 1fr 1fr 1fr; } .grid.g7 .kpi .value { font-size: 20px; } }
@media (max-width: 500px) { .grid.g7 { grid-template-columns: 1fr 1fr; } }

/* Monitoring tiles: big, readable from across the room (iPad standing alone) */
.grid.bigkpis { grid-template-columns: 1fr 1fr 1fr 1fr; }
.grid.bigkpis .kpi { padding: 16px 16px 15px; min-height: 128px; }
.grid.bigkpis .kpi .label { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid.bigkpis .kpi .value { font-size: 40px; font-weight: 700; letter-spacing: -1px; margin-top: 10px; line-height: 1.1; }
.grid.bigkpis .kpi .sub { font-size: 14px; margin-top: 8px; }
@media (max-width: 800px) {
  .grid.bigkpis .kpi { padding: 13px 12px 12px; min-height: 112px; }
  .grid.bigkpis .kpi .label { font-size: 12.5px; letter-spacing: 0.3px; }
  .grid.bigkpis .kpi .value { font-size: 29px; letter-spacing: -0.8px; }
  .grid.bigkpis .kpi .sub { font-size: 12.5px; }
}
@media (max-width: 560px) { .grid.bigkpis { grid-template-columns: 1fr 1fr; } }

/* Monitoring tile groups (Compte / Positions ouvertes / Risque) */
.section-title.kgroup { margin: 4px 2px 7px; font-size: 13px; }
.grid.bigkpis + .section-title.kgroup { margin-top: 16px; }
/* Two figures in one tile (best / worst position) */
.grid.bigkpis .kpi .value.duos { font-size: 26px; letter-spacing: -0.5px; margin-top: 7px; }
.duo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.duo small { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
/* Long / short balance bar */
.lsbar { height: 6px; border-radius: 3px; background: var(--loss); overflow: hidden; margin: 2px 0 6px; }
.lsbar i { display: block; height: 6px; background: var(--gain); }
@media (max-width: 800px) {
  .grid.bigkpis .kpi .value.duos { font-size: 20px; }
  .duo small { font-size: 12px; }
}
/* Calendar: days with partial closes, and the tapped day's trades */
.cal .t .part { color: var(--warn); }
.kv.picked ~ .kv.small { padding: 5px 12px; }

/* ---------- Dashboard tab */
/* account summary: value, change since the start, then the key amounts */
.hero { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; padding: 18px 20px;
  background: linear-gradient(120deg, rgba(57, 135, 229, 0.16), rgba(57, 135, 229, 0) 55%), #0f131b; border-color: rgba(57, 135, 229, 0.22); }
.hero-main { -webkit-flex: none; flex: none; min-width: 250px; padding-right: 24px; border-right: 1px solid var(--line); }
.hero-value { font-size: 38px; font-weight: 700; letter-spacing: -1px; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-change { font-size: 15px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero-change .muted { font-size: 12px; font-weight: 400; }
.hero-stats { -webkit-flex: 1; flex: 1; min-width: 0; display: -webkit-box; display: -webkit-flex; display: flex; }
.hs { -webkit-flex: 1; flex: 1; min-width: 0; padding-left: 20px; }
.hv { font-size: 19px; font-weight: 650; margin-top: 5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) {
  .hero { display: block; }
  .hero-main { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 14px; }
  .hero-stats { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .hs { -webkit-flex: none; flex: none; width: 50%; padding: 12px 10px 0 0; }
}
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; background: rgba(255, 255, 255, 0.06); color: var(--muted); vertical-align: 1px; }
.chip.gain { background: rgba(47, 209, 139, 0.13); color: var(--gain); }
.chip.loss { background: rgba(255, 92, 112, 0.13); color: var(--loss); }
/* period tiles: colored edge by sign */
.kpi.period { border-left: 3px solid var(--neutral); }
.kpi.period.up { border-left-color: var(--gain); }
.kpi.period.down { border-left-color: var(--loss); }
.kpi.period .value { font-size: 24px; margin-top: 5px; }
.kpi.period .sub { margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.period .sub + .sub { margin-top: 2px; }
/* performance indicators: one card, cells split by hairlines */
.metrics { display: -ms-grid; display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; grid-gap: 1px; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.metric { background: var(--surface); padding: 12px 14px; min-width: 0; }
.metric .value { font-size: 22px; font-weight: 650; letter-spacing: -0.3px; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .value small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.metric .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) { .metrics { grid-template-columns: 1fr 1fr; } }
/* goals, two columns */
.goals { display: -ms-grid; display: grid; grid-template-columns: 1fr 1fr; grid-gap: 16px 28px; gap: 16px 28px; }
@media (max-width: 700px) { .goals { grid-template-columns: 1fr; } }
.goal-head { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; -webkit-align-items: center; align-items: center; }
.goal-head .name { font-size: 12.5px; color: var(--muted); }
.goal-val { font-size: 16px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.goal-val .muted { font-size: 12.5px; font-weight: 400; }
