/* ==========================================================================
   Legenda i pomoc — panel wysuwany z prawej
   ========================================================================== */
button.legend-tab {
    position: fixed;
    top: 50%;
    right: 0;
    z-index: 900;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    min-height: 34px;
    padding: 0 12px 0 10px;
    border: 1px solid #cbd5e1;
    border-right: 0;
    border-radius: 6px 0 0 6px;
    background: #fff;
    background-color: #fff;
    box-shadow: -2px 0 8px rgba(15, 23, 42, .08);
    font-size: 12px;
    color: #475569;
    cursor: pointer;
}

button.legend-tab:hover {
    background-color: #f8fafc;
}

.legend-tab {
    position: fixed;
    top: 50%;
    right: 0;
    z-index: 900;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px 0 10px;
    border: 1px solid #cbd5e1;
    border-right: 0;
    border-radius: 6px 0 0 6px;
    background: #fff;
    box-shadow: -2px 0 8px rgba(15, 23, 42, .08);
    font-size: 12px;
    color: #475569;
    cursor: pointer;
}

.legend-tab:hover { background: #f8fafc; }

.legend-tab__icon { font-size: 14px; }

/* --- panel ---------------------------------------------------------------- */

.legend-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 901;
    width: 460px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    box-shadow: -8px 0 24px rgba(15, 23, 42, .12);
    transform: translateX(100%);
    transition: transform .22s ease;
}

.legend-panel.is-open { transform: translateX(0); }

.legend-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.legend-panel__title {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
}
button.legend-panel__close {
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: none;
    background-color: transparent;
    box-shadow: none;
    font-size: 20px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}
.legend-panel__close {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    background: none;
    font-size: 20px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}

.legend-panel__close:hover { background: #f1f5f9; }

.legend-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 20px;
}

/* --- sekcje --------------------------------------------------------------- */

.legend-section { padding: 14px 0; border-top: 1px solid #f1f5f9; }
.legend-section:first-child { border-top: 0; }

.legend-section__title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
}

/* --- wiersze legendy ------------------------------------------------------ */

.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 12px;
    color: #475569;
}

.legend-row__icon {
    flex: none;
    width: 34px;
    height: 16px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.legend-row__label { flex: 1; min-width: 0; line-height: 1.35; }

.legend-row__state {
    flex: none;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.legend-row__state.is-on  { background: #dcfce7; color: #15803d; }
.legend-row__state.is-off { background: #fee2e2; color: #b91c1c; }

.legend-row--head { font-weight: 500; color: #1e293b; }

.legend-row__swatch {
    flex: none;
    width: 34px;
    height: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 3px;
}

.legend-row__swatch--bar  { box-shadow: inset 3px 0 0 #b45309; }
.legend-row__swatch--fill { background: #fde68a; }
.legend-row__swatch--dim  { background: #dbeafe; }
.legend-row__swatch--day  { background: #dcfce7; }

/* wiersze zalezne od aktywnego trybu */
body:not(.abs--bar)  .help-absence-bar  { display: none; }
body:not(.abs--fill) .help-absence-fill { display: none; }
body:not(.dim--shift):not(.dim--brigade):not(.dim--duty) .help-dim { display: none; }

/* --- instrukcja ----------------------------------------------------------- */

.help-list { margin: 0; font-size: 12px; }

.help-list dt {
    margin: 10px 0 3px;
    font-weight: 600;
    color: #334155;
}

.help-list dt:first-child { margin-top: 0; }

.help-list dd {
    margin: 0;
    color: #64748b;
    line-height: 1.5;
}

.help-list kbd {
    display: inline-block;
    min-width: 16px;
    padding: 1px 5px;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 3px;
    background: #f8fafc;
    font: 11px/1.4 Consolas, Monaco, monospace;
    color: #334155;
    text-align: center;
}

body.legend-open .page-region-content {
    margin-right: 340px;
    transition: margin-right .22s ease;
}
body:not(.abs--text) .help-absence-text {
    display: none;
}

.legend-row__swatch--text {
    border: 0;
    font-weight: 600;
    color: #b45309;
    font-size: 11px;
    text-align: center;
    line-height: 16px;
}
/* --- wąskie ekrany -------------------------------------------------------- */

@media (max-width: 640px) {
    .legend-panel { width: 100%; }
    .legend-tab__text { display: none; }
}