/* Hintergrund: Leiterplatten-Motiv, Inhalt auf einer hellen Fläche darüber */
body {
    background: #f3f6f4 url("../img/hintergrund.svg") center / cover no-repeat fixed;
    min-height: 100vh;
}
.inhalt {
    background: rgba(255, 255, 255, 0.5);
    border-radius: .75rem;
    box-shadow: 0 2px 14px rgba(0, 0, 0, .06);
    padding: 1.5rem;
}
@media (max-width: 576px) {
    .inhalt { padding: 1rem .75rem; border-radius: .5rem; }
}

body { font-size: 0.95rem; }
.table td, .table th { vertical-align: middle; }
.wert { font-weight: 600; font-size: 1.05rem; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.klein { font-size: 0.82rem; color: var(--bs-secondary-color); }
.menge-form { display: inline-flex; gap: .25rem; align-items: center; }
.menge-form .btn { padding: 0 .45rem; line-height: 1.4; }
.filterleiste .form-control, .filterleiste .form-select { min-width: 9rem; }
.kachel { border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: 1rem; height: 100%; }
.kachel .zahl { font-size: 1.8rem; font-weight: 700; }

/* Widerstand mit Farbringen */
.widerstand {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    gap: 3px;
    height: 16px;
    margin: 0 14px;
    padding: 0 9px;
    background: #e9d9b7;
    border: 1px solid #c9b58c;
    border-radius: 8px;
    vertical-align: middle;
}
.widerstand::before,
.widerstand::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 14px;
    height: 2px;
    margin-top: -1px;
    background: #9aa0a6;
}
.widerstand::before { left: -15px; }
.widerstand::after { right: -15px; }
.widerstand .ring {
    width: 5px;
    box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, .25);
}
.widerstand .ring.toleranz { margin-left: 7px; }

/* ---------------------------------------------------------------
   Dunkles Design (umschaltbar, Bootstrap data-bs-theme="dark")
   --------------------------------------------------------------- */
.symbol-hell { display: none; }
[data-bs-theme="dark"] .symbol-hell { display: inline; }
[data-bs-theme="dark"] .symbol-dunkel { display: none; }

[data-bs-theme="dark"] body {
    background: #111814 url("../img/hintergrund-dunkel.svg") center / cover no-repeat fixed;
}
[data-bs-theme="dark"] .inhalt {
    background: rgba(18, 24, 21, 0.5);
    box-shadow: 0 2px 18px rgba(0, 0, 0, .45);
}
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
}
[data-bs-theme="dark"] .navbar.bg-dark {
    background-color: #0b0f0d !important;
    border-bottom: 1px solid #1f2b25;
}
[data-bs-theme="dark"] .widerstand {
    background: #cdb98f;
    border-color: #a8956b;
}
[data-bs-theme="dark"] .widerstand::before,
[data-bs-theme="dark"] .widerstand::after {
    background: #7d8580;
}

