/* ==========================================
   BASE ART SYSTEM — Styl globalny
   ========================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

/* --- CSS Variables — Dark Mode (domyślny) --- */
:root {
    --color-primary:        #F5B800;
    --color-primary-dark:   #D4A000;
    --color-primary-light:  #FFD740;
    --color-primary-glow:   rgba(245, 184, 0, 0.15);

    --color-bg:             #0A0A0A;
    --color-bg-light:       #111111;
    --color-bg-card:        #161616;
    --color-bg-card-hover:  #1C1C1C;
    --color-sidebar:        #0D0D0D;

    --color-text:           #E8E8E8;
    --color-text-muted:     #888888;
    --color-text-light:     #AAAAAA;
    --color-white:          #FFFFFF;

    --color-border:         #222222;
    --color-border-light:   #333333;

    --color-success:        #22C55E;
    --color-success-bg:     rgba(34, 197, 94, 0.1);
    --color-danger:         #EF4444;
    --color-danger-bg:      rgba(239, 68, 68, 0.1);
    --color-warning:        #F5B800;
    --color-warning-bg:     rgba(245, 184, 0, 0.1);
    --color-info:           #3B82F6;
    --color-info-bg:        rgba(59, 130, 246, 0.1);

    --font-heading:         'Montserrat', sans-serif;
    --font-body:            'Inter', sans-serif;

    --radius-sm:            6px;
    --radius-md:            12px;
    --radius-lg:            16px;
    --radius-xl:            24px;

    --shadow-sm:            0 2px 8px rgba(0,0,0,0.3);
    --shadow-md:            0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg:            0 8px 40px rgba(0,0,0,0.5);

    --transition:           0.25s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width:        260px;
    --topbar-height:        64px;
    --bottom-nav-height:    58px;
}

/* --- Light Mode override --- */
body.light-mode {
    --color-bg:             #F0F2F5;
    --color-bg-light:       #E8EAED;
    --color-bg-card:        #FFFFFF;
    --color-bg-card-hover:  #F8F9FA;
    --color-sidebar:        #1A1A2E;

    --color-text:           #1A1A1A;
    --color-text-muted:     #6B7280;
    --color-text-light:     #9CA3AF;

    --color-border:         #E5E7EB;
    --color-border-light:   #D1D5DB;

    --shadow-sm:            0 2px 8px rgba(0,0,0,0.08);
    --shadow-md:            0 4px 24px rgba(0,0,0,0.1);
    --shadow-lg:            0 8px 40px rgba(0,0,0,0.15);
}

/* Light mode: --color-white used for text in main content becomes dark
   (sidebar keeps its own dark bg so white text there is fine) */
body.light-mode .main-content {
    --color-white: #111111;
}

