:root {
  --bg: #0B1017;
  --bg-elev: #101821;
  --card: #171F2B;
  --card-2: #1D2734;
  --line: #2A3544;
  --line-2: #3A4656;
  --text: #E8EEF5;
  --muted: #8B9AAB;
  --muted-2: #6A7888;
  --green: #3EE08F;
  --green-dim: rgba(62, 224, 143, 0.14);
  --green-ink: #0B2A1C;
  --red: #FF6B7A;
  --red-dim: rgba(255, 107, 122, 0.14);
  --blue: #5B9FFF;
  --blue-dim: rgba(91, 159, 255, 0.16);
  --amber: #F5C14A;
  --amber-dim: rgba(245, 193, 74, 0.16);
  --banner-bg: #3A2A0C;
  --banner-fg: #FFD978;
  --radius: 16px;
  --nav-h: 64px;
  --shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  background: #06080c;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  min-height: 100%;
}
button, input { font-family: inherit; }
#app {
  max-width: 412px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
#sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
}
#banner {
  background: var(--banner-bg);
  color: var(--banner-fg);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 217, 120, 0.22);
}
#top {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.sample-note {
  margin: 8px 0 0;
  color: var(--muted-2);
  font-size: 11px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.2;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--green-dim); color: var(--green); }
.badge.warn { background: var(--amber-dim); color: var(--amber); }
.badge.stale { background: var(--red-dim); color: var(--red); }
.filters { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.seg {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 6px;
  border-radius: 9px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--card-2);
  color: var(--text);
  box-shadow: var(--shadow);
}
main { padding: 12px 16px 18px; }
.view[hidden] { display: none !important; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.card h2, .section-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.hero-cap {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.pnl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.pnl-box {
  background: var(--card-2);
  border-radius: 12px;
  padding: 10px 11px;
}
.pnl-box .lbl { color: var(--muted); font-size: 11px; font-weight: 600; }
.pnl-box .eur {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pnl-box .pct {
  margin-top: 1px;
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.pos { color: var(--green); }
.neg { color: var(--red); }
.neu { color: var(--muted); }
.alloc {
  display: flex;
  gap: 14px;
  align-items: center;
}
.alloc svg { flex: 0 0 auto; }
.legend { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.leg-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.leg-name { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.swatch { width: 8px; height: 8px; border-radius: 50%; }
.leg-val { text-align: right; font-variant-numeric: tabular-nums; }
.leg-val .v { font-size: 13px; font-weight: 650; }
.leg-val .p { font-size: 11px; color: var(--muted); }
.note {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.note-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.bench-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.bench-row:first-of-type { border-top: 0; padding-top: 0; }
.bench-name { font-weight: 650; }
.bench-sub { color: var(--muted); font-size: 11px; margin-top: 1px; }
.bench-nums { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.delta-pill {
  display: inline-block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 6px;
}
.delta-pill.ahead { background: var(--green-dim); color: var(--green); }
.delta-pill.behind { background: var(--red-dim); color: var(--red); }
.chart-wrap { overflow: hidden; }
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.unit-toggle { display: flex; gap: 4px; }
.unit-toggle button {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
}
.unit-toggle button[aria-pressed="true"] {
  background: var(--blue-dim);
  border-color: transparent;
  color: var(--blue);
}
svg.chart { width: 100%; height: auto; display: block; }
.heat-month { margin-bottom: 12px; }
.heat-month:last-child { margin-bottom: 0; }
.heat-month h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 650;
  text-transform: capitalize;
}
.heat-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.heat-dow {
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted-2);
  letter-spacing: 0.04em;
  padding-bottom: 2px;
}
.heat-cell {
  aspect-ratio: 1;
  border-radius: 5px;
  background: #121820;
  border: 0;
  padding: 0;
  color: transparent;
  font-size: 0;
  position: relative;
}
.heat-cell.empty { background: transparent; }
.heat-cell.out { background: #121820; opacity: 0.35; }
.heat-cell.closed { background: #1A222C; }
.heat-cell.selected { outline: 2px solid #E8EEF5; outline-offset: 1px; }
.heat-tip {
  margin-top: 8px;
  background: var(--card-2);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  min-height: 36px;
  color: var(--muted);
}
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.stat.wide { grid-column: 1 / -1; }
.stat .k { font-size: 11px; color: var(--muted); font-weight: 650; }
.stat .n { margin-top: 4px; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .s { margin-top: 2px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.group-label {
  margin: 14px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.group-label:first-child { margin-top: 0; }
.holding { padding: 12px; }
.holding + .holding { margin-top: 8px; }
.h-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.h-name { font-size: 15px; font-weight: 700; }
.h-short { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 4px; }
.h-weight { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.h-mid {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.h-val { font-weight: 650; font-size: 13px; }
.h-pnl { font-size: 12px; font-weight: 650; text-align: right; }
.h-meta { margin-top: 2px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-row { margin-top: 8px; }
.bar-lbl {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.bar-track { height: 6px; background: #121820; border-radius: 99px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 99px; width: 0; }
.diary { display: flex; flex-direction: column; gap: 8px; }
.event {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.event.pending { border-color: rgba(245, 193, 74, 0.45); background: linear-gradient(180deg, rgba(245,193,74,0.08), var(--card) 42%); }
.ev-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.ev-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.pill {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
}
.pill.ok { background: var(--green-dim); color: var(--green); }
.pill.no { background: var(--red-dim); color: var(--red); }
.pill.wait { background: var(--amber-dim); color: var(--amber); }
.ev-date { color: var(--muted); font-size: 11px; }
.ev-title { margin: 6px 0 0; font-size: 14px; font-weight: 700; }
.ev-body { margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.ev-lines { margin: 8px 0 0; padding: 0; list-style: none; }
.ev-lines li {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 3px 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 12px;
}
#tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 412px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  background: rgba(11, 16, 23, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 30;
}
#tabbar button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 10px;
}
#tabbar button[aria-current="page"] { color: var(--text); }
#tabbar svg { width: 22px; height: 22px; display: block; }
html.shot, html.shot body { background: #FF00FF !important; }
html.shot #app { min-height: 0; padding-bottom: 0; }
html.shot #tabbar {
  position: relative;
  left: auto;
  transform: none;
  width: 100%;
  max-width: none;
}

#banner[hidden] { display: none !important; }
#boot {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
#boot.error { color: var(--red); }
#boot h2 { margin: 0 0 8px; font-size: 16px; color: var(--text); }
#app.waiting #views,
#app.waiting #tabbar,
#app.waiting .filters { display: none; }
#app.ready #boot { display: none; }
