/* ============================================================
   GRUNDLAGEN & SCHUTZ VOR SEITLICHEM VERSCHIEBEN
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    max-width: 100%;
}

html {
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    background-color: #0b0d12;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: clip;
    background: transparent;
    color: #ece8df;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    --gold-light: #e2c275;
    --text-main: #ece8df;
    --text-muted: #9ea4b2;
    --border-subtle: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(226, 194, 117, 0.45);
    --success: #48b878;
}

/* ============================================================
   GEDÄMPFTER, GROB STILISIERTER UHRWERK-AUSSENHINTERGRUND
   ============================================================ */
.clockwork-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    opacity: 0.055;
    -webkit-mask-image: radial-gradient(
        ellipse 82% 72% at 72% 28%,
        rgba(0, 0, 0, 0.9) 0%,
        rgba(0, 0, 0, 0.42) 62%,
        rgba(0, 0, 0, 0.08) 100%
    );
    mask-image: radial-gradient(
        ellipse 82% 72% at 72% 28%,
        rgba(0, 0, 0, 0.9) 0%,
        rgba(0, 0, 0, 0.42) 62%,
        rgba(0, 0, 0, 0.08) 100%
    );
}

.clockwork-bg svg {
    width: 100%;
    height: 100%;
    display: block;
}

.top-header,
.container,
.site-bottom-footer,
.site-footer,
.login-wrap {
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .clockwork-bg {
        opacity: 0.035;
    }
}

@media print {
    .clockwork-bg {
        display: none !important;
    }
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: var(--gold-light);
}

/* ============================================================
   LAYOUT-CONTAINER & HEADER
   ============================================================ */
.container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 20px;
}

.top-header {
    width: 100%;
    background: rgba(15, 18, 25, 0.94);
    border-bottom: 1px solid var(--border-subtle);
}

.top-header-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.brand-block h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--gold-light);
}

.brand-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.nav-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* ============================================================
   BUTTONS & FORMULARFELDER
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    min-height: 40px;
}

.btn-gold {
    background: var(--gold-light);
    color: #12141a;
    border-color: var(--gold-light);
    font-weight: 600;
}

.panel {
    background: rgba(18, 21, 29, 0.95);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 18px;
}

.intro-box {
    background: rgba(18, 21, 29, 0.95);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--gold-light);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 18px;
    color: var(--text-main);
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: #0d1017;
    color: var(--text-main);
    font-size: 1rem;
}

