:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --sidebar-primary: #2563eb;
    --sidebar-primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #3b82f6;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 9999;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

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

.hidden {
    display: none !important;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 10px;
}

.subtitle {
    color: var(--gray-500);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 14px;
}

.form-group label i {
    margin-right: 8px;
    color: var(--gray-500);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn i {
    font-size: 14px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-500);
    color: white;
}

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

.btn-success:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

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

.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-success:active,
.btn-danger:active,
.btn-warning:active {
    transform: translateY(1px);
    box-shadow: var(--shadow-sm);
    filter: brightness(0.96);
}

.btn:disabled,
.btn-success:disabled {
    background: var(--gray-400) !important;
    color: white;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none !important;
}

.btn-press-3d {
    box-shadow: 0 4px 0 var(--primary-dark), var(--shadow-sm);
}

.btn-press-3d:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--primary-dark), var(--shadow-sm);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.btn-export {
    min-width: 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon {
    min-width: 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.demo-credentials {
    margin-top: 30px;
    padding: 20px;
    background: var(--gray-100);
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid var(--gray-200);
}

.demo-credentials p {
    margin: 5px 0;
    color: var(--gray-600);
}

.error-message {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid rgba(220, 38, 38, 0.2);
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
}

.error-message.success-message {
    border: 1px solid rgba(5, 150, 105, 0.25);
    background: rgba(5, 150, 105, 0.08);
    color: var(--success);
}

.login-link-btn {
    margin-top: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--primary);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    padding: 6px 4px;
}

.login-link-btn:hover {
    color: var(--primary-dark);
}

.forgot-password-panel {
    margin-top: 14px;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    background: var(--gray-100);
}

.forgot-password-note {
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 12px;
}

.forgot-password-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

#send-otp-btn {
    background: var(--success);
    color: white;
}

#send-otp-btn:hover:not(:disabled) {
    filter: brightness(0.9);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

/* Sidebar */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 80px;
}

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

.logo {
    font-size: 24px;
    font-weight: 800;
    color: var(--sidebar-primary);
    letter-spacing: -1px;
}

.sidebar-toggle {
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: var(--gray-100);
}

.user-info {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--sidebar-primary), var(--sidebar-primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 20px;
    margin-bottom: 12px;
}

.user-details h4 {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.user-details p {
    font-weight: 600;
    color: var(--gray-800);
}

.sidebar-nav {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: var(--radius);
    color: var(--gray-600);
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item i {
    width: 24px;
    font-size: 18px;
    margin-right: 12px;
}

.nav-item:hover {
    background: var(--gray-100);
    color: var(--sidebar-primary);
}

.nav-item.active {
    background: var(--sidebar-primary);
    color: white;
}

.nav-item.active i {
    color: white;
}

.sidebar-badge {
    background: #d32f2f;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: auto;
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.nav-submenu {
    display: none;
    padding-left: 14px;
    margin-top: -2px;
    margin-bottom: 6px;
}

.nav-submenu.open {
    display: block;
}

.nav-subitem {
    padding: 10px 12px;
    margin-bottom: 2px;
    font-size: 13px;
}

.nav-subitem i {
    font-size: 14px;
    width: 20px;
}

.nav-caret {
    margin-left: auto;
    margin-right: 0 !important;
    width: auto !important;
    font-size: 12px !important;
    transition: transform 0.2s ease;
}

.nav-caret.open {
    transform: rotate(180deg);
}

.sidebar.collapsed .nav-item span {
    display: none;
}

.sidebar.collapsed .nav-item i {
    margin-right: 0;
}

.sidebar.collapsed .logo span {
    display: none;
}

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

.btn-logout {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

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

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--gray-100);
    transition: all 0.3s ease;
    min-height: 0;
}

.content-header {
    background: white;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
}

.page-title h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
}

.header-actions {
    display: flex;
    gap: 12px;
}

.content-body {
    padding: 30px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

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

.stat-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.stat-info h4 {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-change {
    font-size: 12px;
    margin-top: 4px;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* Ledger Tabs */
.ledger-tabs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.ledger-tab {
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ledger-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.ledger-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.ledger-tab-content {
    margin-top: 4px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    max-height: calc(60px + 11 * 60px);
    overflow-y: auto;
}

.table-responsive table thead th {
    position: sticky;
    top: 0;
    z-index: 30;
}

.data-table {
    width: 100%;
    background: white;
    border-radius: var(--radius);
    border-collapse: collapse;
    box-shadow: var(--shadow);
}

.data-table th {
    background: var(--gray-800);
    color: white;
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 13px;
}

.data-table tr:hover {
    background: var(--gray-100);
}

.data-table.compact-table th,
.data-table.compact-table td {
    padding: 10px 12px;
    vertical-align: middle;
}

.data-table.compact-table th,
.data-table.compact-table td {
    text-align: left;
}

.data-table.compact-table th:last-child,
.data-table.compact-table td:last-child {
    text-align: center;
    white-space: nowrap;
    width: 96px;
}

/* Keep table header text style consistent across all modules */
.table-responsive table th,
.table-responsive table thead th,
.data-table th {
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.25 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-active {
    background: rgba(5,150,105,0.1);
    color: var(--success);
}

.status-inactive {
    background: rgba(100,116,139,0.1);
    color: var(--gray-600);
}

.status-pending {
    background: rgba(217,119,6,0.1);
    color: var(--warning);
}

.status-paid {
    background: rgba(5,150,105,0.1);
    color: var(--success);
}

.status-partial {
    background: rgba(217,119,6,0.1);
    color: var(--warning);
}

/* Modals */
.modal,
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: min(95vw, 100%);
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    margin: auto;
    box-sizing: border-box;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
    flex: 1;
    min-width: 0;
}

.modal-header > div {
    flex-shrink: 0;
}

.close-btn {
    cursor: pointer;
    font-size: 24px;
    color: var(--gray-500);
}

.modal-body {
    padding: 20px;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        z-index: 1000;
        height: 100vh;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .content-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .header-actions,
    .btn {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        padding: 20px;
    }
    
    .data-table {
        border: 1px solid #000;
    }
}
@keyframes toolbar-alert-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}
.toolbar-alert-dot {
    background: #dc2626;
    border-radius: 50%;
    width: 10px;
    height: 10px;
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
    animation: toolbar-alert-blink 1s linear infinite;
}