:root {
  --bg: #eef1ec;
  --paper: #fffdf8;
  --ink: #14241f;
  --ink-soft: #4d5c56;
  --muted: #7a8882;
  --line: #e3e8e2;
  --forest: #15241f;
  --gold: #c9a227;
  --pos: #1c6b45;
  --pos-bg: #e4f3ea;
  --neg: #9a3d3d;
  --neg-bg: #f6e6e4;
  --radius: 14px;
  --shadow: 0 12px 34px rgba(20, 36, 31, 0.08);
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 420px at 8% -8%, #e8efe4 0%, transparent 55%),
    radial-gradient(800px 380px at 100% 0%, #efe6c8 0%, transparent 48%),
    var(--bg);
  line-height: 1.45;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 1.2rem;
  background: var(--forest);
  color: #f7f3ea;
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-mark {
  width: 1.7rem; height: 1.7rem; border-radius: 5px;
  background: var(--gold); color: var(--forest);
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: 0.72rem;
}
.brand-name { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 0.95rem; }
.brand-sub { margin: 0; font-size: 0.72rem; color: #d9c889; }
.top-link { color: #f3e3aa; font-size: 0.82rem; font-weight: 600; text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: 0.8rem; }
.chip {
  font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase;
  background: #2a5a3a; color: #e8f6ea; padding: 0.2rem 0.55rem; border-radius: 999px;
}
.chip.busy { background: #7a6220; }
.chip.err { background: #7a3030; }

.layout { width: min(1180px, calc(100% - 1.5rem)); margin: 1rem auto 3rem; display: grid; gap: 1rem; }
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.panel-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
h1, h2 { font-family: var(--serif); margin: 0.15rem 0 0.4rem; }
h2 { font-size: 1.05rem; }
.kicker { margin: 0; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.lede, .hint { color: var(--ink-soft); font-size: 0.88rem; }
.hint { font-size: 0.8rem; }

.signal-hero {
  display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  background: var(--forest); color: #f7f3ea; border-radius: var(--radius); padding: 1.2rem 1.3rem;
}
.signal-hero.buy { box-shadow: inset 4px 0 0 #7dcc8a; }
.signal-hero.sell { box-shadow: inset 4px 0 0 #e08a7a; }
.signal-hero h1 { font-size: 2.4rem; margin: 0.1rem 0; letter-spacing: 0.04em; }
.hero-stats { display: flex; gap: 1.4rem; align-items: end; }
.hero-stats span { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: #d9c889; }
.hero-stats strong { font-size: 1.15rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
.actions .hint { flex: 1 1 100%; margin: 0.2rem 0 0; }
.btn {
  background: var(--forest); color: #f7f3ea; border: 0; border-radius: 8px;
  padding: 0.45rem 0.85rem; font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--forest); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; cursor: wait; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.7rem; }
.kpi {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.8rem;
}
.kpi span { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.kpi strong { font-size: 1.2rem; font-family: var(--serif); }
.kpi.ok strong { color: var(--pos); }
.kpi.bad strong { color: var(--neg); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th, td { text-align: left; padding: 0.4rem 0.45rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.win { color: var(--pos); font-weight: 600; }
.loss { color: var(--neg); font-weight: 600; }
.scroll { max-height: 420px; }

/* CSS box is the layout size. Bitmap size is set in JS and must not drive layout. */
.chart-canvas,
#equity-chart,
#dd-chart,
#inspect-chart {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 180px;
  box-sizing: border-box;
  flex-shrink: 0;
}
#inspect-chart { height: 220px; }

.bench { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.bench-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 0.45rem 0.7rem; min-width: 140px;
}
.bench-item.ok { background: var(--pos-bg); }
.bench-item.bad { background: var(--neg-bg); }
.bench-item small { display: block; color: var(--muted); }

.login-page { display: grid; place-items: center; min-height: calc(100vh - 3rem); padding: 1rem; }
.login-panel { width: min(420px, 100%); }
.form { display: grid; gap: 0.45rem; }
.form label { font-size: 0.82rem; font-weight: 600; margin-top: 0.3rem; }
.form input {
  border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.6rem; background: #fff;
}
.login-error { color: var(--neg); background: var(--neg-bg); padding: 0.45rem 0.6rem; border-radius: 8px; }

/* --- Hilfe-UI --- */
.intro p { margin: 0; font-size: 0.92rem; color: var(--ink-soft); }
.intro strong { color: var(--forest); font-weight: 650; }

.legend {
  margin: -0.1rem 0 0.65rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

h1, h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.signal-line { display: flex; align-items: center; gap: 0.5rem; }
.hero-gloss { margin: 0.15rem 0 0.35rem; font-size: 0.88rem; color: #e8d9a0; }
.signal-hero .lede { color: #d8d0c4; }
.signal-hero .kicker { display: flex; align-items: center; gap: 0.35rem; color: #d9c889; }

.btn-wrap { display: inline-flex; align-items: center; gap: 0.28rem; }
.kpi span { display: flex; align-items: center; gap: 0.28rem; }
.hero-stats span { display: flex; align-items: center; gap: 0.28rem; }
th { white-space: nowrap; }
.panel-head .hint { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }

.help-btn {
  display: inline-grid;
  place-items: center;
  width: 1.2rem;
  height: 1.2rem;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #c5cdc8;
  background: #fff;
  color: var(--forest);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}
.help-btn:hover, .help-btn:focus-visible {
  border-color: var(--gold);
  color: #8a7014;
  background: #fbf6e6;
}
.help-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.help-btn[aria-expanded="true"] {
  background: var(--forest);
  color: #f7f3ea;
  border-color: var(--forest);
}
.help-btn.on-dark {
  border-color: #d9c889;
  background: transparent;
  color: #f3e3aa;
}
.help-btn.on-dark:hover, .help-btn.on-dark:focus-visible {
  background: rgba(201, 162, 39, 0.18);
  color: #fff6d4;
  border-color: var(--gold);
}
.help-btn.on-dark[aria-expanded="true"] {
  background: var(--gold);
  color: var(--forest);
  border-color: var(--gold);
}

.help-popover {
  position: fixed;
  z-index: 80;
  width: min(22.5rem, calc(100vw - 1.5rem));
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem 1rem;
}
.help-popover[hidden] { display: none !important; }
.help-popover-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  margin: 0 1.6rem 0.35rem 0;
}
.help-popover-body {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
.help-popover-close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
}
.help-popover-close:hover, .help-popover-close:focus-visible {
  background: var(--line);
  color: var(--ink);
}
.help-popover-close:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

@media (max-width: 800px) {
  .help-popover { width: calc(100vw - 1.25rem); }
}

.live-warn {
  margin: 0.55rem 0 0;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: rgba(201, 162, 39, 0.18);
  color: #f3e3aa;
  font-size: 0.86rem;
}
.live-warn[hidden] { display: none !important; }

.inspect-controls {
  display: grid;
  grid-template-columns: minmax(12rem, 18rem) 1fr auto;
  gap: 0.8rem 1rem;
  align-items: end;
  margin: 0.4rem 0 0.6rem;
}
.inspect-field {
  display: grid;
  gap: 0.28rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.inspect-field input[type="datetime-local"],
.inspect-field input[type="range"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  background: #fff;
}
.inspect-slider input[type="range"] {
  padding: 0.45rem 0;
  accent-color: var(--forest);
}
.inspect-actions { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }

.inspect-verdict {
  margin: 0.8rem 0 0.5rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f7f5ef;
}
.inspect-verdict[data-state="buy"] { background: var(--pos-bg); border-color: #c5e2cf; }
.inspect-verdict[data-state="sell"] { background: var(--neg-bg); border-color: #ead3d0; }
.inspect-verdict[data-state="almost"] { background: #fbf6e6; border-color: #e6d7a4; }
.inspect-verdict[data-state="gap"] { background: #f3f1ea; }
.inspect-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.inspect-verdict > p:nth-child(2) { margin: 0; font-family: var(--serif); font-size: 1.05rem; }
.inspect-setup {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.45rem 0 0.8rem;
}
.inspect-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.65rem;
  min-width: 7.5rem;
  background: #fff;
}
.inspect-chip small { display: block; color: var(--muted); font-size: 0.72rem; }

.inspect-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.cond-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: #fff;
}
.cond-block h3 { margin: 0 0 0.45rem; font-size: 0.92rem; font-family: var(--serif); }
.cond {
  margin: 0 0 0.55rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}
.cond:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.cond-top { display: flex; align-items: baseline; gap: 0.45rem; }
.cond-status {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.cond[data-status="erfüllt"] .cond-status { color: var(--pos); }
.cond[data-status="fast"] .cond-status { color: #8a7014; }
.cond[data-status="nicht erfüllt"] .cond-status { color: var(--neg); }
.cond-label { font-size: 0.82rem; font-weight: 600; }
.cond-note { margin: 0.2rem 0 0; font-size: 0.78rem; color: var(--ink-soft); }
.cond-bar {
  height: 6px;
  border-radius: 99px;
  background: #e8ece6;
  margin-top: 0.3rem;
  overflow: hidden;
}
.cond-bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--forest);
  border-radius: 99px;
}
.cond[data-status="erfüllt"] .cond-bar > i { background: var(--pos); }
.cond[data-status="fast"] .cond-bar > i { background: var(--gold); }
.cond[data-status="nicht erfüllt"] .cond-bar > i { background: var(--neg); }
.filters-span { grid-column: 1 / -1; }

@media (max-width: 800px) {
  .inspect-controls { grid-template-columns: 1fr; }
  .inspect-lists { grid-template-columns: 1fr; }
}
