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

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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.2);

    /* Semantički tokeni za površine/tekst - omogućavaju dark mode */
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-faint: #94a3b8;
    --border: #e2e8f0;
}

:root[data-theme="dark"] {
    --surface: #1c1f2b;
    --surface-alt: #14161f;
    --text: #e5e7eb;
    --text-muted: #9aa4b5;
    --text-faint: #6b7280;
    --border: #333a4a;
}

:root[data-theme="dark"] body {
    background: linear-gradient(135deg, #1e1b2e 0%, #2a1f3d 100%);
}

:root[data-theme="dark"] .empty-state p {
    color: var(--text-faint);
}

:root[data-theme="dark"] .stat-detail {
    color: var(--text-muted);
}

:root[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--surface-alt);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 24px; /* VRAĆENO: standardni desktop razmak */
    color: var(--text);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

header {
    background: var(--bg-gradient);
    color: white;
    padding: 40px 48px;
    position: relative;
}

header h1 {
    margin-bottom: 28px;
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
}

.header-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.header-controls select,
.header-controls input,
#groupSelect,
#monthSelect,
#statsGroupFilter,
#statsMonthFilter {
    padding: 14px 18px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236366f1' d='M1 0l4 4 4-4 1 1-5 5-5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.12);
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.header-controls select:focus,
.header-controls input:focus,
#groupSelect:focus,
#monthSelect:focus,
#statsGroupFilter:focus,
#statsMonthFilter:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
    transform: translateY(-1px);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#syncStatus {
    font-size: 16px;
}

#syncStatus.connected {
    color: #10b981;
}

#syncStatus.syncing {
    color: #f59e0b;
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#syncStatus.error {
    color: #ef4444;
}

main {
    padding: 48px; /* VRAĆENO: standardni desktop razmak */
    min-height: 500px;
    background: var(--surface-alt);
}

.empty-state {
    text-align: center;
    padding: 120px 40px;
    color: var(--text-faint);
    font-size: 20px;
    font-weight: 500;
}

.gender-table-container {
    margin-bottom: 48px;
}

.table-title {
    color: var(--primary);
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 24px;
    padding: 20px 28px;
    background: var(--surface);
    border-radius: 16px;
    border-left: 6px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.table-title-text {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-title-badge {
    background: var(--primary);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.table-title-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.table-title-extra-btn {
    background: var(--info);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.table-title-extra-btn:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .table-title {
        flex-wrap: wrap;
        gap: 12px;
    }

    .table-title-actions {
        width: 100%;
        justify-content: space-between;
    }
}

.attendance-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    background: var(--surface);
    scroll-behavior: auto; /* NOVO: Sprečava smooth scroll koji može uzrokovati flicker */
    position: relative; /* NOVO: Za bolju kontrolu scroll pozicije */
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    min-width: 700px;
}

th, td {
    padding: 0;
    text-align: center;
    border-bottom: 1px solid var(--border);
    width: 60px;
    min-width: 60px;
    max-width: 60px;
}

th {
    padding: 16px;
    background: var(--bg-gradient);
    color: white;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 10;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.8px;
}

th:first-child,
td:first-child {
    padding: 16px 20px;
    text-align: left;
    min-width: 220px;
    max-width: 280px;
    width: 220px;
}

th:first-child {
    border-top-left-radius: 16px;
}

th:last-child {
    border-top-right-radius: 16px;
}

td:first-child {
    font-weight: 600;
    background: var(--surface-alt);
    position: sticky;
    left: 0;
    z-index: 5;
    color: var(--text);
}

.attendance-cell {
    cursor: pointer;
    user-select: none;
    font-size: 24px;
    font-weight: 700;
    transition: all 0.15s ease;
    width: 60px;
    height: 60px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.attendance-cell:hover {
    background: var(--surface-alt);
    transform: scale(1.15);
    box-shadow: var(--shadow-sm);
}

.attendance-cell:active {
    transform: scale(1.05);
}

.status-present { 
    color: var(--success);
}

.status-absent { 
    color: var(--danger);
}

.status-excused { 
    color: var(--warning);
}

.stats-row {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    font-weight: 800;
    border-top: 3px solid #3b82f6;
}

.stats-row td:first-child {
    color: #1e40af;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.btn-primary, .btn-secondary, .btn-success {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-primary:disabled, .btn-secondary:disabled, .btn-success:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-primary {
    background: var(--bg-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border: 2px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-success:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.95);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
    color: white;
    padding: 40px;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top: 4px solid white;
    width: 60px;
    height: 60px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 16px;
    font-weight: 500;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    overflow-y: auto;
    padding: 30px;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    padding: 48px;
    border-radius: 20px;
    max-width: 1000px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    margin: 0; /* PROMENJENO: Bez margin-a, flex centrira */
    box-shadow: var(--shadow-xl);
}

.modal-content h2 {
    margin-bottom: 32px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.settings-section {
    margin-bottom: 32px;
    padding: 28px;
    background: var(--surface-alt);
    border-radius: 16px;
    border: 2px solid var(--border);
    transition: all 0.2s ease;
}

.settings-section:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.settings-section h3 {
    margin-bottom: 24px;
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
}

/* NOVO: Info text za backup sekciju */
.info-text {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.6;
}

/* NOVO: Sync buttons wrapper */
.sync-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.sync-buttons .btn-primary {
    flex: 1;
    min-width: 200px;
    justify-content: center;
}

.gender-section {
    margin-bottom: 28px;
    padding: 24px;
    background: var(--surface);
    border-radius: 14px;
    border: 2px solid var(--border);
}

.gender-section h4 {
    color: var(--primary);
    font-size: 18px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.input-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.input-group input,
.input-group select {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: var(--surface);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.group-item, .member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--surface);
    margin-bottom: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--border);
}

/* NOVO: wrapper za gumbe desno */
.item-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.edit-btn {
    background: var(--info);
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.15s ease;
    margin-left: 0; /* UKLONJENO: margin-left */
}

.edit-btn:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-sm);
}

.delete-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.delete-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.days-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.days-selector label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--surface);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--border);
    font-weight: 500;
}

