/* ==============================================================   MageCRM — Oberflaeche
   Farben kommen aus Custom Properties, damit Hell/Dunkel eine Zeile ist.
   ===================================================================== */

:root {
  /* Farben: eine Akzentfarbe, vier Bedeutungsfarben, drei Grautoene. */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --border-strong: #c5cbd3;
  --text: #1a1d21;
  --text-dim: #565c63;
  --text-faint: #686e75;
  --accent: #3350c4;
  --accent-hover: #2a43a8;
  --accent-soft: #e8edfb;
  --on-accent: #ffffff;
  --on-color: #ffffff;   /* Schrift auf frei gewaehlten Farbflaechen (Label-Chips) */
  --scrim: rgba(10, 14, 20, .55);   /* Hintergrund hinter Dialogen */
  --green: #167048;
  --green-soft: #e3f3ea;
  --red: #c4262b;
  --red-soft: #fdeced;
  --amber: #9a5a00;
  --amber-soft: #fcf1dc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .22);
  --sidebar-bg: color-mix(in srgb, var(--surface) 94%, var(--accent));
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --focus: 0 0 0 3px rgba(51, 80, 196, .35);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23565c63' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* Abstandsskala (4er-Raster). */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* Schriftskala. */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-2xl: 26px;

  --card-pad: 20px;
  --radius: 14px;
  --radius-sm: 8px;
  --control-h: 40px;
  --control-h-sm: 30px;
  --sidebar-w: 232px;
  --topbar-h: 57px;
  /* Hoehe der mobilen Unten-Navigation ohne den Sicherheitsabstand des Geraets. */
  --unten-nav-h: 60px;
}

/* hidden gilt immer: Klassen mit display (row, flex, grid, badge) duerfen es nicht ueberschreiben. */
[hidden] { display: none !important; }


@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151d;
    --surface: #1a202b;
    --surface-2: #232b38;
    --border: #333d4d;
    --border-strong: #3c434a;
    --text: #eceef0;
    --text-dim: #b4b9be;
    --text-faint: #939aa1;
    --accent: #8ba2f5;
    --accent-hover: #a5b7f8;
    --accent-soft: #1f2744;
    --on-accent: #0e1226;
    --green: #4cc38a;
    --green-soft: #15291f;
    --red: #ff7a7f;
    --red-soft: #2e1719;
    --amber: #f1a93b;
    --amber-soft: #2c2010;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
    --focus: 0 0 0 3px rgba(139, 162, 245, .4);
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23b4b9be' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

* { box-sizing: border-box; }

:root { color-scheme: light dark; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: var(--fs-2xl); letter-spacing: -.035em; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}
::selection { background: var(--accent-soft); }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus {
  position: fixed; left: 16px; top: 12px; z-index: 100;
  padding: var(--sp-3) 20px; background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

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

#app { min-height: 100vh; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  /* Die Seitenleiste ist klebend und hoechstens so hoch wie der Bildschirm;
     der Hintergrund der Spalte gehoert deshalb dem Raster, damit er auch auf
     langen Seiten bis ganz nach unten reicht. */
  background-image: linear-gradient(to right,
    var(--sidebar-bg) calc(var(--sidebar-w) - 1px), var(--border) calc(var(--sidebar-w) - 1px),
    var(--border) var(--sidebar-w), transparent var(--sidebar-w));
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  /* Schmale Laufleiste, die nur im Abstand zum Rand sichtbar wird (hell wie dunkel). */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.sidebar:hover, .sidebar:focus-within {
  scrollbar-color: color-mix(in srgb, var(--text-faint) 55%, transparent) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
.sidebar:hover::-webkit-scrollbar-thumb, .sidebar:focus-within::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-faint) 55%, transparent);
}

.brand {
  display: flex;
  align-items: center;
  min-height: var(--topbar-h);
  padding: 0 var(--sp-4) 0 18px;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.01em;
  border-bottom: 1px solid var(--border);
}
.brand span { color: var(--accent); }

.org-switch { padding: var(--sp-3); border-bottom: 1px solid var(--border); }
.org-switch select { border-color: var(--border); background-color: var(--surface-2); font-size: var(--fs-sm); }

.nav { padding: var(--sp-2); flex: 1; }
.nav a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  padding: 9px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: var(--fs-md);
  position: relative;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav .group {
  padding: var(--sp-4) 10px var(--sp-1);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  font-weight: 600;
}
.nav .count {
  font-size: var(--fs-xs);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 10px;
  color: var(--text-faint);
}

.sidebar-foot {
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-dim);
}
.sidebar-foot .btn-ghost { margin-top: var(--sp-1); }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--topbar-h);
  padding: var(--sp-2) var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.search-wrap { position: relative; flex: 0 1 460px; }
.search-wrap input { width: 100%; }
.topbar .search-wrap input { background-color: var(--surface-2); border-color: transparent; }
.topbar .search-wrap input:focus { border-color: var(--accent); background-color: var(--surface); }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 40;
}
.search-results button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  color: var(--text);
  font-size: var(--fs-sm);
}
.search-results button:hover, .search-results button:focus-visible { background: var(--surface-2); border-radius: 0; }
.content {
  padding: clamp(20px, 2vw, 40px);
  flex: 1;
  min-width: 0;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}
.page-head h1 { line-height: 1.25; overflow-wrap: anywhere; }
.page-head .sub { color: var(--text-dim); font-size: var(--fs-sm); margin-top: 2px; }
.page-head > div:first-child { min-width: 0; }

/* Gemeinsame Orientierung fuer alle Arbeitsbereiche. */
.page-context { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: var(--fs-sm); }
.page-context-section { color: var(--text-dim); white-space: nowrap; }
.page-context-separator { color: var(--border-strong); }
.page-context-title { font-weight: 600; white-space: nowrap; }
.attention-panel {
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
  margin-bottom: var(--sp-5);
}
.attention-panel p { margin: 6px 0 var(--sp-4); }
.attention-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--sp-3); }
.attention-link {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3);
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text);
}
.attention-link:hover { background: var(--accent-soft); text-decoration: none; }
.attention-link strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.attention-link span:last-child { margin-left: auto; color: var(--text-dim); }

/* Projektkarten nutzen die verfuegbare Breite ohne gequetschte Titel. */
.projects-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 20px; padding: 20px; }
.projects-search { flex: 1 1 280px; max-width: 440px; }
.projects-search label { display: block; font-size: var(--fs-sm); margin-bottom: 6px; font-weight: 600; }
.projects-filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.projects-filters button { border-color: var(--border); background: transparent; }
.projects-filters button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.projects-filters .count { padding: 0 5px; font-variant-numeric: tabular-nums; }
.projects-result-meta { margin: 20px 0 var(--sp-3); }
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 20px; }
.project-card { display: flex; flex-direction: column; gap: 20px; padding: 22px; min-width: 0; }
.projects-grid > .card.project-card { margin-top: 0; }
.project-card.needs-attention { border-top: 3px solid var(--amber); padding-top: 20px; }
.project-card-head { display: flex; align-items: flex-start; gap: var(--sp-3); }
.project-title { flex: 1; min-width: 0; }
.project-title h2 { margin-top: var(--sp-1); overflow-wrap: anywhere; }
.project-title h2 a { color: var(--text); }
.project-title h2 a:hover { color: var(--accent); }
.project-color { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; margin-top: 7px; }
.project-card-head .badge { max-width: 42%; white-space: normal; }
.project-card-context { display: flex; flex-direction: column; gap: var(--sp-1); overflow-wrap: anywhere; }
.project-progress { margin-top: auto; }
.project-progress .bar { margin-top: var(--sp-2); height: 6px; }
.project-card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); border-top: 1px solid var(--border); padding-top: var(--sp-4); }
.project-open { margin-left: auto; font-weight: 600; }
.projects-empty { margin-top: 20px; }

/* -------------------------------------------------------------- Bausteine */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: var(--card-pad); }
.card + .card { margin-top: var(--sp-4); }
.card h2 { line-height: 1.35; }
.card:focus-within { border-color: var(--border-strong); }
.card.clickable { transition: border-color .15s, box-shadow .15s; }
.card.clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }
.card-pad > h2:first-child { margin-bottom: 2px; }

.grid { display: grid; gap: var(--sp-4); }
.grid > .card { margin-top: 0; min-width: 0; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); margin-bottom: var(--sp-4); }

.stat { padding: var(--sp-4); border-top: 3px solid var(--border-strong); min-width: 0; container-type: inline-size; }
.stat .label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  font-weight: 600;
}
.stat .value { font-size: clamp(18px, 13cqw, 28px); white-space: nowrap; font-weight: 650; margin-top: var(--sp-2); letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .hint { font-size: var(--fs-xs); color: var(--text-dim); margin-top: var(--sp-1); }
a.stat-link { display: block; color: inherit; text-decoration: none; }
a.stat-link:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
a.stat-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Name als Link in einer klickbaren Zeile: wirkt wie Text, bis man darauf zeigt. */
a.zeilen-link { color: inherit; font-weight: inherit; }
a.zeilen-link:hover { color: var(--accent); text-decoration: underline; }

/* Formulare und Buttons */

input, select, textarea {
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 var(--sp-3);
  min-height: var(--control-h);
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
textarea { padding: var(--sp-2) var(--sp-3); min-height: 88px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--text-faint); opacity: 1; font-weight: 400; }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}
input:disabled, select:disabled, textarea:disabled {
  background-color: var(--surface-2);
  color: var(--text-dim);
  cursor: not-allowed;
}
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--red); }
select {
  appearance: none;
  padding-right: var(--sp-6);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
}
select[multiple] { background-image: none; padding-right: var(--sp-3); }
input[type=checkbox], input[type=radio] {
  width: 16px;
  min-height: 16px;
  height: 16px;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}
input[type=color] { padding: 2px; width: 48px; cursor: pointer; }
input[type=search] { -webkit-appearance: none; appearance: none; }
label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-dim); margin-bottom: var(--sp-1); }
label.row, label.check { display: flex; font-weight: 500; color: var(--text); margin: 0 0 var(--sp-2); cursor: pointer; }
label.row { gap: var(--sp-2); align-items: center; }
.field { margin-bottom: var(--sp-3); }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

