/* Basis: K-IT Formbridge public/app.css (Variablen, Header, Card, Tabelle, Badge, Button), 2026-10-02. */
:root {
  --bg-page: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --border: #e4e4e7;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --bg-accent-muted: #f2f5ff;
  --accent: #3b5bfd;
  --bg-warning: #fef3c7;
  --text-warning: #92620a;
  --bg-success: #dcfce7;
  --text-success: #15803d;
  --bg-danger: #fee2e2;
  --text-danger: #b91c1c;
  --bg-info: #e0f2fe;
  --text-info: #075985;
  --bg-neutral: #f1f1f3;
  --text-neutral: #52525b;
  --radius: 6px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  margin: 0;
  padding: 0 2rem 3rem;
  color: var(--text-primary);
  background: var(--bg-page);
}

header.top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 0;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 1.5rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-link:hover {
  opacity: 0.75;
}

header.top img.brand-logo {
  height: 24px;
  width: auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

header.top h1 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.brand-tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
}

header.top nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

header.top a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
}

header.top a:hover {
  color: var(--text-primary);
}

/* Shows the language you'd switch TO, not the current one — a single
   link/toggle instead of two side-by-side DE/EN links. */
header.top a.lang-switch {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

header.top a.lang-switch:hover {
  color: var(--text-primary);
  background: var(--bg-neutral);
}

.card {
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 1.25rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-head .title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.card h3 {
  font-size: 0.95rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-primary);
}

.card h3:first-child {
  margin-top: 0;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.btn:hover {
  filter: brightness(0.92);
}

.card-head .count {
  font-size: 12px;
  color: var(--text-muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 0.5px solid var(--border);
  font-size: 0.9rem;
}

/* Deployment-ID/Job-ID are for debugging, not routine reading — hidden by
   default so the message column gets the room, one click away via the
   "show IDs" toggle. */
th {
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

tr:hover td {
  background: var(--bg-accent-muted);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
}

.badge.draft { background: var(--bg-warning); color: var(--text-warning); }
.badge.ready { background: var(--bg-success); color: var(--text-success); }
.badge.successful { background: var(--bg-success); color: var(--text-success); }
.badge.failed { background: var(--bg-danger); color: var(--text-danger); }
.badge.starting, .badge.running { background: var(--bg-info); color: var(--text-info); }
.badge.unknown { background: var(--bg-neutral); color: var(--text-neutral); }

.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.field-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.5rem;
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.field-grid dt { color: var(--text-muted); }
.field-grid dd { margin: 0; }

/* Two genuinely independent .field-grid blocks side by side, each with its
   own themed set of fields (see testcase-detail.ejs) — CHANGED 2026-09-14:
   a single 4-column grid can only alternate every other field between
   "left"/"right", it can't group fields by theme regardless of how many
   there are on each side. Wraps to a single stacked column on narrow
   screens. */
button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

button svg {
  width: 14px;
  height: 14px;
  flex: none;
}

button:hover:not(:disabled) {
  background: var(--bg-accent-muted);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.error-msg {
  color: var(--text-danger);
  background: var(--bg-danger);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.hint {
  color: var(--text-info);
  background: var(--bg-info);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Control Room settings page's "Verbindung testen" result — one line per
   checked item (auth, Run-As user, each pool), icon + text instead of a

/* ---- autostocks ---- */
h2 { font-size: 1.15rem; margin: 0 0 1rem; }
h2 .muted { font-size: 0.85rem; font-weight: 400; margin-left: 0.5rem; }
.section { margin-bottom: 1.25rem; }
.card-head .count { font-size: 12px; color: var(--text-muted); }
.table-wrap { overflow-x: auto; }
th.num, td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.pos { color: var(--text-success); }
td.neg { color: var(--text-danger); }
.hint-small.neg { color: var(--text-danger); }
tr.total-row td { font-weight: 600; border-top: 2px solid var(--border); background: var(--bg-neutral); }
form.inline { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; }
form.inline button { padding: 0.15rem 0.4rem; }
/* Automatik-Schalter in der Positionstabelle: der Badge IST der Knopf */
button.badge-toggle { border: none; background: none; padding: 0; }
button.badge-toggle:hover:not(:disabled) { background: none; filter: brightness(0.95); }
.customer-picker select { font-size: 0.85rem; padding: 0.25rem 0.4rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.current-user { font-size: 0.85rem; color: var(--text-secondary); }
.chart-box { position: relative; height: 340px; }
.login-card { max-width: 420px; margin: 4rem auto; text-align: center; }
.login-card .card-head { justify-content: center; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 0.35rem 0; }
.hint-small { font-size: 0.8rem; margin: 0.75rem 0 0; }
a { color: var(--accent); }
@media (max-width: 700px) {
  body { padding: 0 1rem 2rem; }
  header.top { flex-wrap: wrap; }
  header.top nav { margin-left: 0; flex-wrap: wrap; gap: 0.75rem; }
}

.card > .field-grid { border: none; background: none; padding: 0; margin: 0; }

/* ---- Formulare (Admin) ---- */
input[type="text"], input:not([type]), input[type="search"], input[type="url"], input[type="date"],
input[type="datetime-local"], select {
  font: inherit; font-size: 0.9rem; padding: 0.35rem 0.5rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-primary);
}
/* gleiche Hoehe und Schrift fuer alle Felder einer Zeile (sonst hängen die Beschriftungen unterschiedlich hoch) */
.row-form input:not([type="checkbox"]), .row-form select, form.stacked > label > input:not([type="checkbox"]), form.stacked > label > select { height: 2.25rem; box-sizing: border-box; }
input[type="date"], input[type="time"], select { font-family: inherit; }
input[type="date"] { min-width: 9.5rem; }
input.wide { min-width: 18rem; }
input.short { width: 7rem; }
input.mono, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
form.stacked { display: flex; flex-direction: column; gap: 0.9rem; }
form.stacked label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--text-secondary); }
.row-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.row-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--text-secondary); }
.row-form label.grow { flex: 1 1 14rem; }
.row-form label.grow input { width: 100%; }
label[hidden] { display: none !important; }
.inline-check { display: inline-flex; align-items: center; gap: 0.3rem; margin-right: 0.75rem; }
.ok-msg { color: var(--text-success); background: var(--bg-success); padding: 0.5rem 0.75rem; border-radius: var(--radius); font-size: 0.85rem; }
tr.inactive-row td { color: var(--text-muted); }
.page-narrow { max-width: 760px; }
.btn.btn-inline { margin-top: 0; }
code { font-size: 0.85em; background: var(--bg-neutral); padding: 0 0.25rem; border-radius: 3px; }
@media (max-width: 700px) { input.wide { min-width: 0; width: 100%; } }

/* ---- Live-Filter (public/table-filter.js) ---- */
tr.filter-row th { padding: 0.3rem 0.5rem 0.5rem; border-bottom: 2px solid var(--border); font-weight: 400; }
tr.filter-row input { width: 100%; min-width: 4rem; font-size: 0.8rem; padding: 0.2rem 0.4rem; }
tr.filter-empty td { color: var(--text-muted); text-align: center; padding: 1rem; }
table.filterable thead tr:first-child th { border-bottom: none; }
tr.filter-row select { width: 100%; font-size: 0.8rem; padding: 0.2rem 0.3rem; }
/* feste Spaltenbreiten: ISIN 12 Zeichen, WKN 6 Zeichen (Monospace) + Zellabstand */
th.w-isin { width: calc(12ch + 2rem); }
th.w-wkn { width: calc(6ch + 2rem); }
th.w-select { width: 9rem; }
th.w-bool { width: 5.5rem; }
th.w-date { width: 7.5rem; }
tr.filter-row th input, tr.filter-row th select { min-width: 0; }
td.mono { font-size: 0.85rem; }
th.w-select { width: 7rem; }
th.w-bool { width: 4.5rem; }
a.row-link { color: inherit; text-decoration: none; }
a.row-link:hover { color: var(--accent); text-decoration: underline; }
tr.filter-row input[type="checkbox"] { width: auto; min-width: 0; accent-color: var(--accent); cursor: pointer; }

/* ---- Buttons: alle blau wie in Testbridge (button.primary) ---- */
button { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 500; }
button:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
form.inline button:not(.badge-toggle) { padding: 0.3rem 0.75rem; }
input.full { width: 100%; min-width: 16rem; }
td.grow-cell { width: 40%; }
/* abschliessende Aktionen (z.B. Auswahl beenden): abgesetzt vom blauen Standard */
button.secondary-danger { background: var(--surface); color: var(--text-danger); border: 1px solid var(--border); font-weight: 500; }
button.secondary-danger:hover:not(:disabled) { background: var(--bg-danger); border-color: var(--text-danger); filter: none; }
/* Mail-Import + Protokoll */
details.mail-import summary { cursor: pointer; }
details.mail-import[open] summary { margin-bottom: 0.75rem; }
textarea { font: inherit; font-size: 0.85rem; padding: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); width: 100%; resize: vertical; }
textarea.drop { border-color: var(--accent); background: var(--bg-accent-muted); }
td.audit-detail { font-size: 0.78rem; color: var(--text-secondary); word-break: break-word; }
.btn.btn-secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
h3.section-title { font-size: 1rem; margin: 1.5rem 0 0.75rem; }
button.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
button.secondary:hover:not(:disabled) { background: var(--bg-accent-muted); filter: none; }
form.stacked label.inline-check { flex-direction: row; align-items: center; gap: 0.5rem; color: var(--text-primary); font-size: 0.9rem; }
input[type="email"] { font: inherit; font-size: 0.9rem; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-primary); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h2 { margin: 0; }
.page-head select { font-size: 0.85rem; padding: 0.25rem 0.4rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
input.end-date { font-size: 0.8rem; padding: 0.15rem 0.3rem; width: auto; }

/* ---- Spaltenbreiten: Textspalte (th.grow) bekommt den freien Platz, alle anderen nur
   so breit wie ihr Inhalt (kein Umbruch). Lange Texte brechen nur in td.wrap um. ---- */
table.fit th, table.fit td { white-space: nowrap; }
table.fit th.grow { width: 100%; white-space: normal; }
table.fit td.wrap { white-space: normal; }
table.fit th.w-isin, table.fit th.w-wkn, table.fit th.w-select, table.fit th.w-bool, table.fit th.w-date { width: auto; }
table.fit tr.filter-row input:not([type="checkbox"]), table.fit tr.filter-row select { min-width: 4.5rem; }
table.fit td.audit-detail { word-break: break-word; }
table.fit th.pct40 { width: 40%; white-space: normal; }
table.fit th.pct30 { width: 30%; white-space: normal; }

/* ---- Positionsseite: Diagramm-Steuerung ---- */
.chart-status { margin: 0.2rem 0 0.6rem; }
.chart-range { display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center; margin-bottom: 0.6rem; }
.chart-range label { display: inline-flex; gap: 0.3rem; align-items: center; }
.chart-range input[type="date"] { width: auto; }
h3.sub-title { font-size: 0.95rem; margin: 1.1rem 0 0.4rem; }
.cash-line { margin: 0.2rem 0 0.8rem; }

/* Screenshot-Ablage in "Trade nachtragen" */
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; color: var(--text-muted); cursor: pointer; }
.drop-zone:focus, .drop-zone.drop { border-color: var(--accent); outline: none; background: var(--surface); }

/* Naehe zum Stop (Uebersicht, Spalte Hoch) und Sortierung der Tabellen */
.stop-near { color: #b45309; font-weight: 600; }
.stop-hit { font-weight: 700; }
table.filterable thead tr:first-child th { cursor: pointer; user-select: none; }
table.filterable thead tr:first-child th[data-sort="asc"]::after { content: " ▲"; font-size: 0.7em; }
table.filterable thead tr:first-child th[data-sort="desc"]::after { content: " ▼"; font-size: 0.7em; }

/* ---- Handy (iPhone): Tabellen als Karten, Navigation als Leiste, groessere Tippflaechen ---- */
@media (max-width: 700px) {
  body { padding: 0 0.75rem calc(2rem + env(safe-area-inset-bottom)); }
  header.top { flex-direction: column; align-items: stretch; gap: 0.5rem; padding: calc(0.6rem + env(safe-area-inset-top)) 0 0.6rem; margin-bottom: 1rem; }
  header.top nav { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; min-width: 0; max-width: 100%; touch-action: pan-x pan-y; overscroll-behavior-x: contain; gap: 1rem; padding-bottom: 0.25rem; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  header.top nav::-webkit-scrollbar { display: none; }
  header.top nav a, header.top nav .current-user { white-space: nowrap; flex: none; padding: 0.35rem 0; }
  .customer-picker { flex: none; }
  .card { padding: 0.9rem; }
  input, select, textarea, button { font-size: 16px !important; } /* verhindert das Hineinzoomen von iOS in Felder */
  .page-head { gap: 0.5rem; }
  .chart-box { height: 260px; }
  .field-grid { grid-template-columns: max-content 1fr; }

  .table-wrap { overflow-x: visible; }
  table.cards, table.cards tbody, table.cards tfoot, table.cards tr, table.cards td { display: block; width: auto; }
  table.cards { min-width: 0; }
  table.cards thead { display: none; }
  table.cards tbody tr { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); margin: 0.6rem 0; padding: 0.4rem 0.75rem; }
  table.cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; border: none; padding: 0.2rem 0; text-align: right; white-space: normal; }
  table.cards td::before { content: attr(data-label); color: var(--text-muted); font-size: 0.8rem; text-align: left; flex: none; }
  table.cards td .cv { min-width: 0; overflow-wrap: anywhere; }
  table.cards td.m-title { display: block; text-align: left; font-weight: 600; padding: 0.25rem 0; order: -1; }
  table.cards td.m-title::before { content: none; }
  table.cards tr { display: flex; flex-direction: column; }
  table.cards tr.filter-empty { display: block; border: none; background: none; }
  table.cards tr.filter-empty td { display: block; text-align: center; }
  table.cards tr.filter-empty td::before { content: none; }
  table.cards td:empty, table.cards td:has(> .cv:empty) { display: none; }
  /* eingeklappt: nur Titel und Schluesselspalten; Tippen klappt auf */
  table.m-collapsible tbody tr { cursor: pointer; }
  table.m-collapsible tbody tr:not(.open) td:not(.m-title):not(.m-key):not(.filter-empty td) { display: none; }
  table.m-collapsible td.m-title::after { content: " ▾"; color: var(--text-muted); font-weight: 400; }
  table.m-collapsible tr.open td.m-title::after { content: " ▴"; }
  table.cards tfoot tr.total-row { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.4rem 0.75rem; margin-top: 0.6rem; }
  table.cards tfoot td { border-top: none; background: none; }
  table.cards tfoot td:not([data-label]) { display: none; }
  table.cards tfoot td:not([data-label]):not(:empty) { display: block; font-weight: 600; text-align: left; order: -1; }
}
@media (max-width: 700px) { table.cards tr[hidden] { display: none; } }

/* aktuelle Seite im Menue */
header.top nav a.active { color: var(--text-primary); font-weight: 700; }

/* Handy: Formulare, Kopfzeilen und Feldlisten */
@media (max-width: 700px) {
  .field-grid { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .field-grid dt { margin-top: 0.6rem; font-size: 0.8rem; }
  .row-form { flex-direction: column; align-items: stretch; }
  .row-form label, .row-form label.grow { flex: 1 1 auto; width: 100%; }
  .row-form input:not([type="checkbox"]), .row-form select, .row-form input.short, .row-form input[type="date"] { width: 100%; min-width: 0; }
  .row-form > button, .row-form > .btn { width: 100%; }
  .card-head { flex-wrap: wrap; gap: 0.5rem; }
  .card-head form.inline { display: flex; flex-direction: column; align-items: stretch; flex: 1 1 100%; gap: 0.35rem; }
  .card-head form.inline input[type="search"] { width: 100%; min-width: 0; }
  .card-head .btn { flex: 1 1 100%; text-align: center; }
  table.cards td.grow-cell { display: block; text-align: left; order: -1; }
  table.cards td.grow-cell::before { content: none; }
  table.cards td.grow-cell .cv { display: block; width: 100%; }
  table.cards td input:not([type="checkbox"]) { max-width: 100%; min-width: 0; }
  table.cards td input.full { width: 100%; }
  table.cards td button { white-space: nowrap; }
  table.cards td form.inline { flex-wrap: wrap; justify-content: flex-end; }
  table.cards td input[type="date"] { min-width: 0; width: 9.5rem; }
}
@media (max-width: 700px) { .cash-line > .muted { display: block; margin-top: 0.2rem; font-size: 0.85rem; } }

/* Handy: Spaltenfilter als Block ueber den Karten (die Kopfzeile selbst ist ausgeblendet) */
@media (max-width: 700px) {
  table.cards thead { display: block; }
  table.cards thead tr:first-child { display: none; }
  table.cards tr.filter-row { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.5rem; }
  table.cards tr.filter-row th { display: flex; flex-direction: column; gap: 0.15rem; flex: 1 1 8rem; width: auto; padding: 0; border: none; font-size: 0.75rem; color: var(--text-muted); text-align: left; }
  table.cards tr.filter-row th:empty { display: none; }
  table.cards tr.filter-row th::before { content: attr(data-label); }
  table.cards tr.filter-row th input[type="checkbox"] { align-self: flex-start; width: 1.4rem; height: 1.4rem; }
  table.cards tr.filter-row th input:not([type="checkbox"]), table.cards tr.filter-row th select { width: 100%; font-size: 16px; padding: 0.35rem 0.5rem; height: 2.25rem; }
  table.cards td.grow-cell input { font-weight: 400; }
}

textarea.autogrow { font: inherit; font-size: 0.9rem; line-height: 1.3; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-primary); resize: none; overflow: hidden; display: block; width: 100%; min-width: 16rem; }
.m-filterbar { display: none; }
@media (max-width: 700px) {
  textarea.autogrow { min-width: 0; font-size: 16px; font-weight: 400; }
  .m-filterbar { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.5rem; }
  .m-filter-toggle { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.6rem; flex: none; }
  .m-filter-toggle.active { background: var(--bg-accent-muted); border-color: var(--accent); }
  .m-filter-summary { font-size: 0.8rem; min-width: 0; overflow-wrap: anywhere; }
  table.cards tr.filter-row { display: none; }
  table.cards.filters-open tr.filter-row { display: flex; }
}
.m-filterbar[hidden] { display: none !important; }

/* ---- Beobachten ---- */
.alert-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-bottom: 0.3rem; }
.alert-line form.inline button { padding: 0.1rem 0.45rem; }
form.alert-form { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
form.alert-form select { max-width: 15rem; }

/* ---- Auftraege (MCP) ---- */
.order-box { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.order-reason { margin: 0.35rem 0; font-style: italic; }
.order-lines { margin: 0.4rem 0; padding-left: 1.2rem; }
.order-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
tr.flag-row td { background: var(--bg-warning); }
.row-form label.check { flex-direction: row; align-items: center; gap: 0.35rem; white-space: nowrap; }
.kpis { display: flex; flex-wrap: wrap; gap: 1rem 2rem; }
.kpis > div { display: flex; flex-direction: column; min-width: 8rem; }
.kpis strong { font-size: 1.25rem; }
.kpis .pos { color: var(--text-success); }
.kpis .neg { color: var(--text-danger); }
@media (max-width: 700px) {
  /* markierte Insider-Zeile als Karte: Rand statt halb eingefaerbter Zellen */
  table.cards tr.flag-row td { background: none; }
  table.cards tr.flag-row { border-left: 4px solid var(--text-warning); background: var(--bg-warning); }
}
strong.big { font-size: 1.2rem; }

/* ---- Menue: Verwaltung als Aufklapp-Menue (Desktop), auf dem Handy die Links direkt ---- */
header.top nav a, header.top nav summary { white-space: nowrap; }
.nav-more { position: relative; }
.nav-more summary { list-style: none; cursor: pointer; color: var(--text-secondary); font-size: 0.85rem; }
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary:hover, .nav-more summary.active { color: var(--text-primary); }
.nav-more summary.active { font-weight: 700; }
.nav-menu { position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 20; display: flex; flex-direction: column; min-width: 12rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.12); padding: 0.35rem 0; }
.nav-menu a { padding: 0.45rem 1rem; }
.nav-menu a:hover { background: var(--bg-neutral); }
.mobile-only { display: none; }
.tabbar { display: none; }
select.m-sort { display: none; }
@media (max-width: 700px) {
  .desk-only { display: none; }
  header.top nav a.mobile-only { display: inline; }
}

/* ---- Spaltenfilter-Auswahl: Standardeintrag heisst "alle" - so breit, dass die Werte lesbar bleiben ---- */
table.fit tr.filter-row select { min-width: 6rem; }
/* dichte Tabelle (Uebersicht/Positionen): weniger seitlicher Abstand, damit alle Spalten passen */
table.dense th, table.dense td { padding-left: 0.4rem; padding-right: 0.4rem; }
table.dense thead th { white-space: normal; }
table.dense tr.filter-row select, table.dense tr.filter-row input:not([type="checkbox"]) { min-width: 3.5rem; }
th.w-paper { min-width: 13rem; }
th.w-name { min-width: 14rem; }
th.w-setting { width: 16rem; }

/* ---- Beobachtungsliste: Alarme als Chips, Formular aufklappbar ---- */
h3.sub { font-size: 0.95rem; margin: 0.75rem 0 0.25rem; }
.alert-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.1rem 0.25rem 0.1rem 0.55rem; border-radius: 999px;
  background: var(--bg-info); color: var(--text-info); font-size: 0.8rem; white-space: nowrap; }
.chip.waiting { background: var(--bg-neutral); color: var(--text-neutral); }
.chip form.inline button.chip-x { background: none; border: none; color: inherit; padding: 0 0.3rem; font-size: 0.75rem; cursor: pointer; }
.add-alert summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; list-style: none; }
.add-alert summary::-webkit-details-marker { display: none; }
.add-alert[open] summary { margin-bottom: 0.35rem; }
td.w-alerts { min-width: 11rem; }
button.small, form.inline button.small { padding: 0.2rem 0.6rem; font-size: 0.8rem; }
.order-label { font-size: 0.8rem; margin-top: 0.4rem; }
.order-reason .muted { font-style: normal; }
.nav-count { display: inline-block; min-width: 1.15rem; padding: 0 0.3rem; margin-left: 0.2rem; border-radius: 999px; background: var(--text-danger);
  color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 1.15rem; text-align: center; vertical-align: 1px; }
