/* CARmove Custom Styles - Design System Implementation */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 23px;
    overflow-x: hidden;
}

/* Layout Grid */
.app {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 100vh;
}

@media (min-width: 960px) {
    .app {
        grid-template-columns: var(--menu-breite, var(--sidebar-width)) minmax(0, 1fr);
    }
}

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

/* Sidebar */
.sidebar {
    display: none;
    background: var(--brand);
    color: var(--on-brand);
    padding: var(--space-4);
    flex-direction: column;
    gap: var(--space-1);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

@media (min-width: 960px) {
    .sidebar {
        display: flex;
    }
}

.sidebar .brandline {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    margin-bottom: var(--space-3);
}

.sidebar .brandline img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--on-brand);
    text-decoration: none;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    opacity: .85;
    font-size: 15px;
}

.sidebar a:hover {
    background: rgba(255,255,255,.1);
    opacity: 1;
}

.sidebar a.active {
    background: rgba(255,255,255,.16);
    opacity: 1;
    font-weight: 600;
}

.sidebar .sep {
    margin-top: auto;
    padding-top: var(--space-3);
    border-top: 1px solid rgba(255,255,255,.18);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar .sep .label {
    color: var(--on-brand);
    opacity: .7;
    margin-bottom: 4px;
}

.sidebar .version {
    font-size: 11px;
    opacity: .5;
    margin-top: var(--space-2);
    text-align: center;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    gap: var(--space-3);
}

.topbar-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

.page-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.tenant-name {
    font-size: 14px;
    color: var(--ink-muted);
}

.user-name {
    font-size: 14px;
    color: var(--ink-muted);
}

/* Page Content */
.page {
    flex: 1;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-4);
    padding-bottom: 80px; /* Space for bottom nav on mobile */
}

@media (min-width: 960px) {
    .page {
        padding: var(--space-6);
        padding-bottom: var(--space-6);
    }
}

.page-narrow {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-6);
}

/* Bottom Nav */
.bottomnav {
    display: flex;
    justify-content: space-around;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 0 4px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

@media (min-width: 960px) {
    .bottomnav {
        display: none;
    }
}

.bottomnav a, .bottomnav summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    color: var(--ink-muted);
    text-decoration: none;
    min-width: 56px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.bottomnav a.active, .bottomnav summary.active {
    color: var(--brand-text);
    font-weight: 600;
}

/* Sheet (Mobile Menu) */
.sheet {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
}

.sheet summary {
    list-style: none;
}

.sheet summary::-webkit-details-marker {
    display: none;
}

.sheet-content {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: var(--shadow-float);
    padding: var(--space-4);
    display: none;
    flex-direction: column;
    gap: var(--space-2);
    max-height: 70vh;
    overflow-y: auto;
}

.sheet[open] .sheet-content {
    display: flex;
}

.sheet-content a {
    color: var(--ink);
    text-decoration: none;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.sheet-content a:last-child {
    border-bottom: none;
}

.sheet-content .label {
    margin-top: var(--space-2);
    margin-bottom: 4px;
}

/* Components */
.icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font: 600 15px/23px var(--font-sans);
    cursor: pointer;
    background: var(--brand);
    color: var(--on-brand);
    text-decoration: none;
    transition: background 150ms;
}

.btn:hover {
    background: var(--brand-strong);
}

.btn:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.btn.secondary {
    background: var(--surface);
    color: var(--brand-text);
    border-color: var(--line-strong);
}

.btn.secondary:hover {
    background: var(--brand-tint);
}

.btn.ghost {
    background: transparent;
    color: var(--brand-text);
    border-color: transparent;
}

.btn.ghost:hover {
    background: var(--brand-tint);
}

.btn.danger {
    background: var(--danger);
    color: #fff;
}

.btn.icon-only {
    padding: 8px;
    border-radius: var(--radius-sm);
}

.btn.small {
    padding: 6px 12px;
    font-size: 13px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 19px;
    font-weight: 600;
}

.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.danger { background: var(--danger-tint); color: var(--danger); }
.badge.info { background: var(--info-tint); color: var(--info); }
.badge.neutral { background: var(--surface-sunken); color: var(--ink-muted); }

.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: var(--space-4);
}

.kpi {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}

