:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --border: #e2e4e9;
    --text: #22262f;
    --text-muted: #6b7280;
    --primary: #2f5fdb;
    --primary-dark: #2447ab;
    --danger: #d1453b;
    --ok-bg: #e8f7ee;
    --ok-text: #1c7a3e;
    --err-bg: #fdeaea;
    --err-text: #b3271b;
    --radius: 10px;
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: #1b2130;
    color: #fff;
}
.topbar-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.brand {
    color: #fff;
    font-weight: 600;
    padding: 14px 0;
    font-size: 1.05rem;
}
.topbar nav {
    display: flex;
    align-items: center;
    gap: 18px;
}
.topbar nav a {
    color: #cfd6e6;
    font-size: 0.92rem;
}
.topbar nav a:hover { color: #fff; }
.topbar .user {
    color: #8891a5;
    font-size: 0.85rem;
}
.topbar .logout {
    background: rgba(255,255,255,0.1);
    padding: 6px 12px;
    border-radius: 6px;
}

.nav-dropdown {
    position: relative;
}
.nav-dropdown summary {
    list-style: none;
    cursor: pointer;
    color: #cfd6e6;
    font-size: 0.92rem;
    font-weight: 400;
    padding: 6px 10px;
    border-radius: 6px;
    user-select: none;
}
.nav-dropdown summary::after {
    content: " ▾";
    font-weight: 400;
    opacity: 0.7;
}
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-dropdown[open] summary { color: #fff; background: rgba(255,255,255,0.12); }
.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    padding: 6px;
    min-width: 170px;
    z-index: 20;
}
.topbar .nav-dropdown-menu a {
    display: block;
    color: #000;
    font-weight: 400;
    font-size: 0.9rem;
    padding: 8px 10px;
    border-radius: 6px;
}
.topbar .nav-dropdown-menu a:hover { background: var(--bg); text-decoration: none; }

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 28px 20px 60px;
}

h1 { font-size: 1.5rem; margin: 0 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
.subtitle { color: var(--text-muted); margin-bottom: 22px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 7px;
    font-size: 0.92rem;
    cursor: pointer;
    text-align: center;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f0f1f4; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #ad2e26; }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }

table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.94rem;
}
th { color: var(--text-muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.actions { white-space: nowrap; text-align: right; }
.actions a, .actions button { margin-left: 8px; }

label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 5px; }
input[type=text], input[type=password], textarea, input[type=search] {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 16px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 0.92rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.fehler { background: var(--err-bg); color: var(--err-text); }

.checkbox-list { list-style: none; margin: 0; padding: 0; }
.checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.checkbox-item:last-child { border-bottom: none; }
.checkbox-item input[type=checkbox] { margin-top: 4px; width: 17px; height: 17px; flex-shrink: 0; }
.checkbox-item .cb-title { font-weight: 600; margin-bottom: 3px; }
.checkbox-item .cb-subheadline { font-size: 0.86rem; font-weight: 600; color: var(--primary-dark); margin-bottom: 3px; }
.checkbox-item .cb-preview { color: var(--text-muted); font-size: 0.87rem; white-space: pre-line; }
.checkbox-item .cb-edit { margin-left: auto; flex-shrink: 0; font-size: 0.82rem; }
.gruppe-zuweisen-select {
    flex-shrink: 0;
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    background: #fff;
    font-family: inherit;
    color: var(--text-muted);
    max-width: 140px;
}

.bereich-anlegen {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}
.bereich-anlegen .bereich-name-input {
    max-width: 280px;
}

.bereich-kopieren-select {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
    background: #fff;
    font-family: inherit;
    color: var(--text-muted);
    max-width: 150px;
}

.bereich-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 4px 0 4px;
}

.bereich-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 16px 0;
    padding: 4px 14px;
    background: #fbfbfd;
}
.bereich-block summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
}
.bereich-block summary::-webkit-details-marker { display: none; }
.bereich-block summary::before {
    content: "▾";
    color: var(--text-muted);
    transition: transform 0.15s;
}
.bereich-block:not([open]) summary::before { transform: rotate(-90deg); }
.bereich-titel-anzeige {
    cursor: text;
    padding: 3px 6px;
    border-radius: 5px;
}
.bereich-titel-anzeige:hover { background: #eceef2; }
.bereich-name-bearbeiten {
    font-weight: 700;
    font-size: 1rem;
    max-width: 260px;
}
.bereich-anzahl { color: var(--text-muted); font-weight: 400; font-size: 0.85rem; }
.bereich-block .checkbox-list { padding-bottom: 10px; }

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 26px 0 10px;
}

.login-wrap {
    max-width: 380px;
    margin: 90px auto 0;
}
.login-wrap h1 { text-align: center; margin-bottom: 4px; }
.login-wrap .subtitle { text-align: center; }

.badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 7px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
}
.badge-global { background: #e6edfb; color: var(--primary-dark); }
.badge-individuell { background: #fdeecb; color: #8a5a00; }
.badge-kategorie { background: #f0e9fb; color: #6b3fa0; }
.badge-status-entwurf { background: #eef0f4; color: #555b66; }
.badge-status-versendet { background: #fdeecb; color: #8a5a00; }
.badge-status-abgeschlossen { background: var(--ok-bg); color: var(--ok-text); }
.status-auswahl-select {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
    background: #fff;
    font-family: inherit;
    color: var(--text-muted);
}

.cb-meta { color: var(--text-muted); font-size: 0.78rem; margin-top: 4px; font-style: italic; }

.sort-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}
.sort-btn {
    width: 26px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1;
}
.sort-btn:hover:not(:disabled) { background: #f0f1f4; color: var(--text); }
.sort-btn:disabled { opacity: 0.3; cursor: default; }

.toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    align-items: center;
}
.toolbar button {
    font-family: inherit;
    font-size: 0.82rem;
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
}
.toolbar button:hover { background: #f0f1f4; }
.toolbar select {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
    background: #fff;
    font-family: inherit;
    color: var(--text);
}
.farb-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 400;
    margin: 0;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}
.farb-label input[type=color] {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

.feld-hinweis {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: normal;
}
.feld-hinweis-positiv { color: var(--ok-text); }

.wysiwyg-editor {
    min-height: 220px;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 12px 14px;
    background: #fff;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text);
}
.wysiwyg-editor:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.wysiwyg-editor h1 { font-size: 1.55rem; margin: 0.6em 0 0.3em; }
.wysiwyg-editor h2 { font-size: 1.35rem; margin: 0.6em 0 0.3em; }
.wysiwyg-editor h3 { font-size: 1.18rem; margin: 0.5em 0 0.3em; }
.wysiwyg-editor h4 { font-size: 1.06rem; margin: 0.5em 0 0.3em; }
.wysiwyg-editor h5 { font-size: 0.96rem; margin: 0.5em 0 0.3em; font-weight: 700; }
.wysiwyg-editor ul { margin: 0.3em 0; padding-left: 1.4em; }
.wysiwyg-editor img { margin: 8px 0; }

.empty { color: var(--text-muted); font-style: italic; padding: 10px 0; }
.help { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

.barcelone {
    text-align: center;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--ok-text);
    margin: 20px 0 4px;
}

/* Toggle-Switch */
.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background-color: #d7dae0;
    transition: 0.2s;
    border-radius: 22px;
}
.toggle-slider::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    top: 3px;
    background-color: #fff;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.toggle input:checked + .toggle-slider {
    background-color: var(--ok-text);
}
.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.todo-nummer {
    flex: 0 0 auto;
    min-width: 20px;
    text-align: right;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

/* Todo-Liste (Bearbeiten-Seite) */
.todo-liste { list-style: none; margin: 0; padding: 0; }
.todo-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.todo-item:last-child { border-bottom: none; }
.todo-item.todo-erledigt { background: var(--ok-bg); margin: 0 -14px; padding: 10px 14px; border-radius: 6px; }
.todo-item-hauptzeile {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
}
.todo-item .sort-controls { flex: 0 0 auto; }
.todo-item .toggle { flex: 0 0 auto; }
.todo-item .todo-entfernen { flex: 0 0 auto; }
.todo-item .todo-details-toggle { flex: 0 0 auto; }
.todo-text-input { flex: 1 1 auto; min-width: 0; }
.todo-beschreibung-input {
    width: 100%;
    margin-top: 8px;
    min-height: 70px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.todo-item .todo-zuweisen-select {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    background: #fff;
    font-family: inherit;
    color: var(--text);
    max-width: 130px;
}
.todo-item .todo-datum-input {
    flex: 0 0 auto;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    max-width: 145px;
}

.todo-zuweisung-badge {
    flex: 0 0 auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #eef0f4;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.todo-datum-badge {
    flex: 0 0 auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #eef0f4;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Todo-Liste (Übersichtsseite, nur lesend + Schnell-Umschalter) */
.todo-anzeige-liste { list-style: none; margin: 0; padding: 0; }
.todo-anzeige-zeile {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    border-radius: 6px;
}
.todo-anzeige-zeile:last-child { border-bottom: none; }
.todo-anzeige-zeile.todo-erledigt { background: var(--ok-bg); }
.todo-anzeige-zeile.todo-ueberfaellig { background: var(--err-bg); }
.todo-anzeige-zeile.todo-ueberfaellig .todo-datum-badge { background: var(--err-bg); color: var(--err-text); font-weight: 600; }
.todo-umschalt-form { margin: 0; flex: 0 0 auto; }
.todo-anzeige-text { font-size: 0.95rem; flex: 1 1 auto; min-width: 0; }
.todo-beschreibung-details { flex: 1 1 auto; min-width: 0; }
.todo-beschreibung-details summary { cursor: pointer; list-style: none; }
.todo-beschreibung-details summary::-webkit-details-marker { display: none; }
.todo-beschreibung-details summary::after { content: " 📝"; font-size: 0.75rem; opacity: 0.6; }
.todo-beschreibung-text {
    margin: 6px 0 0;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: pre-line;
}