/* Light mode: elementy poza .main-content (dropdowny, notyfikacje) */
body.light-mode .user-dropdown-name { color: #111111; }
body.light-mode .notif-title { color: #111111; }
/* Sidebar pozostaje ciemny, ale sidebar-user-name używa --color-text → trzeba zostawić białe */
body.light-mode .sidebar-user-name { color: #FFFFFF; }

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

html { font-size: 16px; scroll-behavior: smooth; overflow-x: hidden; }

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
    /* Wiele stron ma szersze od ekranu elementy (tabele, kalendarz) — bez tego cała strona
       (a razem z nią position:fixed/sticky topbar i dolny pasek) skacze w bok na telefonie
       zamiast trzymać się ekranu. Elementy, które faktycznie muszą przewijać się w poziomie
       (np. .table-responsive, .cal-scroll), mają własne overflow-x i działają bez zmian. */
    overflow-x: hidden;
}

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

img { max-width: 100%; display: block; }

/* --- Layout: Sidebar + Main --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ==========================================
   SIDEBAR
   ========================================== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(245, 184, 0, 0.4));
}

.sidebar-logo-text {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--color-white);
}

.sidebar-logo-text span {
    color: var(--color-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    padding: 16px 20px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0;
    transition: all var(--transition);
    position: relative;
    cursor: pointer;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: var(--color-text);
    background: rgba(255,255,255,0.04);
}

body.light-mode .nav-item:hover {
    color: #FFFFFF;
}

.nav-item.active {
    color: var(--color-primary);
    background: var(--color-primary-glow);
    border-left-color: var(--color-primary);
}

.nav-item.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }

/* Sidebar — accordion z podstronami */
.nav-group-arrow {
    margin-left: auto;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    opacity: 0.5;
}
.nav-group.open > .nav-group-toggle .nav-group-arrow {
    transform: rotate(90deg);
}
.nav-group-toggle { user-select: none; }
.nav-sub-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.nav-group.open > .nav-sub-list {
    max-height: 500px;
}
.nav-sub-list .nav-item {
    padding-left: 46px;
    font-size: 0.84rem;
}

.nav-badge {
    margin-left: auto;
    background: var(--color-primary);
    color: #000;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}

.nav-badge.badge-danger {
    background: var(--color-danger);
    color: #fff;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8rem;
    color: #000;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ==========================================
   MAIN CONTENT
   ========================================== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    min-width: 0;
    max-width: calc(100vw - var(--sidebar-width));
    display: flex;
    flex-direction: column;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    /* position:sticky TU NIE DZIAŁA — zmierzone empirycznie (CDP, getBoundingClientRect po
       scrollu): mimo poprawnego computed style (position:sticky, top:0) element przesuwał się
       1:1 ze scrollem zamiast się przykleić (zgłoszone 2026-10-02, "topbar ma być przypięty
       jak dolny pasek na mobile"). .user-dropdown i .notif-dropdown od dawna są position:fixed
       z top:var(--topbar-height), czyli implicitly ZAKŁADAŁY że topbar jest fixed — to utwierdza,
       że fixed było właściwym zamiarem od początku. Rozwiązanie: fixed zamiast sticky (ten sam
       mechanizm co już działający .mobile-bottom-nav), z left:var(--sidebar-width) na desktopie
       (patrz override left:0 w @media max-width:768px, zgodnie z .main-content margin-left:0 tam).
       .page-content dostaje margin-top:var(--topbar-height) żeby skompensować usunięcie topbara
       z normalnego przepływu dokumentu. */
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 100;
}

.topbar-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-white);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Breadcrumb in page content */
.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.bc-item {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    text-decoration: none;
    white-space: nowrap;
    font-weight: 500;
    transition: color 0.15s;
}
.bc-item:hover { color: var(--color-primary); }
.bc-sep { color: var(--color-border-light); font-size: 0.75rem; flex-shrink: 0; }
.bc-current { overflow: hidden; text-overflow: ellipsis; }
.bc-current:hover { color: var(--color-text-muted); cursor: default; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon-only {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-icon-only:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: var(--color-primary-glow);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: all var(--transition);
}
.topbar-user:hover { border-color: var(--color-primary-light); }
.topbar-user-name { font-size: 0.85rem; font-weight: 600; color: var(--color-text); }

.topbar-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #000;
}

/* Global topbar user widget (rendered via sidebar.php, moved into topbar by JS) */
.topbar-user-wrap {
    display: none;
}
.user-dropdown {
    display: none;
    position: fixed;
    right: 20px;
    top: var(--topbar-height);
    z-index: 300;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    min-width: 210px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dropdown-header { padding: 16px; border-bottom: 1px solid var(--color-border); }
.user-dropdown-name { font-weight: 600; color: var(--color-white); font-size: 0.9rem; }
.user-dropdown-email { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 2px; }
.user-dropdown-body { padding: 8px 0; }
.user-dropdown-logout {
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--color-danger);
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background var(--transition);
}
.user-dropdown-logout:hover { background: var(--color-danger-bg); }
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--color-text);
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition);
}
.user-dropdown-item:hover { background: var(--color-bg-hover); color: var(--color-text); }
.user-dropdown-divider { height: 1px; background: var(--color-border); margin: 4px 0; }

/* Hamburger for mobile */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    padding: 4px;
}

/* --- Page content --- */
.page-content {
    padding: 28px;
    flex: 1;
    /* Kompensacja za .topbar: position:fixed (patrz komentarz tam) wyjmuje go z normalnego
       przepływu dokumentu, więc bez tego treść strony chowałaby się pod nim na starcie. */
    margin-top: var(--topbar-height);
}

