/* ======================================================================
   Chrome aplikacji: ramka, sidebar, nawigacja, topbar, dzwonek, toasty, modale.
   Style elementow, ktore zyja w layoucie, a nie na pojedynczej stronie.
   ====================================================================== */

/* ---------- app shell ---------- */
.ld-app {
    display: flex;
    min-height: 100vh;
}

.ld-sidebar {
    width: 344px;
    flex: 0 0 344px;
    background: var(--ld-sidebar-bg);
    color: var(--ld-sidebar-fg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.ld-sidebar__header {
    height: 64px;
    flex: 0 0 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--ld-sidebar-border);
}

.ld-sidebar__body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px 16px;
}

.ld-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--ld-bg);
}

.ld-topbar {
    /* Przyklejony: przy dlugich listach odjezdzal razem z dzwonkiem i wylogowaniem,
       a to ma byc osiagalne zawsze. */
    position: sticky;
    top: 0;
    z-index: 40;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--ld-page-pad);
    background: var(--ld-surface);
    border-bottom: 1px solid var(--ld-border);
}

/* Pasek trwającej awarii — pod topbarem, na każdej stronie. Ma być widoczny, więc pełna
   szerokość i mocny kolor tła; znika sam, gdy zespół zamknie awarię. */
.ld-incidents {
    display: flex;
    flex-direction: column;
}

.ld-incident {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid var(--ld-border);
}

.ld-incident--danger {
    background: var(--ld-c-red-bg);
    color: var(--ld-c-red-700);
}

.ld-incident--warning {
    background: var(--ld-c-amber-bg);
    color: var(--ld-primary-ink);
}

.ld-incident--info {
    background: var(--ld-c-blue-bg);
    color: var(--ld-c-blue-600);
}

.ld-incident__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.ld-incident__text {
    flex: 1 1 auto;
    min-width: 0;
}

.ld-incident__btn {
    flex: 0 0 auto;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid currentColor;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.ld-incident__btn:hover {
    background: rgba(var(--ld-rgb-ink), .07);
}

@media (max-width: 640px) {
    .ld-incident {
        padding: 10px 16px;
        font-size: 13px;
        align-items: flex-start;
        flex-wrap: wrap;
    }
}

.ld-content {
    padding: 4px var(--ld-page-pad) 36px;
}

/* ---------- logo ---------- */
.ld-logo {
    display: block;
}

.ld-logo__svg {
    height: 44px;
    width: auto;
    display: block;
}

/* ---------- search ---------- */
.ld-search__label {
    font-size: 10px;
    color: var(--ld-sidebar-muted);
    margin: 0 6px 8px;
}

.ld-search {
    display: flex;
    gap: 8px;
}

.ld-search__field {
    position: relative;
    flex: 1;
    min-width: 0;
}

.ld-search__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--ld-sidebar-muted);
    pointer-events: none;
}

.ld-search__input {
    width: 100%;
    height: 42px;
    border-radius: var(--ld-radius-sm);
    border: 1px solid var(--ld-sidebar-border);
    background: var(--ld-sidebar-input);
    color: var(--ld-c-white);
    padding: 0 12px 0 36px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
}

.ld-search__input::placeholder {
    color: var(--ld-sidebar-muted);
}

.ld-search__input:focus {
    border-color: var(--ld-primary);
}

.ld-search__btn {
    height: 42px;
    padding: 0 16px;
    border-radius: var(--ld-radius-sm);
    background: var(--ld-primary);
    color: var(--ld-on-primary);
    border: none;
    font-weight: 600;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

/* ---------- report button ---------- */
.ld-report {
    height: 52px;
    border-radius: 12px;
    /* glowne CTA = akcent marki. Czerwien rezerwujemy na akcje niszczace. */
    background: var(--ld-primary);
    color: var(--ld-on-primary);
    border: none;
    font-weight: 700;
    font-size: 13px;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    cursor: pointer;
    box-shadow: 0 10px 22px -10px rgba(var(--ld-rgb-amber), .75);
}

.ld-report svg {
    width: 18px;
    height: 18px;
}

/* ---------- nav ---------- */
.ld-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ld-nav__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--ld-radius-sm);
    color: var(--ld-sidebar-fg);
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
}

