:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f8f9fb;
    --border: #e2e5eb;
    --text: #1a1d24;
    --muted: #6b7280;
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #d97706;
}

* { box-sizing: border-box; }

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

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.topbar { background: #fff; border-bottom: 1px solid var(--border); }
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 0.75rem 1rem;
    display: flex; align-items: center; gap: 1.5rem;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar-inner nav { display: flex; gap: 1rem; flex: 1; }
.topbar-inner nav a { text-decoration: none; color: var(--text); font-size: 0.95rem; }
.topbar-inner nav a:hover { color: var(--primary); }
.icon-nav { display: flex; gap: 0.15rem; flex: 1; }
.icon-nav a {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 6px; color: var(--text);
    text-decoration: none; transition: background 0.15s, color 0.15s;
}
.icon-nav a:hover { background: #eef2ff; color: var(--primary); }
.icon-nav svg { width: 20px; height: 20px; flex-shrink: 0; }
.topbar-user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: var(--muted); }
.topbar-user a { color: var(--primary); text-decoration: none; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 0.5rem 0; color: var(--muted); }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

.btn, button, input[type=submit] {
    display: inline-block; background: var(--primary); color: #fff; border: none;
    padding: 0.55rem 1rem; border-radius: 6px; text-decoration: none; cursor: pointer;
    font-size: 0.9rem;
}
.btn:hover, button:hover { background: var(--primary-dark); }

a { color: var(--primary); }

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.table th, .table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.92rem; }
.table th { background: #f2f4f7; font-weight: 600; }
.table tr:last-child td { border-bottom: none; }

.kv { border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 1rem; }
.kv th, .kv td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.92rem; }
.kv th { width: 220px; color: var(--muted); font-weight: 500; }

.badge { padding: 0.15rem 0.55rem; border-radius: 12px; font-size: 0.78rem; font-weight: 600; background: #e5e7eb; color: #374151; }
.badge-lager { background: #dbeafe; color: #1e40af; }
.badge-ausgegeben { background: #dcfce7; color: #166534; }
.badge-ausgegeben_offen { background: #ffedd5; color: #9a3412; }
.badge-standort { background: #ede9fe; color: #6d28d9; }
.badge-defekt { background: #fee2e2; color: #991b1b; }
.badge-reparatur { background: #fef3c7; color: #92400e; }
.badge-ausgemustert { background: #e5e7eb; color: #4b5563; }

.form { max-width: 560px; display: flex; flex-direction: column; gap: 0.9rem; }
.form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; font-weight: 500; }
.form input, .form select, .form textarea {
    padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; font-family: inherit;
}
.form .checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }
.form fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem; }
.form legend { padding: 0 0.4rem; font-size: 0.85rem; color: var(--muted); }

.checkbox-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 340px; overflow-y: auto; }
.checkbox-list label { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: normal; }
.picker-filter { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 0.5rem; font-family: inherit; }

.filter-bar { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.card {
    background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 1rem; text-align: center;
    display: block; text-decoration: none; color: inherit; transition: box-shadow 0.15s, border-color 0.15s;
}
.card:hover { border-color: var(--primary); box-shadow: 0 1px 6px rgba(37,99,235,0.15); }
.card-number { font-size: 1.8rem; font-weight: 700; }
.card-label { font-size: 0.85rem; color: var(--muted); }
.card-warn .card-number { color: var(--warn); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }

.flash { padding: 0.7rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

.muted { color: var(--muted); }

.login-box { max-width: 340px; margin: 4rem auto; background: #fff; padding: 2rem; border-radius: 8px; border: 1px solid var(--border); }
.login-box form { display: flex; flex-direction: column; gap: 0.9rem; }
.login-box label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }
.login-box input { padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab-btn { background: none; color: var(--muted); border: none; padding: 0.6rem 1rem; cursor: pointer; border-bottom: 2px solid transparent; border-radius: 0; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel.hidden { display: none; }

.sigpad-actions { margin: 0.5rem 0; }

.protocol-frame { background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.protocol-iframe { width: 100%; height: 80vh; border: none; }

@media print {
    .no-print, .topbar { display: none !important; }
    .container { max-width: none; padding: 0; }
}

@media (max-width: 800px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .topbar-inner { flex-wrap: wrap; }
}

.table th a { color: inherit; text-decoration: none; display: inline-block; }
.table th a:hover { text-decoration: underline; }
.warn-icon { cursor: help; margin-left: 0.2rem; font-size: 0.85em; }
#bulk-form .table th:first-child, #bulk-form .table td:first-child { width: 2rem; text-align: center; }

.app-footer { text-align: center; padding: 1.5rem 1rem 2rem; font-size: 0.78rem; }
