:root {
    --orange:      #ED6404;
    --orange-dark: #c96419;
    --orange-light:#fdf3ea;
    --dark:        #1a1a1a;
    --mid:         #555;
    --muted:       #888;
    --border:      #ddd;
    --bg:          #f5f5f5;
    --white:       #fff;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--dark);
}

.topbar {
    background: var(--dark);
    color: #fff;
    padding: 0 24px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
}
.topbar-brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
    pointer-events: none;
    white-space: nowrap;
}
.topbar-brand span { color: var(--orange); }
.topbar a { color: #aaa; text-decoration: none; font-size: 12px; }
.topbar a:hover { color: #fff; }
.topbar-right { display: inline-flex; align-items: center; gap: 14px; }
.topbar-budget {
    font-size: 12px;
    color: #ccc;
    padding: 2px 8px;
    border: 1px solid #555;
    border-radius: 10px;
    white-space: nowrap;
}
.topbar-budget.knapp { color: #fff; background: var(--orange); border-color: var(--orange); }

/* Hinweis, wenn das Monatsbudget erschöpft ist */
.budget-warnung {
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--orange);
    background: var(--orange-light);
    border-radius: 6px;
    color: var(--orange-dark);
    font-size: 14px;
    line-height: 1.5;
}

/* Modulübergreifende Navigationsleiste unter der Topbar */
.modulnav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 0 16px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 13px;
}
.modulnav a, .modulnav .deaktiviert {
    display: inline-block;
    padding: 9px 11px;
    color: #555;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.modulnav a:hover { color: var(--orange); }
.modulnav a.aktiv {
    color: var(--orange);
    border-bottom-color: var(--orange);
    font-weight: 600;
}
.modulnav .deaktiviert { color: #bbb; cursor: not-allowed; }
.modulnav-spacer { flex: 1 1 auto; }

/* Breadcrumb-Pfad für mehrstufige Module */
.breadcrumb {
    font-size: 13px;
    color: var(--muted);
    margin: 0 0 1.25rem;
}
.breadcrumb a { color: var(--orange); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--border); margin: 0 6px; }

main { max-width: 1400px; margin: 2rem auto; padding: 0 1.5rem; }

.card {
    background: var(--white);
    border-radius: 6px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.dashboard-group-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 2rem 0 0.75rem;
}
.dashboard-group-title:first-of-type { margin-top: 0.5rem; }
.dashboard-grid + .dashboard-group-title { margin-top: 2rem; }

.module-tile {
    background: var(--white);
    border-radius: 6px;
    padding: 1.75rem;
    border: 1.5px solid var(--border);
    text-decoration: none;
    color: inherit;
    display: block;
    transition: border-color 0.15s;
}
.module-tile:hover { border-color: var(--orange); }
.module-tile h2 { margin: 0 0 0.4rem; font-size: 1rem; font-weight: 600; }
.module-tile p { margin: 0; color: var(--muted); font-size: 13px; }
.module-tile.disabled {
    pointer-events: none;
    opacity: 0.4;
    cursor: default;
}
.module-tile.admin-link {
    border-style: dashed;
    border-color: var(--orange);
    background: var(--orange-light);
}
.module-tile.admin-link:hover { border-color: var(--orange-dark); }

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 6px;
    padding: 1.75rem;
    text-align: center;
    margin-bottom: 1rem;
    background: var(--bg);
}
.upload-area:hover { border-color: var(--orange); }

input[type="file"] { font-size: 13px; }

button, .btn {
    padding: 7px 18px;
    background: var(--orange);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.15s;
}
button:hover, .btn:hover { background: var(--orange-dark); }
button:disabled, .btn:disabled { opacity: 0.4; cursor: not-allowed; background: var(--orange); }

.btn-secondary {
    background: var(--white);
    color: var(--mid);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--orange); color: var(--orange); background: var(--white); }

input[type="text"], input[type="password"], select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: var(--white);
    color: var(--dark);
}
input[type="text"]:focus,
input[type="password"]:focus,
select:focus { outline: 2px solid var(--orange); border-color: transparent; }

label { font-size: 13px; font-weight: 600; color: var(--mid); display: block; margin-bottom: 4px; }

.login-form { max-width: 360px; margin: 4rem auto; }
.login-form input { margin-bottom: 1rem; }
.login-form button { width: 100%; margin-top: 0.5rem; }

.htmx-indicator { display: none; color: var(--muted); font-style: italic; margin-left: 0.75rem; font-size: 13px; align-items: center; gap: 6px; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-flex; }

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Upload-Layout */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.upload-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 6px;
    padding: 2rem 1rem;
    text-align: center;
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
}
.upload-drop-zone:hover,
.upload-drop-zone.drag-over { border-color: var(--orange); background: var(--orange-light); }
.upload-drop-zone input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-drop-zone-icon { font-size: 24px; margin-bottom: 0.5rem; }
.upload-drop-zone-text { font-size: 13px; color: var(--mid); }
.upload-drop-zone-hint { font-size: 11px; color: var(--muted); margin-top: 0.25rem; }

.upload-selected {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    background: var(--white);
    min-height: 80px;
}
.upload-selected-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; }
.upload-selected-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
}
.upload-selected-file button {
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 400;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    line-height: 1.4;
}
.upload-selected-file button:hover { color: #c0392b; border-color: #c0392b; background: transparent; }
.upload-empty { font-size: 13px; color: var(--muted); font-style: italic; }

.result { margin-top: 1rem; }
.result pre {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 13px;
    white-space: pre-wrap;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); font-weight: 600; color: var(--mid); }
