:root {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --card: #ffffff;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: #22d3ee;
    --text: #1e293b;
    --muted: #64748b;
    --danger: #ef4444;
    --ok: #16a34a;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(2, 6, 23, .15);
    --sidebar-w: 248px;
    --sidebar-collapsed: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: #f1f5f9;
}

/* ---------- Strony auth ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);
    padding: 20px;
}

.auth-card {
    background: var(--card);
    width: 100%;
    max-width: 400px;
    padding: 38px 34px;
    border-radius: 22px;
    box-shadow: var(--shadow);
    animation: pop .4s ease;
}

@keyframes pop {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.brand { text-align: center; margin-bottom: 26px; }
.brand-icon { font-size: 42px; display: inline-block; }
.brand h1 { font-size: 26px; margin-top: 6px; letter-spacing: -.5px; }
.brand-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 14px;
}

input[type=text], input[type=password], input[type=date], input[type=number] {
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    transition: border .2s, box-shadow .2s;
    background: #f8fafc;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .15);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 22px;
    border-radius: 12px;
    transition: transform .12s, box-shadow .2s, background .2s;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; margin-top: 6px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(99, 102, 241, .5); }

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

.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.auth-switch a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.flash {
    padding: 11px 14px;
    border-radius: 11px;
    font-size: 14px;
    margin-bottom: 14px;
    font-weight: 500;
}
.flash-error { background: #fee2e2; color: #b91c1c; }
.flash-success { background: #dcfce7; color: #15803d; }

/* ---------- Layout aplikacji ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #1e293b, #0f172a);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    transition: width .28s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.layout.collapsed .sidebar { width: var(--sidebar-collapsed); }

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 20px;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}
.sidebar-title { transition: opacity .2s; }
.layout.collapsed .sidebar-title { opacity: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 12px;
    border-radius: 12px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    transition: background .18s, color .18s;
}
.nav-item:hover { background: rgba(148, 163, 184, .15); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-ico { font-size: 18px; min-width: 22px; text-align: center; }
.nav-label { transition: opacity .2s; }
.layout.collapsed .nav-label { opacity: 0; pointer-events: none; }
.sidebar-foot { border-top: 1px solid rgba(148,163,184,.15); padding-top: 10px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.5);
    z-index: 15;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    padding: 14px 24px;
    box-shadow: 0 1px 6px rgba(2,6,23,.06);
    position: sticky;
    top: 0;
    z-index: 5;
}
.hamburger {
    border: none;
    background: #f1f5f9;
    width: 42px; height: 42px;
    border-radius: 11px;
    font-size: 20px;
    cursor: pointer;
    transition: background .2s;
}
.hamburger:hover { background: #e2e8f0; }
.topbar-title { font-size: 19px; flex: 1; }
.user-chip { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; }
.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
}

.content { padding: 26px; max-width: 1000px; width: 100%; margin: 0 auto; }

/* ---------- Statystyki ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius);
    color: #fff;
    box-shadow: var(--shadow);
}
.stat-1 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.stat-2 { background: linear-gradient(135deg, #06b6d4, #22d3ee); }
.stat-3 { background: linear-gradient(135deg, #f59e0b, #f97316); }
.stat-ico { font-size: 30px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 13px; opacity: .9; }

/* ---------- Karty ---------- */
.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: 0 4px 16px rgba(2,6,23,.06);
    margin-bottom: 22px;
}
.card-title { font-size: 17px; margin-bottom: 16px; }

.entry-form .form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.entry-form label { margin-bottom: 0; flex: 1; min-width: 150px; }
.entry-form label.grow { flex: 2; }

