/* Zmienne globalne - light mode */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Tło i powierzchnie */
    --color-bg:             white;
    --color-surface:        #ffffff;
    --color-border:         #e5e7eb;
    --color-border-light:   #f3f4f6;

    --color-text:           #111827;
    --color-text-secondary: #6b7280;
    --color-text-muted:     #9ca3af;

    --color-primary:        #111827;
    --color-primary-fg:     #ffffff;

    /* Sidebar */
    --sidebar-width:        260px;
    --sidebar-bg:           #ffffff;
    --sidebar-border:       #e5e7eb;
    --sidebar-text:         #374151;
    --sidebar-text-muted:   #9ca3af;
    --sidebar-active-bg:    #f3f4f6;
    --sidebar-hover-bg:     #f0f1f3;
    --sidebar-active-text:  #111827;

    --header-height:        56px;
    --header-bg:            #ffffff;
    --header-border:        #e5e7eb;

    --radius-sm:  0.375rem;
    --radius-md:  0.5rem;
    --radius-lg:  0.75rem;
    --radius-xl:  1rem;

    --shadow-sm:  0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);

    /* Kolor akcentu - default, preset emerald */
    --color-accent-primary: oklch(0.55 0.19 160);
}

.app-sidebar-toggle {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
}

.app-sidebar-chevron {
    margin-left: auto;
    font-size: 0.6875rem;
    opacity: 0.5;
    transition: transform 0.2s ease;
}

.app-sidebar-badge {
    margin-left: auto;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    border-radius: 999px;
    background: var(--color-accent-primary);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.app-sidebar-toggle .app-sidebar-badge {
    margin-right: 0.25rem;
}

.app-sidebar-toggle .app-sidebar-chevron {
    margin-left: 0;
}

.table-row-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.3rem;
    margin-left: 0.375rem;
    border-radius: 999px;
    background: var(--color-accent-primary);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    vertical-align: middle;
}

.app-sidebar-toggle[aria-expanded="true"] .app-sidebar-chevron {
    transform: rotate(180deg);
}

.app-sidebar-toggle.active {
    color: var(--color-accent-primary);
    font-weight: 600;
}

.app-sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.app-sidebar-submenu .app-sidebar-link {
    padding-left: 2.5rem;
    font-size: 0.8125rem;
}

.app-sidebar-submenu .app-sidebar-submenu .app-sidebar-link {
    padding-left: 3.5rem;
}

.app-sidebar-group { margin: 0; }

/* Dark mode */
html.dark {
    --color-bg:             black;
    --color-surface:        #141414;
    --color-border:         #292929;
    --color-border-light:   #2a2a2a;
    --color-text:           white;
    --color-text-secondary: white;
    --color-text-muted:     #666666;
    --color-primary:        white;
    --color-primary-fg:     #111111;

    --sidebar-bg:           black;
    --sidebar-border:       #2e2e2e;
    --sidebar-text:         rgba(250,250,250,0.7);
    --sidebar-text-muted:   rgba(250,250,250,0.3);
    --sidebar-active-bg:    #141414;
    --sidebar-hover-bg:     rgba(46,46,46,0.5);
    --sidebar-active-text:  #fafafa;
    --header-bg:            black;
    --header-border:        #2e2e2e;
}

/* nagłówki - dark mode */
html.dark h1, html.dark h2, html.dark h3,
html.dark h4, html.dark h5, html.dark h6 { color: var(--color-text); }

html.dark .btn.btn-primary.btn-auth {
    background-color: #ffffff;
    border-color: #ffffff;
    color: #111111;
}

html.dark .btn.btn-primary.btn-auth:hover {
    background-color: #e5e5e5;
    border-color: #e5e5e5;
    color: #111111;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

html.dark body { background-color: var(--color-bg); color: var(--color-text); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.25); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,0.45); }

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

.app-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.app-content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.25s ease;
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1040;
    flex-shrink: 0;
}

html.dark .app-header { background-color: var(--header-bg); border-color: var(--header-border); }

.app-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* Logo w headerze */
.app-header-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    flex-shrink: 0;
}

.app-header-brand:hover { text-decoration: none; }

.app-header-brand-icon {
    width: 36px;
    height: 36px;
    background-color: var(--color-accent-primary);
    border-radius: 0;
    display: block;
    flex-shrink: 0;
    -webkit-mask: url('../images/logo-mask.png') center / contain no-repeat;
    mask: url('../images/logo-mask.png') center / contain no-repeat;
}

.app-header-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.app-header-brand-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.app-header-brand-sub {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
}

.app-header-sep {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    flex-shrink: 0;
}

/* Tytuł strony w headerze */
.app-header-page-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ikonkowe przyciski bez obramówki */
.app-header-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    padding: 0.4375rem 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.app-header-btn:hover {
    background-color: var(--color-border-light);
    color: var(--color-text);
}

html.dark .app-header-btn:hover { background-color: rgba(255,255,255,0.06); }

.app-header-btn::after { display: none; }

/* Ikony headera będące linkami, np. wiadomości */
a.app-header-btn,
a.app-header-btn:hover { text-decoration: none; }

/* Przycisk usera */
.app-header-user {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.15s;
}

.app-header-user:hover { background-color: var(--color-border-light); }
html.dark .app-header-user:hover { background-color: rgba(255,255,255,0.06); }
.app-header-user::after { display: none; }

/* Avatar inicjały */
.app-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent-primary), color-mix(in srgb, var(--color-accent-primary) 70%, #7c3aed));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

/* Dropdown usera */
.app-header-dropdown {
    min-width: 220px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 0.375rem;
}


.app-header-dropdown .dropdown-header { padding: 0.5rem 0.625rem; color: var(--color-text); }
.app-header-dropdown .dropdown-divider { margin: 0.25rem 0; border-color: var(--color-border); }
.app-header-dropdown .dropdown-item { border-radius: var(--radius-sm); font-size: 0.8125rem; padding: 0.4375rem 0.625rem; color: var(--color-text); }
.app-header-dropdown .dropdown-item:hover { background-color: var(--sidebar-hover-bg); color: var(--sidebar-active-text); }

html.dark .app-header-dropdown { background-color: #141414; border-color: var(--color-border); }
html.dark .app-header-dropdown .dropdown-item { color: var(--color-text); }
html.dark .app-header-dropdown .dropdown-item:hover { background-color: var(--sidebar-hover-bg); color: var(--sidebar-active-text); }
html.dark .app-header-dropdown .dropdown-divider { border-color: var(--color-border); }

.app-header .breadcrumb { font-size: 0.8125rem; margin: 0; }
.app-header .breadcrumb-item + .breadcrumb-item::before { color: var(--color-text-muted); }

.breadcrumb-item a {
    color: var(--color-accent-primary);
}

.breadcrumb-item a:hover {
    color: color-mix(in srgb, var(--color-accent-primary) 80%, black);
}

html.dark .breadcrumb-item a:hover {
    color: white;
}

.breadcrumb-item:not(.active),
.breadcrumb-item.active {
    color: var(--color-text-secondary);
}

html.dark .breadcrumb-item:not(.active),
html.dark .breadcrumb-item.active {
    color: white;
}

/* Paginacja */
.pagination {
    --bs-pagination-padding-x: 0.75rem;
    --bs-pagination-padding-y: 0.375rem;
    --bs-pagination-font-size: 0.8125rem;
    --bs-pagination-border-radius: var(--radius-sm);
    margin-bottom: 0;
}

.page-link {
    color: var(--color-text-secondary);
    background-color: var(--color-surface);
    border-color: var(--color-border);
}

.page-link:hover {
    color: var(--color-text);
    background-color: var(--color-border-light);
    border-color: var(--color-border);
}

.page-link:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-primary) 20%, transparent);
}