.days-selector label:hover {
    border-color: var(--primary);
    background: var(--surface-alt);
}

.days-selector label:has(input:checked) {
    background: var(--bg-gradient);
    color: white;
    border-color: var(--primary-dark);
}

.days-selector input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.theme-toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--surface);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--border);
    font-weight: 500;
    width: fit-content;
}

.theme-toggle-label:hover {
    border-color: var(--primary);
    background: var(--surface-alt);
}

.theme-toggle-label:has(input:checked) {
    background: var(--bg-gradient);
    color: white;
    border-color: var(--primary-dark);
}

.theme-toggle-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--surface-alt);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* NOVO: Scroll to top button - ažurirano da bude u skladu sa ostalim stilovima */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--bg-gradient);
    color: white;
    border: none;
    border-radius: 16px; /* PROMENJENO: konzistentno sa ostalim dugmićima */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    z-index: 100;
    backdrop-filter: blur(10px); /* NOVO: dodato za konsistentnost */
    border: 2px solid rgba(255, 255, 255, 0.2); /* NOVO: dodato za konsistentnost */
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    transform: translateY(-4px) scale(1.1);
    box-shadow: var(--shadow-xl);
    border-color: rgba(255, 255, 255, 0.4); /* NOVO: hover efekat za border */
}

.scroll-to-top:active {
    transform: translateY(-2px) scale(1.05);
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        /* ...existing code... */
        padding: 6px; /* NOVO: manji ali ne nula razmak na telefonu */
    }
    .container {
        margin: 0;
        border-radius: 12px;
    }
    main {
        padding: 16px; /* NOVO: malo više prostora unutra */
    }
    
    .modal-content {
        padding: 28px 20px;
        border-radius: 14px;
        max-width: 100%;
        width: calc(100% - 12px);
    }

    .header-controls {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .settings-section,
    .gender-section {
        padding: 18px;
        border-radius: 12px;
    }

    .group-item,
    .member-item {
        padding: 14px 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .item-buttons {
        justify-content: stretch;
        width: 100%;
    }

    .item-buttons button {
        flex: 1;
    }

    .sync-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .input-group {
        flex-direction: column; /* NOVO: složi kontrole vertikalno */
        gap: 10px;             /* NOVO: ujednačen razmak */
    }

    .input-group input,
    .input-group select,
    .input-group button {
        width: 100%;           /* NOVO: puni raspoloživu širinu */
    }

    #addGroupBtn,
    #addMemberBtn {
        width: 100%;           /* NOVO: istakni dugmad */
        justify-content: center;
    }

    .member-details {
        margin: 0;
        border-radius: 12px; /* NOVO: kompaktniji dropdown */
    }
    .member-details summary {
        padding: 12px 14px; /* NOVO: uži prikaz na mobilu */
    }
    .members-stats-table {
        margin: 8px 0 0; /* NOVO: smanjen razmak */
    }
    .members-stats-table table {
        min-width: 420px; /* PROMENA: uža tabela */
    }
}

