/*
 * Service-Portal – eigenes Stylesheet ohne Framework.
 * Nur System-Schriften, keine externen Ressourcen. Inline-Styles sind per CSP verboten,
 * deshalb gibt es für Balkenbreiten die Klassen .pct-0 bis .pct-100.
 */

:root {
    --navy: #14283c;
    --navy-2: #1d3650;
    --accent: #f2b705;
    --psa: #0f766e;
    --psa-dark: #0d5f59;
    --cs: #6d28d9;
    --cs-dark: #5b21b6;
    --admin: #475569;
    --bg: #f3f5f8;
    --border: #e2e7ee;
    --text: #1f2937;
    --muted: #64748b;
    --danger: #b91c1c;
    --warning: #b45309;
    --success: #15803d;
    --sidebar-w: 240px;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45; }
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .6rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
code, .mono { font-family: var(--mono); font-size: .88em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--navy); color: #c8d4e0; display: flex; flex-direction: column; z-index: 10;
}
.brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1.1rem 1rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand:hover { text-decoration: none; }
.brand small { display: block; color: #8fa3b8; font-size: .75rem; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: var(--navy); font-weight: 800; letter-spacing: .5px; flex: none; }
.brand-mark.lg { width: 54px; height: 54px; font-size: 1.3rem; border-radius: 12px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: .6rem 0; }
.nav-link { display: block; color: #c8d4e0; padding: .42rem 1.2rem; border-left: 3px solid transparent; font-size: .93rem; }
.nav-link:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--navy-2); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav-section { margin: 1rem 1.2rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; display: flex; align-items: center; gap: .45rem; color: #8fa3b8; }
.nav-section::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.nav-section.psa::before { background: #2dd4bf; }
.nav-section.cs::before { background: #a78bfa; }
.sidebar-footer { padding: .8rem 1.2rem; font-size: .75rem; color: #6b8299; border-top: 1px solid rgba(255,255,255,.08); }

/* ---------- Hauptbereich ---------- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--border); padding: .7rem 1.6rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.page-title { font-size: 1.15rem; font-weight: 600; }
.area-pill { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .22rem .55rem; border-radius: 999px; color: #fff; background: var(--admin); }
.area-psa .area-pill { background: var(--psa); }
.area-cs .area-pill { background: var(--cs); }
.user-info { text-align: right; line-height: 1.25; }
.content { padding: 1.5rem 1.6rem 3rem; max-width: 1500px; }

/* Kontomenü ohne JavaScript (<details>) */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-items { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(16,24,40,.12); min-width: 180px; padding: .3rem 0; z-index: 20; }
.menu-items a, .menu-items button { display: block; width: 100%; text-align: left; padding: .45rem 1rem; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.menu-items a:hover, .menu-items button:hover { background: #f1f5f9; text-decoration: none; }

/* ---------- Raster und Abstände ---------- */
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: start; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.side-main { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.grid.stretch { align-items: stretch; }
.span-2 { grid-column: span 2; }
.row-flex { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.row-flex.between { justify-content: space-between; }
.row-flex.end { justify-content: flex-end; }
.row-flex.top { align-items: flex-start; }
.row-flex.bottom { align-items: flex-end; }
.gap-lg { gap: 1rem; }
.gap-xl { gap: 1.6rem; }
.mt { margin-top: 1rem; } .mt-sm { margin-top: .5rem; } .mt-0 { margin-top: 0; }
.mb { margin-bottom: 1rem; } .mb-sm { margin-bottom: .5rem; } .mb-0 { margin-bottom: 0; }
.grow { flex: 1; }
.narrow { max-width: 640px; }
.w-100 { width: 100%; }
.inline { display: inline; }
.nowrap { white-space: nowrap; }
.pre-line { white-space: pre-line; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none; }

/* ---------- Texte ---------- */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.xsmall { font-size: .75rem; }
.strong { font-weight: 600; }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 1.4rem 0 .6rem; }
.otp { font-family: var(--mono); font-size: 1.1rem; background: #fff7d6; padding: .15rem .5rem; border-radius: 6px; }
.lead { font-size: 1.05rem; color: var(--muted); }

/* ---------- Karten und Kennzahlen ---------- */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); min-width: 0; }
.card-header { padding: .75rem 1rem; font-weight: 600; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.card-body { padding: 1rem; }
.card-footer { padding: .6rem 1rem; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); }
.card > .table-wrap:last-child .table tr:last-child td { border-bottom: 0; }
.kpi { padding: 1rem 1.2rem; }
.kpi .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.kpi .value.md { font-size: 1.3rem; }
.kpi .hint { font-size: .82rem; color: var(--muted); }
.kpi.warn .value { color: var(--warning); }
.kpi.bad .value { color: var(--danger); }
.area-tile { border-left: 5px solid var(--admin); height: 100%; }
.area-tile.psa { border-left-color: var(--psa); }
.area-tile.cs { border-left-color: var(--cs); }
.area-tile.locked { opacity: .55; }
.stat { display: inline-block; margin-right: 1.5rem; }
.stat .num-lg { font-size: 1.4rem; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .45rem .9rem; border-radius: 7px; border: 1px solid transparent;
    font: inherit; font-size: .92rem; font-weight: 550; line-height: 1.2; cursor: pointer;
    background: #e2e8f0; color: var(--text); text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(.96); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: #1d4ed8; color: #fff; }
.area-psa .btn-primary, .btn-psa { background: var(--psa); color: #fff; }
.area-cs .btn-primary, .btn-cs { background: var(--cs); color: #fff; }
.area-admin .btn-primary { background: var(--admin); color: #fff; }
.btn-accent { background: var(--accent); color: var(--navy); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border-color: #cbd5e1; color: var(--text); }
.btn-outline-danger { background: #fff; border-color: #fca5a5; color: var(--danger); }
.btn-sm { padding: .25rem .6rem; font-size: .82rem; }
.btn-link { background: none; border: 0; padding: 0; color: #1d4ed8; font-weight: 500; }
.btn-link.danger { color: var(--danger); }
.btn-block { width: 100%; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.actions form { display: inline; }

/* ---------- Formulare ---------- */
label.field { display: block; margin-bottom: .75rem; }
label.field > span, .field-label { display: block; font-size: .83rem; font-weight: 600; color: #475569; margin-bottom: .2rem; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], input[type=email], input[type=file], select, textarea {
    width: 100%; padding: .45rem .6rem; border: 1px solid #cbd5e1; border-radius: 7px;
    font: inherit; font-size: .93rem; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; outline-offset: 0; border-color: #60a5fa; }
input[readonly] { background: #f1f5f9; }
input.qty { width: 6rem; }
input.count { width: 6.5rem; text-align: right; }
select[multiple] { min-height: 9rem; }
textarea { min-height: 4rem; }
.check { display: flex; gap: .5rem; align-items: flex-start; margin: .35rem 0; font-size: .93rem; }
.check input { margin-top: .2rem; }
.form-row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.form-row label.field { margin-bottom: 0; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .9rem; margin: 0 0 .9rem; }
legend { font-size: .83rem; font-weight: 600; color: #475569; padding: 0 .3rem; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .45rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
.table thead th a { color: inherit; }
.table tbody tr:hover { background: #f8fafc; }
.table tfoot td { font-weight: 700; background: #f8fafc; }
.table.compact th, .table.compact td { padding: .3rem .55rem; }
.table tr.muted td { color: #94a3b8; }
.table tr.warn td { background: #fff7ed; }
.table tr.bad td { background: #fef2f2; }
.table tr.ok td { background: #f0fdf4; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stock-low { color: var(--danger); font-weight: 700; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* ---------- Badges und Meldungen ---------- */
.badge { display: inline-block; padding: .18rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e2e8f0; color: #334155; white-space: nowrap; margin: 0 .2rem .15rem 0; }
.badge-psa { background: #ccfbf1; color: #115e59; }
.badge-cs { background: #ede9fe; color: #5b21b6; }
.badge-admin { background: #e2e8f0; color: #334155; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-bad { background: #fee2e2; color: #991b1b; }
.badge-off { background: #f1f5f9; color: #94a3b8; border: 1px solid var(--border); }
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ---------- Diagramme ---------- */
.bar-track { background: #eef2f6; border-radius: 5px; height: 10px; min-width: 80px; }
.bar { height: 10px; border-radius: 5px; background: var(--psa); }
.area-cs .bar { background: var(--cs); }
.month-chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.month-chart .col-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.month-chart .col-bar .fill { width: 100%; background: var(--psa); border-radius: 4px 4px 0 0; min-height: 2px; }
.area-cs .month-chart .col-bar .fill { background: var(--cs); }
.month-chart .col-bar span { font-size: .7rem; color: var(--muted); margin-top: 4px; }
.bar.pct-0 { width: 0; } .bar.pct-5 { width: 5%; } .bar.pct-10 { width: 10%; } .bar.pct-15 { width: 15%; } .bar.pct-20 { width: 20%; }
.bar.pct-25 { width: 25%; } .bar.pct-30 { width: 30%; } .bar.pct-35 { width: 35%; } .bar.pct-40 { width: 40%; } .bar.pct-45 { width: 45%; }
.bar.pct-50 { width: 50%; } .bar.pct-55 { width: 55%; } .bar.pct-60 { width: 60%; } .bar.pct-65 { width: 65%; } .bar.pct-70 { width: 70%; }
.bar.pct-75 { width: 75%; } .bar.pct-80 { width: 80%; } .bar.pct-85 { width: 85%; } .bar.pct-90 { width: 90%; } .bar.pct-95 { width: 95%; }
.bar.pct-100 { width: 100%; }
.fill.pct-0 { height: 0; } .fill.pct-5 { height: 5%; } .fill.pct-10 { height: 10%; } .fill.pct-15 { height: 15%; } .fill.pct-20 { height: 20%; }
.fill.pct-25 { height: 25%; } .fill.pct-30 { height: 30%; } .fill.pct-35 { height: 35%; } .fill.pct-40 { height: 40%; } .fill.pct-45 { height: 45%; }
.fill.pct-50 { height: 50%; } .fill.pct-55 { height: 55%; } .fill.pct-60 { height: 60%; } .fill.pct-65 { height: 65%; } .fill.pct-70 { height: 70%; }
.fill.pct-75 { height: 75%; } .fill.pct-80 { height: 80%; } .fill.pct-85 { height: 85%; } .fill.pct-90 { height: 90%; } .fill.pct-95 { height: 95%; }
.fill.pct-100 { height: 100%; }

/* ---------- Anmeldung ---------- */
.auth-body { background: linear-gradient(135deg, var(--navy) 0%, #23466b 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
/* Unten mehr Abstand als oben: der Inhalt sitzt optisch etwas über der Mitte */
.auth-wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 2rem 1rem 22vh; }
.auth-brand { display: flex; gap: 1rem; align-items: center; justify-content: center; color: #fff; margin-bottom: 1.5rem; }
.auth-brand h1 { font-size: 1.7rem; margin: 0; font-weight: 700; }
.auth-brand p { margin: 0; color: #b8c8d8; }
.auth-footer { color: #8fa3b8; font-size: .8rem; margin-top: 1.5rem; text-align: center; }
.auth-wrap > .alert, .auth-wrap > .narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
/* Anmeldekarte mittig; mit Demo-Zugängen stehen beide Karten nebeneinander und zusammen mittig */
.login-grid { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 1.5rem; }
.login-grid > .card { flex: 1 1 340px; max-width: 420px; }
.login-grid > .card + .card { flex: 1 1 460px; max-width: 520px; }

/* ---------- Druckansichten ---------- */
.letter { background: #fff; max-width: 210mm; min-height: 270mm; margin: 0 auto 1.5rem; padding: 18mm 20mm; box-shadow: 0 2px 8px rgba(0,0,0,.08); font-size: 11pt; }
.letter .sender { font-size: 8pt; color: #555; border-bottom: 1px solid #999; display: inline-block; margin-bottom: 4mm; }
.letter .address { min-height: 40mm; }
.letter .date { text-align: right; margin-bottom: 8mm; }
.print-only { display: none; }

@media print {
    .no-print, .sidebar, .topbar { display: none !important; }
    .print-only { display: block; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; max-width: none; }
    body { background: #fff; font-size: 10pt; }
    .letter { box-shadow: none; margin: 0; page-break-after: always; }
    .card { border: none; box-shadow: none; }
    .table tbody tr:hover { background: none; }
    a { color: inherit; }
}

/* ---------- Schmale Bildschirme (Tablet für Inventur) ---------- */
@media (max-width: 1100px) {
    .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.main-side, .grid.side-main, .grid.cols-3 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
}
@media (max-width: 800px) {
    .sidebar { position: static; width: auto; }
    .sidebar nav { max-height: none; }
    .main { margin-left: 0; }
    .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
    .topbar { position: static; flex-wrap: wrap; }
}

/* ---------- Ergänzungen ---------- */
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain:disabled input, fieldset.plain:disabled select { background: #f8fafc; color: var(--muted); }
fieldset.scroll-box { max-height: 220px; overflow: auto; margin: 0; }
.scroll-y { max-height: 600px; overflow-y: auto; }
.scroll-y thead th { position: sticky; top: 0; z-index: 1; }
.bar.full { background: var(--warning) !important; }
