:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #d9e0ea;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
    --sidebar: #111827;
    --shadow: 0 14px 36px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

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

a { color: var(--primary-dark); text-decoration: none; }
h1, h2 { margin: 0 0 .5rem; line-height: 1.15; letter-spacing: 0; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.15rem; }
p { margin-top: 0; }
strong { font-weight: 800; }

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.mobile-shellbar,
.sidebar-backdrop { display: none; }

.mobile-menu-button {
    display: grid;
    gap: 4px;
    place-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 8px;
    background: #1f2937;
}
.mobile-menu-button span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
}

.sidebar {
    background: var(--sidebar);
    color: #fff;
    padding: 24px 18px;
}

.brand,
.login-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 10px;
    background: #08111f;
    color: #fff;
    font-weight: 850;
}
.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.brand strong { display: block; }
.brand span,
.topbar p,
.meta,
.page-header p { color: var(--muted); }
.sidebar .brand span,
.mobile-brand span { color: #b8c2d6; }

.side-nav {
    display: grid;
    gap: 4px;
}
.nav-link {
    display: block;
    min-height: 40px;
    border-radius: 8px;
    padding: 9px 12px;
    color: #d6dceb;
    font-weight: 650;
}
.nav-link:hover { background: #1f2937; color: #fff; }
.nav-link.sub {
    min-height: 34px;
    margin-left: 10px;
    padding: 7px 10px;
    color: #b8c2d6;
    font-size: .94rem;
}
.nav-group {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, .1);
}
.nav-group summary {
    min-height: 36px;
    padding: 8px 12px;
    cursor: pointer;
    color: #f8fafc;
    font-weight: 750;
    list-style: none;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after {
    content: " ▾";
    color: #94a3b8;
}

.content {
    min-width: 0;
    padding: 28px;
}
.public-content {
    min-height: 100vh;
}
.public-content.login-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(37, 99, 235, .12), transparent 36%),
        var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    min-height: 48px;
}
.topbar p { margin: 3px 0 0; }
.topbar h1,
.page-header h1 { margin-bottom: 4px; }
.topbar-title {
    min-width: 0;
}
.topbar-title h1 {
    margin: 0;
}
.topbar-title p {
    margin: 4px 0 0;
    color: var(--muted);
}
.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex: 0 0 auto;
}
.topbar-actions form {
    margin: 0;
}
.topbar-user {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 650;
    white-space: nowrap;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.page-header p,
.meta { margin: .2rem 0 0; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.panel,
.card,
.table-card,
.setup-panel {
    margin-bottom: 16px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 25px rgba(15, 23, 42, .04);
}
.setup-panel {
    width: min(760px, calc(100% - 2rem));
    margin: 48px auto;
}
.setup-body { background: #edf1f5; }
.card > h2,
.table-card > h2 { margin-bottom: 14px; }

.status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 800;
}
.status.open { background: #fff7ed; color: var(--warning); }
.status.done { background: #ecfdf5; color: var(--success); }
.training-card {
    position: relative;
    padding-top: 34px;
}
.training-card-head {
    display: block;
    margin-bottom: 14px;
    padding-right: 132px;
}
.training-card-head h2 {
    margin: 0;
}
.training-card-head .status {
    position: absolute;
    top: 20px;
    right: 20px;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 8px;
}
.training-card-head .status.done {
    background: var(--success);
    color: #fff;
}
.training-card-head .status.open {
    background: var(--danger);
    color: #fff;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.stacked-form {
    display: grid;
    gap: 16px;
}
label {
    display: grid;
    gap: 6px;
    color: #25323a;
    font-weight: 650;
}
input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
.wide { grid-column: 1 / -1; }
.section-inline {
    display: grid;
    gap: 4px;
    align-content: end;
}
.section-inline h2 {
    margin: 0;
    font-size: 1rem;
}
.section-inline p {
    margin: 0;
    color: var(--muted);
}
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; min-height: auto; }
.actions {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    gap: 8px;
    grid-column: 1 / -1;
}
.update-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.button-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font: inherit;
    font-weight: 750;
    text-align: center;
    white-space: nowrap;
}
.button.primary { background: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.button.danger { background: var(--danger); color: #fff; }
.button.small { min-height: 34px; padding: 6px 10px; font-size: .92rem; }
.button.link { border: 0; background: transparent; color: var(--primary-dark); padding-left: 0; }
.button.disabled { background: #e8eef1; color: var(--muted); cursor: not-allowed; }
.login-submit {
    width: 100%;
    min-height: 48px;
    margin-top: 4px;
    font-size: 1rem;
}

.notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.notice.success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.notice.danger { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.notice.info { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.danger-zone {
    border-color: #fecaca;
    background: #fffafa;
}
.danger-zone p { color: #7f1d1d; }
.detail-panel { background: #fbfcfe; }
.metric-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.metric-row > div {
    display: grid;
    gap: 2px;
    min-height: 78px;
    align-content: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.metric-row strong { font-size: 1.45rem; }
.metric-row span { color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
th {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 800;
}
.table-action {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}
.table-card table tr:last-child td { border-bottom: 0; }
.compact-form,
.inline-edit,
.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 8px;
}
.compact-form input,
.compact-form select,
.inline-edit input,
.filter-row select {
    width: auto;
    min-width: 150px;
}
.inline-edit { margin-top: 10px; }

.pdf-frame {
    width: 100%;
    min-height: 72vh;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.confirm-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.check-list { padding-left: 20px; }
.check-list .ok { color: var(--success); }
.check-list .fail { color: var(--danger); }

.app-footer,
.footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-top: 28px;
    padding: 18px 0 2px;
    color: var(--muted);
    font-size: .9rem;
}
.app-footer a,
.footer a { color: var(--muted); font-weight: 650; text-decoration: none; }
.app-footer a:hover,
.footer a:hover { color: var(--primary-dark); text-decoration: underline; }
.legal-page {
    width: min(960px, calc(100% - 32px));
    max-width: 900px;
    margin: 32px auto;
}
.legal-content { color: #25323a; }
.legal-editor {
    min-height: 430px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.subnav a {
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
}
.subnav a.active {
    border-color: var(--primary);
    background: #eef4ff;
    color: var(--primary-dark);
}

.is-hidden { display: none !important; }
.cookie-banner {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 100;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    width: min(720px, calc(100vw - 36px));
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .18);
}
.cookie-banner p {
    margin: 4px 0 8px;
    color: var(--muted);
}
.cookie-banner ul {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    font-size: .9rem;
}
.cookie-actions {
    display: flex;
    align-items: end;
    gap: 8px;
}

.login-page {
    min-height: auto;
    width: 100%;
    display: grid;
    place-items: center;
    padding: 0;
}

.public-content > .notice {
    position: fixed;
    top: 16px;
    left: 50%;
    z-index: 20;
    width: min(520px, calc(100vw - 32px));
    transform: translateX(-50%);
}

.login-content .public-footer {
    justify-content: center;
    width: 100%;
    margin: 18px 0 0;
    padding: 0;
}

.login-content .public-footer a {
    color: var(--muted);
}

.login-panel {
    width: min(100%, 440px);
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .12);
}

.login-brand h1 {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 700;
}

.login-brand p {
    margin: 3px 0 0;
    color: var(--muted);
}

@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
        min-height: calc(100vh - 66px);
    }
    .mobile-shellbar {
        position: sticky;
        top: 0;
        z-index: 40;
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 66px;
        padding: 12px 16px;
        background: var(--sidebar);
        color: #fff;
        box-shadow: 0 6px 20px rgba(15, 23, 42, .18);
    }
    .mobile-brand { margin-bottom: 0; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 50;
        width: min(84vw, 320px);
        transform: translateX(-100%);
        transition: transform .18s ease;
        overflow-y: auto;
        box-shadow: 16px 0 32px rgba(15, 23, 42, .25);
    }
    body.menu-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 45;
        background: rgba(15, 23, 42, .45);
    }
    body.menu-open .sidebar-backdrop { display: block; }
    .content { padding: 18px; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 760px) {
    body { background: #fff; }
    h1 { font-size: 1.55rem; }
    .content { padding: 16px; width: 100%; }
    .card,
    .table-card,
    .setup-panel {
        box-shadow: none;
    }
    .card,
    .table-card {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        margin-left: -16px;
        margin-right: -16px;
    }
    .form-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .metric-row { grid-template-columns: 1fr; }
    table,
    thead,
    tbody,
    tr,
    th,
    td { display: block; }
    thead { display: none; }
    tr {
        padding: 10px 0;
        border-bottom: 1px solid var(--line);
    }
    td {
        padding: 6px 0;
        border: 0;
    }
    .table-action {
        width: auto;
        text-align: left;
    }
    td.table-action .button {
        width: 100%;
        margin-top: 6px;
    }
    .compact-form input,
    .compact-form select,
    .inline-edit input,
    .filter-row select {
        width: 100%;
    }
    .cookie-banner {
        right: 12px;
        bottom: 12px;
        grid-template-columns: 1fr;
        width: calc(100vw - 24px);
    }
    .cookie-actions {
        align-items: stretch;
        flex-direction: column;
    }
}

/* KFZ portal layout layer, adapted to the Schulungsportal class names. */
.page-header {
    align-items: center;
    min-height: 42px;
}

.page-header h1,
.topbar h1 {
    font-size: 1.55rem;
    font-weight: 700;
}

.page-header .button,
.topbar .button {
    flex: 0 0 auto;
}

.card,
.table-card,
.panel {
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, .04);
}

.card + .card,
.table-card + .card,
.card + .table-card {
    margin-top: 16px;
}

.grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid > .card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 154px;
}

.grid > .card:hover {
    border-color: #c8d7f4;
    background: #fbfdff;
}

.card h2,
.table-card h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.table-card {
    overflow: hidden;
}
.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.table-card-header .button {
    margin-left: auto;
}
.table-card-header h2 {
    margin: 0;
}

.table-card table {
    background: #fff;
}

.table-card th {
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

.table-card td {
    background: #fff;
}

.table-card tr:hover td {
    background: #fbfcfe;
}

.table-action {
    vertical-align: middle;
}

.filter-row {
    align-items: flex-end;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.filter-row label {
    min-width: 180px;
}

.form-grid {
    align-items: end;
}

.form-grid > .wide,
.form-grid > .notice,
.form-grid > .actions {
    align-self: stretch;
}

.form-grid textarea {
    align-self: stretch;
}

label {
    margin: 0;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(37, 99, 235, .14);
}

.button {
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.button:hover {
    box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
}

.button.secondary:hover {
    border-color: #c8d7f4;
    background: #f8fbff;
    color: var(--primary-dark);
}

.button.link:hover {
    box-shadow: none;
    text-decoration: underline;
}

.notice {
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .03);
}

.status {
    border-radius: 999px;
    white-space: nowrap;
}

.metric-row {
    margin-top: 4px;
}

.metric-row > div {
    min-height: 86px;
    background: #fbfcfe;
}

.confirm-box {
    background: #f8fafc;
}

.course-chapter,
.question-box {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}
.course-chapter + .course-chapter {
    margin-top: 12px;
}
.course-chapter h3,
.question-box legend {
    margin: 0 0 10px;
    font-weight: 750;
}
.question-box {
    display: grid;
    gap: 10px;
}
.question-box legend {
    padding: 0;
}

.pdf-frame {
    display: block;
    background: #f8fafc;
}

.subnav {
    padding: 4px 0;
}

.subnav a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.sidebar .nav-link,
.side-nav .nav-link {
    color: #d6dceb;
    text-decoration: none;
}

.sidebar .nav-link:hover,
.side-nav .nav-link:hover {
    background: #1f2937;
    color: #fff;
}

.nav-group summary {
    border-radius: 8px;
}

.nav-group summary:hover {
    background: #1f2937;
}

.legal-content {
    line-height: 1.65;
}

.setup-body {
    background:
        linear-gradient(135deg, rgba(37, 99, 235, .08), transparent 34%),
        #edf1f5;
}

.setup-panel {
    box-shadow: 0 18px 50px rgba(15, 23, 42, .12);
}

.setup-panel > h1 {
    font-size: 1.65rem;
    font-weight: 760;
}

@media (max-width: 1080px) {
    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 960px) {
    .page-header {
        align-items: flex-start;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .filter-row,
    .button-row,
    .update-actions,
    .confirm-box {
        align-items: stretch;
        flex-direction: column;
    }

    .filter-row label,
    .filter-row select,
    .filter-row input,
    .filter-row .button,
    .button-row .button,
    .update-actions .button,
    .confirm-box .button {
        width: 100%;
    }
}

@media (max-width: 760px) {
    .page-header .button,
    .topbar .button,
    .actions .button {
        width: 100%;
    }

    .topbar-actions {
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
    }

    .topbar-user {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .training-card {
        padding-top: 20px;
    }

    .training-card-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        padding-right: 0;
    }

    .training-card-head .status {
        position: static;
    }

    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .table-card {
        overflow: visible;
    }

    .table-card-header {
        align-items: center;
        flex-direction: row;
    }

    .table-card tr {
        margin: 0 0 12px;
        padding: 10px 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }

    .table-card tr:last-child {
        margin-bottom: 0;
    }

    .table-card td {
        display: grid;
        grid-template-columns: minmax(116px, 38%) minmax(0, 1fr);
        gap: 10px;
        padding: 8px 0;
        background: transparent;
    }

    .table-card td::before {
        content: "";
        color: var(--muted);
        font-size: .82rem;
        font-weight: 700;
    }

    .table-card td.table-action {
        display: block;
    }

    .table-card td.table-action::before {
        content: none;
    }

    .login-panel,
    .setup-panel {
        width: min(100%, 440px);
        margin: 0 auto;
    }

    .login-page {
        padding: 0;
    }

    .public-content.login-content {
        padding: 18px;
    }
}
