/* Lizenzverwaltung – Oberfläche */
:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e7ee;
    --text: #1b2533;
    --muted: #64718a;
    --primary: #2b5a8a;
    --primary-strong: #1f4670;
    --primary-soft: #e6eef7;
    --sidebar: #16263a;
    --sidebar-text: #b9c6d8;
    --sidebar-active: #24405f;
    --ok: #1d7a4a; --ok-bg: #e3f4ea;
    --warn: #8a5a00; --warn-bg: #fdf1d6;
    --danger: #b42318; --danger-bg: #fde8e6;
    --info: #1f5a96; --info-bg: #e3eefa;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1722; --surface: #172131; --surface-2: #1c283a; --border: #2a3a51;
        --text: #e4eaf3; --muted: #94a3bb; --primary: #5b9bd8; --primary-strong: #7bb2e6; --primary-soft: #1d3149;
        --sidebar: #0b121c; --sidebar-text: #9fb0c8; --sidebar-active: #1d3149;
        --ok: #5cd394; --ok-bg: #12301f; --warn: #f2c25b; --warn-bg: #3a2c0c;
        --danger: #ff8a7f; --danger-bg: #3d1714; --info: #8cc0f2; --info-bg: #142c45;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0; line-height: 1.25; font-weight: 650; }
h1 small { font-size: .95rem; color: var(--muted); font-weight: 500; }
h2 { font-size: 1.02rem; margin: 0 0 .8rem; font-weight: 650; }
code.block { display: block; padding: .6rem .7rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; word-break: break-all; font-size: .85rem; }
.mono, .secret { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; margin: 0; }
.ico { width: 18px; height: 18px; fill: currentColor; flex: none; }

