/* ============================================
   THEME SYSTEM: Light Mode (Default)
   ============================================ */
:root {
    /* Brand Colors */
    --primary: #1a1a1a;
    --primary-light: #2d2d2d;
    --accent: #ff6b00;
    --accent-hover: #e65a00;

    /* Semantic Colors */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Background Colors */
    --bg-body: #f4f7f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-solid: #ffffff;
    --bg-input: #f4f7f9;
    --bg-light: #f4f7f9;

    /* Sidebar */
    --sidebar-bg-start: #1a1a1a;
    --sidebar-bg-end: #252525;

    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-dark: #1e293b;
    --text-dim: #64748b;
    --white: #ffffff;

    /* Borders & Surfaces */
    --border-color: #e2e8f0;
    --table-stripe: #fafafa;
    --table-hover: #e2e8f0;

    /* Glassmorphism */
    --glass-blur: 16px;
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.1);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* ============================================
   THEME SYSTEM: Dark Mode
   ============================================ */
[data-theme="dark"] {
    /* Background Colors */
    --bg-body: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.9);
    --bg-card-solid: #1e293b;
    --bg-input: #1e293b;
    --bg-light: #1e293b;

    /* Text Colors */
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-dark: #e2e8f0;
    --text-dim: #94a3b8;
    --white: #f1f5f9;

    /* Borders & Surfaces */
    --border-color: #334155;
    --table-stripe: #283548;
    --table-hover: #334155;

    /* Glassmorphism - Dark */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Dark mode specific overrides */
[data-theme="dark"] .page-header h2 {
    color: var(--white);
}

[data-theme="dark"] .page-header .btn-primary {
    background: var(--accent);
}

[data-theme="dark"] .search-input {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .search-input::placeholder {
    color: var(--text-dim);
}

[data-theme="dark"] .input-group input,
[data-theme="dark"] .input-group textarea,
[data-theme="dark"] .input-group select {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .login-card h1 {
    color: var(--white);
}

[data-theme="dark"] #login-view {
    background: linear-gradient(135deg, #1a1a1a 0%, #252525 100%);
}

[data-theme="dark"] .modal-header h3 {
    color: var(--white);
}

[data-theme="dark"] .expense-table tr:hover td,
[data-theme="dark"] .data-table tr:hover td {
    background: #3d4a5c !important;
}

[data-theme="dark"] .input-group input:focus,
[data-theme="dark"] .input-group textarea:focus {
    background: var(--bg-input);
    color: var(--text-primary);
}

.hidden-desktop {
    display: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Background - Clean & Professional */
.background-blobs {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: blob-float 10s infinite alternate cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 107, 0, 0.2) 0%, rgba(255, 107, 0, 0) 70%);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(26, 26, 26, 0.1) 0%, rgba(26, 26, 26, 0) 70%);
    animation-duration: 15s;
    animation-direction: alternate-reverse;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0) 70%);
    animation-duration: 20s;
}

@keyframes blob-float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 50px);
    }
}

/* Layout */
.app-layout {
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-end) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: width 0.3s ease;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);

    /* Sticky Sidebar */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */

    /* For toggle button positioning */
    flex-shrink: 0;
    z-index: 10;
}

/* Hide scrollbar for Chrome/Safari/Opera */
.sidebar::-webkit-scrollbar {
    display: none;
}

.user-info-side {
    margin-top: auto;
    /* Push to bottom */
}

/* Collapsed Sidebar State */
.sidebar.collapsed {
    width: 80px;
    padding: 1.5rem 0.5rem;
}

.sidebar.collapsed .logo img,
.sidebar.collapsed .user-info-side span,
.sidebar.collapsed .user-role,
.sidebar.collapsed .nav-item span {
    display: none;
}

/* Center icons in collapsed state */
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 1rem 0;
}

.sidebar.collapsed .nav-item i {
    margin-right: 0;
    font-size: 1.2rem;
}

.sidebar.collapsed .logo {
    justify-content: center;
}

