/* Agentur-Dashboard – Designsystem „Salbei“ (v2)
   App-Shell mit Seitenleiste, Hell/Dunkel, Inter, mobil mit Schublade + Leiste unten.
   Module verwenden ausschließlich diese Variablen und Bausteine – keine eigenen Farben/Schriften. */

@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/inter-latin-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
/* Hausschrift der Agentur (Corpid C1, Webfont-Lizenz der Agentur) – nur für den Rahmen der App, Inhalte bleiben in Inter */
@font-face { font-family: 'Corpid'; src: url('/assets/fonts/corpid-c1-regular.woff') format('woff'); font-weight: 400; font-style: normal; font-display: swap }
@font-face { font-family: 'Corpid'; src: url('/assets/fonts/corpid-c1-bold.woff') format('woff'); font-weight: 600 700; font-style: normal; font-display: swap }
.side, .topbar, .tabbar, .crumbs, .pagehead h1, .login, .menu-title, .nav-sec { font-family: 'Corpid', 'Inter', -apple-system, "Segoe UI", Arial, sans-serif }

/* ---------- Farben & Maße ---------- */
:root {
  color-scheme: light;
  --paper: #F3F5F2; --sheet: #FFFFFF; --side: #FAFBF9;
  --ink: #141A16; --ink-soft: #3C4640; --muted: #6E7972;
  --hair: #E2E7E1; --fill: #EEF2ED; --fill-hover: #E4EAE3; --track: #CBD4CA;
  --accent: #2E6A4E; --accent-hover: #245840; --accent-soft: #E0EDE5; --accent-ink: #21573D; --on-accent: #FFFFFF;
  --krank: #4E6E86; --krank-soft: #E3EBF1; --kind: #A9702E; --kind-soft: #F4EADC;
  --ok: #2E6A4E; --ok-soft: #E0EDE5; --wait: #8A7424; --wait-soft: #F3ECD6;
  --danger: #A33A33; --danger-soft: #F7E3E1;
  --client: #6B4F86; --client-soft: #EDE6F4;
  --tint-0: var(--sheet); --tint-1: #E7F1EA; --tint-2: #E5EEF7; --tint-3: #F6EFDD; --tint-4: #F8E7E9; --tint-5: #EEE8F7;
  --dot-0: #C9D1C8; --dot-1: #6FA884; --dot-2: #6E9CC6; --dot-3: #C9A55A; --dot-4: #D88A96; --dot-5: #9C86C9;
  --r: 14px; --r-in: 10px; --r-btn: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 18, .05);
  --shadow: 0 1px 2px rgba(16, 24, 18, .04), 0 8px 24px -14px rgba(16, 24, 18, .14);
  --shadow-hover: 0 2px 4px rgba(16, 24, 18, .06), 0 18px 40px -16px rgba(16, 24, 18, .24);
  --shadow-pop: 0 28px 70px -18px rgba(10, 16, 12, .35), 0 0 0 1px rgba(16, 24, 18, .06);
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --side-w: 256px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0D1210; --sheet: #151B18; --side: #111714;
    --ink: #E6ECE8; --ink-soft: #C2CBC5; --muted: #8B968F;
    --hair: #25302A; --fill: #1C2420; --fill-hover: #232E28; --track: #34413A;
    --accent: #62B78C; --accent-hover: #74C69C; --accent-soft: #1A3226; --accent-ink: #8ED1AD; --on-accent: #0C1510;
    --krank: #82A9C7; --krank-soft: #1A2732; --kind: #D89D59; --kind-soft: #33261A;
    --ok: #62B78C; --ok-soft: #1A3226; --wait: #D6C065; --wait-soft: #2F2A16;
    --danger: #E47F77; --danger-soft: #3A1F1D;
    --client: #BBA0DA; --client-soft: #2A2236;
    --tint-1: #1B2E23; --tint-2: #1A2835; --tint-3: #2D281A; --tint-4: #33212A; --tint-5: #282237;
    --dot-0: #3A463F;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 26px -14px rgba(0, 0, 0, .6);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .4), 0 18px 40px -16px rgba(0, 0, 0, .75);
    --shadow-pop: 0 28px 70px -18px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .06);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0D1210; --sheet: #151B18; --side: #111714;
  --ink: #E6ECE8; --ink-soft: #C2CBC5; --muted: #8B968F;
  --hair: #25302A; --fill: #1C2420; --fill-hover: #232E28; --track: #34413A;
  --accent: #62B78C; --accent-hover: #74C69C; --accent-soft: #1A3226; --accent-ink: #8ED1AD; --on-accent: #0C1510;
  --krank: #82A9C7; --krank-soft: #1A2732; --kind: #D89D59; --kind-soft: #33261A;
  --ok: #62B78C; --ok-soft: #1A3226; --wait: #D6C065; --wait-soft: #2F2A16;
  --danger: #E47F77; --danger-soft: #3A1F1D;
  --client: #BBA0DA; --client-soft: #2A2236;
  --tint-1: #1B2E23; --tint-2: #1A2835; --tint-3: #2D281A; --tint-4: #33212A; --tint-5: #282237;
  --dot-0: #3A463F;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 26px -14px rgba(0, 0, 0, .6);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .4), 0 18px 40px -16px rgba(0, 0, 0, .75);
  --shadow-pop: 0 28px 70px -18px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .06);
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box }
html, body { margin: 0; padding: 0 }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px }
body {
  background: var(--paper); color: var(--ink);
  font: 400 14.5px/1.55 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important }
a { color: var(--accent-ink); text-underline-offset: 2px }
button, input, select, textarea { font: inherit; color: inherit }
.icon { flex: 0 0 auto; display: block }
::selection { background: var(--accent-soft) }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px }
kbd { font: 500 11px/1 var(--mono); padding: 3px 5px; border-radius: 5px; border: 1px solid var(--hair); background: var(--sheet); color: var(--muted) }

/* ---------- App-Shell ---------- */
.app { min-height: 100vh; min-height: 100dvh }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 40;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--side); border-right: 1px solid var(--hair); padding: 18px 14px 14px;
}
.main { margin-left: var(--side-w); min-width: 0 }
.view { max-width: 1200px; margin: 0 auto; padding: 24px 32px 80px; outline: none }
body.guest .side, body.guest .topbar, body.guest .tabbar { display: none }
body.guest .main { margin-left: 0 }

