/* Zentrale – Basis-Styles. Neutral, ruhig, Brand-Farben als Akzent. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e4e7ec;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #8a94a6;
  --primary: #111827;
  --primary-text: #ffffff;
  --accent: #2563eb;
  --ok: #15803d;
  --ok-bg: #e8f6ee;
  --warn: #b45309;
  --warn-bg: #fdf3e2;
  --err: #b91c1c;
  --err-bg: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1f2630;
    --border: #2a313c;
    --text: #e6e9ee;
    --text-2: #b4bcc8;
    --muted: #7d8796;
    --primary: #e6e9ee;
    --primary-text: #0d1117;
    --accent: #60a5fa;
    --ok: #4ade80; --ok-bg: #12301f;
    --warn: #fbbf24; --warn-bg: #33270d;
    --err: #f87171; --err-bg: #3a1616;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0 0 .75em; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.i { flex-shrink: 0; vertical-align: -3px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 18px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px; }
.logo.center { justify-content: center; margin-bottom: 20px; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: var(--primary-text); display: grid; place-items: center; font-size: 14px; }
.sidebar nav, .side-foot, .side-brands { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a, .side-foot a, .side-brands a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.sidebar nav a:hover, .side-foot a:hover, .side-brands a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.active, .side-foot a.active { background: var(--surface-2); color: var(--text); }
.sidebar .count { margin-left: auto; font-style: normal; font-size: 11px; background: var(--err); color: #fff; border-radius: 10px; padding: 0 7px; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 10px 4px; }
.side-brands a { font-size: 13px; padding: 6px 10px; }
.side-foot { margin-top: auto; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 0 12px; color: var(--muted); }
.search input { border: 0; background: transparent; padding: 9px 0; width: 100%; box-shadow: none; }
.search input:focus { outline: none; box-shadow: none; }
.me { margin-left: auto; }
.content { padding: 24px; max-width: 1400px; width: 100%; }
.tabbar { display: none; }

/* ---------- Menüs ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; display: flex; flex-direction: column; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; background: none; border: 0; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Buttons & Formulare ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { opacity: .9; color: var(--primary-text); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type=checkbox] { width: auto; accent-color: var(--primary); }
input[type=color] { padding: 2px; height: 36px; width: 48px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }
.form-actions { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-top: 6px; }

/* ---------- Karten & Layout ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > h2, .card > h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2, .card.flush > h3 { padding: 14px 16px 0; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols.even { grid-template-columns: 1fr 1fr; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.stat .value.err { color: var(--err); }
.stat .hint { font-size: 12px; color: var(--muted); }

.dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td a.strong { font-weight: 600; }

/* ---------- Badges ---------- */
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.st-lead { background: #e0ecff; color: #1d4ed8; }
.pill.st-kunde { background: var(--ok-bg); color: var(--ok); }
.pill.st-inaktiv { background: var(--surface-2); color: var(--muted); }
.pill.ts-in_arbeit { background: #e0ecff; color: #1d4ed8; }
.pill.ts-warten { background: var(--warn-bg); color: var(--warn); }
.pill.won { background: var(--ok-bg); color: var(--ok); }
.pill.lost { background: var(--err-bg); color: var(--err); }
@media (prefers-color-scheme: dark) { .pill.st-lead, .pill.ts-in_arbeit { background: #172a4a; color: #93c5fd; } }
.brand { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); white-space: nowrap; }
.brand::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.avatar { --c: #64748b; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: #fff; font-size: 11.5px; font-weight: 700; flex-shrink: 0; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.empty { background: var(--surface-2); color: var(--muted); }

/* ---------- Flash ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 500; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tabs a.active { border-color: var(--primary); color: var(--text); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a { padding: 6px 12px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.seg a.active { background: var(--surface-2); color: var(--text); }

/* ---------- Aufgaben ---------- */
.task-list { display: flex; flex-direction: column; }
.task-group { margin-bottom: 4px; }
.task-group h4 { margin: 14px 16px 4px; display: flex; gap: 8px; align-items: center; }
.task-group h4.overdue { color: var(--err); }
.task { display: flex; align-items: flex-start; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task:hover { background: var(--surface-2); }
.cb { width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--muted); background: transparent; color: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; flex-shrink: 0; transition: .15s; }
.cb:hover { border-color: var(--ok); color: var(--ok); }
.task.done .cb { background: var(--ok); border-color: var(--ok); color: #fff; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 500; display: block; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.task-meta .ctx a { color: var(--text-2); }
.task-meta .ctx a:hover { color: var(--accent); }
.task-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.due { font-size: 12px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.due.overdue { color: var(--err); }
.due.today { color: var(--warn); }
.prio-high { color: var(--err); font-weight: 600; }
.quick-task { display: grid; grid-template-columns: 1fr 150px 160px auto; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }

/* ---------- Kanban ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; scroll-snap-type: x mandatory; }
.col { flex: 0 0 272px; background: var(--surface-2); border-radius: var(--radius); padding: 10px; scroll-snap-align: start; max-height: calc(100vh - 210px); display: flex; flex-direction: column; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 10px; gap: 8px; }
.col-head strong { font-size: 13px; }
.col-head .muted { font-size: 12px; }
.col-body { display: flex; flex-direction: column; gap: 8px; min-height: 60px; overflow-y: auto; border-radius: 8px; transition: background .15s; }
.col-body.over { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.col.won .col-head strong { color: var(--ok); }
.col.lost .col-head strong { color: var(--err); }
.kcard { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--c, var(--border)); border-radius: 8px; padding: 10px 12px; box-shadow: var(--shadow); cursor: grab; }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .4; }
.kcard .k-title { font-weight: 600; display: block; margin-bottom: 2px; overflow-wrap: anywhere; }
.kcard .k-sub { font-size: 12.5px; color: var(--text-2); }
.kcard .k-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); gap: 6px; }
.kcard .k-value { font-weight: 700; color: var(--text); }
.kcard .k-move { display: none; margin-top: 8px; font-size: 12px; padding: 4px 6px; }
@media (hover: none) { .kcard .k-move { display: block; } .kcard { cursor: default; } }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: 0; }
.tl-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); flex-shrink: 0; }
.tl-item.system .tl-icon { color: var(--muted); }
.tl-body { flex: 1; min-width: 0; }
.tl-body .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-item.system .txt { color: var(--text-2); font-size: 13px; }
.tl-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.tl-meta form { margin-left: auto; }
.activity-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.activity-form .row { display: flex; gap: 8px; }
.activity-form .row select { width: auto; }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; display: block; overflow-wrap: anywhere; }
.list-item .sub { font-size: 12.5px; color: var(--muted); }
.progress { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); }
.brand-bars { display: flex; flex-direction: column; gap: 10px; }
.brand-bar { display: grid; grid-template-columns: 140px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.brand-bar .bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.brand-bar .bar span { display: block; height: 100%; background: var(--c); border-radius: 4px; }

.contact-links { display: flex; gap: 6px; flex-wrap: wrap; }
.contact-links a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

.win-box { border: 1px solid var(--ok); background: var(--ok-bg); border-radius: var(--radius); padding: 16px; }

/* ---------- Auth ---------- */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow-lg); }
.auth-card.wide { max-width: 560px; }
.checks { list-style: none; padding: 0; margin: 0 0 16px; font-size: 13px; }
.checks .ok { color: var(--ok); } .checks .bad { color: var(--err); font-weight: 600; }
.code-input { font-size: 26px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.qr { background: #fff; padding: 12px; border-radius: 10px; display: inline-block; }
.qr svg, .qr img { display: block; }

/* ---------- Mobil ---------- */
.hide-lg { display: none; }
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .content { padding: 16px 14px calc(90px + env(safe-area-inset-bottom)); }
  .hide-sm { display: none; }
  .hide-lg { display: initial; }
  .filters.hide-lg { display: flex; }
  .cols.even, .grid2, .grid3 { grid-template-columns: 1fr; }
  .quick-task { grid-template-columns: 1fr 1fr; }
  .quick-task input[name=title] { grid-column: 1 / -1; }
  .quick-task .btn { grid-column: 1 / -1; }
  .col { flex-basis: 84vw; max-height: none; }
  .board { margin: 0 -14px; padding: 0 14px 12px; }
  .brand-bar { grid-template-columns: 100px 1fr 70px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: center; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); flex: 1; padding: 4px 0; }
  .tabbar a.active { color: var(--text); }
  .tabbar .tab-plus { flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: var(--primary-text); justify-content: center; margin-top: -18px; box-shadow: var(--shadow-lg); }
  th, td { padding: 9px 10px; }
  .table-wrap .opt { display: none; }
  .task { padding: 11px 14px; }
  .cb { width: 24px; height: 24px; }
  input, select, textarea { font-size: 16px; } /* verhindert iOS-Zoom */
}