.sidebar.collapsed .user-info-side {
    align-items: center;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 28px;
    /* Move to top near logo */
    right: -12px;
    width: 24px;
    height: 24px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
    transition: transform 0.3s;
}

.sidebar-toggle:hover {
    color: var(--primary);
    transform: scale(1.1);
}

.hidden-mobile {
    display: flex;
}

@media (max-width: 768px) {
    .hidden-mobile {
        display: none !important;
    }
}

.side-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 2rem;
}

.nav-item {
    text-decoration: none;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    font-weight: 600;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

/* Logo constraint */
.logo img {
    max-width: 100%;
    /* Ensure it never exceeds container */
    height: auto;
    object-fit: contain;
    /* Prevent distortion */
    display: block;
    /* Remove inline spacing */
}

.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-light);
    padding: 2rem;
}

.module-view {
    display: none;
}

.module-view.active {
    display: block;
}

.user-info-side {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    /* Stack vertically for better space */
    gap: 0.5rem;
    font-size: 0.9rem;
}

/* Sidebar specific overrides for dark mode feel */
.sidebar .btn-icon {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar .btn-icon:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

.user-info-side #user-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
    color: rgba(255, 255, 255, 0.9);
}

.user-actions-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.user-info-side .badge {
    margin: 0;
    /* Clean up margin */
}

/* Glassmorphism - Premium Cards */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-normal);
}

.glass-card:hover {
    box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.15);
}

.glass-nav {
    background: var(--white);
    border-bottom: 3px solid var(--accent);
    /* Brand accent line */
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Views */
.view {
    display: none;
    flex: 1;
}

.view.active {
    display: flex;
    flex-direction: column;
}

/* Login View */
#login-view {
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

#login-view .glass-card {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.login-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.login-card p {
    color: var(--text-dim);
    margin-bottom: 2rem;
}

/* Login Theme Toggle */
.login-theme-toggle {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.login-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    transform: rotate(15deg);
}

.login-card {
    position: relative;
    padding-bottom: 5rem;
}

/* Inputs */
.input-group {
    position: relative;
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 500;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    /* Icon padding */
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-dark);
    font-size: 1rem;
    transition: all 0.2s;
}

.input-group textarea {
    padding-left: 1rem;
    /* No icon for textarea usually */
}

/* Fix padding for inputs without icons in modal if any */
/* Using generic selector to catch new forms */
form .input-group input {
    padding-left: 1rem;
}

/* Exception for login form which has icons */
#login-form .input-group input {
    padding-left: 2.5rem;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(0, 135, 186, 0.1);
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 0.8rem;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    background: #e65a00;
    /* Darker orange */
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
    transition-duration: 0.1s;
}

.btn-secondary:active {
    transform: translateY(1px) scale(0.98);
    transition-duration: 0.1s;
}

.page-header .btn-primary {
    width: auto;
    padding: 0.6rem 1.5rem;
    background: var(--primary);
}

.page-header .btn-primary:hover {
    background: var(--primary-light);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}

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

/* Dashboard */
.container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 1.8rem;
    color: var(--primary);
    font-weight: 700;
}

.page-header p {
    color: var(--text-dim);
}

/* Table */
/* Table */
.table-container {
    padding: 0;
    overflow: hidden;
    /* Main container is static */
    background: var(--bg-card-solid);
    display: flex;
    flex-direction: column;
}

.table-scroll-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    max-height: calc(100vh - 180px);
    /* Constrain height for vertical scrolling */
}

/* Sticky table header */
.data-table thead,
.expense-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table thead th,
.expense-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-light);
    /* Ensure background covers content behind */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Subtle shadow to indicate sticky header */
}

.expense-table,
.data-table {
    width: 100%;
    border-collapse: collapse;
}



.data-table tbody tr:hover {
    background-color: var(--table-hover) !important;
    /* transform removed - was causing horizontal scrollbar shift */
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: var(--bg-light);
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

/* Sortable column headers */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.data-table th.sortable:hover {
    background: var(--table-hover);
    color: var(--primary);
}

.data-table th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 0.5rem;
    opacity: 0.3;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}