.page-item.active .page-link {
    background-color: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
    color: #ffffff;
}

.page-item.disabled .page-link {
    background-color: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

html.dark .page-link {
    background-color: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text);
}

html.dark .page-link:hover {
    background-color: rgba(255,255,255,0.06);
}

html.dark .page-item.disabled .page-link {
    background-color: var(--color-surface);
    color: var(--color-text-muted);
}

/* Switche on/off */
.form-switch .form-check-input:checked {
    background-color: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
}

/* Checkboxy */
.form-check-input:checked {
    background-color: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
}

.form-switch .form-check-input:focus {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-primary) 20%, transparent);
}

/* Toasty/Alerty */
.app-toasts {
    position: fixed;
    top: calc(var(--header-height) + 0.75rem);
    right: 1rem;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 280px;
    max-width: 360px;
}

.app-toast {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: toast-in 0.2s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(1rem); }
    to   { opacity: 1; transform: translateX(0); }
}

.app-toast--success { background-color: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.app-toast--error   { background-color: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.app-toast--warning { background-color: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

html.dark .app-toast--success {
    background-color: color-mix(in srgb, #22c55e 15%, var(--color-surface));
    color: #86efac;
    border-color: rgba(34,197,94,0.25);
}
html.dark .app-toast--error {
    background-color: color-mix(in srgb, #ef4444 15%, var(--color-surface));
    color: #fca5a5;
    border-color: rgba(239,68,68,0.25);
}
html.dark .app-toast--warning {
    background-color: color-mix(in srgb, #eab308 15%, var(--color-surface));
    color: #fde047;
    border-color: rgba(234,179,8,0.25);
}

.app-toast-icon { flex-shrink: 0; font-size: 0.875rem; }
.app-toast-msg  { flex: 1; line-height: 1.4; }

.app-toast-close {
    background: none;
    border: none;
    padding: 0.125rem 0.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: opacity 0.15s;
    margin-left: auto;
}

.app-toast-close:hover { opacity: 1; }

/* Sidebar */
.app-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1036;
    transition: transform 0.25s ease;
}

html.dark .app-sidebar { background-color: var(--sidebar-bg); border-color: var(--sidebar-border); }

/* Obszar linków */
.app-sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
}

/* Nagłówek grupy */
.app-sidebar-section-title {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text-muted);
    padding: 0 0.75rem;
    margin: 0 0 0.25rem 0;
}

.app-sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Pojedynczy link */
.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.app-sidebar-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-active-text);
    text-decoration: none;
}

.app-sidebar-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--color-accent-primary);
    font-weight: 600;
}

html.dark .app-sidebar-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--color-accent-primary);
}

/* Ikona przy linku */
.app-sidebar-icon {
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.app-sidebar-link:hover .app-sidebar-icon,
.app-sidebar-link.active .app-sidebar-icon { opacity: 1; }

/* Stopka sidebara */
.app-sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.app-sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-md);
    transition: background 0.15s;
    cursor: pointer;
}

.app-sidebar-user:hover { background-color: var(--sidebar-hover-bg); }

/* Avatar */
.app-sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent-primary), color-mix(in srgb, var(--color-accent-primary) 70%, #7c3aed));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.app-sidebar-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-sidebar-user-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--sidebar-active-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-sidebar-user-role {
    font-size: 0.6875rem;
    color: var(--sidebar-text-muted);
    text-transform: capitalize;
}

.app-sidebar-logout {
    background: none;
    border: none;
    color: var(--sidebar-text-muted);
    padding: 0.25rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color 0.15s;
    line-height: 1;
    flex-shrink: 0;
}

.app-sidebar-logout:hover { color: var(--sidebar-text); }

/* Mobile overlay */
.app-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}


/* Nagłówek strony */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 0.125rem 0;
    letter-spacing: -0.01em;
}

.page-subtitle { font-size: 0.8125rem; color: var(--color-text-secondary); margin: 0; }


/* STAT CARDS */
.stat-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s;
}