.side-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 10px }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-height: 34px }
.brand img { height: 28px; width: auto; display: block }
.brand .logo-dark { display: none }
:root[data-theme="dark"] .brand .logo-light { display: none }
:root[data-theme="dark"] .brand .logo-dark { display: block }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light { display: none }
  :root:not([data-theme="light"]) .brand .logo-dark { display: block }
}
.brand .wordmark { font-weight: 650; letter-spacing: -.01em }
.side .side-close { display: none }

.search-btn {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; margin: 0 0 8px;
  background: var(--sheet); border: 1px solid var(--hair); border-radius: var(--r-btn); color: var(--muted);
  cursor: pointer; font-size: 13.5px; text-align: left; box-shadow: var(--shadow-sm); transition: border-color .15s;
}
.search-btn:hover { border-color: var(--track); color: var(--ink-soft) }
.search-btn span { flex: 1 }

.nav { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin }
.nav-sec { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; padding: 16px 10px 6px }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; margin: 1px 0;
  color: var(--ink-soft); text-decoration: none; font-size: 14px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--fill); color: var(--ink) }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink) }
.nav a .icon { opacity: .85 }
.nav a .count { margin-left: auto; font-size: 11.5px; font-weight: 600; background: var(--wait-soft); color: var(--wait); border-radius: 999px; padding: 1px 7px }
.nav .av { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; background: var(--fill-hover); color: var(--ink-soft); flex: 0 0 auto }
.nav a.active .av { background: var(--accent); color: var(--on-accent) }
.nav a span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

.side-foot { border-top: 1px solid var(--hair); padding-top: 10px; display: flex; align-items: center; gap: 8px }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: 9px; color: var(--ink); text-decoration: none }
.me:hover { background: var(--fill) }
.me .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 650; font-size: 13px; flex: 0 0 auto }
.me .who { min-width: 0; line-height: 1.25 }
.me .who b { display: block; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.me .who small { color: var(--muted); font-size: 12px }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: none; border: 0; color: var(--muted); cursor: pointer; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--fill); color: var(--ink) }

/* Oberer Ladebalken (nur wenn ein Seitenwechsel länger dauert) */
.progress-top { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--accent); z-index: 100; opacity: 0; transition: width .4s var(--ease), opacity .2s }
.progress-top.on { opacity: 1; width: 70% ; transition: width 2.5s var(--ease), opacity .1s }
.progress-top.done { opacity: 0; width: 100%; transition: width .15s, opacity .3s .1s }

/* Seitenwechsel: dezentes Einblenden */
.page { animation: page-in .22s var(--ease) both }
@keyframes page-in { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }

/* ---------- Mobil: Kopfzeile, Schublade, Leiste unten ---------- */
.topbar, .tabbar, .scrim { display: none }
@media (max-width: 900px) {
  .main { margin-left: 0 }
  .view { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)) }
  .topbar {
    display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 30;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px; background: color-mix(in srgb, var(--paper) 86%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--hair);
  }
  .topbar .brand img { height: 24px }
  .topbar .t { flex: 1; min-width: 0; text-align: center; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
  .side {
    width: min(86vw, 320px); transform: translateX(-102%); visibility: hidden;
    transition: transform .26s var(--ease), visibility 0s linear .26s;
    box-shadow: none; padding-top: calc(18px + env(safe-area-inset-top));
  }
  body.drawer .side { transform: none; visibility: visible; box-shadow: var(--shadow-pop); transition: transform .26s var(--ease) }
  .side .side-close { display: inline-grid }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(8, 12, 10, .4); opacity: 0; pointer-events: none; transition: opacity .2s }
  body.drawer .scrim { opacity: 1; pointer-events: auto }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--sheet) 90%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--hair);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px; border-radius: 10px;
    color: var(--muted); text-decoration: none; font-size: 10.5px; font-weight: 550; background: none; border: 0; cursor: pointer; min-width: 0;
  }
  .tabbar a.active { color: var(--accent-ink) }
  .tabbar a.active .icon { stroke-width: 2.2 }
  .tabbar .tb-l { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
}

