:root {
  --bg: #f4f5f7; --card: #fff; --border: #e3e6ea; --text: #1f2328; --muted: #6b7280;
  --accent: #2563eb; --accent-d: #1d4ed8; --green: #15803d; --amber: #b45309; --red: #b91c1c;
  --amber-bg: #fff7e6; --sel: #dbeafe; --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121417; --card: #1b1e23; --border: #2c3138; --text: #e8eaed; --muted: #9aa1ab;
          --accent: #4f8cff; --accent-d: #3b78f0; --green: #3fbf73; --amber: #e0a43a; --red: #f06b6b;
          --amber-bg: #2a2416; --sel: #1e2f4d; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
h1 { font-size: 21px; margin: 0; } h2 { font-size: 16px; margin: 0 0 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.btn { font: inherit; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 8px;
  padding: 9px 14px; cursor: pointer; }
.btn:hover:not(:disabled) { filter: brightness(0.96); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-d); }
.btn.danger { color: var(--red); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: transparent; }
input, select { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.lbl { font-weight: 600; font-size: 14px; }
.msg { min-height: 1.2em; font-size: 13px; margin: 6px 0 0; }
.msg.ok { color: var(--green); } .msg.err { color: var(--red); } .msg.warn { color: var(--amber); }

/* Tooltips: Maus drauf oder antippen */
.tip { font-style: normal; color: var(--accent); cursor: help; position: relative; font-weight: 400; margin-left: 2px; }
.tip:hover::after, .tip:focus::after {
  content: attr(data-tip); position: absolute; left: 50%; top: 130%; transform: translateX(-50%);
  width: max-content; max-width: min(320px, 80vw); white-space: normal; z-index: 50;
  background: #1f2937; color: #fff; padding: 9px 11px; border-radius: 8px; font-size: 13px; font-weight: 400;
  line-height: 1.4; text-align: left; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.tip:focus { outline: none; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 6px; }

/* Kopf */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 8px; flex-wrap: wrap; }
.top-right { display: flex; align-items: center; gap: 10px; position: relative; flex-wrap: wrap; }
.age { font-size: 13px; }
.age.fresh { color: var(--green); } .age.mid { color: var(--amber); } .age.old { color: var(--red); }
.menu { position: absolute; right: 0; top: 110%; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); z-index: 40; display: flex; flex-direction: column; min-width: 200px; }
.menu button { font: inherit; text-align: left; background: none; border: 0; padding: 10px 14px; color: var(--text); cursor: pointer; }
.menu button:hover { background: var(--bg); }

/* Reiter */
.tabs { display: flex; gap: 4px; padding: 0 16px; }
.tab { font: inherit; font-weight: 600; border: 1px solid var(--border); border-bottom: 0; background: #e6e8ec; color: var(--muted);
  padding: 9px 18px; border-radius: 10px 10px 0 0; cursor: pointer; }
@media (prefers-color-scheme: dark) { .tab { background: #23272e; } }
.tab.active { background: var(--card); color: var(--accent); }
.tabpage { border-top: 1px solid var(--border); padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; }

.row { display: flex; gap: 12px; align-items: stretch; }
.row.grow { flex: 1; }
.inputs { flex: 0 0 auto; }
.fields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.fields label { margin: 0; } .fields input { width: 120px; } .fields select { width: 170px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; flex: 1; }
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi b { font-size: 22px; font-weight: 650; }
.k-title { color: var(--muted); font-size: 13px; }
.learn progress { width: 100%; height: 10px; accent-color: var(--accent); }
.warn { background: var(--amber-bg); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px; line-height: 1.6; }
.warn a { color: inherit; }

.table-card { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px 6px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.table-wrap { overflow: auto; flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; background: color-mix(in srgb, var(--bg) 70%, var(--card)); position: sticky; top: 0; z-index: 1; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; } tbody tr:hover { background: color-mix(in srgb, var(--sel) 45%, transparent); }
tbody tr.sel { background: var(--sel); }
td img { width: 20px; height: 20px; vertical-align: -5px; margin-right: 6px; image-rendering: pixelated; }
.t-buy { color: #1e40af; } .t-sell { color: var(--green); }
@media (prefers-color-scheme: dark) { .t-buy { color: #8fb0ff; } }
.plus { color: var(--green); } .minus { color: var(--red); } .open { color: var(--amber); }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }

.steps { flex: 0 0 340px; display: flex; flex-direction: column; }
.steps ol { padding-left: 0; list-style: none; margin: 8px 0 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.steps li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; }
.steps li .n { color: var(--accent); font-weight: 700; text-align: right; }
.steps li.note { color: var(--muted); font-size: 13px; }
.steps li.muted { display: block; }
.steps li.alert { color: var(--amber); font-size: 13px; }
.steps details { font-size: 13px; color: var(--muted); }
.steps details ul { padding-left: 18px; margin: 6px 0; }
.s-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.form { flex: 0 0 380px; }
.seg { display: flex; gap: 4px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .seg { margin: 0; }
.seg-btn { font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.seg-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.radios { display: flex; gap: 16px; margin: 4px 0 10px; flex-wrap: wrap; }
.radio { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
.radio input { width: auto; }
.actions { display: flex; gap: 6px; align-items: center; padding: 0 14px 8px; flex-wrap: wrap; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

dialog { border: 1px solid var(--border); color: var(--text); width: min(440px, 94vw); padding: 18px 20px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg-btns { display: flex; gap: 8px; margin-top: 8px; } .dlg-btns .danger { margin-left: auto; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #1f2937; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; max-width: 92vw; box-shadow: 0 8px 24px rgba(0,0,0,.3); }

/* Handy */
@media (max-width: 980px) {
  .row { flex-direction: column; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps, .form { flex: none; }
  .tabs { overflow-x: auto; }
  .tab { padding: 9px 12px; }
  .fields input, .fields select { width: 100%; }
  .fields label { flex: 1 1 140px; }
  .table-wrap { max-height: 60vh; }
  th, td { padding: 7px 8px; }
}
