:root {
    --bg-main: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-card: #f8fafc;
    --bg-input: #ffffff;
    --bg-hover: #f1f5f9;

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;

    --border: #e2e8f0;
    --border-light: #cbd5e1;

    --accent-primary: #0284c7;
    --accent-primary-hover: #0369a1;
    --accent-primary-glow: rgba(2, 132, 199, 0.12);
    --accent-amber: #d97706;
    --accent-amber-glow: rgba(217, 119, 6, 0.12);
    
    --status-gering-bg: #f0fdf4;
    --status-gering-text: #15803d;
    --status-gering-border: #bbf7d0;

    --status-schwer-bg: #fef2f2;
    --status-schwer-text: #b91c1c;
    --status-schwer-border: #fecaca;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);

    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

/* UN SCHÄRFE FÜR DEN APP-HINTERGRUND BEI AKTIVEM MODAL */
body.blur-active .app-container {
    filter: blur(8px);
    pointer-events: none;
    transition: filter 0.2s ease;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 0.75rem;
    gap: 0.6rem;
    transition: filter 0.2s ease;
}

/* HEADER & BRANDING */
header {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.65rem 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo-wrapper {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(2, 132, 199, 0.06);
    border-radius: 10px;
    border: 1px solid rgba(2, 132, 199, 0.15);
}

.pill-logo-svg {
    width: 32px;
    height: 32px;
}

.brand-text {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

.brand-text .highlight {
    color: var(--accent-primary);
    font-weight: 800;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-badge {
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border: 1px solid #cbd5e1;
    color: var(--text-muted);
    padding: 0 14px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    height: 30px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: all 0.2s ease;
}

.header-badge.highlight {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.1), rgba(2, 132, 199, 0.03));
    border-color: rgba(2, 132, 199, 0.35);
    color: var(--accent-primary);
    font-weight: 700;
}

/* WORKSPACE GRID */
main {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 0.6rem;
    flex: 1;
    min-height: 0;
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(248, 250, 252, 0.6);
    flex-shrink: 0;
    height: 40px;
}

.panel-title {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.panel-title i { color: var(--accent-primary); }

.live-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
    color: var(--text-dim);
    font-family: var(--font-sans);
    font-weight: 600;
}

.live-dot {
    width: 6px;
    height: 6px;
    background-color: #22c55e;
    border-radius: 50%;
    position: relative;
    display: inline-block;
}

.live-dot::after {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 50%;
    background-color: #22c55e;
    opacity: 0.6;
    animation: pulse 1.8s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 0.8; }
    100% { transform: scale(2.4); opacity: 0; }
}

/* LINKES PANEL */
.panel-analysis {
    width: 450px;
    flex-shrink: 0;
}

.panel-analysis .panel-content {
    padding: 0.65rem 0.85rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    flex: 1;
}

.panel-db .panel-content {
    padding: 0.85rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* FORM CONTROLS */
.form-group { display: flex; flex-direction: column; gap: 0.25rem; }
.form-label {
    font-size: 0.63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.input-box { position: relative; }
.input-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 0.75rem;
}

input[type="text"], input[type="number"], select {
    width: 100%;
    height: 32px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0 8px 0 30px;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-sans);
    outline: none;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
}

select { padding-left: 10px; cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
input:focus, select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

.preset-container { display: flex; gap: 3px; margin-top: 1px; }
.preset-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    height: 20px;
    line-height: 18px;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 1;
    text-align: center;
}
.preset-btn:hover { background: var(--accent-primary-glow); color: var(--accent-primary); border-color: rgba(2, 132, 199, 0.3); }

/* CARDS & STECKBRIEF */
.steckbrief-card, .result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex-shrink: 0;
}

.steckbrief-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.35rem;
}

.steckbrief-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-anlage {
    font-size: 0.6rem;
    font-family: var(--font-sans);
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-amber-glow);
    color: var(--accent-amber);
    border: 1px solid rgba(217, 119, 6, 0.25);
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.steckbrief-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.6rem;
}