/* ---------- Seitenkopf ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 13px; color: var(--muted) }
.crumbs a { color: var(--muted); text-decoration: none }
.crumbs a:hover { color: var(--ink) }
.crumbs .sl { color: var(--track) }
h1 { font-size: 24px; font-weight: 680; letter-spacing: -.025em; margin: 0; line-height: 1.25 }
.lead { color: var(--muted); font-size: 14px; margin: 3px 0 0; max-width: 72ch }
.pagehead { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 22px }
.pagehead .ph-main { flex: 1 1 260px; min-width: 0 }
.pagehead .ph-lead { flex: 0 0 auto }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
h2 { font-size: 13px; color: var(--muted); margin: 0 0 14px; font-weight: 600; letter-spacing: .01em }
h3 { font-size: 15.5px; font-weight: 620; margin: 0 0 8px; letter-spacing: -.01em }
.section { margin-top: 32px }
.muted { color: var(--muted) }
.small { font-size: 13px }
.mono { font-family: var(--mono); font-size: 12.5px }
.nowrap { white-space: nowrap }
.num { font-variant-numeric: tabular-nums; white-space: nowrap }
.loading { color: var(--muted); padding: 40px 0 }
@media (max-width: 900px) {
  h1 { font-size: 22px }
  .lead { font-size: 14px; margin-bottom: 20px }
  .pagehead .actions { width: 100%; margin-bottom: 18px }
  .pagehead .actions > * { flex: 1 1 auto }
}

/* ---------- Kacheln ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px }
.tile {
  position: relative; background: var(--sheet); border: 1px solid var(--hair); border-radius: var(--r); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px; min-height: 132px; color: var(--ink); text-decoration: none;
  box-shadow: var(--shadow-sm); transition: transform .16s var(--ease), box-shadow .16s, border-color .16s;
}
a.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--track) }
.tile .ti { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); margin-bottom: 6px }
.tile .kicker { font-size: 12px; color: var(--muted) }
.tile h3 { font-size: 16px; margin: 0 }
.tile p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5 }
.tile .go { margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--accent-ink); font-weight: 550; display: flex; align-items: center; gap: 4px }
.tile.off { opacity: .55; box-shadow: none; background: var(--fill) }
@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr; gap: 10px }
  .tile { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 14px 16px }
  .tile .ti { margin: 0 }
  .tile h3 { flex: 1 }
  .tile p, .tile .kicker { flex-basis: 100% }
  .tile .go { display: none }
}

/* ---------- Flächen und Formulare ---------- */
.grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; align-items: start }
.grid.wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) }
@media (max-width: 1000px) { .grid, .grid.wide { grid-template-columns: minmax(0, 1fr); gap: 18px } }
.panel { background: var(--sheet); border: 1px solid var(--hair); border-radius: var(--r); padding: 22px 24px; box-shadow: var(--shadow-sm); min-width: 0 }
.panel + .panel { margin-top: 18px }
.panel.soft { background: var(--fill); box-shadow: none; border-color: transparent }
@media (max-width: 560px) { .panel { padding: 18px 16px; border-radius: 12px } }
label, .label { display: block; font-size: 13px; font-weight: 550; color: var(--ink-soft); margin: 0 0 7px }
.label small, label small { font-weight: 400; color: var(--muted) }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time], input[type=password], input[type=search], select, textarea {
  width: 100%; font-size: 14.5px; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--track); border-radius: var(--r-in); padding: 9px 12px; min-height: 40px;
  transition: border-color .15s, box-shadow .15s, background .15s; box-shadow: var(--shadow-sm);
}
input::placeholder, textarea::placeholder { color: var(--muted) }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--track) 50%, var(--muted)) }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft) }
input[readonly] { background: var(--fill); color: var(--ink-soft); box-shadow: none }
textarea { min-height: 110px; resize: vertical; line-height: 1.55 }
select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 16px center, right 11px center; background-size: 5px 5px; background-repeat: no-repeat }
@media (max-width: 900px) { input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time], input[type=password], input[type=search], select, textarea { font-size: 16px; min-height: 44px } }
.field { margin-bottom: 16px }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 6px }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; gap: 0 } }
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; cursor: pointer; font-weight: 400 }
.check input { margin: 3px 0 0; width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto }
.check span { font-size: 14.5px; color: var(--ink) }
.check small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 14px; font-weight: 550; line-height: 1.25;
  padding: 9px 15px; min-height: 38px; border-radius: var(--r-btn); cursor: pointer; text-decoration: none; white-space: nowrap;
  border: 1px solid var(--track); background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-sm);
  transition: border-color .15s, background .15s, transform .08s, box-shadow .15s;
}
.btn:hover { border-color: var(--muted); background: var(--fill) }
.btn:active { transform: translateY(1px) }
.btn:disabled { opacity: .5; cursor: not-allowed }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; box-shadow: 0 1px 2px rgba(16, 40, 28, .25), inset 0 1px 0 rgba(255, 255, 255, .12) }
.btn.primary:hover { background: var(--accent-hover) }
.btn.block { width: 100% }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft) }
.btn.small { font-size: 13px; padding: 5px 11px; min-height: 32px }
@media (max-width: 900px) { .btn { min-height: 44px } .btn.small { min-height: 36px } }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--accent-ink); cursor: pointer; font-size: 13.5px; font-weight: 550 }
.linkbtn:hover { text-decoration: underline }
.linkbtn.danger { color: var(--muted) }
.linkbtn.danger:hover { color: var(--danger) }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center }
.msg { font-size: 13px; margin-top: 12px; min-height: 18px }
.msg:empty { margin-top: 0; min-height: 0 }
.msg.ok { color: var(--ok) } .msg.err { color: var(--danger) }

/* Segment-Schalter */
.seg { display: inline-flex; gap: 2px; background: var(--fill); padding: 3px; border-radius: 10px; flex-wrap: wrap; border: 1px solid var(--hair) }
.seg button { border: 0; background: none; color: var(--ink-soft); font-size: 13px; font-weight: 550; padding: 6px 12px; border-radius: 7px; cursor: pointer }
.seg button:hover { color: var(--ink) }
.seg button.active { background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-sm) }
@media (max-width: 720px) {
  .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none }
  .seg::-webkit-scrollbar { display: none }
  .seg button { flex: 0 0 auto }
}

/* Skelett beim allerersten Laden (danach bleibt die alte Seite stehen, bis die neue fertig ist) */
.skeleton .sk { background: linear-gradient(90deg, var(--fill) 25%, var(--fill-hover) 37%, var(--fill) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 10px }
.skeleton .sk.h1 { width: 220px; height: 30px; margin: 4px 0 26px }
.skeleton .sk.card { height: 120px }
.skeleton .row { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px }
@keyframes sk { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

/* ---------- Tabellen (auf dem Handy als Karten) ---------- */
.table-wrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow-sm) }
table.list { width: 100%; border-collapse: collapse; font-size: 14px }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--hair); white-space: nowrap; background: var(--fill) }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--hair); vertical-align: top }
table.list tr:last-child td { border-bottom: 0 }
table.list td.right, table.list th.right { text-align: right }
table.list tr.clickable { cursor: pointer }
table.list tr.clickable:hover td { background: var(--fill) }
table.list tr.dim td { color: var(--muted) }
.empty { color: var(--muted); font-size: 14px; padding: 28px 18px; text-align: center; background: var(--sheet); border: 1px dashed var(--track); border-radius: var(--r) }
.panel > .empty { border: 0; background: none; padding: 12px 0 }
@media (max-width: 720px) {
  .table-wrap { background: none; border: 0; box-shadow: none; overflow: visible }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100% }
  table.list thead { display: none }
  table.list tr { background: var(--sheet); border: 1px solid var(--hair); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm) }
  table.list tr.clickable:hover td { background: none }
  table.list tr.clickable:active { background: var(--fill) }
  table.list td { border: 0; padding: 4px 0; display: flex; gap: 12px; justify-content: space-between; align-items: baseline; text-align: right }
  table.list td > * { text-align: right }
  table.list td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 550; text-align: left; flex: 0 0 auto; padding-right: 8px }
  table.list td[data-label=""]::before { display: none }
  table.list td:first-child { font-weight: 600; font-size: 15px; display: block; text-align: left; padding-bottom: 6px }
  table.list td:first-child > * { text-align: left }
  table.list td:first-child::before { display: none }
  table.list td[data-label=""] { justify-content: flex-end }
  table.list td.right, table.list td.num { text-align: right }
}

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; line-height: 1.5; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: var(--fill); color: var(--ink-soft) }
.badge.ok { background: var(--ok-soft); color: var(--ok) }
.badge.wait { background: var(--wait-soft); color: var(--wait) }
.badge.danger { background: var(--danger-soft); color: var(--danger) }
.badge.client { background: var(--client-soft); color: var(--client) }
.badge.k { background: var(--krank-soft); color: var(--krank) }
.badge.kk { background: var(--kind-soft); color: var(--kind) }
.chip { display: inline-block; font-size: 12.5px; padding: 3px 10px; background: var(--fill); border-radius: 999px; margin: 0 6px 6px 0 }

