:root {
  color-scheme: dark;
  --bg: #111214;
  --card: #1b1c1f;
  --line: #2a2b30;
  --text: #efefef;
  --muted: #9c9c9c;
  --series: #338ced;      /* eine Datenreihe: Depotwert, Anteile */
  --series-soft: #1d3550; /* Spur der Anteilsbalken (gleicher Ton, dunkler) */
  --good: #0aac23;
  --warn: #d28e05;
  --bad: #eb6263;
  --r: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Rahmen an allen Rändern, eigener Scrollbereich, Menü im Fluss (kein position:fixed – iOS) */
#frame { position: fixed; inset: 0; display: flex; flex-direction: column; min-height: 0; }
#top {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 18px) 10px calc(env(safe-area-inset-left) + 18px);
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; letter-spacing: .2px; }
.logo, .login-logo { width: 26px; height: 26px; border-radius: 7px; background: url("/icon-192.png") center/cover; }
#main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px calc(env(safe-area-inset-right) + 14px) 24px calc(env(safe-area-inset-left) + 14px); }
.view { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

#tabs {
  flex: none; display: flex; border-top: 1px solid var(--line); background: #151619;
  padding: 6px calc(env(safe-area-inset-right) + 6px) calc(env(safe-area-inset-bottom) + 6px) calc(env(safe-area-inset-left) + 6px);
}
.ios-pwa #tabs { padding-bottom: 6px; }
#tabs button {
  flex: 1; min-width: 0; background: none; border: 0; padding: 6px 2px 4px; color: var(--muted);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
}
#tabs button.on { color: var(--text); }
#tabs button.on .ico { background: var(--series); }
.ico { width: 24px; height: 24px; background: var(--muted); -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat; }
.i-depot   { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 20h18M5 16l4-5 4 3 6-8'/%3E%3C/svg%3E"); }
.i-orders  { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 7h13M7 12h13M7 17h13M3.5 7h.01M3.5 12h.01M3.5 17h.01'/%3E%3C/svg%3E"); }
.i-journal { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='3' width='14' height='18' rx='2'/%3E%3Cpath d='M9 8h6M9 12h6M9 16h4'/%3E%3C/svg%3E"); }
.i-control { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Cpath d='M12 8v4'/%3E%3C/svg%3E"); }

/* Karten */
.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin-bottom: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grid2 > * { min-width: 0; }
.label { color: var(--muted); font-size: 13px; }
.hero-value { font-size: 44px; font-weight: 650; letter-spacing: -.5px; margin: 2px 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.sim { color: var(--text); border-color: #3b3d44; }
.chip.live { color: #fff; background: var(--bad); border-color: var(--bad); }

/* Hinweise */
.alert { border-radius: var(--r); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; background: var(--card); border-left: 4px solid var(--warn); }
.alert.bad { border-left-color: var(--bad); }
.alert strong { display: block; margin-bottom: 2px; }

/* Diagramm */
.chart { position: relative; height: 170px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series); opacity: .12; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .dot { fill: var(--series); stroke: var(--card); stroke-width: 2; }
.chart-empty { height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: 14px; padding: 0 20px; }
.card { position: relative; }
.tip { position: absolute; pointer-events: none; background: #26272c; border: 1px solid #3a3b41; border-radius: 10px; padding: 6px 10px; font-size: 13px; white-space: nowrap; z-index: 3; }
.tip b { display: block; font-weight: 650; }

/* Bausteine */
.sleeve { padding: 10px 0; border-top: 1px solid var(--line); }
.sleeve:first-child { border-top: 0; padding-top: 2px; }
.sleeve-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.sleeve-name { font-weight: 600; }
.sleeve-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--series-soft); margin: 8px 0 6px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--series); }
.bar > s { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.sleeve-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: 13.5px; margin-top: 8px; }
.pos .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos .v { text-align: right; font-variant-numeric: tabular-nums; }
.pos .sub { color: var(--muted); font-size: 12px; }
.inactive { opacity: .55; }

/* Key/Value */
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.st { display: inline-flex; align-items: center; gap: 6px; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st.good { color: var(--good); } .st.warn { color: var(--warn); } .st.bad { color: var(--bad); }
ul.plain { list-style: none; margin: 0 0 6px; padding: 0; font-size: 14px; }
ul.plain li { padding: 5px 0; border-top: 1px solid var(--line); }
ul.plain li:first-child { border-top: 0; }

/* Listen */
.list .it { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; min-width: 0; }
.list .it:first-child { border-top: 0; padding-top: 0; }
.it-top { display: flex; justify-content: space-between; gap: 10px; }
.it-top b { font-weight: 600; }
.it .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; overflow-wrap: anywhere; }
.side { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 5px; margin-right: 6px; background: #26272c; }
.lvl { font-size: 11px; font-weight: 700; margin-right: 6px; }
.lvl.WARN { color: var(--warn); } .lvl.ERROR { color: var(--bad); } .lvl.INFO { color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; }

/* Knöpfe */
.btn { display: block; width: 100%; border: 1px solid #34363c; background: #24252a; border-radius: 12px; padding: 12px 14px; font-weight: 600; cursor: pointer; margin-top: 10px; }
.btn.big { padding: 15px; font-size: 16px; }
.btn.primary { background: var(--series); border-color: var(--series); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: none; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.99); }
.state { font-size: 15px; margin: 6px 0 2px; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

/* Anmeldung */
.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login-logo { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto 12px; }
.login h1 { margin: 0 0 4px; font-size: 26px; }
details { margin-top: 26px; text-align: left; background: var(--card); border-radius: var(--r); padding: 12px 14px; }
summary { cursor: pointer; font-weight: 600; }
details input { width: 100%; margin-top: 10px; background: #111214; border: 1px solid #34363c; border-radius: 10px; padding: 12px; font-size: 17px; }
#enrollCode { letter-spacing: 3px; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.msg { min-height: 20px; color: var(--bad); font-size: 14px; margin-top: 14px; }
.msg.ok { color: var(--good); }

/* Dialog, Meldung */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 10;
  padding: 16px calc(env(safe-area-inset-right) + 12px) calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 12px); }
.sheet-box { background: var(--card); border-radius: 18px; padding: 18px; width: 100%; max-width: 440px; }
.sheet-box h2 { margin: 0 0 6px; font-size: 18px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 64px); background: #26272c; border: 1px solid #3a3b41;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 11; max-width: 90vw; }

/* Breite Ansichten (iPhone Duo aufgeklappt, Mac) */
@media (min-width: 640px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .hero-value { font-size: 52px; }
}
@media (max-height: 700px) and (min-width: 601px) {
  #top { padding-top: calc(env(safe-area-inset-top) + 6px); padding-bottom: 6px; }
  .chart { height: 140px; }
}
@media (max-width: 360px) {
  .hero-value { font-size: 36px; }
}
