/* Dashboard – Hell/Dunkel über CSS-Variablen */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f0f1f5;
  --border: #e2e4ea;
  --text: #1b1e27;
  --muted: #6b7180;
  --accent: #4f46e5;
  --accent-soft: #eceafd;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --error: #b91c1c;
  --error-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / 18%);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;
    --surface: #181b24;
    --surface-2: #20242f;
    --border: #2b303d;
    --text: #e7e9ef;
    --muted: #9198a8;
    --accent: #818cf8;
    --accent-soft: #272a4a;
    --accent-text: #0f1117;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --warn: #fbbf24;
    --warn-soft: #3a2c0d;
    --error: #f87171;
    --error-soft: #3b1717;
    --info: #60a5fa;
    --info-soft: #172a47;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-lg: 0 12px 32px rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #20242f;
  --border: #2b303d;
  --text: #e7e9ef;
  --muted: #9198a8;
  --accent: #818cf8;
  --accent-soft: #272a4a;
  --accent-text: #0f1117;
  --ok: #4ade80;
  --ok-soft: #14301f;
  --warn: #fbbf24;
  --warn-soft: #3a2c0d;
  --error: #f87171;
  --error-soft: #3b1717;
  --info: #60a5fa;
  --info-soft: #172a47;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / 55%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; font-weight: 650; }
code, pre { font-family: var(--mono); font-size: .88em; }
.boot { padding: 40px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- Buttons & Formulare */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-size: .9rem; font-weight: 550;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--error); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 3px 8px; font-size: .82rem; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  border-radius: 6px; padding: 4px 6px; font: inherit; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--accent); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 550; }
.form-grid { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-weight: 500; }

/* ---------- Layout */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 10px 16px 0;
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px 16px; align-items: center;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand img { width: 28px; height: 28px; }
.status-pill {
  justify-self: end; display: inline-flex; align-items: center; gap: 7px;
  font-size: .8rem; color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.error { background: var(--error); }
.dot.info { background: var(--info); }
.nav {
  grid-column: 1 / -1; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 9px 12px; color: var(--muted); text-decoration: none; font-weight: 550; font-size: .92rem;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); border-bottom-color: var(--accent); }