button, .btn, a:where([class*="btn-"]) {
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 0 var(--sp-4);
  min-height: var(--control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
a.btn, a:where([class*="btn-"]) { line-height: 1.2; }
button:hover, .btn:hover, a:where([class*="btn-"]):hover { background: var(--surface-2); text-decoration: none; }
button:active, .btn:active { background: var(--border); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover, .btn-primary:active { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--red); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-sm { padding: 0 var(--sp-3); min-height: var(--control-h-sm); font-size: var(--fs-sm); }
.btn-ghost { border-color: transparent; background: none; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* Tabellen */

.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
th {
  text-align: left;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  font-weight: 600;
  padding: 10px var(--sp-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
td { padding: 11px var(--sp-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
tbody tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; box-shadow: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.card > .table-wrap th:first-child:not(.prio-cell), .card > .table-wrap td:first-child:not(.prio-cell) { padding-left: var(--card-pad); }
.card > .table-wrap th:last-child, .card > .table-wrap td:last-child { padding-right: var(--card-pad); }
/* Kopfzeile bleibt sichtbar, wenn eine lange Liste im Rahmen scrollt. */
@media (min-width: 861px) {
  .table-wrap { max-height: min(74vh, 780px); overflow: auto; }
  .table-wrap thead th { position: sticky; top: 0; z-index: 2; }
  .table-wrap.fliesst { max-height: none; }
  .table-wrap:not(.no-sticky) thead th { box-shadow: 0 1px 0 var(--border-strong); border-bottom: 0; }
}

/* Chips, Badges */

.badge {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  padding: 1px 9px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.label-chip {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 4px;
  color: var(--on-color);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .35);
}

.prio { width: 3px; border-radius: 2px; align-self: stretch; }
.prio-0 { background: var(--border); }
.prio-1 { background: var(--accent); }
.prio-2 { background: var(--amber); }
.prio-3 { background: var(--red); }

/* Kanban */

.board {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-3);
  align-items: flex-start;
}
.board-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 288px;
  flex: 0 0 288px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 190px);
}
.board-col.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.board-col-head {
  padding: 10px var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.board-col-head .count { font-size: var(--fs-xs); color: var(--text-dim); font-weight: 500; background: var(--surface); border-radius: 10px; padding: 0 7px; }
.board-col-head .sum { font-size: var(--fs-xs); color: var(--text-dim); font-weight: 500; margin-left: auto; font-variant-numeric: tabular-nums; }
.board-col-body { padding: var(--sp-2); overflow-y: auto; flex: 1; min-height: 60px; }

.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 10px;
  margin-bottom: var(--sp-2);
  cursor: grab;
  display: flex;
  gap: var(--sp-2);
  box-shadow: var(--shadow);
}
.board-card:active { cursor: grabbing; }
.board-card:hover { border-color: var(--border-strong); }
.board-card.dragging { opacity: .4; }
.board-card .body { flex: 1; min-width: 0; }
.board-card .title { font-weight: 550; font-size: var(--fs-sm); word-break: break-word; }
.board-card .meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: var(--fs-xs);
  color: var(--text-dim);
}
.board-card .value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-dim); }

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh var(--sp-4) var(--sp-5);
  animation: fade-in .15s ease-out;
  overflow-y: auto;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  animation: pop-in .16s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal.wide { max-width: 760px; }
.modal-head {
  padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: var(--sp-5); }
.modal-foot {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 12px 12px;
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

/* Zustaende */

.empty { padding: 40px var(--sp-5); text-align: center; color: var(--text-dim); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty .btn, .empty button { margin-top: var(--sp-3); }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
  border: 1px solid transparent;
}
.alert.error { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.alert.ok { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.alert.warn { background: var(--amber-soft); color: var(--amber); border-color: var(--amber); }
.alert.warn a, .alert.error a { color: inherit; text-decoration: underline; }
/* Support-Sitzung (SAS-4): Farbe fuer Bedeutung, nicht zur Dekoration. */
.alert.support-leiste {
  background: var(--amber-soft); color: var(--amber); border-color: var(--amber);
  margin: 0; border-radius: 0; display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap;
}

.toast {
  pointer-events: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px var(--sp-4);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-md);
  max-width: min(380px, calc(100vw - 32px));
  animation: pop-in .18s ease-out;
}
.toast.error { border-left-color: var(--red); }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
/* Teilaufgaben als Checkliste im Aufgabendialog */
/* .teil-zeile davor: label:has(> input[type=checkbox]) macht sonst einen Block daraus. */
.teil-zeile .teil-haken { display: inline-flex; align-items: center; justify-content: center; margin: 0 var(--sp-2) 0 0; vertical-align: middle; }
.teil-zeile .teil-haken input { width: auto; }
@media (pointer: coarse) { .teil-zeile .teil-haken { min-width: 44px; margin: 0; } .teil-zeile .teil-haken input { width: 20px; height: 20px; } }
.teil-zeile.erledigt a { color: var(--text-faint); text-decoration: line-through; }
.small { font-size: var(--fs-sm); }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.overdue { color: var(--red); font-weight: 600; }

.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 4px; }

/* Balkendiagramm fuer gewonnene Deals */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; border-bottom: 1px solid var(--border); }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.chart .col > div { background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .9; }
.chart .col:hover > div { opacity: 1; }
.chart .lbl { font-size: var(--fs-xs); color: var(--text-dim); text-align: center; margin-top: var(--sp-1); }
.chart-labels { display: flex; gap: 6px; }
.chart-labels .lbl { flex: 1; font-size: var(--fs-xs); color: var(--text-dim); text-align: center; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* Anmeldeseite */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card { width: 100%; max-width: 420px; padding: var(--sp-6); }
.auth-card h1 { margin-bottom: var(--sp-3); }
.auth-card .brand { border: 0; justify-content: center; font-size: 24px; padding: 0; min-height: 0; margin-bottom: var(--sp-1); }
.auth-card .tagline { text-align: center; color: var(--text-dim); margin-bottom: var(--sp-5); font-size: var(--fs-sm); }
.auth-switch { text-align: center; margin-top: 14px; font-size: var(--fs-sm); }

/* Detailseiten */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: var(--sp-5); align-items: start; }
.detail-grid > .card { margin-top: 0; }
.detail-grid > div > .card:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: var(--sp-2) var(--sp-3); font-size: var(--fs-md); margin: 0; }
.kv dt { color: var(--text-dim); font-size: var(--fs-sm); }
.kv dd { margin: 0; word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 11px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font-size: var(--fs-xs); color: var(--text-dim); }
.timeline .who { font-weight: 600; font-size: var(--fs-sm); }

.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); overflow-x: auto; }
.tabs button {
  border: 0;
  background: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-dim);
  font-size: var(--fs-md);
  min-height: 40px;
  flex: 0 0 auto;
}
.tabs button:hover { background: none; color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.loading { padding: 48px; text-align: center; color: var(--text-dim); }
.loading::before {
  content: "";
  display: block;
  width: 22px;
  height: 22px;
  margin: 0 auto var(--sp-3);
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- Schmal */

@media (max-width: 860px) {
  /* auto 1fr: bei kurzen Seiten wuchs sonst die Kopfzeile mit (freier Platz wurde auf beide Zeilen verteilt). */
  /* Keine Seitenleiste: die Navigation steht unten (.unten-nav, Abschnitt am Ende). */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  .sidebar { display: none; }
  .nav { padding: var(--sp-2) var(--sp-3) var(--sp-4); flex: none; }
  .nav a { padding: 10px var(--sp-3); font-size: var(--fs-lg); }
  .nav a.active::before { left: -12px; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .field-row { grid-template-columns: 1fr; }
  .content { padding: var(--sp-4) var(--sp-3) var(--sp-6); }
  .page-head { margin-bottom: var(--sp-4); }
  .board-col { max-height: none; width: 84vw; flex-basis: 84vw; }
  .modal-backdrop { padding: var(--sp-3); }
  .modal-body { padding: var(--sp-4); }
  .kv { grid-template-columns: 112px minmax(0, 1fr); }
  /* 16 px verhindert das automatische Hineinzoomen auf dem iPhone. */
  input, select, textarea { font-size: var(--fs-lg); }
}

/* ==============================================================   Ergaenzungen: Formularraster, Benachrichtigungen, Belege, Portal
   ===================================================================== */

/* ---------------------------------------------------------- Hilfsklassen */

.mb { margin-bottom: 10px; }
.mb-xs { margin-bottom: var(--sp-1); }
.mt { margin-top: 14px; }
.mt-sm { margin-top: var(--sp-2); }
.mt-xs { margin-top: var(--sp-1); }
.mt-card { margin-top: var(--sp-4); }
.grow { flex: 1; min-width: 0; }
.strong { font-weight: 650; }
.full { width: 100%; }
.center { text-align: center; }
.flush { padding-left: 0; }
.tight { padding: 0 var(--sp-1); }
.narrow { max-width: 130px; }
.auto { width: auto; }
.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.row.top { align-items: flex-start; }
.pre { white-space: pre-wrap; word-break: break-word; }
.clip { overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
        -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.done { text-decoration: line-through; opacity: .6; }
.crumb { font-size: var(--fs-sm); color: var(--text-dim); margin-bottom: 2px; }
.crumb a { color: var(--text-dim); }
.crumb a:hover { color: var(--accent); }
.key { font-size: var(--fs-lg); font-weight: 500; }
.big-value { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -.02em; }
.section-head { border-bottom: 1px solid var(--border); }
.card-pad.section-head, .row.section-head { padding: var(--sp-3) var(--card-pad); min-height: 56px; }
.section-head h2 { font-size: var(--fs-lg); }
.card .section-head + .table-wrap table tbody tr:first-child td { border-top: 0; }
.prio-cell { width: 4px; padding: 0 !important; }
.prio-cell .prio { min-height: 38px; height: 100%; }
.progress-cell { min-width: 150px; }
.funnel-row { margin-bottom: 10px; }
.deal-head { align-items: flex-end; gap: var(--sp-5); }
.toolbar { border-bottom: 1px solid var(--border); gap: var(--sp-2); }
.toolbar select.auto, .toolbar input.auto { width: auto; min-width: 140px; }
.toolbar input[type=search] { max-width: 300px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-wrap { display: inline-flex; align-items: center; gap: 2px; }
.scroll-box { max-height: 220px; overflow-y: auto; }
.mail-body { max-height: 45vh; overflow-y: auto; background: var(--surface-2);
             border-radius: 6px; padding: var(--sp-3); margin-top: var(--sp-3); font-size: var(--fs-sm); }
.reply-box textarea { font-size: 13.5px; }
.reply-box .tabs { margin-bottom: var(--sp-3); }
.reply-box[data-modus="notiz"] .rt { border-left: 3px solid var(--amber); background: var(--amber-soft); }
.reply-hinweis { flex: 1 1 14rem; }
/* Geteilter Knopf: Hauptaktion links, Menue mit Folgeaktionen rechts. */
.btn-split { display: inline-flex; align-items: stretch; }
.btn-split > .btn-primary { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-split > .item-more > summary.btn-primary {
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  border-left: 1px solid rgba(255, 255, 255, .45); height: 100%;
}
.btn-split .caret {
  width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}
.item-menu.nach-oben { top: auto; bottom: calc(100% + 4px); }
.timeline li.internal { border-left: 2px solid var(--amber); padding-left: 10px; }

/* Kontrollkaestchen mit Beschriftung */
label.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
              font-weight: 500; color: var(--text); margin: 0; }
label.check input { width: auto; }
label.check.inline { margin: 0 10px var(--sp-1) 0; }
label.check.small { font-size: var(--fs-sm); }

/* --------------------------------------------------------- Formularraster */

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--sp-3); }
.field-grid > .field { grid-column: 1 / -1; }
.field-grid > .field.half { grid-column: span 1; }
.field .hint { margin-top: 3px; }
.modal.narrow { max-width: 420px; }

/* ---------------------------------------------------- Stoppuhr (ADR-0209) */

.zeit-uhr { flex: none; }
.zeit-uhr[hidden] { display: none; }
.uhr-lauf { display: flex; align-items: center; gap: var(--sp-2); padding: 2px var(--sp-2); border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.uhr-punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: uhr-puls 1.6s ease-in-out infinite; }
.uhr-ziel { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uhr-start .icon { margin-right: 4px; }
@keyframes uhr-puls { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .uhr-punkt { animation: none; } }
@media (max-width: 860px) {
  .uhr-ziel, .uhr-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .topbar.suche-offen .zeit-uhr { display: none; }
  .uhr-start { min-width: 44px; min-height: 44px; justify-content: center; }
  .uhr-lauf .btn { min-height: 36px; }
}

/* ---------------------------------------------------- Benachrichtigungen */

.bell-wrap { position: relative; }
.badge-count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--red);
  color: var(--surface);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
  line-height: 18px;
}
.badge-count[hidden] { display: none; }
.notif-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 340px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
}
.notif-head { padding: 10px var(--sp-3); border-bottom: 1px solid var(--border); }
.notif {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: none;
  padding: 10px var(--sp-3);
  cursor: pointer;
  color: var(--text);
}
.notif:hover { background: var(--surface-2); }
.notif.unread { border-left: 3px solid var(--accent); }
.notif .t { font-size: var(--fs-sm); font-weight: 550; }
.notif .w { margin-top: 3px; }
.no-hits { padding: var(--sp-3); }
.search-results .kind {
  display: inline-block;
  min-width: 62px;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
}
.search-results .hit { font-weight: 500; }

/* ------------------------------------------------------ Positionseditor */

.items { display: grid; gap: var(--sp-2); }
.items-row {
  display: grid;
  grid-template-columns: 24px 88px 88px 120px 80px 80px minmax(96px, 1fr) auto;
  grid-template-areas:
    "grip desc desc desc desc desc desc act"
    "grip qty unit price tax disc amount .";
  gap: var(--sp-1) var(--sp-2);
  align-items: end;
  padding: var(--sp-2) 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.items-row:last-child { border-bottom: 0; }
.items-row > .item-grip { grid-area: grip; align-self: stretch; }
.items-row > .item-desc { grid-area: desc; position: relative; min-width: 0; }
.items-row > .item-actions { grid-area: act; justify-self: end; align-self: start; display: flex; gap: 2px; }
.items-row > .ic-qty { grid-area: qty; }
.items-row > .ic-unit { grid-area: unit; }
.items-row > .ic-price { grid-area: price; }
.items-row > .ic-tax { grid-area: tax; }
.items-row > .ic-disc { grid-area: disc; }
.items-row > .ic-amount { grid-area: amount; }
.items-row > .item-differenz {
  grid-column: 2 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: end;
  padding-top: var(--sp-1);
}
.item-differenz .ic { min-width: 160px; }
.item-differenz input[type=checkbox] { min-height: 0; width: 16px; height: 16px; }
.items-row-title, .items-row-text {
  grid-template-areas: "grip desc desc desc desc desc desc act";
  align-items: start;
}
.items-row-subtotal {
  grid-template-areas: "grip label label label label label amount act";
  align-items: end;
  border-top: 1px solid var(--border-strong);
}
.items-row-subtotal > .ic-label { grid-area: label; }
.items-row-title { background: var(--surface-2); border-radius: var(--radius-sm); padding-inline: var(--sp-2); border-bottom: 0; }
.ic { display: grid; gap: 2px; min-width: 0; font-weight: 400; }
.ic-l { font-size: var(--fs-xs); color: var(--text-dim); font-weight: 500; }
.ic-amount .amount { text-align: right; min-height: 32px; line-height: 32px; font-size: var(--fs-md); }
.ic-amount .ic-l { text-align: right; }
.items-row input, .items-row textarea { font-size: var(--fs-sm); }
.items-row input { padding: 0 var(--sp-2); min-height: 32px; }
.items-row input.num { text-align: right; }
.item-text {
  display: block;
  width: 100%;
  box-sizing: border-box;
  resize: none;
  overflow: hidden;
  min-height: 32px;
  padding: 6px var(--sp-2);
  line-height: 1.45;
  font: inherit;
  font-size: var(--fs-sm);
  field-sizing: content;
}
.item-title { font-weight: 600; }
.item-grip {
  width: 24px;
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  min-height: 32px;
}
.item-grip span {
  width: 10px;
  height: 16px;
  background-image: radial-gradient(circle, var(--text-faint) 1.3px, transparent 1.6px);
  background-size: 5px 5px;
}
.item-grip:hover span, .item-grip:focus-visible span { background-image: radial-gradient(circle, var(--text) 1.3px, transparent 1.6px); }
.items-row.ziehen { opacity: .45; }
.items-row.drop-vor { box-shadow: 0 -2px 0 0 var(--accent); }
.items-row.drop-nach { box-shadow: 0 2px 0 0 var(--accent); }
.item-del { font-size: var(--fs-lg); line-height: 1; }
.item-more { position: relative; }
.item-more > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; }
.item-more > summary::-webkit-details-marker { display: none; }
.item-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 220px;
  display: grid;
  padding: var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.item-menu button {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  align-items: center;
  text-align: left;
  border: 0;
  background: none;
  color: var(--text);
  padding: 6px var(--sp-2);
  border-radius: 6px;
  font-size: var(--fs-sm);
  min-height: 32px;
  cursor: pointer;
}
.item-menu button:hover:not(:disabled), .item-menu button:focus-visible { background: var(--surface-2); }
.item-menu button:disabled { color: var(--text-faint); cursor: default; }
.item-menu button.danger { color: var(--red); }
.item-menu-sep { font-size: var(--fs-xs); color: var(--text-faint); padding: var(--sp-2) var(--sp-2) 2px; }
.item-menu-sep:empty { border-top: 1px solid var(--border); margin: var(--sp-1) 0; padding: 0; }
kbd {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 2px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.item-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 30;
  margin: 0;
  padding: var(--sp-1);
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
}
.item-suggest li {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 6px var(--sp-2);
  border-radius: 6px;
  cursor: pointer;
  font-size: var(--fs-sm);
}
.item-suggest li[aria-selected="true"] { background: var(--accent-soft); }
.item-suggest .s-titel { font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.item-suggest .s-detail { color: var(--text-dim); white-space: nowrap; font-size: var(--fs-xs); align-self: center; }
.items-undo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
.items-undo[hidden] { display: none; }
.items-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.items-tools { flex-wrap: wrap; gap: var(--sp-2); }
.items-hint { margin: var(--sp-2) 0 0; }
.kbd-table { width: 100%; border-collapse: collapse; }
.kbd-table th, .kbd-table td { padding: 6px var(--sp-2); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-size: var(--fs-sm); }
.kbd-table th { white-space: nowrap; font-weight: 500; }
.items-dialog { z-index: 130; }
.tabelle-optionen { gap: var(--sp-4); flex-wrap: wrap; align-items: center; margin: var(--sp-3) 0; }
.tabelle-vorschau { max-height: 46vh; overflow: auto; }
.tabelle-tab { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tabelle-tab th, .tabelle-tab td { padding: var(--sp-1) var(--sp-2); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tabelle-tab td.num, .tabelle-tab th.num { text-align: right; white-space: nowrap; }
.tabelle-tab tr.fehler td { background: var(--red-soft); }
.tabelle-tab select { min-height: 30px; font-size: var(--fs-xs); min-width: 120px; }
.tabelle-fehler { color: var(--red); white-space: normal; }
/* Anzeige eines mehrzeiligen Positionstextes (Detail, Portal, Beleg). */
.pos-titel { font-weight: 550; overflow-wrap: anywhere; }
.pos-text { color: var(--text-dim); font-size: var(--fs-sm); margin-top: 2px; }
.pos-text p { margin: 0 0 var(--sp-1); }
.pos-liste { margin: 0 0 var(--sp-1); padding-left: var(--sp-5); }
.pos-zeile-titel td { background: var(--surface-2); padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.pos-zeile-text td { color: var(--text-dim); }
.pos-zeile-summe td { border-top: 1px solid var(--border-strong); }
@media (max-width: 640px) {
  .items-table tbody tr.pos-zeile-summe td:nth-child(3) { color: var(--text); font-size: inherit; margin-left: auto; font-weight: 600; }
  .items-table tbody tr.pos-zeile-summe td:nth-child(2) { flex: 0 1 auto; margin-left: auto; }
}
@media print {
  .pos-text { color: var(--text-dim); }
  .pos-zeile-titel td { background: none; }
}

.totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 20px;
  max-width: 320px;
  margin-left: auto;
  font-size: 13.5px;
}
.totals dt { color: var(--text-dim); }
.totals dd { margin: 0; text-align: right; }
.totals dt.strong, .totals dd.strong {
  border-top: 1px solid var(--border);
  padding-top: 5px;
  margin-top: 3px;
  font-size: 15px;
}

.items-table tfoot td { border-bottom: 0; padding: var(--sp-1) var(--sp-3); }
.items-table tfoot tr.grand td {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-2);
  font-size: 15px;
}

/* ------------------------------------------------------------- Belege */

.doc-wrap { max-width: 820px; margin: 0 auto; padding: 28px var(--sp-4) 60px; }
.doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 40px;
}
.doc-head { margin-bottom: 28px; }
.doc-org { font-weight: 700; font-size: var(--fs-lg); margin-bottom: 18px; }
.doc-title h1 { font-size: 22px; }
.doc-intro { margin-bottom: 20px; }
.doc-terms { margin-top: var(--sp-5); padding-top: 14px; border-top: 1px solid var(--border); }
.doc-paid { margin-top: var(--sp-3); text-align: right; color: var(--text-dim); }
.doc-foot {
  margin-top: 28px;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: flex-end;
}
@media (max-width: 480px) {
  .doc-foot > button { flex: 1 1 100%; }
}

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

.portal-wrap { max-width: 1000px; margin: 0 auto; padding: var(--sp-5) var(--sp-4) 60px; }
.portal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.portal-head .brand { padding: 0; border: 0; font-size: 19px; }


/* ------------------------------------------------- Formatierter Freitext */
/* ADR 0095. .richtext ist die Typografie fuer Editor UND Anzeige, damit
   Bearbeiten, Vorschau und PDF dasselbe zeigen. */

.richtext { line-height: 1.5; overflow-wrap: anywhere; }
.richtext > :first-child { margin-top: 0; }
.richtext > :last-child { margin-bottom: 0; }
.richtext p { margin: 0 0 .6em; }
.richtext h3 { font-size: 1.1em; margin: .9em 0 .35em; }
.richtext ul, .richtext ol { margin: 0 0 .6em; padding-left: 1.5em; }
.richtext ul ul, .richtext ol ol, .richtext ul ol, .richtext ol ul { margin: .15em 0 0; }
.richtext li { margin: .1em 0; }
.richtext a { color: var(--accent); text-decoration: underline; }

.rt {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  transition: border-color .12s, box-shadow .12s;
  min-width: 0;
}
.rt:hover { border-color: var(--text-faint); }
.rt:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.rt-bar {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: var(--sp-1);
  border-bottom: 1px solid var(--border);
  background-color: var(--surface-2);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.rt-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text-dim); cursor: pointer;
}
.rt-btn:hover { background: var(--surface); color: var(--text); }
.rt-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.rt-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.rt-area {
  padding: var(--sp-2) var(--sp-3);
  min-height: 9em; max-height: 60vh;
  overflow: auto; resize: vertical;
  outline: none; color: var(--text);
}
.rt-area:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint); pointer-events: none;
}
.rt-link {
  display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center;
  padding: var(--sp-2); border-top: 1px solid var(--border);
}
.rt-link[hidden] { display: none; }
.rt-link input { flex: 1 1 200px; min-width: 0; }
@media (max-width: 480px) {
  .rt-btn { min-width: 40px; height: 40px; }
  .rt-area { font-size: var(--fs-lg); }
}

