* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 50%, #e8ecf1 100%);
    background-attachment: fixed;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main {
    width: 100%;
    max-width: 1200px;
    margin: 96px auto 32px;
    padding: 0 24px;
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Topbar / navigacija */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: 64px;
    height: auto;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    color: #f8fafc;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 0 24px;
    z-index: 20;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.12);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.topbar-left {
    flex: 1 1 auto;
}

.brand {
    display: none;
    font-weight: 700;
    letter-spacing: 0.03em;
    font-size: 1.15rem;
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.2));
}

.topnav {
    display: flex;
    gap: 12px;
    align-items: center;
}

.topnav a {
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.95rem;
    color: #cbd5e1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    position: relative;
    letter-spacing: 0.01em;
}

.topnav a.active,
.topnav a:hover {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2) 0%, rgba(59, 130, 246, 0.15) 100%);
    color: #93c5fd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.25);
}

.topnav a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
    border-radius: 3px 3px 0 0;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.5);
}

.topbar-user {
    margin-left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.user-name {
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
}

.btn-logout:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.nav-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #f9fafb;
    font-size: 1.4rem;
    margin-right: 12px;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.nav-toggle:hover {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.nav-toggle:active {
    background: rgba(255,255,255,0.15);
}

/* Kartice, layout */
.page-header {
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0 0 12px;
    font-size: 2.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #475569 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-header p {
    margin: 0;
    color: #64748b;
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0.01em;
}

.card {
    background: linear-gradient(135deg, #ffffff 0%, #fefefe 100%);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 28px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover::before {
    opacity: 1;
}

.card:hover {
    box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 4px 16px rgba(59, 130, 246, 0.08);
    transform: translateY(-4px);
    border-color: rgba(96, 165, 250, 0.3);
}

.card-header {
    padding: 24px 28px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    position: relative;
}

.card-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(59, 130, 246, 0.3) 50%, transparent 100%);
}

.card-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.card-body {
    padding: 28px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-value {
    font-size: 2.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.2));
}

.stat-label {
    color: #64748b;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Tablice */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th,
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    transform: scale(1.005);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.table tbody tr.row-overdue {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-left: 3px solid #ef4444;
}

.table tbody tr.row-overdue:hover {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.15);
}

.table tbody tr.row-mine {
    background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
    border-left: 3px solid #06b6d4;
}

.table tbody tr.row-mine:hover {
    background: linear-gradient(135deg, #cffafe 0%, #a5f3fc 100%);
    box-shadow: 0 2px 12px rgba(6, 182, 212, 0.15);
}

/* Details rows (expandable grids under main rows) */
.table tbody tr.details-row {
    display: none;
    background: #f8fafc;
}

.table tbody tr.details-row.is-open {
    display: table-row;
}

.table tbody tr.details-row td {
    border-top: 0;
    padding-top: 8px;
    padding-bottom: 12px;
}

.details-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}

.table.table-compact th,
.table.table-compact td {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.table th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #cbd5e1;
    position: relative;
}

.table th::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(59, 130, 246, 0.4) 50%, transparent 100%);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.badge:hover {
    transform: scale(1.08) translateY(-1px);
    filter: brightness(1.05);
}

