:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --ink: #1f2933;
    --muted: #6b7684;
    --primary: #2b6cb0;
    --primary-dark: #234e78;
    --border: #dbe1e8;
    --ok: #2f855a;
    --ok-bg: #e6fffa;
    --err: #c53030;
    --err-bg: #fff5f5;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: var(--primary-dark);
    color: #fff;
    padding: 0.7rem 1.4rem;
}
.topnav a { color: #dbeafe; text-decoration: none; font-size: 0.95rem; }
.topnav a:hover { color: #fff; }
.topnav .brand { font-weight: 700; font-size: 1.15rem; color: #fff; }
.topnav .spacer { flex: 1; }
.topnav .user { color: #cbd5e0; font-size: 0.85rem; }
.linkbtn {
    background: none; border: none; color: #dbeafe; cursor: pointer;
    font-size: 0.95rem; padding: 0;
}
.linkbtn:hover { color: #fff; text-decoration: underline; }
.inline { display: inline; }

main { max-width: 1050px; margin: 1.6rem auto; padding: 0 1.2rem; }
footer { text-align: center; color: var(--muted); padding: 1.5rem 0; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.3rem 1.5rem;
    margin-bottom: 1.2rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--muted); font-weight: 600; }

/* Sticky Header + Zebra + Hover für die Dokumenttabelle */
table.docs thead th {
    position: sticky; top: 0; z-index: 3;
    background: #eef2f7; color: #4a5568;
    box-shadow: inset 0 -1px 0 var(--border);
}
table.docs tbody tr.galt > td { background: #f7f9fc; }
table.docs tbody tr.mainrow:hover > td { background: #eef4fb; }
table.docs td { padding: 0.5rem 0.6rem; }

/* Einklappbare Vorgängerversionen */
tr.subrow.collapsed { display: none; }
.ver-toggle {
    display: inline-flex; align-items: center; gap: 0.2rem;
    margin-left: 0.45rem; padding: 0.05rem 0.4rem;
    background: #edf2f7; border: 1px solid var(--border); border-radius: 999px;
    font-size: 0.72rem; color: var(--muted); cursor: pointer;
}
.ver-toggle:hover { background: #e2e8f0; color: var(--ink); }
.ver-toggle .ic { width: 0.9em; height: 0.9em; transition: transform .15s ease; }
.ver-toggle[aria-expanded="true"] .ic { transform: rotate(180deg); }

/* Paginierung */
.pager { display: flex; align-items: center; justify-content: center; gap: 0.4rem; margin-top: 1.1rem; flex-wrap: wrap; }
.pager .pageinfo { color: var(--muted); font-size: 0.85rem; margin: 0 0.4rem; }
.pager .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    cursor: pointer;
    background: var(--primary); color: #fff; border: none;
    padding: 0.5rem 0.95rem; border-radius: 7px; font-size: 0.9rem;
    text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #e2e8f0; color: var(--ink); }
.btn.secondary:hover { background: #cbd5e0; }
.btn.danger { background: var(--err); }
.btn.danger:hover { background: #9b2c2c; }
.btn.small { padding: 0.32rem 0.6rem; font-size: 0.8rem; gap: 0.3rem; }

/* Inline-Icon: erbt Textfarbe, skaliert mit Schrift */
.ic { width: 1.05em; height: 1.05em; flex: 0 0 auto; display: inline-block; vertical-align: -0.15em; }
.btn.small .ic { width: 1em; height: 1em; }
.topnav a .ic, .topnav .linkbtn .ic { vertical-align: -0.15em; margin-right: 0.25rem; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.9rem; }
.field input[type=text], .field input[type=password], .field input[type=file], .field textarea, .field select {
    width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.95rem; font-family: inherit;
}
.field textarea { min-height: 90px; }
.checkbox { display: flex; align-items: center; gap: 0.5rem; }
.checkbox input { width: auto; }

/* Hinweisbanner */
.alert {
    position: relative;
    display: flex; align-items: flex-start; gap: 0.6rem;
    padding: 0.8rem 2.4rem 0.8rem 1rem;
    border-radius: 10px; margin-bottom: 1rem; font-size: 0.92rem;
    border: 1px solid transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    animation: alert-in .25s ease;
}
.alert::before { font-size: 1.05rem; line-height: 1.3; }
.alert.success { background: var(--ok-bg); color: #22643f; border-color: #9ae6b4; }
.alert.success::before { content: "✓"; color: var(--ok); font-weight: 700; }
.alert.error { background: var(--err-bg); color: #9b2c2c; border-color: #feb2b2; }
.alert.error::before { content: "⚠"; color: var(--err); }
.alert.hiding { opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s; }
.alert-close {
    position: absolute; top: 0.35rem; right: 0.5rem;
    background: none; border: none; cursor: pointer;
    font-size: 1.2rem; line-height: 1; color: inherit; opacity: 0.55; padding: 0.15rem 0.35rem;
}
.alert-close:hover { opacity: 1; }
@keyframes alert-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Bestätigungs-Modal */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(15, 23, 42, 0.45);
    display: none; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; animation: overlay-in .15s ease; }
body.modal-open { overflow: hidden; }
.modal {
    background: var(--card); border-radius: 14px;
    width: 100%; max-width: 420px;
    padding: 1.4rem 1.5rem 1.2rem;
    box-shadow: 0 20px 50px rgba(0,0,0,.28);
    animation: modal-in .18s ease;
}
.modal h3 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.modal .modal-message { margin: 0 0 1.3rem; color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.text-danger { color: var(--err); font-size: 0.85rem; }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.inarbeit { background: #feebc8; color: #9c4221; }
.badge.freigegeben { background: #c6f6d5; color: #22543d; }
.badge.ersetzt { background: #e2e8f0; color: #4a5568; }

/* Filterleiste in der Dokumentübersicht */
.filterbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem 1rem;
    align-items: end;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    margin: 0.4rem 0 0.6rem;
}
.filterbar .field { margin-bottom: 0; }
.filterbar .field label { font-size: 0.8rem; }
.filterbar .filteractions { grid-column: 1 / -1; display: flex; gap: 0.5rem; }
@media (max-width: 720px) { .filterbar { grid-template-columns: 1fr; } }

/* Vorgängerversionen in der Dokumentliste: eingerückt und kleinerer Font */
tr.subrow td { font-size: 0.8rem; color: var(--muted); background: #fafbfc; }
tr.subrow td:first-child { padding-left: 1.6rem; }
tr.subrow td:nth-child(2) { padding-left: 1.2rem; }

.muted { color: var(--muted); }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.right { text-align: right; }
.narrow { max-width: 460px; }