.nav .badge { margin-left: 4px; }
main.content { max-width: 1440px; margin: 0 auto; padding: 20px 16px 60px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h1 { font-size: 1.35rem; margin-right: auto; }
.toolbar input[type="search"] { width: 220px; }
.toolbar select { width: auto; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card > h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card > h2 .spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.stack { display: grid; gap: 16px; }
.section { align-content: start; gap: 12px; }
.section-title { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 2px; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; font-size: .92rem; }

.badge {
  display: inline-block; font-size: .72rem; font-weight: 650; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); vertical-align: middle; white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.error { background: var(--error-soft); color: var(--error); }
.badge.info { background: var(--info-soft); color: var(--info); }
.tag { font-size: .75rem; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 0 6px; }

/* ---------- Übersicht */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .num { font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: .82rem; font-weight: 550; }
.stat.warn .num { color: var(--warn); }
.stat.error .num { color: var(--error); }

.widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.widget { position: relative; padding: 14px 16px 12px 18px; overflow: hidden; }
.widget::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--info); }
.widget.ok::before { background: var(--ok); }
.widget.warn::before { background: var(--warn); }
.widget.error::before { background: var(--error); }
.widget .w-label { color: var(--muted); font-size: .8rem; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.widget .w-value { font-size: 1.35rem; font-weight: 700; margin: 2px 0; word-break: break-word; }
.widget .w-unit { font-size: .85rem; color: var(--muted); font-weight: 500; margin-left: 3px; }
.widget .w-meta { color: var(--muted); font-size: .74rem; }
.widget .icon-btn { position: absolute; top: 6px; right: 6px; opacity: 0; }
.widget:hover .icon-btn { opacity: 1; }

.list { display: grid; }
.row {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px;
  border-top: 1px solid var(--border);
}
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; }
.row .title.link { cursor: pointer; }
.row .title.link:hover { color: var(--accent); }
.row .sub { color: var(--muted); font-size: .8rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.done .title { text-decoration: line-through; color: var(--muted); }
.prio { width: 9px; height: 9px; border-radius: 3px; flex: none; background: var(--border); }
.prio.p1 { background: var(--error); }
.prio.p2 { background: var(--info); }
.prio.p3 { background: var(--muted); opacity: .5; }
.due.overdue { color: var(--error); font-weight: 650; }
.due.today { color: var(--warn); font-weight: 650; }

/* ---------- Kanban */
.board {
  display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 14px;
  overflow-x: auto; padding-bottom: 8px; align-items: start;
}
.column {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; min-height: 160px; display: flex; flex-direction: column; gap: 8px;
}
.column.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 4px; font-weight: 650; }
.column-head .count { color: var(--muted); font-weight: 550; font-size: .85rem; }
.column-head .icon-btn { margin-left: auto; font-size: 1.1rem; }
.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; box-shadow: var(--shadow); cursor: grab; user-select: none;
}
.kcard:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.kcard.dragging { opacity: .4; }
.kcard .k-title { font-weight: 550; display: flex; gap: 8px; align-items: baseline; }
.kcard .k-title .prio { position: relative; top: 1px; }
.kcard .k-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: .78rem; color: var(--muted); }
.kcard .k-desc { color: var(--muted); font-size: .82rem; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.drop-marker { height: 3px; background: var(--accent); border-radius: 2px; }
.kcard .k-move { display: none; gap: 4px; margin-top: 8px; }
@media (hover: none) { .kcard .k-move { display: flex; } }

/* ---------- Notizen */
.note { padding: 14px 16px; border-left: 4px solid transparent; }
.note.unread { border-left-color: var(--accent); }
.note.alert.unread { border-left-color: var(--error); }
.note-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note-head h3 { font-size: 1rem; }
.note-head .actions { margin-left: auto; display: flex; gap: 2px; }
.note .meta { color: var(--muted); font-size: .78rem; }
.md { margin-top: 8px; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre { margin: .5em 0; }
.md h3, .md h4, .md h5, .md h6 { margin: .8em 0 .3em; font-size: 1rem; }
.md pre { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.md code { background: var(--surface-2); border-radius: 4px; padding: 1px 4px; }
.md pre code { background: none; padding: 0; }
.md ul, .md ol { padding-left: 1.4em; }
.composer { display: grid; gap: 10px; }
.composer .inline select { width: auto; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button {
  border: 0; background: var(--surface); color: var(--muted); padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer;
  border-left: 1px solid var(--border);
}
.segmented button:first-child { border-left: 0; }
.segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

/* ---------- Dateien */
.crumbs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-weight: 550; }
.crumbs a { text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--surface-2); }
.crumbs span { color: var(--muted); }
.ficon { width: 20px; height: 20px; flex: none; color: var(--muted); }
.ficon.folder { color: var(--accent); }
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center;
  color: var(--muted); margin-bottom: 16px; transition: border-color .15s, background .15s;
}
.dropzone.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.uploads { display: grid; gap: 6px; margin-bottom: 12px; }
.upload { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: .85rem; }
.bar { grid-column: 1 / -1; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload.error .bar > div { background: var(--error); }
.upload.done .bar > div { background: var(--ok); }

/* ---------- Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.files-table td:first-child, .files-table th:first-child { width: 36px; padding-right: 0; }
.files-table td:nth-child(2) { word-break: break-all; }

/* ---------- Modal & Toast */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 45%);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px;
}
.modal h2 { margin-bottom: 14px; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; align-items: center; }
.modal-actions .spacer { flex: 1; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--info);
  border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow-lg); font-size: .9rem;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--error); }
.secret {
  font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; word-break: break-all; user-select: all;
}
.banner {
  border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: .9rem;
  background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}

/* ---------- Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px;
}
.login-card form { display: grid; gap: 14px; margin-top: 18px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand h1 { font-size: 1.3rem; }
.login-error { color: var(--error); background: var(--error-soft); border-radius: 8px; padding: 8px 12px; margin: 16px 0 0; font-size: .9rem; }
.login-hint { color: var(--muted); font-size: .9rem; margin: 14px 0 0; }

@media (max-width: 720px) {
  .topbar-inner { grid-template-columns: 1fr auto auto; gap: 8px; }
  .status-pill .status-text { display: none; }
  .toolbar input[type="search"] { width: 100%; }
  .board { grid-template-columns: repeat(4, minmax(78vw, 1fr)); scroll-snap-type: x mandatory; }
  .column { scroll-snap-align: start; }
  .hide-sm { display: none; }
}
