/* Trading-Dashboard — Design-Tokens nach validierter Referenz-Palette
   (dataviz-Skill). Light + Dark über prefers-color-scheme, ein Token-Satz. */

:root {
  color-scheme: light dark;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --sunken: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --neg-text: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --sunken: #131312;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #06121f;
    --good-text: #0ca30c;
    --neg-text: #e66767;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 1150px; margin: 0 auto; padding: 1.75rem 1.25rem 5rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1 { font-size: 1.35rem; font-weight: 650; letter-spacing: -0.01em; margin: 0.5rem 0 1rem; }
h2 { font-size: 1rem; font-weight: 650; letter-spacing: -0.005em; color: var(--ink-2);
  margin: 2.25rem 0 0.75rem; text-transform: uppercase; font-size: 0.8rem;
  letter-spacing: 0.06em; }
.muted { color: var(--muted); }
.pos { color: var(--good-text); }
.neg { color: var(--neg-text); }

/* ---------- Nav ---------- */
nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 0.25rem;
  padding: 0.6rem 1.25rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}
nav .brand {
  font-weight: 700; letter-spacing: -0.01em; margin-right: 1rem;
  color: var(--ink); display: flex; align-items: center; gap: 0.45rem;
}
nav a.navlink {
  color: var(--ink-2); padding: 0.3rem 0.7rem; border-radius: 8px;
  font-weight: 500;
}
nav a.navlink:hover { background: var(--sunken); text-decoration: none; color: var(--ink); }
nav a.navlink.active { background: var(--sunken); color: var(--ink); font-weight: 650; }
nav .btn-new {
  background: var(--accent); color: var(--accent-ink);
  padding: 0.3rem 0.85rem; border-radius: 8px; font-weight: 650;
  margin-left: 0.5rem;
}
nav .btn-new:hover { text-decoration: none; filter: brightness(1.08); }
nav .logout { margin-left: auto; }
nav .logout button {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 0.28rem 0.75rem; cursor: pointer; font: inherit;
  font-size: 0.85rem;
}
nav .logout button:hover { color: var(--ink); border-color: var(--muted); }

/* ---------- Panels & Tabellen ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
  margin: 0.75rem 0;
}
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.55rem 0.9rem; white-space: nowrap; }
td { border-top: 1px solid var(--hairline); }
th {
  color: var(--muted); font-weight: 600; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--sunken);
}
tbody tr:hover td, table tr:hover td { background: color-mix(in srgb, var(--sunken) 55%, transparent); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .rowaction { font-size: 0.85rem; }

/* ---------- Badges (Status: Punkt + Label, nie Farbe allein) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; font-weight: 650; letter-spacing: 0.03em;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--ink-2);
  background: var(--sunken);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.badge.v-verkaufen      { background: color-mix(in srgb, var(--critical) 12%, var(--surface)); }
.badge.v-verkaufen .dot { background: var(--critical); }
.badge.v-gewinnmitnahme      { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); }
.badge.v-gewinnmitnahme .dot { background: var(--warning); }
.badge.v-beobachten      { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.badge.v-beobachten .dot { background: var(--accent); }
.badge.v-halten      { background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.badge.v-halten .dot { background: var(--good); }
.badge.side-long  { color: var(--good-text); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
.badge.side-short { color: var(--neg-text);  background: color-mix(in srgb, var(--critical) 10%, var(--surface)); }

/* ---------- Banner ---------- */
.banner {
  display: flex; align-items: baseline; gap: 0.6rem;
  padding: 0.7rem 1rem; border-radius: 10px; margin: 0.6rem 0;
  background: var(--surface); border: 1px solid var(--border);
  border-left-width: 3px;
}
.banner.warn  { border-left-color: var(--warning); }
.banner.error { border-left-color: var(--critical); color: var(--neg-text); }
.banner.info  { border-left-color: var(--accent); }