.kpi .value {
    font-size: 36px;
    line-height: 40px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.kpi .value small {
    font-size: 15px;
    font-weight: 500;
    color: var(--ink-muted);
    margin-left: 4px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table th {
    background: var(--surface-sunken);
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.table td {
    padding: 12px;
    border-top: 1px solid var(--line);
    vertical-align: middle;
}

.table tr:hover td {
    background: var(--brand-tint);
}

.table td.num, .table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.field label.cm-tile { text-transform: none; letter-spacing: 0; font: inherit; color: var(--ink); }

.field input, .field select, .field textarea {
    font: 400 15px/23px var(--font-sans);
    color: var(--ink);
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    width: 100%;
}

.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
    border-color: var(--line-strong);
}

.banner {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--info-tint);
    color: var(--ink);
    border: 1px solid var(--line);
    margin-top: var(--space-4);
}

.banner.warn { background: var(--warn-tint); }
.banner.danger { background: var(--danger-tint); }
.banner.ok { background: var(--ok-tint); }

.banner strong { display: block; }
.banner .actions { margin-left: auto; display: flex; gap: var(--space-2); flex-shrink: 0; }

.label {
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.num {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* Compatibility Layer */
.grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

article, .card, article.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: var(--space-4);
}

button, .button, input[type=submit] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font: 600 15px/23px var(--font-sans);
    cursor: pointer;
    background: var(--brand);
    color: var(--on-brand);
    text-decoration: none;
}

/* #630: nur echte Knöpfe verdunkeln; Reiter, Chips und Segmente haben eigene
   Hover-Regeln in components.css (Akte-Reiter zeigten sonst Orange). */
.button:hover, input[type=submit]:hover {
    background: var(--brand-strong);
}

button.secondary, .button.secondary, .outline, input[type=submit].secondary {
    background: var(--surface);
    color: var(--brand-text);
    border-color: var(--line-strong);
}

button.secondary:hover, .button.secondary:hover, .outline:hover {
    background: var(--brand-tint);
}

button.ghost, .button.ghost, .contrast {
    background: transparent;
    color: var(--brand-text);
    border-color: transparent;
}

a {
    color: var(--brand-text);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}

table th {
    background: var(--surface-sunken);
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

table td {
    padding: 12px;
    border-top: 1px solid var(--line);
    vertical-align: middle;
}

.table-container {
    overflow-x: auto;
}

input, select, textarea {
    font: 400 15px/23px var(--font-sans);
    color: var(--ink);
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    width: 100%;
}

label {
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-muted);
    display: block;
    margin-bottom: 6px;
}

form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

details.dropdown, details.menu {
    position: relative;
}

details.dropdown summary, details.menu summary {
    list-style: none;
    cursor: pointer;
}

details.dropdown summary::-webkit-details-marker, details.menu summary::-webkit-details-marker {
    display: none;
}

details.dropdown ul, details.menu ul, .menu-list {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-float);
    list-style: none;
    padding: var(--space-2);
    margin: 4px 0 0;
    min-width: 150px;
    z-index: 1000;
}

details.dropdown li, details.menu li, .menu-list li {
    padding: 0;
}

details.dropdown li a, details.menu li a, .menu-list li a, .menu-list li button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink);
    text-decoration: none;
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
}

details.dropdown li a:hover, details.menu li a:hover, .menu-list li a:hover, .menu-list li button:hover {
    background: var(--brand-tint);
}

.notification, .banner {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-top: var(--space-4);
}

.notification.is-neutral, .banner.is-neutral {
    background: var(--info-tint);
    color: var(--ink);
    border: 1px solid var(--line);
}

.notification.is-positive, .banner.is-positive {
    background: var(--ok-tint);
    color: var(--ink);
    border: 1px solid var(--line);
}

.notification.is-negative, .banner.is-negative {
    background: var(--danger-tint);
    color: var(--ink);
    border: 1px solid var(--line);
}

.container {
    width: 100%;
    max-width: none;
    padding: 0;
    margin: 0;
}

dialog {
    border: none;
    border-radius: var(--radius-md);
    padding: 0;
    width: 90%;
    max-width: 500px;
    background: var(--surface);
    color: var(--ink);
}

dialog::backdrop {
    background-color: rgba(0,0,0,0.5);
}

.badge-new { background: var(--info-tint); color: var(--info); }
.badge-ready { background: var(--ok-tint); color: var(--ok); }
.badge-sold { background: var(--surface-sunken); color: var(--ink-muted); }
.badge-archived { background: var(--warn-tint); color: var(--warn); }
.badge-default { background: var(--surface-sunken); color: var(--ink-muted); }

