/* ── Multikalender ─────────────────────────────────────────────────────────── */

/* Kalender-Seite: Content als Flex-Spalte, damit Wrapper + sticky Legende greifen */
.page-kalender .main-content {
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}
.page-kalender .kal-wrapper {
    flex: 1;
    min-height: 0;
    max-height: none;
}
.page-kalender .kal-legende {
    position: sticky;
    bottom: 0;
    background: var(--body-bg);
    margin: 0;
    padding: .6rem 0 .9rem;
}

/* Jahres-Heatmap (Navigations-Minimap oberhalb des Multikalenders) */
.kal-heatmap {
    margin-bottom: 1rem;
    padding: 10px 14px 8px;
    border-radius: 10px;
    background: var(--bg-white);
}
.kal-heatmap-months {
    display: flex;
    margin-bottom: 4px;
}
.kal-heatmap-months span {
    text-align: center;
    font-size: .72rem;
    color: var(--muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.kal-heatmap-svg {
    position: relative;
    cursor: pointer;
    line-height: 0;
}
.kal-heatmap-svg svg { display: block; }
.kal-heatmap-hint {
    position: absolute;
    top: -4px;
    right: 6px;
    padding: 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .8);
    color: #020202;
    pointer-events: none;
    z-index: 6;
}
[data-theme="dark"] .kal-heatmap-hint { background: rgba(36, 44, 57, .8); color: var(--body-text); }
.kal-heatmap-hint-path { fill: none; stroke: currentColor; stroke-miterlimit: 10; stroke-width: 1.3px; }
.kal-heatmap-window {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(255, 193, 7, .2);
    border-left: 2px solid var(--accent-yellow);
    border-right: 2px solid var(--accent-yellow);
    pointer-events: none;
    z-index: 4;
}
.kal-heatmap-selector {
    position: absolute;
    top: 0;
    height: 100%;
    display: none;
    border: 2px solid #4977ae;
    background: rgba(73, 119, 174, .85);
    pointer-events: none;
    z-index: 5;
}
.kal-heatmap-selector span {
    display: block;
    position: absolute;
    top: 10px;
    padding: 2px 6px;
    font-size: .78rem;
    color: #fff;
    width: max-content;
}

.kal-toolbar {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: .5rem;
}
.kal-btns { margin-top: .18rem; }
.kal-scroll-btns { display: flex; gap: .5rem; margin-top: .18rem; }
.kal-toolbar .vt-tab { padding: .6rem 1rem; min-width: 68px; font-size: .9rem; }
.kal-tabs .vt-tab[href="/kalender/auslastung"] { padding: .65rem 1.6rem .4rem 1.6rem; }
.kal-tabs .vt-tab[href="/kalender/auslastung"] .ti { font-size: 1.1rem; }
.kal-toolbar .input-addon { max-width: none; }
.kal-toolbar .btn-icon { padding: .5rem 1.3rem; }
.kal-toolbar .btn-icon .ti { font-size: 1.2rem; }
@media (max-width: 768px) {
    .kal-toolbar { flex-wrap: wrap; gap: .75rem; }
    .view-toggle.kal-tabs { width: 100%; border-radius: 30px; margin-bottom: .8rem; }
    .kal-toolbar .vt-tab { min-width: 0; flex: 1; padding: .6rem 1rem; }
    .kal-toolbar .btn-icon { padding: .5rem .91rem; }
    .kal-scroll-btns,
    .kal-btns { margin-bottom: 1rem; }
    .kal-tabs .vt-tab[href="/kalender/auslastung"] { padding: .6rem 1.1rem .4rem 1.1rem; }
}
.kal-jahr-nav { display: flex; align-items: center; gap: .8rem; margin-top: .1rem; }
.kal-jahr-nav #kal-year { font-size: 1rem; font-weight: 700; min-width: 50px; text-align: center; }
.kal-jahr-nav .btn .ti { font-size: 1.1rem; margin-right: 0; padding: .18rem .4rem; }

/* Wrapper: scrollt horizontal + vertikal, damit sticky Header/Labels greifen */
.kal-wrapper {
    overflow: auto;
    max-height: calc(100vh - 220px);
    border: 1px solid var(--border);
    border-radius: 10px;
    user-select: none;
    scrollbar-width: auto;
}
.kal-wrapper::-webkit-scrollbar { width: 14px; height: 14px; }
.kal-wrapper::-webkit-scrollbar-track { background: var(--body-bg); border-radius: 0 0 10px 10px; }
.kal-wrapper::-webkit-scrollbar-thumb { background: #b0b0b0; border-radius: 7px; border: 3px solid var(--body-bg); }
.kal-wrapper::-webkit-scrollbar-thumb:hover { background: #888; }

.kal-grid {
    display: grid;
    grid-template-columns: max-content repeat(var(--kal-days, 120), 44px);
    width: max-content;
}

/* Header */
.kal-corner {
    grid-row: 1 / span 2;
    grid-column: 1;
    position: sticky;
    top: 0;
    left: 0;
    z-index: 15;
    background: var(--bg-white-light);
    border-bottom: 1px solid var(--border);
}

.kal-mhead {
    grid-row: 1;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 8px 12px 6px;
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--bg-white-light);
}
.kal-mhead--odd { background: var(--bg-white); }

.kal-day-head {
    grid-row: 2;
    position: sticky;
    top: 34px;
    z-index: 10;
    text-align: center;
    padding: 4px 3px 3px;
    font-size: .85rem;
    background: var(--bg-white);
    border-right: 1px solid var(--border-multi);
    box-shadow: 0 4px 6px -2px rgba(0, 0, 0, .05);
}
.kal-day-head .kal-wt {
    display: block;
    font-size: .72rem;
    color: var(--muted);
}
.kal-day-head.kal-we { background: var(--surface-2); }
.kal-day-head.kal-today {
    background: rgba(255, 193, 7, .2);
    border-bottom: 3px solid var(--accent-yellow);
}
/* Labels (Spalte 1) */
.kal-label {
    grid-column: 1;
    position: sticky;
    left: 0;
    z-index: 9;
    padding: 8px 15px;
    text-align: right;
    font-size: .9rem;
    background: var(--bg-white-light);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    max-width: 180px;
}
.kal-label-text {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kal-label--objekt { min-height: 40px; }
a.kal-label { color: currentColor; cursor: pointer; }
a.kal-label:hover { text-decoration: none; background: var(--bg-white); }

.kal-objekt-header {
    padding: 12px 18px 2px;
    font-size: .85rem;
    color: var(--muted);
    background: var(--bg-white-light);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 8;
}

/* Tages-Zellen */
.kal-cell {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-multi);
    border-right: 1px solid var(--border-multi);
    z-index: 1;
}
.kal-cell.kal-we { background: var(--bg-white-light); }
.kal-cell[data-date] { cursor: crosshair; }
.kal-cell--sel { background: #ffefbe !important; }
.kal-cell--today {
    position: relative;
}
.kal-cell--today::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    margin-left: -1.5px;
    background: var(--accent-yellow);
    pointer-events: none;
}

/* Belegungs-Balken (S = Standard) */
.kal-event {
    z-index: 5;
    position: relative;
    margin: 3px 26px 3px 25px;
    padding: 2px 6px 2px 8px;
    height: 30px;
    font-size: .82rem;
    line-height: 30px;
    color: #fff;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 10px 4px 14px 4px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: opacity .2s ease;
}
.kal-event span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kal-event:hover { opacity: .8; }
.kal-event.js-bel-open { cursor: pointer; }

.kal-event img {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    flex-shrink: 0;
}
.kal-event em {
    font-style: normal;
    color: rgba(255, 255, 255, .6);
    padding-left: 2px;
}
.kal-event .ti { font-size: 1rem; }

/* Größen: L (< 8 Zeilen) und XXL (< 3 Zeilen) */
.kal--lg .kal-event { height: 38px; margin: 2px 24px; padding: 1px 6px 1px 6px; }
.kal--lg .kal-label { min-height: 46px; }
.kal--xl .kal-event { height: 55px; margin: 6px 23px; padding: 5px 8px 0; }
.kal--xl .kal-label { min-height: 70px; }

/* Buchung beginnt vor dem sichtbaren Fenster */
.kal-event--cut { border-radius: 0 4px 14px 0; }
.kal-event--cut::before {
    content: '';
    position: absolute;
    top: -1px;
    bottom: -1px;
    left: -22px;
    width: 22px;
    background: linear-gradient(to left, var(--kal-bg), transparent);
    pointer-events: none;
}

/* Neu-Punkt (< 24h erstellt) */
.kal-event--neu::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 27px;
    width: 7px;
    height: 7px;
    background: #00d1ff;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, .4);
}

/* Reinigungs-Marker (Multi) am An-/Abreisetag */
.kal-reinigung {
    z-index: 6;
    align-self: end;
    justify-self: center;
    margin-bottom: 4px;
    margin-left: 7px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle at 25% 25%, #e2e1ec, #ffbf45 50%, #e49e19);
    border: 2px solid #fff;
    cursor: pointer;
}
.kal-reinigung--ab {
    align-self: start;
    margin-top: 0;
    margin-bottom: 0;
    margin-left: -9px;
}

/* Belegungsarten */
.kal-art-0  { background: #c54d4d; --kal-bg: #c54d4d; }
.kal-art-1  { background: #f39832; --kal-bg: #f39832; }
.kal-art-2  { background: #4977ae; --kal-bg: #4977ae; }
.kal-art-3  { background: #d6a1a1; --kal-bg: #d6a1a1; }
.kal-art-20 { background: #9897a8; --kal-bg: #9897a8; justify-content: flex-start; }
.kal-art-20 img { width: 22px; height: 22px; }
.kal-art-21 {
    background: #f0f0f0;
    background-image: repeating-linear-gradient(45deg, #aeadbd, #aeadbd 5px, #a3a2b6 5px, #a3a2b6 10px);
    --kal-bg: #aeadbd;
}

/* Hover-Tooltip */
.kal-tip {
    position: fixed;
    z-index: 1200;
    max-width: 300px;
    padding: .55rem .85rem .65rem;
    background: var(--bg-white);
    color: var(--body-text);
    font-size: .82rem;
    line-height: 1.55;
    border-radius: 8px;
    border-left: 8px solid transparent;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
    white-space: pre-line;
    pointer-events: none;
}
.kal-tip::first-line { font-weight: 700; font-size: .88rem; }
.kal-tip--b { border-left-color: #c54d4d; }
.kal-tip--r { border-left-color: #f39832; }
.kal-tip--s { border-left-color: #4977ae; }
.kal-tip--c { border-left-color: #a3a2b6; }

/* Legende */
.kal-legende {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin: 1.2rem 0;
    font-size: .85rem;
    font-weight: 400;
}
.kal-legende span { display: inline-flex; align-items: center; gap: .4rem; }
.kal-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 3px;
}
.kal-dot--neu {
    background: #00d1ff;
    border-radius: 50%;
    border: 1.5px solid var(--bg-white);
    box-shadow: 0 0 0 1px var(--border);
}
.kal-dot--angebot {
    background: var(--bg-white);
    border-bottom: 3px solid #00d1ff;
}
.kal-dot--reinigung {
    background: radial-gradient(circle at 25% 25%, #e2e1ec, #ffbf45 50%, #e49e19);
    border-radius: 50%;
    border: 1px solid #fff;
    box-shadow: 0 0 0 1px var(--border);
}

/* ── Einzelansicht ─────────────────────────────────────────────────────────── */

.kal-einzel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
@media (max-width: 768px) {
    .kal-einzel { grid-template-columns: 1fr; }
}

.kal-mon {
    background: var(--bg-white);
    border-radius: 10px;
    padding: .6rem .8rem .8rem;
}
.kal-mon-head {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: .6rem;
    padding-left: 2px;
    text-align: center;
}
.kal-mon-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
}
.kal-mon-wt {
    font-size: .9rem;
    color: var(--muted);
    text-align: center;
    padding-bottom: 7px;
    font-weight: 400;
}

/* Tageszelle: An-/Abreise als runde Bögen (SVG-Form wie Altsystem) */
.ke {
    --am: var(--body-bg);
    --pm: var(--body-bg);
    --mask-am: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='0' cy='0' r='36'/%3E%3C/svg%3E");
    --mask-pm: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='32' cy='32' r='36'/%3E%3C/svg%3E");
    position: relative;
    aspect-ratio: 1.25;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    color: var(--muted-light); /*#86a86c;*/
    background: var(--bg-white-light); /*var(--kal-frei, #e7f0df)*/
}
.ke-am-b { --am: #bd4040; }
.ke-am-r { --am: #f39832; }
.ke-am-s { --am: #4977ae; }
.ke-am-c { --am: #9897a8; }
.ke-pm-b { --pm: #bd4040; }
.ke-pm-r { --pm: #f39832; }
.ke-pm-s { --pm: #4977ae; }
.ke-pm-c { --pm: #9897a8; }

/* Abreise: Bogen links oben / Anreise: Bogen rechts unten */
.ke:not(.ke-am-f):not(.ke--voll)::before,
.ke:not(.ke-pm-f):not(.ke--voll)::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
}
.ke:not(.ke-am-f):not(.ke--voll)::before {
    background: var(--am);
    -webkit-mask: var(--mask-am) no-repeat 0 0 / 100% 100%;
    mask: var(--mask-am) no-repeat 0 0 / 100% 100%;
}
.ke:not(.ke-pm-f):not(.ke--voll)::after {
    background: var(--pm);
    -webkit-mask: var(--mask-pm) no-repeat 0 0 / 100% 100%;
    mask: var(--mask-pm) no-repeat 0 0 / 100% 100%;
}

/* Voll belegter Zwischentag */
.ke--voll { background: var(--pm); }

/* Hover: gesamte Belegung hervorheben (JS setzt ke--hi auf alle Zellen der bel-id) */
.ke--hi:not(.ke--wechsel) { filter: brightness(1.15); }
.ke--hi:has(.ke-gast) { z-index: 3; }

/* Buchung am Vormittag: helle Oberkante (wie Altsystem edit_bb*) */
.ke-am-b:not(.ke--wechsel) { border-top: 1px solid #ca6464; }

/* Wechseltag: zwei überbreite Ellipsen decken die Hälften voll ab,
   dazwischen bleibt ein geschwungener weißer Streifen (wie edit_bww) */
.ke--wechsel {
    background: var(--bg-white);
    --mask-am: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cellipse cx='-5' cy='0' rx='23' ry='33'/%3E%3C/svg%3E");
    --mask-pm: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cellipse cx='37' cy='32' rx='23' ry='33'/%3E%3C/svg%3E");
}

.ke:not(.ke-am-f.ke-pm-f) {
    color: rgba(255, 255, 255, .4);
}

/* Zahl und Marker über den Bogen-Ebenen halten */
.ke-num { position: relative; z-index: 1; }

/* Wechsel-/Anreisetag: Tageszahl als Box (wie Altsystem) */
.ke--wechsel .ke-num,
.ke-am-f:not(.ke-pm-f) .ke-num {
    margin-top: 1px;
    margin-left: 3px;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 12px 3px 3px 3px;
    color: rgb(255, 255, 255);
    padding: 2px 5px;
    font-weight: normal;
    font-size: .95rem;
    line-height: 19px;
    min-width: 30px;
    min-height: 19px;
    display: block;
    text-align: center;
    background: var(--pm);
}

.ke--heute { border: 2.5px solid var(--accent-yellow) !important; border-radius: 2px; }
.ke--frei { cursor: crosshair; }
.ke--sel-start,
.ke--sel,
.ke--sel-end { background: rgb(230 191 191); color: #000; }
.ke--sel-start { border-radius: 12px 0 0 12px; }
.ke--sel-end   { border-radius: 0 12px 12px 0; }
body.kal-sel-active .ke--frei:not(.ke--sel-start):not(.ke--sel):not(.ke--sel-end) { opacity: .6; }
.ke.js-bel-open { cursor: pointer; }

/* Gastname: ein Balken pro Belegung, läuft über die Folgezellen */
.ke-gast {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    padding: 0;
    font-size: .9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, .95);
    text-align: left;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    pointer-events: none;
}
.ke-gast span {
    display: inline-block;
    max-width: 100%;
    padding: 1px 4px;
    border-radius: 6px;
    background: var(--pm);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: middle;
}
.ke-gast--1 { width: 100%; }
.ke-gast--2 { width: 200%; }
.ke-gast--3 { width: 300%; }
.ke-gast--4 { width: 400%; }
.ke-gast--5 { width: 500%; }
.ke-gast--6 { width: 600%; }
.ke-gast--7 { width: 700%; }
.ke-dot {
    position: absolute;
    z-index: 1;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 2px;
    background: #00d1ff;
}
.ke-neu {
    position: absolute;
    z-index: 2;
    top: 2px;
    left: 7px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #00d1ff;
    border: 1.5px solid #fff;
}
.ke-reinigung {
    position: absolute;
    z-index: 1;
    bottom: 3px;
    left: -5px;
    width: 11px;
    height: 11px;
    border-radius: 6px;
    background: radial-gradient(circle at 25% 25%, #e2e1ec, #ffbf45 50%, #e49e19);
    border: 1.5px solid #fff;
}
.ke-pm-f:not(.ke-am-f) .ke-reinigung { bottom: auto; top: 3px; left: auto; right: -3px; }
.ke-spray {
    position: absolute;
    z-index: 1;
    bottom: 1px;
    left: 2px;
    font-size: .7rem;
    color: #fff;
    opacity: .9;
}
.ke--has-portal { justify-content: center; align-items: center; padding-bottom: 0; }
.ke-portal {
    position: relative;
    z-index: 1;
    width: 24px;
    height: 24px;
    border-radius: 3px;
    object-fit: contain;
}

/* ── Auslastung ────────────────────────────────────────────────────────────── */

.kal-aus-row {
    margin-bottom: 2rem;
}
@media (max-width: 768px) {
    /* Alle Auslastungs-Reihen zusammen horizontal scrollen */
    .kal-aus-wrap { overflow-x: auto; }
    .kal-aus-wrap .kal-aus-monate,
    .kal-aus-wrap .kal-aus-label { min-width: 900px; }
}
.kal-aus-label {
    display: flex;
    align-items: baseline;
    font-weight: 400;
    font-size: .95rem;
    margin-top: 1rem;
    margin-bottom: .5rem;
}
.kal-aus-typ {
    min-width: 160px;
}
.kal-aus-obj {
    font-weight: 400;
    font-size: .85rem;
    color: var(--muted);
}
.kal-aus-monate {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: .4rem;
}
.kal-aus-mon {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 6px 8px 10px 8px;
    border: 2px solid transparent;
    border-radius: 6px;
    background: var(--bg-white, #fff);
    text-decoration: none;
    color: var(--body-text);
    transition: border-color .15s, box-shadow .15s;
}
.kal-aus-mon:hover {
    border-color: var(--accent-yellow);
    box-shadow: 0 1px 4px rgba(22, 67, 94, .2);
    text-decoration: none;
}
.kal-aus-mon-name {
    display: block;
    text-align: center;
    font-size: .9rem;
    margin-bottom: 5px;
    font-weight: 400;
}
.kal-aus-grid-wrap {
    margin-bottom: 10px;
    overflow: hidden;
}
.kal-aus-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}
.kal-aus-grid i {
    aspect-ratio: 1;
    border-radius: 1.5px;
    background: var(--body-bg);
}
.kal-aus-grid i.ka-pad { background: transparent; }
.kal-aus-grid i.ka-b { background: #e95f5f; }
.kal-aus-grid i.ka-r { background: #ffac62; }
.kal-aus-grid i.ka-s { background: #4977ae; }
.kal-aus-grid i.ka-c { background: #9897a8; }

.kal-aus-pct {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-top: auto;
    padding-bottom: 2px;
}
.kal-aus-frei {
    display: block;
    margin: 12px auto 15px auto;
    width: fit-content;
    font-style: normal;
    font-size: .85rem;
    background: var(--bg-green);
    color: var(--text-green);
    border-radius: 5px;
    padding: 1px 8px;
}
.kal-chart {
    display: block;
    margin: 0 auto;
    width: 54px;
    height: 54px;
}
.kal-chart-bg  { fill: none; stroke: var(--bg-white-light); stroke-width: 4; }
.kal-chart-val { fill: none; stroke: #e95f5f; stroke-width: 2; stroke-linecap: round; }
.kal-chart text { fill: #d75353; font-weight: 700; font-size: .68em; text-anchor: middle; }

.kal-tabs .ti { font-size: 1rem; }

.kal-overbooked {
    margin-top: 11px !important;
    border-top: 4px dotted var(--bg-white);
}