.stat-card:hover { box-shadow: var(--shadow-md); }
html.dark .stat-card { background-color: var(--color-surface); border-color: var(--color-border); }

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.stat-card-icon--blue   { background: #eff6ff; color: #3b82f6; }
.stat-card-icon--green  { background: #f0fdf4; color: #22c55e; }
.stat-card-icon--orange { background: #fff7ed; color: #f97316; }
.stat-card-icon--purple { background: #faf5ff; color: #a855f7; }

.stat-card-body { flex: 1; min-width: 0; }

.stat-card-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin: 0 0 0.25rem 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 0.125rem 0;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stat-card-change { font-size: 0.75rem; margin: 0; }

/* CARD PANEL */
.card-panel {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-panel.card-panel--clip {
    overflow: hidden;
}

html.dark .card-panel { background-color: var(--color-surface); border-color: var(--color-border); }

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

.card-panel-title { font-size: 0.9375rem; font-weight: 600; color: var(--color-text); margin: 0; }
.card-panel-body { padding: 1.25rem; }

.card-panel-body--tree {
    padding: 0.75rem 1.25rem;
}

/* Autentykacja */
.auth-body {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e8edf5 100%);
    min-height: 100vh;
}

html.dark .auth-body { background: black; }

.auth-body .auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    color: var(--color-text);
    font-weight: 700;
    font-size: 1.0625rem;
}

.auth-logo:hover { color: var(--color-text); }
html.dark .auth-logo { color: var(--color-text); }

.auth-logo-icon {
    width: 48px;
    height: 48px;
    background-color: var(--color-accent-primary);
    border-radius: 0;
    display: block;
    flex-shrink: 0;
    -webkit-mask: url('../images/logo-mask.png') center / contain no-repeat;
    mask: url('../images/logo-mask.png') center / contain no-repeat;
}

.auth-logo-text { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.02em; }
.auth-logo-img { height: 40px; width: auto; object-fit: contain; }

.auth-card {
    width: 100%;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

html.dark .auth-card { background-color: #141414; border-color: var(--color-border); }

.auth-card-header { padding: 1.75rem 2rem 0; text-align: center; }

.auth-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 0.375rem 0;
    letter-spacing: -0.02em;
}

html.dark .auth-card-title { color: var(--color-text); }

.auth-card-description { font-size: 0.875rem; color: var(--color-text-secondary); margin: 0; }
html.dark .auth-card-description { color: var(--color-text-secondary); }

.auth-card-body { padding: 1.5rem 2rem; }


.auth-card-footer {
    padding: 1rem 2rem 1.5rem;
    text-align: center;
    border-top: 1px solid var(--color-border);
    font-size: 0.875rem;
}

html.dark .auth-card-footer { border-color: var(--color-border); }

.auth-card .form-label { font-size: 0.8125rem; font-weight: 500; color: var(--color-text); margin-bottom: 0.375rem; }
html.dark .auth-card .form-label { color: var(--color-text); }

.auth-card .form-control,
.auth-card .form-select {
    font-size: 0.875rem;
    border-color: var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    color: var(--color-text);
    background-color: var(--color-surface);
    box-shadow: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

html.dark .auth-card .form-control,
html.dark .auth-card .form-select { background-color: #333333; border-color: var(--color-border); color: var(--color-text); }

.auth-card .form-control:focus,
.auth-card .form-select:focus {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-primary) 20%, transparent);
}

.auth-card .form-control::placeholder { color: var(--color-text-muted); }

.btn-auth { padding: 0.5625rem 1rem; font-size: 0.875rem; font-weight: 500; border-radius: var(--radius-sm); }

.btn.btn-primary.btn-auth {
    background-color: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
    color: #ffffff;
}

.btn.btn-primary.btn-auth:hover {
    background-color: color-mix(in srgb, var(--color-accent-primary) 85%, black);
    border-color: color-mix(in srgb, var(--color-accent-primary) 85%, black);
}

.auth-link { color: var(--color-accent-primary); text-decoration: none; font-weight: 500; font-size: 0.875rem; }
.auth-link:hover { color: color-mix(in srgb, var(--color-accent-primary) 80%, black); text-decoration: underline; }
html.dark .auth-link { color: var(--color-accent-primary) }
html.dark .auth-link:hover { color: white; }
html.dark .btn-close {
    filter: invert(1);
}

.auth-separator { position: relative; text-align: center; margin: 1.25rem 0; }
.auth-separator::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background-color: var(--color-border); }
.auth-separator span { position: relative; background-color: var(--color-surface); padding: 0 0.75rem; font-size: 0.75rem; color: var(--color-text-muted); }
html.dark .auth-separator span { background-color: #141414; }

.btn-social {
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border-color: var(--color-border);
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-social:hover { background-color: var(--color-border-light); border-color: var(--color-border); color: var(--color-text); }
html.dark .btn-social { border-color: var(--color-border); color: var(--color-text); }
html.dark .btn-social:hover { background-color: rgba(255,255,255,0.06); }

.social-icon { width: 16px; height: 16px; flex-shrink: 0; }

html.dark .form-check-label { color: var(--color-text); }


/* nadpisanie klas bootstrapa */
.btn { font-size: 0.875rem; font-weight: 500; border-radius: var(--radius-sm); }

.form-control, .form-select { font-size: 0.875rem; border-radius: var(--radius-sm); border-color: var(--color-border); }

.form-control:focus, .form-select:focus {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-primary) 20%, transparent);
}

html.dark .form-control,
html.dark .form-select { background-color: #333333; border-color: var(--color-border); color: var(--color-text); }
html.dark .form-control:focus,
html.dark .form-select:focus { background-color: #333333; color: var(--color-text); }
html.dark .form-control::placeholder { color: var(--color-text-muted); }

.input-group-text {
    background-color: var(--color-border-light);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}

html.dark .input-group-text {
    background-color: #333333;
    border-color: var(--color-border);
    color: var(--color-text);
}

html.dark .input-group-text:disabled,
html.dark button.input-group-text:disabled {
    background-color: #2a2a2a;
    border-color: var(--color-border);
    color: var(--color-text-muted);
    opacity: 1;
}

html.dark .filter-chip-select,
html.dark .filter-chip {
    background-color: #1a1a1a;
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}
html.dark .filter-chip-select.is-active,
html.dark .filter-chip.is-active {
    background-color: color-mix(in srgb, var(--color-accent-primary) 16%, #1a1a1a);
}
html.dark .filter-chip-panel {
    background-color: #1f1f1f;
}
html.dark .filter-chip-search input {
    background-color: #1a1a1a;
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-primary { background-color: var(--color-accent-primary); border-color: var(--color-accent-primary); color: #ffffff; }
.btn-primary:hover { background-color: color-mix(in srgb, var(--color-accent-primary) 85%, black); border-color: color-mix(in srgb, var(--color-accent-primary) 85%, black); color: #ffffff; }

.btn-outline-primary {
    color: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
    background-color: transparent;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active,
.btn-outline-primary.active {
    color: #ffffff;
    background-color: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
}

.dropdown-menu { border: 1px solid var(--color-border); box-shadow: var(--shadow-lg); border-radius: var(--radius-md); font-size: 0.875rem; padding: 0.375rem; }
html.dark .dropdown-menu { background-color: #292929; border-color: var(--color-border); }

.dropdown-menu {
    max-width: calc(100vw - 2rem);
}

.dropdown-item { border-radius: var(--radius-sm); padding: 0.4375rem 0.625rem; font-size: 0.8125rem; }
.dropdown-item:hover { background-color: var(--color-border-light); }
.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--sidebar-active-bg);
    color: var(--color-accent-primary);
}
html.dark .dropdown-item { color: var(--color-text); }
html.dark .dropdown-item:hover { background-color: rgba(255,255,255,0.06); }
html.dark .dropdown-item.active,
html.dark .dropdown-item:active {
    background-color: var(--sidebar-active-bg);
    color: var(--color-accent-primary);
}
html.dark .dropdown-divider { border-color: var(--color-text) }

.alert { border-radius: var(--radius-md); font-size: 0.875rem; border: none; }
html.dark .alert-success { background-color: rgba(34,197,94,0.1); color: #86efac; }
html.dark .alert-danger  { background-color: rgba(239,68,68,0.1); color: #fca5a5; }
html.dark .alert-warning { background-color: rgba(234,179,8,0.1); color: #fde047; }

html.dark .btn-outline-secondary { border-color: var(--color-border); color: var(--color-text-secondary); }
html.dark .btn-outline-secondary:hover { background-color: rgba(255,255,255,0.06); color: var(--color-text); border-color: var(--color-border); }

html.dark .text-muted { color: var(--color-text-muted) !important; }
html.dark .btn-close { color:white };

/* THEME CUSTOMIZER */
.customizer-offcanvas { width: 280px; border-left: 1px solid var(--color-border); }
html.dark .customizer-offcanvas { background-color: black; border-color: var(--color-border); }

.customizer-section { margin-bottom: 0.25rem; }

.customizer-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
}

.customizer-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }

.customizer-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem 0.5rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.customizer-option:hover { border-color: var(--color-accent-primary); color: var(--color-text); }

.customizer-option.is-active {
    border-color: var(--color-accent-primary);
    background-color: color-mix(in srgb, var(--color-accent-primary) 8%, transparent);
    color: var(--color-accent-primary);
}

.customizer-option-icon { font-size: 1rem; }

.customizer-color-dot { width: 22px; height: 22px; border-radius: 50%; display: block; }

.customizer-option.is-active .customizer-color-dot {
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent-primary);
}

.customizer-divider { border-color: var(--color-border); margin: 1.25rem 0; }

html.dark .customizer-option { color: var(--color-text-secondary); }
html.dark .customizer-option:hover { color: var(--color-text); }

/* PROFIL UŻYTKOWNIKA */
.profile-settings {
    max-width: 1000px;
}

/* Nagłówek strony - profil */
.profile-settings-header {
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.profile-settings-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.profile-settings-desc {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 0;
}

/* Layout - profil usera */
.profile-settings-body {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
}

/* Lewy sidebar - profil */
.profile-settings-nav {
    width: 180px;
    flex-shrink: 0;
}

.profile-settings-nav-link {
    display: block;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
    margin-bottom: 2px;
}

.profile-settings-nav-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-active-text);
}

.profile-settings-nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--color-accent-primary);
    font-weight: 500;
}

/* Prawa sekcja z formularzem */
.profile-settings-content {
    flex: 1;
    min-width: 0;
    max-width: 520px;
}

/* Sekcja formularza */
.profile-section-header {
    margin-bottom: 1.5rem;
}

.profile-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.profile-section-desc {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 0;
}

.profile-saved-feedback {
    font-size: 0.875rem;
    color: var(--color-success);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.table-toolbar {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.table-toolbar-filters {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: nowrap;
    justify-content: space-between;
}

.table-toolbar-inputs {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: nowrap;
    min-width: 0;
}

.table-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.table-filter-roles {
    width: 200px;
    flex-shrink: 0;
}

.table-filter-status {
    width: 170px;
    flex-shrink: 0;
}

/* Nowoczesny, zwarty pasek filtrów (chip / dropdown) */
.filter-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.filter-bar-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1 1 auto;
}

.filter-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
    margin-left: auto;
}

.filter-chip-select {
    appearance: none;
    -webkit-appearance: none;
    height: 2rem;
    padding: 0 1.75rem 0 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%239ca3af' d='M4.5 6l3.5 3.5L11.5 6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    background-size: 12px;
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    max-width: 180px;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.filter-chip-select:hover {
    border-color: color-mix(in srgb, var(--color-accent-primary) 35%, var(--color-border));
    color: var(--color-text);
}

.filter-chip-select:focus {
    outline: none;
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-primary) 18%, transparent);
}

.filter-chip-select.is-active {
    border-color: color-mix(in srgb, var(--color-accent-primary) 45%, var(--color-border));
    background-color: color-mix(in srgb, var(--color-accent-primary) 10%, var(--color-surface));
    color: var(--color-text);
}

.filter-chip-search {
    position: relative;
    width: 200px;
    flex-shrink: 0;
}

.filter-chip-search > i {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    pointer-events: none;
}

.filter-chip-search input {
    height: 2rem;
    width: 100%;
    padding: 0 0.65rem 0 1.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-chip-search input:focus {
    outline: none;
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-primary) 18%, transparent);
}

.filter-chip-search input.is-active,
.filter-chip-search.is-active input {
    border-color: color-mix(in srgb, var(--color-accent-primary) 45%, var(--color-border));
    background-color: color-mix(in srgb, var(--color-accent-primary) 10%, var(--color-surface));
}

.filter-chip-roles {
    min-width: 200px;
    max-width: 260px;
    flex-shrink: 0;
}

.filter-chip-roles .select2-container {
    width: 100% !important;
}

.filter-chip-roles .select2-container--default .select2-selection--multiple {
    min-height: 2rem;
    border-radius: var(--radius-md);
    border-color: var(--color-border);
}

.filter-chip-toggle {
    cursor: pointer;
    gap: 0.5rem;
    margin: 0;
}

.filter-chip-toggle input {
    margin: 0;
    accent-color: var(--color-accent-primary);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    height: 2rem;
    padding: 0 0.625rem 0 0.625rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.filter-chip:hover,
.filter-chip.show {
    border-color: color-mix(in srgb, var(--color-accent-primary) 35%, var(--color-border));
    color: var(--color-text);
}

.filter-chip.is-active {
    border-color: color-mix(in srgb, var(--color-accent-primary) 45%, var(--color-border));
    background-color: color-mix(in srgb, var(--color-accent-primary) 10%, var(--color-surface));
    color: var(--color-text);
}

.filter-chip-icon {
    font-size: 0.75rem;
    opacity: 0.7;
}

.filter-chip-caret {
    font-size: 0.5625rem;
    opacity: 0.55;
    margin-left: 0.125rem;
}

.filter-chip-value {
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.filter-chip-panel {
    min-width: 260px;
    padding: 0.875rem !important;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.filter-chip-panel-title {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.625rem;
}

.filter-chip-panel-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.filter-chip-panel-field label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.filter-chip-panel-field .form-control {
    font-size: 0.8125rem;
}

.filter-bar-actions .btn {
    height: 2rem;
    padding-top: 0;
    padding-bottom: 0;
    display: inline-flex;
    align-items: center;
    font-size: 0.8125rem;
}

.table-toolbar--filters {
    padding: 0.75rem 1.25rem;
}

.table-sort-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.table-sort-header:hover {
    color: var(--color-accent-primary, var(--bs-primary));
}

.table-sort-icon {
    margin-left: 0.25rem;
    font-size: 0.7em;
    opacity: 0.35;
    vertical-align: middle;
}

.table-sort-header.is-sorted-asc .table-sort-icon,
.table-sort-header.is-sorted-desc .table-sort-icon {
    opacity: 1;
    color: var(--color-accent-primary, var(--bs-primary));
}

.table-filter-roles select[multiple] {
    height: auto;
    min-height: 31px;
}

.table-toolbar-filters .btn {
    flex-shrink: 0;
}

.table-search {
    position: relative;
    max-width: 250px;
    width: 100%;
    flex-shrink: 0;
}

.table-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    pointer-events: none;
}

.table-search-clear {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    text-decoration: none;
    transition: color 0.15s;
}

.table-search-clear:hover {
    color: var(--color-text);
}

.table-search input {
    padding-left: 2.25rem;
    padding-right: 2.25rem;
}

.table-row-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.table-row-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent-primary), color-mix(in srgb, var(--color-accent-primary) 70%, #7c3aed));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.table-row-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text);
    margin: 0;
    line-height: 1.3;
}

.table-row-email {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.3;
}

.table-actions-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.table-actions-btn:hover {
    background-color: var(--color-border-light);
    color: var(--color-text);
}

html.dark .table-actions-btn:hover { background-color: rgba(255,255,255,0.06); }

.table-actions-btn::after { display: none; }

.table-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2.5rem 1rem;
}

.table {
    color: var(--color-text);
    --bs-table-bg: transparent;
}

.table > :not(caption) > * > * {
    background-color: transparent;
    color: var(--color-text);
    border-bottom-color: var(--color-border);
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--sidebar-hover-bg);
    color: var(--color-text);
}

.table thead th {
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom-width: 1px;
    border-color: var(--color-border);
}

html.dark .table-hover > tbody > tr:hover > * {
    background-color: rgba(255,255,255,0.04);
}

.dropdown-menu.show {
    z-index: 1039;
}

.table-row-clickable {
    cursor: pointer;
}

.card-panel .table-responsive {
    overflow: visible;
}

/* modal przydzielania ról */
.assign-roles-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 360px;
}

.assign-roles-left {
    padding: 1.25rem;
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    max-height: 480px;
}

.assign-roles-right {
    padding: 1.25rem;
    overflow-y: auto;
    max-height: 480px;
    background-color: var(--color-border-light);
}

html.dark .assign-roles-right {
    background-color: #0d0d0d;
}

.assign-roles-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: 0.875rem;
}

.assign-roles-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border-light);
}