/* ---------- Tabela ---------- */
.table-wrap { overflow-x: auto; }
.entries { width: 100%; border-collapse: collapse; }
.entries th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    padding: 10px 12px;
    border-bottom: 2px solid #f1f5f9;
}
.entries td { padding: 13px 12px; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.entries tr:hover td { background: #f8fafc; }
.text-right { text-align: right; }
.badge-date {
    background: #eef2ff;
    color: var(--primary-dark);
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
}

.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty-ico { font-size: 44px; margin-bottom: 10px; }

/* ---------- Zarobek na żywo ---------- */
.live-earn-tile {
    margin-bottom: 22px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.live-earn-btn-today { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.live-earn-btn-today:hover { box-shadow: 0 10px 24px rgba(99,102,241,.35); }
.live-earn-btn {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    padding: 22px 24px;
    border: none;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    text-align: left;
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s;
}
.live-earn-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(5,150,105,.35); }
.live-earn-ico { font-size: 34px; }
.live-earn-text { display: flex; flex-direction: column; gap: 4px; }
.live-earn-title { font-size: 19px; font-weight: 700; }
.live-earn-sub { font-size: 13px; opacity: .9; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    position: relative;
    background: #fff;
    border-radius: var(--radius);
    padding: 30px 34px;
    box-shadow: 0 18px 50px rgba(2,6,23,.35);
    max-width: 420px;
    width: 100%;
    text-align: center;
}
.modal-close {
    position: absolute;
    top: 12px; right: 12px;
    border: none;
    background: #f1f5f9;
    width: 34px; height: 34px;
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    transition: background .2s;
}
.modal-close:hover { background: #e2e8f0; }
.live-earn-rate { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.live-earn-amount {
    font-size: 44px;
    font-weight: 800;
    color: #059669;
    margin: 10px 0;
    letter-spacing: -1px;
}
.live-earn-hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ---------- Ustawienia: grafik pracy ---------- */
.muted { color: var(--muted); }
.mb16 { margin-bottom: 16px; }

/* ---------- Filtr statystyk ---------- */
.filter-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(2,6,23,.06);
    margin-bottom: 22px;
    overflow: hidden;
}

.filter-tabs {
    display: flex;
    border-bottom: 2px solid #f1f5f9;
}

.filter-tab {
    flex: 1;
    padding: 14px 20px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: color .18s, background .18s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}
.filter-tab:hover { background: #f8fafc; color: var(--text); }
.filter-tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    margin-bottom: -2px;
    background: #f5f3ff;
}

.filter-body { padding: 20px 24px; }

.filter-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    margin-bottom: 12px;
}

.filter-month-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-select-wrap {
    position: relative;
    flex: 1;
    min-width: 180px;
}
.filter-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    padding: 11px 40px 11px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    background: #f8fafc;
    color: var(--text);
    cursor: pointer;
    transition: border .2s, box-shadow .2s;
}
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99,102,241,.15);
    background: #fff;
}
.filter-select-ico {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--muted);
    font-size: 13px;
}

.filter-range-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.filter-date-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 160px;
}
.filter-date-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
}
.filter-date-input {
    flex: 1;
    padding: 11px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    background: #f8fafc;
    color: var(--text);
    transition: border .2s, box-shadow .2s;
}
.filter-date-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99,102,241,.15);
    background: #fff;
}
.filter-range-sep {
    font-size: 18px;
    color: var(--muted);
    font-weight: 700;
}

.btn-light {
    background: #eef2ff;
    color: var(--primary-dark);
}
.btn-light:hover { background: #e0e7ff; }
.btn-ghost {
    background: transparent;
    color: var(--muted);
}
.btn-ghost:hover { background: #f1f5f9; color: #0f172a; }

.schedule-form { display: block; }
.sched-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }

.sched-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr 2fr;
    gap: 10px 14px;
    align-items: center;
}
.sched-head {
    font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--muted);
}
.sched-row { display: contents; }
.sched-day { font-weight: 600; padding: 6px 0; }
.sched-toggle { padding: 6px 0; }
.sched-hours { padding: 6px 0; }
.time-pair { display: inline-flex; align-items: center; gap: 8px; }
.time-sep { color: var(--muted); }
.sched-hint { font-size: 12px; color: var(--danger); margin-top: 6px; }
.sched-actions { margin-top: 16px; }