/* ---------- Hinweise, Kopierfeld, Infos ---------- */
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin-top: 20px; max-width: 72ch }
.hint strong { color: var(--ink); font-weight: 600 }
.notice { border-radius: 10px; padding: 11px 14px; font-size: 13.5px; background: var(--fill); margin-bottom: 16px }
.notice.err { background: var(--danger-soft); color: var(--danger) }
.notice.ok { background: var(--ok-soft); color: var(--ok) }
.notice.wait { background: var(--wait-soft); color: var(--wait) }
.copybox { background: var(--fill); border-radius: 12px; padding: 14px; margin: 14px 0 }
.copybox input { font-family: var(--mono); font-size: 12.5px; margin-bottom: 10px }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: 14px }
.kv dt { color: var(--muted) }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere }
.divider { height: 1px; background: var(--hair); margin: 26px 0 }

/* ---------- Anmeldung ---------- */
.login { max-width: 400px; margin: 9vh auto 0 }
.login .brand { margin-bottom: 28px }
.login h1 { margin-bottom: 4px }
.login .lead { margin-bottom: 22px }
.login .panel { padding: 24px; box-shadow: var(--shadow) }

/* ---------- Startseite ---------- */
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px }
.hello h1 { font-size: 28px }
.hello .date { color: var(--muted); font-size: 14px }
.widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 30px; align-items: start }
.widget { background: var(--sheet); border: 1px solid var(--hair); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow-sm); min-width: 0 }
.widget-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px }
.widget-head h2 { margin: 0; color: var(--ink); font-size: 14.5px; flex: 1 }
.widget-head .ti { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink) }
.widget-head a { font-size: 13px; text-decoration: none; font-weight: 550 }
@media (max-width: 560px) { .widgets { grid-template-columns: 1fr } .hello h1 { font-size: 23px } }
.wlist { list-style: none; margin: 0; padding: 0 }
.wlist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--hair); font-size: 13.5px; min-width: 0 }
.wlist li:first-child { border-top: 0 }
.wlist .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

/* ---------- Rechte-Editor / Freigaben ---------- */
.perm-group { margin-bottom: 18px }
.perm-group h3 { font-size: 14px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center }
.perm-group .check { margin-bottom: 8px }
.grant { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--hair) }
.grant:last-child { border-bottom: 0 }
.grant .what { font-weight: 550 }
.grant .where { font-size: 13px; color: var(--muted) }

/* ---------- Upload ---------- */
.dropzone {
  display: block; border: 1.5px dashed var(--track); border-radius: var(--r); padding: 26px; text-align: center; color: var(--muted);
  background: var(--sheet); transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink) }
.dropzone strong { color: var(--accent-ink); font-weight: 600 }
.dropzone input[type=file] { display: none }
.progress { height: 6px; background: var(--fill); border-radius: 999px; overflow: hidden; margin-top: 12px }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s }

/* ---------- Rich-Text-Editor und -Anzeige ---------- */
.rte { background: var(--sheet); border: 1px solid var(--track); border-radius: 12px; overflow: hidden; transition: border-color .15s, box-shadow .15s; box-shadow: var(--shadow-sm) }
.rte:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft) }
.rte-bar { display: flex; gap: 2px; align-items: center; padding: 6px; border-bottom: 1px solid var(--hair); flex-wrap: wrap; background: var(--fill) }
.rte-bar button { font-size: 13px; color: var(--ink-soft); background: none; border: 0; border-radius: 7px; padding: 5px 10px; cursor: pointer; min-height: 30px }
.rte-bar button:hover { background: var(--fill-hover); color: var(--ink) }
.rte-bar .dict { margin-left: auto }
.rte-sep { width: 1px; height: 18px; background: var(--track); margin: 0 5px }
.rte-area { padding: 14px 16px; font-size: 15px; line-height: 1.7; outline: none; overflow: auto; color: var(--ink) }
.rte-area:empty::before { content: attr(data-ph); color: var(--muted) }
.rte-area h3, .rich h3 { font-size: 16px; font-weight: 620; margin: 14px 0 6px }
.rte-area p, .rich p { margin: 0 0 10px }
.rich p:last-child { margin-bottom: 0 }
.rte-area ul, .rte-area ol, .rich ul, .rich ol { margin: 0 0 10px; padding-left: 22px }
.rich { line-height: 1.7; overflow-wrap: anywhere }
.rich li { margin: 3px 0 }
.rich b { font-weight: 650 }

/* ---------- Dokumentansicht ---------- */
.doc { background: var(--sheet); border: 1px solid var(--hair); border-radius: var(--r); padding: 32px 36px; max-width: 820px; box-shadow: var(--shadow-sm) }
.doc h1 { margin: 0 0 2px }
.doc .meta { display: flex; gap: 10px 28px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin: 10px 0 22px }
.doc .meta b { display: block; color: var(--ink); font-size: 14px; font-weight: 600; margin-top: 2px }
.doc .body { font-size: 15px; border-top: 1px solid var(--hair); padding-top: 20px }
.timeline { margin-top: 24px; border-top: 1px solid var(--hair); padding-top: 20px }
.tl-item { padding: 14px 0; border-bottom: 1px solid var(--hair) }
.tl-item:last-child { border-bottom: 0 }
.tl-item .when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums }
.tl-item .rich { margin-top: 6px }
.conf-list { display: flex; flex-direction: column; gap: 10px }
.conf-row { display: flex; align-items: center; gap: 10px; font-size: 14.5px; flex-wrap: wrap }
.conf-row .who { min-width: 170px }
.conf-row .when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums }
@media (max-width: 600px) { .doc { padding: 20px 16px } .conf-row .who { min-width: 0; flex-basis: 100%; font-weight: 550 } }

.picker { border: 1px solid var(--track); border-radius: 12px; max-height: 260px; overflow: auto; background: var(--sheet) }
.picker label { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-bottom: 1px solid var(--hair); color: var(--ink); font-size: 14.5px; font-weight: 400; margin: 0; cursor: pointer }
.picker label:last-child { border-bottom: 0 }
.picker label:hover { background: var(--fill) }
.picker input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0 }