/* --- Dolna nawigacja (mobile only, jak w aplikacjach mobilnych) --- */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--bottom-nav-height);
    background: var(--color-bg-card);
    border-top: 1px solid var(--color-border);
    z-index: 150;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
}
.mobile-bottom-nav-inner {
    display: flex;
    height: var(--bottom-nav-height);
}
.mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.66rem;
    font-weight: 600;
}
.mobile-bottom-nav-item svg { width: 20px; height: 20px; }
.mobile-bottom-nav-item.active { color: var(--color-primary); }

.page-header {
    margin-bottom: 28px;
}

.page-header-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--color-white);
    margin-bottom: 4px;
}

.page-header-subtitle {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* ==========================================
   CARDS
   ========================================== */
.card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.card-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-white);
}

.card-body { padding: 24px; }

/* Section heading — full-width divider inside a card (settings, forms) */
.section-heading {
    padding: 9px 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    background: var(--color-bg-light);
    border-bottom: 1px solid var(--color-border);
}
.section-heading:not(:first-child) {
    border-top: 1px solid var(--color-border);
}
/* Padded content area inside a card section */
.card-form { padding: 20px 24px; }

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-md);
    background: var(--color-primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    flex-shrink: 0;
}

.stat-icon.icon-blue  { background: rgba(59,130,246,0.15); color: #3B82F6; }
.stat-icon.icon-green { background: rgba(34,197,94,0.15);  color: #22C55E; }
.stat-icon.icon-red   { background: rgba(239,68,68,0.15);  color: #EF4444; }
.stat-icon.icon-purple{ background: rgba(168,85,247,0.15); color: #A855F7; }

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-white);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ==========================================
   TABLES
   ========================================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
    color: var(--color-text);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover { background: rgba(255,255,255,0.02); }
body.light-mode tbody tr:hover { background: rgba(0,0,0,0.02); }

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-cell-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #000;
    flex-shrink: 0;
}

.user-cell-name { font-weight: 600; color: var(--color-white); }
body.light-mode .user-cell-name { color: var(--color-text); }
.user-cell-email { font-size: 0.8rem; color: var(--color-text-muted); }

/* ==========================================
   BADGES
   ========================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-admin   { background: var(--color-primary-glow); color: var(--color-primary); }
.badge-user    { background: var(--color-info-bg); color: var(--color-info); }
.badge-active  { background: var(--color-success-bg); color: var(--color-success); }
.badge-inactive{ background: rgba(107,114,128,0.15); color: #6B7280; }

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--color-primary);
    color: #000;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-light); color: #000; }

.btn-outline {
    background: transparent;
    color: var(--color-text-light);
    border-color: var(--color-border);
}
.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-glow);
}

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

.btn-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border-color: var(--color-success);
}

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-icon-btn {
    width: 34px; height: 34px;
    padding: 0;
    justify-content: center;
}

/* ==========================================
   FORMS
   ========================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-white);
}
body.light-mode .form-group label { color: var(--color-text); }

.form-control {
    width: 100%;
    padding: 11px 14px;
    background: #2f2f2f;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all var(--transition);
}
body.light-mode .form-control {
    background: #ffffff;
    border-color: #C4CAD4;
    color: var(--color-text);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

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

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 5px;
}

.form-error {
    font-size: 0.8rem;
    color: var(--color-danger);
    margin-top: 5px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ==========================================
   ALERTS
   ========================================== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    border: 1px solid;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success { background: var(--color-success-bg); border-color: var(--color-success); color: var(--color-success); }
.alert-danger, .alert-error   { background: var(--color-danger-bg);  border-color: var(--color-danger);  color: var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); border-color: var(--color-warning); color: var(--color-warning); }
.alert-info    { background: var(--color-info-bg);    border-color: var(--color-info);    color: var(--color-info); }

/* ==========================================
   MODAL
   ========================================== */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-backdrop.active { display: flex; }

.modal {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-white);
}
body.light-mode .modal-title { color: var(--color-text); }

.modal-close {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { color: var(--color-danger); border-color: var(--color-danger); }
.modal-close.btn  { width: auto; height: auto; }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ==========================================
   LOGIN PAGE
   ========================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    position: relative;
    overflow: hidden;
}

.login-bg-glow {
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(245,184,0,0.06) 0%, transparent 70%);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.login-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo-img {
    width: 56px; height: 56px;
    object-fit: contain;
    margin: 0 auto 12px;
    filter: drop-shadow(0 0 12px rgba(245,184,0,0.5));
}

.login-logo-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-white);
}
.login-logo-title span { color: var(--color-primary); }

