/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary:   #2e7d52;
    --color-primary-h: #245f40;
    --color-confirmed: #28a745;
    --color-planned:   #ffc107;
    --color-danger:    #dc3545;
    --color-bg:        #f8f9fa;
    --color-surface:   #ffffff;
    --color-border:    #dee2e6;
    --color-text:      #343a40;
    --color-muted:     #6c757d;
    --radius:          8px;
    --shadow:          0 2px 8px rgba(0,0,0,.08);
    --shadow-lg:       0 8px 32px rgba(0,0,0,.15);
}

html { font-size: 16px; }

body {
    font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* ─── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-primary);
    text-decoration: none;
}

.nav-links {
    list-style: none;
    display: flex;
    align-items: center;
    gap: .25rem;
    flex: 1;
}

.nav-links a {
    display: block;
    padding: .4rem .8rem;
    border-radius: var(--radius);
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
}

.nav-links a:hover { background: var(--color-bg); }
.nav-links a.active { background: var(--color-primary); color: #fff; }

.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--color-muted);
    font-size: .9rem;
}

.nav-user-btn {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 700;
    color: var(--color-text);
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.nav-user-btn:hover { background: #e9ecef; }

.nav-user-caret { font-size: .7rem; opacity: .6; }

.nav-user { position: relative; }

.user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 500;
    overflow: hidden;
    animation: slideUp .15s;
}

.user-dropdown[hidden] { display: none; }

.user-dropdown-item {
    display: block;
    padding: .65rem 1rem;
    font-size: .9rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    transition: background .12s;
    white-space: nowrap;
}
.user-dropdown-item:hover { background: var(--color-bg); text-decoration: none; }
.user-dropdown-item--danger { color: var(--color-danger); }
.user-dropdown-item--danger:hover { background: #fff5f5; }

.user-dropdown-divider {
    height: 1px;
    background: var(--color-border);
    margin: .25rem 0;
}

/* ─── Main & Footer ───────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.footer {
    text-align: center;
    padding: 1rem;
    color: var(--color-muted);
    font-size: .85rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

/* ─── Page header ─────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .5rem 1.1rem;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .1s;
    line-height: 1.3;
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-h); }

.btn-secondary { background: #e9ecef; color: var(--color-text); }
.btn-secondary:hover { background: #dee2e6; }

.btn-danger    { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b02a37; }

.btn-block { width: 100%; justify-content: center; }

.btn-sm { padding: .3rem .65rem; font-size: .82rem; }

.btn-icon {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    justify-content: center;
    font-size: 1.6rem;
    line-height: 1;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}
.btn-icon:hover { background: #e9ecef; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin-bottom: .9rem;
}

.form-group label {
    font-weight: 700;
    font-size: .9rem;
    color: var(--color-text);
}

.form-group-grow { flex: 1; }

.form-group-checkbox {
    justify-content: flex-end;
    padding-bottom: .2rem;
}
.form-group-checkbox label {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 160px; }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="color"],
select,
textarea {
    padding: .5rem .75rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .95rem;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color .15s;
    width: 100%;
}

input[type="color"] { padding: .2rem .4rem; height: 2.4rem; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(46,125,82,.15);
}

textarea { resize: vertical; min-height: 80px; }

.form-actions {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-weight: 600;
}
.radio-label input[type="radio"] { width: auto; }

/* ─── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-weight: 600;
}
.alert-error   { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.alert-success { background: #d1e7dd; color: #0a3622; border: 1px solid #badbcc; }

/* ─── Year nav ────────────────────────────────────────────────────────────── */
.year-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.year-nav h2 {
    font-size: 1.75rem;
    font-weight: 800;
    min-width: 5rem;
    text-align: center;
}

/* ─── Calendar grid ───────────────────────────────────────────────────────── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

@media (max-width: 1100px) { .calendar-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 780px)  { .calendar-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px)  { .calendar-grid { grid-template-columns: 1fr; } }

.month-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.month-header {
    background: var(--color-primary);
    color: #fff;
    text-align: center;
    padding: .5rem;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: .03em;
}

.day-names {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: .4rem .4rem 0;
}

.day-names span {
    text-align: center;
    font-size: .75rem;
    font-weight: 700;
    color: var(--color-muted);
    padding: .2rem 0;
}
.day-names span.weekend { color: #c0392b; }

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: .2rem .4rem .4rem;
    gap: 2px;
}

.day-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s, color .12s;
    position: relative;
    user-select: none;
}

.day-cell.empty { cursor: default; }

.day-cell:not(.empty):hover { background: #e9ecef; }

.day-cell.today {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    color: var(--color-primary);
}

.day-cell.weekend:not(.has-confirmed):not(.has-planned) { color: #c0392b; }

.day-cell.has-confirmed {
    background: var(--color-confirmed);
    color: #fff;
}
.day-cell.has-confirmed.today { outline-color: #fff; }

.day-cell.has-planned {
    background: var(--color-planned);
    color: #6b4f00;
}

.day-cell.has-confirmed:hover { background: #218838; }
.day-cell.has-planned:hover   { background: #e0a800; }

.cal-tooltip {
    position: fixed;
    transform: translate(-50%, calc(-100% - 10px));
    background: #1a1a1a;
    color: #fff;
    font-size: .8rem;
    font-family: inherit;
    font-weight: 600;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 260px;
    padding: .55rem .8rem;
    border-radius: 7px;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.cal-tooltip[hidden] { display: none; }

/* ─── Modals ──────────────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[hidden] { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    animation: fadeIn .2s;
}

.modal-dialog {
    position: relative;
    background: var(--color-surface);
    border-radius: calc(var(--radius) * 1.5);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp .2s;
}

.modal-dialog-lg { max-width: 680px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 1;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 800;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-muted);
    line-height: 1;
    padding: .2rem .4rem;
    border-radius: 4px;
    transition: background .12s;
}
.modal-close:hover { background: var(--color-bg); }

.modal-body { padding: 1.25rem; }

body.modal-active { overflow: hidden; }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Booking cards ───────────────────────────────────────────────────────── */
.booking-card {
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: .75rem;
}
.booking-card.status-confirmed { border-left: 4px solid var(--color-confirmed); }
.booking-card.status-planned   { border-left: 4px solid var(--color-planned); }

.booking-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .35rem;
}

.booking-card-meta {
    font-size: .85rem;
    color: var(--color-muted);
    margin-bottom: .5rem;
}

.booking-card-actions {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

/* ─── Status badges ───────────────────────────────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}
.status-confirmed { background: #d1e7dd; color: #0a3622; }
.status-planned   { background: #fff3cd; color: #664d03; }

.work-status-badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

/* ─── Tabs ────────────────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: .5rem;
}

.tab-btn {
    padding: .45rem 1rem;
    border: 1.5px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    background: none;
    color: var(--color-muted);
    transition: background .15s, color .15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}
.tab-btn:hover { background: var(--color-bg); color: var(--color-text); }
.tab-btn.active {
    background: var(--color-surface);
    color: var(--color-primary);
    border-color: var(--color-border);
    border-bottom-color: var(--color-surface);
    margin-bottom: -2px;
}

/* ─── Note cards ──────────────────────────────────────────────────────────── */
.notes-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    align-items: start;
}

/* ─── Ferien category view ────────────────────────────────────────────────── */
.notes-container--ferien {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.ferien-section {
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.ferien-section-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.1rem;
    background: var(--color-primary);
    color: #fff;
    flex-wrap: wrap;
}

.ferien-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    flex: 1;
}

.ferien-section-dates {
    font-size: .85rem;
    opacity: .85;
    white-space: nowrap;
}

.ferien-section-header .booking-badge {
    background: rgba(255,255,255,.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
}

.ferien-notes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    padding: 1rem;
    align-items: start;
}

.ferien-section-standalone .ferien-section-header {
    background: var(--color-muted);
}

.ferien-section-empty {
    padding: .75rem 1rem;
    color: var(--color-muted);
    font-size: .9rem;
    font-style: italic;
}

.note-card {
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    transition: box-shadow .15s;
}
.note-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }

