/* ============================================================
   SunnyDatasheets – App-Styles
   Farbschema: Orange #F7941D / Blau #3AABE2 / Dunkelblau #005A8E
   ============================================================ */

:root {
    --orange:       #F7941D;
    --orange-dark:  #D97D0C;
    --blue:         #3AABE2;
    --blue-dark:    #005A8E;
    --blue-deeper:  #00406A;
    --bg:           #EEF4F9;
    --surface:      #FFFFFF;
    --border:       #CDDDE9;
    --text:         #1D2D3A;
    --text-muted:   #5E7A90;
    --text-light:   #9BB0C0;
    --header-h:     58px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────────── */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Header ─────────────────────────────────────────── */

.app-header {
    height: var(--header-h);
    background: linear-gradient(90deg, #1A6A9A 0%, #2288BE 100%);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.header-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.header-right {
    flex: 0 0 auto;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-guest {
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    font-style: italic;
}

.header-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--orange);
    letter-spacing: 0.4px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

.header-logo {
    height: 42px;
    object-fit: contain;
}

.logout-btn {
    background: var(--orange);
    color: #fff;
    border: none;
    padding: 7px 18px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: background 0.15s;
}
.logout-btn:hover { background: var(--orange-dark); }

.nav-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.45);
    padding: 7px 16px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.3px;
    margin-right: 10px;
    transition: background 0.15s;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.25); }

/* ── App Main ────────────────────────────────────────── */

.app-main {
    flex: 1;
    overflow: hidden;
    display: flex;
}

/* ── Home: zwei-Spalten-Layout ───────────────────────── */

.home-container {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ── Linkes Such-Panel ───────────────────────────────── */

.search-panel {
    width: 320px;
    min-width: 260px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.search-box {
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.search-input-group {
    display: flex;
    gap: 6px;
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(58,171,226,0.18);
    background: #fff;
}
.search-input::placeholder { color: var(--text-light); }

.search-btn {
    background: var(--blue);
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.search-btn:hover { background: var(--blue-dark); }

.search-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.results-count {
    font-size: 11px;
    color: var(--text-muted);
    padding-left: 2px;
}

.new-datasheet-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--orange);
    color: #fff;
    border: none;
    padding: 5px 11px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.new-datasheet-btn:hover:not(:disabled) { background: var(--orange-dark); }
.new-datasheet-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Ergebnisliste ───────────────────────────────────── */

.results-list {
    flex: 1;
    overflow-y: auto;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid #F0F5F9;
    transition: background 0.12s;
}
.result-item:hover { background: #F0F8FF; }
.result-item.selected {
    background: #E3F3FC;
    border-left: 3px solid var(--blue);
    padding-left: 9px;
}

.result-thumbnail {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 5px;
    flex-shrink: 0;
    background: #fff;
}

.result-thumb-placeholder {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--blue);
}

.mini-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.result-info { flex: 1; min-width: 0; }

.result-category {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
    color: var(--orange);
    margin-bottom: 1px;
}

.result-hersteller-zeile {
    display: flex;
    align-items: baseline;
    gap: 6px;
    overflow: hidden;
}

.result-hersteller {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    max-width: 55%;
}

.result-typ {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Rechtes Detail-Panel ────────────────────────────── */

.detail-panel {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: var(--bg);
    position: relative;
}

.detail-loading {
    padding: 30px 0;
}

/* ── Detail Header ───────────────────────────────────── */

.detail-header {
    display: flex;
    gap: 16px;
    background: var(--surface);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.07);
    align-items: flex-start;
}

.detail-catalog-image {
    width: 90px;
    height: 90px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    flex-shrink: 0;
    cursor: pointer;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.detail-catalog-image:hover {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(58,171,226,0.2);
}

.detail-pdf-thumb {
    width: 90px;
    height: 90px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    flex-shrink: 0;
    cursor: pointer;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.detail-pdf-thumb:hover {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(58,171,226,0.2);
}

.detail-image-placeholder {
    width: 90px;
    height: 90px;
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--blue);
}

.detail-title-area { flex: 1; min-width: 0; }

.detail-category {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    color: var(--orange);
    margin-bottom: 3px;
}

.detail-hersteller-zeile {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    line-height: 1.2;
}

.detail-hersteller {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.detail-typ-inline {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-muted);
}

.detail-meta {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 5px;
}

.uid-badge {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 11px;
}

/* ── Detail Sections ─────────────────────────────────── */

.detail-section {
    background: var(--surface);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.07);
    transition: background 0.12s, box-shadow 0.12s, border-color 0.12s;
    border: 2px solid transparent;
}

.detail-section.drag-over {
    background: rgba(58, 171, 226, 0.06);
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(58, 171, 226, 0.18);
}

.drop-zone-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    padding: 6px 0 2px;
    opacity: 0.65;
    user-select: none;
    pointer-events: none;
}

.detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 7px;
    border-bottom: 2px solid var(--blue);
}

.detail-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--blue-dark);
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--orange);
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}
.upload-btn:hover { background: var(--orange-dark); }