.stock-ok { color: var(--ok); font-weight: 600; }
.stock-warn { color: var(--warn); font-weight: 600; }
.stock-alert { color: var(--danger); font-weight: 600; }

.text-big {
    font-size: 36px;
    line-height: 40px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.feedback-fab {
    position: fixed;
    bottom: 84px;
    right: 20px;
    z-index: 1000;
    background-color: var(--brand);
    color: var(--on-brand);
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    box-shadow: var(--shadow-float);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

@media (min-width: 960px) {
    .feedback-fab {
        bottom: 20px;
    }
}

.feedback-fab:hover {
    background-color: var(--brand-strong);
}

.feedback-actions {
    display: flex;
    gap: 10px;
    margin-top: 1rem;
    justify-content: flex-end;
}

.feedback-thanks {
    padding: 1rem;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

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

/* Kopfzeile am Handy: nur Symbole, Namen ausblenden */
@media (max-width: 959px) {
    .topbar .tenant-name,
    .topbar .user-name { display: none; }
}

/* Kennzahl-Zustände und Hilfsklassen für Listen, Formulare, Login (Phase B/C) */
.kpi.is-ok .value { color: var(--ok); }
.kpi.is-warn .value { color: var(--warn); }
.kpi.is-danger .value { color: var(--danger); }
.kpi .badge { align-self: flex-start; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
.filter-bar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; margin-bottom: var(--space-4); }
.filter-bar .field { flex: 1 1 200px; min-width: 0; }
.filter-bar .btn { flex: 0 0 auto; }
.empty { padding: var(--space-8) var(--space-4); text-align: center; color: var(--ink-muted); background: var(--surface); border-radius: var(--radius-md); border: 1px dashed var(--line-strong); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
@media (min-width: 600px) { .field-row { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }
.field-row > * { min-width: 0; }
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; padding-top: var(--space-3); border-top: 1px solid var(--line); }
.card.narrow { max-width: 720px; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.muted { color: var(--ink-muted); }
.check { display: flex; align-items: center; gap: var(--space-2); font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.check input { width: auto; }
.login-card { max-width: 420px; margin: var(--space-8) auto; }
.brand-wordmark { font-family: var(--font-display); font-weight: 700; font-size: 28px; color: var(--brand-text); text-align: center; margin-bottom: var(--space-4); }
.brand-wordmark .cm-logo { justify-content: center; font-size: 28px; padding: 0; color: var(--ink); }
.is-unread { font-weight: 600; }
.text-ok { color: var(--ok); font-weight: 600; }
.text-warn { color: var(--warn); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); }

/* Filterleiste: waagerecht, unabhängig von den allgemeinen form-Regeln */
form.filter-bar { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; justify-content: flex-start; gap: var(--space-3); margin: 0 0 var(--space-4); max-width: none; }
form.filter-bar .field { flex: 1 1 200px; margin: 0; }
form.filter-bar .field select, form.filter-bar .field input { margin: 0; }
.page-head:empty, .page-head > .page-actions:empty { display: none; }

/* Detailseiten, Hof, Kalender (Phase D) */
.kv { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr; gap: var(--space-2) var(--space-3); margin: 0; }
.kv dt { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); align-self: center; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.spot { padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }
.spot .label { margin: 0; }
.calendar { table-layout: fixed; }
.calendar th, .calendar td { vertical-align: top; min-height: 96px; }
.calendar td .badge { display: inline-flex; margin: 2px 2px 0 0; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-2); }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); }
.detail-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-4); align-items: start; }
@media (min-width: 1100px) { .detail-grid { grid-template-columns: 2fr 3fr; } }
.detail-grid .card { min-width: 0; }

/* Kontrollkästchen und Radios nicht auf volle Breite ziehen */
.field input[type="checkbox"], .field input[type="radio"], input[type="checkbox"], input[type="radio"] { width: auto; margin: 0; }
.field > input[type="checkbox"] { align-self: flex-start; }

/* Stellplatz-Karte: Badges nicht dehnen */
.spot .badge { align-self: flex-start; }