.data-table th.sortable:hover::after {
    opacity: 0.6;
}

.data-table th.sortable.sort-asc::after {
    content: '▲';
    opacity: 1;
    color: var(--primary);
}

.data-table th.sortable.sort-desc::after {
    content: '▼';
    opacity: 1;
    color: var(--primary);
}


/* Ensure actions column doesn't get crushed */
.expense-table th:last-child,
.data-table th:last-child,
.expense-table td:last-child,
.data-table td:last-child {
    min-width: 90px;
    width: 1%;
    /* Compact as possible but obeying min-width */
    white-space: nowrap;
}

.expense-table td,
.data-table td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-dark);
    font-size: 0.82rem;
    /* Reverted global nowrap to allow text to wrap reasonably */
}

.expense-table tr:last-child td,
.data-table tr:last-child td {
    border-bottom: none;
}

.expense-table tr:nth-child(odd) td,
.data-table tr:nth-child(odd) td {
    background-color: var(--bg-card-solid);
}

.expense-table tr:nth-child(even) td,
.data-table tr:nth-child(even) td {
    background-color: var(--table-stripe);
}

.expense-table tr:hover td,
.data-table tr:hover td {
    background: var(--table-hover);
    transition: background 0.1s ease-in-out;
}

/* Badges */
.status-badge {
    padding: 0.35rem 0.8rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
}

.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-approved {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge {
    background: var(--bg-light);
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 1rem;
    color: var(--primary);
    border: 1px solid var(--border-color);
}

/* Sidebar badge - always on dark background */
.sidebar .badge,
.user-info-side .badge {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Demo role badge - distinctive purple gradient */
.badge[data-role="demo"],
.sidebar .badge[data-role="demo"] {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    color: white;
    border: none;
}

.logo {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--primary);
    display: flex;
    align-items: center;
}

.logo i {
    color: var(--accent);
    margin-right: 0.5rem;
}

/* Actions */
.action-btn {
    padding: 0.5rem;
    border-radius: 6px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-right: 0.3rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    filter: brightness(1.05);
}

.action-btn:active {
    transform: translateY(0);
}

.approve-btn {
    background: var(--success);
    color: white;
}

.reject-btn {
    background: var(--danger);
    color: white;
}

.approve-btn:hover {
    opacity: 0.9;
}

/* Compact Icon Action Buttons */
.icon-action-btn {
    transition: all 0.15s ease;
}

.icon-action-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.icon-action-btn:active {
    transform: translateY(0);
}

/* Kebab Dropdown Menu */
.kebab-btn:hover {
    filter: brightness(1.2);
}

.kebab-dropdown button:hover {
    background: #f1f5f9 !important;
}

/* Modal */
/* MS Login Button */
.btn-ms-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    width: 100%;
    padding: 0.8rem;
    margin-top: 1.5rem;
    background: #2f2f2f;
    color: white;
    border: 1px solid #000;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-ms-login:hover {
    background: #000;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    color: var(--primary);
}

