/* ==================== STYLES ====================
   All visual styling and animations, extracted unchanged from the
   original inline <style> block. ==================== */
    :root {
      --primary: #1E293B;
      --secondary: #764ba2;
      --accent: #F59E0B;
      --success: #10B981; 
      --danger: #EF4444;
      --bg: #F1F5F9;
      --card-bg: rgba(255,255,255,0.95); 
      --glass-bg: rgba(255,255,255,0.85); 
      --text-dark: #334155; 
      --sidebar-width-collapsed: 78px;
      --sidebar-width-expanded: 260px;
      --header-height: 70px; 
      --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    body.dark { --bg: #0f172a; --card-bg: rgba(30,41,59,0.95); --glass-bg: rgba(30,41,59,0.85); --text-dark: #f8fafc; }
    body.dark .text-dark { color: #f8fafc !important; }
    body.dark .text-muted { color: #94a3b8 !important; }
    body.dark .bg-light { background-color: #1e293b !important; border-color: #334155 !important; }
    body.dark .table-light { background-color: #334155 !important; color: #f8fafc !important; border-color: #475569 !important; }
    body.dark .table-hover tbody tr:hover { background-color: rgba(255,255,255,0.05) !important; color: #fff; }
    body.dark td, body.dark th { border-color: #334155 !important; color: #f8fafc !important; }
    body.dark .modal-content { background-color: #0f172a !important; color: #f8fafc !important; border: 1px solid #334155; }
    body.dark .card { border-color: #334155 !important; }
    body.dark .bg-white { background-color: #1e293b !important; }
    body.dark input, body.dark select, body.dark textarea { background-color: #0f172a !important; color: #fff !important; border-color: #475569 !important; }
    body.dark ::placeholder { color: #64748b !important; opacity: 1; }
    body.dark .card-header { background-color: #1e293b !important; color: #f8fafc !important; border-color: #334155 !important; }
    body.dark .card-footer { background-color: #1e293b !important; color: #f8fafc !important; border-color: #334155 !important; }
    body.dark .modal-header, body.dark .modal-footer { border-color: #334155 !important; }
    body.dark .accordion-button { background-color: #1e293b !important; color: #f8fafc !important; }
    body.dark .accordion-button:not(.collapsed) { color: #f8fafc !important; box-shadow: none !important; }
    body.dark .accordion-button::after { filter: invert(1) brightness(2); }
    body.dark .accordion-body { background-color: #0f172a !important; color: #f8fafc !important; }
    body.dark .dropdown-menu { background-color: #1e293b !important; color: #f8fafc !important; border-color: #334155 !important; }
    body.dark .dropdown-item { color: #f8fafc !important; }
    body.dark .dropdown-item:hover { background-color: #334155 !important; }
    body.dark .btn-outline-secondary { color: #cbd5e1 !important; border-color: #475569 !important; }
    body.dark .btn-outline-secondary:hover { background-color: #334155 !important; color: #fff !important; }
    body.dark .btn-outline-info, body.dark .btn-outline-primary, body.dark .btn-outline-danger { border-color: currentColor !important; }
    body.dark .btn-close { filter: invert(1) brightness(2); }
    body.dark .list-group-item { background-color: #1e293b !important; color: #f8fafc !important; border-color: #334155 !important; }
    body.dark .alert-light, body.dark .bg-section-1, body.dark .bg-section-2, body.dark .bg-section-3 { background-color: #1e293b !important; color: #f8fafc !important; }
    body.dark .badge.bg-light { background-color: #334155 !important; color: #f8fafc !important; }
    body.dark .form-section-head { color: var(--secondary) !important; border-color: var(--secondary) !important; }
    body.dark .glass { border-color: rgba(255,255,255,0.08); }
    body.dark .compact-form label { color: #94a3b8 !important; }
    body.dark ::-webkit-scrollbar-thumb { background: #334155; }
    body.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }
    body.dark .badge.bg-white { background-color: #1e293b !important; color: #f8fafc !important; }
    body.dark .login-card { background: rgba(15,23,42,0.9) !important; }
    body.dark .table > :not(caption) > * > * { background-color: transparent; }
    body.dark #notificationDropdown { background-color: #1e293b !important; color: #f8fafc !important; }
    body.dark #notificationDropdown .border-bottom { border-color: #334155 !important; }

    /* ==================== THEME PRESETS ====================
       Each preset overrides brand colors only; --bg/--card-bg/--glass-bg/--text-dark
       remain controlled independently by the light/dark toggle above. */
    body.theme-indigo   { --primary: #2d2a5e; --secondary: #5b53a8; --accent: #e0a458; }
    body.theme-emerald  { --primary: #1b4332; --secondary: #40916c; --accent: #e0a458; }
    body.theme-sapphire { --primary: #1e3a5f; --secondary: #4a7fa5; --accent: #e8a33d; }
    body.theme-amber    { --primary: #6b4423; --secondary: #c08552; --accent: #2f6690; }
    body.theme-rose     { --primary: #6b2737; --secondary: #b56576; --accent: #6d9dc5; }
    body.theme-graphite { --primary: #2b2d42; --secondary: #6c7a89; --accent: #4ecdc4; }
    body.theme-plum     { --primary: #3c1642; --secondary: #7b4b94; --accent: #e0a458; }
    body.theme-olive    { --primary: #3a4d39; --secondary: #697a5b; --accent: #c08552; }

    .theme-swatch { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; display: inline-block; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
    .theme-swatch:hover { transform: scale(1.12); }
    .theme-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--secondary); }
    #themeDropdown { width: 220px; }
    
    * { box-sizing: border-box; }
    body { font-family: 'Inter', sans-serif; background: var(--bg); margin: 0; color: var(--text-dark); transition: background 0.3s, color 0.3s; overflow-x: hidden; }
    
    .glass { background: var(--glass-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid rgba(255,255,255,0.4); border-radius: 20px; }
    .card-lift { transition: transform 0.2s, box-shadow 0.2s; border-radius: 18px; background: var(--card-bg); border: none; box-shadow: 0 10px 25px -8px rgba(0,0,0,0.06); padding: 1.25rem; }
    .card-lift:hover { transform: translateY(-5px); box-shadow: 0 20px 30px -12px rgba(0,0,0,0.15); }
    
    .sidebar { 
      width: var(--sidebar-width-collapsed); 
      background: var(--primary); color: white; 
      position: fixed; top: 0; left: 0; height: 100vh; 
      overflow-x: hidden; z-index: 1050; 
      transition: var(--transition); 
      white-space: nowrap; 
      box-shadow: 2px 0 10px rgba(0,0,0,0.1); 
    }
    .sidebar:hover { 
      width: var(--sidebar-width-expanded); 
      box-shadow: 5px 0 25px rgba(0,0,0,0.25); 
    }
    .sidebar .nav-text, .sidebar .brand-text { 
      opacity: 0; transition: opacity 0.2s; display: inline-block; vertical-align: middle; 
    }
    .sidebar:hover .nav-text, .sidebar:hover .brand-text { 
      opacity: 1; transition-delay: 0.1s; 
    }
    
    .sidebar .nav-link { 
      color: rgba(255,255,255,0.75); border-radius: 12px; margin: 6px 12px; padding: 12px 14px; 
      transition: 0.2s; font-weight: 500; display: flex; align-items: center; cursor: pointer; 
      position: relative; overflow: hidden;
    }
    .sidebar .nav-link::after {
      content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 3px; 
      background: var(--accent); transition: width 0.3s ease;
    }
    .sidebar .nav-link:hover::after, .sidebar .nav-link.active::after { width: 100%; }
    .sidebar .nav-link i { font-size: 1.25rem; min-width: 30px; text-align: center; margin-right: 12px; z-index: 1; }
    .sidebar .nav-link:hover, .sidebar .nav-link.active { background: var(--secondary); color: white; transform: translateX(4px); }
    
    .brand-logo { max-height: 38px; max-width: 40px; margin-right: 12px; object-fit: contain; flex-shrink: 0; }
    
    .main-content { margin-left: var(--sidebar-width-collapsed); padding: 24px; min-height: 100vh; transition: margin-left 0.3s; }
    .top-header { background: var(--glass-bg); backdrop-filter: blur(12px); height: var(--header-height); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-radius: 24px; margin-bottom: 24px; position: sticky; top: 16px; z-index: 100; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
    
    @media (max-width: 992px) { 
      .sidebar { width: var(--sidebar-width-expanded); transform: translateX(-100%); } 
      .sidebar.mobile-open { transform: translateX(0); } 
      .sidebar .nav-text, .sidebar .brand-text { opacity: 1; }
      .main-content { margin-left: 0; } 
    }
    
    .floating-btn { position: fixed; bottom: 24px; right: 24px; z-index: 999; background: var(--secondary); color: white; border-radius: 50px; padding: 12px 24px; box-shadow: 0 10px 20px rgba(13, 148, 136, 0.4); border: none; font-weight: 600; }
    .toast-container { z-index: 9999; }
    .chart-container { position: relative; height: 280px; width: 100%; }
    
    .fade-in { animation: fadeIn 0.4s ease; }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes modalPop { 0% { opacity: 0; transform: scale(0.95) translateY(-10px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
    .modal-content { border-radius: 20px; overflow: hidden; animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
    @keyframes rowFadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
    .table-animated tbody tr { animation: rowFadeInUp 0.35s ease-out forwards; opacity: 0; }
    .table-animated tbody tr:nth-child(1) { animation-delay: 0.05s; }
    .table-animated tbody tr:nth-child(2) { animation-delay: 0.08s; }
    .table-animated tbody tr:nth-child(3) { animation-delay: 0.11s; }
    .table-animated tbody tr:nth-child(4) { animation-delay: 0.14s; }
    .table-animated tbody tr:nth-child(5) { animation-delay: 0.17s; }
    .table-animated tbody tr:nth-child(n+6) { animation-delay: 0.20s; }

    @keyframes gradientBG {
        0% { background-position: 0% 50%; }
        50% { background-position: 100% 50%; }
        100% { background-position: 0% 50%; }
    }
    @keyframes floatLogo {
        0% { transform: translateY(0px); }
        50% { transform: translateY(-12px); filter: drop-shadow(0 10px 15px rgba(0,0,0,0.2)); }
        100% { transform: translateY(0px); }
    }
    .animated-logo { animation: floatLogo 3.5s ease-in-out infinite; }
    .login-container { 
        min-height: 100vh; display: flex; align-items: center; justify-content: center; 
        background: linear-gradient(135deg, #667eea 50%, #764ba2 100%);
        background-size: 400% 400%;
        animation: gradientBG 15s ease infinite;
        position: relative;
    }
    .login-card { backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.2); }

    .hidden { display: none !important; }
    .badge-editable { cursor: pointer; transition: all 0.2s; }
    .badge-editable:hover { transform: scale(1.05); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
    .filter-active { background: var(--secondary) !important; color: white !important; border-color: var(--secondary) !important; }
    
    th.sortable { cursor: pointer; user-select: none; position: relative; padding-right: 20px !important; }
    th.sortable i { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); font-size: 0.7rem; color: #94a3b8; }
    th.sortable.asc i.fa-sort-up { color: var(--secondary); }
    th.sortable.desc i.fa-sort-down { color: var(--secondary); }
    
    ::-webkit-scrollbar { width: 8px; height: 8px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
    ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
    
    .compact-form label { font-size: 0.7rem; margin-bottom: 2px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
    .compact-form .form-control, .compact-form .form-select { font-size: 0.8rem; padding: 3px 8px; border-radius: 6px; }
    .compact-form .form-control-sm { font-size: 0.75rem; padding: 2px 6px; }
    .form-section-head { font-size: 0.75rem; font-weight: 700; color: var(--secondary); border-bottom: 1px solid var(--secondary); padding-bottom: 3px; margin-bottom: 8px; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
    .bg-section-1 { background-color: #f8fafc; border-radius: 8px; padding: 10px; }
    .bg-section-2 { background-color: #f0fdfa; border-radius: 8px; padding: 10px; }
    .bg-section-3 { background-color: #fffbeb; border-radius: 8px; padding: 10px; }

    .cal-cell { height: 110px; vertical-align: top; padding: 6px; position: relative; }
    .cal-day-num { position: absolute; top: 4px; right: 6px; font-weight: 700; font-size: 0.8rem; color: #94a3b8; }
    .cal-entry { background-color: #F59E0B; color: #fff; padding: 3px 6px; border-radius: 4px; font-size: 0.7rem; margin-bottom: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
    .cal-entry:hover { transform: scale(1.02); filter: brightness(1.1); }
    body.dark .cal-day-num { color: #cbd5e1; }

    .status-received { background-color: #d1fae5; color: #065f46; }
    .status-pending { background-color: #fef3c7; color: #92400e; }
    .status-paid { background-color: #d1fae5; color: #065f46; }
    .status-unpaid { background-color: #fee2e2; color: #991b1b; }

    .report-card {
      transition: transform 0.2s, box-shadow 0.2s;
      border-radius: 16px;
      background: var(--card-bg);
      border: none;
      box-shadow: 0 4px 12px rgba(0,0,0,0.06);
      padding: 1.5rem 1.25rem;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
    }
    .report-card:hover {
      transform: translateY(-4px);
      box-shadow: 0 12px 28px rgba(0,0,0,0.12);
    }
    .report-card .report-icon {
      width: 56px;
      height: 56px;
      border-radius: 50%;
      background: var(--bg);
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 12px;
      font-size: 1.5rem;
      color: var(--secondary);
      flex-shrink: 0;
    }
    .report-card h6 {
      font-weight: 700;
      margin-bottom: 14px;
      font-size: 0.95rem;
      color: var(--text-dark);
    }
    .report-card .btn-group {
      width: 100%;
    }
    .report-card .btn-group .btn {
      flex: 1;
      font-size: 0.75rem;
      padding: 6px 4px;
    }
    body.dark .report-card .report-icon {
      background: #1e293b;
    }

    .claim-intimated { background-color: #fef3c7; color: #92400e; }
    .claim-surveyor { background-color: #bfdbfe; color: #1e40af; }
    .claim-repair { background-color: #e9d5ff; color: #6b21a8; }
    .claim-documents { background-color: #dbeafe; color: #1e40af; }
    .claim-settlement { background-color: #d1fae5; color: #065f46; }
    .claim-payment { background-color: #a7f3d0; color: #065f46; }
    .claim-settled { background-color: #d1fae5; color: #065f46; }
    .claim-rejected { background-color: #fee2e2; color: #991b1b; }
    .claim-withdrawn { background-color: #f3f4f6; color: #4b5563; }
    
    .claim-step-item {
      padding: 4px 10px;
      border-radius: 6px;
      margin-bottom: 3px;
      cursor: pointer;
      transition: all 0.2s ease;
      border-left: 3px solid #e5e7eb;
      font-size: 0.75rem;
    }
    .claim-step-item:hover { background: var(--bg); }
    .claim-step-item.active { border-left-color: var(--secondary); background: #f0fdfa; }
    .claim-step-item.completed { border-left-color: var(--success); background: #d1fae5; }
    .claim-step-item .step-num { 
      width: 18px; height: 18px; border-radius: 50%; 
      display: inline-flex; align-items: center; justify-content: center;
      font-weight: 700; font-size: 0.55rem;
      background: #e5e7eb; color: #6b7280;
      margin-right: 6px;
    }
    .claim-step-item.active .step-num { background: var(--secondary); color: white; }
    .claim-step-item.completed .step-num { background: var(--success); color: white; }
    
    .claim-stage-collapse .card-header {
      padding: 6px 12px;
      cursor: pointer;
      background: #f8fafc;
    }
    .claim-stage-collapse .card-header:hover { background: #f1f5f9; }
    .claim-stage-collapse .card-body { padding: 8px 12px; }
    
    .field-required { color: var(--danger); font-weight: 700; margin-left: 2px; }
    .field-error { border-color: var(--danger) !important; background-color: #fef2f2 !important; }
    .field-error:focus { border-color: var(--danger) !important; box-shadow: 0 0 0 0.2rem rgba(239, 68, 68, 0.25) !important; }

    .claim-indicator {
      display: inline-block;
      background: #EF4444;
      color: white;
      font-size: 0.5rem;
      font-weight: 700;
      padding: 1px 5px;
      border-radius: 10px;
      line-height: 1.4;
      margin-left: 4px;
      cursor: pointer;
      vertical-align: top;
      min-width: 16px;
      text-align: center;
      transition: all 0.2s;
    }
    .claim-indicator:hover {
      transform: scale(1.15);
      background: #dc2626;
    }
    body.dark .claim-indicator {
      background: #EF4444;
    }

    /* User management modal styles */
    .user-modal .form-label {
      font-weight: 600;
      color: #475569;
    }
    .user-modal .form-control, .user-modal .form-select {
      border-radius: 8px;
      padding: 8px 12px;
    }
    .user-modal .modal-header {
      border-bottom: 2px solid var(--secondary);
    }
    .user-role-badge {
      font-size: 0.7rem;
      padding: 3px 10px;
      border-radius: 12px;
    }
    
    /* Loading overlay */
    .loading-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.5);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 9999;
    }
    .loading-overlay .spinner {
      width: 50px;
      height: 50px;
      border: 5px solid #fff;
      border-top-color: var(--secondary);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }
    @keyframes spin {
      to { transform: rotate(360deg); }
    }
