/* AgencyFlow – App-Styles */

:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --ink: #14182B;
  --ink-2: #3B4157;
  --muted: #6B7088;
  --faint: #9A9FB2;
  --line: #E4E6EC;
  --line-2: #EEF0F4;
  --accent: #2F54EB;
  --accent-hover: #2445D4;
  --accent-soft: #EBF0FF;
  --accent-ink: #1D3AB8;
  --signal: #FFC94D;
  --signal-soft: #FFF6DC;
  --green: #12805C;
  --green-soft: #E4F5EE;
  --amber: #9A5800;
  --amber-soft: #FFF2D9;
  --red: #C4314B;
  --red-soft: #FDECEF;
  --side: #14182B;
  --side-2: #1E2338;
  --side-text: #B6BBD0;

  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif;

  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 24, 43, .04), 0 2px 8px rgba(20, 24, 43, .04);
  --shadow-pop: 0 12px 40px rgba(20, 24, 43, .16), 0 2px 6px rgba(20, 24, 43, .06);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { font-family: var(--display); color: var(--ink); margin: 0; line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
p { margin: 0 0 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- App-Gerüst ---------- */

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side);
  color: var(--side-text);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand:hover { color: #fff; }
.brand-mark { width: 26px; height: 26px; flex-shrink: 0; }
.agency-switch { display: flex; align-items: center; gap: 10px; padding: 10px; margin: 0 0 14px; border-radius: var(--r-md); background: var(--side-2); color: #fff; }
.agency-switch .meta { min-width: 0; }
.agency-switch strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agency-switch span { font-size: 12px; color: var(--side-text); }
.nav-label { font-size: 12px; color: #6E7491; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--side-text); font-weight: 500; font-size: 14.5px;
  position: relative;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.nav a.active { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .count { margin-left: auto; font-size: 12px; background: var(--signal); color: var(--ink); border-radius: 20px; padding: 0 7px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .07); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: #fff; border-radius: var(--r-sm); }
.user-chip:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.user-chip .meta { min-width: 0; flex: 1; }
.user-chip strong { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip span { font-size: 12px; color: var(--side-text); }
.logout-btn { background: none; border: 0; color: var(--side-text); cursor: pointer; padding: 6px; border-radius: 6px; display: flex; }
.logout-btn:hover { color: #fff; background: rgba(255, 255, 255, .08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 32px 40px 64px; max-width: 1240px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.crumb:hover { color: var(--ink); }

.impersonation-bar { background: var(--signal); color: var(--ink); padding: 8px 40px; font-size: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.impersonation-bar button { background: var(--ink); color: #fff; border: 0; border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: 13px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-md);
  font: inherit; font-weight: 600; font-size: 14.5px; line-height: 1;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, .2) inset, 0 1px 2px rgba(47, 84, 235, .3); }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.btn-secondary:hover { border-color: #CDD1DB; color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--red); border-color: #F3C9D1; }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #262B45; color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13.5px; border-radius: var(--r-sm); gap: 6px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.inline-form { display: inline; margin: 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.link-btn:hover { color: var(--accent-hover); }
.link-danger { color: var(--red); }

/* ---------- Karten & Flächen ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 22px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line-2); }
.card-head h2 { font-size: 16px; }
.card-head .hint { color: var(--muted); font-size: 13.5px; }
.card-body { padding: 20px 24px; }
.card-foot { padding: 14px 24px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13.5px; }
.tiny { font-size: 12.5px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.pre { white-space: pre-line; }

/* ---------- Kennzahlen ---------- */

.stat { padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; }
.stat .label { color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.stat .value { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 13px; color: var(--muted); }
.stat .foot.bad { color: var(--red); }
.stat-hero { background: var(--ink); border-color: var(--ink); color: #fff; }
.stat-hero .label { color: #A9AECA; }
.stat-hero .value { color: #fff; }
.stat-hero .foot { color: #A9AECA; }

/* ---------- Badges ---------- */

.badge { display: inline-flex; align-items: center; gap: 5px; height: 23px; padding: 0 9px; border-radius: 20px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-neutral { background: var(--line-2); color: var(--ink-2); }
.badge-blue { background: var(--accent-soft); color: var(--accent-ink); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-muted { background: var(--line-2); color: var(--faint); text-decoration: line-through; }
.badge-plain::before { display: none; }

/* ---------- Tabellen ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table th:first-child { padding-left: 24px; }
.table th:last-child { padding-right: 24px; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table td:first-child { padding-left: 24px; }
.table td:last-child { padding-right: 24px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: #FAFBFD; }
.table .title-cell a { color: var(--ink); font-weight: 600; }
.table .title-cell a:hover { color: var(--accent); }
.table .title-cell .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--r-lg); }

/* ---------- Formulare ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 14px; font-weight: 600; color: var(--ink); }
.field .help { font-size: 13px; color: var(--muted); }
.field .error { font-size: 13px; color: var(--red); }
.input, .select, .textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid #D9DCE4; border-radius: var(--r-md);
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
.input, .select { height: 42px; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 84, 235, .15); }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--red); }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236B7088' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; border: 1px solid #D9DCE4; border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--surface-2); color: var(--muted); font-size: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.check .help { display: block; font-size: 13px; color: var(--muted); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 8px; flex-wrap: wrap; }
.form-section { padding: 24px; border-bottom: 1px solid var(--line-2); }
.form-section:last-child { border-bottom: 0; }
.form-section > h2 { font-size: 16px; margin-bottom: 4px; }
.form-section > .sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=file] { font: inherit; font-size: 14px; }

.segmented { display: inline-flex; background: var(--line-2); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 6px 12px; font-size: 13.5px; border-radius: var(--r-sm); cursor: pointer; color: var(--ink-2); font-weight: 500; }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

/* ---------- Filter / Tabs ---------- */

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.pills { display: flex; gap: 4px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 20px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.pill:hover { background: var(--line-2); color: var(--ink); }
.pill.active { background: var(--ink); color: #fff; }
.pill .n { font-size: 12px; opacity: .65; }
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search .input { padding-left: 38px; width: 260px; height: 38px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-color: var(--ink); font-weight: 600; }
.tabs .n { font-size: 12px; background: var(--line-2); border-radius: 10px; padding: 0 7px; color: var(--ink-2); }

/* ---------- Fortschritt ---------- */

.progress { height: 6px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.progress.done > span { background: var(--green); }
.progress.over > span { background: var(--red); }
.progress-lg { height: 10px; }

/* Projekt-Fluss: die markante Status-Leiste */
.flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.flow-step { position: relative; padding-top: 14px; font-size: 13px; color: var(--faint); }
.flow-step::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px; border-radius: 5px; background: var(--line-2); }
.flow-step.done { color: var(--ink-2); }
.flow-step.done::before { background: var(--accent); }
.flow-step.now { color: var(--ink); font-weight: 600; }
.flow-step.now::before { background: linear-gradient(90deg, var(--accent) 0 50%, var(--signal) 50%); }

/* ---------- Avatare ---------- */

.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; letter-spacing: .02em; }
.avatar-sm { width: 28px; height: 28px; font-size: 11.5px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-sq { border-radius: 9px; }

/* ---------- Listen ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 14px 24px; border-bottom: 1px solid var(--line-2); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--ink); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta { font-size: 13px; color: var(--muted); }
.list a.title:hover { color: var(--accent); }

.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; font-size: 14.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Aktivitäts-Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 22px; font-size: 14px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline li::after { content: ''; position: absolute; left: 7px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { display: block; font-size: 12.5px; color: var(--faint); }

/* Updates-Feed */
.update { padding: 18px 24px; border-bottom: 1px solid var(--line-2); }
.update:last-child { border-bottom: 0; }
.update-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.update-head .who { font-weight: 600; font-size: 14px; }
.update-head .when { font-size: 13px; color: var(--muted); }
.update-body { white-space: pre-line; color: var(--ink-2); padding-left: 38px; }
.update-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ---------- Dateien & Dropzone ---------- */

.file-row { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line-2); }
.file-row:last-child { border-bottom: 0; }
.file-ico { width: 38px; height: 38px; border-radius: 9px; background: var(--line-2); color: var(--ink-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-ico.image { background: #EAF6FF; color: #0B6BB5; }
.file-ico.pdf { background: var(--red-soft); color: var(--red); }
.file-ico.archive { background: var(--amber-soft); color: var(--amber); }
.file-ico.media { background: #F1ECFF; color: #6B3FD4; }
.file-row .grow { flex: 1; min-width: 0; }
.file-row .name { font-weight: 600; color: var(--ink); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .name:hover { color: var(--accent); }
.file-row .meta { font-size: 13px; color: var(--muted); }
.from-client { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--amber); background: var(--signal-soft); padding: 1px 7px; border-radius: 10px; }

.dropzone {
  position: relative; border: 2px dashed #CBD0DC; border-radius: var(--r-lg);
  background: var(--surface-2); padding: 34px 24px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); border-style: solid; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone .dz-icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px; background: var(--signal); color: var(--ink); display: flex; align-items: center; justify-content: center; }
.dropzone .dz-title { font-family: var(--display); font-weight: 650; font-size: 17px; color: var(--ink); }
.dropzone .dz-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.dz-queue { list-style: none; margin: 14px 0 0; padding: 0; text-align: left; }
.dz-queue li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 6px; font-size: 14px; }
.dz-queue .bar { flex: 0 0 120px; height: 5px; background: var(--line-2); border-radius: 5px; overflow: hidden; }
.dz-queue .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.dz-queue .ok { color: var(--green); }
.dz-queue .err { color: var(--red); }
.dz-queue .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.request { display: flex; gap: 12px; align-items: flex-start; padding: 14px 24px; border-bottom: 1px solid var(--line-2); }
.request:last-child { border-bottom: 0; }
.request .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #CBD0DC; display: flex; align-items: center; justify-content: center; background: none; cursor: pointer; padding: 0; color: transparent; flex-shrink: 0; margin-top: 1px; }
.request .tick:hover { border-color: var(--green); }
.request.done .tick { background: var(--green); border-color: var(--green); color: #fff; }
.request.done .r-title { color: var(--muted); text-decoration: line-through; }
.request .grow { flex: 1; min-width: 0; }
.request .r-title { font-weight: 600; }
.request .r-desc { font-size: 14px; color: var(--muted); }

/* ---------- Leere Zustände ---------- */

.empty { text-align: center; padding: 48px 24px; }
.empty .e-icon { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.empty h3 { font-size: 17px; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 400px; margin: 0 auto 18px; }
.empty-sm { padding: 28px 24px; }
.empty-sm p { margin-bottom: 0; font-size: 14px; }

/* ---------- Meldungen ---------- */

.flashes { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--ink); color: #fff; box-shadow: var(--shadow-pop); font-size: 14.5px; animation: flash-in .25s ease-out; }
.flash .icon { margin-top: 2px; }
.flash-success .icon { color: #6EE7B7; }
.flash-error { background: #fff; color: var(--ink); border: 1px solid #F3C9D1; }
.flash-error .icon { color: var(--red); }
.flash button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 0; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-ink); font-size: 14.5px; }
.notice-warn { background: var(--signal-soft); color: #6B4500; }
.notice-danger { background: var(--red-soft); color: var(--red); }
.notice .icon { margin-top: 2px; }
.notice > div { flex: 1; }
.alert { padding: 12px 14px; border-radius: var(--r-md); font-size: 14.5px; margin-bottom: 16px; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-success { background: var(--green-soft); color: var(--green); }

/* ---------- Dialoge ---------- */

dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); width: min(520px, calc(100vw - 32px)); color: var(--ink); }
dialog.modal::backdrop { background: rgba(20, 24, 43, .45); }
dialog.modal[open] { animation: flash-in .2s ease-out; }
.modal-head { padding: 20px 24px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 16px 24px; }
.modal-foot { padding: 14px 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

.menu { position: relative; display: inline-block; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 6px; z-index: 30; display: none; }
.menu.open .menu-list { display: block; }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 6px; background: none; border: 0; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; text-align: left; }
.menu-list a:hover, .menu-list button:hover { background: var(--line-2); }
.menu-list .danger { color: var(--red); }
.menu-list hr { margin: 6px 0; }

/* ---------- Projektkarten ---------- */

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.project-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.project-card:hover { border-color: #C9CEDA; color: var(--ink); box-shadow: 0 4px 16px rgba(20, 24, 43, .07); }
.project-card .pc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.project-card h3 { font-size: 17px; }
.project-card .client { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.project-card .pc-meta { display: flex; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.project-card .pc-meta span { display: inline-flex; align-items: center; gap: 5px; }
.project-card .pc-meta .late { color: var(--red); }
.project-card .pc-money { display: flex; justify-content: space-between; font-size: 13.5px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.project-card .pc-money strong { font-variant-numeric: tabular-nums; }

/* Kosten-Summen */
.cost-sums { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line-2); }
.cost-sums > div { padding: 18px 24px; border-right: 1px solid var(--line-2); }
.cost-sums > div:last-child { border-right: 0; }
.cost-sums .k { font-size: 13px; color: var(--muted); }
.cost-sums .v { font-family: var(--display); font-weight: 700; font-size: 21px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.type-tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.type-tag.monthly { background: var(--accent-soft); color: var(--accent-ink); }

/* Balkendiagramm (Umsatz) */
.bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; align-items: end; height: 150px; padding-top: 10px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar-col .b { width: 100%; max-width: 44px; background: var(--accent-soft); border-radius: 6px 6px 3px 3px; min-height: 3px; position: relative; }
.bar-col.current .b { background: var(--accent); }
.bar-col .l { font-size: 12.5px; color: var(--muted); }
.bar-col .b:hover::after { content: attr(data-v); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; padding: 3px 7px; border-radius: 5px; white-space: nowrap; }

/* ---------- Rechnungseditor ---------- */

.items-table { width: 100%; border-collapse: collapse; }
.items-table th { text-align: left; font-size: 13px; font-weight: 500; color: var(--muted); padding: 0 6px 8px; }
.items-table td { padding: 4px 6px; vertical-align: top; }
.items-table .input { height: 40px; }
.items-table textarea.input { min-height: 40px; height: 40px; resize: vertical; padding-top: 9px; }
.items-table .c-qty { width: 92px; }
.items-table .c-unit { width: 120px; }
.items-table .c-price { width: 140px; }
.items-table .c-total { width: 120px; text-align: right; padding-top: 14px; font-variant-numeric: tabular-nums; font-weight: 600; }
.items-table .c-del { width: 40px; }
.totals { margin-left: auto; width: 320px; font-size: 14.5px; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 17px; font-family: var(--display); }

/* Rechnungs-Dokument (Ansicht, Druck, öffentlich) */
.doc-wrap { background: #E9EBF0; padding: 32px 16px 64px; min-height: 100vh; }
.doc-bar { max-width: 820px; margin: 0 auto 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.doc { background: #fff; max-width: 820px; margin: 0 auto; padding: 64px 64px 48px; box-shadow: 0 4px 24px rgba(20, 24, 43, .1); border-radius: 4px; font-size: 14px; color: #1a1d2b; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 48px; }
.doc-logo img { max-height: 60px; max-width: 220px; }
.doc-logo .name { font-family: var(--display); font-size: 22px; font-weight: 700; }
.doc-sender { text-align: right; font-size: 12.5px; color: #555a6e; line-height: 1.5; }
.doc-addr-line { font-size: 10.5px; color: #8a8fa3; text-decoration: underline; margin-bottom: 6px; }
.doc-meta-row { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 40px; }
.doc-recipient { white-space: pre-line; line-height: 1.5; font-size: 14.5px; }
.doc-meta { font-size: 13px; }
.doc-meta td { padding: 2px 0 2px 18px; }
.doc-meta td:first-child { color: #6b7088; padding-left: 0; }
.doc h1 { font-size: 24px; margin-bottom: 14px; }
.doc .intro { margin-bottom: 24px; white-space: pre-line; }
.doc-items { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.doc-items th { text-align: left; font-size: 12px; font-weight: 600; color: #6b7088; border-bottom: 1.5px solid #1a1d2b; padding: 8px 6px; }
.doc-items td { padding: 10px 6px; border-bottom: 1px solid #e6e8ee; vertical-align: top; }
.doc-items .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-items .desc { white-space: pre-line; }
.doc-totals { margin-left: auto; width: 300px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.doc-totals .grand { border-top: 1.5px solid #1a1d2b; margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 16px; }
.doc .notes { margin-top: 32px; white-space: pre-line; color: #3b4157; }
.doc-foot { margin-top: 56px; padding-top: 16px; border-top: 1px solid #e6e8ee; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; font-size: 11.5px; color: #6b7088; line-height: 1.5; }
.doc-stamp { display: inline-block; border: 2px solid var(--red); color: var(--red); font-weight: 700; padding: 4px 12px; border-radius: 6px; transform: rotate(-4deg); margin-bottom: 18px; letter-spacing: .04em; }
.doc-stamp.paid { border-color: var(--green); color: var(--green); }

/* ---------- Auth-Layout ---------- */

.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; background: var(--surface); }
.auth-main { display: flex; flex-direction: column; padding: 32px 48px; }
.auth-main .brand { color: var(--ink); padding: 0; }
.auth-form { width: 100%; max-width: 400px; margin: auto; padding: 40px 0; }
.auth-form h1 { font-size: 30px; margin-bottom: 8px; }
.auth-form .lead { color: var(--muted); margin-bottom: 28px; }
.auth-form .field { margin-bottom: 16px; }
.auth-form .btn { height: 46px; font-size: 15.5px; }
.auth-alt { margin-top: 24px; text-align: center; color: var(--muted); font-size: 14.5px; }
.auth-legal { font-size: 13px; color: var(--faint); display: flex; gap: 16px; }
.auth-legal a { color: var(--faint); }
.auth-side { background: var(--side); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth-side h2 { color: #fff; font-size: 34px; line-height: 1.12; max-width: 440px; font-weight: 700; letter-spacing: -0.025em; }
.auth-side p { color: #A9AECA; max-width: 420px; margin-top: 16px; font-size: 16px; }
.auth-side .flow-demo { margin-top: 44px; display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.flow-demo .fd { display: flex; align-items: center; gap: 14px; background: var(--side-2); border: 1px solid rgba(255, 255, 255, .06); border-radius: 12px; padding: 14px 16px; }
.flow-demo .fd .ic { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: rgba(47, 84, 235, .25); color: #9DB1FF; flex-shrink: 0; }
.flow-demo .fd.sig .ic { background: rgba(255, 201, 77, .18); color: var(--signal); }
.flow-demo .fd strong { display: block; font-size: 14.5px; }
.flow-demo .fd span { font-size: 13px; color: #A9AECA; }
.flow-demo .fd .amt { margin-left: auto; font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.flow-demo .link-line { width: 2px; height: 14px; background: linear-gradient(var(--accent), var(--signal)); margin-left: 33px; border-radius: 2px; }

.password-wrap { position: relative; }
.password-wrap .toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--faint); cursor: pointer; padding: 6px; display: flex; }
.password-wrap .toggle:hover { color: var(--ink); }
.password-wrap .input { padding-right: 42px; }

/* Onboarding */
.steps { display: flex; gap: 8px; margin-bottom: 32px; }
.steps .s { flex: 1; }
.steps .s .bar { height: 4px; border-radius: 4px; background: var(--line-2); }
.steps .s.done .bar, .steps .s.now .bar { background: var(--accent); }
.steps .s span { display: block; font-size: 12.5px; color: var(--faint); margin-top: 8px; }
.steps .s.now span { color: var(--ink); font-weight: 600; }
.onb-form { max-width: 520px; }
.team-sizes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.team-sizes label { position: relative; }
.team-sizes input { position: absolute; opacity: 0; }
.team-sizes span { display: block; text-align: center; border: 1px solid #D9DCE4; border-radius: var(--r-md); padding: 10px 4px; font-size: 14px; cursor: pointer; font-weight: 500; }
.team-sizes input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.team-sizes input:focus-visible + span { outline: 2px solid var(--accent); }
.done-list { display: grid; gap: 10px; margin: 28px 0; }
.done-list a { display: flex; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); color: var(--ink); }
.done-list a:hover { border-color: var(--accent); background: var(--accent-soft); }
.done-list .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.done-list strong { display: block; }
.done-list span { font-size: 13.5px; color: var(--muted); }

/* ---------- Portal ---------- */

.portal-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.portal-top .in { max-width: 1040px; margin: 0 auto; padding: 0 24px; height: 66px; display: flex; align-items: center; gap: 24px; }
.portal-top .agency { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 17px; color: var(--ink); }
.portal-top .agency img { max-height: 32px; max-width: 140px; }
.portal-top nav { display: flex; gap: 4px; }
.portal-top nav a { padding: 8px 12px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; font-size: 14.5px; }
.portal-top nav a:hover { background: var(--line-2); color: var(--ink); }
.portal-top nav a.active { background: var(--line-2); color: var(--ink); font-weight: 600; }
.portal-top .me { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.portal-content { max-width: 1040px; margin: 0 auto; padding: 32px 24px 64px; }
.portal-foot { text-align: center; padding: 24px; font-size: 13px; color: var(--faint); }
.portal-foot a { color: var(--muted); }
.portal-hero { padding: 28px; background: var(--ink); color: #fff; border-radius: var(--r-lg); margin-bottom: 24px; display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: center; }
.portal-hero h1 { color: #fff; font-size: 26px; }
.portal-hero p { color: #A9AECA; margin: 6px 0 0; }

/* ---------- Fehlerseiten ---------- */

.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.error-page .code { font-family: var(--display); font-size: 88px; font-weight: 800; letter-spacing: -0.04em; color: var(--accent); line-height: 1; }
.error-page h1 { margin: 12px 0 8px; }
.error-page p { color: var(--muted); margin-bottom: 24px; }

.cost-grid { grid-template-columns: 2fr 1fr 1fr; }

/* ---------- Responsiv ---------- */

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
  .cost-sums { grid-template-columns: repeat(2, 1fr); }
  .cost-sums > div:nth-child(2) { border-right: 0; }
  .cost-sums > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-2); }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(20, 24, 43, .4); z-index: 40; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar .brand { padding: 0; font-size: 16px; }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; display: flex; cursor: pointer; }
  .content { padding: 22px 16px 48px; }
  .impersonation-bar { padding: 8px 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-main { padding: 24px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3, .cost-grid { grid-template-columns: 1fr; }
  .search .input { width: 100%; }
  .search { flex: 1; }
  h1 { font-size: 24px; }
  .doc { padding: 32px 22px; }
  .doc-head, .doc-meta-row { flex-direction: column; }
  .doc-sender { text-align: left; }
  .doc-foot { grid-template-columns: 1fr; }
  .doc-totals, .totals { width: 100%; }
  .items-table thead { display: none; }
  .items-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
  .items-table td { padding: 0; width: auto !important; }
  .items-table .c-desc { grid-column: 1 / -1; }
  .items-table .c-total { text-align: left; padding-top: 10px; }
  .portal-top .in { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 10px; }
  .portal-top .me { margin-left: 0; width: 100%; justify-content: space-between; }
  .portal-content { padding: 22px 16px 48px; }
  .card-head, .card-body, .list > li, .file-row, .request, .update { padding-left: 16px; padding-right: 16px; }
  .table td:first-child, .table th:first-child { padding-left: 16px; }
  .table td:last-child, .table th:last-child { padding-right: 16px; }
  .update-body { padding-left: 0; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 10px; }
  .team-sizes { grid-template-columns: repeat(3, 1fr); }
  .flashes { left: 16px; right: 16px; max-width: none; }
  .hide-sm { display: none !important; }
}

@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr; }
  .cost-sums { grid-template-columns: 1fr; }
  .cost-sums > div { border-right: 0; border-bottom: 1px solid var(--line-2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Druck ---------- */

@media print {
  @page { size: A4; margin: 14mm 0; }
  body, .doc-wrap { background: #fff !important; padding: 0 !important; }
  .doc-bar, .no-print { display: none !important; }
  .doc { box-shadow: none; padding: 0 16mm; max-width: none; border-radius: 0; }
}
.form-section > h2 + .form-grid, .form-section > h2 + .field { margin-top: 14px; }
