/* Optimed Tracker – gemeinsames Stylesheet */
:root {
  color-scheme: light;
  --page: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #f0efea;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e7e6df;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, .09);
  --accent: #1c6b58;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe8;
  --good: #006300;
  --bad: #c02f2f;
  --warn: #9a6200;
  --s1: #2a78d6;   /* Gewicht / systolisch */
  --s1-soft: #2a78d62e;
  --s2: #eb6834;   /* diastolisch */
  --s3: #1baf7a;   /* Muskel */
  --s4: #e87ba4;   /* Fett */
  --s5: #4a3aa7;   /* Puls */
  --s6: #2a9bd6;   /* Trinken */
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #8f8d86;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.09);
    --accent: #3fb893; --accent-ink: #06231b; --accent-soft: #173a30;
    --good: #2fbf4a; --bad: #f07070; --warn: #e3a52a;
    --s1: #3987e5; --s1-soft: #3987e533; --s2: #d95926; --s3: #199e70; --s4: #d55181; --s5: #9085e9; --s6: #3aa6e0;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #8f8d86;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.09);
  --accent: #3fb893; --accent-ink: #06231b; --accent-soft: #173a30;
  --good: #2fbf4a; --bad: #f07070; --warn: #e3a52a;
  --s1: #3987e5; --s1-soft: #3987e533; --s2: #d95926; --s3: #199e70; --s4: #d55181; --s5: #9085e9; --s6: #3aa6e0;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 550;
  text-decoration: none; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn svg { width: 18px; height: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 550; }
.field input, .field textarea, .field select {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px;
  padding: 10px 12px; outline: none; width: 100%;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); background: var(--surface); }
.field .hint { font-size: 12px; color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--page); padding: 10px 18px; border-radius: 999px;
  font-weight: 550; opacity: 0; transition: .25s; pointer-events: none; z-index: 100;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); color: #fff; }

/* Dialoge */
dialog {
  border: none; padding: 0; border-radius: 20px; background: var(--surface); color: var(--ink);
  width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(10, 12, 11, .45); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { padding: 12px 20px; display: grid; gap: 14px; }
.dlg-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 8px 20px 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Diagramme */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .ref-line { stroke: var(--muted); stroke-width: 1.25; stroke-dasharray: 4 4; }
.chart .ref-label { fill: var(--muted); font-size: 11px; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-raw { fill: none; stroke-width: 1.25; opacity: .45; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .end-label { font-size: 12px; font-weight: 650; fill: var(--ink); }
.chart .empty { fill: var(--muted); font-size: 13px; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14); white-space: nowrap; z-index: 5; display: none;
}
.tip .t-date { color: var(--ink-2); font-size: 12px; margin-bottom: 4px; }
.tip .t-row { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.tip .sw { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.tip b { font-weight: 650; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px) !important; height: 2px; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.good::before { background: #0ca30c; } .badge.warn::before { background: #fab219; }
.badge.serious::before { background: #ec835a; } .badge.critical::before { background: #d03b3b; }
.pbar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.pbar > div { height: 100%; background: var(--s6); border-radius: 999px; transition: width .4s; max-width: 100%; }
.chart .bar { transition: opacity .1s; }