/* ---------- Diktier-Knopf (public/lib/dictate.js) ---------- */
.dict {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 10px; border-radius: 999px; cursor: pointer;
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid transparent; font-size: 13.5px; font-weight: 600;
  transition: background .15s, color .15s, box-shadow .2s;
}
.dict:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 12%) }
.dict:disabled { opacity: .55; cursor: not-allowed }
.dict.compact { padding: 0 9px; height: 30px; gap: 6px }
.dict .dict-level, .dict .dict-time { display: none }
.dict[data-state="recording"] { background: var(--danger); color: #fff; box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 50%, transparent); animation: dict-pulse 1.6s infinite }
.dict[data-state="recording"] .dict-level { display: inline-flex; align-items: center; gap: 2px; height: 16px }
.dict[data-state="recording"] .dict-time { display: inline; font-variant-numeric: tabular-nums; font-weight: 600 }
.dict .dict-level i { display: block; width: 3px; height: 14px; border-radius: 2px; background: currentColor; transform: scaleY(.3); transition: transform .08s linear }
.dict[data-state="busy"] { cursor: progress }
.dict[data-state="busy"] .dict-icon { animation: spin 1s linear infinite }
@keyframes dict-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 45%, transparent) } 70% { box-shadow: 0 0 0 10px transparent } 100% { box-shadow: 0 0 0 0 transparent } }
@keyframes spin { to { transform: rotate(360deg) } }

/* =====================================================================
   Bausteine v3 (Inhaltsbereich): Abschnitte, Zeilen, Avatare, Kennzahlen,
   Reiter, Chips, Menü, Seitenpanel, Editor-Leiste. Siehe /muster.
   ===================================================================== */
.grid > .panel + .panel { margin-top: 0 }
.pagehead .actions > .icon-only { flex: 0 0 auto }
.btn.icon-only { padding: 0; width: 38px; min-width: 38px }
.btn.icon-only.small { width: 32px; min-width: 32px }
@media (max-width: 900px) { .btn.icon-only { width: 44px } .pagehead .actions { margin-bottom: 0 } }

/* Fläche: eine ruhige Karte je Seite bzw. Spalte */
.surface { background: var(--sheet); border: 1px solid var(--hair); border-radius: var(--r); padding: 6px 20px 14px; box-shadow: var(--shadow-sm); min-width: 0 }
.surface + .surface { margin-top: 16px }
.split > .surface + .surface, .grid > .surface + .surface { margin-top: 0 }
@media (max-width: 560px) { .surface { padding: 4px 14px 12px; border-radius: 12px } }

/* Abschnitte */
.sec { margin-top: 18px }
.sec:first-child { margin-top: 8px }
.sec-head { display: flex; align-items: center; gap: 10px; min-height: 36px; border-bottom: 1px solid var(--hair); margin-bottom: 2px }
.sec-head h2 { margin: 0; flex: 1; color: var(--ink); font-size: 14.5px; font-weight: 640; letter-spacing: -.005em; display: flex; align-items: center; gap: 8px }
.sec-count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--fill); border-radius: 999px; padding: 0 8px; line-height: 20px }
.sec-hint { font-size: 12.5px; color: var(--muted) }
.sec-actions { display: flex; gap: 6px }

/* Zeilenlisten */
.rows { display: flex; flex-direction: column }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--hair); color: var(--ink); text-decoration: none; min-width: 0; border-radius: 8px }
.row:last-child { border-bottom-color: transparent }
.row.link { cursor: pointer; transition: background .12s }
.row.link:hover { background: var(--fill) }
.row.dim { color: var(--muted) }
.row.dim .row-title { color: var(--muted) }
.row-lead { flex: 0 0 auto; display: flex; align-items: center; color: var(--muted) }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column }
.row-title { font-size: 14.5px; font-weight: 520; overflow-wrap: anywhere }
.row-sub { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere }
.row-meta { flex: 0 0 auto; font-size: 12.5px; color: var(--muted); text-align: right; white-space: nowrap }
.row-trail { flex: 0 0 auto; display: flex; gap: 6px; align-items: center }
.row-chev { flex: 0 0 auto; color: var(--track); display: flex }
.row.link:hover .row-chev { color: var(--muted) }
@media (max-width: 600px) {
  .row { flex-wrap: wrap; gap: 4px 12px }
  .row-main { flex-basis: calc(100% - 80px) }
  .row-meta { order: 5; flex-basis: 100%; text-align: left }
  .row:has(.row-lead) .row-meta { padding-left: 44px }
}

/* Avatare */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; font-weight: 650; letter-spacing: .01em; flex: 0 0 auto; line-height: 1 }
.avatar.square { border-radius: 28% }
.avatar.t1 { background: var(--accent-soft); color: var(--accent-ink) }
.avatar.t2 { background: var(--krank-soft); color: var(--krank) }
.avatar.t3 { background: var(--kind-soft); color: var(--kind) }
.avatar.t4 { background: var(--client-soft); color: var(--client) }
.avatar.t5 { background: var(--tint-4); color: var(--danger) }
.avatar.muted { background: var(--fill); color: var(--muted) }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0 0 18px }
.stat { background: var(--sheet); border: 1px solid var(--hair); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column }
.stat-label { font-size: 12.5px; color: var(--muted) }
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums }
.stat.warn .stat-value { color: var(--wait) }
@media (max-width: 560px) { .stats { grid-template-columns: 1fr 1fr } }

/* Reiter */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--hair); margin: 22px 0 6px; overflow-x: auto; scrollbar-width: none }
.tabs::-webkit-scrollbar { display: none }
.tabs button { background: none; border: 0; padding: 10px 0; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; font-weight: 550; cursor: pointer; display: flex; align-items: center; gap: 7px; white-space: nowrap }
.tabs button:hover { color: var(--ink) }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent) }
.tab-count { font-size: 11.5px; font-weight: 650; background: var(--fill); color: var(--ink-soft); border-radius: 999px; padding: 0 7px; line-height: 19px }
.tab-count.wait { background: var(--wait-soft); color: var(--wait) }

/* Chips (Eigenschaften) */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-soft); background: var(--fill); border: 1px solid transparent; border-radius: 999px; padding: 3px 10px; line-height: 1.4; white-space: nowrap }
.pill.dashed { background: none; border: 1px dashed var(--track); color: var(--muted) }
.pill.link { cursor: pointer }
.pill.link:hover { border-color: var(--muted); color: var(--ink) }
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center }