.ld-nav__link:hover {
    background: rgba(255, 255, 255, .05);
}

.ld-nav__link.active {
    background: var(--ld-sidebar-active);
    color: var(--ld-c-white);
}

.ld-nav__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.ld-nav__dot--blue { background: var(--ld-c-blue-400);
}

.ld-nav__dot--lilac { background: var(--ld-c-violet-400);
}

.ld-nav__dot--amber { background: var(--ld-warn);
}

.ld-nav__dot--green { background: var(--ld-ok);
}

.ld-nav__dot--slate { background: var(--ld-c-slate-400);
}

.ld-nav__dot--red { background: var(--ld-danger);
}

.ld-nav__dot--sky { background: var(--ld-primary-soft);
}

.ld-nav__dot--teal { background: var(--ld-c-teal);
}

.ld-nav__count {
    margin-left: auto;
    background: rgba(255, 255, 255, .12);
    color: var(--ld-c-white);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 10px;
    font-weight: 600;
}

/* ---------- system status ---------- */
.ld-status {
    margin-top: auto;
    background: var(--ld-sidebar-card);
    border: 1px solid var(--ld-sidebar-border);
    border-radius: var(--ld-radius);
    padding: 16px;
}

.ld-status__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ld-status__title {
    color: var(--ld-c-white);
    font-weight: 600;
    font-size: 12px;
}

.ld-status__online {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--ld-ok);
    font-weight: 600;
}

.ld-status__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ld-ok);
}

.ld-status__bars {
    display: flex;
    gap: 6px;
    margin: 13px 0;
}

.ld-status__bar {
    height: 6px;
    flex: 1;
    border-radius: 3px;
    background: var(--ld-ok);
}

.ld-status__bar--degraded { background: var(--ld-warn);
}

.ld-status__bar--down { background: var(--ld-danger);
}

.ld-status__msg {
    font-size: 10px;
    line-height: 1.5;
    color: var(--ld-sidebar-muted);
}

/* ---------- topbar user ---------- */
.ld-topbar__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
}

.ld-topbar__crumb,
.ld-topbar__sep {
    color: var(--ld-text-muted);
}

.ld-topbar__section {
    color: var(--ld-text-body);
}

a.ld-topbar__crumb {
    text-decoration: none;
}

a.ld-topbar__crumb:hover {
    color: var(--ld-text-body);
    text-decoration: underline;
}

.ld-usermenu {
    position: relative;
}

.ld-user {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 4px 6px;
    border: none;
    border-radius: 12px;
    background: none;
    font: inherit;
    color: inherit;
}

.ld-user:hover {
    background: var(--ld-c-slate-bg);
}

.ld-user__meta {
    text-align: right;
    line-height: 1.3;
}

.ld-user__name {
    font-weight: 700;
    color: var(--ld-text-strong);
    font-size: 12px;
}

.ld-user__company {
    font-size: 10px;
    color: var(--ld-text-muted);
}

.ld-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--ld-avatar-bg);
    color: var(--ld-c-white);
    font-weight: 700;
    font-size: 13px;
    display: grid;
    place-items: center;
}

.ld-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    min-width: 220px;
    padding: 6px;
    overflow: hidden;
    background: var(--ld-surface);
    border: 1px solid var(--ld-border);
    border-radius: 14px;
    box-shadow: 0 18px 44px -14px rgba(0, 0, 0, .4);
}

.ld-menu__item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 9px;
    background: none;
    font: inherit;
    font-size: 13px;
    text-align: left;
    text-decoration: none;
    color: var(--ld-text-body);
    cursor: pointer;
}

.ld-menu__item:hover {
    background: var(--ld-c-slate-bg);
    color: var(--ld-text-strong);
}

.ld-menu__item--danger {
    color: var(--ld-danger);
}