.note-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}

.note-title {
    font-size: 1rem;
    font-weight: 700;
    flex: 1;
}

.note-booking { margin-bottom: .5rem; }

.booking-badge {
    display: inline-block;
    padding: .15rem .5rem;
    background: #e8f4f8;
    color: #0c5460;
    border-radius: 4px;
    font-size: .8rem;
    font-weight: 600;
}

.note-preview {
    font-size: .9rem;
    color: var(--color-muted);
    margin-bottom: .5rem;
    white-space: pre-wrap;
}

.note-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    border-top: 1px solid var(--color-border);
    padding-top: .5rem;
    margin-top: .5rem;
}

.note-meta {
    font-size: .8rem;
    color: var(--color-muted);
}

.note-actions {
    display: flex;
    gap: .3rem;
    align-items: center;
}

.status-select {
    padding: .2rem .4rem;
    font-size: .78rem;
    border-radius: 999px;
    background: #e9ecef;
    border: none;
    font-weight: 700;
    cursor: pointer;
    width: auto;
}

.note-detail-meta {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

.note-category-badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    color: #fff;
}

.note-date-badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    background: #e8f4f8;
    color: #0c5460;
    white-space: nowrap;
}

/* Für Gäste freigegebene Notiz */
.guest-badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    background: #fff3cd;
    color: #7a5b00;
    white-space: nowrap;
}