.assign-roles-item:last-child { border-bottom: none; }

.assign-roles-item .form-check { flex: 1; margin: 0; }

.assign-roles-eye {
    background: none;
    border: none;
    color: var(--color-text-muted);
    padding: 0.25rem 0.375rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    font-size: 0.875rem;
    line-height: 1;
}

.assign-roles-eye:hover { color: var(--color-accent-primary); background-color: var(--color-border-light); }
.assign-roles-eye.is-active { color: var(--color-accent-primary); }
html.dark .assign-roles-eye:hover { background-color: rgba(255,255,255,0.06); }

/* Role */ 
.role-row-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}
 
.role-row-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--color-accent-primary) 12%, transparent);
    color: var(--color-accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}
 
.role-slug {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    background: transparent;
    padding: 0;
}
 
.role-show-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--color-accent-primary) 12%, transparent);
    color: var(--color-accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
}

.role-user-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--color-border-light);
}
 
.role-user-row:last-child {
    border-bottom: none;
}

.role-users-list {
    max-height: 280px;
    overflow-y: auto;
}

.btn-icon-sm {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.role-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent-primary), color-mix(in srgb, var(--color-accent-primary) 70%, #7c3aed));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5625rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
 
.role-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
 
.role-user-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
 
.role-user-email {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-users-hint {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--color-border-light);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
 
html.dark .role-users-hint {
    background: rgba(255,255,255,0.04);
}
 
/* Drzewo uprawnień */
.perm-tree {
    font-size: 0.875rem;
}
 
.perm-tree-node--root {
    margin-bottom: 0.125rem;
}
 
.perm-tree-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.3125rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.1s;
}

html.dark .form-text {
    color:white;
}

.perm-tree-row:hover {
    background: var(--color-border-light);
}
 
html.dark .perm-tree-row:hover {
    background: rgba(255,255,255,0.04);
}
 
/* Przycisk zwijania */
.perm-tree-toggle {
    background: none;
    border: none;
    padding: 0.125rem 0.25rem;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 0.625rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.0625rem;
    transition: color 0.15s, background 0.15s;
}
 
.perm-tree-toggle:hover {
    color: var(--color-text);
    background: var(--color-border);
}
 
.perm-tree-toggle-placeholder {
    width: 20px;
    flex-shrink: 0;
}
 
/* Checkbox w drzewie */
.perm-tree .perm-checkbox {
    margin-top: 0.1875rem;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--color-accent-primary);
}
 
