:root {
  --bg: #f3f5f9; --card: #fff; --text: #1d2430; --muted: #66707f; --line: #d9dfea;
  --dark: #1f3a5f; --accent: #2f6fdb; --accent-text: #fff; --done: #e3f4e6; --done-line: #9dd1a6;
  --danger: #b3261e; --link: #0b57d0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d; --card: #1b212b; --text: #e6eaf1; --muted: #9aa5b6; --line: #2c3544;
    --dark: #0f1a2b; --accent: #5b92f0; --accent-text: #0b1220; --done: #17301d; --done-line: #2f6b3c;
    --danger: #f2a09b; --link: #8ab4f8;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 10px 14px; min-height: 44px; cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
input, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); min-height: 44px;
}
label, legend { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 4px; }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: .85rem; }

/* Login */
#login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--card); border-radius: 16px; padding: 24px; border: 1px solid var(--line); }
.login-card h1 { font-size: 1.3rem; margin-bottom: 8px; }
.login-card button { width: 100%; margin-top: 8px; }

/* Layout */
#app { height: 100%; display: flex; flex-direction: column; }
.top { background: var(--dark); color: #fff; display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.top h1 { font-size: 1.1rem; flex: 1; white-space: nowrap; }
.top .status { color: #c9d6ea; font-size: .8rem; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .ghost { color: #fff; border-color: rgba(255,255,255,.3); min-width: 44px; padding: 6px 10px; }
.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 12px; }
.pane { min-height: 0; min-width: 0; overflow-y: auto; display: none; }
@media (max-width: 899px) {
  .top { flex-wrap: wrap; }
  .top h1 { flex: 1 1 auto; }
  .top .status { order: 3; flex-basis: 100%; max-width: none; }
}
.pane.active { display: block; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pane-head h2 { font-size: 1.1rem; color: var(--dark); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pane-head h2 { color: var(--text); } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); background: var(--card); }
.tabs button { border: 0; border-radius: 0; min-height: 52px; }
.tabs button.active { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }

@media (min-width: 900px) {
  .panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pane { display: block !important; }
  .tabs { display: none; }
}

/* Karten */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card.done { background: var(--done); border-color: var(--done-line); }
.card-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; }
.check { flex: none; width: 44px; height: 44px; padding: 0; font-size: 1.5rem; line-height: 1; }
.card.done .check { color: #2e7d32; }
.card-main { flex: 1; min-width: 0; text-align: left; background: transparent; border: 0; padding: 4px 0; min-height: 44px; }
.card-main .t1 { font-weight: 600; overflow-wrap: anywhere; }
.card-main .t2 { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.card-main .t3 { color: #2e7d32; font-size: .85rem; margin-top: 2px; }
.card-detail { border-top: 1px solid var(--line); padding: 10px 14px 14px; }
.card-detail dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.card-detail dt { color: var(--muted); font-size: .85rem; }
.card-detail dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.card-detail .btns { display: flex; gap: 8px; margin-top: 12px; }
.mail-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font: inherit; }
a { color: var(--link); }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* Import-Protokoll */
.import-log { list-style: none; margin: 0 0 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-size: .9rem; }
.import-log li { padding: 2px 0; overflow-wrap: anywhere; }
.import-log .ok { color: #2e7d32; } .import-log .dup { color: var(--muted); } .import-log .fail { color: var(--danger); }

/* Dialoge */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin-bottom: 4px; overflow-wrap: anywhere; }
fieldset { border: 0; padding: 0; margin: 12px 0 0; }
.check-line { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check-line input { width: 22px; height: 22px; min-height: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#stelle-fields textarea { min-height: 80px; }