.note-full-content {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1rem;
    font-size: .95rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ─── Anhänge ─────────────────────────────────────────────────────────────── */
.attachment-badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    background: #e9ecef;
    color: #495057;
    white-space: nowrap;
}

.attachment-block { margin-top: 1rem; }
.attachment-block h4 { font-size: .95rem; font-weight: 800; margin-bottom: .5rem; }

.attachment-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.attachment-list:not(:empty) { margin-bottom: .6rem; }

.attachment-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .7rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .9rem;
}

.attachment-item--pending {
    border-style: dashed;
    background: transparent;
}

.attachment-icon { flex-shrink: 0; }

.attachment-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
    font-weight: 600;
}

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

.attachment-meta {
    flex-shrink: 0;
    font-size: .8rem;
    color: var(--color-muted);
}

.attachment-open {
    flex-shrink: 0;
    font-size: .8rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
}
.attachment-open:hover { text-decoration: underline; }

.attachment-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: .95rem;
    line-height: 1;
    padding: .2rem;
    opacity: .7;
}
.attachment-remove:hover { opacity: 1; }

/* Der eigentliche Dateidialog ist versteckt – dieses Label ist der Knopf. */
.file-picker {
    display: inline-block;
    padding: .5rem .9rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
}
.file-picker:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ─── Admin ───────────────────────────────────────────────────────────────── */
.admin-section { padding: 1rem 0; }
.admin-section h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 1rem; }

