:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --sunken: #eceae4;
  --ink: #1d1c1a;
  --muted: #6d6a63;
  --line: #e1ded6;
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --warn: #9a6400;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 8px 24px rgb(0 0 0 / 6%);
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1d1d1a;
    --sunken: #25241f;
    --ink: #eceae4;
    --muted: #9c988f;
    --line: #302f2a;
    --accent: #53c1ab;
    --accent-ink: #0b211d;
    --danger: #f2877f;
    --warn: #e0ad4f;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 35%);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* Anmeldung */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(400px, 100%);
  display: grid; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); box-shadow: 6px 6px 0 -2px color-mix(in srgb, var(--accent) 35%, transparent); }

/* Rahmen */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 12px; border-right: 1px solid var(--line); background: var(--surface);
}
.side .brand { padding: 0 8px; }
.nav, .nav-group { display: grid; gap: 2px; }
.nav-group { flex: 1; align-content: start; }
.nav-title { padding: 0 8px 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.nav-empty { padding: 0 8px; color: var(--muted); font-size: 14px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 7px; color: var(--muted); }
.nav-link:hover { background: var(--sunken); color: var(--ink); }
.nav-link.is-active { background: var(--sunken); color: var(--ink); font-weight: 600; }
.nav-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 3px; }
.side-user { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.side-user-name { display: grid; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.side-user-name small { font-weight: 400; color: var(--muted); }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--muted); cursor: pointer; text-align: left; }
.link-btn:hover { color: var(--ink); text-decoration: underline; }

.main { padding: 28px 32px 64px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.project-desc { max-width: 70ch; margin-bottom: 20px; color: var(--muted); white-space: pre-wrap; }

/* Bedienelemente */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-small { padding: 4px 10px; font-size: 13px; }
.icon-btn { width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--sunken); color: var(--ink); }

.tabs { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--sunken); }
.tab { border: 0; background: none; padding: 5px 14px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 550; }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 12%); }

.avatar {
  flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); font-size: 12px; font-weight: 700;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