/* Leerzustand */
.empty { display: grid; justify-items: center; gap: 6px; text-align: center; color: var(--muted); font-size: 14px; padding: 26px 16px; background: none; border: 1px dashed var(--track); border-radius: 12px; margin: 8px 0 }
.empty b { color: var(--ink); font-weight: 600 }
.empty .btn { margin-top: 6px }
.surface .empty, .panel .empty { border: 0; padding: 18px 8px }

/* Menü (Popover am Desktop, Blatt von unten am Handy) */
.menu { position: fixed; margin: 0; padding: 6px; border: 1px solid var(--hair); border-radius: 12px; background: var(--sheet); box-shadow: var(--shadow-pop); min-width: 220px; max-width: min(320px, calc(100vw - 16px)); animation: page-in .12s var(--ease) both }
.menu::backdrop { background: transparent }
.menu-title { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 6px 10px 4px }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px; color: var(--ink); font-size: 14px; text-align: left; text-decoration: none; cursor: pointer }
.menu-item:hover, .menu-item:focus-visible { background: var(--fill); outline: none }
.menu-item.danger { color: var(--danger) }
.menu-item .icon, .menu-noicon { width: 16px; flex: 0 0 16px; color: var(--muted) }
.menu-item.danger .icon { color: var(--danger) }
.menu-label { display: flex; flex-direction: column }
.menu-label small { font-size: 12px; color: var(--muted) }
.menu.sheet { inset: auto 0 0 0; width: 100%; max-width: 100%; border-radius: 18px 18px 0 0; padding: 6px 10px calc(10px + env(safe-area-inset-bottom)) }
.menu.sheet::backdrop { background: rgba(8, 12, 10, .4) }
.menu.sheet .menu-item { padding: 13px 10px; font-size: 15px }
.menu-cancel { color: var(--muted) !important; border-top: 1px solid var(--hair) !important; border-radius: 0 !important; margin-top: 4px }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--track); margin: 4px auto 8px }

/* Seitenpanel */
.side-panel { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: 100dvh; width: min(460px, 100vw); max-width: 100vw; border: 0; border-left: 1px solid var(--hair); padding: 0; background: var(--sheet); box-shadow: var(--shadow-pop); flex-direction: column; animation: panel-in .2s var(--ease) both }
.side-panel[open] { display: flex }
.side-panel.wide { width: min(620px, 100vw) }
.side-panel::backdrop { background: rgba(8, 12, 10, .35) }
.sp-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--hair) }
.sp-head h2 { flex: 1; margin: 0; color: var(--ink); font-size: 16px; font-weight: 650 }
.sp-body { flex: 1; overflow-y: auto; padding: 18px }
.sp-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--hair) }
@keyframes panel-in { from { transform: translateX(24px); opacity: 0 } to { transform: none; opacity: 1 } }
@media (max-width: 720px) {
  .side-panel { inset: auto 0 0 0; width: 100vw; height: auto; max-height: 92dvh; border-left: 0; border-radius: 18px 18px 0 0; animation: sheet-in .22s var(--ease) both }
  .side-panel.wide { width: 100vw }
  .sp-foot > .btn { flex: 1 }
}
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }

/* Editor-Leiste (fest oben, mit „Nicht gespeichert“) */
.ebar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 0; margin: -10px 0 14px; background: var(--paper); border-bottom: 1px solid var(--hair) }
.ebar .crumbs { margin: 0; min-width: 0 }
.ebar-spacer { flex: 1 }
.ebar-state { font-size: 12.5px; font-weight: 600; color: var(--wait); background: var(--wait-soft); border-radius: 999px; padding: 2px 10px; white-space: nowrap }
@media (max-width: 900px) { .ebar { top: 57px; margin-top: -6px } .ebar .crumbs { display: none } }

/* Titel direkt bearbeiten */
.title-input { width: 100%; border: 0 !important; box-shadow: none !important; background: none !important; padding: 2px 0 !important; min-height: 0 !important; font-size: 24px !important; font-weight: 680; letter-spacing: -.025em; color: var(--ink) }
.title-input::placeholder { color: var(--track) }
.title-input:focus { box-shadow: 0 2px 0 var(--accent) !important; border-radius: 0 }
@media (max-width: 900px) { .title-input { font-size: 21px !important } }

/* Zweispaltig: Hauptinhalt + schmale Seitenspalte */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start }
@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr) } }

/* Editor- und Dokumentseiten: einheitliche Lesebreite */
.page.narrow { max-width: 880px }

/* Werkzeugleiste über Listen: Filter links, Suche rechts */
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 0 0 12px }
.toolbar input[type=search] { max-width: 260px }
@media (max-width: 600px) { .toolbar input[type=search] { max-width: none; flex: 1 1 100% } }
.row-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--fill); color: var(--ink-soft) }

/* Tabellen: leichter (eine Fläche, keine Kopfzeilen-Füllung) */
table.list th { background: none; padding: 9px 14px; font-weight: 550 }
table.list td { padding: 11px 14px }