/* Label w drzewie */
.perm-tree-label {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.375rem;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}
 
/* Tryb readonly drzewa uprawnień */
.perm-tree--readonly .perm-tree-label {
    cursor: default;
}
 
.perm-tree-display-name {
    font-weight: 500;
    color: var(--color-text);
}
 
.perm-tree-name {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    background: transparent;
    padding: 0;
    font-family: ui-monospace, 'Cascadia Code', monospace;
}
 
.perm-tree-desc {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    width: 100%;
    line-height: 1.4;
}
 
.perm-tree-status {
    font-size: 0.875rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
}
 
.perm-tree-status--on  { color: #22c55e; }
.perm-tree-status--off { color: var(--color-border); }
 
html.dark .perm-tree-status--off { color: #3a3a3a; }
 
.perm-tree-children {
    padding-left: 1.625rem;
    border-left: 1px dashed var(--color-border);
    margin-left: 0.625rem;
    margin-top: 0.125rem;
    overflow: hidden;
}
 
.perm-tree-children.is-collapsed {
    display: none;
}
 
.perm-tree-node--root + .perm-tree-node--root {
    border-top: 1px solid var(--color-border-light);
    padding-top: 0.25rem;
    margin-top: 0.25rem;
}
 
/* Drzewko uprawnień */
.assign-roles-tree { font-family: var(--font-sans); }

.assign-roles-tree-node {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    padding: 0.1875rem 0;
    line-height: 1.5;
}

.assign-roles-tree-prefix {
    font-family: monospace;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    white-space: pre;
    flex-shrink: 0;
}

.assign-roles-tree-name {
    font-size: 0.8125rem;
    color: var(--color-text);
    font-weight: 500;
}

.assign-roles-tree-slug {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    font-family: monospace;
}

html.dark .modal-content {
    background-color: #141414;
    border-color: var(--color-border);
}

html.dark .modal-header,
html.dark .modal-footer {
    border-color: var(--color-border);
}

/* SELECT2 style */
.select2-container--default .select2-selection--multiple {
    background-color: var(--color-surface);
    border-color: var(--color-border);
    border-radius: var(--radius-sm);
    min-height: 31px;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-primary) 20%, transparent);
    outline: none;
}

/* Badge zaznaczonej opcji */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--color-accent-primary);
    border: none;
    color: #ffffff;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: rgba(255,255,255,0.7);
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #ffffff;
    background: none;
}

/* Dropdown */
.select2-dropdown {
    background-color: var(--color-surface);
    border-color: var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.8125rem;
}

.select2-container--default .select2-results__option {
    padding: 0.4375rem 0.625rem;
    color: var(--color-text);
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--color-accent-primary);
    color: #ffffff;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: var(--sidebar-active-bg);
    color: var(--color-accent-primary);
}

/* Dark mode */
html.dark .select2-container--default .select2-selection--multiple {
    background-color: #333333;
    border-color: var(--color-border);
}

html.dark .select2-search--inline .select2-search__field {
    color: var(--color-text);
}

html.dark .select2-dropdown {
    background-color: #292929;
    border-color: var(--color-border);
}

html.dark .select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: #333333;
    border-color: var(--color-border);
    color: var(--color-text);
}

html.dark .select2-container--default .select2-results__option {
    color: var(--color-text);
}

html.dark .select2-container--default .select2-results__option[aria-selected=true] {
    background-color: var(--sidebar-active-bg);
    color: var(--color-accent-primary);
}

.app-header-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: #dc3545;
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
}

.app-header-notifications .dropdown-item {
    white-space: normal;
}
/* Tooltip renderowany w body przez JS - bez dziedziczenia text-transform z labeli */
.app-floating-tooltip {
    position: fixed;
    z-index: 10000;
    max-width: min(320px, calc(100vw - 1.5rem));
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    background: var(--color-text);
    color: var(--color-bg);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: normal;
    text-transform: none;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, calc(-100% - 8px)) scale(0.96);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.app-floating-tooltip.is-visible {
    opacity: 1;
    transform: translate(-50%, calc(-100% - 8px)) scale(1);
}

/* Bootstrap ustawia cursor:help (znak zapytania) na abbr z title */
abbr[title],
abbr[data-bs-original-title] {
    cursor: inherit;
    text-decoration: none;
}

/* zarządzanie uprawnieniami */
.perm-mgmt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    gap: 1rem;
}

.perm-mgmt-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.perm-mgmt-tree-wrap {
    overflow-y: auto;
    overflow-x: visible;
    max-height: calc(100vh - 220px);
    padding: 0.5rem 0;
}

.perm-mgmt-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
    text-align: center;
}

.perm-mgmt-tree {
    font-size: 0.875rem;
}

.perm-mgmt-node--root {
    border-bottom: 1px solid var(--color-border-light);
    position: relative;
}

.perm-mgmt-node--root:last-child {
    border-bottom: none;
}

.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(1)  { z-index: 100; }
.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(2)  { z-index: 99; }
.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(3)  { z-index: 98; }
.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(4)  { z-index: 97; }
.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(5)  { z-index: 96; }
.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(6)  { z-index: 95; }
.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(7)  { z-index: 94; }
.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(8)  { z-index: 93; }
.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(9)  { z-index: 92; }
.perm-mgmt-tree > .perm-mgmt-node--root:nth-child(10) { z-index: 91; }

.perm-mgmt-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3125rem 1.25rem;
    transition: background 0.1s;
    min-height: 38px;
}

.perm-mgmt-row:hover {
    background: var(--color-border-light);
}

html.dark .perm-mgmt-row:hover {
    background: rgba(255,255,255,0.03);
}