/* -------------------------------------------------------------- Drucken */

@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #fff; --border: #ccc;
    --text: #000; --text-dim: #333; --text-faint: #666; --shadow: none;
  }
  body { background: #fff; }
  .no-print, .topbar, .sidebar, .toasts, .modal-backdrop, .doc-foot { display: none !important; }
  .doc, .card { border: 0; box-shadow: none; padding: 0; }
  .doc-wrap, .portal-wrap { padding: 0; max-width: none; }
  .items-table { font-size: 11pt; }
  a { color: #000; text-decoration: none; }
}

/* -------------------------------------------------------------- Schmal */

@media (max-width: 860px) {
  .field-grid { grid-template-columns: 1fr; }
  .field-grid > .field.half { grid-column: 1 / -1; }
  .notif-panel { width: calc(100vw - 32px); right: -8px; }
  .doc { padding: 20px; }
  .toolbar input[type=search] { max-width: none; }
}

/* ----------------------------------------------- Verlauf (VER-2) */

.verlauf-eintrag {
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.verlauf-eintrag:last-child { border-bottom: 0; }

/* Die Einrueckung einer Teilaufgabe in der Listenansicht (FAC-2).
   GENAU EINE STUFE — tiefer als zwei Ebenen geht es nicht (Migration
   0024), und eine Einrueckung, die mehr Stufen kennt als es Ebenen gibt,
   ist eine Einladung. */
.indent { padding-left: 2rem; }

/* FAC-1: Trefferlisten und Konzernbaum ohne Aufzaehlungszeichen */
ul.plain { list-style: none; margin: 6px 0; padding: 0; }
ul.plain li { padding: 2px 0; }

/* ------------------------------------------- Portal und Dateiauswahl */

input[type=file] { padding: 0; min-height: var(--control-h); color: var(--text-dim); }
input[type=file]::file-selector-button {
  font: inherit;
  font-weight: 550;
  height: calc(var(--control-h) - 2px);
  margin-right: var(--sp-3);
  padding: 0 var(--sp-4);
  border: 0;
  border-right: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.portal-wrap .brand { min-height: 0; }

/* Nummern und Titel im Portal sind Knoepfe, sehen aber aus wie Links; Kennzahlen springen zur Liste. */
.btn-link { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.btn-link:hover { text-decoration: underline; }
.stat-knopf { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.stat-knopf:hover { border-color: var(--accent); }
tr.klickzeile { cursor: pointer; }
tr.klickzeile:hover td { background: var(--bg-hover, rgba(127,127,127,.08)); }
.plain-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.vorschlag-text { margin: .4rem 0 .6rem; }

/* Schmale Bildschirme: Tabellenzeilen des Portals werden zu Karten, damit
   die Schaltflaechen am Zeilenende nicht aus dem Bild laufen. */
@media (max-width: 640px) {
  .portal-wrap { padding: var(--sp-4) var(--sp-3) var(--sp-6); }
  .portal-wrap .table-wrap { max-height: none; overflow: visible; }
  .portal-wrap table, .portal-wrap tbody { display: block; }
  .portal-wrap thead { display: none; }
  .portal-wrap tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-1) var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
  }
  .portal-wrap tbody tr:last-child { border-bottom: 0; }
  .portal-wrap td, .portal-wrap .card > .table-wrap td:first-child, .portal-wrap .card > .table-wrap td:last-child {
    display: block;
    padding: 0;
    border: 0;
    width: auto;
  }
  .portal-wrap td.num:last-child { margin-left: auto; }
  .portal-wrap .progress-cell { min-width: 0; flex: 1 1 100%; }
}

/* ------------------------------------------------------- Feinschliff */

label:has(> input[type=checkbox]), label:has(> input[type=radio]) {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}
.grid > .field { margin-bottom: 0; }
.section-head:has(> .btn, > button, > a.btn) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.card-pad > .empty, .card-pad > .table-wrap > .empty { padding: var(--sp-4) 0; }
.card > .card-pad + .card-pad { border-top: 1px solid var(--border); }

@media (max-width: 640px) {
  /* Positionen als Karten: Beschreibung oben, Menge, Preis und Betrag darunter. */
  .items-table, .items-table tbody, .items-table tfoot { display: block; }
  .items-table thead { display: none; }
  .items-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px var(--sp-3);
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--border);
  }
  .items-table td { display: block; padding: 0; border: 0; }
  .card > .table-wrap .items-table td:first-child, .card > .table-wrap .items-table td:last-child { padding: 0; }
  .items-table tbody td:nth-child(1):not([colspan]), .items-table tbody td:nth-child(5):not([colspan]) { display: none; }
  .items-table tbody td:nth-child(2) { flex: 1 1 100%; font-weight: 550; }
  .items-table tbody td:nth-child(3), .items-table tbody td:nth-child(4) { color: var(--text-dim); font-size: var(--fs-sm); }
  .items-table tbody td:nth-child(6) { margin-left: auto; font-weight: 600; }
  .items-table tfoot tr { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 3px 0; }
  .items-table tfoot tr.grand { border-top: 1px solid var(--border); margin-top: var(--sp-2); padding-top: var(--sp-2); }
  .items-table tfoot td { padding: 0; border: 0; }
}

.card-pad > h2 + .kv, .card-pad > h2 + dl { margin-top: var(--sp-3); }
@media (max-width: 640px) {
  td, th { padding-left: var(--sp-2); padding-right: var(--sp-2); }
  .card > .table-wrap th:first-child:not(.prio-cell), .card > .table-wrap td:first-child:not(.prio-cell) { padding-left: var(--sp-3); }
  .card > .table-wrap th:last-child, .card > .table-wrap td:last-child { padding-right: var(--sp-3); }
  td.mono.nowrap, td.num { white-space: nowrap; }
}

/* Persönliche Verbindungen (Einstellungen) */
.conn + .conn { border-top: 1px solid var(--border); }
.conn h3 { font-size: var(--fs-md, 1rem); }
.conn-caps { border: 0; padding: 0; margin: var(--sp-2) 0; }
.conn-cap { display: flex; gap: var(--sp-2); align-items: flex-start; padding: var(--sp-1) 0; cursor: pointer; }
.conn-cap input { margin-top: 3px; flex: none; }
.conn-panel { margin-top: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.conn-panel h4 { margin-bottom: var(--sp-1); }
.conn-select th:first-child, .conn-select td:first-child { width: 1%; white-space: nowrap; }
.conn-msgs { list-style: none; margin: var(--sp-2) 0 0; padding: 0; }
.conn-msg { padding: var(--sp-3) 0; border-top: 1px solid var(--border); display: grid; gap: var(--sp-2); }
.conn-msg:first-child { border-top: 0; }
/* ---- Importassistent ---- */
.import-schritte { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); list-style: none; padding: 0; margin: var(--sp-3) 0 var(--sp-4); }
.import-schritte li { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-faint); font-size: var(--fs-sm); }
.import-schritte .nr { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-strong); font-size: var(--fs-xs); }
.import-schritte li[aria-current="step"] { color: var(--text); font-weight: 600; }
.import-schritte li[aria-current="step"] .nr { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.import-schritte li.fertig .nr { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.import-kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--sp-2); margin: var(--sp-3) 0; }
.import-kachel { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: var(--sp-3); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; min-height: 56px; font: inherit; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.import-kachel span { font-size: var(--fs-xs); color: var(--text-faint); }
.import-kachel:hover { border-color: var(--border-strong); background: var(--surface-2); }
.import-kachel[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.import-kachel:focus-visible { outline: none; box-shadow: var(--focus); }
.import-hilfe { background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); margin: var(--sp-3) 0; }
.import-hilfe h4 { margin: 0 0 var(--sp-1); font-size: var(--fs-md); }
.import-hilfe p { margin: var(--sp-1) 0; }
.import-art { border: 0; padding: 0; margin: var(--sp-3) 0; display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.import-art legend { font-weight: 600; margin-bottom: var(--sp-1); padding: 0; }
.radio-zeile { display: inline-flex; align-items: center; gap: var(--sp-2); }
.import-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1); min-height: 140px; padding: var(--sp-5); text-align: center; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
.import-drop.aktiv, .import-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.import-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.import-drop:focus-within { box-shadow: var(--focus); }
.import-aktionen { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-4); }
.import-zeile2 { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; margin: var(--sp-3) 0; }
.import-felder { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--sp-3); margin: var(--sp-3) 0; }
.import-felder label { display: flex; flex-direction: column; gap: var(--sp-1); }
.import-zaehler { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-3) 0; }
.import-warnung { background: var(--amber-soft); color: var(--amber); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); }
.import-trocken { background: var(--accent-soft); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); }
.import-ok { background: var(--green-soft); color: var(--green); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); font-weight: 600; }
.import-tabelle { max-height: 420px; overflow: auto; }
.import-tabelle .zeile-fehler td { background: var(--red-soft); }
@media (max-width: 600px) { .import-aktionen > * { flex: 1 1 100%; } .import-schritte .txt { display: none; } .import-schritte li[aria-current="step"] .txt { display: inline; } }