.modal-header button {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.25rem;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.error-msg {
    color: var(--danger);
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* Top Scrollbar Logic (Global) */
.top-scroll-bar {
    width: 100%;
    overflow-x: auto !important;
    height: 16px;
    min-height: 16px;
    margin-bottom: 0px;
    display: block;
    /* Controlled by JS via opacity, but block for layout */
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid #e2e8f0;
}

.top-scroll-dummy {
    height: 1px;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {

    /* Layout Switch */
    .app-layout {
        flex-direction: column;
        height: auto;
        /* Allow scrolling body */
    }

    .sidebar {
        width: 100%;
        height: 60px;
        /* Fixed header height */

        padding: 0 1rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        position: relative;
        z-index: 100;
    }

    .logo {
        font-size: 1.2rem;
    }

    .mobile-menu-toggle {
        display: block;
        background: transparent;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
    }

    .logo {
        font-size: 1.2rem;
    }

    .side-nav {
        position: fixed;
        top: 60px;
        left: 0;
        width: 260px;
        height: calc(100vh - 60px);
        background: var(--primary);
        flex-direction: column;
        justify-content: flex-start;
        padding: 1rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        margin-top: 0;
        overflow-y: auto;
    }

    .side-nav.active {
        transform: translateX(0);
    }

    .nav-item {
        padding: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        font-size: 1rem;
        white-space: normal;
    }

    .nav-item i {
        display: inline-block;
        /* Show icons in drawer */
        width: 24px;
        margin-right: 10px;
    }

    .user-info-side {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 260px;
        background: var(--primary-light);
        padding: 1rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        z-index: 101;
        flex-direction: column;
        gap: 0.5rem;
    }

    .user-info-side.active {
        transform: translateX(0);
    }

    .main-content {
        padding: 1rem;
    }

    /* Card View for Tables */
    .table-container {
        background: transparent;
        box-shadow: none;
        padding: 0;
    }

    .data-table,
    .expense-table {
        background: transparent;
        display: block;
    }

    .data-table thead,
    .expense-table thead {
        display: none;
        /* Hide headers */
    }

    .data-table tbody,
    .expense-table tbody {
        display: block;
    }

    .data-table tr,
    .expense-table tr {
        display: block;
        background: var(--bg-card-solid);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        padding: 1rem;
    }

    .data-table td,
    .expense-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border-color);
        text-align: right;
    }

    .data-table td:last-child,
    .expense-table td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    .data-table td:before,
    .expense-table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-dim);
        font-size: 0.85rem;
        margin-right: 1rem;
        text-align: left;
    }

    /* Modal adjustments */
    .modal {
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .row {
        flex-direction: column;
        gap: 0;
    }

    /* Compact Mobile Header Controls */
    .page-header {
        column-gap: 0.5rem;
        row-gap: 0.5rem;
    }

    .page-header>div:first-child {
        flex: 0 0 100% !important;
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    .page-header .search-input {
        flex: 1;
        min-width: 0;
        width: auto;
        padding: 0.6rem 0.8rem;
    }

    .page-header .add-btn,
    .page-header .quick-add-btn {
        width: 40px !important;
        min-width: 40px !important;
        height: 40px;
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0 !important;
        margin-right: 0;
    }

    .page-header .add-btn i,
    .page-header .quick-add-btn i {
        font-size: 1.1rem;
        margin: 0;
    }
}

/* Page Header Layout */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.page-header>div:first-child {
    flex: 1;
    min-width: 200px;
}

/* Search Input Styling */
.search-input {
    padding: 0.7rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: white;
    min-width: 200px;
    max-width: 300px;
    flex-shrink: 0;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.1);
}

.search-input::placeholder {
    color: #94a3b8;
}

/* CSV Import Cards */
.import-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.import-card {
    padding: 1.5rem;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
}

.import-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.1);
    transform: translateY(-2px);
}

.import-card h4 {
    margin: 0 0 1rem 0;
    color: var(--primary);
    font-size: 1.1rem;
}