.login-logo-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.login-form h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-white);
    margin-bottom: 24px;
}
body.light-mode .login-form h2 { color: var(--color-text); }

/* ==========================================
   UTILITIES
   ========================================== */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-center { text-align: center; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.font-heading { font-family: var(--font-heading); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
}
.empty-state-icon {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    opacity: 0.3;
}
.empty-state-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-light);
    margin-bottom: 8px;
}

/* Separator */
.divider {
    height: 1px;
    background: var(--color-border);
    margin: 20px 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ==========================================
   LAYOUT UTILITIES
   ========================================== */
/* Responsive 2-column grid (wide|narrow) */
.grid-2col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}
/* Responsive 1-1 grid */
.grid-1-1 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* ==========================================
   PAGINATION
   ========================================== */
.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}
.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-bg-card);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
    cursor: pointer;
    user-select: none;
}
.pagination a:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}
.pagination .active {
    background: var(--color-primary);
    color: #000;
    border-color: var(--color-primary);
    font-weight: 700;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--color-primary) 35%, transparent);
}
.pagination .active:hover {
    background: var(--color-primary);
    color: #000;
}
.pagination .disabled {
    opacity: 0.3;
    pointer-events: none;
    cursor: default;
}
/* Nav arrows slightly smaller text */
.pagination a:first-child,
.pagination a:last-child,
.pagination a:nth-child(2),
.pagination a:nth-last-child(2) {
    font-size: 1rem;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

/* --- Węższy desktop / laptop (np. MacBook) — tabele mają się KURCZYĆ do szerokości
   ekranu, nigdy nie przewijać w poziomie (ani strona, ani kontener tabeli). Poniżej
   1500px zwężamy nagłówki (mogą się zawinąć) i paddingi. Kolumny z liczbami zostają
   nowrap (ustawiane lokalnie na stronach), żeby kwoty się nie łamały. --- */
@media (max-width: 1500px) {
    th { white-space: normal; padding: 9px 10px; font-size: 0.7rem; line-height: 1.25; }
    td { padding: 10px 10px; font-size: 0.84rem; }
}

/* Gęste tabele analityczne (Analiza finansowa, Raport wydarzeń, Analiza klientów —
   klasy .report-scroll/.report-table zduplikowane w 3 plikach, więc reguła globalna).
   Poniżej 1600px: bez poziomego scrolla — stały layout kolumn + skracanie za długiej
   treści wielokropkiem zamiast rozpychania tabeli. */
@media (max-width: 1600px) {
    .report-scroll { overflow-x: hidden !important; }
    .report-table  { min-width: 0 !important; table-layout: fixed; }
    .report-table th, .report-table td {
        white-space: normal !important;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 6px 6px !important;
        font-size: 0.76rem !important;
    }
    .report-table th a { white-space: normal !important; }
}

/* Bardzo wąski ekran — zwykłe listy (.table-responsive) NIGDY nie przewijają w poziomie:
   stały layout kolumn + skracanie za długiej treści wielokropkiem. Gęste tabele analityczne
   (.report-table/.settle-table/.wm-table/.data-table) mają własne, osobne reguły wyżej i nie są
   opakowane w .table-responsive, więc ten selektor ich nie łapie. */
@media (max-width: 1080px) {
    .table-responsive { overflow-x: hidden; }
    .table-responsive > table,
    .table-responsive > form > table {
        table-layout: fixed;
        width: 100%;
    }
    .table-responsive > table th, .table-responsive > table td,
    .table-responsive > form > table th, .table-responsive > form > table td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .main-content {
        margin-left: 0;
        max-width: 100vw;
    }
    .menu-toggle { display: flex; }
    .mobile-bottom-nav { display: block; }
    /* Banner zgody na push jest też position:fixed;bottom:0 — bez tego nakładałby się na dolną nawigację */
    #push-consent-banner { bottom: var(--bottom-nav-height) !important; }
    /* Dodatkowy odstęp na dole, żeby stały dolny pasek nawigacji (kokpit/kalendarz/rozliczenia)
       nigdy nie zasłaniał treści na końcu strony. */
    .page-content { padding: 16px 16px calc(16px + var(--bottom-nav-height)) 16px; }
    .topbar { padding: 0 16px; gap: 8px; left: 0; }
    /* Standaryzacja mobilnego topbara: każda z ~75 stron ma własny, ręcznie pisany
       .topbar-actions z inną liczbą przycisków (Dodaj, Historia, Eksportuj, Anuluj, motyw...),
       przez co pasek bywał ucięty/przewijany. Na mobile zostaje tylko esencja — dzwonek
       powiadomień i widget użytkownika (oba mają stałe id, wstrzykiwane przez notifications.js
       i system.js) — reszta znika, niezależnie od tego co dana strona doda do topbar-actions. */
    .topbar-actions > *:not(#notif-bell-wrap):not(#topbar-user) { display: none !important; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .login-card { padding: 32px 24px; }

    /* Collapse equal-column grids on mobile */
    .grid-1-1 { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
    /* Collapse all multi-column layouts on phones */
    .grid-2col { grid-template-columns: 1fr; }

    /* Stat cards: neat uniform grid (3 equal columns) instead of free-wrapping chips */
    .stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
    .stat-card {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 4px;
        padding: 10px 4px;
    }
    .stat-card:hover { transform: none; box-shadow: none; }
    .stat-icon { width: 26px; height: 26px; border-radius: 8px; }
    .stat-icon svg { width: 13px; height: 13px; }
    .stat-value { font-size: 0.95rem; line-height: 1.1; }
    .stat-label { font-size: 0.56rem; margin-top: 0; line-height: 1.2; }

    /* Page header: stack on mobile */
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}

@media (max-width: 480px) {
    .topbar-user-name { display: none; }
    /* Ta reguła nadpisywała padding z bloku @media(max-width:768px), który rezerwuje miejsce
       na dolny pasek nawigacji (Kokpit/Kalendarz/Rozliczenia) — a niemal każdy telefon w pionie
       ma szerokość ≤480px, więc w praktyce ZAWSZE wygrywała, zasłaniając dół treści na każdej
       stronie. Trzeba tu też doliczyć --bottom-nav-height, nie tylko zresetować na płaskie 12px. */
    .page-content { padding: 12px 12px calc(12px + var(--bottom-nav-height)) 12px; }
    .card-body { padding: 16px; }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
}
.sidebar-overlay.active { display: block; }

/* ================================================================
   Notification Bell & Dropdown
   ================================================================ */
.notif-dropdown {
    display: none;
    position: fixed;
    right: 60px;
    top: var(--topbar-height);
    z-index: 300;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    width: 340px;
    max-width: calc(100vw - 32px);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    flex-direction: column;
}
.notif-dropdown.open { display: flex; }
.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.notif-list {
    overflow-y: auto;
    max-height: 420px;
}
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background .12s;
}
.notif-item:hover { background: var(--color-bg-hover); }
.notif-item.read { opacity: .65; }
.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    flex-shrink: 0;
    margin-top: 5px;
    transition: opacity .15s;
}
.notif-item.read .notif-dot { background: transparent; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 0.85rem; font-weight: 600; color: var(--color-white); margin-bottom: 2px; }
.notif-body  { font-size: 0.78rem; color: var(--color-text-muted); line-height: 1.4; }
.notif-time  { font-size: 0.7rem; color: var(--color-text-muted); margin-top: 4px; }
.notif-empty { padding: 32px; text-align: center; color: var(--color-text-muted); font-size: 0.85rem; }
.notif-load-more {
    display: block;
    width: 100%;
    padding: 10px;
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
}
.notif-load-more:hover { background: var(--color-bg-hover); }

@media (max-width: 480px) {
    .notif-dropdown { right: 8px; width: calc(100vw - 16px); }
}

/* Alternating table rows */
.eq-row-alt { background: rgba(255,255,255,0.03); }
body.light-mode .eq-row-alt { background: rgba(0,0,0,0.04); }