.import-felder label .small, .import-felder label .faint { font-weight: 400; text-transform: none; letter-spacing: 0; }
@media (max-width: 600px) {
  .import-tabelle { max-height: none; overflow: visible; }
  .import-tabelle thead { display: none; }
  .import-tabelle table, .import-tabelle tbody, .import-tabelle tr, .import-tabelle td { display: block; width: 100%; }
  .import-tabelle tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: var(--sp-2); padding: var(--sp-2) var(--sp-3); background: var(--surface); }
  .import-tabelle td { padding: 2px 0; border: 0; }
  .import-tabelle td::before { content: attr(data-l) ": "; color: var(--text-faint); font-size: var(--fs-xs); }
  .import-tabelle .zeile-fehler { background: var(--red-soft); }
}
.import-warnung .btn { white-space: normal; max-width: 100%; margin: var(--sp-2) 0 0; display: block; }
/* ------------------------------------------ Verlauf und Aktivitaet (VER-2) */

/* Der Unterschied. Alt und neu sind getoent UND beschriftet (Vorher/Nachher):
   die Farbe allein darf nichts tragen. */
.vd { display: flex; flex-direction: column; margin-top: 6px; }
.vd-zeile {
  display: grid;
  grid-template-columns: minmax(96px, 0.8fr) 1.6fr 1.6fr;
  gap: var(--sp-1) var(--sp-3);
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm, 13px);
}
.vd-zeile:first-child { border-top: 0; }
.vd-feld { color: var(--text-dim); }
.vd-alt, .vd-neu { padding: 2px 6px; border-radius: var(--radius-sm, 4px); word-break: break-word; }
div.vd-alt { background: var(--red-soft); color: var(--text); }
div.vd-neu { background: var(--green-soft); color: var(--text); }
div.vd-ruhig { background: transparent; }
div.vd-alt::before, div.vd-neu::before {
  content: attr(data-label);
  display: none;
  font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em;
}
del.vd-alt { background: var(--red-soft); text-decoration: line-through; padding: 0 2px; border-radius: 3px; }
ins.vd-neu { background: var(--green-soft); text-decoration: none; padding: 0 2px; border-radius: 3px; }
.vd-text { grid-template-columns: minmax(96px, 0.8fr) 3.2fr; }
.vd-text-inhalt { line-height: 1.5; word-break: break-word; }
.vd-hinweis { margin: var(--sp-2) 0; }
.vd-anlegen .vd-zeile { grid-template-columns: minmax(96px, 0.8fr) 3.2fr; }

