/* SaboDan CRM – Hausstil SaboDan Backend */
@font-face {
  font-family: "Schibsted Grotesk"; font-style: normal; font-display: swap; font-weight: 400 900;
  src: url(fonts/schibsted-grotesk-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk"; font-style: normal; font-display: swap; font-weight: 400 900;
  src: url(fonts/schibsted-grotesk-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --brand: #336699; --brand-hover: #2a5580; --brand-tint: #e7eef6; --brand-ink: #24496e;
  --bg: #f2f3f5;
  --panel: #ffffff; --ink: #1d2733; --muted: #5f6b7a;
  --line: #e1e4e8; --line-strong: #cdd2d8;
  --danger: #b42318; --danger-tint: #fdecea; --ok: #157347; --ok-tint: #e7f4ec;
  --wait: #8a5a00; --wait-tint: #fdf3dc;
  --radius: 12px; --radius-s: 8px;
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --brand: #7fa7d1; --brand-hover: #9dbde0; --brand-tint: #1f2f40; --brand-ink: #b9d0e8;
          --bg: #14181d; --panel: #1b2027; --ink: #e6e9ee; --muted: #9aa4b2; --line: #2a313a; --line-strong: #3a434e;
          --danger: #f08b80; --danger-tint: #3a1f1d; --ok: #6fcf97; --ok-tint: #1b3326; --wait: #f2c46d; --wait-tint: #3a2f17; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.25; font-weight: 700; letter-spacing: -0.015em; margin: 0; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 650; margin: 0 0 14px; }
h3 { font-size: 15px; font-weight: 650; margin: 0 0 8px; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.ico { width: 19px; height: 19px; flex: none; }
.btn .ico { width: 17px; height: 17px; }

/* ---------- Grundlayout ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--panel) 251px, var(--line) 251px, var(--line) 252px, var(--bg) 252px); }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column; padding: 16px 12px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 12px; flex: none; color: var(--ink); font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-logo { height: 34px; width: auto; max-width: 150px; object-fit: contain; }
.brand-logo-only .brand-logo { height: 40px; max-width: 210px; }
.nav { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; margin: 0 -6px; padding: 0 6px 4px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-head { font-size: 12px; color: var(--muted); padding: 0 10px 3px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--radius-s);
  color: var(--ink); font-weight: 500; font-size: 14.5px; line-height: 1.4;
}
.nav a .ico { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--brand-tint); color: var(--brand-ink); font-weight: 650; }
.nav a.active .ico { color: var(--brand); }
.nav .ico { color: var(--muted); }
.pill { margin-left: auto; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 650; line-height: 1; padding: 4px 7px; border-radius: 999px; }
.pill.pill-muted { background: var(--line-strong); color: var(--ink); }
.side-foot { flex: none; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.side-user { display: flex; align-items: center; gap: 2px; }
.side-user .userblock { flex: 1; min-width: 0; }
.side-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-s); color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; flex: none; }
.side-icon:hover { background: var(--bg); color: var(--brand-ink); text-decoration: none; }
.side-icon .ico { width: 18px; height: 18px; }
.side-user form { margin: 0; display: flex; }
.side-version { font-size: 12px; color: var(--muted); padding: 0 8px; }
.userblock { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: var(--radius-s); color: var(--ink); }
.userblock:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.userblock > span:last-child { min-width: 0; }
.userblock strong { display: block; font-size: 14px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userblock small { display: block; font-size: 12.5px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 650; font-size: 13.5px; flex: none; }
.side-links { display: flex; gap: 14px; padding: 0 8px; font-size: 13.5px; align-items: center; }
.side-links form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.side-version { padding: 0 8px; font-size: 12px; color: var(--muted); }

.main { padding: 34px 44px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .lead { color: var(--muted); margin: 6px 0 0; }
.crumb { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; display: block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions select { width: auto; }

/* ---------- Karten & Raster ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid, .stats + .card, .stats + .grid, .tabs + .card, .msg + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.grid > .card, .grid > div > .card:first-child { margin-top: 0; }
.grid > div > .card + .card { margin-top: 18px; }
.card.flush .card-head { padding: 20px 24px 0; }
.grid { display: grid; gap: 18px; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stats.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat-label { font-size: 13.5px; color: var(--muted); }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin: 4px 0 2px; }
.stat-value.danger { color: var(--danger); }
.stat-hint { font-size: 12.5px; color: var(--muted); }
.up { color: var(--ok); } .down { color: var(--danger); }

/* Seitenleiste auf niedrigen Bildschirmen (Laptops) noch kompakter */
@media (min-width: 861px) and (max-height: 860px) {
  .sidebar { padding-top: 12px; }
  .brand { padding-bottom: 8px; }
  .brand-logo { height: 30px; } .brand-logo-only .brand-logo { height: 34px; }
  .nav { gap: 8px; }
  .nav a { padding: 4px 10px; font-size: 14px; }
  .nav-head { font-size: 11.5px; padding-bottom: 2px; }
  .side-version { display: none; }
}
@media (min-width: 861px) and (max-height: 720px) {
  .nav-head { display: none; }
  .nav-group + .nav-group { border-top: 1px solid var(--line); padding-top: 6px; }
  .nav { gap: 6px; }
  .nav a { padding: 3px 10px; }
  .userblock small { display: none; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font: inherit; font-weight: 600; font-size: 14.5px; line-height: 1;
  padding: 10px 15px; border-radius: var(--radius-s); border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary, .btn-primary:hover { color: #0f1a26; } }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--panel); }
.btn-danger:hover { background: var(--danger-tint); color: var(--danger); }
.btn-small { padding: 7px 11px; font-size: 13.5px; }
.btn-icon { padding: 7px; }
.inline { display: inline; margin: 0; }

/* ---------- Formulare ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label, .label { display: block; font-size: 14px; font-weight: 550; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 9px 11px; min-height: 40px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
input[type=file] { font: inherit; font-size: 14px; }
.save-bar {
  position: sticky; bottom: 0; z-index: 5; margin-top: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  box-shadow: 0 -6px 18px rgba(20, 30, 45, 0.06);
}
.save-bar .spacer { flex: 1; }
.searchbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.searchbar input[type=search] { max-width: 320px; }
.searchbar select { width: auto; }

.label-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-bottom: 6px; }
.label-row label { margin: 0; }
select.baustein-select { width: auto; min-height: 32px; padding: 4px 28px 4px 10px; font-size: 13px; color: var(--brand-ink); background-color: var(--brand-tint); border-color: transparent; cursor: pointer; }

/* Schalter-Zeile */
.switch-row { display: flex; gap: 14px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 40px; height: 23px; border-radius: 999px; background: var(--line-strong); position: relative; flex: none; margin-top: 1px; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch-row input:checked + .switch { background: var(--brand); }
.switch-row input:checked + .switch::after { transform: translateX(17px); }
.switch-row input:focus-visible + .switch { box-shadow: 0 0 0 3px var(--brand-tint); }
.switch-row strong { display: block; font-weight: 650; }
.switch-row span.desc { display: block; font-size: 13.5px; color: var(--muted); }

/* Auswahlkarten */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.choice { border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 12px 14px; cursor: pointer; display: block; }
.choice input { position: absolute; opacity: 0; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.choice strong { display: block; font-weight: 650; }
.choice span { font-size: 13px; color: var(--muted); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; background: var(--panel); }
.table th { font-size: 13px; font-weight: 550; color: var(--muted); text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--bg) 60%, var(--panel)); }
.table tr.click { cursor: pointer; }
.table td.num, .table th.num { text-align: right; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.table .sub { display: block; font-size: 13px; color: var(--muted); }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 24px; }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 24px; }
.show-m { display: none !important; }
.empty { padding: 36px 24px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* Tags */
.tag { display: inline-block; font-size: 12.5px; font-weight: 600; line-height: 1; padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.tag-ok { color: var(--ok); background: var(--ok-tint); }
.tag-off, .tag-danger { color: var(--danger); background: var(--danger-tint); }
.tag-brand { color: var(--brand-ink); background: var(--brand-tint); }
.tag-wait { color: var(--wait); background: var(--wait-tint); }
.tag-grey { color: var(--muted); background: var(--bg); }

/* Reiter */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 9px 12px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tabs .count { font-size: 12px; color: var(--muted); }

/* Meldungen */
.msg { border: 1px solid; border-radius: var(--radius-s); padding: 12px 16px; margin-bottom: 18px; font-weight: 500; }
.msg-ok { color: var(--ok); background: var(--ok-tint); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.msg-fehler { color: var(--danger); background: var(--danger-tint); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.msg-info { color: var(--brand-ink); background: var(--brand-tint); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.msg ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }

/* ---------- Diagramm ---------- */
.chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; align-items: end; height: 210px; padding-top: 22px; }
.chart-col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; min-width: 0; position: relative; }
.chart-bar { width: 100%; max-width: 44px; background: var(--brand); border-radius: 5px 5px 2px 2px; min-height: 2px; position: relative; transition: background .15s; }
.chart-bar.zero { background: var(--line); }
.chart-bar.neg { background: var(--danger); }
.chart-col:hover .chart-bar { background: var(--brand-hover); }
.chart-val { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 11.5px; color: var(--muted); white-space: nowrap; opacity: 0; transition: opacity .12s; pointer-events: none; }
.chart-col:hover .chart-val { opacity: 1; color: var(--ink); font-weight: 600; }
.chart-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-empty { height: 120px; display: grid; place-items: center; color: var(--muted); font-size: 14px; }

/* Rangliste */
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
.rank .rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .rank-val { text-align: right; font-weight: 600; }
.rank .rank-track { grid-column: 1 / -1; height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.rank .rank-fill { height: 100%; background: var(--brand); border-radius: 999px; }

/* Definitionsliste */
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Kundenwahl ---------- */
.kundenwahl { position: relative; }
.kw-liste { position: absolute; z-index: 30; left: 0; right: 0; top: 44px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-s); box-shadow: 0 12px 30px rgba(20, 35, 55, 0.12); max-height: 320px; overflow-y: auto; padding: 4px; }
.kw-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.kw-item.aktiv, .kw-item:hover { background: var(--brand-tint); }
.kw-name { font-weight: 600; }
.kw-meta { font-size: 13px; color: var(--muted); }
.kw-item mark, .table mark { background: color-mix(in srgb, var(--wait-tint) 70%, #ffe58a); color: inherit; border-radius: 2px; padding: 0 1px; }
.kw-leer { padding: 10px; color: var(--muted); font-size: 14px; }
.kw-karte { margin-top: 8px; display: flex; justify-content: space-between; gap: 12px; align-items: center; border: 1px solid var(--line); background: var(--bg); border-radius: var(--radius-s); padding: 10px 14px; font-size: 14px; }

/* ---------- Rechnungseditor ---------- */
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 13px; font-weight: 550; color: var(--muted); text-align: left; padding: 0 6px 8px; white-space: nowrap; }
.items td { padding: 4px 6px; vertical-align: top; }
.items input, .items select { min-height: 38px; padding: 7px 9px; font-size: 14.5px; }
.items .c-nr { width: 130px; } .items .c-menge { width: 90px; } .items .c-einheit { width: 92px; }
.items .c-preis { width: 110px; } .items .c-rabatt { width: 76px; } .items .c-ust { width: 86px; } .items .c-summe { width: 120px; } .items .c-del { width: 44px; }
.items td.sum { padding-top: 13px; text-align: right; font-weight: 600; white-space: nowrap; }
.items input.num { text-align: right; }
.totals { margin-left: auto; width: 100%; max-width: 340px; border-collapse: collapse; margin-top: 14px; }
.totals td { padding: 5px 0; }
.totals td:last-child { text-align: right; }
.totals tr.total td { border-top: 1px solid var(--line-strong); padding-top: 9px; font-weight: 700; font-size: 17px; }

/* ---------- Hilfe ---------- */
details.faq { border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel); }
details.faq + details.faq { margin-top: 8px; }
details.faq summary { cursor: pointer; padding: 13px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); margin-top: 6px; transition: transform .15s; flex: none; }
details.faq[open] summary::after { transform: rotate(45deg); }
details.faq .faq-body { padding: 0 16px 14px; color: var(--ink); }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 650; font-size: 13.5px; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.5; margin: 8px 0 0; }

/* ---------- Anmeldung ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; position: relative; overflow: hidden; }
.login-bg { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; color: color-mix(in srgb, var(--brand) 35%, var(--line-strong)); }
.login-col { width: 100%; max-width: 420px; position: relative; z-index: 1; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand img { height: 52px; width: auto; max-width: 260px; object-fit: contain; }
.login-brand strong { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: 0 12px 40px rgba(20, 35, 55, 0.08); }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card .field { margin-top: 16px; }
.login-card .btn { width: 100%; margin-top: 22px; padding: 12px; }
.login-foot { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 18px; }
.draw-logo { animation: logo-in .9s ease-out both; }
@keyframes logo-in { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
.login-bg { animation: bg-in 1.6s ease-out both; }
@keyframes bg-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .draw-logo, .login-bg { animation: none; } }

/* ---------- Mobil ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .sidebar { position: sticky; top: 0; height: auto; z-index: 20; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); gap: 8px; }
  .brand { padding: 0; flex: 1; }
  .brand-logo { height: 28px; }
  .nav { order: 3; width: 100%; flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; width: calc(100% + 28px); }
  .nav::-webkit-scrollbar { display: none; }
  .nav-group { flex-direction: row; gap: 4px; }
  .nav-head { display: none; }
  .nav a { white-space: nowrap; padding: 7px 10px; }
  .nav { flex: none; overflow-y: hidden; }
  .side-user .side-icon[href="/hilfe"] { display: none; }
  .side-foot { margin: 0; padding: 0; border: 0; flex-direction: row; }
  .side-foot .side-links, .side-foot .side-version, .userblock span:not(.avatar) { display: none; }
  .userblock { padding: 0; }
  .avatar { width: 32px; height: 32px; font-size: 12.5px; }
  .main { padding: 22px 16px 50px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 23px; }
  .stat-value { font-size: 24px; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .chart { gap: 4px; height: 170px; }
  .chart-label { font-size: 10.5px; }
  .items thead { display: none; }
  .items, .items tbody, .items tr, .items td { display: block; width: 100% !important; }
  .items tr { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .items td { padding: 0; }
  .items td.c-bez-cell, .items td.c-nr { grid-column: 1 / -1; }
  .items td.sum { padding-top: 9px; }
  .hide-m { display: none; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .show-m { display: block !important; }
  .save-bar { padding: 10px 12px; gap: 6px; }
  .save-bar .btn { padding: 9px 11px; font-size: 13.5px; }
  .save-bar .spacer, .save-bar .muted { display: none; }
  .card-head { flex-wrap: wrap; }
  .table td, .table th { padding: 10px 8px; }
  .card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 14px; }
  .card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 14px; }
  .card.flush .card-head { padding: 16px 14px 0; }
  .card { padding: 18px 16px; }
}
@media (max-width: 520px) {
  .stats, .stats.stats-3 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Druck (Statistik u. a.) ---------- */
.print-head { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; color: #1d2733; font-size: 11pt; }
  .sidebar, .no-print, .save-bar, .msg, .tabs, .searchbar, .actions .btn { display: none !important; }
  .shell { display: block; background: none; }
  .main { padding: 0; max-width: none; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid #1d2733; padding-bottom: 6px; margin-bottom: 14px; font-size: 10pt; }
  .print-head strong { font-size: 15pt; }
  .card, .stat { break-inside: avoid; border-color: #cdd2d8; }
  .grid, .stats { gap: 10px; }
  th.hide-m, td.hide-m { display: table-cell !important; }
  .show-m { display: none !important; }
  a { color: inherit; text-decoration: none; }
  .chart-bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rank-fill, .tag { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Zeitraum-Auswahl ---------- */
.zeitraum { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -8px 0 18px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); font-size: 13.5px; font-weight: 550; }
.chip:hover { text-decoration: none; background: var(--bg); color: var(--ink); }
.chip.active { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-ink); }
.zeitraum-frei { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.zeitraum-frei input[type=date] { width: auto; min-height: 34px; padding: 5px 8px; font-size: 13.5px; }
@media (max-width: 860px) { .zeitraum-frei { margin-left: 0; width: 100%; } .zeitraum-frei input[type=date] { flex: 1; } }

.changelog-liste { margin: 6px 0 14px; padding-left: 20px; }
.changelog-liste li { margin: 3px 0; }
a.side-version:hover { color: var(--brand); text-decoration: none; }

/* Angebote/Aufträge: Ablauf */
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.plain[disabled] .kw-suche, fieldset.plain[disabled] input, fieldset.plain[disabled] textarea, fieldset.plain[disabled] select { background: var(--bg); }
.ablauf { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.ablauf > .hint { flex-basis: 100%; }
.ablauf-schritte { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.schritt { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px dashed var(--line-strong); color: var(--muted); font-size: 14px; }
.schritt svg { width: 16px; height: 16px; }
.schritt.done { border: 1px solid transparent; background: var(--brand-tint); color: var(--brand-ink); font-weight: 600; }
.rank .rank-name .sub { display: block; white-space: normal; }
.stats + .tabs { margin-top: 18px; }
fieldset.plain[disabled] button, fieldset.plain[disabled] .baustein-select, fieldset.plain[disabled] select.baustein-select { display: none; }

/* ---------- Artikel: Bilder und Unterlagen ---------- */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn:hover { color: var(--brand-ink); border-color: var(--line-strong); background: var(--brand-tint); }
.icon-btn svg { width: 17px; height: 17px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.galerie { display: grid; gap: 12px; margin-bottom: 14px; }
.galerie-haupt { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; cursor: zoom-in; overflow: hidden; aspect-ratio: 4 / 3; }
.galerie-haupt img { width: 100%; height: 100%; object-fit: contain; display: block; }
.galerie-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.galerie-item { display: flex; flex-direction: column; gap: 6px; }
.galerie-thumb { padding: 0; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; overflow: hidden; aspect-ratio: 1; cursor: pointer; }
.galerie-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.galerie-item.haupt .galerie-thumb, .galerie-thumb.aktiv { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint); }
.galerie-aktionen { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 32px; }
.galerie-aktionen .tag { font-size: 11.5px; }

.doku-liste { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; }
.doku-liste li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.doku-liste li:first-child { padding-top: 0; }
.doku-icon { width: 40px; height: 48px; border-radius: 6px; border: 1px solid #f0c9c4; background: var(--danger-tint); color: var(--danger); font-weight: 700; font-size: 11.5px; cursor: pointer; font-family: inherit; }
.doku-titel { background: none; border: 0; padding: 0; text-align: left; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.doku-titel:hover { color: var(--brand); text-decoration: underline; }
.doku-text .sub { display: block; font-size: 12.5px; color: var(--muted); }
.doku-aktionen { display: flex; gap: 6px; }
.doku-umbenennen summary { font-size: 12.5px; color: var(--brand); cursor: pointer; list-style: none; margin-top: 2px; }
.doku-umbenennen summary::-webkit-details-marker { display: none; }
.inline-form { display: flex; gap: 6px; margin-top: 6px; }
.inline-form input { flex: 1; min-width: 0; }

.upload-flaeche { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 20px 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }
.upload-flaeche:hover, .upload-zone.drag .upload-flaeche { border-color: var(--brand); background: var(--brand-tint); }
.upload-flaeche svg { width: 24px; height: 24px; color: var(--brand); }
.upload-flaeche strong { font-weight: 600; }
.upload-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-status:empty { display: none; }
.upload-status { font-size: 13px; color: var(--brand-ink); font-weight: 600; }
.upload-zone.laedt .upload-flaeche { opacity: .7; pointer-events: none; }

.art-zelle { display: flex; gap: 12px; align-items: flex-start; }
.art-thumb { width: 44px; height: 44px; flex: none; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; background: #fff; }
.art-thumb.leer { display: inline-flex; align-items: center; justify-content: center; background: var(--bg); color: var(--muted); }
.art-thumb.leer svg { width: 20px; height: 20px; }

.viewer { width: min(1100px, 94vw); height: 90vh; max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); }
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgba(16, 22, 30, .6); }
.viewer-kopf { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.viewer-kopf .spacer { flex: 1; }
.viewer-kopf strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
@media (max-width: 860px) {
  .viewer { width: 100vw; height: 100dvh; max-height: 100dvh; max-width: 100vw; border-radius: 0; margin: 0; }
  .viewer-kopf .btn-small:first-of-type { display: none; }
}