/* #419: Anker „Was ist neu“ nicht unter Kopfzeile/Reitern verstecken */
#was-ist-neu { scroll-margin-top: 140px; }
/* #581: lange Wörter (z. B. Pfade) brechen um, kein seitliches Scrollen am Handy */
#was-ist-neu li { overflow-wrap: anywhere; }
/* #419: Akte bei 360 px – Banner-Knöpfe umbrechen, Tabellen scrollen statt die Seite zu verbreitern */
.banner { flex-wrap: wrap; min-width: 0; }
.banner .actions { flex-shrink: 1; flex-wrap: wrap; }
.table-container { max-width: 100%; min-width: 0; }
/* #420: Link im Update-Hinweis als Tippfläche ≥ 44 px */
.banner a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }

/* Passwortstärke (#433) */
.cm-passwort-regeln { margin: 0 0 1rem; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 8px; }
.cm-passwort-regeln ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.cm-staerke { margin-top: .5rem; min-height: 2.5rem; }
.cm-staerke__balken { width: 100%; height: .75rem; }
.cm-staerke__stufe { margin: .25rem 0 0; }
.cm-staerke__stufe.is-gut { color: var(--ok); }
.cm-staerke__stufe.is-schwach, .cm-staerke__hinweis.is-schwach { color: var(--danger); }
.cm-staerke__hinweis { margin: .25rem 0 0; }
.cm-staerke__tipps { margin: .25rem 0 0; padding-left: 1.2rem; }