.login-wrap {
    max-width: 420px;
    margin: 48px auto;
    padding: 24px;
    background: rgba(18, 21, 29, 0.96);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.alert-err {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 14px;
    background: rgba(201, 74, 74, 0.2);
    border: 1px solid rgba(224, 96, 96, 0.6);
    color: #ffc2c2;
}

/* ============================================================
   BESUCHERBEREICH: FILTER, VITRINE & KACHELWAND
   ============================================================ */
.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.calibre-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.calibre-btn {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
}

.calibre-btn.active {
    background: var(--gold-light);
    color: #12141a;
    border-color: var(--gold-light);
    font-weight: 600;
}

.vitrine {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.vitrine-stage {
    position: relative;
    width: 100%;
    height: 440px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: #090b0f;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-in;
    touch-action: manipulation;
}

.vitrine-stage.zoomed {
    cursor: zoom-out;
}

.vitrine-stage img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.22s ease;
    transform-origin: center center;
}

.filmstrip {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filmstrip img {
    width: 68px;
    height: 68px;
    flex: 0 0 68px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    opacity: 0.72;
}

.filmstrip img.active {
    border-color: var(--gold-light);
    opacity: 1;
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.04);
}

.badge-status-avail {
    border-color: rgba(72, 184, 120, 0.5);
    color: #8ee5b1;
}

.badge-status-sold {
    border-color: rgba(224, 96, 96, 0.55);
    color: #ffb4b4;
}

.vitrine-details h2 {
    margin: 0 0 8px;
    font-size: 1.5rem;
    color: var(--gold-light);
}

/* ============================================================
   FLIESSENDES ÖFFNEN DER DETAILANSICHT & FEINER LICHTSCHEIN
   ============================================================ */
.vitrine-details {
    position: relative;
    opacity: 0;
    transform: translateX(18px);
    transition:
        opacity 0.52s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.58s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
}

.vitrine-details.is-detail-open {
    opacity: 1;
    transform: translateX(0);
}

.vitrine-details .spec-card,
.vitrine-details .star-rating-box {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
    box-shadow: 0 0 0 rgba(226, 194, 117, 0);
    transition:
        opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.58s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 1.15s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.75s ease-out,
        background 0.25s ease;
    will-change: opacity, transform, box-shadow;
}

.vitrine-details.is-detail-open .spec-card {
    opacity: 1;
    transform: translateY(0) scale(1);
    box-shadow:
        0 0 22px rgba(226, 194, 117, 0.17),
        0 6px 18px rgba(0, 0, 0, 0.22),
        inset 0 0 12px rgba(226, 194, 117, 0.05);
}

.vitrine-details.is-detail-open .star-rating-box {
    opacity: 1;
    transform: translateY(0) scale(1);
    border-color: rgba(226, 194, 117, 0.56);
    box-shadow:
        0 0 26px rgba(226, 194, 117, 0.28),
        0 0 10px rgba(226, 194, 117, 0.16),
        inset 0 1px 0 rgba(255, 236, 179, 0.24);
}

.vitrine-details.is-detail-settled .spec-card {
    box-shadow: 0 0 10px rgba(226, 194, 117, 0.06);
}

.vitrine-details.is-detail-settled .star-rating-box {
    border-color: rgba(226, 194, 117, 0.38);
    box-shadow:
        0 0 12px rgba(226, 194, 117, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.vitrine-details .star-rating-on {
    transition: text-shadow 0.9s ease-out;
}

.vitrine-details.is-detail-open .star-rating-on {
    text-shadow: 0 0 12px rgba(226, 194, 117, 0.45);
}

.vitrine-details.is-detail-settled .star-rating-on {
    text-shadow: 0 0 4px rgba(226, 194, 117, 0.14);
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
}

.tile-card {
    display: block;
    text-decoration: none;
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(18, 21, 29, 0.94);
}

.tile-card img {
    width: 100%;
    height: 175px;
    object-fit: cover;
}

.tile-caption {
    padding: 8px 10px;
    font-size: 0.85rem;
    color: var(--gold-light);
}

.site-footer {
    margin-top: 36px;
    padding: 18px 20px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.site-footer-inner {
    max-width: 1240px;
    margin: 0 auto;
}

/* ============================================================
   BACKEND-STATS & SCHALTER
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    background: rgba(18, 21, 29, 0.95);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 14px 16px;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.stat-value {
    margin-top: 4px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gold-light);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #2b3040;
    border-radius: 999px;
    transition: 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--gold-light);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: #12141a;
}

/* ============================================================
   SMARTPHONE-OPTIMIERUNG (BIS 768 PX)
   ============================================================ */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .top-header-inner {
        padding: 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .brand-block h1 {
        font-size: 1.18rem;
    }

    .nav-controls {
        width: 100%;
    }

    .nav-controls .btn {
        flex: 1 1 calc(50% - 4px);
        font-size: 0.85rem;
        padding: 8px 10px;
    }

    /* Kaliber-Filter auf dem Smartphone als saubere Einzeiler-Leiste ohne Seiten-Scroll */
    .calibre-buttons {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .vitrine {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .vitrine-stage {
        height: clamp(230px, 40vh, 330px);
        border-radius: 8px;
    }

    .filmstrip img {
        width: 58px;
        height: 58px;
        flex: 0 0 58px;
    }

    .vitrine-details {
        transform: translateY(14px);
    }

    .vitrine-details.is-detail-open {
        transform: translateY(0);
    }

    .vitrine-details h2 {
        font-size: 1.25rem;
    }

    .vitrine-details .nav-controls .btn {
        flex: 1 1 100%;
    }

    .tile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .tile-card img {
        height: 145px;
    }

    .login-wrap {
        margin: 24px 12px;
        padding: 18px;
    }

    /* Backend auf Smartphone */
    .stats-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .panel {
        padding: 14px;
    }

    .mc-custom-row.open {
        flex-direction: column;
        align-items: stretch;
    }
}