:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1d2733;
    --muted: #657080;
    --border: #dce2e8;
    --primary: #b51f2e;
    --primary-dark: #8e1723;
    --success: #e8f6ed;
    --danger: #fdebec;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    width: min(1150px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    background: #151a20;
    color: white;
    margin-bottom: 32px;
}

.nav-wrap {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    color: white;
    font-weight: 750;
    font-size: 1.1rem;
}

nav { display: flex; gap: 18px; flex-wrap: wrap; }
nav a { color: #e8edf2; }

h1 { margin: 0 0 8px; }
h2 { margin-top: 0; }
p { color: var(--muted); }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 22px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: 0 4px 14px rgba(20, 30, 40, .04);
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.stat strong {
    display: block;
    font-size: 2rem;
    color: var(--primary);
}
.stat span { color: var(--muted); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    border-radius: 9px;
    padding: 10px 14px;
    font-weight: 650;
    cursor: pointer;
}
.button:hover { text-decoration: none; }
.button.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.button.primary:hover { background: var(--primary-dark); }

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}
th {
    font-size: .82rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
tr:last-child td { border-bottom: 0; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.full { grid-column: 1 / -1; }

label {
    display: grid;
    gap: 7px;
    font-weight: 650;
}

input, select, textarea {
    width: 100%;
    border: 1px solid #cbd3dc;
    border-radius: 8px;
    padding: 10px 11px;
    font: inherit;
    background: white;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(181,31,46,.18);
    border-color: var(--primary);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
}
.checkbox input { width: auto; }

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.material-grid {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.material-row {
    grid-template-columns: 1fr 120px;
    align-items: center;
    padding: 13px;
    border-bottom: 1px solid var(--border);
}
.material-row:last-child { border-bottom: 0; }
.material-row small {
    display: block;
    color: var(--muted);
    font-weight: 400;
    margin-top: 3px;
}

.inline-form {
    display: flex;
    align-items: end;
    gap: 14px;
    flex-wrap: wrap;
}
.inline-form label { min-width: 210px; }

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: .8rem;
    font-weight: 750;
    background: #edf0f3;
}
.badge.confirmed { background: #dff3e6; color: #176c35; }
.badge.planned { background: #fff1cf; color: #845d00; }
.badge.returned { background: #e5eefc; color: #24558d; }
.badge.cancelled { background: #f7dddd; color: #8b1f2a; }

.messages { margin-bottom: 18px; }
.message {
    border-radius: 9px;
    padding: 11px 13px;
    margin-bottom: 8px;
}
.message.success { background: var(--success); }
.message.error { background: var(--danger); }

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
}
dl {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px;
}
dt { font-weight: 750; }
dd { margin: 0; color: var(--muted); }
.muted { color: var(--muted); }
.unavailable { background: #fff4f4; }

@media (max-width: 760px) {
    .nav-wrap, .page-head { align-items: flex-start; flex-direction: column; padding: 14px 0; }
    .stats, .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .full { grid-column: auto; }
    .material-row { grid-template-columns: 1fr 90px; }
    dl { grid-template-columns: 1fr; }
}

/* Erweiterungen für Buchungsbearbeitung und Scanner */
.nowrap { white-space: nowrap; }
code {
    background: #f0f2f5;
    border-radius: 5px;
    padding: 2px 5px;
    font-size: .88em;
}
.qr-mini {
    width: 46px;
    height: 46px;
    display: block;
    border-radius: 5px;
}
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    margin-bottom: 12px;
}
.section-head h2 { margin-bottom: 3px; }
.material-search { width: min(320px, 100%); }
.scan-panel {
    border: 1px dashed #b9c3ce;
    background: #f9fafb;
    border-radius: 12px;
    padding: 18px;
}
.scan-panel h2 { margin-bottom: 4px; }
.scan-entry {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    gap: 8px;
    margin-top: 12px;
}
.scan-result {
    min-height: 22px;
    margin-top: 9px;
    font-size: .92rem;
}
.scan-result.ok { color: #176c35; }
.error-text { color: #9d1f2b; }
.scanner-video {
    width: min(480px, 100%);
    margin-top: 12px;
    border-radius: 12px;
    background: #111;
}
.scanner-video.large { width: min(720px, 100%); }
.scan-highlight {
    background: #e8f6ed;
    transition: background .25s ease;
}
.sticky-actions {
    position: sticky;
    bottom: 0;
    background: rgba(255,255,255,.96);
    padding: 12px 0 2px;
    border-top: 1px solid var(--border);
    backdrop-filter: blur(8px);
}
.button.danger {
    background: #fff;
    color: #9d1f2b;
    border-color: #e0a6ab;
}
.button.danger:hover { background: #fdebec; }
.stack-form { display: grid; gap: 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.scan-workflow { display: grid; gap: 18px; }
.scan-workflow > label { max-width: 760px; }

@media (max-width: 760px) {
    .scan-entry { grid-template-columns: 1fr 1fr; }
    .scan-entry input { grid-column: 1 / -1; }
    .section-head { align-items: stretch; flex-direction: column; }
    .material-search { width: 100%; }
}

/* Benutzerverwaltung & Artikelfotos */
.user-chip { color: #aeb9c5; font-size: .85rem; align-self: center; }
.auth-wrap { min-height: 65vh; display: grid; place-items: center; }
.auth-card { width: min(440px, 100%); display: grid; gap: 16px; }
.auth-card h1 { margin-bottom: 0; }
.role-badge { display: inline-block; border-radius: 999px; padding: 5px 9px; font-weight: 700; font-size: .8rem; background: #edf0f3; }
.role-admin { background: #fdebec; color: #8b1f2a; }
.role-manager { background: #fff1cf; color: #845d00; }
.role-staff { background: #e5eefc; color: #24558d; }
.role-viewer { background: #edf0f3; color: #4b5663; }
.permission-help p { margin: 8px 0; }
.image-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.material-photo-card { margin: 0; border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: #fafbfc; }
.material-photo-card img { width: 100%; height: 150px; object-fit: cover; border-radius: 7px; display: block; }
.material-photo-card figcaption { color: var(--muted); font-size: .82rem; padding: 7px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-thumb { width: 58px; height: 48px; object-fit: cover; border-radius: 7px; display: block; border: 1px solid var(--border); }
.thumb-placeholder { width: 58px; height: 48px; border-radius: 7px; display: grid; place-items: center; background: #eef1f4; color: #8893a0; }
.button.small { padding: 6px 9px; font-size: .8rem; }


/* V4: Live-Verfügbarkeit, Etiketten und mobile Nutzung */
.table-sub { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.live-availability { display: block; margin-top: 5px; font-size: .82rem; font-weight: 700; color: #566170; }
.availability-row { transition: background .18s ease, box-shadow .18s ease; }
.availability-row.availability-ok { background: #f2fbf5; }
.availability-row.availability-warning { background: #fff9e9; }
.availability-row.availability-bad { background: #fff0f1; box-shadow: inset 4px 0 0 #b51f2e; }
.availability-row.availability-bad .live-availability { color: #9d1f2b; }
.availability-row.availability-ok .live-availability { color: #176c35; }
.availability-summary { border-radius: 9px; padding: 10px 12px; background: #eef2f5; margin-bottom: 10px; font-weight: 650; }
.availability-summary.ok { background: #e8f6ed; color: #176c35; }
.availability-summary.bad { background: #fdebec; color: #9d1f2b; }
button:disabled { opacity: .5; cursor: not-allowed; }

.label-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: #fafbfc; }
.label-material-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.label-material-row { display: grid; grid-template-columns: 1fr 120px; gap: 16px; align-items: center; padding: 12px; border-bottom: 1px solid var(--border); }
.label-material-row:last-child { border-bottom: 0; }
.label-material-row small { display: block; color: var(--muted); margin-top: 3px; }
.mobile-reader { width: min(520px, 100%); margin-top: 12px; overflow: hidden; border-radius: 12px; }
.mobile-reader video { max-width: 100%; }

@media (max-width: 760px) {
    body { font-size: 16px; }
    .container { width: min(100% - 20px, 1150px); }
    .topbar { margin-bottom: 18px; }
    .nav-wrap { gap: 10px; }
    nav { width: 100%; gap: 6px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
    nav a { padding: 10px 8px; border-radius: 8px; background: rgba(255,255,255,.06); text-align: center; }
    nav .user-chip { grid-column: 1 / -1; text-align: center; padding: 6px; }
    .card { padding: 15px; border-radius: 11px; }
    .page-head .actions { width: 100%; }
    .page-head .actions .button { flex: 1 1 calc(50% - 6px); }
    input, select, textarea, .button { min-height: 44px; font-size: 16px; }
    .material-row { grid-template-columns: 1fr 76px; padding: 12px 9px; gap: 8px; }
    .material-row .material-qty { text-align: center; font-size: 18px; font-weight: 750; padding-left: 4px; padding-right: 4px; }
    .material-row small { line-height: 1.35; }
    .live-availability { font-size: .78rem; }
    .scan-entry { grid-template-columns: 1fr; }
    .scan-entry input { grid-column: auto; }
    .scan-entry .button { width: 100%; }
    .mobile-primary { background: var(--primary); color: white; border-color: var(--primary); }
    .scanner-video, .scanner-video.large, .mobile-reader { width: 100%; }
    .sticky-actions { margin-left: -15px; margin-right: -15px; padding: 10px 15px; z-index: 20; }
    .sticky-actions .button { flex: 1 1 100%; }
    .label-settings { grid-template-columns: 1fr 1fr; }
    .label-material-row { grid-template-columns: 1fr 86px; gap: 8px; }
    table th, table td { padding: 10px 7px; }
}
@media (max-width: 430px) {
    .label-settings { grid-template-columns: 1fr; }
    nav { grid-template-columns: 1fr 1fr; }
}

.category-list{display:grid;gap:10px}.category-row{display:grid;grid-template-columns:1.2fr 2fr auto auto;gap:10px;align-items:center;border-bottom:1px solid var(--border);padding:8px 0}.row-form,.case-fill{display:flex;gap:6px;align-items:center}.case-fill select{min-width:150px}.case-fill input{width:80px}.stats.compact{grid-template-columns:repeat(4,minmax(0,1fr))}.badge.available{background:#dff3e6;color:#176c35}.badge.out{background:#fff1cf;color:#845d00}.badge.defective,.badge.missing_parts{background:#f7dddd;color:#8b1f2a}.badge.repair{background:#e5eefc;color:#24558d}
@media(max-width:760px){.category-row{grid-template-columns:1fr}.row-form,.case-fill{flex-wrap:wrap}.stats.compact{grid-template-columns:repeat(2,1fr)}.table-wrap table{min-width:720px}}