/* Kontexthilfe (#450): am PC Leiste von rechts, am Handy Blatt von unten (wie Glocke/Mehr) */
.cm-hilfe-dialog { padding: 0 16px 16px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-float); overflow: auto; }
.cm-hilfe-dialog::backdrop { background: rgba(10, 12, 16, .45); }
@media (min-width: 768px) {
  .cm-hilfe-dialog { margin: 0 0 0 auto; width: min(440px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
}
@media (max-width: 767px) {
  .cm-hilfe-dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; max-height: 85dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
.cm-hilfe-kopf { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.cm-hilfe-kopf h2 { margin: 0; font-size: 17px; line-height: 1.3; }
/* #1364: kurze Einführung + aufklappbare Abschnitte statt Fließtext */
.cm-hilfe-seite { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
.cm-hilfe-ueberschrift { font-size: 16px; margin: 8px 0 4px; }
.cm-hilfe-einfuehrung-titel { font-size: 15px; margin: 12px 0 4px; }
.cm-hilfe-einfuehrung p { margin: 0 0 8px; }
.cm-hilfe-klappe { margin: 0 0 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.cm-hilfe-klappe summary { display: flex; align-items: center; min-height: 44px; padding: 0 12px; cursor: pointer; list-style: none; font-weight: 600; }
.cm-hilfe-klappe summary::-webkit-details-marker { display: none; }
.cm-hilfe-klappe summary::before { content: ""; flex: none; width: 10px; height: 10px; margin-right: 8px; border-right: 2px solid var(--ink-muted); border-bottom: 2px solid var(--ink-muted); transform: rotate(-45deg) translateY(-1px); transition: transform .15s; }
.cm-hilfe-klappe[open] summary::before { transform: rotate(45deg) translateY(-1px); }
.cm-hilfe-klappe[open] summary { border-bottom: 1px solid var(--line); }
.cm-hilfe-klappe-inhalt { padding: 4px 12px 8px; }
.cm-hilfe-klappe-inhalt p { margin: 8px 0 0; }
.cm-hilfe-klappe-inhalt ul, .cm-hilfe-klappe-inhalt ol { margin: 8px 0 0; padding-left: 1.2rem; }
.cm-hilfe-klappe-inhalt li { margin: 2px 0; }
.cm-hilfe-klappe-inhalt table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.cm-hilfe-klappe-inhalt th, .cm-hilfe-klappe-inhalt td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
.cm-hilfe-klappe-inhalt blockquote { margin: 8px 0 0; padding: 6px 10px; border-left: 3px solid var(--line-strong); color: var(--ink-muted); }
.cm-hilfe-verwandte-liste { list-style: none; margin: 0; padding: 0; }
.cm-hilfe-verwandte-liste li { border-top: 1px solid var(--line); }
.cm-hilfe-verwandte-liste li:first-child { border-top: 0; }
.cm-hilfe-verwandte-liste a { display: flex; align-items: center; min-height: 44px; padding: 0 4px; }
.cm-hilfe-frage { padding: 12px 0 0; }
.cm-hilfe-frage h3 { font-size: 15px; margin: 0 0 8px; }
.cm-hilfe-eingabe { display: flex; gap: 8px; align-items: center; }
.cm-hilfe-eingabe input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
.cm-hilfe-eingabe .cm-iconbtn[disabled] { opacity: .45; cursor: not-allowed; }
.cm-hilfe-eingabe .cm-btn, .cm-hilfe-eingabe .cm-iconbtn { min-height: 44px; min-width: 44px; }
/* #575: „Wird bearbeitet …“ während die Hilfe-KI arbeitet (htmx setzt die
   Klasse htmx-request, solange die Anfrage läuft — kein Skript, nur Text). */
.cm-hilfe-warten { padding: 8px 0 0; font-size: 14px; color: var(--ink-muted); }
.cm-hilfe-warten.htmx-request { display: block; }

/* #1072/#1073: Hilfe-Fußzeile — Support-Nummer, E-Mail und Meldelink als Tippfläche ≥ 44 px (wie #420) */
.cm-hilfe-fuss { margin-top: 12px; padding: 12px 0 0; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
.cm-hilfe-fuss-zeile { margin: 0 0 4px; }
.cm-hilfe-fuss a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }

/* #459: Reiter der Ansichten (Schadensbild, Eingangsprüfung) auch am PC; .cm-zonen allein bleibt ab 760 px aus */
@media (min-width:760px){.cm-zonen.cm-ansichten{display:grid!important}}

/* #461 Akte: Knöpfe immer unter dem Titel (sonst springen sie je nach Titellänge); leerer Sauber-Check-Kasten unsichtbar */
.cm-pagehead.cm-pagehead-unten{flex-direction:column;align-items:flex-start}
.cm-pagehead.cm-pagehead-unten .cm-actions{justify-content:flex-start}
#clean-box:not(:has(*)){display:none}

/* #468: Sprungziele der Fälligkeitslisten nicht unter der festen Kopfleiste verstecken */
.cm-card[id^="faellig-"]{scroll-margin-top:80px}

/* #1051: Kassenbuch „Bar rein / Bar raus“ als Kacheln – ganze Fläche tippbar, mindestens 48 px */
.kasse-art{border:0;margin:0;padding:0;min-width:0}
.kasse-art-wahl{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px}
.kasse-art-kachel{position:relative;display:flex;align-items:center;justify-content:center;gap:10px;min-height:56px;padding:0 16px;border:1px solid var(--line-strong,var(--line));border-radius:var(--radius-md,8px);background:var(--surface);font-weight:600;cursor:pointer}
.kasse-art-kachel input{width:20px;height:20px;margin:0;accent-color:var(--brand)}
.kasse-art-kachel:has(input:checked){border-color:var(--brand);box-shadow:inset 0 0 0 1px var(--brand)}
.kasse-art-kachel:has(input:focus-visible){outline:2px solid var(--brand);outline-offset:2px}

/* #1054 Punkt 8: GwG-Hinweis im Kassenformular erst ab der Schwelle (kasse.js) */
[data-gwg-ab][hidden] {
  display: none;
}

/* #1076: Google-Fahrzeuganzeigen-Vorschau – lange Gründe und Kennungen brechen um
   (kein waagerechter Überlauf am Handy), die Aufklapp-Fläche ist ≥ 44 px hoch. */
.cm-umbruch { overflow-wrap: anywhere; min-width: 0; }
.cm-google-vorschau { min-width: 0; }
.cm-google-vorschau details { margin: 0; }
.cm-google-vorschau summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  font-size: 15px;
  line-height: 23px;
  color: var(--ink);
}
.cm-google-vorschau summary::-webkit-details-marker { display: none; }
.cm-google-vorschau-zahl { color: var(--ink-muted); font-weight: 600; }
.cm-google-vorschau-liste {
  list-style: disc;
  margin: var(--space-1) 0 0;
  padding-left: 1.4rem;
  color: var(--ink);
}
.cm-google-vorschau-liste li { overflow-wrap: anywhere; }

/* #1016 Vertragsvorlagen: drei Spalten am PC (ab 1200 px), Marken, Muster-Vergleich */
/* Handy (unter 768 px) nur lesen, Bearbeiten ab Tablet */
.vorlagen-handy { display: none; }
@media (max-width: 767.98px) {
  .vorlagen-handy { display: flex; }
  .vorlagen-gross { display: none; }
}
.cm-vorlage-lesetext { font-size: 15px; line-height: 22px; margin-top: 6px; overflow-wrap: anywhere; }
.cm-vorlage-aus { opacity: .62; }

.cm-vorlagen-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.cm-vorlagen-spalten { display: none; }
@media (min-width: 1200px) {
  .cm-vorlagen-layout { grid-template-columns: 280px minmax(0, 1fr) 260px; }
  .cm-vorlagen-spalten { display: flex; flex-direction: column; gap: var(--space-3); }
}
.cm-vorlagen-mitte { display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; }
.cm-vorlagen-mitte .cm-card { scroll-margin-top: 84px; }
/* Unter 1200 px einspaltig: Variablen einklappbar oben */
.cm-vorlagen-variablen { order: -1; min-width: 0; }
@media (min-width: 1200px) {
  .cm-vorlagen-variablen { order: 0; }
}

.cm-vorlagen-sprungliste { display: flex; flex-direction: column; gap: 4px; }
.cm-vorlagen-sprungliste a { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--radius-md); text-decoration: none; color: var(--ink); }
.cm-vorlagen-sprungliste a:hover, .cm-vorlagen-sprungliste a:focus-visible { background: var(--surface-sunken); }
.cm-vorlagen-sprungliste .t { font-weight: 700; font-size: 15px; line-height: 20px; overflow-wrap: anywhere; }
.cm-vorlagen-sprungliste .s { font-size: 12.5px; line-height: 17px; color: var(--ink-muted); overflow-wrap: anywhere; }

.cm-variablen-blatt { margin: 0; }
.cm-variablen-blatt summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; cursor: pointer; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; background: var(--surface); margin-bottom: 0; }
.cm-variablen-blatt summary::-webkit-details-marker { display: none; }
.cm-variablen-liste { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }
@media (min-width: 1200px) {
  .cm-variablen-blatt summary { display: none; }
  .cm-variablen-blatt > .cm-variablen-liste { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow: auto; }
}
.cm-variable { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); text-align: left; font: inherit; cursor: pointer; min-height: 48px; color: var(--ink); }
.cm-variable:hover, .cm-variable:focus-visible { border-color: var(--line-strong); }
.cm-variable .name { font: 600 12.5px/1.3 var(--font-mono); color: var(--brand-text); }
.cm-variable .desc { font-size: 12.5px; line-height: 16px; color: var(--ink-muted); }

/* Variablen als Marke: bekannte farbig, unbekannte rot mit „unbekannt“ */
.cm-vorlage-marke { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--brand-tint); color: var(--brand-text); font: 600 .88em/1.4 var(--font-mono); white-space: nowrap; }
.cm-vorlage-marke.unbekannt { background: var(--danger-tint); color: var(--danger); }
.cm-vorlage-marke .unbekannt-wort { font-weight: 400; font-size: .9em; font-style: normal; }

/* Vorschau-Zeile unter jedem Textfeld */
.cm-marken-vorschau { display: block; padding: 8px 12px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); background: var(--surface-sunken); color: var(--ink-muted); font: 500 13px/1.7 var(--font-mono); min-height: 38px; white-space: pre-wrap; word-break: break-word; }
.cm-marken-vorschau:empty { display: none; }

/* Muster-Vergleich: „Dein Text“ gegen „Neues Muster“ */
.cm-muster-vergleich { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.cm-muster-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 991.98px) { .cm-muster-spalten { grid-template-columns: 1fr; } }
.cm-muster-vergleich.ist-zugeklappt .cm-muster-spalten { display: none; }
.cm-muster-text { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 12px 14px; min-width: 0; }
.cm-muster-text.neu { border: 2px solid var(--ok-line); }
.cm-muster-text-inhalt { font-size: 15px; line-height: 24px; overflow-wrap: anywhere; }
.cm-muster-text-inhalt del { background: var(--danger-tint); color: var(--danger); text-decoration: none; border-radius: 3px; padding: 0 1px; }
.cm-muster-text-inhalt ins { background: var(--ok-tint); color: var(--ok); text-decoration: none; border-radius: 3px; padding: 0 1px; }

/* Speichern-Leiste bleibt am Tablet (768–1199 px) unten erreichbar, siehe K7 */
.cm-vorlagen-fuss { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 0; background: var(--ground); z-index: 5; }
.cm-vorlagen-fuss .cm-btn { flex: 1; }
@media (min-width: 1200px) { .cm-vorlagen-fuss { display: none; } }