td { padding: 8px 10px; border-bottom: 1px solid #eee; vertical-align: top; }

.error { color: #c0392b; font-size: 13px; }
.success { color: #27ae60; font-size: 13px; }
.hinweis { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* Auffällige Warnung (z. B. Word-Schaubilder nicht lektoriert) */
.warnbox {
    background: var(--orange-light);
    border-left: 4px solid var(--orange);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    font-size: 13px;
    line-height: 1.55;
    color: var(--dark);
    margin-bottom: 1.25rem;
}
.warnbox strong { color: var(--orange); }
.warnbox code {
    background: var(--white);
    padding: 0 4px;
    border-radius: 3px;
    font-size: 12px;
}

mark { background: #fff176; padding: 0 2px; border-radius: 2px; font-style: normal; }

/* Stift-Nummerierung */
.fn-num {
    margin-right: 4px;
}
.fn-edit-btn {
    background: transparent;
    color: var(--muted);
    border: none;
    padding: 0 2px;
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.15s;
    vertical-align: middle;
}
tr:hover .fn-edit-btn { opacity: 1; }
.fn-edit-input {
    font-family: inherit;
    font-size: 13px;
    padding: 1px 4px;
    border: 1px solid var(--orange);
    border-radius: 3px;
    width: 3.5em;
    outline: none;
}
.fn-edit-input.invalid { border-color: #c0392b; }
.fn-edit-confirm {
    background: transparent;
    color: var(--orange);
    border: 1px solid var(--orange);
    padding: 1px 6px;
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    border-radius: 3px;
    margin-left: 2px;
}
.fn-edit-confirm:hover { background: var(--orange-light); }

h1 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.5rem; }
h2 { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; }
p { color: var(--mid); font-size: 13px; margin-bottom: 1rem; }

/* Ergebnistabelle: feste Spaltenbreiten damit Tabelle nicht über den Rand läuft */
#ergebnis table,
#erledigt-section table {
    table-layout: fixed;
}
#ergebnis table th,
#ergebnis table td,
#erledigt-section table th,
#erledigt-section table td {
    overflow-wrap: break-word;
    word-break: break-word;
}
/* „Stelle"-Spalte breiter, damit „Überschrift" ohne Umbruch passt */
#ergebnis table th:nth-child(1), #ergebnis table td:nth-child(1),
#erledigt-section table th:nth-child(1), #erledigt-section table td:nth-child(1) { width: 9%; }
#ergebnis table th:nth-child(2), #ergebnis table td:nth-child(2),
#erledigt-section table th:nth-child(2), #erledigt-section table td:nth-child(2) { width: 15%; }
#ergebnis table th:nth-child(5), #ergebnis table td:nth-child(5),
#erledigt-section table th:nth-child(5), #erledigt-section table td:nth-child(5) { width: 40px; }
/* Aktionsspalte (docx-Modus): gleiche Spezifität wie nth-child(5), aber
   später deklariert → gewinnt. Breit genug für ✎ ✓ ✗ bzw. „↑ zurück",
   rechtsbündig, oben ausgerichtet, kein Überstand über den Tabellenrand. */
#ergebnis table th.col-act, #ergebnis table td.col-act {
    width: 7.5rem;
    text-align: right;
    vertical-align: top;
    white-space: nowrap;
    padding-left: 4px;
}

/* Checkbox-Spalte */
.col-check { width: 40px; text-align: center; padding: 6px !important; }
input[type="checkbox"].fn-done-cb,
input[type="checkbox"].lekt-done-cb {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--orange);
}

/* Erledigte-Sektion */
#erledigt-section { opacity: 0.7; }
#erledigt-section td { color: var(--muted); }
#erledigt-section mark { opacity: 0.6; }

/* Drucken-Button — deutlicher Abstand zum „Verarbeiteten Text"-Block darüber */
.btn-print { display: block; margin-top: 2rem; }

/* Aufzählungslisten im Ergebnis-Bereich (Konvertierungs-Artefakte):
   eingerückt, nicht bündig mit der Überschrift */
.card ul, .card ol { padding-left: 1.6rem; margin: 0.6rem 0 1rem; }
.card li { margin-bottom: 0.35rem; }

/* Abstand zwischen den Ergebnis-Abschnitten: Luft vor jeder
   Abschnitts-Überschrift, damit Tabellen nicht an die nächste
   Überschrift stoßen. Die erste Überschrift („Ergebnis") bleibt bündig. */
#ergebnis .card > h2 { margin-top: 2.2rem; margin-bottom: 0.6rem; }
#ergebnis .card > h2:first-of-type { margin-top: 0; }

/* Druck / PDF-Export */
@media print {
    .topbar, #upload-card, .btn-print,
    .fn-edit-btn, .fn-edit-input, .fn-edit-confirm,
    .col-check { display: none !important; }

    body { background: white; }
    main { max-width: none; margin: 0; padding: 0 1rem; }
    .card { border: 1px solid #ccc; box-shadow: none; }
    #erledigt-section { opacity: 1; }
    #erledigt-section td { color: var(--dark); }
    mark {
        background: #ffff99;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