.vl-gruppe { padding: var(--sp-3) 0; border-top: 1px solid var(--border); }
.vl-gruppe:first-child { border-top: 0; }
.vl-kopf { display: grid; gap: var(--sp-3); align-items: baseline; justify-content: space-between; }
.vl-aktionen { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.vl-filter { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: end; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.vl-filter label { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-xs); color: var(--text-dim); }

@media (max-width: 640px) {
  .vd-zeile, .vd-text { grid-template-columns: 1fr; }
  div.vd-alt::before, div.vd-neu::before { display: block; }
  .vl-aktionen .btn, .vl-aktionen button { flex: 1 1 100%; }
}
.vd-konflikt div[data-label]::before { display: block; }
.vd-konflikt .vd-ruhig { background: var(--surface-2); }
.vd-tech { margin-top: 6px; }
.vd-tech summary { cursor: pointer; }
/* ------------------------------------------------------------ Volltextsuche */

.such-feld { margin-bottom: var(--sp-4); flex-wrap: nowrap; }
.such-feld input { flex: 1; min-width: 0; }
.such-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
.such-filter summary { cursor: pointer; padding: var(--sp-3) var(--sp-4); font-weight: 600; list-style: none; }
.such-filter summary::-webkit-details-marker { display: none; }
.such-filter summary::after { content: ""; float: right; width: 8px; height: 8px; margin-top: 5px;
  border-right: 2px solid var(--text-dim); border-bottom: 2px solid var(--text-dim); transform: rotate(45deg); }
.such-filter[open] summary::after { transform: rotate(-135deg); margin-top: 9px; }
.such-filter fieldset { border: 0; padding: 0; margin: 0 0 var(--sp-3); }
.such-filter legend { font-size: var(--fs-sm); font-weight: 600; margin-bottom: 6px; padding: 0; }
.such-art { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) 0; font-size: var(--fs-sm); cursor: pointer; }
.such-art input { width: auto; flex: none; }
.such-art .such-anzahl { margin-left: auto; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.treffer-liste { list-style: none; margin: 0; padding: 0; }
.treffer-liste li + li { border-top: 1px solid var(--border); }
.treffer { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); color: var(--text); text-decoration: none; }
.treffer:hover, .treffer:focus-visible { background: var(--surface-2); outline: none; }
.treffer:focus-visible { box-shadow: inset 3px 0 0 var(--accent); }
.treffer-icon { color: var(--text-faint); padding-top: 2px; flex: none; }
.treffer-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.treffer-kopf { display: flex; gap: var(--sp-2); align-items: baseline; flex-wrap: wrap; }
.treffer-titel { font-weight: 600; overflow-wrap: anywhere; }
.treffer-auszug { color: var(--text-dim); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.treffer-labels { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.treffer .label-chip mark, .label-chip mark { background: rgba(255, 255, 255, .3); color: inherit; text-decoration: underline; border-radius: 2px; padding: 0; box-shadow: none; }
.treffer-meta { color: var(--text-faint); font-size: var(--fs-xs); }
.treffer mark, .such-ergebnis mark { background: var(--amber-soft); color: var(--text); border-radius: 3px; padding: 0 1px;
  box-shadow: 0 0 0 1px var(--amber-soft); font-weight: inherit; }
.such-mehr { text-align: center; margin-top: var(--sp-4); }
.such-tipps { text-align: left; display: inline-block; margin: var(--sp-3) 0 0; padding-left: 20px; color: var(--text-dim); }
.such-tipps code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.alert.info { background: var(--accent-soft); color: var(--text); margin-bottom: var(--sp-3); }
.anker-treffer { animation: anker-blinken 2.4s ease-out; }
@keyframes anker-blinken { 0%, 40% { background: var(--amber-soft); } 100% { background: transparent; } }
@media (max-width: 760px) {
  .such-layout { grid-template-columns: minmax(0, 1fr); }
  .such-feld { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .anker-treffer { animation: none; background: var(--amber-soft); } }
.treffer, .treffer:hover { text-decoration: none; }

/* --- Belegvorlagen (ADR-0170 bis 0173) ------------------------------------ */
.vl-raster { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr); gap: var(--sp-5); align-items: start; }
.vl-vorschau { position: sticky; top: var(--sp-4); }
.vl-rahmen { width: 100%; height: 72vh; min-height: 420px; border: 0; background: var(--surface-2); display: block; }
.vl-abschnitt { margin-top: 0; }
.vl-abschnitt + .vl-abschnitt, .vl-pflicht + .vl-abschnitt { margin-top: var(--sp-3); }
.vl-abschnitt > summary { cursor: pointer; padding: var(--sp-3) var(--sp-4); font-weight: 600; }
.vl-name { min-width: 260px; flex: 1 1 260px; margin-bottom: 0; }
.vl-notiz { flex: 1 1 220px; min-width: 180px; }
.vl-fehler { border: 1px solid var(--red); background: var(--red-soft); color: var(--text); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); }
.vl-fehler ul { margin: var(--sp-1) 0 0 var(--sp-4); }
.vl-warn { color: var(--red); font-weight: 600; }
.vl-chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-3); }
.vl-chip { font-family: var(--font-mono, monospace); font-size: var(--fs-sm); }
.vl-fuss { align-items: center; }
.vl-fuss label { margin: 0; }
.vl-spalten input[type=text], .vl-spalten input[type=number] { width: 100%; min-width: 70px; }
tr.vl-offen td { background: var(--accent-soft); }
@media (max-width: 960px) {
  .vl-raster { grid-template-columns: minmax(0, 1fr); }
  .vl-vorschau { position: static; }
}
/* ------------------------------------- Positionstabelle: Karten auf dem Telefon */