hr { border: none; border-top: 1px solid var(--color-border); margin: 1.5rem 0; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: .9rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.admin-table th,
.admin-table td {
    padding: .7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.admin-table th {
    background: #f1f3f5;
    font-weight: 700;
    color: var(--color-muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--color-bg); }

.td-actions {
    display: flex;
    gap: .4rem;
    align-items: center;
    flex-wrap: wrap;
}

.admin-form {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.color-swatch {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,.2);
    vertical-align: middle;
    margin-right: .25rem;
}

/* ─── Profile ─────────────────────────────────────────────────────────────── */
.profile-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    max-width: 680px;
}

.profile-fieldset {
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.25rem .5rem;
    margin-bottom: 1.25rem;
}

.profile-fieldset legend {
    padding: 0 .5rem;
    font-weight: 800;
    font-size: .95rem;
    color: var(--color-text);
}

.fieldset-hint {
    font-weight: 400;
    font-size: .82rem;
    color: var(--color-muted);
}

/* ─── Login ───────────────────────────────────────────────────────────────── */
.login-body {
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-container { width: 100%; max-width: 400px; }

.login-card {
    background: var(--color-surface);
    border-radius: calc(var(--radius) * 2);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h1 { font-size: 2rem; font-weight: 800; color: var(--color-primary); margin-bottom: .5rem; }
.login-header p  { color: var(--color-muted); }

/* ─── Utilities ───────────────────────────────────────────────────────────── */
.text-muted   { color: var(--color-muted); }
.text-center  { text-align: center; }
.loading      { text-align: center; padding: 2rem; color: var(--color-muted); }

/* ─── Handbuch ────────────────────────────────────────────────────────────── */

.hb-header-actions { display: flex; gap: .5rem; }

.hb-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.hb-sidebar {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    position: sticky;
    top: 5rem;
}

/* Aufklapp-Leiste – am Rechner nicht nötig, dort steht das Verzeichnis immer da */
.hb-toc-toggle { display: none; }

.hb-search input {
    width: 100%;
    padding: .5rem .7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font: inherit;
    margin-bottom: .75rem;
}

.hb-chapter-list { display: flex; flex-direction: column; gap: .15rem; }

.hb-chapter-item {
    display: flex;
    align-items: center;
    gap: .25rem;
    border-radius: 6px;
}
.hb-chapter-item.active { background: rgba(46,125,82,.1); }
.hb-chapter-item.dragging { opacity: .4; }

.hb-chapter-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .55rem;
    color: var(--color-text);
    font-size: .92rem;
    border-radius: 6px;
}
.hb-chapter-link:hover { background: var(--color-bg); text-decoration: none; }
.hb-chapter-item.active .hb-chapter-link { color: var(--color-primary); font-weight: 700; }
.hb-chapter-title { overflow-wrap: anywhere; }

.hb-drag-handle {
    cursor: grab;
    color: var(--color-muted);
    padding: 0 .1rem;
    user-select: none;
}

.hb-draft-badge {
    font-size: .68rem;
    font-weight: 700;
    background: #fff3cd;
    color: #7a5b00;
    padding: .1rem .4rem;
    border-radius: 999px;
}

.hb-sidebar-hint { margin-top: .75rem; font-size: .75rem; color: var(--color-muted); }

.hb-article {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.hb-article-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--color-border);
}

.hb-article-meta { margin-top: 1.5rem; font-size: .8rem; color: var(--color-muted); }

/* Fließtext des Handbuchs */
.hb-article-body { line-height: 1.7; }
.hb-article-body > *:first-child { margin-top: 0; }
.hb-article-body p { margin: .75rem 0; }
.hb-article-body h3 { margin: 1.5rem 0 .5rem; font-size: 1.15rem; }
.hb-article-body h4 { margin: 1.25rem 0 .4rem; font-size: 1rem; }
.hb-article-body ul,
.hb-article-body ol { margin: .75rem 0 .75rem 1.5rem; }
.hb-article-body li { margin: .3rem 0; }
.hb-article-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 1rem 0;
    box-shadow: var(--shadow);
}
.hb-article-body table { border-collapse: collapse; margin: 1rem 0; }
.hb-article-body th,
.hb-article-body td { border: 1px solid var(--color-border); padding: .4rem .6rem; }
.hb-article-body blockquote {
    margin: 1rem 0;
    padding: .5rem 1rem;
    border-left: 3px solid var(--color-primary);
    background: var(--color-bg);
}
.hb-article-body .callout,
.callout {
    margin: 1rem 0;
    padding: .75rem 1rem;
    background: #fff8e1;
    border-left: 4px solid var(--color-planned);
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Checklisten */
.hb-article-body ul.checklist { list-style: none; margin-left: 0; }
.hb-article-body ul.checklist li {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .35rem .5rem;
    border-radius: 6px;
}
.hb-article-body ul.checklist li:hover { background: var(--color-bg); }
.hb-article-body ul.checklist li.done { color: var(--color-muted); text-decoration: line-through; }
.hb-check { margin-top: .35rem; width: 1.1rem; height: 1.1rem; flex-shrink: 0; cursor: pointer; }

.hb-checklist-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.25rem;
    padding-top: .75rem;
    border-top: 1px solid var(--color-border);
    font-size: .85rem;
    color: var(--color-muted);
}