.upload-error {
    background: #FFF0F0;
    border: 1px solid #FFBBBB;
    color: #B00020;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 12px;
    margin-bottom: 8px;
}

/* ── Markdown Notes ──────────────────────────────────── */

.notes-content {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
}

.description-content {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    white-space: pre-wrap;
}

/* ── Varianten ─────────────────────────────────────── */

.variants-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}
.variants-table th {
    background: var(--bg);
    font-weight: 600;
    text-align: left;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 6px 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.variants-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    vertical-align: top;
    color: var(--text);
}
.variant-uid {
    font-size: 10px;
    color: var(--text-light, var(--text-muted));
    opacity: 0.6;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    margin-top: 2px;
    letter-spacing: 0.2px;
}

.variants-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.btn-add-variant {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}
.btn-add-variant:hover { background: var(--blue-dark); }

.variants-edit-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.variant-edit-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.variant-edit-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.variant-row-top {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

/* ── Varianten-Bild-Picker (quadratische Kachel + Popup-Grid) ── */
.variant-image-picker {
    position: relative;
    flex-shrink: 0;
    width: 64px;
    align-self: stretch;          /* so hoch wie die zwei Eingabezeilen */
}
.vpick-button {
    width: 100%;
    height: 100%;
    min-height: 64px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.vpick-button:hover {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(58, 171, 226, 0.2);
}
.vpick-current {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--bg);
}
.vpick-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: var(--text-light);
}

.vpick-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: transparent;
}
.vpick-popup {
    position: absolute;
    top: 0;
    left: calc(100% + 6px);
    z-index: 3001;
    width: 250px;
    max-height: 232px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    padding: 8px;
}
.vpick-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.vpick-tile {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 2px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.vpick-tile:hover {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(58, 171, 226, 0.2);
}
.vpick-tile.vpick-tile-sel {
    border-color: var(--orange);
    box-shadow: 0 0 0 2px rgba(247, 148, 29, 0.3);
}
.vpick-tile img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--bg);
}
.vpick-tile-empty { font-size: 16px; opacity: 0.5; }
.vpick-tile-clear { color: #c0392b; }
.vpick-empty {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    padding: 8px;
}

/* Variantenbild-Thumbnail in der Detail-Tabelle */
.variant-typ-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}
.variant-detail-thumb {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    flex-shrink: 0;
    cursor: pointer;
}
.variant-typ-text { min-width: 0; }

.variant-remove-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: #c0392b;
    border-radius: 5px;
    cursor: pointer;
    padding: 0 8px;
    display: flex;
    align-items: center;
    transition: background 0.12s, color 0.12s;
}
.variant-remove-btn:hover {
    background: #c0392b;
    color: #fff;
}
.variants-empty-hint {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    padding: 4px 0;
}

/* ── Datenfelder (kategoriespezifisch) ───────────────── */

.datafields-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}
.datafields-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    vertical-align: top;
    color: var(--text);
}
.datafields-table .df-caption {
    font-weight: 600;
    color: var(--blue-dark);
    width: 35%;
    background: var(--bg);
}
.datafields-table .df-value {
    white-space: pre-wrap;
}
.df-empty {
    color: var(--text-muted);
    font-style: italic;
}

.datafields-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 2px 0 8px;
    line-height: 1.4;
}

.datafield-row-top {
    display: grid;
    grid-template-columns: 1fr 1fr 130px;
    gap: 6px;
}
.notes-content h1, .notes-content h2, .notes-content h3 {
    color: var(--blue-dark);
    margin: 14px 0 6px;
    font-weight: 600;
}
.notes-content h1 { font-size: 18px; }
.notes-content h2 { font-size: 16px; }
.notes-content h3 { font-size: 14px; }
.notes-content p { margin-bottom: 8px; }
.notes-content ul, .notes-content ol { padding-left: 20px; margin-bottom: 8px; }
.notes-content li { margin-bottom: 3px; }
.notes-content code {
    background: #EEF4F9;
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 13px;
}
.notes-content pre {
    background: #EEF4F9;
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 10px;
}
.notes-content pre code {
    background: none;
    border: none;
    padding: 0;
}
.notes-content blockquote {
    border-left: 3px solid var(--blue);
    padding-left: 12px;
    color: var(--text-muted);
    margin: 8px 0;
}
.notes-content a { color: var(--blue-dark); }
.notes-content table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 10px;
}
.notes-content th {
    background: var(--bg);
    font-weight: 600;
    text-align: left;
}
.notes-content th, .notes-content td {
    border: 1px solid var(--border);
    padding: 6px 10px;
}

