
:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --sidebar: #111827;
    --sidebar-text: #d1d5db;
    --accent: #2563eb;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 245px;
    background: var(--sidebar);
    color: white;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
}
.brand { font-size: 22px; font-weight: 700; padding: 8px 10px 22px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a {
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 8px;
}
.sidebar a:hover, .sidebar a.active {
    background: #1f2937;
    color: white;
}
.sidebar-footer { margin-top: auto; border-top: 1px solid #374151; padding-top: 14px; }
.small { color: #9ca3af; font-size: 13px; margin: 0 10px 8px; }
.content { margin-left: 245px; width: calc(100% - 245px); padding: 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 26px; }
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.btn {
    display: inline-block; border: 0; border-radius: 8px; padding: 10px 14px;
    text-decoration: none; cursor: pointer; font-weight: 600;
    transition: transform .14s ease, box-shadow .18s ease, filter .18s ease, background-color .18s ease, border-color .18s ease;
    touch-action: manipulation; user-select: none;
}
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: #e5e7eb; color: #111827; }
.btn:hover:not(:disabled):not([aria-disabled="true"]){transform:translateY(-2px);filter:brightness(.96);box-shadow:0 7px 17px rgba(15,23,42,.17)}
.btn:active:not(:disabled):not([aria-disabled="true"]){transform:translateY(1px) scale(.98);filter:brightness(.90);box-shadow:0 2px 5px rgba(15,23,42,.14);transition-duration:.05s}
.btn:focus-visible{outline:3px solid rgba(37,99,235,.32);outline-offset:3px}
.btn:disabled,.btn[aria-disabled="true"]{cursor:not-allowed;opacity:.58;box-shadow:none;transform:none}
.btn.is-processing{cursor:wait!important;pointer-events:none;opacity:.78;position:relative}
.btn.is-processing::after{content:"";display:inline-block;width:13px;height:13px;margin-left:9px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;vertical-align:-2px;animation:akm-button-spin .65s linear infinite}
@keyframes akm-button-spin{to{transform:rotate(360deg)}}
table { width: 100%; border-collapse: collapse; background: white; }
th, td { border-bottom: 1px solid var(--border); padding: 10px; text-align: left; }
th { font-size: 13px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-group { display: grid; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; }
input, textarea {
    width: 100%; padding: 10px 11px; border: 1px solid #d1d5db;
    border-radius: 8px; font: inherit; background: white;
}
textarea { min-height: 110px; resize: vertical; }
.notice { padding: 11px 13px; border-radius: 8px; background: #ecfdf5; margin-bottom: 16px; }
.error { background: #fef2f2; }
@media (max-width: 900px) {
    .sidebar { width: 190px; }
    .content { margin-left: 190px; width: calc(100% - 190px); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.search-row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.search-row input[type="text"], .search-row input:not([type]) { flex:1; min-width:260px; }
.check-inline { display:flex; align-items:center; gap:7px; font-weight:400; margin-left:auto; }
.check-inline input { width:auto; }
.btn-small { padding:7px 10px; font-size:13px; }
.badge { display:inline-block; padding:5px 8px; border-radius:999px; font-size:12px; font-weight:700; }
.badge-ok { background:#ecfdf5; color:#065f46; }
.badge-off { background:#f3f4f6; color:#6b7280; }
.row-muted { opacity:.6; }
.toolbar { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:16px; }
.toolbar form { margin:0; }
.detail-head { display:flex; justify-content:space-between; gap:20px; align-items:flex-start; margin-bottom:20px; }
.detail-head h2 { margin:3px 0 0; }
.eyebrow { font-size:12px; color:var(--muted); font-weight:700; letter-spacing:.04em; text-transform:uppercase; }
.muted { color:var(--muted); }
.detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
.detail-grid > div { padding-bottom:12px; border-bottom:1px solid var(--border); }
.detail-label { display:block; color:var(--muted); font-size:12px; margin-bottom:5px; }
.notes-box { margin-top:20px; padding:14px; background:#f9fafb; border-radius:8px; }
.section-head { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom:12px; }
.section-head h2 { margin:0; }
@media (max-width:700px) {
    .detail-grid { grid-template-columns:1fr; }
    .check-inline { margin-left:0; }
}

select { width:100%; padding:10px 11px; border:1px solid #d1d5db; border-radius:8px; font:inherit; background:white; }

.breadcrumb { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:18px; font-size:14px; }
.breadcrumb a { color:var(--accent); text-decoration:none; }
.breadcrumb span { color:var(--muted); }
.catalog-link { color:var(--text); text-decoration:none; }
.catalog-link:hover { color:var(--accent); }
.badge-info { background:#eff6ff; color:#1d4ed8; }

.small-stat{font-size:18px!important;line-height:1.25;word-break:break-word}


.form-separator {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 26px 0;
}

.customer-picker {
    position: relative;
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.customer-results {
    display: none;
    position: absolute;
    z-index: 100;
    top: 70px;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0,0,0,.12);
    max-height: 330px;
    overflow-y: auto;
}

.customer-result-item {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: white;
    padding: 11px 13px;
    text-align: left;
    cursor: pointer;
    display: grid;
    gap: 4px;
}

.customer-result-item:hover {
    background: #f9fafb;
}

.customer-result-item span,
.customer-result-empty {
    color: var(--muted);
    font-size: 12px;
}

.customer-result-empty {
    padding: 12px 13px;
}

.selected-customer {
    padding: 10px 12px;
    border-radius: 8px;
    background: #ecfdf5;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.selected-customer > div {
    display: grid;
    gap: 3px;
}

.selected-customer span {
    color: #047857;
    font-size: 12px;
}

.new-customer-box {
    margin-top: 12px;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.new-customer-box h3 {
    margin-top: 0;
}


.dynamic-category-level {
    margin-top: 14px;
}

.dynamic-category-level label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.dynamic-category-level select {
    width: 100%;
}

.fault-quick-row{margin-bottom:8px}.fault-quick-select{width:100%}


.fault-quick-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.fault-add-btn {
    min-width: 42px;
    font-size: 20px;
    line-height: 1;
}

.fault-manage-link {
    white-space: nowrap;
    font-size: .9rem;
}

.fault-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.fault-modal {
    width: min(520px, 100%);
    background: #fff;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 18px 50px rgba(0,0,0,.25);
}

.fault-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.fault-modal-close {
    border: 0;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
}

.fault-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.inline-check {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.fault-admin-card {
    padding: 16px 0;
    border-bottom: 1px solid var(--border, #ddd);
}

.fault-admin-card:last-child {
    border-bottom: 0;
}

.fault-admin-main {
    display: grid;
    grid-template-columns: minmax(260px,1fr) 120px 180px auto;
    gap: 12px;
    align-items: end;
}

.fault-checks {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-bottom: 8px;
}

.fault-admin-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.fault-links {
    margin-top: 12px;
    padding: 12px;
    background: rgba(0,0,0,.025);
    border-radius: 8px;
}

.fault-link-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 8px 0;
}

.fault-link-chip {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 5px 8px;
    border: 1px solid var(--border, #ddd);
    border-radius: 999px;
}

.fault-link-chip button {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.fault-add-link {
    display: grid;
    grid-template-columns: minmax(220px,1fr) auto auto;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

@media (max-width: 800px) {
    .fault-admin-main,
    .fault-add-link,
    .fault-quick-row {
        grid-template-columns: 1fr;
    }
}


.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border, #ddd);
    text-align: left;
}

.table th {
    font-size: .9rem;
    color: var(--muted, #666);
}


/* Native modal for quick Fehlerbild creation */
.fault-dialog {
    width: min(520px, calc(100vw - 32px));
    max-width: 520px;
    border: 0;
    border-radius: 12px;
    padding: 0;
    background: #fff;
    box-shadow: 0 18px 50px rgba(0,0,0,.28);
}

.fault-dialog::backdrop {
    background: rgba(0,0,0,.38);
}

.fault-dialog-inner {
    padding: 18px;
    margin: 0;
}

.fault-dialog .fault-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.fault-dialog .fault-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}


/* v4.0 Dashboard */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.dashboard-stat-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid var(--border, #ddd);
    border-radius: 12px;
    padding: 18px;
    transition: transform .12s ease, box-shadow .12s ease;
}

.dashboard-stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
}

.dashboard-stat-label {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.dashboard-stat-value {
    font-size: 2rem;
    line-height: 1;
    font-weight: 700;
    margin-bottom: 8px;
}

.dashboard-stat-note {
    font-size: .85rem;
    color: var(--muted, #666);
}

.dashboard-section-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.dashboard-section-header h2 {
    margin: 0;
}

@media (max-width: 1000px) {
    .dashboard-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
}


/* v4.1 - clean radio/checkbox alignment in Fehlerbild editor */
form.card .inline-check {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: auto !important;
    margin: 8px 0 !important;
    padding: 0 !important;
    text-align: left !important;
}

form.card .inline-check input[type="radio"],
form.card .inline-check input[type="checkbox"] {
    flex: 0 0 auto !important;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    padding: 0 !important;
}

form.card .inline-check + .inline-check {
    margin-left: 18px !important;
}

#category_selection .inline-check {
    margin-left: 0 !important;
}

@media (max-width: 700px) {
    form.card .inline-check {
        display: flex !important;
        margin: 8px 0 !important;
    }

    form.card .inline-check + .inline-check {
        margin-left: 0 !important;
    }
}


/* v4.6 - clean Modellfeld checkbox alignment in category editor */
.non-repair-only {
    display: block !important;
}

.non-repair-only > label:first-child {
    display: block !important;
    margin-bottom: 8px !important;
}

.non-repair-only .inline-check {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left !important;
}

.non-repair-only .inline-check input[type="checkbox"] {
    flex: 0 0 auto !important;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
}

.non-repair-only .muted {
    margin-top: 8px !important;
    text-align: left !important;
}


/* v5.0 repair service price matrix */
.repair-price-grid {
    margin-top: 14px;
    border: 1px solid var(--border, #ddd);
    border-radius: 10px;
    overflow: hidden;
}

.repair-price-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 180px;
    gap: 16px;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border, #ddd);
}

.repair-price-row:last-child {
    border-bottom: 0;
}

.repair-price-input {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px;
    align-items: center;
}

.repair-price-input input {
    width: 100%;
}

.price-list-print {
    background: #fff;
    padding: 18px;
}

.price-list-title {
    margin-bottom: 18px;
}

.price-list-title h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.price-matrix {
    width: 100%;
    border-collapse: collapse;
}

.price-matrix th,
.price-matrix td {
    border: 1px solid #888;
    padding: 9px 10px;
    text-align: left;
}

.price-matrix th {
    font-weight: 700;
    background: #f2f2f2;
}

.price-matrix th:not(:first-child),
.price-matrix td:not(:first-child) {
    text-align: center;
    white-space: nowrap;
}

@media (max-width: 800px) {
    .repair-price-row {
        grid-template-columns: 1fr;
    }

    .price-list-print {
        overflow-x: auto;
    }
}

@media print {
    .no-print,
    .sidebar,
    aside,
    nav {
        display: none !important;
    }

    body,
    .app,
    .main,
    main,
    .content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
        background: #fff !important;
    }

    .price-list-print {
        padding: 0 !important;
    }

    .price-list-title h1 {
        font-size: 20px;
    }

    .price-matrix {
        font-size: 11px;
    }

    .price-matrix th,
    .price-matrix td {
        padding: 6px 7px;
    }
}


/* v5.7 "ab Preis" */
.repair-price-input {
    grid-template-columns: 1fr auto auto !important;
}

.repair-price-from {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    margin: 0 0 0 6px !important;
    white-space: nowrap;
    font-weight: 600;
}

.repair-price-from input[type="checkbox"] {
    width: 17px !important;
    height: 17px !important;
    margin: 0 !important;
    flex: 0 0 auto;
}


/* v5.8 restore layout for existing repair assignments */
.assignment-list {
    margin-top: 10px;
    border: 1px solid var(--border, #ddd);
    border-radius: 10px;
    overflow: hidden;
}

.assignment-row {
    display: grid !important;
    grid-template-columns: minmax(320px, 1fr) 110px auto !important;
    gap: 14px !important;
    align-items: center !important;
    padding: 11px 13px !important;
    border-bottom: 1px solid var(--border, #ddd);
}

.assignment-row:last-child {
    border-bottom: 0;
}

.assignment-row > div:first-child {
    min-width: 0;
}

.assignment-price {
    text-align: right !important;
    font-weight: 600;
    white-space: nowrap;
}

.assignment-row .btn {
    white-space: nowrap;
}

@media (max-width: 760px) {
    .assignment-row {
        grid-template-columns: 1fr !important;
        gap: 7px !important;
    }

    .assignment-price {
        text-align: left !important;
    }
}


/* v5.9 customer link search dropdown */
.customer-link-search {
    position: relative;
}

.customer-link-search .customer-results {
    top: calc(100% + 6px) !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 280px;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0,0,0,.14);
    overflow-y: auto;
}

.customer-link-search .customer-link-row {
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center;
    gap: 14px;
    cursor: default;
    padding: 10px 12px;
}

.customer-link-search .customer-link-row > div {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.customer-link-search .customer-link-row strong {
    font-size: 14px;
}

.customer-link-search .customer-link-row span {
    display: block;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.customer-link-search .customer-link-row form {
    margin: 0;
}

.customer-link-search .customer-link-row .btn {
    white-space: nowrap;
}

@media (max-width: 700px) {
    .customer-link-search .customer-link-row {
        grid-template-columns: 1fr !important;
    }

    .customer-link-search .customer-link-row form {
        justify-self: start;
    }
}


/* v6.1 - no hover/focus decoration on sidebar logo */
.sidebar .brand-logo-link {
    display: inline-block !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: inherit !important;
}

.sidebar .brand-logo-link:hover,
.sidebar .brand-logo-link:active,
.sidebar .brand-logo-link:focus {
    background: transparent !important;
    color: inherit !important;
    box-shadow: none !important;
    outline: none !important;
}

/* v17.5.4: two-column navigation toolbar.
   Column 1 is reserved exclusively for Back. Page actions always wrap inside column 2. */
.toolbar-nav {
    display: grid !important;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 8px;
    align-items: start;
    margin-bottom: 16px;
}
.toolbar-nav .toolbar-back {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: flex-start;
    min-width: max-content;
}
.toolbar-nav .toolbar-actions {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    align-content: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}
.toolbar-nav .toolbar-actions form { margin: 0; }
.toolbar-nav .toolbar-back:empty { display: none; }
.toolbar-nav .toolbar-back:empty + .toolbar-actions {
    grid-column: 1 / -1;
}
@media (max-width: 640px) {
    .toolbar-nav { column-gap: 6px; }
    .toolbar-nav .toolbar-actions { gap: 8px; }
}

/* v17.8.1: larger quick-create popup for Zubehör / Fehlerbilder */
#quick_template_modal.fault-dialog {
    width: min(900px, calc(100vw - 48px));
    max-width: 900px;
}

#quick_template_modal .fault-dialog-inner {
    min-width: 0 !important;
    min-height: 430px;
    padding: 28px 30px;
    box-sizing: border-box;
}

#quick_template_modal .fault-modal-header {
    margin-bottom: 24px;
}

#quick_template_modal .fault-modal-header strong {
    font-size: 1.35rem;
}

#quick_template_modal .form-group {
    margin-bottom: 20px;
}

#quick_template_modal .fault-modal-actions {
    margin-top: 28px;
}

@media (max-width: 700px) {
    #quick_template_modal.fault-dialog {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
    }

    #quick_template_modal .fault-dialog-inner {
        min-height: 0;
        padding: 20px;
    }
}


/* v17.12: unified CRM dialogs */
body.crm-dialog-open { overflow: hidden; }
.crm-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .12s ease;
}
.crm-dialog-overlay[hidden] { display: none !important; }
.crm-dialog-overlay.is-open { opacity: 1; }
.crm-dialog {
    width: min(640px, calc(100vw - 32px));
    max-height: min(80vh, 720px);
    overflow: auto;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 0 18px;
    position: relative;
    padding: 30px;
    border: 1px solid rgba(148, 163, 184, .35);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    transform: translateY(8px) scale(.985);
    transition: transform .12s ease;
}
.crm-dialog-overlay.is-open .crm-dialog { transform: translateY(0) scale(1); }
.crm-dialog-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #eaf2ff;
    color: #155eef;
    font-size: 26px;
    font-weight: 800;
}
.crm-dialog.is-danger .crm-dialog-icon {
    background: #fff0ee;
    color: #b42318;
}
.crm-dialog-content { min-width: 0; padding-right: 26px; }
.crm-dialog-content h2 { margin: 1px 0 10px; font-size: 1.35rem; }
.crm-dialog-message {
    white-space: pre-line;
    line-height: 1.55;
    color: #475467;
    overflow-wrap: anywhere;
}
.crm-dialog-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: #f2f4f7;
    color: #475467;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.crm-dialog-close:hover { background: #e4e7ec; }
.crm-dialog-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #eaecf0;
}
.crm-dialog-actions .btn { min-width: 118px; justify-content: center; }
.btn-danger {
    background: #b42318 !important;
    border-color: #b42318 !important;
    color: #fff !important;
}
.btn-danger:hover { background: #912018 !important; border-color: #912018 !important; }
@media (max-width: 620px) {
    .crm-dialog { grid-template-columns: 44px minmax(0,1fr); padding: 22px; gap: 0 14px; }
    .crm-dialog-icon { width: 42px; height: 42px; font-size: 22px; }
    .crm-dialog-actions { flex-direction: column-reverse; }
    .crm-dialog-actions .btn { width: 100%; }
}

/* v17.63 – zentrale mobile Darstellung für die gesamte CRM */
@media (max-width: 760px) {
    html, body { max-width: 100%; overflow-x: hidden; }
    .content { min-width: 0; overflow-x: hidden; }
    .card { min-width: 0; max-width: 100%; }
    .form-grid, .detail-grid { grid-template-columns: minmax(0,1fr) !important; }
    .form-group.full { grid-column: auto; }
    .search-row { align-items: stretch; flex-direction: column; }
    .search-row input[type="text"], .search-row input:not([type]) { min-width: 0; width: 100%; }
    .detail-head, .section-head { align-items: stretch; flex-direction: column; }
    .detail-head .toolbar, .section-head .toolbar { width: 100%; }
    img, video, canvas { max-width: 100%; height: auto; }
    pre, code { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }

    table.crm-mobile-table-cards {
        display: block;
        width: 100%;
        border: 0;
        background: transparent;
    }
    table.crm-mobile-table-cards thead,
    table.crm-mobile-table-cards > tr:first-child:has(th) { display: none; }
    table.crm-mobile-table-cards tbody {
        display: grid;
        width: 100%;
        gap: 13px;
    }
    table.crm-mobile-table-cards tbody tr {
        display: block;
        width: 100%;
        overflow: hidden;
        border: 1px solid #e2e8f0;
        border-radius: 13px;
        background: #fff;
        box-shadow: 0 3px 12px rgba(15,23,42,.07);
    }
    table.crm-mobile-table-cards tbody td {
        display: grid;
        grid-template-columns: minmax(92px, .8fr) minmax(0, 1.2fr);
        align-items: start;
        gap: 14px;
        width: 100%;
        min-width: 0 !important;
        padding: 11px 13px;
        border: 0;
        border-bottom: 1px solid #edf0f4;
        text-align: right !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }
    table.crm-mobile-table-cards tbody td:last-child { border-bottom: 0; }
    table.crm-mobile-table-cards tbody td::before {
        content: attr(data-label);
        min-width: 0;
        color: #526174;
        font-size: 12px;
        font-weight: 800;
        line-height: 1.4;
        text-align: left;
        overflow-wrap: anywhere;
    }
    table.crm-mobile-table-cards tbody td.crm-mobile-cell-unlabelled {
        display: block;
        text-align: left !important;
    }
    table.crm-mobile-table-cards tbody td.crm-mobile-cell-unlabelled::before { display: none; }
    table.crm-mobile-table-cards tbody td > * { min-width: 0; max-width: 100%; }
    table.crm-mobile-table-cards tbody td input:not([type="checkbox"]):not([type="radio"]),
    table.crm-mobile-table-cards tbody td select,
    table.crm-mobile-table-cards tbody td textarea { width: 100%; min-width: 0 !important; }
    table.crm-mobile-table-cards tbody td .button,
    table.crm-mobile-table-cards tbody td .btn { max-width: 100%; white-space: normal; }

    table.crm-mobile-table-scroll { min-width: 720px; }
    table.crm-mobile-table-scroll:before { content: none; }
    .table-responsive, .webmgr-table-wrap, .crm-table-scroll {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-inline: contain;
    }
}

@media (max-width: 480px) {
    table.crm-mobile-table-cards tbody td { grid-template-columns: minmax(82px,.75fr) minmax(0,1.25fr); padding: 10px 11px; gap: 10px; }
    table.crm-mobile-table-cards tbody td::before { font-size: 11px; }
}

/* v17.64 – zentrale Navigation für Einstellungen */
.settings-tabs{
    display:flex;
    align-items:stretch;
    gap:8px;
    flex-wrap:wrap;
    margin:0 0 24px;
    padding:0;
}
.settings-tab{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:42px;
    padding:9px 16px;
    border:1px solid #d9dee7;
    border-radius:10px;
    background:#f3f5f8;
    color:#1f2937;
    text-align:center;
    text-decoration:none;
    font-weight:700;
    line-height:1.25;
    transition:background .15s ease,border-color .15s ease,color .15s ease,box-shadow .15s ease;
}
.settings-tab:hover{background:#e9edf3;border-color:#cbd2dc;color:#111827}
.settings-tab.is-active{background:#172033;border-color:#172033;color:#fff;box-shadow:0 2px 6px rgba(15,23,42,.12)}
@media(max-width:700px){
    .settings-tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:18px}
    .settings-tab{width:100%;min-height:46px;padding:9px 8px;font-size:14px;box-sizing:border-box}
    .settings-tab:last-child:nth-child(odd){grid-column:1/-1}
}

/* v17.65 – Herkunft von Aufträgen im gemeinsamen Arbeitsvorrat */
.order-list-filters{align-items:stretch;flex-wrap:wrap}
.order-list-filters>input{min-width:min(320px,100%);flex:1 1 280px}
.order-list-filters>select{min-width:180px}
.order-origin-line{display:flex;align-items:center;gap:7px;margin-top:6px;max-width:260px}
.order-origin-badge{display:inline-flex;align-items:center;min-height:23px;padding:2px 8px;border-radius:999px;background:#dbeafe;color:#1d4ed8;font-size:11px;font-weight:800;letter-spacing:.04em;text-transform:uppercase;white-space:nowrap}
.order-origin-badge.office{background:#eef2f7;color:#52606d}
.order-origin-domain{overflow:hidden;color:var(--muted,#667085);font-size:12px;text-overflow:ellipsis;white-space:nowrap}
@media(max-width:700px){.order-list-filters>input,.order-list-filters>select,.order-list-filters>.btn{width:100%;min-width:0}}

/* v17.66 – Kundenstatus und kontrollierte E-Mail-Benachrichtigung */
.status-mail-option{display:inline-flex;align-items:center;gap:7px;min-height:38px;padding:7px 10px;border:1px solid #bfdbfe;border-radius:9px;background:#eff6ff;color:#1e3a5f;font-size:13px;font-weight:700;line-height:1.25}
.status-mail-option input{width:17px;height:17px;margin:0;flex:0 0 auto}
.edit-status-mail{margin-top:8px}
.customer-status-preview{margin:0 0 18px;padding:14px 16px;border:1px solid #bfdbfe;border-radius:12px;background:#f7fbff}
.customer-status-preview strong{display:block;margin-top:3px;color:#123d70;font-size:17px}
.customer-status-preview p{margin:5px 0 0;color:#465467}
@media(max-width:700px){.quick-status-form{width:100%}.quick-status-form select,.quick-status-form button,.quick-status-form .status-mail-option{width:100%}.status-mail-option{justify-content:flex-start}}

/* v18.09: sidebar can scroll independently on iPad and shorter displays.
   Keep logout reachable, including Safari's dynamic browser chrome. */
@media screen {
  .sidebar {
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    scrollbar-width: thin;
  }
  .sidebar nav, .sidebar-site-links, .sidebar-footer {
    flex-shrink: 0;
  }
  .sidebar-footer {
    padding-bottom: 8px;
  }
}

/* v18.10 - robust scrolling for desktop, reduced windows and iPad */
@media screen {
  #crmSidebar.sidebar { height:100vh!important; height:100dvh!important; max-height:100dvh!important; overflow-y:auto!important; overflow-x:hidden!important; -webkit-overflow-scrolling:touch; overscroll-behavior-y:contain; touch-action:pan-y; }
  #crmSidebar .brand, #crmSidebar nav, #crmSidebar .sidebar-site-links, #crmSidebar .sidebar-footer {flex-shrink:0!important;}
  #crmSidebar .sidebar-footer {margin-top:12px!important;}
}