@media (max-width: 400px) {
    body {
        /* ...existing code... */
        padding: 4px; /* NOVO: minimalni razmak na najmanjim ekranima */
    }
    .container {
        margin: 0;
        border-radius: 10px; /* NOVO: zadrži blago zaobljenje */
    }
    main {
        padding: 12px; /* NOVO: zadrži malo daha unutra */
    }
    
    .cancel-btn {
        padding: 3px 8px;
        font-size: 10px;
        min-width: 26px;
        height: 22px;
        border-radius: 6px;
    }
    
    .members-stats-table table {
        min-width: 320px; /* NOVO: prilagođeno najmanjim ekranima */
    }
}

/* NOVO: Extra mali ekrani (< 400px) */
@media (max-width: 400px) {
    /* ...existing code... */
    
    .cancel-option-btn {
        padding: 14px;
        gap: 12px;
        font-size: 13px;
        border-radius: 10px;
    }
    
    .option-icon {
        font-size: 26px;
        min-width: 38px;
    }
    
    .option-title {
        font-size: 13px;
    }
    
    .option-desc {
        font-size: 11px;
    }
    
    .cancel-btn {
        padding: 2px 6px;
        font-size: 9px;
        min-width: 24px;
        height: 20px;
    }
}

/* VAŽNO: th.cancelled NE sme imati pointer-events: none jer dugme mora raditi! */
th.cancelled {
    opacity: 0.8;
    cursor: default; /* Promenjen cursor */
}

/* Samo ćelije u body tabele imaju pointer-events: none */
td.cancelled-cell,
.cancelled-cell {
    pointer-events: none;
}

.cancelled-cell .attendance-cell {
    cursor: not-allowed;
    pointer-events: none;
}

/* Dugme MORA raditi čak i na otkazanom headeru */
th.cancelled .cancel-btn {
    pointer-events: auto !important; /* FORCE enable */
    cursor: pointer !important;
}

/* Današnji trening - blaga crvenkasta */
th.today {
    background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%) !important; /* Još blaža nijansa */
    animation: pulse-today 2s ease-in-out infinite;
}

@keyframes pulse-today {
    0%, 100% { 
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    }
    50% { 
        box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
    }
}

/* Budući treninzi - blaga siva */
th.future {
    background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%) !important;
    opacity: 0.7;
}

/* Dodatni (vanredni) trening - dodat izvan redovnog rasporeda */
th.extra {
    background: linear-gradient(135deg, #67e8f9 0%, var(--info) 100%) !important;
}

.extra-delete-btn {
    margin-left: 4px;
}

/* NOVO: Ceo red za današnji datum - blago crvenkasta */
/* FIKSAJ: Koristi td sa klasom direktno, ne :has() selektor */
td.today-cell-wrapper {
    background: rgba(254, 202, 202, 0.3) !important; /* Veoma blaga crvenkasta za <td> */
}

td.today-cell .attendance-cell,
td.today-cell-wrapper .attendance-cell {
    background: rgba(252, 165, 165, 0.2); /* Još blaža za same ćelije */
}

td.today-cell .attendance-cell:hover,
td.today-cell-wrapper .attendance-cell:hover {
    background: rgba(252, 165, 165, 0.4) !important;
}

td.future-cell {
    opacity: 0.5;
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    color: white;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 30px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    letter-spacing: 0.3px;
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.cancel-btn.active {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    border-color: var(--success);
    box-shadow: 0 3px 8px rgba(16, 185, 129, 0.4);
}

.cancel-btn.active:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px) scale(1.02);
}

/* NOVO: Cancel options modal styling */
.cancel-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 28px 0;
}