/* ── Dateien ─────────────────────────────────────────── */

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #F0F5F9;
}
.file-item:last-child { border-bottom: none; }

.file-thumb-cell {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-thumbnail {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.file-thumbnail:hover {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(58,171,226,0.25);
}

.file-thumb-clickable {
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.file-thumb-clickable:hover {
    border-color: var(--blue);
    background: #E3F3FC;
}

.file-thumb-placeholder {
    width: 56px;
    height: 56px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.file-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}
.file-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-badge { font-size: 12px; }

.file-size {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Datei-Aktions-Buttons (Download / Edit / Löschen) — einheitliches Design */
.file-download-btn,
.file-note-btn,
.file-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    transition: background 0.12s, box-shadow 0.12s, color 0.12s, border-color 0.12s;
}

.file-download-btn { color: var(--blue-dark); }
.file-download-btn:hover {
    background: var(--blue-dark);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.file-note-btn { color: var(--blue-dark); }
.file-note-btn:hover {
    background: var(--blue-dark);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.file-note-btn.has-note {
    border-color: #b9750f;
    color: #b9750f;
}
.file-note-btn.has-note:hover {
    background: #b9750f;
    color: #fff;
    border-color: #b9750f;
}

.file-delete-btn {
    border-color: #e5b4b4;
    color: #c0392b;
}
.file-delete-btn:hover {
    background: #c0392b;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.file-note-preview {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.modal-panel-sm {
    max-width: 500px;
}

.filename-edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.filename-edit-row .form-input {
    flex: 1;
}
.filename-ext {
    color: var(--text-muted);
    font-size: 13px;
    font-family: monospace;
    user-select: none;
    flex-shrink: 0;
}

.no-files-hint {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 0;
}

/* ── Leer-Zustand ────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state-icon {
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state-text {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.empty-state-hint {
    font-size: 13px;
    color: var(--text-light);
}

/* ── Login-Seite ─────────────────────────────────────── */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--blue-deeper) 0%, var(--blue-dark) 50%, var(--blue) 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.30);
}

.login-logo {
    text-align: center;
    margin-bottom: 20px;
}
.login-logo img {
    height: 52px;
    object-fit: contain;
}

.login-title {
    text-align: center;
    font-size: 21px;
    font-weight: 700;
    color: var(--blue-dark);
    margin-bottom: 24px;
    letter-spacing: -0.3px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.form-input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}
.form-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(58,171,226,0.18);
    background: #fff;
}

.login-btn {
    background: var(--orange);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 7px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    letter-spacing: 0.2px;
    transition: background 0.15s;
}
.login-btn:hover:not(:disabled) { background: var(--orange-dark); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-error {
    background: #FFF0F0;
    border: 1px solid #FFBBBB;
    color: #B00020;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 4px;
}

/* ── Detail-Action-Buttons (Bearbeiten / Löschen) ───── */

.detail-action-btns {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    z-index: 5;
}

.detail-edit-btn,
.detail-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    transition: background 0.12s, box-shadow 0.12s, color 0.12s;
}

.detail-edit-btn {
    border: 1px solid var(--border);
    color: var(--blue-dark);
}
.detail-edit-btn:hover {
    background: var(--blue-dark);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.detail-delete-btn {
    border: 1px solid #e5b4b4;
    color: #c0392b;
}
.detail-delete-btn:hover {
    background: #c0392b;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

/* ── Modal ──────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 30, 60, 0.55);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-panel {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Overlay nur über dem rechten Detailbereich (Suchspalte bleibt sichtbar/bedienbar). */
.modal-overlay-right {
    inset: 0 0 0 320px;
    padding: 0;
    background: rgba(0, 30, 60, 0.45);
}

/* Volle Größe innerhalb des rechten Bereichs. */
.modal-panel-full {
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 2px solid var(--blue);
    flex-shrink: 0;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--blue-dark);
}

.modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.12s, background 0.12s;
}
.modal-close-btn:hover { color: var(--text); background: var(--bg); }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
    background: var(--bg);
}