/* ---------- Stat-Kacheln ---------- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem; margin: 1rem 0 1.5rem;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: 0.85rem 1rem; display: flex; flex-direction: column; gap: 0.15rem;
}
.stat .label { color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.stat .value { font-size: 1.45rem; font-weight: 650; letter-spacing: -0.01em; }
.stat .sub { color: var(--muted); font-size: 0.78rem; }

/* ---------- Scanner-Output & Läufe ---------- */
.output {
  background: var(--sunken); border-top: 1px solid var(--hairline);
  padding: 0.9rem 1rem; margin: 0; overflow-x: auto;
  font: 0.8rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--ink-2); max-height: 480px; overflow-y: auto;
}
.panel > .output { border-top: none; }
.run {
  margin: 0.5rem 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.run summary {
  cursor: pointer; padding: 0.65rem 1rem; font-weight: 500;
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
  list-style: none;
}
.run summary::-webkit-details-marker { display: none; }
.run summary::before { content: "▸"; color: var(--muted); font-size: 0.8rem; }
.run[open] summary::before { content: "▾"; }
.run summary:hover { background: var(--sunken); }
.run .mode {
  font-size: 0.72rem; font-weight: 650; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  padding: 0.05rem 0.5rem; border-radius: 999px;
}
.run .pick { color: var(--muted); font-size: 0.85rem; }

/* ---------- Karten (Login etc.) ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  padding: 2.5rem 2rem; max-width: 420px; margin: 5rem auto;
}
.center { text-align: center; }
.card .logo { font-size: 2.2rem; display: block; margin-bottom: 0.5rem; }
.card p { color: var(--ink-2); }

/* ---------- Formulare ---------- */
.tradeform fieldset {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  margin: 1rem 0; padding: 1rem 1.1rem 1.2rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem 1rem;
}
.tradeform legend {
  color: var(--ink-2); font-weight: 650; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 0 0.4rem;
}
.tradeform label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.8rem; font-weight: 500; color: var(--ink-2);
}
.tradeform label.wide { grid-column: 1 / -1; }
.tradeform label.check { flex-direction: row; align-items: center; gap: 0.5rem; }
.tradeform input, .tradeform select, .tradeform textarea {
  background: var(--page); border: 1px solid var(--border); color: var(--ink);
  border-radius: 8px; padding: 0.5rem 0.65rem; font: inherit;
}
.tradeform input:focus, .tradeform select:focus, .tradeform textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.tradeform textarea { min-height: 64px; resize: vertical; }
.tradeform input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; }

details.journal > summary {
  cursor: pointer; color: var(--muted); font-size: 0.85rem; font-weight: 500;
  padding: 0.5rem 0.25rem; list-style: none;
}
details.journal > summary::-webkit-details-marker { display: none; }
details.journal > summary::before { content: "▸ "; }
details.journal[open] > summary::before { content: "▾ "; }
details.journal > summary:hover { color: var(--ink); }

.actions {
  display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem;
}
button.primary {
  background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: 10px; padding: 0.6rem 1.5rem; font: inherit; font-weight: 650;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }
.cancel { color: var(--muted); }

/* ---------- Icons (Inline-SVG-Sprite, erben currentColor) ---------- */
.icon {
  width: 1em; height: 1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.125em;
}
nav .brand-icon { width: 1.15em; height: 1.15em; color: var(--accent); }
.banner-icon { width: 1.1em; height: 1.1em; margin-top: 0.2em; }
.banner-icon.warn { color: var(--warning); }
.banner-icon.info { color: var(--accent); }
.banner { align-items: flex-start; }
.card .logo .icon { width: 2.4rem; height: 2.4rem; color: var(--accent); stroke-width: 1.75; }

.jstate {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.82rem; font-weight: 500;
}
.jstate.done { color: var(--good-text); }
.jstate.open { color: var(--muted); }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 2.5rem 1rem; text-align: center;
}
.empty p { margin: 0.2rem 0; }
.empty .empty-icon { width: 2rem; height: 2rem; color: var(--muted); stroke-width: 1.5; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- Kleinkram ---------- */
@media (max-width: 640px) {
  nav { padding: 0.5rem 0.75rem; }
  main { padding: 1.25rem 0.75rem 4rem; }
  .card { margin: 2.5rem auto; }
}