/* Suche */
.hb-search-results {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.hb-search-hit {
    padding: .6rem 0;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
}
.hb-search-hit:last-child { border-bottom: none; }
.hb-search-hit:hover strong { color: var(--color-primary); }
.hb-search-hit p { font-size: .85rem; color: var(--color-muted); margin-top: .15rem; }

/* Editor */
.hb-edit-dialog { max-width: 900px; }

.hb-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    padding: .4rem;
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--color-bg);
}
.hb-toolbar button {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 5px;
    padding: .25rem .5rem;
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
    color: var(--color-text);
}
.hb-toolbar button:hover { background: var(--color-surface); border-color: var(--color-border); }
.hb-toolbar-sep { width: 1px; height: 1.2rem; background: var(--color-border); margin: 0 .25rem; }

.hb-editor {
    min-height: 320px;
    max-height: 55vh;
    overflow-y: auto;
    padding: .9rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--color-surface);
    line-height: 1.7;
}
.hb-editor:focus { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.hb-editor img { max-width: 100%; height: auto; border-radius: var(--radius); }
.hb-editor ul.checklist { list-style: none; margin-left: 0; padding-left: 0; }
.hb-editor ul.checklist li::before { content: '☐ '; color: var(--color-muted); }

.hb-revision {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--color-border);
}
.hb-revision:last-child { border-bottom: none; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .hb-layout { grid-template-columns: 1fr; }
    .hb-article { padding: 1rem; }
    .hb-header-actions { flex-wrap: wrap; }

    /* Auf dem Handy steht das Verzeichnis dem Text im Weg: eingeklappt,
       eine Leiste zum Auffalten bleibt stehen. */
    .hb-sidebar { position: static; padding: .5rem; }

    .hb-toc-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: .5rem;
        padding: .6rem .7rem;
        border: none;
        background: transparent;
        border-radius: 6px;
        font: inherit;
        font-weight: 700;
        color: var(--color-text);
        cursor: pointer;
        text-align: left;
    }
    .hb-toc-toggle:hover { background: var(--color-bg); }

    .hb-toc-caret { transition: transform .15s ease; color: var(--color-muted); }
    .hb-sidebar.open .hb-toc-caret { transform: rotate(180deg); }

    .hb-toc-panel { display: none; padding: .25rem .25rem 0; }
    .hb-sidebar.open .hb-toc-panel { display: block; }

    /* Etwas mehr Platz zum Tippen mit dem Finger */
    .hb-chapter-link { padding: .6rem .55rem; }
    .navbar  { padding: .6rem 1rem; gap: .75rem; }
    .nav-links a { padding: .35rem .6rem; font-size: .85rem; }
    .main-content { padding: 1rem; }
    .modal-dialog { margin: 0; border-radius: var(--radius); }
    .form-row { flex-direction: column; }
    .notes-container { grid-template-columns: 1fr; }
    .ferien-notes-list { grid-template-columns: 1fr; }
    .ferien-section-header { gap: .5rem; }
    .ferien-section-dates { font-size: .8rem; }
}