.import-card .file-input {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* ===========================
   INLINE EDITING STYLES
   =========================== */

/* Editable cells */
.editable-cell {
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.editable-cell:hover {
    background-color: #f0f9ff !important;
    outline: 1px dashed #3b82f6;
}

.editable-cell::after {
    content: '✎';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #94a3b8;
    opacity: 0;
    transition: opacity 0.2s;
}

.editable-cell:hover::after {
    opacity: 1;
}

/* Cell in edit mode */
.editing-cell {
    padding: 0 !important;
    background-color: var(--bg-input) !important;
}

.editing-cell input,
.editing-cell select {
    width: 100%;
    padding: 8px;
    border: 2px solid #3b82f6;
    border-radius: 4px;
    font-size: inherit;
    font-family: inherit;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: var(--bg-card-solid);
    color: var(--text-primary);
}

.editing-cell input:focus,
.editing-cell select:focus {
    border-color: #2563eb;
}

/* Saving state */
.cell-saving {
    opacity: 0.6;
    pointer-events: none;
    background-color: rgba(245, 158, 11, 0.2) !important;
}

.cell-saving::before {
    content: '⏳';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    animation: pulse 1s ease-in-out infinite;
}

/* Success feedback */
.cell-success {
    background-color: rgba(16, 185, 129, 0.2) !important;
    transition: background-color 0.3s ease;
}

/* Error feedback */
.cell-error {
    background-color: rgba(239, 68, 68, 0.2) !important;
    transition: background-color 0.3s ease;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===========================
   BATCH EDITING STYLES
   =========================== */

/* Batch edit toolbar */
.batch-toolbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 8px;
    display: none;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.batch-toolbar.active {
    display: flex;
}

.batch-toolbar-count {
    font-weight: 600;
    color: #92400e;
    font-size: 0.95rem;
}

.batch-toolbar button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.batch-toolbar .btn-batch-edit {
    background: #f59e0b;
    color: white;
}

.batch-toolbar .btn-batch-edit:hover {
    background: #d97706;
}

.batch-toolbar .btn-clear {
    background: white;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.batch-toolbar .btn-clear:hover {
    background: #fef3c7;
}

/* Batch delete button - red for destructive action */
.batch-toolbar .btn-batch-delete {
    background: #ef4444;
    color: white;
}

.batch-toolbar .btn-batch-delete:hover {
    background: #dc2626;
}

/* Row selection checkbox */
.row-select-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #f59e0b;
}

.select-all-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #f59e0b;
}

/* Checkbox column */
td.checkbox-cell,
th.checkbox-cell {
    width: 40px;
    text-align: center;
    padding: 0.6rem 0.5rem !important;
}

/* Batch edit modal */
#batch-edit-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000 !important;
    align-items: center;
    justify-content: center;
}

#batch-edit-modal.active {
    display: flex !important;
}

#batch-edit-modal .modal-content {
    background: var(--bg-card-solid);
    border-radius: 12px;
    padding: 24px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

#batch-edit-modal h2 {
    margin: 0 0 20px 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

#batch-edit-modal label {
    display: block;
    margin: 12px 0 6px 0;
    font-weight: 600;
    color: var(--text-secondary);
}

#batch-field-select,
#batch-value-input {
    width: 100%;
    padding: 10px;
    margin: 0 0 12px 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

#batch-field-select:focus,
#batch-value-input:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.batch-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.batch-modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.batch-modal-actions .btn-cancel {
    background: #e5e7eb;
    color: #374151;
}

.batch-modal-actions .btn-cancel:hover {
    background: #d1d5db;
}

.batch-modal-actions .btn-apply {
    background: #f59e0b;
    color: white;
}

.batch-modal-actions .btn-apply:hover {
    background: #d97706;
}

/* Duplicate button in toolbar */
.batch-toolbar .btn-duplicate {
    background: #3b82f6;
    color: white;
}

.batch-toolbar .btn-duplicate:hover {
    background: #2563eb;
}

/* ============================================
   DUPLICATE MODAL STYLES
   ============================================ */

#duplicate-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000 !important;
    align-items: center;
    justify-content: center;
}

#duplicate-modal.active {
    display: flex !important;
}

#duplicate-modal .modal-content {
    background: var(--bg-card-solid);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

#duplicate-modal h2 {
    margin: 0 0 20px 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

#duplicate-modal .input-group {
    margin-bottom: 16px;
}

#duplicate-modal label {
    display: block;
    margin: 0 0 8px 0;
    font-weight: 600;
    color: var(--text-secondary);
}

#duplicate-copy-count {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

#duplicate-copy-count:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#duplicate-modal .btn-duplicate {
    background: #3b82f6;
    color: white;
}

#duplicate-modal .btn-duplicate:hover {
    background: #2563eb;
}

/* ============================================
   AUDIT LOG STYLES
   ============================================ */

/* Audit Log Modal */
#audit-log-modal {
    display: none;
    position: fixed;
    z-index: 10000 !important;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

#audit-log-modal.active {
    display: flex;
}

#audit-log-modal .modal-content {
    background: var(--bg-card-solid);
    padding: 30px;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
    border: 1px solid var(--border-color);
}