.badge, .tag, .prio { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 4px; font-size: 12px; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.badge { background: var(--sunken); color: var(--muted); }
.tag { background: var(--tag); color: #fff; }
.st-in_arbeit, .ps-aktiv { background: color-mix(in srgb, #2f5fb3 15%, var(--surface)); color: color-mix(in srgb, #2f5fb3 65%, var(--ink)); }
.st-review, .ps-pausiert { background: color-mix(in srgb, #a37a12 18%, var(--surface)); color: color-mix(in srgb, #a37a12 65%, var(--ink)); }
.st-erledigt, .ps-abgeschlossen { background: color-mix(in srgb, #4f7a28 18%, var(--surface)); color: color-mix(in srgb, #4f7a28 65%, var(--ink)); }
.st-dot { width: 9px; height: 9px; padding: 0; border-radius: 50%; }
.st-dot.st-offen { background: var(--muted); }
.st-dot.st-in_arbeit { background: #2f5fb3; }
.st-dot.st-review { background: #a37a12; }
.st-dot.st-erledigt { background: #4f7a28; }
.prio { padding: 0; color: var(--muted); }
.prio-hoch { color: var(--warn); }
.prio-dringend { color: var(--danger); }
.due { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.due.today { color: var(--warn); font-weight: 600; }
.due.overdue { color: var(--danger); font-weight: 600; }
.count { color: var(--muted); font-weight: 500; font-size: 13px; }

/* Projektkarten */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  display: grid; gap: 12px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--tag); border-radius: var(--radius);
}
.card:hover { box-shadow: var(--shadow); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card h3 { font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
.card-desc { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.bar { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 3px; }
.card-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }

/* Board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 14px; min-height: 60vh; overflow-x: auto; padding-bottom: 8px; }
.col { display: grid; gap: 8px; align-content: start; padding: 10px; background: var(--sunken); border-radius: var(--radius); outline: 2px solid transparent; }
.col.is-over { outline-color: var(--accent); }
.col-title { display: flex; align-items: center; gap: 8px; margin: -10px -10px 2px; padding: 8px 8px 8px 12px; border-radius: var(--radius) var(--radius) 0 0; color: #fff; }
.col-title h2 { font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.col-count { font-size: 12px; font-weight: 600; padding: 0 7px; border-radius: 999px; background: rgb(255 255 255 / 25%); }
.col-edit { flex: none; width: 26px; height: 24px; border: 0; border-radius: 6px; background: none; color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.col-edit:hover, .col-edit:focus-visible { background: rgb(255 255 255 / 25%); }
.col-new { align-self: start; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--radius); background: none; color: var(--muted); cursor: pointer; text-align: left; font-weight: 550; }
.col-new:hover { border-color: var(--muted); color: var(--ink); }
.col-cards { display: grid; gap: 8px; min-height: 36px; align-content: start; }
.task {
  display: grid; gap: 8px; padding: 10px 12px; cursor: grab;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.task:hover { border-color: var(--muted); }
.task.is-dragging { opacity: 0.35; }
.task.is-done .task-title { color: var(--muted); text-decoration: line-through; }
.task-title { font-weight: 550; overflow-wrap: anywhere; }
.task-meta { display: flex; align-items: center; gap: 8px; min-height: 24px; font-size: 12px; white-space: nowrap; }
.task-meta:not(:has(> :not(.spacer))) { display: none; }
.quick-add { width: 100%; padding: 7px 10px; border: 1px dashed var(--line); border-radius: 8px; background: none; color: var(--muted); text-align: left; cursor: pointer; }
.quick-add:hover { border-color: var(--muted); color: var(--ink); background: var(--surface); }
.quick-form { display: grid; gap: 8px; }
.quick-actions { display: flex; gap: 6px; }

/* Listen */
.group { margin-bottom: 24px; }
.group-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; font-weight: 650; }
.list-tools { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-title { flex: 1; min-width: 0; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; font-weight: 550; overflow-wrap: anywhere; }
.row-title:hover { color: var(--accent); }
.row-static { cursor: default; }
.row-static:hover { color: inherit; }
.row-who { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.row.is-done .row-title { color: var(--muted); text-decoration: line-through; }
.row.is-done .avatar { opacity: 0.5; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; flex: none; margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }

.empty { display: grid; gap: 6px; justify-items: center; padding: 56px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h2 { font-size: 16px; color: var(--ink); }

/* Formulare und Dialoge */
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; }
.field-hint { font-size: 12px; color: var(--muted); }
input:not([type="checkbox"], [type="radio"]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 0; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.form-error { color: var(--danger); font-size: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches label { position: relative; cursor: pointer; }
.swatches input { position: absolute; opacity: 0; }
.swatch { display: block; width: 26px; height: 26px; border-radius: 7px; }
.swatches input:checked + .swatch { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatches input:focus-visible + .swatch { outline: 2px solid var(--accent); outline-offset: 2px; }

.dlg {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 22px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.dlg-wide { width: min(620px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgb(0 0 0 / 45%); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.dlg-head h2 { font-size: 18px; font-weight: 650; }

.comment-box { display: grid; gap: 12px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.comment-box h3 { font-size: 14px; font-weight: 650; }
.comments { display: grid; gap: 12px; }
.comment { display: grid; gap: 2px; }
.comment-head { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.comment p { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: grid; gap: 8px; justify-items: end; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 10; }
.toast { padding: 10px 14px; border-radius: 9px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); max-width: 340px; }
.toast-error { background: var(--danger); color: #fff; }

@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: flex; }
  .nav-group { display: none; }
  .side-user { border-top: 0; padding: 0; grid-template-columns: repeat(4, auto); margin-left: auto; }
  .side-user-name { display: none; }
  .main { padding: 20px 16px 48px; }
  .form-row { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .row-title { flex-basis: 60%; }
}

/* Tags und eigene Felder */
.task-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.row .tag { flex: none; }
.tag-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag-btn { border: 1px solid transparent; cursor: pointer; opacity: 0.45; }
.tag-btn:hover { opacity: 0.85; }
.tag-btn.is-on { opacity: 1; }
.tag-btn.is-on::before { content: "✓"; margin-right: 4px; }
input.tag-new { width: 130px; padding: 3px 8px; border-style: dashed; border-radius: 4px; font-size: 13px; }
.custom-fields { padding-top: 14px; border-top: 1px solid var(--line); }
.manage { display: grid; gap: 10px; }
.manage-row { display: flex; align-items: center; gap: 8px; }
.manage-row input { flex: 1; min-width: 0; }
.manage-add { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.manage-add h3 { font-size: 14px; font-weight: 650; }
[hidden] { display: none !important; }
@media (max-width: 800px) {
  .manage-row { flex-wrap: wrap; }
}

/* Tag-Farben und Anzeige-Auswahl */
.color-pick { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.color-dot { width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; }
.color-dot.is-on { outline: 2px solid var(--ink); outline-offset: 2px; }
.tag-create { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
.tag-row { flex-wrap: wrap; }
.tag-row input { flex: 1 1 140px; }
.tag-create input.tag-new { border-style: solid; }
.task-desc { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.task-custom { display: grid; gap: 2px; font-size: 12px; }
.cf { overflow-wrap: anywhere; }
.row .cf { font-size: 13px; }
.check-list { display: grid; gap: 10px; }

/* CRM */
.list-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
input.search { flex: 1 1 240px; max-width: 380px; }
.row-link:hover { background: var(--sunken); }
.cs-kunde { background: color-mix(in srgb, #4f7a28 18%, var(--surface)); color: color-mix(in srgb, #4f7a28 65%, var(--ink)); }
.cs-interessent { background: color-mix(in srgb, #2f5fb3 15%, var(--surface)); color: color-mix(in srgb, #2f5fb3 65%, var(--ink)); }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); font-size: 14px; }
.back:hover { color: var(--ink); }
.detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.panel { display: grid; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel h2 { font-size: 15px; font-weight: 650; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.panel a:not(.contact) { color: var(--accent); }
.panel a:not(.contact):hover { text-decoration: underline; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.info dt { color: var(--muted); font-size: 13px; }
.info dd { margin: 0; overflow-wrap: anywhere; }
.contact { display: flex; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.contact-body { flex: 1; min-width: 0; display: grid; gap: 1px; overflow-wrap: anywhere; }
.contact-links { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
a.contact:hover strong { color: var(--accent); }
.project-customer { margin-bottom: 8px; color: var(--muted); }
.project-customer a { color: var(--accent); }
.project-customer a:hover { text-decoration: underline; }
.card-customer { font-size: 13px; font-weight: 600; }

.tabs-wrap { flex-wrap: wrap; }

select.filter-select { width: auto; flex: 0 1 220px; }

/* Zeiterfassung */
.timer { display: grid; gap: 6px; padding: 0 8px; }
.timer-btn { justify-self: start; }
.timer.is-running { padding: 10px; margin: 0 4px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line)); border-radius: 9px; background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.timer-head { display: flex; align-items: center; gap: 8px; }
.timer-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .timer-dot { animation: none; } }
.timer-clock { font-weight: 650; font-variant-numeric: tabular-nums; }
.timer-what { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.timer-what:hover { color: var(--ink); }
.entry-time { min-width: 52px; font-weight: 650; font-variant-numeric: tabular-nums; }
.entry-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.entry-task { margin-left: 8px; font-weight: 550; overflow-wrap: anywhere; }
.entry-note { font-size: 13px; overflow-wrap: anywhere; }
.badge-live { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: grid; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.group-panel { margin-bottom: 24px; }
.group-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; align-items: center; gap: 12px; }
.group-name { overflow-wrap: anywhere; }
input.filter-date { width: auto; }
.time-hint { margin: -4px 0 12px; font-size: 13px; }
@media (max-width: 800px) {
  .timer { order: 3; padding: 0; }
  .group-row { grid-template-columns: 1fr auto; }
  .group-row .bar { display: none; }
}

.timer.is-paused { padding: 10px; margin: 0 4px; border: 1px solid var(--line); border-radius: 9px; background: var(--sunken); }
.timer.is-paused .timer-dot { background: var(--muted); animation: none; }
.timer-state { font-size: 12px; font-weight: 600; color: var(--muted); }
.timer-total { font-size: 12px; color: var(--muted); }
.timer-sum { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.timer-last { padding: 4px 0; border: 0; background: none; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.timer-last:hover { color: var(--accent); }
.timer-head .btn-small { min-width: 30px; }

/* Mitglieder und Zuständige */
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.members-btn { gap: 8px; }
.member-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.person-btn { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 13px; opacity: 0.6; }
.person-btn:hover { opacity: 0.9; }
.person-btn.is-on { opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); font-weight: 600; }