/* Einstufung im Sicherheitsprotokoll (Admin → Sicherheit) */
.sev {
    display: inline-block;
    width: .6rem;
    height: .6rem;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: .35rem;
}
.sev-info  { background: #94a3b8; }
.sev-warn  { background: #f59e0b; }
.sev-alert { background: #dc2626; }

/* ─── Rechenwerkzeuge an Notizen ──────────────────────────────────────────── */

/* Abzeichen auf der Notizkarte: hier steckt eine Berechnung drin */
.tool-badge {
    display: inline-block;
    padding: .2rem .5rem;
    border-radius: 999px;
    font-size: .78rem;
    background: #eef2ff;
    white-space: nowrap;
}

.note-tool {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    padding: 1rem;
}

.fr-block + .fr-block { margin-top: 1.25rem; }

.fr-block h4 {
    font-size: .95rem;
    font-weight: 800;
    margin-bottom: .5rem;
    color: var(--color-primary);
}

.fr-zeile {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
}

.fr-feld {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    font-size: .8rem;
    font-weight: 700;
    color: var(--color-muted);
    min-width: 7rem;
    flex: 1 1 7rem;
}

.fr-feld input {
    padding: .45rem .6rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font: inherit;
    font-size: .95rem;
    background: var(--color-surface);
    width: 100%;
}

.fr-feld input:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
}

/* Die vier Ecken des umschließenden Rechtecks */
.fr-ecken {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: .75rem;
    margin-top: .5rem;
}

.fr-ecke {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: .6rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.fr-ecke strong { font-size: .8rem; }

.fr-raender {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: .6rem;
    margin-top: .5rem;
}

.fr-feld-rand { min-width: 0; }

/* ─── Ergebnis ────────────────────────────────────────────────────────────── */

.fr-ergebnis { margin-top: 1.25rem; }

.fr-kennzahlen {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.fr-kennzahl {
    flex: 1 1 7rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .7rem .9rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.fr-kennzahl-gross {
    flex: 1 1 12rem;
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.fr-kennzahl-gross .fr-text small { color: rgba(255,255,255,.85); }

.fr-zahl {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1.1;
}

.fr-text {
    font-size: .8rem;
    font-weight: 700;
    color: var(--color-muted);
}

.fr-kennzahl-gross .fr-text { color: #fff; }

.fr-text small { font-weight: 600; font-size: .72rem; }

.fr-flaechen {
    margin-top: .75rem;
    font-size: .85rem;
    color: var(--color-muted);
}

.fr-kurzmass {
    font-size: .85rem;
    font-weight: 700;
    color: var(--color-muted);
    margin-bottom: .5rem;
}

.fr-zeichnung {
    margin-top: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
}

.fr-svg {
    display: block;
    width: 100%;
    max-height: 60vh;
}

/* Die Zeichnung: ganze Fliesen, angeschnittene, Riemchen, Umriss */
.fr-aussen   { fill: #fff; stroke: none; }
.fr-feld     { fill: #dbeafe; stroke: none; }
.fr-ganz     { fill: #bfdbfe; stroke: #1d4ed8; stroke-width: .4; }
.fr-schnitt  { fill: #fed7aa; stroke: #c2410c; stroke-width: .4; }
.fr-riemchen { fill: #e2e8f0; stroke: #64748b; stroke-width: .4; }
.fr-kontur   { fill: none;   stroke: #1f2937; stroke-width: 1.2; }
.fr-mass     { font-size: 9px; fill: #6b7280; font-weight: 700; }
.fr-hinweis  { font-size: 12px; fill: #374151; font-weight: 700; }

.fr-tabelle {
    width: 100%;
    border-collapse: collapse;
    margin-top: .5rem;
    font-size: .85rem;
}

.fr-tabelle th,
.fr-tabelle td {
    text-align: left;
    padding: .35rem .5rem;
    border-bottom: 1px solid var(--color-border);
}

.fr-tabelle thead th { color: var(--color-muted); font-size: .78rem; }
.fr-tabelle tfoot th { border-bottom: none; }

.fr-ergebnis h5 {
    margin-top: 1rem;
    font-size: .9rem;
    font-weight: 800;
}

@media (max-width: 640px) {
    .fr-zeile { gap: .5rem; }
    .fr-feld  { flex-basis: 100%; }
    .fr-kennzahl { flex-basis: 100%; }
}

/* Hinweistext als eigener Absatz (im Admin unter dem Kategorieformular,
   im Fliesenrechner unter den Eingabefeldern) */
p.fieldset-hint { margin: .35rem 0 .5rem; }

/* Freigabe der Werkzeuge je Kategorie (Admin → Kategorien) */
.tool-choices {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.25rem;
    padding: .5rem 0;
}
.tool-choices label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-weight: 400;
}

/* Auswahlfeld des Werkzeugs in der Notiz */
#noteToolSelect { margin-bottom: .75rem; }

/* ─── Werkzeug „Ausgaben teilen" ──────────────────────────────────────────── */

.au-namenszeile {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .4rem;
    max-width: 22rem;
}

.au-namenszeile input {
    flex: 1 1 auto;
    padding: .4rem .6rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font: inherit;
    font-size: .95rem;
    background: var(--color-surface);
}

/* Kopfzeile über den Ausgaben, gleiche Spalten wie die Zeilen selbst */
.au-kopfzeile,
.au-zeile {
    display: grid;
    /* Die Kategoriespalte muss den längsten Namen tragen können – ein
       abgeschnittenes „Lebensmitte" ist im Auswahlfeld nicht lesbar. */
    grid-template-columns: minmax(6rem, 1fr) minmax(8rem, 1.3fr) minmax(7rem, 1.5fr) 6.5rem 2rem;
    gap: .4rem;
    align-items: center;
}

.au-kopfzeile {
    font-size: .75rem;
    font-weight: 700;
    color: var(--color-muted);
    padding: 0 .2rem .25rem;
}

.au-zeile { margin-bottom: .4rem; }

.au-zeile select,
.au-zeile input {
    width: 100%;
    padding: .4rem .5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font: inherit;
    font-size: .92rem;
    background: var(--color-surface);
}

.au-zeile .au-betrag { text-align: right; }

.au-weg {
    border: none;
    background: transparent;
    color: var(--color-muted);
    font-size: 1rem;
    line-height: 1;
    padding: .3rem;
    border-radius: 6px;
    cursor: pointer;
}
.au-weg:hover:not(:disabled) { background: #f8d7da; color: var(--color-danger); }
.au-weg:disabled { opacity: .3; cursor: not-allowed; }

.au-hinweis {
    font-size: .88rem;
    color: var(--color-muted);
    padding: .4rem 0;
}

/* ─── Ergebnis ────────────────────────────────────────────────────────────── */

.au-ergebnis { margin-top: 1.25rem; }

.au-ergebnis h5 {
    margin-top: 1rem;
    font-size: .9rem;
    font-weight: 800;
}

.au-zahl { text-align: right; white-space: nowrap; }
.au-plus  { color: var(--color-confirmed); font-weight: 700; }
.au-minus { color: var(--color-danger);    font-weight: 700; }
.au-anteil { color: var(--color-muted); }

.au-ausgleich {
    list-style: none;
    margin: .5rem 0 0;
    padding: 0;
}

.au-ausgleich li {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .5rem .75rem;
    margin-bottom: .4rem;
    font-size: .95rem;
}

/* Betrag im Ausgleich – nicht zu verwechseln mit dem Eingabefeld .au-betrag */
.au-summe { float: right; font-weight: 800; }

.au-kategorien td:first-child { width: 30%; }
.au-balkenzelle { width: 40%; }

.au-balken {
    display: block;
    height: .55rem;
    border-radius: 999px;
    background: var(--color-primary);
    min-width: 2px;
}

@media (max-width: 640px) {
    /* Auf schmalen Geräten stehen die Felder einer Ausgabe untereinander;
       die Kopfzeile passt dann nicht mehr dazu. */
    .au-kopfzeile { display: none; }
    .au-zeile {
        grid-template-columns: 1fr 1fr;
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        padding: .5rem;
        background: var(--color-surface);
    }
    .au-zeile .au-text { grid-column: 1 / -1; }
    .au-kategorien td:first-child { width: auto; }
    .au-balkenzelle { display: none; }
}

/* ─── Reiter im Bearbeitungsfenster ───────────────────────────────────────── */

/* Speichern gehört in die Kopfzeile: bei einem langen Rechner müsste man
   sonst jedes Mal ans Ende scrollen. Die Kopfzeile klebt schon oben. */
.modal-header-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.modal-tabs {
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 1;
}

.tab-inhalt[hidden] { display: none; }

@media (max-width: 640px) {
    .modal-header h3 { font-size: 1rem; }
    .modal-header-actions { gap: .3rem; }
}

/* In der Ecken-Kachel stehen die Felder untereinander. Dort wird aus dem
   flex-basis der Felder (7rem) eine Mindesthöhe – die Kacheln wurden dadurch
   dreimal so hoch wie nötig. */
.fr-ecke .fr-feld { flex: 0 0 auto; min-width: 0; }

/* Die vier Ecken als 2x2-Raster: so liegen die Kacheln da, wo die Ecken der
   Fläche liegen – oben links steht oben links. */
.fr-ecken { grid-template-columns: repeat(2, minmax(0, 1fr)); }
