* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: #f0f2f5; color: #222; }

/* Login */
#login { display: flex; align-items: center; justify-content: center; height: 100vh; }
#login form { background: white; padding: 2rem; border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,0.1); width: 320px; }
#login h2 { margin-bottom: 1.5rem; font-size: 1.1rem; font-weight: 500; }
#login input { width: 100%; padding: 0.6rem; border: 1px solid #ddd; border-radius: 6px; margin-bottom: 1rem; font-size: 1rem; }
#login button { width: 100%; padding: 0.7rem; background: #1d4ed8; color: white; border: none; border-radius: 6px; font-size: 1rem; cursor: pointer; }

/* Layout */
.page { display: none; max-width: 1000px; margin: 0 auto; padding: 1.5rem; }
.page.wide { max-width: 1100px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.topbar h1 { font-size: 1rem; font-weight: 500; color: #555; }
.topbar-links { display: flex; gap: 0.8rem; }
.topbar-links a, .topbar-links button { font-size: 0.85rem; color: #1d4ed8; text-decoration: none; background: none; border: none; cursor: pointer; padding: 0; }

/* Cards */
.card { background: white; border-radius: 10px; padding: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.07); margin-bottom: 1rem; }

/* Progress */
#progress-wrap { background: #e5e7eb; border-radius: 4px; height: 6px; margin-bottom: 0.4rem; }
#progress-bar { background: #1d4ed8; height: 6px; border-radius: 4px; transition: width 0.3s; }
#progress-text { font-size: 0.8rem; color: #888; margin-bottom: 1rem; }

/* Jump select */
#jump-select { width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 6px; font-size: 0.88rem; margin-bottom: 1rem; background: white; }

/* Section */
.chapter-label { font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.section-title { font-size: 1.2rem; font-weight: 500; margin-bottom: 1rem; }
.section-text { line-height: 1.75; color: #444; font-size: 0.95rem; border-left: 3px solid #e5e7eb; padding-left: 1rem; margin-bottom: 1.5rem; }

/* Codes */
.group-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #999; margin-bottom: 0.5rem; margin-top: 1.2rem; }
.codes-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.code-btn { padding: 0.35rem 0.85rem; border: 1.5px solid #d1d5db; border-radius: 20px; background: white; cursor: pointer; font-size: 0.85rem; color: #555; transition: all 0.15s; user-select: none; }
.code-btn:hover { border-color: #9ca3af; color: #222; }
.code-btn.active { color: white; border-color: transparent; }
.code-btn[data-code="forderung"].active    { background: #2563eb; }
.code-btn[data-code="behauptung"].active   { background: #0891b2; }
.code-btn[data-code="unbelegte_bewertung"].active { background: #7c3aed; }
.code-btn[data-code="versprechen"].active  { background: #0369a1; }
.code-btn[data-code="feindbild"].active    { background: #ea580c; }
.code-btn[data-code="falschaussage"].active { background: #dc2626; }
.code-btn[data-code="falschrahmung"].active { background: #9333ea; }
.code-btn[data-code="demokratiefeindlich"].active { background: #991b1b; }
.code-btn[data-code="verschwoerung"].active { background: #4338ca; }

hr { border: none; border-top: 1px solid #f0f2f5; margin: 1.2rem 0; }

/* Fiskal */
.toggle-row { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; user-select: none; }
.toggle-row input { width: 16px; height: 16px; cursor: pointer; accent-color: #1d4ed8; }
.toggle-row span { font-size: 0.9rem; color: #444; }
#fiskal-block { display: none; background: #f8fafc; border-radius: 8px; padding: 1rem 1.2rem; margin-top: 0.8rem; border: 1px solid #e5e7eb; }
.fiskal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 0.8rem; }
.fiskal-field label { font-size: 0.78rem; color: #666; display: block; margin-bottom: 0.3rem; }
.direction-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.dir-btn { padding: 0.35rem 0.8rem; border: 1.5px solid #d1d5db; border-radius: 6px; background: white; cursor: pointer; font-size: 0.88rem; transition: all 0.15s; }
.dir-btn:hover { border-color: #9ca3af; }
.dir-btn[data-dir="+"].active  { background: #15803d; color: white; border-color: #15803d; }
.dir-btn[data-dir="-"].active  { background: #dc2626; color: white; border-color: #dc2626; }
.dir-btn[data-dir="+-"].active { background: #92400e; color: white; border-color: #92400e; }
.finanziert-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.8rem; }
.finanziert-row input { accent-color: #15803d; }
.finanziert-row span { font-size: 0.88rem; color: #444; }

/* Fields */
.field-label { font-size: 0.78rem; color: #666; display: block; margin-bottom: 0.3rem; margin-top: 1rem; }
textarea { width: 100%; padding: 0.5rem 0.7rem; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 0.9rem; font-family: inherit; background: white; resize: vertical; min-height: 80px; }
textarea:focus { outline: none; border-color: #1d4ed8; }
input[type=text] { width: 100%; padding: 0.5rem 0.7rem; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 0.9rem; font-family: inherit; }
input[type=text]:focus { outline: none; border-color: #1d4ed8; }

/* Sources */
.source-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.4rem 0; min-height: 20px; }
.source-tag { display: inline-flex; align-items: center; gap: 0.3rem; background: #eff6ff; color: #1d4ed8; border-radius: 12px; padding: 0.2rem 0.7rem; font-size: 0.8rem; }
.source-tag button { background: none; border: none; cursor: pointer; color: #93c5fd; font-size: 1rem; line-height: 1; padding: 0; }
.source-row { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.source-row select { flex: 1; padding: 0.5rem; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 0.85rem; }

/* Buttons */
.btn-sm { padding: 0.4rem 0.8rem; border: 1px solid #1d4ed8; color: #1d4ed8; background: white; border-radius: 6px; cursor: pointer; font-size: 0.83rem; white-space: nowrap; }
.btn-sm:hover { background: #1d4ed8; color: white; }
.btn-sm.red { border-color: #dc2626; color: #dc2626; }
.btn-sm.red:hover { background: #dc2626; color: white; }
.btn-sm.green { border-color: #15803d; color: #15803d; }
.btn-sm.green:hover { background: #15803d; color: white; }

/* Nav */
.nav-row { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #f0f2f5; }
.nav-btn { padding: 0.55rem 1.4rem; border-radius: 6px; border: none; cursor: pointer; font-size: 0.92rem; }
#btn-prev { background: #e5e7eb; color: #444; }
#btn-prev:disabled { opacity: 0.4; cursor: default; }
#btn-next { background: #1d4ed8; color: white; }
#btn-next:disabled { opacity: 0.4; cursor: default; }
#btn-save { background: #15803d; color: white; padding: 0.55rem 1.4rem; border-radius: 6px; border: none; cursor: pointer; font-size: 0.92rem; }
.save-ok { font-size: 0.8rem; color: #15803d; opacity: 0; transition: opacity 0.3s; }
.save-ok.show { opacity: 1; }

/* Modal */
#source-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 100; align-items: center; justify-content: center; }
#source-modal.open { display: flex; }
.modal-box { background: white; border-radius: 10px; padding: 1.5rem; width: 480px; max-width: 95vw; }
.modal-box h3 { font-size: 1rem; font-weight: 500; margin-bottom: 1.2rem; }
.modal-field { margin-bottom: 0.7rem; }
.modal-field label { font-size: 0.78rem; color: #666; display: block; margin-bottom: 0.25rem; }
.modal-field input, .modal-field select { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 0.88rem; }
.modal-row { display: flex; gap: 0.6rem; }
.modal-row .modal-field { flex: 1; }
.modal-lookup { display: flex; gap: 0.4rem; }
.modal-lookup input { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.2rem; }
.btn-primary { padding: 0.5rem 1.2rem; background: #1d4ed8; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 0.88rem; }
.btn-cancel { padding: 0.5rem 1.2rem; background: #e5e7eb; color: #444; border: none; border-radius: 6px; cursor: pointer; font-size: 0.88rem; }

/* Overview */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.8rem; margin-bottom: 1.5rem; }
.stat-card { background: white; border-radius: 8px; padding: 0.9rem 1rem; box-shadow: 0 1px 4px rgba(0,0,0,0.07); }
.stat-label { font-size: 0.72rem; color: #888; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.stat-value { font-size: 1.6rem; font-weight: 500; color: #1d4ed8; }
.stat-value.orange { color: #ea580c; }
.stat-value.red { color: #dc2626; }
.stat-value.green { color: #15803d; }
.filter-bar { background: white; border-radius: 10px; padding: 1rem 1.2rem; box-shadow: 0 1px 4px rgba(0,0,0,0.07); margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.filter-bar select { padding: 0.4rem 0.6rem; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 0.85rem; }
.filter-bar input[type=text] { padding: 0.4rem 0.7rem; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 0.85rem; width: 200px; }
.table-wrap { background: white; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.07); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { padding: 0.7rem 0.8rem; text-align: left; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: #888; border-bottom: 1px solid #f0f2f5; white-space: nowrap; cursor: pointer; user-select: none; }
th:hover { color: #1d4ed8; }
td { padding: 0.6rem 0.8rem; border-bottom: 1px solid #f9fafb; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.id-cell { font-family: monospace; font-size: 0.78rem; color: #888; white-space: nowrap; }
.title-cell { max-width: 260px; }
.title-cell a { color: #1d4ed8; text-decoration: none; font-weight: 500; }
.title-cell a:hover { text-decoration: underline; }
.title-cell .chapter { font-size: 0.75rem; color: #999; margin-top: 0.1rem; }
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 10px; font-size: 0.75rem; margin: 0.1rem; white-space: nowrap; }
.b-forderung { background: #dbeafe; color: #1e40af; }
.b-behauptung { background: #cffafe; color: #0e7490; }
.b-unbelegte_bewertung { background: #ede9fe; color: #5b21b6; }
.b-versprechen { background: #e0f2fe; color: #0369a1; }
.b-feindbild { background: #ffedd5; color: #9a3412; }
.b-falschaussage { background: #fee2e2; color: #991b1b; }
.b-falschrahmung { background: #f3e8ff; color: #6b21a8; }
.b-demokratiefeindlich { background: #fecaca; color: #7f1d1d; }
.b-verschwoerung { background: #e0e7ff; color: #3730a3; }
.fiskal-badge { background: #dcfce7; color: #14532d; font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 10px; white-space: nowrap; }
.fiskal-badge.minus { background: #fee2e2; color: #7f1d1d; }
.fiskal-badge.both { background: #fef3c7; color: #78350f; }
.notes-cell { max-width: 200px; font-size: 0.8rem; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-cell { white-space: nowrap; display: flex; gap: 0.4rem; }
.uncoded { opacity: 0.5; }

/* Subfields */
#subfields-container { margin-top: 1rem; }
.subfield-group { background: #f8fafc; border-radius: 8px; padding: 0.8rem 1rem; margin-bottom: 0.6rem; border: 1px solid #e5e7eb; }
.subfield-group-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #6b7280; margin-bottom: 0.6rem; }
.subfield-row { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.4rem; }
.subfield-row:last-child { margin-bottom: 0; }
.subfield-label { font-size: 0.82rem; color: #555; min-width: 100px; }
.subfield-select { flex: 1; padding: 0.35rem 0.6rem; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 0.85rem; background: white; }
.subfield-select:focus { outline: none; border-color: #1d4ed8; }

/* Fiskal betrag */
.betrag-wrap { display: flex; align-items: center; gap: 0.5rem; }
.betrag-wrap input { flex: 1; }
.betrag-unit { font-size: 0.82rem; color: #888; white-space: nowrap; }
.code-btn[data-code="falschrahmung"].active { background: #9333ea; }
.code-btn[data-code="scheinargument"].active { background: #b45309; }
.code-btn[data-code="anekdotische_evidenz"].active { background: #0f766e; }
.code-btn[data-code="demokratiefeindlich"].active { background: #991b1b; }
.code-btn[data-code="populismus"].active { background: #1d4ed8; }
.code-btn[data-code="opfernarrativ"].active { background: #7e22ce; }
.code-btn[data-code="begriffsumdeutung"].active { background: #0369a1; }
.code-btn[data-code="widerspruch"].active { background: #475569; }
.code-btn[data-code="expressiv"].active { background: #0891b2; }


/* Sources library */
.source-title-cell { max-width: 350px; }
.source-title { font-weight: 500; font-size: 0.88rem; color: #222; margin-bottom: 0.2rem; }
.source-meta { font-size: 0.78rem; color: #888; }
.source-doi { font-size: 0.75rem; color: #1d4ed8; margin-top: 0.15rem; }
.type-badge { background: #f3f4f6; color: #555; padding: 0.1rem 0.4rem; border-radius: 8px; font-size: 0.72rem; }
.badge-file { padding: 0.2rem 0.6rem; border-radius: 10px; font-size: 0.78rem; cursor: pointer; white-space: nowrap; }
.badge-file.ok { background: #dcfce7; color: #14532d; }
.badge-file.missing { background: #fef3c7; color: #92400e; }
.usage-link { color: #1d4ed8; text-decoration: none; font-size: 0.8rem; font-family: monospace; background: #eff6ff; padding: 0.1rem 0.4rem; border-radius: 4px; margin: 0.1rem; display: inline-block; }
.usage-link:hover { background: #1d4ed8; color: white; }
#pdf-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; flex-direction: column; }
#pdf-modal.open { display: flex; }
#pdf-modal-header { background: #1d4ed8; color: white; padding: 0.8rem 1.2rem; display: flex; justify-content: space-between; align-items: center; }
#pdf-modal-header span { font-size: 0.9rem; font-weight: 500; }
#pdf-modal-header button { background: none; border: none; color: white; font-size: 1.4rem; cursor: pointer; line-height: 1; }
#pdf-iframe { flex: 1; border: none; width: 100%; }

.hl-refs { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.4rem; width: 100%; }
.hl-ref { font-size: 0.75rem; color: #444; padding: 0.2rem 0.5rem; background: #f8fafc; border-radius: 4px; cursor: pointer; font-style: italic; display: flex; align-items: center; gap: 0.4rem; }
.hl-ref:hover { background: #eff6ff; }
.hl-page { background: #e0e7ff; color: #3730a3; padding: 0.05rem 0.35rem; border-radius: 8px; font-size: 0.7rem; font-style: normal; }

.b-expressiv { background: #cffafe; color: #0e7490; }
.b-scheinargument { background: #fef3c7; color: #92400e; }
.b-anekdotische_evidenz { background: #f0fdf4; color: #166534; }
.b-populismus { background: #eff6ff; color: #1d4ed8; }
.b-opfernarrativ { background: #fdf4ff; color: #7e22ce; }
.b-begriffsumdeutung { background: #fff7ed; color: #c2410c; }
.b-widerspruch { background: #f8fafc; color: #475569; }