/* Przełącznik (switch) */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0; background: #e2e8f0; transition: .2s; border-radius: 999px;
}
.slider:before {
    position: absolute; content: ""; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff;
    transition: .2s; border-radius: 50%; box-shadow: 0 2px 6px rgba(2,6,23,.15);
}
.switch input:checked + .slider { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* Inputs time look */
input[type=time] {
    width: 120px;
    margin-top: 0;
    padding: 10px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    background: #f8fafc;
}
input[type=time]:disabled { background: #f1f5f9; color: #94a3b8; }

/* Popup / Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Przyciski akcji w tabeli */
.actions-cell {
    white-space: nowrap;
    text-align: right;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f1f5f9;
}

.btn-edit { color: #3b82f6; }
.btn-delete { color: #ef4444; }

@media (max-width: 640px) {
    /* Dedykowany widok mobilny: sidebar zawsze ukryty domyślnie,
       wysuwany dopiero po dodaniu klasy .sidebar-open na .layout. */
    .layout {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--sidebar-w) !important;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        box-shadow: 10px 0 30px rgba(2, 6, 23, 0.35);
    }

    /* Na mobile ignorujemy desktopowy stan 'collapsed' i pokazujemy
       pełne etykiety, gdy menu jest otwarte. */
    .layout.collapsed .sidebar,
    .layout .sidebar {
        transform: translateX(-100%);
    }

    .layout.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .layout.collapsed .sidebar-title,
    .layout.collapsed .nav-label {
        opacity: 1;
        pointer-events: auto;
    }

    .main {
        width: 100%;
        margin-left: 0 !important;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .sidebar-overlay {
        z-index: 900;
    }

    .layout.sidebar-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .hamburger {
        display: inline-flex !important;
        position: fixed;
        left: 0;
        top: 15px;
        z-index: 1100; /* Nad sidebar (1000) */
        transition: transform 0.28s ease, left 0.28s ease;
        background: var(--card-bg);
        border: 1.5px solid #e2e8f0;
        border-left: none; /* Przyklejony do lewej */
        border-radius: 0 8px 8px 0;
        width: 32px;
        height: 36px;
        justify-content: center;
        align-items: center;
        box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
        font-size: 14px;
        color: var(--primary);
    }

    .layout.sidebar-open .hamburger {
        left: var(--sidebar-w);
        border-left: 1.5px solid #e2e8f0;
        border-radius: 8px;
        margin-left: 5px;
    }

    /* Ustawienia: Grafik pracy na mobile */
    .sched-grid {
        display: block;
    }
    .sched-head {
        display: none; /* Nagłówki nie pasują do układu pionowego */
    }
    .sched-row {
        display: block;
        padding: 16px 0;
        border-bottom: 1px solid #f1f5f9;
    }
    .sched-row:last-child {
        border-bottom: none;
    }
    .sched-day {
        font-size: 16px;
        margin-bottom: 8px;
    }
    .sched-toggle {
        margin-bottom: 12px;
    }
    .sched-hours {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    .time-pair {
        flex-wrap: wrap;
        gap: 6px 12px;
    }
    input[type=time] {
        width: 110px; /* Nieco węższe, by lepiej pasowały obok siebie */
    }

    /* Formularz stawki na mobile */
    .entry-form .form-row {
        flex-direction: column;
        gap: 12px;
    }
    .entry-form label, .entry-form label.grow {
        width: 100%;
        min-width: 0;
    }

    /* Przerwa pod spodem */
    .break-section {
        margin-top: 12px;
    }
    .break-label {
        font-size: 11px;
        color: #64748b;
        font-weight: 600;
        margin-bottom: 4px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    .time-pair.no-label {
        margin-top: 0;
    }
}