/* ---------- Bestätigungsdialog (ui.confirmAction) ---------- */
.ask { border: 0; padding: 0; background: none; width: min(440px, calc(100vw - 24px)); overflow: visible }
.ask::backdrop { background: rgba(8, 12, 10, .45); backdrop-filter: blur(2px) }
.ask-box { background: var(--sheet); border: 1px solid var(--hair); border-radius: 16px; padding: 20px 22px; box-shadow: var(--shadow-pop); animation: page-in .16s var(--ease) both }
.ask-box h3 { font-size: 17px; margin: 0 0 6px }
.ask-box p { margin: 0 0 16px; color: var(--ink-soft); line-height: 1.55 }
.ask-box .field { margin-bottom: 16px }
.ask-extra { margin: -6px 0 16px }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap }
.btn.danger-solid { background: var(--danger); color: #fff; border-color: transparent }
.btn.danger-solid:hover { background: color-mix(in srgb, var(--danger) 85%, #000) }
@media (max-width: 600px) {
  .ask { width: 100vw; max-width: 100vw; margin: auto 0 0 }
  .ask-box { border-radius: 18px 18px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)) }
  .ask-actions > .btn { flex: 1 }
}

/* ---------- Benachrichtigungen ---------- */
.bell { position: relative }
.bell .dot { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--side) }
.inbox { border: 0; padding: 0; background: none; width: min(400px, calc(100vw - 24px)); margin: 70px 0 0 calc(var(--side-w) + 12px); overflow: visible }
.inbox::backdrop { background: transparent }
.inbox-box { background: var(--sheet); border: 1px solid var(--hair); border-radius: 16px; box-shadow: var(--shadow-pop); overflow: hidden; animation: page-in .16s var(--ease) both }
.inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--hair) }
.inbox-head h3 { margin: 0; font-size: 15px }
.inbox-list { max-height: min(60vh, 520px); overflow-y: auto }
.inbox-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--hair); color: var(--ink); text-decoration: none; cursor: pointer }
.inbox-item:last-child { border-bottom: 0 }
.inbox-item:hover { background: var(--fill) }
.inbox-item .ii { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--fill); color: var(--muted); flex: 0 0 auto }
.inbox-item.unread .ii { background: var(--accent-soft); color: var(--accent-ink) }
.inbox-item.unread b { font-weight: 650 }
.inbox-item b { display: block; font-weight: 550; font-size: 14px }
.inbox-item p { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.45; overflow-wrap: anywhere }
.inbox-item small { color: var(--muted); font-size: 12px }
.inbox-empty { padding: 30px 16px; text-align: center; color: var(--muted) }
@media (max-width: 900px) { .inbox { margin: 60px auto 0 } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px) }
.toast { background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-pop); animation: toast-in .22s var(--ease) both }
.toast.ok { background: var(--accent); color: var(--on-accent) }
.toast.err { background: var(--danger); color: #fff }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1; transform: none } }
@media (max-width: 900px) { .toasts { bottom: calc(84px + env(safe-area-inset-bottom)) } }

/* ---------- Schnellsuche (Strg+K) ---------- */
.cmdk { border: 0; padding: 0; background: none; width: min(620px, calc(100vw - 24px)); margin: 12vh auto 0; max-height: 70vh; overflow: visible }
.cmdk::backdrop { background: rgba(8, 12, 10, .45); backdrop-filter: blur(2px) }
.cmdk-box { background: var(--sheet); border: 1px solid var(--hair); border-radius: 16px; box-shadow: var(--shadow-pop); overflow: hidden; animation: page-in .16s var(--ease) both }
.cmdk-in { display: flex; align-items: center; gap: 10px; padding: 4px 16px; border-bottom: 1px solid var(--hair); color: var(--muted) }
.cmdk-in input { border: 0 !important; box-shadow: none !important; background: none; padding: 14px 0; font-size: 16px; min-height: 0 }
.cmdk-list { max-height: min(56vh, 460px); overflow-y: auto; padding: 6px }
.cmdk-group { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 10px 10px 4px }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; cursor: pointer; color: var(--ink-soft) }
.cmdk-item.sel { background: var(--accent-soft); color: var(--accent-ink) }
.cmdk-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500 }
.cmdk-item small { color: var(--muted); font-size: 12px }
.cmdk-empty { padding: 26px; text-align: center; color: var(--muted) }
.cmdk-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--hair); font-size: 12px; color: var(--muted); background: var(--fill) }
@media (max-width: 600px) { .cmdk { margin-top: 8px } .cmdk-foot { display: none } }

/* ---------- Druck ---------- */
/* =====================================================================
   Kundenbereich v1: Erläuterung, Vorschaubild, Ablagefläche kompakt, Ansprechpartner,
   Unterpunkte in der Navigation, Widgets auf der Kunden-Übersicht.
   ===================================================================== */
.explain { display: flex; gap: 12px; align-items: flex-start; background: var(--accent-soft); color: var(--ink); border-radius: 12px; padding: 13px 16px; margin: 0 0 16px; font-size: 14px; line-height: 1.6 }
.explain > .icon { color: var(--accent-ink); margin-top: 2px }
.explain-body { flex: 1; min-width: 0 }
.explain-body b { display: block; font-weight: 620; margin-bottom: 2px }
.explain-body p { margin: 0; max-width: 78ch; white-space: pre-line; overflow-wrap: anywhere }
.explain-body ul { margin: 6px 0 0; padding-left: 18px }
.explain-action { flex: 0 0 auto }
.surface .explain { margin: 12px 0 6px }
@media (max-width: 560px) { .explain { flex-wrap: wrap } .explain-action { flex-basis: 100%; padding-left: 30px } }

.thumb { flex: 0 0 auto; display: inline-grid; place-items: center; overflow: hidden; border-radius: 7px; border: 1px solid var(--hair); background: var(--fill); color: var(--muted); position: relative }
.thumb small { position: absolute; bottom: 2px; font-size: 9px; font-weight: 700; letter-spacing: .04em }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block }
.thumb.has-img { background: var(--sheet) }
.thumb-contain img { object-fit: contain; padding: 3px }
.thumb.thumb-dark, .thumb.thumb-dark.has-img { background: #2B2F2D }
.thumb-sm { width: 30px; height: 30px }
.thumb-md { width: 40px; height: 48px }
.thumb-lg { width: 64px; height: 72px }

.dz-compact { position: relative; cursor: pointer }
.dz-compact input[type=file] { display: none }
.dropzone > .icon { margin: 0 auto 6px; color: var(--muted) }
.newdot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; flex: 0 0 auto }
.ver { font: 600 11px/1.5 var(--mono); padding: 1px 7px; border-radius: 999px; background: var(--fill); color: var(--ink-soft); white-space: nowrap }

/* Ansprechpartner */
.contact { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--hair); align-items: flex-start }
.contact:last-child { border-bottom: 0 }
.contact .who { min-width: 0; flex: 1 }
.contact .who b { display: block; font-weight: 600 }
.contact .role { font-size: 12.5px; color: var(--muted) }
.contact .line { display: flex; align-items: center; gap: 6px; font-size: 13.5px; margin-top: 4px; color: var(--ink-soft) }
.contact .line span { overflow-wrap: anywhere; min-width: 0; user-select: all }
.contact .line > .icon { color: var(--muted) }
.contact .line .icon-btn { width: 26px; height: 26px }

.contact-edit { padding: 8px 0; border-bottom: 1px solid var(--hair) }
.contact-edit:last-child { border-bottom: 0 }
.contact-edit .check { margin-bottom: 6px }
.contact-edit .two { padding-left: 27px }

/* Navigation: Bereiche eines Kunden als Unterpunkte */
.nav a.sub { padding-left: 40px; font-size: 13.5px }
.nav a.sub .icon { width: 16px; height: 16px }