.cancel-option-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 28px;
    border: 2px solid transparent;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-align: left;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.cancel-option-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.5) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.cancel-option-btn:hover::before {
    opacity: 1;
}

.cancel-option-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.cancel-btn-action {
    border-color: transparent;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    position: relative;
}

.cancel-btn-action::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
    border-radius: 0 2px 2px 0;
}

.cancel-btn-action:hover {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    box-shadow: 0 12px 32px rgba(239, 68, 68, 0.2);
}

.replace-btn-action {
    border-color: transparent;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    position: relative;
}

.replace-btn-action::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    border-radius: 0 2px 2px 0;
}

.replace-btn-action:hover {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    box-shadow: 0 12px 32px rgba(245, 158, 11, 0.2);
}

.restore-btn-action {
    border-color: transparent;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    position: relative;
}

.restore-btn-action::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
    border-radius: 0 2px 2px 0;
}

.restore-btn-action:hover {
    border-color: #10b981;
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.2);
}

.option-icon {
    font-size: 42px;
    min-width: 60px;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.cancel-btn-action .option-icon {
    background: linear-gradient(135deg, #fecaca 0%, #fee2e2 100%);
    color: #dc2626;
}

.replace-btn-action .option-icon {
    background: linear-gradient(135deg, #fde68a 0%, #fef3c7 100%);
    color: #d97706;
}

.restore-btn-action .option-icon {
    background: linear-gradient(135deg, #bbf7d0 0%, #dcfce7 100%);
    color: #059669;
}

.cancel-option-btn:hover .option-icon {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.option-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.option-title {
    font-size: 18px;
    font-weight: 800;
    color: #1e293b; /* Fiksna boja - pozadina kartice je uvek svetla, nezavisno od teme */
    margin-bottom: 2px;
    letter-spacing: -0.3px;
    transition: color 0.3s ease;
}

.option-desc {
    font-size: 15px;
    color: #64748b; /* Fiksna boja - pozadina kartice je uvek svetla, nezavisno od teme */
    line-height: 1.5;
    font-weight: 500;
    transition: color 0.3s ease;
}

.cancel-option-btn:hover .option-title {
    color: #0f172a;
}

.cancel-option-btn:hover .option-desc {
    color: #475569;
}

/* Replacement date input styling */
#replacementDateInput {
    margin: 24px 0;
    padding: 24px;
    background: linear-gradient(135deg, var(--surface-alt) 0%, var(--surface) 100%);
    border-radius: 16px;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

#replacementDateInput:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.input-label {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    letter-spacing: -0.2px;
}

#replacementDayInput {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--surface);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

#replacementDayInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

#replacementDayInput::placeholder {
    color: var(--text-faint);
    font-weight: 500;
}

/* Modal buttons enhancement */
.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-buttons button {
    flex: 1;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.modal-close-btn {
    width: 100%;
    margin-top: 24px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 12px;
    transition: all 0.3s ease;
}

/* Responsive design - POBOLJŠANO za telefone */
@media (max-width: 768px) {
    /* ...existing code... */
    
    body {
        /* ...existing code... */
        padding: 0; /* PROMENA: uklonjen bočni prostor */
    }
    .container {
        /* ...existing code... */
        margin: 0; /* PROMENA: rastegni do ivica */
        border-radius: 0; /* PROMENA: ivice poravnane sa ekranom */
    }
    main {
        /* ...existing code... */
        padding: 12px; /* PROMENA: malo smanjen unutrašnji padding */
    }
    
    .cancel-btn {
        padding: 3px 8px;
        font-size: 10px;
        min-width: 26px;
        height: 22px;
        border-radius: 6px;
    }
    
    .stats-overview {
        display: flex;
        flex-direction: column;
        gap: 28px;
    }

    .stats-cards {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 20px;
    }

    .stat-card {
        align-items: stretch;
        padding: 26px;
        border-radius: 18px;
    }

    .stat-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }

    .stat-content {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .stat-label {
        font-size: 13px;
        letter-spacing: 0.3px;
    }

    .stats-section-title {
        margin-top: 12px;
        font-size: 24px;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .group-stats-card {
        display: flex;
        flex-direction: column;
        gap: 18px;
    }

    .group-stats-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 14px;
    }

    .group-stat-item {
        padding: 14px 18px;
        border-radius: 12px;
        background: var(--surface-alt);
        border: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .group-stat-item .label {
        font-size: 12px;
        letter-spacing: 0.4px;
        color: var(--text-muted);
        text-transform: uppercase;
    }

    .group-stat-item .value {
        font-size: 20px;
        font-weight: 700;
        color: var(--text);
    }

    .members-stats-table {
        margin-top: 16px;
        border-radius: 14px;
        border: 1px solid var(--border);
        overflow-x: auto;
    }

    .members-stats-table table {
        width: 100%;
        border-collapse: collapse;
    }

    .members-stats-table th,
    .members-stats-table td {
        padding: 12px 16px;
        text-align: left;
        font-size: 13px;
        border-bottom: 1px solid var(--border);
    }

    .members-stats-table th {
        background: var(--bg-gradient);
        color: white;
        text-transform: uppercase;
        letter-spacing: 0.6px;
        font-size: 12px;
    }

    .members-stats-table tbody tr:nth-child(odd) {
        background: var(--surface-alt);
    }

    .members-stats-table tbody tr:hover {
        background: rgba(99, 102, 241, 0.08);
    }

    .member-details summary {
        font-weight: 700;
        font-size: 15px;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .member-details summary::marker {
        color: var(--primary);
    }

    .stats-cards {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .stat-card {
        padding: 22px;
        text-align: left;
        align-items: flex-start;
    }

    .group-stats-grid {
        grid-template-columns: 1fr;
    }

    .members-stats-table {
        border-radius: 10px;
    }

    .members-stats-table table {
        min-width: 520px;
        font-size: 12px;
    }

    .stats-filters {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-bottom: 22px;
    }
}

@media (max-width: 400px) {
    .scroll-to-top {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 22px;
        border-radius: 12px; /* PROMENJENO: proporcionalno smanjeno */
    }
}

.date-header span {
    font-size: 12px; /* NOVO: smanjen tekst da stane u header */
    line-height: 1.15; /* NOVO: zbijeniji red */
    word-break: keep-all; /* NOVO: spreči lomljenje reči */
}

@media (max-width: 768px) {
    .date-header span {
        font-size: 11px; /* NOVO: još manje na telefonima */
    }
}

.stats-overview {
    display: flex;
    flex-direction: column;
    gap: 28px;
    max-width: 1100px;
    margin: 0 auto;
}

.stat-card {
    align-items: stretch;
    padding: 26px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(99,102,241,0.08));
    border: 1px solid rgba(99,102,241,0.18);
    box-shadow: 0 14px 30px rgba(79,70,229,0.08);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 36px rgba(79,70,229,0.14);
}

.stat-value {
    font-size: 36px;
    letter-spacing: -0.8px;
}

.stat-detail {
    font-size: 13px;
    color: rgba(15,23,42,0.7);
}

.group-stats-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 24px;
    border-radius: 18px;
    border: 1px solid rgba(15,23,42,0.08);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.group-stats-card h4 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.4px;
}

.group-stat-item {
    padding: 14px 18px;
    border-radius: 12px;
    background: rgba(241,245,249,0.8);
    border: 1px solid rgba(148,163,184,0.25);
}

.group-stat-item .value {
    font-size: 22px;
    color: #0f172a;
}

.member-details {
    border-radius: 14px;
    border: 1px solid rgba(148,163,184,0.35);
    overflow: hidden;
    background: rgba(248,250,252,0.7);
}

.member-details summary {
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(129,140,248,0.08));
    color: #1e293b; /* Fiksna boja - podloga je uvek svetla, nezavisno od teme */
}

.member-details[open] {
    box-shadow: 0 10px 26px rgba(15,23,42,0.12);
}

.member-details summary::after {
    content: '▾';
    margin-left: auto;
    font-size: 14px;
    transition: transform 0.2s ease;
}

.member-details[open] summary::after {
    transform: rotate(180deg);
}

.members-stats-table {
    margin: 12px -6px 0;
    border-radius: 12px;
    background: var(--surface);
}

.members-stats-table th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.members-stats-table tbody tr:hover td {
    background: rgba(99, 102, 241, 0.06);
}

/* Mobile tweaks */
@media (max-width: 768px) {
    .stats-overview {
        gap: 22px;
        padding-bottom: 16px;
    }

    .stat-card {
        padding: 24px 20px;
        border-radius: 16px;
    }

    .stat-value {
        font-size: 32px;
    }

    .group-stats-card {
        padding: 20px;
    }

    .member-details summary {
        font-size: 13px;
        padding: 14px 16px;
    }

    .members-stats-table {
        margin: 8px 0 0; /* NOVO: smanjen razmak */
    }
    .members-stats-table table {
        min-width: 420px; /* PROMENA: uža tabela */
    }
}

@media (max-width: 400px) {
    .members-stats-table table {
        min-width: 320px; /* NOVO: prilagođeno najmanjim ekranima */
    }
}

/* Sakrij podrazumevane oznake za select elemente */
header .header-controls select::-webkit-select {
    display: none;
}

/* Prilagodi stilove za select elemente u headeru */
.header-controls select {
    padding: 14px 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    width: 100%;
    padding-right: 42px;
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236366f1' d='M1 0l4 4 4-4 1 1-5 5-5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
    appearance: none;
}

/* Prilagodi stilove za input elemente u headeru */
.header-controls input {
    padding: 14px 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    width: 100%;
}

/* Sakrij podrazumevane oznake za summary elemente u member-details */
.member-details summary::-webkit-details-marker {
    display: none;
}

/* Prilagodi stilove za member-details tabele na malim ekranima */
@media (max-width: 480px) {
    .members-stats-table table {
        min-width: unset;
        width: 100%;
        display: block;
    }
    .members-stats-table thead {
        display: none;
    }
    .members-stats-table tbody {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
    .members-stats-table tr {
        position: relative;
        padding: 18px 16px 16px;
        border: 1px solid rgba(99, 102, 241, 0.18);
        border-radius: 18px;
        background: linear-gradient(160deg, rgba(236, 233, 254, 0.88), rgba(255, 255, 255, 0.95));
        box-shadow: 0 12px 28px rgba(79, 70, 229, 0.12);
        gap: 12px;
        color: #1e293b; /* Fiksna boja - kartica je uvek svetla, nezavisno od teme */
    }
    .members-stats-table tr::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 4px;
        border-radius: 18px 0 0 18px;
        background: linear-gradient(180deg, #6366f1, #8b5cf6);
    }
    .members-stats-table td {
        font-size: 13.5px;
        line-height: 1.45;
    }
    .members-stats-table td:first-child {
        font-size: 17px;
        letter-spacing: -0.2px;
    }
    .members-stats-table td[data-label]::before {
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        color: #64748b; /* Fiksna boja - kartica na malim ekranima je uvek svetla */
    }
    .members-stats-table td[data-label="Procenat"] strong {
        font-size: 18px;
        color: var(--primary);
    }
}

/* NOVO: Stats filters styling */
.stats-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
    column-gap: 24px;
    row-gap: 18px;
    max-width: 720px;
    margin: 0 auto 32px;
}

@media (max-width: 600px) {
    .stats-filters {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-bottom: 22px;
    }
}

@media (max-width: 480px) {
    .members-stats-table tr {
        padding: 18px;
        border-radius: 16px;
        background: linear-gradient(165deg, rgba(241,245,249,0.92), rgba(255,255,255,0.98));
        box-shadow: 0 10px 24px rgba(79,70,229,0.1);
        color: #1e293b; /* Fiksna boja - kartica je uvek svetla, nezavisno od teme */
    }
    .members-stats-table tr::before {
        width: 3px;
        background: linear-gradient(180deg, #6366f1, #8b5cf6);
    }
    .members-stats-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 4px 0;
        font-size: 13.5px;
        line-height: 1.4;
    }
    .members-stats-table td:first-child {
        display: block;
        margin-bottom: 6px;
        font-size: 17px;
        font-weight: 700;
        letter-spacing: -0.2px;
    }
    .members-stats-table td:first-child::before {
        display: none;
    }
    .members-stats-table td[data-label]::before {
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        color: #64748b; /* Fiksna boja - kartica na malim ekranima je uvek svetla */
    }
    .members-stats-table td[data-label="Procenat"] strong {
        font-size: 18px;
        color: var(--primary);
    }
}