/* Toggle */
.perm-mgmt-toggle {
    background: none;
    border: none;
    padding: 0.125rem 0.25rem;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 0.625rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

.perm-mgmt-toggle:hover {
    color: var(--color-text);
    background: var(--color-border);
}

.perm-mgmt-toggle-ph {
    width: 20px;
    flex-shrink: 0;
}

.perm-mgmt-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.perm-mgmt-display-name {
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
}

.perm-mgmt-name {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    font-family: ui-monospace, 'Cascadia Code', monospace;
    background: transparent;
    padding: 0;
}

.perm-mgmt-group {
    font-size: 0.6875rem;
    color: var(--color-accent-primary);
    background: color-mix(in srgb, var(--color-accent-primary) 10%, transparent);
    padding: 0.0625rem 0.375rem;
    border-radius: 99px;
    font-weight: 500;
}

.perm-mgmt-display-name--inactive {
    text-decoration: line-through;
    color: var(--color-text-muted);
}

/* Route jako klikalny URL */
.perm-mgmt-route-link {
    font-size: 0.6875rem;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    color: var(--color-accent-primary);
    text-decoration: none;
    transition: color 0.15s, text-decoration 0.15s;
}

.perm-mgmt-route-link:hover {
    color: color-mix(in srgb, var(--color-accent-primary) 80%, black);
    text-decoration: underline;
}

html.dark .perm-mgmt-route-link:hover {
    color: white;
}

/* Route którego nie ma w routerze - ostrzeżenie */
.perm-mgmt-route-invalid {
    font-size: 0.6875rem;
    color: #ef4444;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    background: transparent;
    padding: 0;
    opacity: 0.8;
}

/* Akcje */
.perm-mgmt-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.perm-mgmt-row:hover .perm-mgmt-actions {
    opacity: 1;
}

.perm-mgmt-action-btn {
    background: none;
    border: none;
    padding: 0.25rem 0.375rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    transition: color 0.15s, background 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.perm-mgmt-action-btn:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.perm-mgmt-action-btn--danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

html.dark .perm-mgmt-action-btn:hover {
    background: rgba(255,255,255,0.08);
}

/* Dzieci */
.perm-mgmt-children {
    overflow: hidden;
}

.perm-mgmt-children.is-collapsed {
    display: none;
}

.perm-mgmt-children > .perm-mgmt-node > .perm-mgmt-row {
    padding-left: 2.5rem;
}

.perm-mgmt-children > .perm-mgmt-node > .perm-mgmt-children > .perm-mgmt-node > .perm-mgmt-row {
    padding-left: 3.75rem;
}

.perm-mgmt-children > .perm-mgmt-node > .perm-mgmt-children > .perm-mgmt-node > .perm-mgmt-children > .perm-mgmt-node > .perm-mgmt-row {
    padding-left: 5rem;
}

/* Podgląd ikony */
.perm-icon-preview {
    width: 38px;
    justify-content: center;
    color: var(--color-accent-primary);
}

/* BADGE STATUSU (reużywalny) */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 99px;
}

.badge-status--active {
    background: color-mix(in srgb, #22c55e 12%, transparent);
    color: #16a34a;
}

.badge-status--inactive {
    background: color-mix(in srgb, #6b7280 12%, transparent);
    color: #6b7280;
}

html.dark .badge-status--active {
    background: color-mix(in srgb, #22c55e 15%, transparent);
    color: #86efac;
}

html.dark .badge-status--inactive {
    background: color-mix(in srgb, #6b7280 15%, transparent);
    color: #9ca3af;
}

/* FIRMY */
.company-show-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--color-accent-primary) 12%, transparent);
    color: var(--color-accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
}

.company-detail-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.company-detail-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.company-detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    min-width: 60px;
}

.company-detail-value {
    color: var(--color-text);
}

.company-detail-row.is-mismatch {
    border: 1px solid #dc3545;
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    margin-inline: -0.5rem;
}

html.dark .company-detail-row.is-mismatch {
    border-color: #f87171;
}

.alert-compact {
    font-size: 0.8125rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 1rem;
}

.company-detail-link {
    color: var(--color-accent-primary);
    text-decoration: none;
}

.company-detail-link:hover {
    text-decoration: underline;
    color: color-mix(in srgb, var(--color-accent-primary) 80%, black);
}

html.dark .company-detail-link:hover {
    color: white;
}

.company-detail-list--sections {
    gap: 0.7rem;
}

.company-detail-group {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.company-detail-group--grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1.25rem;
}

.company-detail-group--grid .company-detail-row,
.company-detail-group--stack .company-detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.company-detail-group--grid .company-detail-label,
.company-detail-group--stack .company-detail-label {
    min-width: 0;
}

.company-detail-group--stack .company-detail-value,
.company-detail-group--grid .company-detail-value {
    word-break: break-word;
}

.company-detail-separator {
    border: 0;
    height: 1px;
    margin: 0;
    background: var(--color-border);
}

.company-detail-caption {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin: 0.4rem 0 0;
}

.company-detail-caption::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: var(--color-border);
}

.company-detail-caption span {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    line-height: 1.3;
    white-space: nowrap;
}

.card-panel .text-muted,
.company-detail-list .text-muted,
.company-detail-caption span {
    color: var(--color-text-muted) !important;
}

.attachment-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.attachment-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
}

.attachment-row-icon {
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--color-accent-primary) 10%, transparent);
    color: var(--color-accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.attachment-row-body {
    min-width: 0;
    flex: 1;
}

.attachment-row-name {
    display: block;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    word-break: break-word;
}

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

.attachment-row-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.attachment-row-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.attachment-upload .form-control {
    font-size: 0.8125rem;
}

@media (max-width: 575.98px) {
    .company-detail-group--grid {
        grid-template-columns: 1fr;
    }
}

img.locale-flag {
    width: 1.25rem;
    height: 0.875rem;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid var(--color-border);
    vertical-align: -2px;
    display: inline-block;
}

/* Wygląd mobilny, responsywność*/
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-content { margin-left: 0; }
    .app-sidebar-overlay.is-visible { display: block; }
    .app-header-sep { display: none; }
    .app-header-title { display: none; }
}

@media (max-width: 767.98px) {

    .table-mobile-hidden { display: none; }

    .table-toolbar-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .table-toolbar-inputs {
        flex-wrap: wrap;
    }

    .table-toolbar-actions {
        flex-wrap: wrap;
    }

    .table-search {
        max-width: 100%;
        width: 100%;
    }

    .table-filter-roles,
    .table-filter-status {
        width: 100%;
        flex-shrink: unset;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar-controls {
        width: 100%;
    }

    .filter-chip-select,
    .filter-chip {
        flex: 1 1 calc(50% - 0.5rem);
        max-width: none;
        justify-content: space-between;
    }

    .filter-chip-search {
        width: 100%;
        flex: 1 1 100%;
    }

    .filter-chip-roles {
        width: 100%;
        max-width: none;
        flex: 1 1 100%;
    }

    .filter-chip-toggle {
        flex: 1 1 100%;
        justify-content: flex-start;
    }

    .filter-bar-actions {
        width: 100%;
    }

    .filter-bar-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .filter-chip-panel {
        width: min(100vw - 2rem, 280px);
    }

    .profile-settings-body {
        flex-direction: column;
        gap: 0;
    }

    .profile-settings-nav {
        width: 100%;
        margin-bottom: 1.5rem;
        border-bottom: 1px solid var(--color-border);
    }

    .profile-settings-nav nav {
        display: flex;
        flex-direction: row;
        width: 100%;
    }

    .profile-section-desc {
        font-size: 0.7rem;
    }

    .profile-settings-nav-link {
        flex: 1;
        text-align: center;
        white-space: nowrap;
        margin-bottom: 0;
        border-radius: 0;
        border-bottom: 2px solid transparent;
        margin-bottom: -1px;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        background: none;
        font-weight: 500;
        color: var(--color-text-secondary);
        transition: color 0.15s, border-color 0.15s;
    }

    .profile-settings-nav-link:hover {
        background: none;
        color: var(--color-text);
        border-bottom-color: var(--color-border);
    }

    .profile-settings-nav-link.active {
        background: none;
        border-bottom-color: var(--color-accent-primary);
        color: var(--color-accent-primary);
        font-weight: 600;
    }

     .profile-settings-content {
        max-width: 100%;
    }

    .profile-settings-header {
        margin-bottom: 1rem;
        padding-bottom: 0;
        border-bottom: none;
    }

    .assign-roles-layout {
        grid-template-columns: 1fr;
    }

    .assign-roles-left {
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        max-height: 300px;
    }

    .card-panel .table-responsive {
        overflow-x: auto;
    }
}

@media (max-width: 575.98px) {
    .pagination-wrapper {
        flex-direction: column;
        align-items: flex-start !important;
    }
}

/* Preferencje powiadomień - lista SaaS (show użytkownika) */
.notify-pref-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.notify-pref-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 0;
    padding: 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.notify-pref-card:hover {
    border-color: color-mix(in srgb, var(--color-accent-primary) 40%, var(--color-border));
    background: color-mix(in srgb, var(--color-accent-primary) 5%, transparent);
}

.notify-pref-list {
    display: flex;
    flex-direction: column;
    margin-top: 0.75rem;
}

.notify-pref-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.25rem;
    margin: 0;
    border-top: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.notify-pref-row:hover {
    background-color: var(--color-border-light);
}

html.dark .notify-pref-row:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.notify-pref-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--color-accent-primary) 12%, transparent);
    color: var(--color-accent-primary);
    font-size: 0.875rem;
}