.steckbrief-item { display: flex; flex-direction: column; gap: 1px; }
.steckbrief-key { font-size: 0.58rem; color: var(--text-dim); text-transform: uppercase; font-weight: 700; letter-spacing: 0.3px; }
.steckbrief-val { font-size: 0.74rem; color: var(--text-main); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* RESULT CARD */
.status-badge {
    font-size: 0.68rem;
    font-weight: 800;
    height: 28px;
    border-radius: 5px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}

.status-gering { background: var(--status-gering-bg); color: var(--status-gering-text); border: 1px solid var(--status-gering-border); }
.status-schwer { background: var(--status-schwer-bg); color: var(--status-schwer-text); border: 1px solid var(--status-schwer-border); }

.threshold-meter {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.meter-bar-bg {
    height: 5px;
    width: 100%;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.meter-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
}

.metric-group {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
}

.metric-group:last-child { border-bottom: none; padding-bottom: 0; }
.metric-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.metric-value { font-family: var(--font-mono); font-size: 0.88rem; font-weight: 700; color: var(--text-main); }

.law-reference { 
    font-size: 0.65rem; 
    color: var(--accent-amber); 
    font-family: var(--font-sans); 
    font-weight: 700; 
    display: flex; 
    align-items: center; 
    gap: 5px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.calc-note-box {
    font-size: 0.65rem; 
    color: var(--text-muted); 
    line-height: 1.35; 
    border-top: 1px solid var(--border); 
    padding-top: 0.3rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* DATABASE LIST & FILTERS */
.db-controls { display: flex; gap: 0.5rem; align-items: center; }
.cat-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.cat-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s ease;
}
.cat-btn.active, .cat-btn:hover { background: var(--accent-primary-glow); border-color: var(--accent-primary); color: var(--accent-primary); }

.db-list { display: flex; flex-direction: column; gap: 0.45rem; }
.db-row {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    display: grid;
    grid-template-columns: 1.3fr 1fr 1.1fr 1fr 70px;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
}
.db-row:hover { border-color: var(--accent-primary); background: rgba(2, 132, 199, 0.02); transform: translateY(-1px); }

.db-cell-name { font-weight: 700; font-size: 0.82rem; color: var(--text-main); display: flex; flex-direction: column; }
.db-cell-sub { font-size: 0.66rem; color: var(--text-muted); font-weight: 500; }
.db-cell-val { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent-primary); font-weight: 700; }
.db-cell-ref { font-family: var(--font-sans); font-size: 0.65rem; color: var(--text-muted); font-weight: 500; }

.db-cell-cat {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent-primary);
    background: var(--accent-primary-glow);
    padding: 3px 8px;
    border-radius: 5px;
    border: 1px solid rgba(2, 132, 199, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
}

.action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--font-sans);
    text-align: center;
    transition: all 0.15s ease;
}
.db-row:hover .action-btn { background: var(--accent-primary); color: #ffffff; border-color: var(--accent-primary); }

/* FOOTER */
footer {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
    box-shadow: var(--shadow-sm);
}

.footer-info { display: flex; align-items: center; gap: 6px; }
.footer-links { display: flex; gap: 14px; }
.footer-links a {
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s ease;
    cursor: pointer;
}
.footer-links a:hover { color: var(--accent-primary); }

/* MODALS */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-window {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 540px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    user-select: text;
    box-shadow: var(--shadow-md);
    overflow: hidden; /* <-- DIESE ZEILE HINZUFÜGEN */
}

.modal-header {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
}

.modal-title { font-size: 0.85rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-main); }
.modal-close {
    background: transparent; border: none;
    color: var(--text-muted); font-size: 1.2rem;
    cursor: pointer; transition: color 0.15s ease;
}
.modal-close:hover { color: var(--text-main); }

.modal-body {
    padding: 1.1rem;
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.modal-body h4 { color: var(--text-main); font-size: 0.85rem; font-weight: 700; margin-top: 0.3rem; }

/* MODAL FOOTER BUTTONS (AKZEPTIEREN / ABBRECHEN) */
.modal-footer {
    padding: 0.75rem 1.1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg-card);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.btn-accept, .btn-decline {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-accept {
    background: var(--accent-primary);
    color: #ffffff;
    border: 1px solid var(--accent-primary);
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.3);
}

.btn-accept:hover {
    background: var(--accent-primary-hover);
    border-color: var(--accent-primary-hover);
}

.btn-decline {
    background: var(--bg-panel);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.btn-decline:hover {
    background: #f8fafc;
    color: var(--text-main);
    border-color: var(--border-light);
}

@media (max-width: 950px) {
    main { grid-template-columns: 1fr; }
    .panel-analysis { width: 100%; }
    .header-meta { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
    .db-row { grid-template-columns: 1fr 1fr 1fr; }
    .db-cell-cat, .action-btn { display: none; }
}

.pdf-export-btn {
    width: 100%;
    height: 36px;
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
    margin-top: 0.25rem;
}

.pdf-export-btn:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(2, 132, 199, 0.35);
}

.pdf-export-btn:active {
    transform: translateY(0);
}