/* Kunden-Übersicht: Kopf mit Kürzel, Widgets der Module */
.kwidgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; margin: 0 0 16px }
.kwidgets .widget { margin: 0 }

@media print {
  body { background: #fff; color: #000 }
  .side, .topbar, .tabbar, .scrim, .toasts, .progress-top, .no-print { display: none !important }
  .main { margin: 0 }
  .view { padding: 0; max-width: none }
  .panel, .tile, .copybox, .doc, .table-wrap { box-shadow: none; border: 0; padding: 0; background: none }
  .doc { max-width: none }
  table.list th { background: none }
  .tl-item, .conf-row { break-inside: avoid }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important } }

/* Kundenbereich › Zugänge */
.za-choices { display: grid; gap: 8px }
.za-choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--hair); border-radius: 10px; cursor: pointer; margin: 0; font-weight: 400 }
.za-choice.on { border-color: var(--accent); background: var(--accent-soft) }
.za-choice input { margin-top: 3px; accent-color: var(--accent) }
.za-choice b { display: block; font-weight: 600; color: var(--ink) }
.za-choice small { display: block; color: var(--muted); font-size: 12.5px }
.za-perms { margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--track); border-radius: 10px; display: grid; gap: 10px }
.za-area b { display: block; font-size: 13px; margin-bottom: 6px }
.za-area .check { margin-bottom: 6px }
.za-projects { margin-top: 10px }
.za-roles { margin: 10px 6px; display: grid; gap: 4px 0; font-size: 13.5px }
.za-roles dt { font-weight: 600 }
.za-roles dd { margin: 0 0 8px; color: var(--muted) }

/* Kundenportal: Login im Design des Kunden, Logo in der Seitenleiste */
.login-brand { display: flex; justify-content: flex-start; margin-bottom: 26px; min-height: 56px; align-items: center }
/* Kundenlogo auf Inhaltsbreite (hohe Logos begrenzt die Höhe, dann linksbündig) */
.login-logo { display: block; width: 100%; height: auto; max-height: 160px; object-fit: contain; object-position: left center }
.login-wordmark { font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: var(--accent-ink) }
.login-by { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 26px; font-size: 12px; color: var(--muted) }
.login-by .brand, .login .login-by .brand { min-height: 0; margin: 0 }
.brand-small img { height: 18px }
.login-agency img { width: 70px; height: auto }
.login-branded h1 { color: var(--ink) }
.brand-client { display: flex; flex-direction: column; gap: 4px; min-width: 0 }
.brand-client img { max-height: 40px; max-width: 200px; object-fit: contain; object-position: left center; display: block }
.brand-client .wordmark { font-size: 17px; color: var(--accent-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.brand-client small { font-size: 10.5px; color: var(--muted); letter-spacing: .01em; white-space: nowrap }

/* Erste Anmeldung (/willkommen) und Hinweistexte */
.onboarding { max-width: 720px; margin: 6vh auto 0; display: flex; flex-direction: column; gap: 16px }
.onboarding .panel + .panel { margin-top: 0 }
.onboarding-foot { display: flex; flex-direction: column; gap: 6px; max-width: 360px }
.notice-scroll { max-height: 46vh; overflow-y: auto; padding: 4px 16px 4px 0; margin-bottom: 16px; border-bottom: 1px solid var(--hair) }
.notice-text { font-size: 14px; line-height: 1.6; color: var(--ink-soft) }
.notice-text h3 { color: var(--ink); font-size: 14.5px; margin: 16px 0 4px }
.notice-text h3:first-child { margin-top: 4px }
.notice-text p { margin: 0 0 8px; max-width: 72ch }
.notice-text ul { margin: 0 0 8px; padding-left: 18px }
@media (max-width: 600px) { .onboarding { margin-top: 2vh } .onboarding-foot { max-width: none } }
.notice-preview { border: 1px solid var(--hair); border-radius: 10px; padding: 8px 14px; max-height: 40vh; overflow-y: auto }

/* Verwaltung › Kunde › Kundenportal-Design */
.ad-design { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: stretch; padding: 12px 6px 0 }
.ad-logo { border: 1px solid var(--hair); border-radius: 10px; min-height: 76px; display: grid; place-items: center; padding: 10px; background: #FFFFFF }
.ad-logo.dark { background: #1B201E }
.ad-logo img { max-height: 54px; max-width: 100%; object-fit: contain }
.ad-swatch { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 0 8px }
.ad-color { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--hair) }
@media (max-width: 560px) { .ad-design { grid-template-columns: minmax(0, 1fr) } .ad-swatch { flex-direction: row } }
.hexrow { display: flex; gap: 8px; align-items: center }
.colorpick { width: 44px; height: 40px; padding: 2px; border: 1px solid var(--track); border-radius: var(--r-in); background: var(--sheet); flex: 0 0 auto }
.nav a.sub.deep { padding-left: 58px; font-size: 13px; color: var(--muted); padding-top: 5px; padding-bottom: 5px }
.nav a.sub.deep .icon { width: 14px; height: 14px; opacity: .8 }
.nav a.sub.deep.active { color: var(--accent-ink) }
.nav a.sub.deep .t { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.3 }

/* Rechtliche Links am Seitenende (LEGAL_LINKS) */
.legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 48px 0 0; padding-top: 18px; border-top: 1px solid var(--hair); font-size: 12px }
.legal-links a { color: var(--muted); text-decoration: none }
.legal-links a:hover { color: var(--ink); text-decoration: underline }
.login .legal-links { border-top: 0; margin-top: 18px; padding-top: 0 }

/* Kleiner Datenschutz-Hinweis (PRIVACY_URL) */
.privacy-banner {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; max-width: 420px;
  display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 16px;
  background: var(--sheet); border: 1px solid var(--hair); border-radius: 14px; box-shadow: var(--shadow-pop);
  font-size: 13px; line-height: 1.45; color: var(--ink);
}
.privacy-banner p { margin: 0 }
.privacy-banner a { color: inherit; text-decoration: underline }
.privacy-banner .btn { flex: none }
@media (max-width: 900px) {
  .privacy-banner { left: 12px; right: 12px; max-width: none; bottom: calc(76px + env(safe-area-inset-bottom)) }
  body.guest .privacy-banner { bottom: calc(12px + env(safe-area-inset-bottom)) }
}