.notify-pref-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.notify-pref-title {
    font-size: 0.875rem;
    font-weight: 550;
    color: var(--color-text);
    line-height: 1.3;
}

.notify-pref-desc {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.35;
}

.notify-pref-row .form-switch,
.notify-pref-card .form-switch {
    padding-left: 2.5em;
    flex-shrink: 0;
}

.notify-pref-row .form-switch .form-check-input,
.notify-pref-card .form-switch .form-check-input {
    width: 2.5em;
    height: 1.35em;
    margin: 0;
    cursor: pointer;
}

@media (max-width: 991.98px) {
    .notify-pref-grid {
        grid-template-columns: 1fr;
    }
}

/* Preferencje powiadomień - kompakt w tabeli Moja firma */
.notify-pref-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
}

.notify-pref-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0;
    padding: 0.2rem 0.45rem 0.2rem 0.55rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.notify-pref-pill:hover {
    border-color: color-mix(in srgb, var(--color-accent-primary) 45%, var(--color-border));
    background: color-mix(in srgb, var(--color-accent-primary) 6%, transparent);
}

.notify-pref-pill > span:first-child {
    font-size: 0.6875rem;
    font-weight: 550;
    color: var(--color-text-secondary);
    line-height: 1;
    white-space: nowrap;
}

.notify-pref-pill .form-switch {
    padding-left: 2.1em;
    min-height: 0;
}

.notify-pref-pill .form-switch .form-check-input {
    width: 1.9em;
    height: 1.05em;
    margin: 0;
    cursor: pointer;
}

/* Dropdown waluty / jednostki przyklejony do inputa */
.currency-price-group .js-currency-toggle,
.currency-price-group .js-unit-toggle {
    cursor: pointer;
    user-select: none;
    min-width: 3.5rem;
    justify-content: center;
}

.currency-price-group .js-currency-toggle:disabled,
.currency-price-group .js-unit-toggle:disabled {
    cursor: default;
}

.currency-price-group .js-currency-toggle::after,
.currency-price-group .js-unit-toggle::after {
    margin-left: 0.35rem;
}

.currency-price-group .dropdown-menu {
    min-width: 11rem;
}

/* ==========================================================================
   Wiadomości - układ trzypanelowy
   Odwzorowanie Zenith > Chat (wątek, bąbelki, separatory dat)
   oraz Zenith > Mail (lewy pasek folderów z licznikami).
   ========================================================================== */

.msg-shell {
    /* Lokalne zmienne - dark mode obsłużony w jednym miejscu, bez duplikowania reguł */
    --msg-muted:  var(--color-text-secondary);
    --msg-subtle: var(--color-border-light);

    display: flex;
    height: calc(100vh - 13rem);
    min-height: 32rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

html.dark .msg-shell {
    --msg-muted:  rgba(250, 250, 250, 0.55);
    --msg-subtle: rgba(255, 255, 255, 0.06);
}

/* --- Panel folderów --- */

.msg-folders {
    width: 15rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--color-border);
}

.msg-filter {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.msg-filter-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--msg-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.msg-filter-btn:hover { background: var(--msg-subtle); color: var(--color-text); }

.msg-filter-btn.active {
    background: var(--msg-subtle);
    color: var(--color-text);
    font-weight: 600;
}

.msg-filter-count {
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--color-accent-primary);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
}

