/* crax v2 — ein Stylesheet. Hell/Dunkel ueber prefers-color-scheme. */
:root {
  --bg: #f4f6f9; --panel: #ffffff; --panel2: #f0f3f7; --line: #dfe4ea;
  --text: #16202c; --muted: #5d6b7c; --faint: #8a96a5;
  --accent: #2463eb; --accent-soft: #e5edff;
  --up: #0f9d58; --up-soft: #e3f6ec; --down: #d93025; --down-soft: #fde8e6;
  --warn: #e37400; --warn-soft: #fff1e0; --gold: #b7791f; --gold-soft: #fdf4dc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f16; --panel: #121925; --panel2: #182131; --line: #243044;
    --text: #e6edf6; --muted: #9aa7b8; --faint: #6b7a8e;
    --accent: #5b8cff; --accent-soft: #1b2a4a;
    --up: #2fbf71; --up-soft: #12301f; --down: #ff5b50; --down-soft: #3a1714;
    --warn: #ffa43a; --warn-soft: #3a2710; --gold: #e3b341; --gold-soft: #3a3012;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .mono { font-family: var(--mono); }
.small { font-size: 13px; } .tiny { font-size: 12px; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }
.nowrap { white-space: nowrap; } .right { text-align: right; } .grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }

/* ------------------------------------------------------------ Shell */
header.top {
  position: sticky; top: 0; z-index: 20; background: var(--panel);
  border-bottom: 1px solid var(--line); padding: 10px 16px;
  display: flex; align-items: center; gap: 14px;
}
.brand { font-weight: 800; letter-spacing: .08em; font-size: 17px; }
.brand small { font-weight: 600; letter-spacing: 0; color: var(--muted); margin-left: 6px; font-size: 12px; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs a {
  padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px;
}
nav.tabs a.on { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
nav.tabs a:hover { text-decoration: none; color: var(--text); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--up); display: inline-block; }
.status-dot.bad { background: var(--down); } .status-dot.mid { background: var(--warn); }
main { max-width: 1180px; margin: 0 auto; padding: 16px; }
@media (max-width: 760px) {
  header.top nav.tabs {
    position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel);
    border-top: 1px solid var(--line); justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  nav.tabs a { font-size: 12px; padding: 6px 8px; display: flex; flex-direction: column; align-items: center; }
  nav.tabs a .ico { font-size: 18px; line-height: 1.1; }
  main { padding: 12px; }
}
@media (min-width: 761px) { nav.tabs a .ico { margin-right: 6px; } body { padding-bottom: 0; } }

/* ------------------------------------------------------------ Karten */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { flex: 1; }
.section { margin-top: 18px; }
.section > h2 { margin: 0 0 10px 2px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (max-width: 900px) { .grid.two { grid-template-columns: 1fr; } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .val { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi .val.small { font-size: 15px; }
.bar { height: 6px; border-radius: 3px; background: var(--panel2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.danger > i { background: var(--down); } .bar.ok > i { background: var(--up); } .bar.mid > i { background: var(--warn); }

/* ------------------------------------------------------------ Chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--muted); white-space: nowrap;
  border: 1px solid transparent;
}
.chip.up { background: var(--up-soft); color: var(--up); }
.chip.down { background: var(--down-soft); color: var(--down); }
.chip.ev { background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }
.chip.theme { background: transparent; border-color: var(--line); }
.chip.btn { cursor: pointer; }
.chip.btn.on { background: var(--accent); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.score { font-family: var(--mono); font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.score.s2 { background: var(--warn-soft); color: var(--warn); }
.score.s3 { background: var(--down-soft); color: var(--down); }

/* ------------------------------------------------------------ Vorgaenge */
.story { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.story:first-child { border-top: 0; padding-top: 2px; }
.story .lvl { width: 4px; border-radius: 2px; background: var(--line); flex: none; }
.story .lvl.s1 { background: var(--gold); } .story .lvl.s2 { background: var(--warn); } .story .lvl.s3 { background: var(--down); }
.story .body { flex: 1; min-width: 0; }
.story .meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.story .title { font-weight: 600; margin: 3px 0 6px; font-size: 15px; display: block; color: var(--text); }
.story .title:hover { color: var(--accent); text-decoration: none; }
.story .why { font-size: 12px; color: var(--faint); margin-top: 4px; }
.story img.thumb { width: 84px; height: 60px; object-fit: cover; border-radius: 8px; flex: none; background: var(--panel2); }
@media (max-width: 560px) { .story img.thumb { display: none; } }
.pos-flag { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 6px; }
.pos-flag.against { background: var(--down-soft); color: var(--down); }
.pos-flag.support { background: var(--up-soft); color: var(--up); }
.pos-flag.touch { background: var(--warn-soft); color: var(--warn); }

/* ------------------------------------------------------------ Positionen */
.positions { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.pos { padding: 14px; }
.pos .head { display: flex; align-items: baseline; gap: 8px; }
.pos .name { font-weight: 700; font-size: 16px; flex: 1; }
.pos .pnl { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.pos .line { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.pos .line b { color: var(--text); font-weight: 600; }
.ladder { position: relative; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--down-soft), var(--panel2) 50%, var(--up-soft)); margin: 12px 0 4px; }
.ladder i { position: absolute; top: -4px; width: 3px; height: 16px; border-radius: 2px; background: var(--text); }
.ladder .lbl { position: absolute; top: 12px; font-size: 11px; color: var(--muted); transform: translateX(-50%); white-space: nowrap; }
.pos .news { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 8px; font-size: 13px; }
.pos .news a { color: var(--text); display: block; padding: 3px 0; }
.dirtag { font-weight: 700; font-size: 12px; padding: 1px 6px; border-radius: 5px; text-transform: uppercase; }
.dirtag.long { background: var(--up-soft); color: var(--up); } .dirtag.short { background: var(--down-soft); color: var(--down); }

/* ------------------------------------------------------------ Tabellen */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--panel2); }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
.scroll-x { overflow-x: auto; }
@media (max-width: 640px) { .hide-sm { display: none; } }

/* ------------------------------------------------------------ Filter/Form */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
input[type=text], input[type=number], input[type=search], input[type=datetime-local], input[type=date], input[type=time], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 120px; font-family: var(--mono); font-size: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  padding: 8px 14px; border-radius: 9px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--down); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.form label.wide { grid-column: 1 / -1; }
.form label input, .form label select, .form label textarea { font-size: 15px; color: var(--text); font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--accent); color: #fff; }

/* ------------------------------------------------------------ Diverses */
.empty { padding: 24px; text-align: center; color: var(--muted); }
.note { background: var(--panel2); border-radius: 9px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.brief { white-space: pre-wrap; font-size: 14px; background: var(--panel2); border-radius: 9px; padding: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw; }
.overlay { position: fixed; inset: 0; background: rgba(8, 12, 20, .55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; overflow-y: auto; }
.dialog { background: var(--panel); border-radius: 14px; width: min(720px, 100%); padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dialog h2 { margin-bottom: 12px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.list-plain { margin: 0; padding: 0; list-style: none; }
.list-plain li { padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.list-plain li:first-child { border-top: 0; }
.back { display: inline-block; margin-bottom: 10px; font-weight: 600; }
.pill-level { font-size: 16px; }
.health-ok { color: var(--up); } .health-bad { color: var(--down); }
details > summary { cursor: pointer; font-weight: 600; }
