/**
 * NimkarGuruji Office Management System
 * Main Stylesheet
 * Developed by Vedatricks Technologies Pvt Ltd
 */

/* ===== CSS VARIABLES ===== */
:root {
    --primary: #7a1f1f;
    --primary-dark: #5a1515;
    --primary-light: #9a3f3f;
    --accent: #c9a961;
    --accent-dark: #b89a51;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-dark: #1f2937;

    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-light: #ffffff;

    --border-color: #e5e7eb;
    --border-radius: 8px;
    --border-radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);

    --sidebar-width: 260px;
    --header-height: 60px;

    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: all 0.3s ease;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== LAYOUT ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-light);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand img {
    height: 60px;
    margin-bottom: 8px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.sidebar-brand .sidebar-logo {
    filter: brightness(0) invert(1);
    opacity: 0.95;
}

.sidebar-brand span {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    margin-top: 5px;
    letter-spacing: 1px;
}

/* Navigation */
.sidebar-nav {
    padding: 15px 0;
}

.nav-section {
    margin-bottom: 10px;
}

.nav-section-title {
    padding: 10px 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
}

.nav-item {
    display: block;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border-left-color: var(--accent);
}

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

.nav-item span {
    flex: 1;
}

/* Nav item attention dot — shown on items that need action */
.nav-item.has-alert i {
    position: relative;
}

.nav-item.has-alert i::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -4px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 1.5px solid var(--primary-dark);
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.6);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.top-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-primary);
    cursor: pointer;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-search {
    position: relative;
}

.header-search input {
    width: 250px;
    padding: 8px 15px 8px 35px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 13px;
    transition: var(--transition);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(122, 31, 31, 0.1);
}