/* ---------- Layout ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: 248px; background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; z-index: 30; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.2rem .4rem; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand .ico { width: 24px; height: 24px; fill: #7fb3e8; }
.company { padding: 0 1.2rem .9rem 3.3rem; font-size: .8rem; color: var(--sidebar-text); opacity: .8; }
.sidebar nav { display: flex; flex-direction: column; padding: .4rem .6rem; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 6px; color: var(--sidebar-text); }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; }
.nav-section { margin: 1rem .7rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; opacity: .6; }
.sidebar-foot { margin-top: auto; padding: 1rem 1.2rem; font-size: .75rem; opacity: .5; }

.main { margin-left: 248px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
    padding: .6rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.quicksearch { flex: 1; max-width: 460px; }
.quicksearch input { width: 100%; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.user-link { display: flex; align-items: center; gap: .55rem; color: var(--text); }
.user-link:hover { text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); }
.content { padding: 1.5rem; max-width: 1500px; width: 100%; }

.nav-toggle, .burger, .nav-backdrop { display: none; }

/* ---------- Komponenten ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.crumbs { margin: 0 0 .2rem; font-size: .85rem; color: var(--muted); }
.head-badges { margin: .45rem 0 0; display: flex; gap: .4rem; flex-wrap: wrap; }
.count { display: inline-block; font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 .55rem; vertical-align: middle; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.card-head h2 { margin: 0; }
.card-head meter { width: 180px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 1.1rem; }
.grid-wide-left { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.stack-cards > .card:last-child { margin-bottom: 0; }

.btn {
    display: inline-flex; align-items: center; gap: .35rem; padding: .48rem .9rem; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 550;
    cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: #c9d2de; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #911c13; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn-xs { padding: .1rem .45rem; font-size: .78rem; }
.btn-block { width: 100%; justify-content: center; padding: .65rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }
.btn-group { display: inline-flex; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }

.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.alert { padding: .7rem .9rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warn-bg); color: var(--warn); }
.alert-info { background: var(--info-bg); color: var(--info); }

/* ---------- Formulare ---------- */
input, select, textarea {
    font: inherit; color: var(--text); background: var(--surface); border: 1px solid #cdd5e0; border-radius: 6px;
    padding: .45rem .6rem; min-width: 0;
}
@media (prefers-color-scheme: dark) { input, select, textarea { border-color: var(--border); background: var(--surface-2); } }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
textarea { resize: vertical; width: 100%; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .9rem 1.2rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .88rem; }
.field input, .field select, .field textarea { width: 100%; }
.field label.check, label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.req { color: var(--danger); }
.help { margin: 0; font-size: .8rem; color: var(--muted); }
.error-text { margin: 0; font-size: .82rem; color: var(--danger); font-weight: 600; }
.form-actions { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.stack label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .88rem; }
.stack input { width: 100%; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters input[type=search] { flex: 1 1 260px; }
.filters select { max-width: 220px; }
.filters-inline { margin: .2rem 0 1rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.inline-form select { min-width: 260px; flex: 1 1 260px; max-width: 420px; }
.inline-form input[name=note] { flex: 1 1 200px; }
.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.2rem; padding: 0 1.2rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 650; padding: .55rem .6rem; border-bottom: 2px solid var(--border); white-space: nowrap; }
table.data td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; white-space: nowrap; }
table.data td.txt { white-space: normal; min-width: 9.5rem; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tfoot td { border-top: 2px solid var(--border); border-bottom: 0; }
table.data .num { text-align: right; white-space: nowrap; }
table.data .sel { width: 28px; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .actions form { display: inline; }
tr.row-alert td { background: var(--danger-bg); }
tr.row-muted td { color: var(--muted); }
a.sort { color: inherit; }
.bulkbar { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.empty { color: var(--muted); padding: .8rem 0; margin: 0; }
.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; margin-top: 1rem; }

/* ---------- Kennzahlen ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: .15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; color: var(--text); box-shadow: var(--shadow); }
a.kpi:hover { text-decoration: none; border-color: var(--primary); }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi-warn { border-left: 4px solid #e0a106; }
.kpi-danger { border-left: 4px solid var(--danger); }
meter { width: 100%; height: 8px; }
.totals { display: flex; flex-wrap: wrap; gap: .6rem 2rem; padding: .8rem 0 1rem; }
.totals div { display: flex; flex-direction: column; }
.totals span { font-size: .78rem; }
.totals strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

dl.kv { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; gap: .4rem .8rem; margin: 0; }
dl.kv-wide { grid-template-columns: minmax(140px, 240px) 1fr; }
dl.kv dt { color: var(--muted); font-size: .85rem; }
dl.kv dd { margin: 0; word-break: break-word; }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

ul.files, ul.plain, ul.timeline { list-style: none; margin: 0; padding: 0; }
ul.files li { display: flex; gap: .8rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
ul.files li form { margin-left: auto; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
ul.timeline li { padding: .35rem 0 .35rem .9rem; border-left: 2px solid var(--border); font-size: .88rem; }
ul.plain li:last-child, ul.files li:last-child { border-bottom: 0; }

.text-danger { color: var(--danger); font-weight: 600; }
.text-warn { color: var(--warn); }
.mt { margin-top: 1.2rem; }
fieldset.choice { border: 1px solid var(--border); border-radius: 6px; padding: .6rem .9rem; margin: 0; display: grid; gap: .35rem; }
fieldset.choice legend { font-weight: 600; font-size: .88rem; padding: 0 .3rem; }
ol.steps { margin: 0 0 .8rem; padding-left: 1.2rem; }
ol.steps li { padding: .15rem 0; }

.checklist { list-style: none; padding: 0; margin: 0 0 1rem; font-size: .9rem; }
.checklist .ok { color: var(--ok); }
.checklist .fail { color: var(--danger); font-weight: 600; }

/* ---------- Anmeldung ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 1rem; background: linear-gradient(160deg, var(--sidebar) 0%, #24405f 100%); }
.auth-box { width: 100%; max-width: 420px; background: var(--surface); border-radius: 12px; padding: 2rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.brand-auth { color: var(--text); justify-content: center; padding: 0 0 .3rem; font-size: 1.25rem; }
.brand-auth .ico { fill: var(--primary); width: 30px; height: 30px; }
.auth-title { font-size: 1.15rem; margin: 1rem 0; text-align: center; }

/* ---------- Responsiv ---------- */
@media (max-width: 1200px) {
    .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .nav-toggle:checked ~ .sidebar { transform: none; }
    .nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 25; }
    .main { margin-left: 0; }
    .burger { display: flex; flex-direction: column; gap: 4px; cursor: pointer; padding: .4rem; }
    .burger span { width: 20px; height: 2px; background: var(--text); display: block; }
    .grid-2, .grid-3, .grid-wide-left { grid-template-columns: minmax(0, 1fr); }
    .kpis, .kpis-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .user-meta { display: none; }
    .content { padding: 1rem; }
    .topbar { padding: .5rem 1rem; }
}
@media (max-width: 520px) {
    .kpis, .kpis-3 { grid-template-columns: minmax(0, 1fr); }
    dl.kv, dl.kv-wide { grid-template-columns: minmax(0, 1fr); }
    dl.kv dd { margin-bottom: .4rem; }
    .quicksearch { display: none; }
}
@media print {
    .sidebar, .topbar, .btn, .filters, .bulkbar, .inline-form, .danger-zone { display: none !important; }
    .main { margin: 0; }
    .card { box-shadow: none; break-inside: avoid; }
}