#audit-log-modal .close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-dim);
    cursor: pointer;
}

#audit-log-modal .close:hover {
    color: var(--text-primary);
}

#audit-log-modal h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.5rem;
}

/* History Button */
.history-btn {
    background: #3b82f6;
    border: none;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.history-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Audit Timeline */
.audit-timeline {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.audit-entry {
    display: flex;
    gap: 15px;
    padding: 15px;
    border-radius: 8px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    transition: all 0.2s;
}

.audit-entry:hover {
    background: var(--table-hover);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.audit-entry.create {
    border-left-color: #10b981;
}

.audit-entry.update {
    border-left-color: #3b82f6;
}

.audit-entry.delete {
    border-left-color: #ef4444;
}

.audit-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.audit-details {
    flex: 1;
}

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

.audit-action {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.audit-timestamp {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.audit-user {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.audit-change {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-top: 5px;
}

.audit-change strong {
    color: var(--text-primary);
    margin-right: 5px;
}

.old-value {
    background: #fee2e2;
    color: #991b1b;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.new-value {
    background: #dcfce7;
    color: #166534;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.arrow {
    margin: 0 8px;
    color: #64748b;
    font-weight: bold;
}

/* Loading and Error States */
.loading,
.no-history,
.error {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

.error {
    color: #dc2626;
}

/* ============================================
   QUICK ADD ROW STYLES
   ============================================ */

/* Quick Add Button */
.quick-add-btn {
    background: #10b981;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    margin-left: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
}

.quick-add-btn:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.quick-add-btn i {
    margin-right: 0.5rem;
}

/* Quick Add Row */
.quick-add-row {
    background: rgba(245, 158, 11, 0.15) !important;
    border: 2px solid #f59e0b !important;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quick-add-row td {
    padding: 0 !important;
    vertical-align: middle;
}

.quick-add-row input,
.quick-add-row select {
    width: 100%;
    border: none;
    padding: 0.5rem;
    background: transparent;
    font-size: 0.875rem;
}

.quick-add-row input:focus,
.quick-add-row select:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
    background: var(--bg-card-solid);
    color: var(--text-primary);
}

.quick-add-row .required-field {
    background: rgba(245, 158, 11, 0.2);
    border-left: 3px solid #f59e0b;
}

.quick-add-row .required-field input {
    font-weight: 500;
}

.quick-add-row .field-error {
    border-left-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.15) !important;
}

.quick-add-row .field-valid {
    border-left-color: #10b981 !important;
}

.quick-add-saving {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.quick-add-saving::after {
    content: '💾 Išsaugoma...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    z-index: 1000;
}

/* Empty state for quick add cells */
.quick-add-row td.non-editable {
    text-align: center;
    color: #9ca3af;
    font-size: 0.75rem;
}

/* Autocomplete dropdown */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 0.5rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s;
}

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

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    z-index: 100000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: toastSlideIn 0.3s ease-out, toastFadeOut 0.3s ease-in 2.7s forwards;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.toast-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.toast-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.toast-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* ============================================
   SAVING INDICATOR
   ============================================ */
.saving-indicator {
    display: inline-block;
    margin-left: 4px;
    animation: savingPulse 0.8s ease-in-out infinite;
}

@keyframes savingPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ============================================
   OPTIMISTIC UI ROW STATES
   ============================================ */
.row-optimistic-update {
    position: relative;
    overflow: hidden;
}

.row-optimistic-update::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.1), transparent);
    animation: shimmer 1s ease-out;
}

@keyframes shimmer {
    to {
        left: 100%;
    }
}

/* Theme Toggle Animation */
#theme-toggle i {
    transition: transform 0.3s ease;
}

#theme-toggle:hover i {
    transform: rotate(15deg);
}


.autocomplete-item:hover {
    background: #f3f4f6;
}

/* Micro-interactions & Animations */
/* Row hover effects disabled for debugging */
/*
.data-table tbody tr:hover td {
    background-color: var(--table-hover) !important;
}
*/




@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}