:root {
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --border: #e2e6ee;
    --text: #1f2430;
    --muted: #6b7280;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 10px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.05);

    --m0: #dc2626;
    --m1: #ea580c;
    --m2: #d97706;
    --m3: #65a30d;
    --m4: #16a34a;
}

* { box-sizing: border-box; }

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

.topbar {
    background: var(--primary-dark);
    color: white;
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
    position: relative;
    z-index: 10;
}
.topbar .brand { color: white; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.topbar nav a { color: #dbeafe; margin-left: 24px; text-decoration: none; font-size: 0.95rem; transition: color 0.15s ease; }
.topbar nav a:hover { color: white; }
.topbar nav a:hover { color: white; }

.container { max-width: 1000px; margin: 0 auto; padding: 32px 24px 80px; }

h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.2rem; margin: 32px 0 12px; border-bottom: 2px solid var(--border); padding-bottom: 6px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.05s ease;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { box-shadow: var(--shadow-md); }
.btn-secondary { background: white; }
.btn-danger { background: white; color: var(--danger); border-color: var(--danger); }
.inline-form { display: inline; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease; }
.card:hover { box-shadow: var(--shadow-md); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-head h3 { margin: 0; font-size: 1.05rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.badge { font-size: 0.7rem; padding: 3px 8px; border-radius: 20px; background: #eef2ff; color: var(--primary-dark); white-space: nowrap; }
.badge-completed { background: #dcfce7; color: #166534; }

.score-row { display: flex; gap: 16px; margin: 14px 0 8px; }
.score-box, .summary-box { text-align: center; }
.score-value { display: block; font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); }
.score-label { font-size: 0.78rem; color: var(--muted); }

.summary-bar { display: flex; gap: 32px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 24px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.score-explainer { font-size: 0.8rem; color: var(--muted); margin: -12px 0 20px; }

.delta-badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 0.8rem; font-weight: 600; }
.delta-up { background: #dcfce7; color: #166534; }
.delta-down { background: #fef2f2; color: #991b1b; }
.delta-flat { background: #f3f4f6; color: var(--muted); }

.progress-bar { background: #e5e7eb; border-radius: 20px; height: 10px; overflow: hidden; margin: 6px 0; }
.progress-bar.small { height: 7px; width: 140px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.progress-fill { background: var(--primary); height: 100%; }

.form-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 560px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
.form-card label { font-weight: 600; font-size: 0.85rem; margin-top: 10px; }
.form-card input, .form-card select { padding: 9px 10px; border-radius: 6px; border: 1px solid var(--border); font-size: 0.95rem; }
.form-card input[type="range"] { padding: 0; border: none; accent-color: var(--primary); }
.form-card .hint { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.category-list { display: flex; flex-direction: column; gap: 8px; }
.category-row {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 14px 18px; text-decoration: none; color: var(--text);
    box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.category-row:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.category-row-main { display: flex; align-items: center; gap: 14px; }
.cat-code { font-weight: 700; color: var(--primary); width: 22px; text-align: center; }
.cat-title { font-weight: 600; }
.category-row-score { display: flex; align-items: center; }

.breadcrumb { color: var(--muted); font-size: 0.85rem; margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); }

.category-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.cat-pill { padding: 5px 10px; border-radius: 20px; background: white; border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: 0.82rem; }
.cat-pill.active { background: var(--primary); border-color: var(--primary); color: white; }

.control-block { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; scroll-margin-top: 16px; box-shadow: var(--shadow-sm); }
.control-block:target { border-color: var(--primary); box-shadow: 0 0 0 3px #dbeafe; }
.measure-card:target { border-color: var(--primary); box-shadow: 0 0 0 3px #dbeafe; scroll-margin-top: 16px; }
.control-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.control-head h3 { margin: 0; font-size: 1.02rem; }
.legal-ref { font-size: 0.75rem; color: var(--muted); text-align: right; }
.legal-ref a { color: var(--primary-dark); text-decoration: underline; }
.control-question { font-weight: 500; margin: 8px 0; }
.control-guidance { font-size: 0.85rem; color: var(--muted); background: #f8fafc; padding: 8px 12px; border-radius: 6px; }

.field-group { margin-top: 14px; }
.field-label { display: block; font-weight: 600; font-size: 0.82rem; margin-bottom: 6px; }
.field-group textarea { width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border); font-family: inherit; font-size: 0.9rem; resize: vertical; }

.maturity-select { margin-top: 14px; }

.maturity-pill { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; color: white; font-weight: 700; font-size: 0.78rem; }
.maturity-0 { background: var(--m0); }
.maturity-1 { background: var(--m1); }
.maturity-2 { background: var(--m2); }
.maturity-3 { background: var(--m3); }
.maturity-4 { background: var(--m4); }

.maturity-slider-row { display: flex; flex-direction: column; gap: 4px; }
.maturity-slider { width: 100%; accent-color: var(--primary); }
.maturity-ticks { display: flex; justify-content: space-between; width: 100%; white-space: nowrap; }
.maturity-tick { opacity: 0.4; transition: opacity 0.15s; }
.maturity-tick.active { opacity: 1; }
.maturity-current-label { margin-top: 2px; }

.autosave-hint { font-size: 0.78rem; color: var(--muted); margin: -6px 0 16px; }

.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 14px 0; justify-content: space-between; }

.flash-stack { margin-bottom: 18px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 0.9rem; }
.flash-success { background: #dcfce7; color: #166534; }

.disclaimer { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 0.82rem; padding: 12px 16px; border-radius: 8px; margin: 14px 0 20px; }

.report-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.report-table th, .report-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.report-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }
.report-table a { color: inherit; text-decoration: none; }
.report-table a:hover { text-decoration: underline; }

/* display:block statt flex-column: mit vielen Einträgen (z.B. 30+ Gaps) bricht
   die Druckausgabe (Chromium/WebKit) bei Flex-Containern über mehrere Seiten
   sonst leer ab (bekanntes Pagination-Problem von display:flex im Druck). */
.finding-list { display: block; }
.finding-item { border-radius: 8px; padding: 12px 16px; border-left: 4px solid; margin-bottom: 10px; }
.finding-gap { background: #fef2f2; border-color: var(--danger); }
.finding-strength { background: #f0fdf4; border-color: var(--success); }
.finding-note { background: #f8fafc; border-color: var(--border); }
.finding-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.finding-head a { color: inherit; text-decoration: none; }
.finding-head a:hover { text-decoration: underline; }
.finding-notes { margin: 6px 0 0; font-style: italic; color: #374151; font-size: 0.88rem; }

.measure-plan-list { margin: 0; padding-left: 18px; }
.measure-plan-list a { color: inherit; text-decoration: none; }
.measure-plan-list a:hover { text-decoration: underline; }

.compare-table th, .compare-table td { text-align: center; }
.compare-table th:first-child, .compare-table td:first-child { text-align: left; }
.overall-row { background: #f8fafc; }

.flash-error { background: #fef2f2; color: #991b1b; }

/* Branding */
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand-logo { height: 42px; width: auto; background: white; padding: 7px 12px; border-radius: 8px; display: block; }
.brand-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.25); }
.brand-product { color: white; font-weight: 700; font-size: 1.02rem; }
.site-footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 20px 24px 40px; }

/* Organisation / Logo */
.org-inline { display: flex; align-items: center; gap: 12px; }
.org-logo-sm { width: 36px; height: 36px; object-fit: contain; border-radius: 4px; }
.org-logo-md { width: 68px; height: 68px; object-fit: contain; border-radius: 8px; }
.org-logo-placeholder {
    width: 68px; height: 68px; border-radius: 8px; background: var(--primary);
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.6rem; flex-shrink: 0;
}
.org-logo-placeholder.small { width: 32px; height: 32px; font-size: 1rem; }
.org-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.org-card-head h3 { margin: 0; }
.current-logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: 0.85rem; }

.role-hint { font-size: 0.78rem; color: var(--primary-dark); background: #eef2ff; display: inline-block; padding: 2px 8px; border-radius: 10px; margin-top: 4px; }

.role-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.role-filter-label { font-size: 0.85rem; color: var(--muted); }
.role-filter-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.role-tag {
    font-size: 0.8rem; padding: 4px 12px; border-radius: 14px; border: 1px solid var(--border);
    background: white; color: var(--text); cursor: pointer; transition: all 0.15s ease;
}
.role-tag:hover { border-color: var(--primary); }
.role-tag.active { background: var(--primary); border-color: var(--primary); color: white; }
.role-filter-reset { font-size: 0.78rem; color: var(--muted); background: none; border: none; text-decoration: underline; cursor: pointer; padding: 0; }
.nist-tag { font-size: 0.7rem; font-weight: 500; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; padding: 2px 8px; margin-left: 10px; vertical-align: middle; white-space: nowrap; }
h1 .nist-tag { font-size: 0.6rem; }

/* Maßnahmen-Block im Interview */
.measures-block { margin-top: 16px; }
.attached-measures-list, .suggestions-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.measure-row {
    display: block; width: 100%; text-align: left; background: #f8fafc; border: 1px solid var(--border);
    border-radius: 8px; padding: 16px 18px; font-family: inherit; color: inherit; box-shadow: var(--shadow-sm);
}
.measure-card { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.measure-row-head, .measure-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.measure-title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.measure-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.measure-description { font-size: 0.9rem; color: #374151; margin: 6px 0 0; line-height: 1.5; }
.icon-btn { background: none; border: none; color: var(--danger); font-size: 0.8rem; cursor: pointer; padding: 2px 6px; flex-shrink: 0; }
.measure-quickedit { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.usage-badge { display: inline-block; font-size: 0.72rem; color: var(--primary-dark); background: #eef2ff; padding: 3px 9px; border-radius: 10px; font-weight: 600; }
.badge-custom { display: inline-block; font-size: 0.72rem; color: #92400e; background: #fef3c7; padding: 3px 9px; border-radius: 10px; font-weight: 600; }
.measure-example {
    font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; padding: 6px 0 0;
}
.measure-example-label { font-weight: 600; color: var(--muted); margin-right: 4px; }
.measure-source { font-size: 0.78rem; color: var(--muted); margin: 6px 0 0; }
.measure-source a { color: var(--primary-dark); text-decoration: underline; }
.evidence-details { font-size: 0.85rem; }
.evidence-details summary { cursor: pointer; color: var(--primary-dark); }
.evidence-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; max-width: 420px; }
.evidence-form select, .evidence-form input, .evidence-form textarea { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); font-family: inherit; font-size: 0.85rem; }
.evidence-quicklink { font-size: 0.85rem; word-break: break-all; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.suggestion-row {
    display: block; width: 100%; text-align: left; cursor: pointer;
    background: white; border: 1px dashed var(--primary); border-radius: 8px; padding: 16px 18px; font-family: inherit;
}
.suggestion-row:hover { background: #eef2ff; }
.suggestion-row .measure-title { color: var(--primary-dark); }

.status-buttons { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.status-buttons-main { display: flex; flex: 1; gap: 6px; min-width: 280px; }
.status-btn {
    flex: 1; text-align: center; padding: 8px 8px; border-radius: 8px; border: 1px solid var(--border);
    background: white; font-family: inherit; font-size: 0.74rem; font-weight: 500; color: var(--muted);
    cursor: pointer; white-space: normal; line-height: 1.25; transition: all 0.15s ease;
}
.status-btn:hover { border-color: var(--primary); color: var(--text); }
.status-btn-na { flex: none; width: auto; padding: 8px 14px; }
.status-btn-1.active { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.status-btn-2.active { background: #fff7ed; border-color: #f59e0b; color: #9a3412; }
.status-btn-3.active { background: #f0fdf4; border-color: #86efac; color: #166534; }
.status-btn-4.active { background: #16a34a; border-color: #16a34a; color: white; }
.status-btn-0.active { background: #f3f4f6; border-color: #9ca3af; color: #4b5563; }

.status-badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: 10px; }
.status-badge.status-0 { background: #f3f4f6; color: #4b5563; }
.status-badge.status-1 { background: #fef2f2; color: #991b1b; }
.status-badge.status-2 { background: #fff7ed; color: #9a3412; }
.status-badge.status-3 { background: #f0fdf4; color: #166534; }
.status-badge.status-4 { background: #16a34a; color: white; }

.evidence-trigger {
    border: 1px solid var(--border); background: #f0fdf4; color: #166534; border-radius: 50%;
    width: 22px; height: 22px; font-size: 0.75rem; cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center; margin-left: 6px; padding: 0; vertical-align: middle;
}
.evidence-trigger:hover { background: #dcfce7; }
.evidence-print-only { display: none; font-size: 0.78rem; color: var(--muted); margin-left: 6px; }
@media print {
    .evidence-trigger { display: none; }
    .evidence-print-only { display: inline; }
}

.evidence-modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.evidence-modal-overlay[hidden] { display: none; }
.evidence-modal { background: white; border-radius: 10px; padding: 24px; max-width: 420px; width: 90%; box-shadow: var(--shadow-md); position: relative; }
.evidence-modal h3 { margin: 0 0 12px; font-size: 1rem; }
.evidence-modal-close { position: absolute; top: 8px; right: 10px; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); line-height: 1; }
.evidence-modal-body a { color: var(--primary-dark); text-decoration: underline; word-break: break-all; }

.measure-search { position: relative; margin-top: 8px; }
.measure-search-input { width: 100%; padding: 9px 12px; border-radius: 6px; border: 1px solid var(--border); font-size: 0.88rem; }
.measure-search-results {
    display: none; position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
    background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    max-height: 260px; overflow-y: auto;
}
.measure-search-results.visible { display: block; }
.measure-search-result { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.measure-search-result:last-child { border-bottom: none; }
.measure-search-result:hover { background: #f4f6fb; }
.measure-search-create { color: var(--primary-dark); font-style: italic; }

.search-form { display: flex; gap: 8px; margin-bottom: 20px; max-width: 460px; }
.search-form input { flex: 1; padding: 9px 12px; border-radius: 6px; border: 1px solid var(--border); }

.catalog-list { display: flex; flex-direction: column; gap: 12px; }
.measure-full-edit { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; max-width: 420px; }
.measure-full-edit select, .measure-full-edit input, .measure-full-edit textarea { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); font-family: inherit; font-size: 0.85rem; }
.measure-full-edit input[type="range"] { padding: 0; border: none; }

.linked-controls { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.linked-controls-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.linked-control-chip {
    font-size: 0.78rem; color: var(--primary-dark); background: #eef2ff; border: 1px solid #c7d7fe;
    padding: 4px 10px; border-radius: 12px; text-decoration: none;
}
.linked-control-chip:hover { background: #dbeafe; }