/* ── Edit-Formular ──────────────────────────────────── */

.edit-header-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 20px;
    align-items: start;
}

.edit-image-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.edit-img-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    align-self: flex-start;
    margin-top: 4px;
}
.edit-img-label:first-child { margin-top: 0; }

.edit-catalog-img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
}

.edit-img-placeholder {
    width: 140px;
    height: 140px;
    border: 2px dashed var(--border);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-light);
    font-size: 12px;
}

.edit-fields-cell {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.edit-row-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: end;
}

.edit-notes-group { margin-top: 4px; }

.edit-notes-textarea {
    min-height: 180px;
    resize: vertical;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.edit-description-textarea {
    min-height: 70px;
    resize: vertical;
    font-size: 13px;
    line-height: 1.5;
}

.form-input-sm { font-size: 12px; padding: 6px 10px; }

/* ── Katalogbild-Picker ─────────────────────────────── */

.catalog-img-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
    transition: background 0.12s, box-shadow 0.12s, border-color 0.12s;
}

/* Drag&Drop-Highlight beim Ziehen von Dateien über die Thumbnail-Leiste */
.catalog-img-picker.drag-over {
    background: rgba(58, 171, 226, 0.06);
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(58, 171, 226, 0.18);
}

.catalog-img-tile {
    width: 80px;
    height: 80px;
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--surface);
    flex-shrink: 0;
    transition: border-color 0.12s, box-shadow 0.12s;
    overflow: hidden;
    color: var(--text-muted);
}
.catalog-img-tile:hover {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(58,171,226,0.2);
}
.catalog-img-tile.cit-selected {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(247,148,29,0.25);
}
.catalog-img-tile.cit-selected-pdf {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(58,171,226,0.30);
}

.cit-pdf-badge {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: var(--blue);
    border-radius: 3px;
    padding: 1px 4px;
    line-height: 1.3;
    pointer-events: none;
    letter-spacing: 0.3px;
}

/* catalog-img-tile braucht position:relative für das Badge */
.catalog-img-tile { position: relative; }

.picker-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 2px 0 6px;
}
.picker-hint-img {
    color: var(--orange);
    font-weight: 600;
}
.picker-hint-pdf {
    color: var(--blue-dark);
    font-weight: 600;
}

.cit-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cit-web-suggestion {
    border-style: dashed;
    border-color: var(--blue);
    position: relative;
}
.cit-web-suggestion:hover {
    border-color: var(--orange);
    box-shadow: 0 0 0 2px rgba(247,148,29,0.25);
}

.cit-web-badge {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 10px;
    font-weight: 700;
    color: var(--blue-dark);
    background: rgba(255,255,255,0.85);
    border-radius: 3px;
    padding: 0 3px;
    line-height: 1.5;
    pointer-events: none;
}

.cit-web-separator {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 4px 0 2px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.cit-search-error {
    width: 100%;
    font-size: 11px;
    color: #B00020;
    padding: 4px 0;
}

/* ── Aktions-Buttons ────────────────────────────────── */

.btn-primary {
    background: var(--orange);
    color: #fff;
    border: none;
    padding: 9px 22px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--orange-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 22px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-danger {
    background: #c0392b;
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-danger:hover:not(:disabled) { background: #a93226; }
.btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Lade-Indikatoren ────────────────────────────────── */

.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.no-results {
    padding: 20px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ── Gerätekategorien-Seite ─────────────────────────── */

.kat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.kat-header {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto 8px;
}

.kat-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    color: var(--blue-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}
.kat-back-btn:hover { background: var(--bg); }

.kat-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--blue-dark);
}

.kat-intro {
    max-width: 900px;
    margin: 0 auto 18px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.kat-empty {
    max-width: 900px;
    margin: 0 auto;
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
    padding: 20px 0;
}

.kat-card {
    max-width: 900px;
    margin: 0 auto 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
}

.kat-card-head {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 14px;
}

.kat-name-group {
    flex: 1;
    margin-bottom: 0;
}

.kat-card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Suchfeld über der Liste */
.kat-search-box {
    max-width: 900px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.kat-search-box .search-input-group {
    flex: 1;
    max-width: 480px;
}
.kat-search-box .results-count {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Ergebnisliste */
.kat-list {
    max-width: 900px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}
.kat-list-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
}
.kat-list-row:last-child { border-bottom: none; }
.kat-list-row:hover { background: var(--bg); }

.kat-list-name {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}
.kat-list-name-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kat-list-count {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.kat-list-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Scrollbar ───────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C0CDD8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue); }