.badge-status-open {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, #fcd34d 100%);
    color: #92400e;
    box-shadow: 0 3px 10px rgba(251, 191, 36, 0.35);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.badge-status-completed {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 50%, #86efac 100%);
    color: #166534;
    box-shadow: 0 3px 10px rgba(34, 197, 94, 0.35);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-priority-low {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #475569;
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.2);
}

.badge-priority-medium {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.badge-priority-high {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #b91c1c;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.badge-priority-urgent {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 50%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 3px 12px rgba(249, 115, 22, 0.5), 0 0 20px rgba(249, 115, 22, 0.3);
    animation: pulse 2s infinite;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.badge-overdue {
    background: linear-gradient(135deg, #b91c1c 0%, #ef4444 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Forme i gumbi */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.form-group label {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #475569;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 16px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    font: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12), 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
    background: #ffffff;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4), 0 2px 8px rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.5), 0 4px 12px rgba(59, 130, 246, 0.3);
    transform: translateY(-3px);
}

.btn-secondary {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    color: #475569;
    border: 2px solid #cbd5e1;
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.1);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 50%, #94a3b8 100%);
    border-color: #94a3b8;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(100, 116, 139, 0.25), 0 2px 8px rgba(100, 116, 139, 0.15);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 18px 24px;
    border-radius: 14px;
    font-size: 0.95rem;
    margin-bottom: 24px;
    border-left: 5px solid;
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, transparent 100%);
    pointer-events: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.alert-success {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 50%, #86efac 100%);
    color: #166534;
    border-left-color: #22c55e;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.25), 0 2px 8px rgba(34, 197, 94, 0.15);
}

.alert-error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 50%, #fca5a5 100%);
    color: #b91c1c;
    border-left-color: #ef4444;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.25), 0 2px 8px rgba(239, 68, 68, 0.15);
}

/* Login stranica */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(135deg, #ffffff 0%, #fefefe 100%);
    border-radius: 24px;
    box-shadow: 0 24px 64px rgba(15,23,42,0.2), 0 8px 24px rgba(15,23,42,0.1);
    padding: 48px 40px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
    border-radius: 24px 24px 0 0;
}

.auth-card h1 {
    margin: 0 0 4px;
}

.auth-card p {
    margin: 0 0 16px;
    color: #6b7280;
    font-size: 0.9rem;
}

.form-error {
    font-size: 0.85rem;
    color: #b91c1c;
    margin-bottom: 8px;
}

.auth-hint {
    margin-top: 12px;
    font-size: 0.8rem;
    color: #6b7280;
}

.attachment-thumb {
    max-width: 120px;
    max-height: 80px;
    display: block;
    margin-bottom: 4px;
    cursor: pointer;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.image-modal.is-open {
    display: flex;
}

.image-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    z-index: 51;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    border-radius: 4px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

/* Mobile utility classes */
.mobile-scroll-hint {
    display: none;
}

@media (max-width: 768px) {
    .mobile-scroll-hint {
        display: block;
        text-align: center;
        font-size: 0.8rem;
        color: #6b7280;
        padding: 8px;
        background: #f9fafb;
        border-radius: 4px;
        margin-bottom: 8px;
    }
}

/* Responsivnost */
@media (max-width: 768px) {
    .topbar {
        flex-wrap: wrap;
        height: auto;
        align-items: center;
    }

    .topnav {
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        flex-direction: column;
        padding: 16px 20px;
        display: none;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        gap: 8px;
    }

    .topnav a {
        padding: 16px 20px;
        font-size: 1.1rem;
        width: 100%;
        border-radius: 8px;
        font-weight: 600;
    }

    .topnav.topnav-open {
        display: flex;
    }

    .nav-toggle {
        display: flex;
    }

    .topbar-user {
        margin-left: auto;
        font-size: 0.9rem;
        gap: 8px;
    }

    .topbar-user .btn-logout {
        padding: 10px 16px;
        font-size: 1rem;
        min-height: 44px;
        font-weight: 600;
    }

    .grid-3 {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .app-main {
        margin-top: 120px;
        padding: 0 16px;
    }

    .page-header h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    .page-header p {
        font-size: 1.05rem;
        line-height: 1.5;
    }

    /* Touch-friendly buttons with better contrast */
    .btn {
        min-height: 48px;
        padding: 14px 20px;
        font-size: 1.05rem;
        font-weight: 600;
    }

    .btn-sm {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 1rem;
    }

    /* Better table display on mobile */
    .table-responsive {
        margin: -12px;
        padding: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
        font-size: 1rem;
    }

    .table th,
    .table td {
        padding: 14px 12px;
        white-space: nowrap;
        line-height: 1.5;
    }

    .table th {
        font-size: 0.95rem;
    }

    /* Improve form display */
    .form-group {
        margin-bottom: 20px;
    }

    .form-group label {
        font-size: 1.05rem;
        margin-bottom: 8px;
        font-weight: 600;
        color: #1e293b;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px 16px;
        font-size: 17px; /* Prevents zoom on iOS, good for visibility */
        min-height: 48px;
        border-width: 2px;
    }

    .form-group textarea {
        min-height: 120px;
        line-height: 1.6;
    }

    /* Card improvements */
    .card {
        border-radius: 16px;
        margin-bottom: 20px;
        border-width: 2px;
    }

    .card-header {
        padding: 20px;
    }

    .card-header h2 {
        font-size: 1.3rem;
        margin: 0;
        font-weight: 700;
    }

    .card-body {
        padding: 20px;
    }

    /* Stats cards with better readability */
    .stat-value {
        font-size: 2.5rem;
        line-height: 1.2;
    }

    .stat-label {
        font-size: 1.05rem;
        line-height: 1.4;
    }

    /* Badge improvements with better contrast */
    .badge {
        padding: 6px 14px;
        font-size: 0.9rem;
        font-weight: 700;
        border: 2px solid rgba(0,0,0,0.1);
    }

    /* Alert improvements */
    .alert {
        padding: 16px 20px;
        font-size: 1.05rem;
        border-radius: 12px;
        line-height: 1.5;
        border-left-width: 6px;
    }

    /* Better link visibility */
    a {
        text-decoration: underline;
        text-decoration-thickness: 2px;
        text-underline-offset: 3px;
    }

    .topnav a,
    .btn {
        text-decoration: none;
    }
}


@media (max-width: 480px) {
    .app-main {
        margin-top: 120px;
        padding: 0 14px;
    }

    .topbar {
        padding: 0 14px;
    }

    .brand {
        font-size: 1rem;
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-name {
        display: none;
    }

    .topbar-user {
        gap: 8px;
    }

    .topbar-user .btn-logout {
        padding: 10px 14px;
        font-size: 0.95rem;
        min-height: 44px;
    }

    .page-header {
        margin-bottom: 20px;
    }

    .page-header h1 {
        font-size: 1.6rem;
        line-height: 1.3;
    }

    .page-header p {
        font-size: 1rem;
        line-height: 1.5;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row .form-group {
        width: 100% !important;
        flex: 1 1 100% !important;
    }

    .card {
        border-radius: 14px;
        border-width: 2px;
    }

    .card-body {
        padding: 18px;
    }

    .stat-value {
        font-size: 2.25rem;
        line-height: 1.2;
    }

    .stat-label {
        font-size: 1rem;
        line-height: 1.4;
    }

    /* Improve button layout on small screens */
    .btn {
        min-height: 52px;
        font-size: 1.1rem;
        padding: 16px 24px;
    }

    .btn-sm {
        min-height: 48px;
        font-size: 1rem;
        padding: 12px 18px;
    }

    .btn-block {
        width: 100%;
        margin-bottom: 12px;
    }

    /* Stack action buttons vertically */
    .table .btn {
        display: block;
        width: 100%;
        margin-bottom: 8px;
        min-height: 48px;
    }

    .table .btn:last-child {
        margin-bottom: 0;
    }

    /* Auth card improvements */
    .auth-card {
        padding: 28px 24px;
        max-width: 100%;
        margin: 0 14px;
    }

    .auth-card h1 {
        font-size: 1.6rem;
        line-height: 1.3;
    }

    .auth-card p {
        font-size: 1rem;
        line-height: 1.5;
    }

    /* Image modal improvements */
    .image-modal-content {
        max-width: 95%;
        max-height: 85%;
    }

    /* Better spacing for filter forms */
    .form-row[style*="margin-bottom"] .form-group {
        margin-bottom: 16px;
    }

    .form-row .form-group[style*="align-self: flex-end"] {
        align-self: stretch !important;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .form-row .form-group[style*="align-self: flex-end"] .btn {
        width: 100%;
    }

    /* Larger touch targets */
    .nav-toggle {
        min-width: 48px;
        min-height: 48px;
        font-size: 1.6rem;
    }

    /* Better table readability */
    .table {
        font-size: 1.05rem;
    }

    .table th {
        font-size: 1rem;
    }

    .table th,
    .table td {
        padding: 16px 12px;
    }
}

/* Landscape orientation improvements for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .app-main {
        margin-top: 60px;
    }

    .topnav {
        max-height: calc(100vh - 56px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .page-header h1 {
        font-size: 1.3rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* Tablet improvements (between mobile and desktop) */
@media (min-width: 481px) and (max-width: 768px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .form-row .form-group {
        flex: 1 1 calc(50% - 6px);
        min-width: 200px;
    }
}

/* Loading states */
.btn.is-loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: #1e293b;
    color: #ffffff;
    font-size: 0.85rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 100;
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.tooltip:hover::after,
.tooltip:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* Floating action button */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.5);
}

/* Improved scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    border-radius: 10px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 4px solid #3b82f6;
    outline-offset: 3px;
    border-radius: 4px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background: #ffffff;
        color: #000000;
    }
    
    .topbar {
        background: #000000;
        color: #ffffff;
        border-bottom: 3px solid #ffffff;
    }
    
    .card {
        border: 3px solid #000000;
    }
    
    .btn-primary {
        background: #0000ff;
        color: #ffffff;
        border: 2px solid #000000;
    }
    
    .btn-secondary {
        background: #ffffff;
        color: #000000;
        border: 3px solid #000000;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Print styles */
@media print {
    .topbar,
    .btn,
    .nav-toggle,
    .fab {
        display: none !important;
    }
    
    .app-main {
        margin-top: 0;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #475569;
}

.empty-state-description {
    font-size: 1rem;
    margin-bottom: 24px;
}

/* Success checkmark animation */
@keyframes checkmark {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.checkmark {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: checkmark 0.5s ease-in-out forwards;
}

/* Ripple effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
    width: 200px;
    height: 200px;
}

/* Status indicator dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-dot.active {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    animation: pulse-dot 2s infinite;
}

.status-dot.inactive {
    background: #94a3b8;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Notification badge */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 999px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Divider */
.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
    margin: 24px 0;
}

/* Chip/Tag */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 16px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 500;
    gap: 6px;
    transition: all 0.2s ease;
}

.chip:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

.chip-close {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.chip-close:hover {
    opacity: 1;
}

/* Accessibility - Text size controls */
body.text-size-normal {
    font-size: 16px;
}

body.text-size-large {
    font-size: 18px;
}

body.text-size-xlarge {
    font-size: 20px;
}

body.text-size-large .page-header h1,
body.text-size-xlarge .page-header h1 {
    font-size: 2.2rem;
}

body.text-size-large .btn,
body.text-size-xlarge .btn {
    font-size: 1.1rem;
    padding: 14px 26px;
}

body.text-size-large .table,
body.text-size-xlarge .table {
    font-size: 1.05rem;
}

/* Accessibility controls panel */
.accessibility-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 20px;
    z-index: 100;
    border: 2px solid #e2e8f0;
    display: none;
}

.accessibility-panel.is-open {
    display: block;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.accessibility-panel h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

.accessibility-option {
    margin-bottom: 16px;
}

.accessibility-option:last-child {
    margin-bottom: 0;
}

.accessibility-option label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #475569;
}

.accessibility-btn-group {
    display: flex;
    gap: 8px;
}

.accessibility-btn {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    background: #ffffff;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #475569;
}

.accessibility-btn:hover {
    border-color: #3b82f6;
    background: #f8fafc;
}

.accessibility-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    border-color: #3b82f6;
}

.accessibility-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: #ffffff;
    cursor: pointer;
    border: none;
    font-size: 1.3rem;
    margin-right: 8px;
    box-shadow: 0 4px 12px rgba(15,23,42,0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.accessibility-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15,23,42,0.5);
}

/* High contrast theme */
body.high-contrast {
    background: #000000;
    color: #ffffff;
}

body.high-contrast .topbar {
    background: #000000;
    border-bottom: 3px solid #ffffff;
}

body.high-contrast .card {
    background: #1a1a1a;
    border: 3px solid #ffffff;
    color: #ffffff;
}

body.high-contrast .card-header {
    background: #000000;
    border-bottom: 3px solid #ffffff;
}

body.high-contrast .btn-primary {
    background: #0066ff;
    color: #ffffff;
    border: 3px solid #ffffff;
}

body.high-contrast .btn-secondary {
    background: #ffffff;
    color: #000000;
    border: 3px solid #000000;
}

body.high-contrast .form-group input,
body.high-contrast .form-group select,
body.high-contrast .form-group textarea {
    background: #1a1a1a;
    color: #ffffff;
    border: 3px solid #ffffff;
}

body.high-contrast .table {
    color: #ffffff;
}

body.high-contrast .table th {
    background: #000000;
    border: 2px solid #ffffff;
}

body.high-contrast .table td {
    border-bottom: 2px solid #ffffff;
}

body.high-contrast .alert {
    border: 3px solid #ffffff;
}

body.high-contrast a {
    color: #66b3ff;
    text-decoration: underline;
    text-decoration-thickness: 2px;
}

/* Stronger, clearer text in high contrast mode */
body.high-contrast {
    font-weight: 700;
}

body.high-contrast .topnav a {
    color: #ffffff;
    font-weight: 700;
}

body.high-contrast .page-header h1,
body.high-contrast .page-header p,
body.high-contrast .user-name,
body.high-contrast .form-group label,
body.high-contrast .table,
body.high-contrast .table th,
body.high-contrast .table td {
    color: #ffffff;
    font-weight: 700;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #3b82f6;
    color: #ffffff;
    padding: 12px 20px;
    text-decoration: none;
    font-weight: 600;
    z-index: 1000;
    border-radius: 0 0 8px 0;
}

.skip-to-main:focus {
    top: 0;
}