.ld-menu__item--danger:hover {
    color: var(--ld-danger);
}

.ld-logout {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: none;
    color: var(--ld-text-muted);
    cursor: pointer;
}

.ld-logout:hover {
    background: var(--ld-c-slate-bg);
    color: var(--ld-danger);
}

.ld-logout svg {
    width: 20px;
    height: 20px;
}

/* ---------- search suggestions ---------- */
.ld-searchbox {
    position: relative;
}

.ld-suggest {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--ld-surface);
    border-radius: 12px;
    box-shadow: 0 18px 44px -14px rgba(0, 0, 0, .5);
    padding: 6px;
    z-index: 50;
}

.ld-suggest__head {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ld-text-muted);
    background: var(--ld-c-slate-bg);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 4px;
}

.ld-suggest__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.ld-suggest__item:hover {
    background: var(--ld-c-slate-bg);
}

.ld-suggest__icon {
    width: 16px;
    height: 16px;
    color: var(--ld-text-muted);
    flex: 0 0 auto;
}

.ld-suggest__text {
    flex: 1;
    min-width: 0;
    color: var(--ld-text-strong);
    font-size: 12px;
}

.ld-suggest__count {
    color: var(--ld-text-muted);
    font-size: 11px;
    flex: 0 0 auto;
}

.ld-searchbox--hero {
    position: relative;
    max-width: 720px;
    margin: 0 auto;
}

/* ---------- notifications ---------- */
.ld-topbar__right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ld-bell {
    position: relative;
}

.ld-bell__btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: none;
    color: var(--ld-text-muted);
    cursor: pointer;
}

.ld-bell__btn:hover {
    background: var(--ld-c-slate-bg);
    color: var(--ld-text-body);
}

.ld-bell__btn svg {
    width: 20px;
    height: 20px;
}

.ld-bell__badge {
    position: absolute;
    top: 5px;
    right: 5px;
    display: grid;
    place-items: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--ld-danger);
    color: var(--ld-c-white);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.ld-notif {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    width: 380px;
    overflow: hidden;
    background: var(--ld-surface);
    border: 1px solid var(--ld-border);
    border-radius: 14px;
    box-shadow: 0 18px 44px -14px rgba(0, 0, 0, .4);
}

.ld-notif__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ld-border);
}

.ld-notif__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ld-text-strong);
}

.ld-notif__mark {
    border: none;
    background: none;
    color: var(--ld-primary-ink);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.ld-notif__list {
    max-height: 380px;
    overflow-y: auto;
}

.ld-notif__empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--ld-text-muted);
    font-size: 13px;
}

.ld-notif__item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ld-border);
    cursor: pointer;
}

.ld-notif__item:last-child {
    border-bottom: none;
}

.ld-notif__item:hover {
    background: var(--ld-c-slate-bg);
}

.ld-notif__item.is-unread {
    background: rgba(var(--ld-rgb-blue), .06);
}

.ld-notif__dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin-top: 5px;
    border-radius: 50%;
}

.ld-notif__dot--accent { background: var(--ld-c-blue-600);
}

.ld-notif__dot--amber { background: var(--ld-c-amber-500);
}

.ld-notif__dot--success { background: var(--ld-c-green-500);
}

.ld-notif__dot--slate { background: var(--ld-c-slate-400);
}

.ld-notif__dot--danger { background: var(--ld-c-red-500);
}

.ld-notif__body {
    flex: 1;
    min-width: 0;
}

.ld-notif__text {
    font-size: 13px;
    line-height: 1.45;
    color: var(--ld-text-strong);
}

.ld-notif__time {
    margin-top: 3px;
    font-size: 12px;
    color: var(--ld-text-muted);
}

.ld-notif__all {
    display: block;
    padding: 12px;
    border-top: 1px solid var(--ld-border);
    color: var(--ld-primary-ink);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}

.ld-notif__all:hover {
    background: var(--ld-c-slate-bg);
}

/* ---------- toasty (wlasny zamiennik snackbara) ---------- */
.ld-toasts {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 48px));
    pointer-events: none;
}