/* Gerber-Ansicht */
.gerber-rahmen { height: 70vh; min-height: 320px; border: 1px solid var(--bs-border-color); border-radius: .5rem;
                 overflow: hidden; background: #0f1214; touch-action: none; }
.gerber-rahmen svg { width: 100%; height: 100%; display: block; cursor: grab; }
.gerber-rahmen svg:active { cursor: grabbing; }

/* Fach-Seite fürs Handy */
.mengen-taste { width: 4.5rem; height: 4.5rem; font-size: 2.2rem; line-height: 1; border-radius: 50%; }
.qr-bild { image-rendering: pixelated; background: #fff; padding: 6px; border-radius: .25rem; }

/* QR-Bogen drucken */
.qr-bogen { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .75rem; }
.qr-karte { border: 1px solid var(--bs-border-color); border-radius: .4rem; padding: .5rem; text-align: center; break-inside: avoid; }
.qr-karte img { width: 100%; max-width: 7rem; image-rendering: pixelated; }
@media print {
    nav.navbar, .nicht-drucken { display: none !important; }
    body, .inhalt { background: #fff !important; color: #000 !important; box-shadow: none !important; }
    .qr-karte { border-color: #999; }
}

/* ---------- Drucklisten (Bestand, Inventur) ---------- */
.druckliste { font-size: .9rem; }
.druckliste .druckkopf { border-bottom: 2px solid currentColor; margin-bottom: .75rem; padding-bottom: .25rem; }
.druckliste .druckkopf h1 { font-size: 1.35rem; margin: 0 0 .15rem; }
.druckliste .druckkopf div { font-size: .85rem; opacity: .8; }
.druckliste h2 { font-size: 1.05rem; margin: 1rem 0 .3rem; }
.druckliste h2 span { font-weight: normal; opacity: .7; }
.druckliste table { width: 100%; border-collapse: collapse; }
.druckliste th, .druckliste td { border: 1px solid #aaa; padding: 2px 5px; vertical-align: top; }
.druckliste th { background: rgba(127,127,127,.15); text-align: left; font-weight: 600; }
.druckliste .eng { white-space: nowrap; }
.druckliste .zahl { text-align: right; white-space: nowrap; }
.druckliste .zaehlfeld { width: 22mm; }
.druckliste .neben { opacity: .7; font-size: .85em; }
.druckliste .abweichung { font-weight: 700; }
.druckliste .unterschrift { margin-top: 1.5rem; display: flex; gap: 3rem; }
.druckliste .unterschrift div { flex: 1; border-top: 1px solid #000; padding-top: 2px; font-size: .8rem; }
.druckliste tr { break-inside: avoid; }
.druckliste thead { display: table-header-group; }

@media print {
    @page { size: A4; margin: 12mm 10mm; }
    main.container-fluid { padding: 0 !important; }
    .druckliste { font-size: 9pt; }
    .druckliste th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .druckliste .neue-seite { break-before: page; }
    .alert { display: none !important; }
}

/* ---------- Etiketten (A4-Bogen und Designer) ---------- */
.etikett { position: relative; background: #fff; color: #000; overflow: hidden; box-sizing: border-box;
           border-radius: 0; font-family: Arial, Helvetica, sans-serif; line-height: 1.05;
           -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.etikett * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.et-feld { position: absolute; display: flex; overflow: hidden; box-sizing: border-box; }
.et-text { white-space: nowrap; flex-shrink: 0; }
.et-umbruch .et-text { white-space: normal; flex-shrink: 1; overflow-wrap: anywhere; }
.et-rahmen { border: .25mm solid #000; padding: 0 .5mm; }
.et-invers { background: #000; color: #fff; padding: 0 .5mm; }
.et-feld img { display: block; image-rendering: pixelated; }
.et-ringe { align-items: stretch !important; }
.et-ring { flex: 1; border: .15mm solid #000; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.et-ring-kz { color: #000; text-shadow: 0 0 .6mm #fff, 0 0 .6mm #fff; }
.et-linie { background: #000; }

/* A4-Bogen */
.bogen { width: 210mm; height: 297mm; position: relative; background: #fff; margin: 0 auto 8mm;
         box-shadow: 0 0 6px rgba(0,0,0,.35); overflow: hidden; break-after: page; page-break-after: always; }
.bogen .etikett { position: absolute; }
.bogen.schnitt .etikett { outline: .1mm solid #9a9a9a; }
.bogen .et-leerplatz { position: absolute; outline: .1mm dashed #ccc; }

/* Designer */
.designer-flaeche { background: repeating-conic-gradient(rgba(127,127,127,.12) 0 25%, transparent 0 50%) 0 0 / 16px 16px;
                    padding: 24px; overflow: auto; border: 1px solid var(--bs-border-color); border-radius: .375rem; min-height: 220px; }
.designer-skala { transform-origin: 0 0; display: inline-block; }
.designer .etikett { box-shadow: 0 0 0 1px #888; }
.designer .et-feld { outline: .1mm dashed rgba(0,0,0,.35); cursor: move; touch-action: none; }
.designer .et-feld.gewaehlt { outline: .35mm solid #0d6efd; z-index: 5; }
.designer .et-aus { opacity: .3; }
.designer .et-leer .et-text { color: #999; font-style: italic; }
.designer .et-platzhalter { background: #ddd; color: #666; justify-content: center; font-size: 7pt; }
.designer .griff { position: absolute; right: 0; bottom: 0; width: 1.6mm; height: 1.6mm; background: #0d6efd; cursor: nwse-resize; touch-action: none; }

@media print {
    .bogen-seite main.container-fluid, .bogen-seite .inhalt { padding: 0 !important; margin: 0 !important; max-width: none !important; }
    .bogen { margin: 0; box-shadow: none; height: 296.5mm; }
    .bogen .et-leerplatz { outline: none; }
}
.bogen:last-child { break-after: auto; page-break-after: auto; }

/* Zurück-Taste in der Kopfleiste – groß genug für den Daumen */
.zurueck-taste { display: inline-flex; align-items: center; justify-content: center; width: 2.6rem; height: 2.4rem; padding: 0; }
.designer-flaeche:focus { outline: 2px solid rgba(13,110,253,.35); outline-offset: -2px; }

/* ---- QR-Scanner ---- */
.scanner { position: relative; width: 100%; aspect-ratio: 1 / 1; background: #000; border-radius: .5rem; overflow: hidden; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-rahmen { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .85); border-radius: .75rem;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); pointer-events: none; }
.scanner-treffer .scanner-rahmen { border-color: #3fd17a; }
.scanner-licht { position: absolute; right: .5rem; bottom: .5rem; }
.scan-taste { padding: .25rem .5rem; line-height: 1; }

/* ---- LCSC-Daten im Formular ---- */
.lcsc-info { border: 1px solid var(--bs-border-color); border-radius: .375rem; padding: .5rem .75rem; background: var(--bs-tertiary-bg); }
.lcsc-info details { margin-top: .25rem; }

/* ---- 3D-Ansicht (STEP) ---- */
.step-ansicht { position: relative; width: 100%; height: 70vh; min-height: 320px; border: 1px solid var(--bs-border-color); border-radius: .5rem; overflow: hidden; }
.step-ansicht canvas { display: block; touch-action: none; }
.step-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; text-align: center; background: var(--bs-body-bg); }
.step-status[hidden] { display: none; }