a.insider-link { font-size: 0.8rem; }

/* Lange Listen am Handy: nur die ersten Zeilen (tr.m-more ausgeblendet), Knopf .m-more-btn klappt alle auf */
.m-more-btn { display: none; margin-top: 8px; }
@media (max-width: 700px) {
  table.m-collapse:not(.m-open) tr.m-more { display: none; }
  .m-more-btn { display: inline-block; }
}

/* Strategie - Stand jetzt (_strategy-state.ejs) */
.strategy-state { border-top: 1px solid var(--border, #e5e7eb); padding: 10px 0; }
.strategy-state:first-of-type { border-top: 0; }
.strategy-state p { margin: 0 0 4px; }
.state-list { margin: 4px 0 6px; padding-left: 20px; }
.state-list li { margin: 2px 0; }
.state-now { list-style: none; margin: 6px 0; padding: 0; }
.state-now li { margin: 3px 0; }
.state-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }

/* Farben fuer Gewinn/Verlust ueberall, nicht nur in Tabellenzellen */
.pos { color: var(--text-success); }
.neg { color: var(--text-danger); }
.stop-rest { color: var(--text-muted); font-style: italic; }
.todo-card { border-left: 3px solid var(--text-danger); }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li { padding: 8px 0; border-top: 1px solid var(--border); }
.todo-list li:first-child { border-top: 0; }
.todo-do { font-size: 1.05rem; }
.todo-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
a.button { display: inline-block; padding: 0.3rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; }
.strategy-state summary { cursor: pointer; }
form.set-high { flex-wrap: wrap; }
.set-high-hint { flex-basis: 100%; }
button[disabled][data-busy] { opacity: 0.6; }
@media (max-width: 700px) {
  button, a.button { min-height: 44px; }
  .todo-actions form, .todo-actions button { flex: 1 1 45%; }
  .state-actions { gap: 10px; }
  button.badge-toggle { min-height: 0; }
}

.foot-note { color: var(--text-muted); font-size: 0.8rem; margin: 24px 0 8px; }
.help h3 { margin-top: 1.2rem; }

/* Dark Mode nach Systemeinstellung (Abends am Handy) */
:root { color-scheme: light dark; }
/* Handy: Hauptseiten als Leiste unten, Sortieren als Auswahl */
@media (max-width: 700px) {
  body:has(.tabbar) { padding-bottom: calc(3.5rem + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; text-align: center; padding: 0.85rem 0.15rem; font-size: 0.85rem; color: var(--text-secondary); text-decoration: none; white-space: nowrap; }
  .tabbar a.active { color: var(--accent); font-weight: 700; }
  select.m-sort { display: block; max-width: 11rem; margin-left: auto; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #111114;
    --surface: #1b1b1f;
    --surface-2: #232328;
    --border: #33333a;
    --text-primary: #ececf0;
    --text-secondary: #b4b4bc;
    --text-muted: #9a9aa4;
    --bg-accent-muted: #20264a;
    --accent: #8ba0ff;
    --bg-warning: #3d2f0c;
    --text-warning: #f5c76b;
    --bg-success: #123321;
    --text-success: #4ade80;
    --bg-danger: #3f1616;
    --text-danger: #f87171;
    --bg-info: #0f2f42;
    --text-info: #7dd3fc;
    --bg-neutral: #2a2a30;
    --text-neutral: #c4c4cc;
  }
  button { color: #111114; }
  button.secondary { color: var(--accent); }
}
.stop-near { color: var(--text-warning); }
details.card > summary { cursor: pointer; font-weight: 500; }
.kpis.section { margin: 0 0 1rem; }