.msg-folder-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.msg-folder {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--msg-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.msg-folder:hover { background: var(--msg-subtle); color: var(--color-text); }

.msg-folder.active {
    background: var(--msg-subtle);
    color: var(--color-text);
    font-weight: 600;
}

.msg-folder-icon {
    width: 1rem;
    flex-shrink: 0;
    text-align: center;
    font-size: 0.8125rem;
}

.msg-folder-label { flex: 1; }

.msg-folder-badge {
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    border-radius: 999px;
    background: var(--color-accent-primary);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.msg-folder-total {
    font-size: 0.6875rem;
    color: var(--msg-muted);
    flex-shrink: 0;
}

/* --- Lista rozmów --- */

.msg-list {
    width: 21rem;
    flex-shrink: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--color-border);
}

.msg-list-search {
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.msg-list-search .filter-chip-search { width: 100%; }

.msg-list-items {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.msg-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.15s;
}

.msg-item:hover  { background: var(--msg-subtle); }
.msg-item.active { background: var(--msg-subtle); }

.msg-item.unread .msg-item-name { font-weight: 700; }

.msg-item.unread .msg-item-preview {
    color: var(--color-text);
    font-weight: 500;
}

.msg-avatar {
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--msg-subtle);
    color: var(--color-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.msg-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.msg-item-head,
.msg-item-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.msg-item-name {
    font-size: 0.8125rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-item-time {
    font-size: 0.625rem;
    color: var(--msg-muted);
    flex-shrink: 0;
}

.msg-item-context {
    font-size: 0.6875rem;
    color: var(--msg-muted);
}

.msg-item-preview {
    font-size: 0.75rem;
    color: var(--msg-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-item-dot {
    width: 0.5rem;
    height: 0.5rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--color-accent-primary);
}

.msg-list-empty {
    margin: 0;
    padding: 1.5rem 0.75rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--msg-muted);
}

.msg-list-pagination {
    padding: 0.5rem;
    border-top: 1px solid var(--color-border);
}

.msg-list-pagination .pagination {
    margin-bottom: 0;
    justify-content: center;
}

.msg-list-pagination p { display: none; }

/* --- Wątek --- */

.msg-thread {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.msg-thread-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.msg-thread-back {
    display: none;
    color: var(--msg-muted);
    text-decoration: none;
}

.msg-thread-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.msg-thread-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-thread-sub {
    font-size: 0.75rem;
    color: var(--msg-muted);
}

.msg-thread-sub a {
    color: var(--color-accent-primary);
    text-decoration: none;
}

.msg-thread-sub a:hover { text-decoration: underline; }

.msg-thread-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}

.msg-thread-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.msg-thread-empty {
    margin: auto;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--msg-muted);
}

.msg-date {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.25rem 0;
}

.msg-date-line {
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

.msg-date-label {
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--msg-muted);
}

.msg-row { display: flex; justify-content: flex-start; }
.msg-row--own { justify-content: flex-end; }

.msg-bubble-wrap {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.msg-row--own .msg-bubble-wrap { align-items: flex-end; }

.msg-bubble-author {
    padding: 0 0.25rem;
    margin-bottom: 0.125rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--msg-muted);
}

.msg-bubble {
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-xl);
    border-bottom-left-radius: var(--radius-md);
    background: var(--msg-subtle);
    color: var(--color-text);
    font-size: 0.8125rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.msg-bubble--own {
    background: var(--color-accent-primary);
    color: #fff;
    border-bottom-left-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-md);
}

.msg-bubble-meta {
    padding: 0 0.25rem;
    margin-top: 0.125rem;
    font-size: 0.625rem;
    color: var(--msg-muted);
}

.msg-system { display: flex; justify-content: center; }

.msg-system-pill {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: var(--msg-subtle);
    color: var(--msg-muted);
    font-size: 0.6875rem;
}

/* --- Pole wysyłania --- */

.msg-composer {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
}

.msg-composer-input {
    flex: 1;
    resize: none;
    min-height: 2.5rem;
    max-height: 7.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.msg-composer-input:focus {
    outline: none;
    border-color: var(--color-accent-primary);
}

.msg-composer-send { flex-shrink: 0; }

.msg-composer-error {
    margin: 0;
    padding: 0 1rem 0.75rem;
    color: #dc3545;
    font-size: 0.75rem;
}

.msg-composer-notice {
    margin: 0;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
    color: var(--msg-muted);
    font-size: 0.75rem;
}

/* --- Stan pusty --- */

.msg-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.msg-empty-icon {
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.75rem;
    border-radius: 50%;
    background: var(--msg-subtle);
    color: var(--msg-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.msg-empty-title {
    margin: 0 0 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.msg-empty-text {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--msg-muted);
}

/* --- Mobile: jeden panel naraz, foldery jako pasek poziomy --- */

@media (max-width: 991.98px) {
    .msg-shell {
        flex-direction: column;
        height: auto;
        min-height: 0;
    }

    .msg-folders {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

    .msg-folder-nav {
        flex-direction: row;
        gap: 0.25rem;
        overflow-x: auto;
    }

    .msg-folder { white-space: nowrap; }

    .msg-list {
        width: 100%;
        border-right: none;
    }

    .msg-list-items  { max-height: 60vh; }
    .msg-thread-body { max-height: 60vh; }

    .msg-thread-back { display: inline-flex; }

    .msg-shell--open .msg-list { display: none; }
    .msg-shell:not(.msg-shell--open) .msg-thread { display: none; }
}

/* ORDER LIFELINE */
.order-lifeline-panel .card-panel-header {
    padding: 0.75rem 1.25rem;
}

.order-lifeline-body {
    padding: 1.1rem 1.25rem 1rem;
}

.order-lifeline-caption {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.order-lifeline {
    position: relative;
    padding: 0.35rem 0.75rem 0;
}

.order-lifeline-track {
    position: relative;
    height: 2px;
    background: var(--color-border);
    margin: 1.15rem 0.5rem 0;
    border-radius: 999px;
}

.order-lifeline-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--color-accent-primary);
    border-radius: 999px;
    transition: width 0.45s ease;
}

.order-lifeline-node {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.order-lifeline-dot {
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    box-shadow: 0 0 0 3px var(--color-surface);
}

.order-lifeline-node.is-done .order-lifeline-dot {
    background: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
}

.order-lifeline-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-accent-primary);
    font-size: 0.7rem;
    box-shadow: var(--shadow-sm);
}

.order-lifeline-labels {
    position: relative;
    min-height: 3.1rem;
    margin: 0.85rem 0.5rem 0;
}

.order-lifeline-label {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    width: 7.5rem;
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.25;
    color: var(--color-text-muted);
}

.order-lifeline-label.is-done {
    color: var(--color-text);
    font-weight: 600;
}

.order-lifeline-label.is-first {
    transform: none;
    text-align: left;
    width: auto;
    max-width: 7.5rem;
}

.order-lifeline-label.is-last {
    transform: translateX(-100%);
    text-align: right;
    width: auto;
    max-width: 7.5rem;
}

.order-lifeline-label small {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--color-text-muted);
}

.order-lifeline-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.order-lifeline-waiting {
    margin-right: auto;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

.table-status-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.badge-delayed {
    background: #fff4e5;
    color: #b45309;
    font-weight: 600;
    margin-left: 0;
}

html.dark .badge-delayed {
    background: color-mix(in srgb, #fd7e14 22%, transparent);
    color: #fdba74;
}

@media (max-width: 767.98px) {
    .order-lifeline {
        overflow-x: auto;
        padding-bottom: 0.25rem;
    }

    .order-lifeline-track,
    .order-lifeline-labels {
        min-width: 36rem;
    }
}

.api-token-prefix,
.api-ability-code {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.api-ability-group-title {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.api-secret-box {
    background: color-mix(in srgb, #f59e0b 12%, var(--color-surface, #fff));
    border: 1px solid color-mix(in srgb, #f59e0b 35%, var(--color-border));
    border-radius: 0.75rem;
    padding: 1.25rem;
}

html.dark .api-secret-box {
    background: color-mix(in srgb, #f59e0b 14%, #1a1a1a);
}

.api-example {
    background: var(--color-bg, #f6f6f6);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

html.dark .api-example {
    background: #141414;
}

.api-docs-swagger {
    background: #fff;
    color: #3b4151;
    min-height: 0;
    isolation: isolate;
}

.api-docs-swagger .swagger-ui {
    color: #3b4151;
}

.api-docs-swagger .swagger-ui .topbar {
    display: none;
}

.api-docs-swagger .swagger-ui .information-container.wrapper {
    padding-top: 1.25rem;
}

.api-docs-swagger .swagger-ui .scheme-container {
    box-shadow: none;
    background: #f8fafc;
    min-height: 0;
    padding: 0.75rem 1.25rem;
    margin: 0;
}

.api-docs-swagger .swagger-ui .scheme-container .schemes {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    min-height: 0;
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: none;
    flex: none;
}

.api-docs-swagger .swagger-ui .scheme-container .auth-wrapper {
    min-height: 0;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0;
}

.api-docs-swagger .swagger-ui .scheme-container .btn.authorize {
    width: auto;
    min-height: 0;
    padding: 0.35rem 0.75rem;
}

html.dark .api-docs-swagger {
    background: #fff;
    color: #3b4151;
}

html.dark .api-docs-swagger h1,
html.dark .api-docs-swagger h2,
html.dark .api-docs-swagger h3,
html.dark .api-docs-swagger h4,
html.dark .api-docs-swagger h5,
html.dark .api-docs-swagger h6,
html.dark .api-docs-swagger p,
html.dark .api-docs-swagger a,
html.dark .api-docs-swagger span,
html.dark .api-docs-swagger label,
html.dark .api-docs-swagger li,
html.dark .api-docs-swagger td,
html.dark .api-docs-swagger th,
html.dark .api-docs-swagger small {
    color: #3b4151;
}

html.dark .api-docs-swagger .form-control,
html.dark .api-docs-swagger input,
html.dark .api-docs-swagger select,
html.dark .api-docs-swagger textarea {
    background-color: #fff;
    color: #3b4151;
    border-color: #d1d5db;
}

.api-docs-swagger .collapse:not(.show) {
    display: revert !important;
    height: auto !important;
    visibility: visible !important;
}