.ld-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    background: var(--ld-surface);
    border: 1px solid var(--ld-border);
    border-left: 3px solid var(--ld-c-slate-400);
    border-radius: var(--ld-radius-sm);
    box-shadow: 0 18px 44px -14px rgba(var(--ld-rgb-ink), .38);
    pointer-events: auto;
    animation: ld-toast-in .16s ease-out;
}

@keyframes ld-toast-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ld-toast { animation: none;
    }
}

.ld-toast__dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin-top: 5px;
    border-radius: 999px;
    background: var(--ld-c-slate-400);
}

.ld-toast__text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ld-text-strong);
    overflow-wrap: anywhere;
}

.ld-toast__close {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--ld-text-muted);
    cursor: pointer;
}

.ld-toast__close:hover {
    background: var(--ld-c-slate-bg);
    color: var(--ld-text-strong);
}

.ld-toast__close svg {
    width: 13px;
    height: 13px;
}

.ld-toast--success { border-left-color: var(--ld-ok);
}

.ld-toast--success .ld-toast__dot { background: var(--ld-ok);
}

.ld-toast--warn { border-left-color: var(--ld-warn);
}

.ld-toast--warn .ld-toast__dot { background: var(--ld-warn);
}

.ld-toast--danger { border-left-color: var(--ld-danger);
}

.ld-toast--danger .ld-toast__dot { background: var(--ld-danger);
}

.ld-toast--info { border-left-color: var(--ld-status-progress-fg);
}

.ld-toast--info .ld-toast__dot { background: var(--ld-status-progress-fg);
}

/* ---------- modale (wlasny host dialogow) ---------- */
.ld-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(var(--ld-rgb-ink), .55);
    overflow-y: auto;
    animation: ld-modal-in .12s ease-out;
}

.ld-modal__panel {
    max-width: 100%;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: var(--ld-surface);
    border-radius: var(--ld-radius);
    box-shadow: 0 30px 80px -20px rgba(var(--ld-rgb-ink), .55);
}

@keyframes ld-modal-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .ld-modal { animation: none;
    }
}

/* ======================================================================
   Responsywnosc chrome'u. Do 900px sidebar zamienia sie w szuflade
   otwierana przyciskiem w topbarze; ponizej 600px topbar sie zageszcza.
   ====================================================================== */

.ld-navtoggle {
    display: none;   /* na desktopie nawigacja jest stale obok */
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--ld-text-muted);
    cursor: pointer;
}

.ld-navtoggle:hover {
    background: var(--ld-c-slate-bg);
    color: var(--ld-text-strong);
}

.ld-navtoggle svg {
    width: 20px;
    height: 20px;
}

.ld-nav-backdrop {
    display: none;
}

@media (max-width: 900px) {
    /* blokowy uklad: sidebar wychodzi z przeplywu, tresc bierze cala szerokosc */
    .ld-app {
        display: block;
    }

    .ld-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 70;
        width: min(320px, 86vw);
        flex-basis: auto;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform .18s ease;
    }

    .ld-app.is-nav-open .ld-sidebar {
        transform: none;
    }

    .ld-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 65;
        background: rgba(var(--ld-rgb-ink), .55);
    }

    .ld-navtoggle {
        display: grid;
    }

    .ld-topbar {
        gap: 10px;
    }
}

@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
    .ld-sidebar {
        transition: none;
    }
}

@media (max-width: 600px) {
    /* Zostaje sam awatar — imie i kancelaria nie miesza sie w pasek szerokosci telefonu. */
    .ld-user__meta {
        display: none;
    }

    .ld-user {
        gap: 0;
        padding: 4px;
    }

    .ld-topbar__title {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Panel powiadomien szerszy niz ekran chowal sie za krawedzia. */
    .ld-notif {
        position: fixed;
        top: 60px;
        right: 12px;
        left: 12px;
        width: auto;
    }

    .ld-toasts {
        right: 12px;
        left: 12px;
        bottom: 12px;
        max-width: none;
    }
}