@media (max-width: 640px) {
  .items-row {
    grid-template-columns: 28px 1fr 1fr;
    grid-template-areas:
      "grip desc desc"
      "grip qty unit"
      "grip price tax"
      "grip disc amount"
      "grip act act";
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    gap: var(--sp-2);
  }
  .items-row:last-child { border-bottom: 1px solid var(--border); }
  .items-row-title, .items-row-text {
    grid-template-areas: "grip desc desc" "grip act act";
  }
  .items-row-subtotal {
    grid-template-areas: "grip label label" "grip amount act";
  }
  .items-row > .item-actions { align-self: center; }
  .item-text { min-height: 96px; font-size: var(--fs-lg); padding: var(--sp-2) var(--sp-3); }
  .items-row-title .item-text { min-height: 44px; }
  .items-row input { min-height: 44px; font-size: var(--fs-lg); }
  .ic-l { font-size: var(--fs-sm); }
  .ic-amount .amount { min-height: 44px; line-height: 44px; }
  .item-grip { min-height: 44px; }
  /* .nach-oben mit: sonst gewinnt dessen bottom:100% und das Blatt landet ueber dem Bildschirmrand. */
  .item-menu, .item-menu.nach-oben { right: auto; left: auto; position: fixed; left: var(--sp-3); right: var(--sp-3); bottom: calc(var(--unten-nav-h) + env(safe-area-inset-bottom) + var(--sp-3)); top: auto; min-width: 0; z-index: 45; }
  .items-tools .btn { min-height: 40px; }
  .tabelle-dialog .modal-body { padding: var(--sp-3); }
}
/* Format-Schaltflaechen einer Rechnung (ZUGFERD-5) */
.format-menue { position: relative; display: inline-block; }
.format-menue > summary { list-style: none; cursor: pointer; }
.format-menue > summary::-webkit-details-marker { display: none; }
.format-menue-liste { position: absolute; z-index: 5; display: flex; gap: var(--sp-2); padding: var(--sp-2);
  margin-top: var(--sp-1); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.vl-belegwahl { display: grid; gap: var(--sp-2); }
.vl-belegwahl input[type=search] { flex: 1 1 200px; min-width: 160px; }
.vl-treffer { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.vl-treffer-knopf { display: grid; grid-template-columns: 9rem 1fr auto; gap: var(--sp-2); width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--radius, 6px); padding: var(--sp-1) var(--sp-2); cursor: pointer; color: inherit; font: inherit; }
.vl-treffer-knopf:hover, .vl-treffer-knopf.aktiv { border-color: var(--border); background: var(--surface-2); }
.vl-treffer-leer { padding: var(--sp-1) 0; }

/* Aufgabenzeilen: auf dem Telefon fällt die Spalte "Zuständig" weg, damit das Fälligkeitsdatum nicht aus dem Bild läuft. */
@media (max-width: 640px) {
  tr[data-task] td:nth-child(4) { display: none; }
  tr[data-task] td { padding-left: var(--sp-2); padding-right: var(--sp-2); hyphens: auto; overflow-wrap: break-word; }
}

/* Belegvorlagen-Liste auf dem Telefon: die Knöpfe bekommen eine eigene Zeile, statt rechts abgeschnitten zu werden. */
@media (max-width: 640px) {
  .vl-liste thead { display: none; }
  .vl-liste tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; border-bottom: 1px solid var(--border); }
  .vl-liste td { border-bottom: 0; }
  .vl-liste td:last-child { grid-column: 1 / -1; padding-top: 0; }
  .vl-liste td:last-child .row { justify-content: flex-start; flex-wrap: wrap; }
}

/* Listen als Kartenzeilen auf dem Telefon (table.karten, siehe karten.ts).
   Dasselbe Muster wie im Kundenportal: keine seitlich laufende Tabelle,
   sondern je Zeile eine Karte. Die Titelspalte steht oben, die übrigen
   Werte darunter mit ihrer Spaltenüberschrift. */
@media (max-width: 640px) {
  .table-wrap:has(> table.karten) { max-height: none; overflow: visible; }
  table.karten, table.karten tbody { display: block; width: 100%; }
  table.karten thead { display: none; }
  table.karten tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    position: relative;
  }
  table.karten tbody tr:last-child { border-bottom: 0; }
  table.karten td,
  .card > .table-wrap table.karten td:first-child:not(.prio-cell),
  .card > .table-wrap table.karten td:last-child {
    display: block;
    padding: 0;
    border: 0;
    white-space: normal;
    font-size: var(--fs-sm);
    color: var(--text-dim);
    min-width: 0;
  }
  table.karten td:empty, table.karten td.karte-leer { display: none; }
  table.karten tbody tr:hover td, table.karten tbody tr.clickable:hover td { background: none; }
  table.karten tbody tr.clickable:hover { background: var(--surface-2); }
  table.karten td[data-label]::before { content: attr(data-label) ": "; color: var(--text-faint); }
  table.karten td.karte-titel,
  table.karten tr:not(:has(> .karte-titel)) > td:first-child:not(.prio-cell),
  table.karten tr:not(:has(> .karte-titel)) > td.prio-cell + td {
    order: -1;
    flex: 1 1 100%;
    font-size: inherit;
    color: var(--text);
    font-weight: 550;
    overflow-wrap: anywhere;
  }
  table.karten td.karte-titel::before { content: none; }
  table.karten td.num:last-child { margin-left: auto; color: var(--text); font-weight: 600; }
  table.karten td[colspan] { flex: 1 1 100%; }
  table.karten td.prio-cell { position: absolute; left: 0; top: var(--sp-3); bottom: var(--sp-3); width: 3px; padding: 0; }
  table.karten td.prio-cell .prio { height: 100%; }
  table.karten:has(thead) tr[data-task] td:nth-child(4) { display: block; }
}

/* =====================================================================
   Politur (Runde 5): Symbole, Kartenkoepfe, Zustaende, Meldungen
   ===================================================================== */

svg.icon { width: 16px; height: 16px; flex: none; }

/* Navigation: Symbol vor dem Text, Zaehler rechts. */
.nav a { justify-content: flex-start; gap: 10px; }
.nav a .nav-label { flex: 1; min-width: 0; }
.nav a .count { margin-left: auto; }
.nav .nav-icon { color: var(--text-faint); transition: color .12s; }
.nav a:hover .nav-icon { color: var(--text-dim); }
.nav a.active .nav-icon { color: var(--accent); }
.nav a:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

/* Kopfleiste: Suchsymbol im Feld, Glocke und Neu mit Symbol. */
.topbar .search-wrap .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
}
.topbar .search-wrap input { padding-left: 36px; }
#bell { gap: 6px; color: var(--text-dim); }
#bell:hover { color: var(--text); }
#quick-add { gap: 6px; }
.btn-primary { box-shadow: 0 1px 1px rgba(16, 24, 40, .12); }
.btn-primary:focus-visible { box-shadow: var(--focus-ring); }
button:active, .btn:active { transform: translateY(.5px); }
button:disabled, .btn[aria-disabled="true"] { transform: none; }

/* Kartenkoepfe: eine Hoehe, ein Rand, Titel und Aktion auf einer Linie. */
.section-head { display: flex; flex-direction: column; justify-content: center; }
.section-head:has(> .btn, > button, > a.btn) { flex-direction: row; }
.section-head h2 { letter-spacing: -.005em; }
.section-head .small { margin-top: 2px; }
.card-pad > h2:first-child { letter-spacing: -.005em; }

/* Listen mit Wert rechts (Heute, Kurzlisten). */
ul.liste { list-style: none; margin: 0; padding: 0; }
ul.liste li {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3);
  padding: 11px var(--card-pad); border-bottom: 1px solid var(--border); min-width: 0;
}
ul.liste li:last-child { border-bottom: 0; }
ul.liste li > a { min-width: 0; overflow-wrap: anywhere; }
ul.liste li:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* Symbolknopf (Loeschen in Zeilen). */
.icon-btn { padding: 0; width: var(--control-h-sm); min-width: var(--control-h-sm); }
.icon-btn.danger { color: var(--text-faint); }
.icon-btn.danger:hover, .icon-btn.danger:focus-visible { color: var(--red); background: var(--red-soft); }
@media (pointer: coarse) { .icon-btn { width: 40px; min-height: 40px; } }

/* Kurzansicht der Belegvorlagen einer Firma. */
.vorlagen-kurz { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.vorlagen-kurz ul.plain { margin: 0; }
#kv-auswahl { border-top: 1px solid var(--border); }

/* Betraege brechen nie zwischen Zahl und Waehrung. */
td.num, .stat .value, .board-col-head .sum, .board-card .value, .totals dd { white-space: nowrap; }
.items-table tfoot td.num.faint .small { margin-left: var(--sp-1); }

/* Formularfehler direkt am Feld. */
label.req::after { content: " *"; color: var(--red); font-weight: 600; }
.field-error { color: var(--red); font-size: var(--fs-sm); margin-top: var(--sp-1); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], .rt[aria-invalid="true"] {
  border-color: var(--red);
}
input[aria-invalid="true"]:focus, select[aria-invalid="true"]:focus, textarea[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 30%, transparent);
}

/* Meldungen stapeln sich, Fehler lassen sich schliessen. */
.toasts {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 200;
  display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-end;
  max-width: min(400px, calc(100vw - 32px)); pointer-events: none;
}
.toasts .toast {
  position: static; max-width: none; pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--sp-2);
  transition: opacity .18s, transform .18s;
}
.toasts .toast.weg { opacity: 0; transform: translateY(6px); }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close { min-height: 22px; width: 22px; padding: 0; font-size: 18px; line-height: 1; margin: -2px -8px -2px 0; }
@media (max-width: 860px) {
  /* Ueber der Unten-Navigation, nicht darunter. */
  .toasts { left: var(--sp-3); right: var(--sp-3); bottom: calc(var(--unten-nav-h) + env(safe-area-inset-bottom) + var(--sp-3)); max-width: none; align-items: stretch; }
}