.header-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover {
    background: var(--bg-primary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: var(--text-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-info {
    text-align: left;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.user-role {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 25px;
}

/* ===== COMPONENTS ===== */

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    color: var(--primary);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

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

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-icon.primary {
    background: rgba(122, 31, 31, 0.1);
    color: var(--primary);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-icon.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.stat-icon.accent {
    background: rgba(201, 169, 97, 0.1);
    color: var(--accent-dark);
}

.stat-content h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.stat-content p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    color: var(--text-light);
}

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

.btn-accent:hover {
    background: var(--accent-dark);
}

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

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

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

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--text-light);
}

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

.btn .fab,
.btn-sm .fab,
.table-actions .fab {
    font-size: inherit;
    vertical-align: middle;
    line-height: 1;
}

/* WhatsApp buttons — brand green with clearly visible logo */
.btn .fa-whatsapp,
.btn-sm .fa-whatsapp {
    font-size: 15px;
}

.table-actions .btn-sm .fa-whatsapp {
    font-size: 16px;
}

/* Inline WhatsApp icon links (e.g. referral thank-you) */
a[href*="wa.me"] .fa-whatsapp,
a[href*="whatsapp"] .fa-whatsapp {
    font-size: 15px;
}

/* WhatsApp brand button (used in table actions and inline) */
.btn-whatsapp,
.table-actions [style*="25d366"],
.table-actions .btn-success {
    background: #25D366 !important;
    color: #fff !important;
    border: none;
}

.btn-whatsapp:hover,
.table-actions [style*="25d366"]:hover,
.table-actions .btn-success:hover {
    background: #1DA851 !important;
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: var(--bg-secondary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(122, 31, 31, 0.1);
}

.form-control:disabled {
    background: var(--bg-primary);
    cursor: not-allowed;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--bg-primary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.table tbody tr:hover {
    background: var(--bg-primary);
}

.table-actions {
    display: flex;
    gap: 5px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: rgba(122, 31, 31, 0.1);
    color: var(--primary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.badge-secondary {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: var(--info);
}

/* Pagination */
.pagination-nav {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.pagination {
    display: flex;
    list-style: none;
    gap: 5px;
}

.page-item .page-link {
    display: block;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 13px;
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-light);
}

.page-item .page-link:hover {
    background: var(--bg-primary);
}

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

.modal-backdrop.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Footer */
.app-footer {
    padding: 15px 25px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.app-footer a {
    color: var(--primary);
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

/* ===== BOTTOM NAVIGATION (Mobile) ===== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 1001;
    padding: 4px 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
    color: var(--text-muted);
    font-size: 10px;
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    min-height: 48px;
    touch-action: manipulation;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

/* ===== SEARCH RESULTS DROPDOWN ===== */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-height: 350px;
    overflow-y: auto;
    z-index: 2000;
    margin-top: 4px;
    min-width: 300px;
}

.search-result-item {
    display: block;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.15s;
}

.search-result-item:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.search-result-name {
    font-weight: 600;
    font-size: 14px;
}

.search-result-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.search-no-results {
    padding: 15px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== PWA INSTALL BANNER ===== */
.pwa-install-banner {
    position: fixed;
    bottom: 70px;
    left: 10px;
    right: 10px;
    background: var(--primary);
    color: var(--text-light);
    border-radius: var(--border-radius-lg);
    padding: 12px 16px;
    z-index: 1100;
    box-shadow: var(--shadow-lg);
}

.pwa-install-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
}

.pwa-install-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ===== OFFLINE INDICATOR ===== */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--danger);
    color: white;
    text-align: center;
    padding: 6px;
    font-size: 12px;
    font-weight: 600;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ===== TOUCH-FRIENDLY ENHANCEMENTS ===== */
.btn, .nav-item, .bottom-nav-item, .quick-action-btn, .search-result-item {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ===== SKELETON LOADING ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== FILTER CHIPS ===== */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
}

.chip.active, .chip:hover {
    background: var(--primary);
    color: var(--text-light);
    border-color: var(--primary);
}

/* ===== FLOATING ACTION BUTTON ===== */
.fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-light);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(122, 31, 31, 0.4);
    border: none;
    cursor: pointer;
    z-index: 999;
    text-decoration: none;
    touch-action: manipulation;
}

.fab:hover {
    background: var(--primary-dark);
    color: var(--text-light);
    transform: scale(1.1);
}

/* ===== BLOCK BUTTON ===== */
.btn-block {
    display: flex;
    width: 100%;
    text-align: center;
}

/* ===== PRINT STYLES ===== */
@media print {
    .sidebar, .top-header, .bottom-nav, .pwa-install-banner, .offline-indicator,
    .app-footer, .fab, .btn, .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .page-content {
        padding: 0 !important;
    }

    body {
        background: white;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== RESPONSIVE ===== */

/* Desktop (1024px+) - full sidebar visible */
@media (min-width: 1025px) {
    .bottom-nav {
        display: none !important;
    }
}

/* Tablet & below (max 1024px) - sidebar hidden, bottom nav appears */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding-bottom: 60px;
    }

    .menu-toggle {
        display: block;
    }

    .header-search input {
        width: 180px;
    }

    .bottom-nav {
        display: flex;
    }

    .app-footer {
        padding-bottom: 70px;
    }

    .pwa-install-banner {
        bottom: 70px;
    }
}

/* Tablet (768px+) */
@media (min-width: 768px) and (max-width: 1024px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile (max 768px) */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .header-search {
        display: none;
    }

    .user-info {
        display: none;
    }

    .page-content {
        padding: 12px;
    }

    .card-body {
        padding: 15px;
    }

    .table th,
    .table td {
        padding: 10px;
        font-size: 13px;
    }

    .d-flex {
        flex-wrap: wrap;
    }

    .page-title {
        font-size: 16px;
    }

    .fab {
        display: flex;
    }

    /* Make modals slide up from bottom on mobile */
    .modal-backdrop {
        align-items: flex-end;
    }

    .modal {
        width: 100%;
        max-width: 100%;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
        max-height: 80vh;
    }
}

/* Small phones (max 480px) */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-content h3 {
        font-size: 20px;
    }

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

    .quick-actions {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .quick-action-btn {
        padding: 12px 8px;
    }

    .quick-action-btn i {
        font-size: 22px;
        margin-bottom: 6px;
    }

    .quick-action-btn span {
        font-size: 11px;
    }

    .top-header {
        padding: 0 12px;
    }

    .card-header {
        padding: 12px 15px;
    }

    .card-title {
        font-size: 14px;
    }
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f0eb 0%, #ede4da 100%);
    padding: 20px;
}

.login-container {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.login-header {
    text-align: center;
    padding: 30px 20px;
    background: #ffffff;
    color: var(--primary);
    border-bottom: 1px solid var(--border-color);
}

.login-header img {
    height: 60px;
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.login-header p {
    font-size: 13px;
    opacity: 0.9;
}

.login-body {
    padding: 30px;
}

.login-footer {
    text-align: center;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.quick-action-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.quick-action-btn i {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 10px;
}

.quick-action-btn span {
    font-size: 13px;
    font-weight: 500;
}

/* Notification Bell Button */
.notification-bell {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    position: relative;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.notification-bell:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.notification-bell.bell-subscribed {
    color: var(--primary);
}

.notification-bell.bell-subscribed i {
    animation: bellRing 0.5s ease-in-out;
}

/* Notification dot on bell */
.notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 1.5px solid #fff;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

/* Notification dropdown panel */
.notif-panel {
    display: none;
    position: absolute;
    top: 44px;
    right: 0;
    width: 360px;
    max-height: 420px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    z-index: 1000;
    overflow: hidden;
}

.notif-panel.open {
    display: block;
}

.notif-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-primary);
}

.notif-clear-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}
.notif-clear-btn:hover {
    background: rgba(122, 31, 31, 0.08);
}

.notif-sub-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.notif-sub-btn:hover {
    background: var(--bg-primary);
}

.notif-list {
    overflow-y: auto;
    max-height: 360px;
}

.notif-item {
    padding: 10px 14px;
    border-bottom: 1px solid #f5f5f5;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 12px;
    position: relative;
}

.notif-item:hover {
    background: #f8f9fa;
}

.notif-item .notif-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.notif-icon.notif-info { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.notif-icon.notif-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.notif-icon.notif-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.notif-icon.notif-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.notif-item .notif-body {
    flex: 1;
    min-width: 0;
}

.notif-item .notif-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.notif-item .notif-text {
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

.notif-item .notif-time {
    color: var(--text-muted);
    font-size: 10px;
    margin-top: 3px;
}

.notif-item .notif-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.notif-item:hover .notif-close {
    opacity: 1;
}

.notif-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

@media (max-width: 480px) {
    .notif-panel {
        width: calc(100vw - 20px);
        right: -50px;
    }
}

.notification-bell.bell-denied {
    color: var(--text-muted);
    opacity: 0.5;
}

@keyframes bellRing {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(15deg); }
    40% { transform: rotate(-15deg); }
    60% { transform: rotate(8deg); }
    80% { transform: rotate(-8deg); }
}

/* As Of Date Bar */
.as-of-date-bar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
}

.as-of-date-bar.backdated {
    background: #fff8e1;
    border-color: #f59e0b;
}

.as-of-date-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}

.as-of-date-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.as-of-date-form input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.as-of-date-bar.backdated input[type="date"] {
    border-color: #f59e0b;
    font-weight: 600;
}

.reset-date-btn {
    font-size: 12px !important;
    padding: 4px 10px !important;
}

.backdated-label {
    font-size: 12px;
    font-weight: 600;
    color: #b45309;
    margin-left: auto;
}

@media (max-width: 600px) {
    .backdated-label { margin-left: 0; width: 100%; margin-top: 6px; }
}

/* Header badge for As Of Date (shown on all pages when backdated) */
.as-of-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff8e1;
    color: #b45309;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid #f59e0b;
    text-decoration: none;
    margin-left: 8px;
    white-space: nowrap;
}

.as-of-badge:hover {
    background: #fef3c7;
}

/* Call User Button */
.call-user-bar {
    margin-bottom: 16px;
}

.call-user-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}

.call-user-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 13px;
    font-family: var(--font-primary);
    color: var(--text-primary);
    background: var(--bg-secondary);
    min-width: 180px;
}

.call-user-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    white-space: nowrap;
}

.call-user-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

@media (max-width: 600px) {
    .call-user-inner { flex-wrap: wrap; }
    .call-user-select { width: 100%; }
    .call-user-btn { width: 100%; justify-content: center; }
}