/* Ladezustand als Gerippe: die Seite springt nicht, wenn Inhalte kommen. */
.loading {
  font-size: 0; line-height: 0; color: transparent; text-align: left;
  height: 112px; padding: 0; margin: var(--sp-4) var(--card-pad);
  background: linear-gradient(100deg, var(--surface-2) 30%, color-mix(in srgb, var(--surface-2) 55%, var(--surface)) 50%, var(--surface-2) 70%) 0 0 / 220% 100%;
  animation: gerippe 1.3s ease-in-out infinite;
  -webkit-mask: linear-gradient(#000 0 0) 0 4px / 62% 14px no-repeat, linear-gradient(#000 0 0) 0 34px / 100% 14px no-repeat,
    linear-gradient(#000 0 0) 0 64px / 84% 14px no-repeat, linear-gradient(#000 0 0) 0 94px / 46% 14px no-repeat;
  mask: linear-gradient(#000 0 0) 0 4px / 62% 14px no-repeat, linear-gradient(#000 0 0) 0 34px / 100% 14px no-repeat,
    linear-gradient(#000 0 0) 0 64px / 84% 14px no-repeat, linear-gradient(#000 0 0) 0 94px / 46% 14px no-repeat;
}
.loading::before { content: none; display: none; }
#outlet > .loading { margin: 0; }
@keyframes gerippe { from { background-position: 120% 0; } to { background-position: -20% 0; } }
@media (prefers-reduced-motion: reduce) { .loading { animation: none; } }

/* Leere Zustaende: Symbol, Titel, Satz, naechster Schritt. */
.empty::before {
  content: ""; display: block; width: 40px; height: 40px; margin: 0 auto var(--sp-3);
  border-radius: 50%; background-color: var(--surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='20' height='20' fill='none' stroke='%23868d95' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='3' width='11' height='10' rx='2'/%3E%3Cpath d='M2.5 9h3l1 1.6h3L10.5 9h3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 20px;
}
.empty p { margin: 0 auto; max-width: 42ch; }
.card-pad > .empty::before, .card-pad > .table-wrap > .empty::before { display: none; }
.empty .btn-primary { margin-top: var(--sp-4); }

/* Dichte und Lesbarkeit der Tabellen. */
td { padding: 10px var(--sp-3); }
tbody tr.clickable:active td { background: var(--border); }
th[aria-sort] { cursor: pointer; }
.overdue { font-variant-numeric: tabular-nums; }

/* Kanban: ruhigere Karten, deutlicher Zug beim Anfassen. */
.board-card { border-radius: var(--radius-sm); transition: border-color .12s, box-shadow .12s, transform .12s; }
.board-card:hover { border-color: var(--border-strong); box-shadow: 0 2px 10px rgba(16, 24, 40, .1); }
.board-card.dragging { transform: rotate(1.2deg); box-shadow: var(--shadow-lg); }
.board-card:focus-visible { box-shadow: var(--focus-ring); }
.board-col-head { position: sticky; top: 0; background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.board-col-head .count { background: var(--surface); border: 1px solid var(--border); }

/* Summen: je Satz eine Zeile, Gesamt hervorgehoben. */
.items-table tfoot tr.grand td { font-size: var(--fs-lg); }
.items-table tfoot td.num.faint { color: var(--text-dim); }

/* Telefon: die Kopfleiste ist eine schlanke Zeile — Seitentitel, Suchsymbol, Meldungen, Neu.
   Das Suchfeld klappt erst auf Tipp auf (.suche-offen, kopfleiste.ts) und nimmt dann die Zeile ein. */
.search-open, .search-close { display: none; }
@media (max-width: 860px) {
  .topbar {
    position: sticky; top: 0; flex-wrap: nowrap; gap: var(--sp-1);
    min-height: 52px;
    padding: calc(var(--sp-1) + env(safe-area-inset-top)) max(var(--sp-3), env(safe-area-inset-right))
      var(--sp-1) max(var(--sp-3), env(safe-area-inset-left));
  }
  .page-context { flex: 1 1 auto; min-width: 0; }
  .page-context-section, .page-context-separator { display: none; }
  .page-context-title { font-size: var(--fs-lg); overflow: hidden; text-overflow: ellipsis; }
  .topbar .spacer { display: none; }
  .search-wrap { display: none; flex: 1 1 auto; min-width: 0; max-width: none; }
  .topbar .search-wrap input { padding-left: 34px; }
  .search-open { display: inline-flex; flex: none; min-width: 44px; min-height: 44px; padding: 0; justify-content: center; color: var(--text-dim); }
  .topbar.suche-offen .search-wrap { display: block; }
  .topbar.suche-offen .search-close { display: inline-flex; flex: none; }
  .topbar.suche-offen .page-context, .topbar.suche-offen .search-open,
  .topbar.suche-offen .bell-wrap, .topbar.suche-offen #quick-add { display: none; }
  .bell-wrap { margin-left: 0; flex: none; }
  .bell-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #bell { padding: 0 var(--sp-2); min-width: 44px; min-height: 44px; justify-content: center; }
  #bell .badge-count { margin-left: -2px; }
  #quick-add { flex: none; min-height: 36px; }
  .shell { background-image: none; }
  .nav a { min-height: 44px; }
}

/* Kopf und Inhalt einer Karte teilen sich genau eine Trennlinie. */
.card > .section-head + .card-pad { border-top: 0; padding-top: var(--sp-3); }

/* Beschriftungen tragen frei gewaehlte Farben; die Abdunklung haelt weisse Schrift auf AA. */
.label-chip { background-image: linear-gradient(rgba(0, 0, 0, .42), rgba(0, 0, 0, .42)); text-shadow: none; }
.page-context-separator { color: var(--text-faint); }
/* Befehlspalette und Tastenhilfe (ABL-1) */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 300; display: flex; justify-content: center;
  align-items: flex-start; padding: 12vh var(--sp-4) var(--sp-4);
  background: rgba(16, 24, 40, .45);
}
.palette {
  width: min(560px, 100%); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 14px 16px; font-size: var(--fs-lg); background: transparent; }
.palette input:focus { outline: none; box-shadow: none; }
.palette ul { list-style: none; margin: 0; padding: var(--sp-1); max-height: 50vh; overflow: auto; }
.palette-gruppe { padding: 8px 12px 4px; font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.palette-zeile { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.palette-zeile.aktiv, .palette-zeile:hover { background: var(--accent-soft); }
.palette-leer { padding: 12px; }
.palette-fuss { padding: 8px 12px; border-top: 1px solid var(--border); }
kbd { font: inherit; font-size: var(--fs-xs); padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface-2); color: var(--text-dim); white-space: nowrap; }
.kuerzel-tabelle { width: 100%; border-collapse: collapse; }
.kuerzel-tabelle th, .kuerzel-tabelle td { text-align: left; padding: 8px 6px; vertical-align: top; border-bottom: 1px solid var(--border); }
.kuerzel-tabelle th { white-space: nowrap; font-weight: 400; }
.toast-aktion { align-items: center; }
.toast-aktion button:not(.toast-close) { color: var(--accent); }

/* Heute (ABL-2) */
.heute-abschnitt { margin-bottom: var(--sp-4); }
.heute-abschnitt > summary, .heute-abschnitt > .section-head { cursor: default; }
.heute-abschnitt summary { cursor: pointer; padding: var(--sp-3) var(--sp-4); font-weight: 600; }
.heute-abschnitt h2 { margin: 0; }
.heute-zeile { display: flex; gap: var(--sp-3); align-items: center; padding: 10px var(--sp-4); border-top: 1px solid var(--border); }
.heute-zeile .titel { flex: 1; min-width: 0; }
.heute-zeile .titel a { font-weight: 500; }
.heute-zeile .aktionen { display: flex; gap: var(--sp-1); flex-wrap: wrap; justify-content: flex-end; }
.heute-zeile .frist.ueberfaellig { color: var(--red); font-weight: 600; }
.heute-zahl { font-variant-numeric: tabular-nums; color: var(--text-dim); font-weight: 400; }
@media (max-width: 640px) { .heute-zeile { flex-wrap: wrap; } .heute-zeile .aktionen { width: 100%; justify-content: flex-start; } }

/* Naechster Schritt am Deal und Heute-Erweiterungen (B-10, B-11) */
.board-card .schritt-zeile { margin-top: 6px; font-size: var(--fs-xs); color: var(--text-dim); word-break: break-word; }
.board-card .schritt-zeile.overdue { color: var(--red); font-weight: 600; }
.board-card .schritt-zeile.schritt-ohne { color: var(--amber); font-weight: 600; background: var(--amber-soft); padding: 2px 6px; border-radius: var(--radius-sm); }
.board-card .schritt-zeile.rottet { color: var(--red); font-weight: 600; }
.board-card.rottet-karte { border-left: 3px solid var(--red); }
.schritt-warnung-kurz { color: var(--amber); font-weight: 600; }
.schritt-warnung { background: var(--amber-soft); color: var(--amber); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); }
.schritt-text { font-size: var(--fs-md, 1rem); }
.schritt-form { margin-top: var(--sp-3); }
.heute-zeile .quelle { font-size: var(--fs-xs); color: var(--text-dim); }
.prognose-tabelle td, .prognose-tabelle th { padding: 8px var(--sp-3); }
.prognose-balken { display: block; height: 6px; background: var(--accent); border-radius: 3px; min-width: 2px; }
.prognose-spur { display: block; height: 6px; background: var(--accent-soft); border-radius: 3px; }

/* Ausstellen: Checkliste vor dem Festschreiben (ABL-6) */
.ausstellen-karte { margin-bottom: var(--sp-4); border-left: 4px solid var(--amber); }
.ausstellen-karte.ok { border-left-color: var(--green); }
.ausstellen-liste { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: var(--sp-2); }
.ausstellen-liste li { display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; }

/* Sammelaenderung (ABL-8) */
.sammel-leiste { background: var(--accent-soft); border-bottom: 1px solid var(--border); gap: var(--sp-3); }
td input[data-sammel-zeile], th input[data-sammel-alle] { width: 18px; height: 18px; margin: 0 var(--sp-2) 0 0; vertical-align: middle; }

/* Abrechnen: das Satzfeld in der Tabelle ist ein normales Eingabefeld, die Beschriftung davor nicht der Wert. */
input.satz { font-weight: 400; max-width: 9em; margin-top: var(--sp-1); }

/* Gespeicherte Ansichten (B-1), Direktbearbeitung (B-2), Tastenlauf (B-8) */
.ansichten-leiste { gap: var(--sp-3); align-items: center; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.ansicht-tabs { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.ansicht-tab {
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  padding: var(--sp-1) var(--sp-3); color: inherit; cursor: pointer; font: inherit;
}
.ansicht-tab:hover { background: var(--surface-2); }
.ansicht-tab[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.ansicht-spalten { position: relative; }
.ansicht-spalten summary { list-style: none; cursor: pointer; }
.ansicht-spalten-liste {
  position: absolute; right: 0; z-index: 20; min-width: 200px; display: grid; gap: var(--sp-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
}
.ansichten-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.ansicht-zeile { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.spalte-aus { display: none !important; }
.inline-zelle { cursor: pointer; }
.inline-zelle:hover { background: var(--surface-2); }
.inline-zelle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.inline-wartet { opacity: .6; }
.inline-feld { max-width: 100%; }
tr.zeile-aktiv { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }

/* Papierkorb: der Hinweis steht ohne Ueberschrift in der Karte, also ohne Aussenabstand. */
.papierkorb-hinweis { margin: 0; }

/* Mobile Unten-Navigation (Runde 7): vier Ziele und "Mehr", fest am unteren Rand.
   Auf breiten Bildschirmen gibt es sie nicht; dort fuehrt die Seitenleiste. */
.unten-nav { display: none; }
@media (max-width: 860px) {
  .unten-nav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    min-height: calc(var(--unten-nav-h) + env(safe-area-inset-bottom));
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -1px 8px rgba(16, 24, 40, .06);
  }
  .unten-nav a, .unten-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: var(--unten-nav-h); min-width: 0; padding: var(--sp-1) 2px;
    border: 0; border-radius: 0; background: none; box-shadow: none;
    color: var(--text-dim); font: inherit; font-size: 11px; font-weight: 500; line-height: 1.2;
    text-decoration: none; cursor: pointer;
  }
  .unten-nav span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .unten-nav .nav-icon { width: 22px; height: 22px; color: inherit; }
  .unten-nav a:hover { text-decoration: none; color: var(--text); }
  .unten-nav .active { color: var(--accent); font-weight: 650; }
  .unten-nav .active .nav-icon { stroke-width: 1.8; }
  .unten-nav a:focus-visible, .unten-nav button:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
  /* Beim Tippen weg: Browser, die bei offener Bildschirmtastatur das Layout
     verkleinern (Firefox, Android-WebView, installierte App), schieben eine
     feste Leiste sonst ueber die Tastatur und damit ueber das Eingabefeld. */
  body:has(:is(input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="reset"], [type="range"], [type="color"], [type="file"]), textarea, [contenteditable="true"]):focus) .unten-nav { display: none; }
  /* Inhalt endet ueber der Leiste. */
  .main { padding-bottom: calc(var(--unten-nav-h) + env(safe-area-inset-bottom)); }
  /* Meldungen und Suchvorschlaege: volle Breite unter der Kopfleiste statt am Symbol zu haengen. */
  .bell-wrap { position: static; }
  .notif-panel, .search-results {
    position: fixed; left: var(--sp-3); right: var(--sp-3); width: auto;
    top: calc(52px + env(safe-area-inset-top) + var(--sp-1));
    max-height: calc(100dvh - 52px - var(--unten-nav-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - var(--sp-5));
  }
  .search-results button { white-space: normal; }
  /* Zaehler an "Mehr" (ungelesene Meldungen) und die Zeile "Meldungen" im Blatt. */
  .unten-nav button { position: relative; }
  .unten-nav .mehr-zaehler { position: absolute; top: 6px; left: calc(50% + 4px); min-width: 18px; padding: 0 5px; line-height: 16px; font-size: 10px; }
}

/* Das Blatt "Mehr": ein Dialog von unten mit allen uebrigen Zielen, Mandant und Abmelden. */
.modal-backdrop.mehr-hinter { align-items: flex-end; padding: 0; overflow: hidden; }
.mehr-blatt {
  width: 100%; max-width: 560px; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-bottom: 0; border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-lg); animation: blatt-hoch .18s ease-out;
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes blatt-hoch { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .mehr-blatt { animation: none; } }
.mehr-kopf {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4) var(--sp-2) var(--sp-5); border-bottom: 1px solid var(--border);
}
.mehr-inhalt { overflow-y: auto; overscroll-behavior: contain; }
.mehr-nav { padding: var(--sp-2) var(--sp-3); }
.mehr-nav button.mehr-meldungen {
  /* Wie die Links darunter: Symbol und Text linksbuendig (der Knopf-Standard zentriert). */
  display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; min-height: 44px;
  padding: 10px var(--sp-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-dim);
  font: inherit; font-size: var(--fs-lg); font-weight: inherit; text-align: left; cursor: pointer;
}
.mehr-nav button.mehr-meldungen .nav-label { flex: 1; min-width: 0; }
.mehr-nav button.mehr-meldungen:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.mehr-konto {
  display: grid; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5) var(--sp-5);
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.mehr-nutzer { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: baseline; }
.mehr-org select { margin-top: var(--sp-1); }

/* Nur auf dem Telefon sichtbar (z. B. Navigations-Link zur Adresse). */
.nur-telefon { display: none; }
@media (max-width: 860px) { .nur-telefon { display: inline; } }

/* Kopf der Aufgabenansicht: Kunde, Anschrift, Ticket (HW-4). */
.einsatz-kopf {
  display: grid; gap: 4px; margin-bottom: 12px; padding: 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--accent-soft);
}
.einsatz-kopf a { padding: 2px 0; }
.einsatz-text { margin-top: 8px; }

/* Teamwoche im Kalender */
.tw-scroll { overflow-x: auto; }
.tw { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 13px; }
.tw th, .tw td { border: 1px solid var(--border); padding: 6px 8px; vertical-align: top; text-align: left; }
.tw thead th { background: var(--surface-2); font-weight: 600; }
.tw .tw-heute { color: var(--accent); }
.tw tbody th { white-space: nowrap; font-weight: 500; }
.tw-termin { margin-bottom: 4px; overflow-wrap: anywhere; }
.board-card .teil-fortschritt { margin-top: var(--sp-2); }
.board-card .teil-fortschritt .bar { height: 5px; }
/* Anrufen und E-Mail unter dem Titel von Kontakt, Firma und Deal (Runde 7b). */
.kontakt-leiste { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.kontakt-leiste .btn { min-height: 44px; padding: 0 var(--sp-5); font-size: var(--fs-md); font-weight: 600; }
.btn-anruf { text-decoration: none; }
a.tipp-ziel { color: var(--accent); }
.sammel-feld { display: inline-flex; padding: 0; margin: 0 var(--sp-2) 0 0; vertical-align: middle; cursor: pointer; }
@media (max-width: 640px) {
  .kontakt-leiste { width: 100%; }
  .kontakt-leiste .btn { flex: 1 1 0; justify-content: center; }
  .page-head > div:first-child { width: 100%; }
}

/* Kurzinfo am Deal: die Fragen vor dem Termin in einem Blick. */
.deal-kurzinfo { display: grid; gap: var(--sp-3); }
.deal-kurzinfo .kurzinfo-zeile { display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; }
.deal-kurzinfo .kurzinfo-text { min-width: 0; }
.deal-kurzinfo .btn-anruf { min-height: 44px; padding: 0 var(--sp-5); font-weight: 600; flex: none; }
.deal-kurzinfo .kurzinfo-feld { font-size: var(--fs-md); overflow-wrap: anywhere; }
.deal-kurzinfo .overdue { color: var(--red); font-weight: 600; }

/* Touch: Bedienelemente haben mindestens 44 x 44 px Trefferfläche; am Desktop bleibt alles beim Alten.
   Links in Text und Tabellen wachsen nur über Innenabstand, die Zeilen bleiben so hoch wie vorher. */
@media (pointer: coarse) {
  .btn, .btn-sm, .btn-primary, .btn-danger, .btn-ghost, button.btn-sm { min-height: 44px; }
  .icon-btn { width: 44px; min-width: 44px; min-height: 44px; }
  .toast-close { min-height: 44px; width: 44px; margin: -12px -12px -12px 0; }
  .tabs button, .ansicht-tab { min-height: 44px; }
  select, input:not([type=checkbox]):not([type=radio]) { min-height: 44px; }
  label:has(> input[type=checkbox]), label:has(> input[type=radio]) { min-height: 44px; }
  .sammel-feld { padding: 14px; margin: -14px 0 -14px -14px; }
  .sammel-feld input { width: 18px; height: 18px; min-height: 18px; }
  :where(td, dd, p, li, .crumb, .sub, .small, .titel, .kurzinfo-feld, .kurzinfo-text) > a:not([class*="btn"]) { padding-block: 14px; }
}

.sprungleiste { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 0; margin-bottom: 8px; background: var(--bg); }
[data-abschnitt] { scroll-margin-top: 64px; }

/* In Karten-Listen (Telefon) stehen die Zellen nur 2 px auseinander: der Innenabstand
   oben liesse den Kunden-Link ueber die Nummer darueber greifen, der Tipp auf die
   Nummer oeffnete die Firma. Die Karte selbst ist dort die grosse Trefferflaeche. */
@media (pointer: coarse) and (max-width: 640px) {
  table.karten td > a:not([class*="btn"]) { padding-block: 0; }
}
/* Arbeitsbericht (P2-13): Zeilen in der Karte und das Unterschriftsfeld */
.bericht-zeile { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; justify-content: space-between; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.bericht-zeile:last-child { border-bottom: 0; }
.bericht-text { min-width: 0; flex: 1 1 14rem; }
.unterschrift { display: block; width: 100%; max-width: 600px; aspect-ratio: 3 / 1; background: #fff; border: 1px solid var(--border); border-radius: var(--radius, 6px); touch-action: none; cursor: crosshair; }
.unterschrift-bild { display: block; width: 100%; max-width: 360px; aspect-ratio: 3 / 1; background: #fff; border: 1px solid var(--border); border-radius: var(--radius, 6px); }
.unterschrift-bild polyline { fill: none; stroke: #111; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.unterschrift-bild circle { fill: #111; }

/* Wochenblick (P2-15) */
.wochenblick-tag .titel > .small { margin-top: 2px; }
.anhang-vorschau { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); }
.anhang-vorschau img { max-width: 6rem; max-height: 6rem; border-radius: var(--radius, 4px); border: 1px solid var(--border); }
/* Lesesicht der Aufgabe auf schmalen Bildschirmen: Bearbeiten steht hinter "Mehr". */
.lese-nur { display: none; }
.aufgabe-lese .lese-nur { display: block; }
.aufgabe-lese .field-grid,
.aufgabe-lese .mehr-nur,
.aufgabe-lese .modal-foot [type="submit"] { display: none; }
