:root {
  --primary: #2c3e50;
  --accent: #1e40af;
  --accent-light: #2563eb;
  --bg: #f5f5f5;
  --muted: #777;
  --card: #ffffff;
  --border: #e0e0dc;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--primary);
}

/* LOGIN */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0f1c, #1c2331, #0f1624);
  color: #fff;
}
.login-box {
  width: 360px;
  background: #1e2a38;
  padding: 26px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
  text-align: center;
}
.logo-container { margin-bottom: 10px; }
.company-logo { max-width: 120px; max-height: 120px; }
.login-box h1 { font-size: 22px; color: #f97316; }
.login-box h2 { font-size: 16px; color: #cfd8dc; margin: 4px 0; }
.login-box p { color: #90a4ae; margin-bottom: 14px; }
.input-group { display:flex; align-items:center; margin:8px 0; background:#263238; border:1px solid #050d11; border-radius:6px; padding:8px; }
.input-group i { margin-right:8px; color:#90a4ae; }
.input-group input, .input-group select { flex:1; background:transparent; border:none; color:#e2e9ee; }
.login-btn { margin-top:14px; padding:10px; width:100%; border-radius:6px; border:none; background:#00bcd4; color:#fff; font-weight:600; cursor:pointer; }
.login-btn:hover { background:#0097a7; }
.admin-info { margin-top:12px; font-size:12px; color:#b0bec5; }

/* HEADER */
.app-header { display:flex; justify-content:space-between; align-items:center; padding:12px 20px; background:linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%); color:#fff; box-shadow:0 2px 4px rgba(0,0,0,0.1); position:sticky; top:0; z-index:1000; }
.header-left { display:flex; align-items:center; gap:12px; }
.header-logo { width:48px; height:48px; }
.company-info { min-width:0; }
.company-info h1 { margin:0; font-size:18px; }
.system-name { font-size:12px; color:#d1f2e6; display:block; }
.mobile-menu-toggle { display:none; background:rgba(255,255,255,0.2); border:none; color:white; padding:8px 12px; border-radius:6px; cursor:pointer; font-size:18px; flex-shrink:0; }
.mobile-menu-toggle { display:none; background:rgba(255,255,255,0.2); border:none; color:white; padding:8px 12px; border-radius:6px; cursor:pointer; font-size:18px; }

/* BODY */
.app-body { display:flex; min-height:calc(100vh - 64px); }
.sidebar { 
  width:300px; 
  background:#f9fafb; 
  border-right:2px solid #e5e7eb; 
  padding:20px; 
  overflow-y:auto; 
  position:relative;
  display:flex;
  flex-direction:column;
  transition:transform 0.3s ease;
}
.sidebar.mobile-hidden {
  transform: translateX(-100%);
}
.main-content { flex:1; padding:20px; background:#f5f5f5; }
.year-selector label, .month-selector label { color:#374151; }
.year-selector select { border:2px solid #e5e7eb; }

/* Months */
.month-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; }
.month-btn { padding:10px 8px; border-radius:8px; border:2px solid #e5e7eb; background:#fff; cursor:pointer; font-size:12px; font-weight:500; transition:all 0.2s; text-align:center; }
.month-btn:hover { border-color:var(--accent); background:#eff6ff; transform:translateY(-1px); }
.month-btn.active { background:var(--accent); color:#fff; border-color:var(--accent); box-shadow:0 2px 4px rgba(59,130,246,0.3); }

/* Categories */
.category-section { 
  margin-top:24px; 
  position:sticky; 
  top:20px; 
  background:#f9fafb; 
  padding:16px; 
  border-radius:12px; 
  border:2px solid #e5e7eb;
}
.category-section h3 { 
  font-size:18px; 
  color:#1f2937; 
  margin:0 0 16px 0; 
  padding-bottom:12px; 
  border-bottom:2px solid #e5e7eb; 
  font-weight:700;
  display:flex;
  align-items:center;
  gap:10px;
}
.category-group { 
  margin-bottom:20px; 
  background:#fff; 
  border-radius:10px; 
  padding:14px; 
  box-shadow:0 2px 4px rgba(0,0,0,0.08); 
  border:1px solid #e5e7eb;
  transition:all 0.2s;
}
.category-group:hover {
  box-shadow:0 4px 8px rgba(0,0,0,0.12);
  transform:translateY(-1px);
}
.category-group-header { 
  display:flex; 
  justify-content:space-between; 
  align-items:center; 
  font-weight:600; 
  padding:8px 0; 
  color:#1f2937; 
  font-size:15px; 
  margin-bottom:8px;
}
.category-group-header h4 { 
  margin:0; 
  font-size:15px; 
  font-weight:600;
}
.category-lock { 
  color:#78716c; 
  font-size:14px; 
}
.category-items { 
  max-height:250px; 
  overflow-y:auto; 
  margin-top:8px; 
  padding-right:4px;
}
.category-items::-webkit-scrollbar {
  width:6px;
}
.category-items::-webkit-scrollbar-track {
  background:#f1f1f1;
  border-radius:3px;
}
.category-items::-webkit-scrollbar-thumb {
  background:#cbd5e1;
  border-radius:3px;
}
.category-items::-webkit-scrollbar-thumb:hover {
  background:#94a3b8;
}
.category-item { 
  padding:10px 12px; 
  border-radius:8px; 
  cursor:pointer; 
  margin-bottom:6px; 
  font-size:14px; 
  transition:all 0.2s; 
  border-left:3px solid transparent; 
  background:#f9fafb;
  font-weight:500;
}
.category-item:hover { 
  background:#f0fdfa; 
  border-left-color:var(--accent); 
  padding-left:14px; 
  transform:translateX(2px);
}
.category-item.active { 
  background:var(--accent); 
  color:#fff; 
  border-left-color:#1e3a8a; 
  font-weight:600; 
  box-shadow:0 2px 4px rgba(30,64,175,0.3);
}

/* Toolbar & files */
.toolbar { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; flex-wrap: wrap; }
.toolbar > div {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.file-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:12px; }
.file-card { background:#fff; padding:12px; border-radius:6px; border:1px solid var(--border); box-sizing: border-box; }
.file-card > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.file-card button {
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  min-width: calc(50% - 4px);
}
.empty-state { text-align:center; padding:40px; color:var(--muted); }
.big-icon { font-size:36px; color:var(--accent); }

/* Modal */
.modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.45); align-items:center; justify-content:center; }
.modal-content { background:#fff; padding:20px; border-radius:10px; width:100%; max-width:540px; }
/* Category PIN modal fixes */
#pinModal .modal-content {
  background: #fff;
  padding: 24px;
  border-radius: 10px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}

#pinModal h3 {
  margin-bottom: 16px;
  font-size: 18px;
  color: var(--primary);
}

#pinModal label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--primary);
}

#pinModal input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-bottom: 14px;
}

#pinModal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}    


/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.loading-spinner {
  text-align: center;
  color: #fff;
}

/* Responsive - Mobile First Approach */
@media (max-width: 768px) {
  /* Mobile Menu Toggle */
  .mobile-menu-toggle {
    display: block !important;
    min-width: 44px;
    min-height: 44px;
  }

  /* Login Screen Mobile */
  .login-container {
    padding: 16px;
    min-height: 100vh;
    align-items: flex-start;
    padding-top: 40px;
  }
  .login-box {
    width: 100%;
    max-width: 100%;
    padding: 24px 20px;
    margin: 0;
    border-radius: 16px;
  }
  .login-box h1 {
    font-size: 20px;
    line-height: 1.3;
  }
  .login-box h2 {
    font-size: 14px;
    margin: 6px 0;
  }
  .company-logo {
    max-width: 90px;
    max-height: 90px;
    margin-bottom: 12px;
  }
  .input-group {
    margin: 10px 0;
    padding: 12px;
    min-height: 48px;
  }
  .input-group input,
  .input-group select {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  .login-btn {
    padding: 14px;
    font-size: 16px;
    margin-top: 16px;
    min-height: 48px;
  }

  /* Header Mobile */
  .app-header {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1001;
  }
  .mobile-menu-toggle {
    order: 0;
    margin-right: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .header-left {
    flex: 1;
    min-width: 0;
    order: 1;
    gap: 8px !important;
    overflow: hidden;
  }
  .header-logo {
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0;
  }
  .company-info {
    min-width: 0;
    overflow: hidden;
  }
  .company-info h1 {
    font-size: 14px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1.2;
  }
  .system-name {
    font-size: 10px !important;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .user-info {
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 11px !important;
    order: 2;
    width: auto;
    flex: 0 0 auto;
    min-width: 0;
  }
  .user-info > div:first-child {
    flex-shrink: 0;
  }
  .user-info > div:last-child {
    display: none; /* Hide text on very small screens */
  }
  .user-info #userAvatar {
    width: 36px !important;
    height: 36px !important;
    font-size: 14px !important;
    min-width: 36px;
    min-height: 36px;
  }
  .header-right {
    flex-wrap: nowrap !important;
    gap: 6px !important;
    order: 3;
    width: 100%;
    justify-content: flex-end;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  .header-right button {
    padding: 8px 12px !important;
    font-size: 13px !important;
    flex: 1;
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .header-right button i {
    font-size: 14px;
  }
  .header-right button:not(#darkModeToggle) {
    min-width: 44px;
    justify-content: center;
  }
  #darkModeToggle {
    min-width: 44px;
    padding: 8px !important;
  }
  .profile-btn,
  .admin-btn,
  #logoutBtnHeader {
    padding: 8px 12px !important;
    font-size: 13px !important;
    min-height: 44px;
  }
  .profile-btn span,
  .admin-btn span,
  #logoutBtnHeader span {
    display: none !important; /* Hide text, show only icons on mobile */
  }
  .profile-btn i,
  .admin-btn i,
  #logoutBtnHeader i {
    margin: 0 !important;
    font-size: 16px;
  }

  /* Body Layout Mobile */
  .app-body {
    flex-direction: column;
    position: relative;
    min-height: calc(100vh - 64px);
  }
  .sidebar {
    width: 100%;
    max-width: 320px;
    padding: 20px 16px;
    border-right: none;
    border-bottom: none;
    max-height: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    background: #f9fafb;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }
  .sidebar.mobile-visible {
    transform: translateX(0);
  }
  .main-content {
    padding: 16px;
    width: 100%;
    min-height: calc(100vh - 64px);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.visible {
    display: block;
  }

  /* Year & Month Selectors Mobile */
  .year-selector,
  .month-selector {
    margin-bottom: 20px;
  }
  .year-selector label,
  .month-selector label {
    font-size: 14px;
    margin-bottom: 8px;
    display: block;
  }
  .year-selector select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    min-height: 48px;
    border-radius: 8px;
  }
  .month-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .month-btn {
    padding: 12px 8px;
    font-size: 12px;
    min-height: 48px;
    font-weight: 600;
    border-radius: 8px;
  }

  /* Category Section Mobile */
  .category-section {
    position: relative;
    top: 0;
    margin-top: 20px;
    padding: 16px;
    border-radius: 12px;
  }
  .category-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }
  .category-group {
    margin-bottom: 16px;
    padding: 14px;
    border-radius: 10px;
  }
  .category-group-header {
    font-size: 14px;
    margin-bottom: 10px;
  }
  .category-group-header h4 {
    font-size: 14px;
  }
  .category-item {
    padding: 12px;
    font-size: 14px;
    min-height: 48px;
    margin-bottom: 8px;
    border-radius: 8px;
  }
  .category-list {
    max-height: none;
    overflow-y: visible;
  }

  /* Toolbar Mobile */
  .toolbar {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
  }
  .toolbar > div {
    width: 100% !important;
    flex-direction: column !important;
    gap: 12px !important;
    margin-bottom: 0 !important;
  }
  .breadcrumb {
    font-size: 16px !important;
    font-weight: 600;
    margin-bottom: 12px;
    width: 100%;
    line-height: 1.4;
    color: #1f2937;
  }
  .breadcrumb i {
    font-size: 16px;
    margin-right: 8px;
  }
  #searchInput {
    width: 100% !important;
    max-width: 100% !important;
    padding: 14px 40px 14px 14px !important;
    font-size: 16px !important;
    box-sizing: border-box;
    min-height: 48px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
  }
  #searchInput + i {
    right: 14px !important;
    font-size: 16px;
  }
  #openUploadModal {
    width: 100% !important;
    justify-content: center !important;
    padding: 14px 20px !important;
    font-size: 16px !important;
    min-height: 48px;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
  }
  #bulkActionsBar {
    flex-direction: column !important;
    width: 100% !important;
    padding: 16px !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
    border-radius: 10px;
  }
  #bulkActionsBar span {
    text-align: center;
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 600;
  }
  #bulkActionsBar button {
    width: 100% !important;
    padding: 14px !important;
    font-size: 15px !important;
    margin: 0 !important;
    min-height: 48px;
    border-radius: 8px;
    font-weight: 600;
  }

  /* File Grid Mobile */
  .file-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  .file-card {
    padding: 16px !important;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
  }
  .file-title {
    font-size: 16px !important;
    margin-bottom: 8px !important;
    word-wrap: break-word;
    line-height: 1.4;
    font-weight: 600;
    color: #1f2937;
  }
  .file-meta {
    font-size: 13px !important;
    margin-bottom: 12px !important;
    line-height: 1.5;
    color: #6b7280;
  }
  .file-amount {
    font-size: 22px !important;
    margin-bottom: 16px !important;
    font-weight: 700;
    color: #059669;
  }
  .file-card > div:last-child {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100%;
  }
  .file-card button {
    width: 100% !important;
    padding: 14px !important;
    font-size: 15px !important;
    font-weight: 600;
    margin: 0 !important;
    box-sizing: border-box;
    min-height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  .file-card button i {
    font-size: 16px;
  }
  .receipt-checkbox {
    width: 28px !important;
    height: 28px !important;
    top: 12px !important;
    right: 12px !important;
    min-width: 28px;
    min-height: 28px;
  }

  /* Modals Mobile */
  .modal {
    padding: 0;
    align-items: flex-end;
    overflow-y: hidden;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
  }
  .modal-content {
    max-width: 100% !important;
    width: 100%;
    margin: 0;
    padding: 24px 20px;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease-out;
  }
  @keyframes slideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  .modal-header {
    padding: 0 0 20px 0;
    margin: 0 0 20px 0;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    padding-bottom: 16px;
    margin-bottom: 20px;
  }
  .modal-header h2,
  .modal-header h3 {
    font-size: 20px;
    margin: 0;
    font-weight: 700;
  }
  .close-btn {
    font-size: 32px;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    background: transparent;
    border: none;
    cursor: pointer;
  }

  /* Profile Modal Mobile */
  #profileModal .modal-content {
    max-height: 90vh;
    padding: 0;
  }
  #profileModal .modal-header {
    padding: 20px;
    margin: 0;
    border-radius: 20px 20px 0 0;
  }
  #profileModal .modal-header > div {
    flex: 1;
  }
  .profile-tab {
    padding: 14px 12px !important;
    font-size: 12px !important;
    white-space: nowrap;
    overflow-x: auto;
    flex-shrink: 0;
  }
  .profile-tab i {
    font-size: 14px;
    margin-right: 6px;
  }
  #profileModal .modal-header > div:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  #profilePictureContainer {
    width: 60px !important;
    height: 60px !important;
    font-size: 24px !important;
  }
  #profileModal .modal-header h2 {
    font-size: 18px;
  }
  #profileModal .modal-header p {
    font-size: 13px;
  }
  #profileModal > div > div:last-child {
    padding: 20px;
  }
  #profileModal [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  #profileModal button[id*="Btn"] {
    width: 100% !important;
    padding: 16px !important;
    font-size: 15px !important;
    min-height: 56px;
  }

  /* Forms Mobile */
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    width: 100%;
    padding: 14px;
    font-size: 16px; /* Prevents zoom on iOS */
    border-radius: 8px;
    min-height: 48px;
    border: 2px solid #e5e7eb;
    box-sizing: border-box;
  }
  input[type="text"]:focus,
  input[type="password"]:focus,
  input[type="number"]:focus,
  input[type="date"]:focus,
  select:focus,
  textarea:focus {
    outline: none;
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
  }
  label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
  }
  button[type="submit"],
  .submit-btn {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    margin-top: 16px;
    min-height: 48px;
    font-weight: 600;
    border-radius: 8px;
  }
  .cancel-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    min-height: 48px;
    border-radius: 8px;
    font-weight: 600;
  }
  .modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
  }
  .modal-actions button {
    width: 100%;
  }

  /* Breadcrumb Mobile */
  .breadcrumb {
    font-size: 15px !important;
    flex-wrap: wrap;
    gap: 6px;
    line-height: 1.5;
  }

  /* Pagination Mobile */
  .pagination {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
  }
  .pagination button {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 8px;
  }
  
  /* Upload Modal Mobile */
  #dropZone {
    padding: 30px 20px !important;
    border-radius: 12px;
  }
  #dropZone i {
    font-size: 40px !important;
  }
  #dropZone p {
    font-size: 14px !important;
    margin: 8px 0 !important;
  }
  #dropZone button {
    padding: 12px 20px !important;
    font-size: 15px !important;
    min-height: 48px;
    border-radius: 8px;
  }
  
  /* Empty State Mobile */
  .empty-state {
    padding: 60px 20px;
  }
  .empty-state .big-icon {
    font-size: 48px;
    margin-bottom: 16px;
  }
  .empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
  }
  .empty-state p {
    font-size: 14px;
    color: #6b7280;
  }

  /* Filter Section Mobile */
  .toolbar > div:last-child {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  }
  #quickFilterChips {
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
  }
  .filter-chip {
    padding: 8px 14px !important;
    font-size: 12px !important;
    min-height: 36px;
  }
  #filterContent {
    padding: 0 !important;
    margin-top: 16px;
  }
  #filterContent > div {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    width: 100%;
    grid-template-columns: 1fr !important;
  }
  #filterContent > div > div {
    width: 100% !important;
    grid-column: span 1 !important;
  }
  #filterContent label {
    font-size: 14px;
    margin-bottom: 8px;
    display: block;
  }
  #filterContent input,
  #filterContent select {
    width: 100% !important;
    padding: 14px !important;
    font-size: 16px !important;
    box-sizing: border-box;
    min-height: 48px;
    border-radius: 8px;
  }
  #filterContent > div > div:last-child {
    grid-column: span 1 !important;
  }
  #filterContent > div > div:last-child > div {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  #filterContent > div > div:last-child > div > div {
    width: 100%;
  }
  #applyFiltersBtn,
  #clearFiltersBtn {
    width: 100% !important;
    padding: 14px !important;
    font-size: 16px !important;
    margin-top: 8px;
    min-height: 48px;
    border-radius: 8px;
    font-weight: 600;
  }
  #filterContent > div > div:last-child label {
    font-size: 13px;
    margin-bottom: 6px;
  }
  #activeFiltersCount {
    font-size: 11px !important;
    padding: 4px 8px !important;
  }
}

@media (max-width: 480px) {
  /* Extra Small Screens */
  .login-container {
    padding: 12px;
    padding-top: 30px;
  }
  .login-box {
    padding: 20px 16px;
    border-radius: 12px;
  }
  .login-box h1 {
    font-size: 18px;
    line-height: 1.3;
  }
  .login-box h2 {
    font-size: 13px;
  }
  .company-logo {
    max-width: 80px;
    max-height: 80px;
  }
  .app-header {
    padding: 8px 10px !important;
  }
  .header-left {
    gap: 6px !important;
  }
  .header-logo {
    width: 32px !important;
    height: 32px !important;
  }
  .company-info h1 {
    font-size: 13px !important;
  }
  .system-name {
    font-size: 10px !important;
  }
  .user-info {
    font-size: 10px !important;
    gap: 6px !important;
  }
  .user-info #userAvatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 12px !important;
  }
  .header-right {
    gap: 4px !important;
    padding-top: 6px;
  }
  .header-right button {
    padding: 8px 10px !important;
    font-size: 12px !important;
    min-height: 40px;
  }
  .sidebar {
    padding: 16px 12px;
    max-width: 100%;
  }
  .main-content {
    padding: 12px !important;
  }
  .month-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .month-btn {
    padding: 10px 6px;
    font-size: 11px;
    min-height: 44px;
  }
  .file-card {
    padding: 14px !important;
  }
  .file-card button {
    padding: 12px !important;
    font-size: 14px !important;
    min-height: 44px;
  }
  .file-title {
    font-size: 15px !important;
  }
  .file-amount {
    font-size: 20px !important;
  }
  .modal-content {
    padding: 20px 16px !important;
    border-radius: 16px 16px 0 0;
  }
  .modal-header {
    padding-bottom: 14px !important;
    margin-bottom: 16px !important;
  }
  .modal-header h2,
  .modal-header h3 {
    font-size: 18px !important;
  }
  .profile-tab {
    padding: 12px 10px !important;
    font-size: 11px !important;
  }
  .profile-tab i {
    font-size: 12px;
    margin-right: 4px;
  }
  .breadcrumb {
    font-size: 14px !important;
  }
  #searchInput {
    padding: 12px 36px 12px 12px !important;
    font-size: 16px !important;
  }
  #openUploadModal {
    padding: 12px 16px !important;
    font-size: 15px !important;
  }
  .toolbar > div:last-child {
    padding: 14px !important;
  }
  #filterContent > div > div {
    margin-bottom: 0;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  /* Mobile touch devices */
  button,
  .category-item,
  .month-btn,
  .file-card button,
  .profile-tab {
    min-height: 44px; /* Apple's recommended touch target size */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }
  input,
  select,
  textarea {
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
  }
  .category-item {
    padding: 12px;
  }
  .file-card button {
    padding: 12px;
  }
  a,
  .file-card,
  .category-group {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
  }
  /* Improve scrolling on mobile */
  * {
    -webkit-overflow-scrolling: touch;
  }
  /* Better focus states for touch */
  button:active,
  .category-item:active,
  .month-btn:active {
    transform: scale(0.98);
    transition: transform 0.1s;
  }
}

/* Dark Mode */
body.dark-mode {
  background: #1a1a1a;
  color: #e0e0e0;
}

body.dark-mode .sidebar {
  background: #2d2d2d;
  border-right-color: #404040;
}

body.dark-mode .main-content {
  background: #1a1a1a;
}

body.dark-mode .file-card {
  background: #2d2d2d;
  border-color: #404040;
  color: #e0e0e0;
}

body.dark-mode .modal-content {
  background: #2d2d2d;
  color: #e0e0e0;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #1a1a1a;
  border-color: #404040;
  color: #e0e0e0;
}

body.dark-mode .category-item:hover {
  background: #404040;
}

body.dark-mode .month-btn {
  background: #2d2d2d;
  border-color: #404040;
  color: #e0e0e0;
}

body.dark-mode .month-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Notification Toast System */
.notification-toast {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 300px;
  max-width: 400px;
  animation: slideInRight 0.3s ease-out;
  pointer-events: auto;
  border-left: 4px solid;
  position: relative;
  overflow: hidden;
}

.notification-toast::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: currentColor;
  width: 100%;
  animation: shrinkWidth 5s linear forwards;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes shrinkWidth {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

.notification-toast.success {
  border-left-color: #10b981;
  color: #065f46;
}

.notification-toast.error {
  border-left-color: #dc3545;
  color: #991b1b;
}

.notification-toast.warning {
  border-left-color: #f59e0b;
  color: #92400e;
}

.notification-toast.info {
  border-left-color: #1e40af;
  color: #1e3a8a;
}

.notification-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.notification-toast.success .notification-icon {
  background: #d1fae5;
  color: #10b981;
}

.notification-toast.error .notification-icon {
  background: #fee2e2;
  color: #dc3545;
}

.notification-toast.warning .notification-icon {
  background: #fef3c7;
  color: #f59e0b;
}

.notification-toast.info .notification-icon {
  background: #dbeafe;
  color: #1e40af;
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  color: #1f2937;
}

.notification-message {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
}

.notification-close {
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.2s;
}

.notification-close:hover {
  color: #374151;
}

/* Confirmation Dialog */
.confirm-dialog-header {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.confirm-dialog-header.danger .confirm-dialog-icon {
  background: #fee2e2;
  color: #dc3545;
}

.confirm-dialog-header.warning .confirm-dialog-icon {
  background: #fef3c7;
  color: #f59e0b;
}

.confirm-dialog-header.info .confirm-dialog-icon {
  background: #dbeafe;
  color: #1e40af;
}

.confirm-dialog-header.success .confirm-dialog-icon {
  background: #d1fae5;
  color: #10b981;
}

#confirmDialogConfirm.danger {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

#confirmDialogConfirm.warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

#confirmDialogConfirm.info {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
}

#confirmDialogConfirm.success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* PIN Modal Improvements */
#pinError {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

#pinInput.error {
  border-color: #dc3545;
  background: #fef2f2;
}

#pinInput.error:focus {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* Receipt Preview Modal */
.receipt-preview-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.receipt-preview-header {
  flex-shrink: 0;
  z-index: 10;
}

#receiptPreviewBody {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#receiptPreviewContent img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin: 0 auto;
  display: block;
}

#receiptPreviewContent iframe {
  width: 100%;
  min-height: 600px;
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#receiptPreviewContent .file-preview-placeholder {
  padding: 60px;
  text-align: center;
  color: #6b7280;
}

#receiptPreviewContent .file-preview-placeholder i {
  font-size: 64px;
  margin-bottom: 20px;
  color: #cbd5e1;
}

.filter-chip.active {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%) !important;
  color: white !important;
  border-color: #1e40af !important;
  box-shadow: 0 2px 4px rgba(30, 64, 175, 0.3);
}

.filter-chip:hover {
  border-color: #1e40af;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#activeFiltersCount {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* Receipt Card Thumbnail */
.receipt-thumbnail {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 48px;
}

.receipt-thumbnail:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.receipt-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.file-card {
  transition: transform 0.2s, box-shadow 0.2s;
}

.file-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Filter Input Focus States */
#filterContent input:focus,
#filterContent select:focus {
  outline: none;
  border-color: #1e40af;
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* Mobile Preview Buttons */
@media (max-width: 768px) {
  .preview-btn-text {
    display: none;
  }
  
  #previewDownloadBtn,
  #previewPrintBtn {
    padding: 10px !important;
    min-width: 44px;
    min-height: 44px;
  }
  
  .receipt-preview-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .receipt-preview-header > div:first-child {
    flex: 1;
    min-width: 0;
  }
  
  .receipt-preview-header > div:last-child {
    width: 100%;
    justify-content: flex-end;
    margin-top: 8px;
  }
  
  #receiptPreviewContent iframe {
    min-height: 400px;
  }
}

/* Additional Mobile Optimizations */
@media (max-width: 768px) {
  /* Better scrolling */
  body {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
  }
  
  /* Prevent horizontal scroll */
  * {
    max-width: 100%;
  }
  
  /* Improve text readability */
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  /* Better spacing for stacked elements */
  .toolbar > div:first-child {
    margin-bottom: 12px;
  }
  
  /* Improve modal form spacing */
  .modal-content form {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  .modal-content form label {
    margin-bottom: 6px;
  }
  
  /* Better button spacing in modals */
  .modal-actions {
    gap: 10px;
  }
  
  /* Improve category list scrolling */
  .category-list {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Better file card spacing */
  .file-card {
    margin-bottom: 0;
  }
  
  /* Improve header logo visibility */
  .header-logo {
    object-fit: contain;
  }
  
  /* Better search input on mobile */
  #searchInput::placeholder {
    font-size: 16px;
  }
  
  /* Notification Toast Mobile */
  #notificationContainer {
    top: 10px !important;
    right: 10px !important;
    left: 10px !important;
    max-width: calc(100% - 20px) !important;
  }
  
  .notification-toast {
    min-width: auto !important;
    max-width: 100% !important;
    padding: 14px 16px !important;
  }
  
  .notification-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 18px !important;
  }
  
  .notification-title {
    font-size: 14px !important;
  }
  
  .notification-message {
    font-size: 12px !important;
  }
  
  /* Confirmation Dialog Mobile */
  #confirmDialog .modal-content {
    max-width: calc(100% - 20px) !important;
    margin: 20px 10px !important;
  }
  
  .confirm-dialog-header {
    padding: 20px !important;
    flex-wrap: wrap;
  }
  
  #confirmDialogIcon {
    width: 40px !important;
    height: 40px !important;
    font-size: 20px !important;
  }
  
  #confirmDialogTitle {
    font-size: 18px !important;
  }
  
  #confirmDialogMessage {
    font-size: 14px !important;
    margin-bottom: 20px !important;
  }
  
  #confirmDialog .modal-content > div:last-child {
    padding: 20px !important;
  }
  
  #confirmDialogConfirm,
  #confirmDialogCancel {
    flex: 1 !important;
    padding: 14px !important;
    font-size: 15px !important;
    min-height: 48px;
  }
  
  /* PIN Modal Mobile */
  #pinModal .modal-content {
    max-width: calc(100% - 20px) !important;
    margin: 20px 10px !important;
  }
  
  #pinModal .modal-header {
    padding: 20px !important;
    flex-wrap: wrap;
  }
  
  #pinModal .modal-header > div:first-child {
    flex: 1;
    min-width: 0;
  }
  
  #pinModal .modal-header > div:first-child > div:first-child {
    width: 48px !important;
    height: 48px !important;
    font-size: 24px !important;
  }
  
  #pinModal .modal-header h3 {
    font-size: 18px !important;
  }
  
  #pinModal .modal-header p {
    font-size: 13px !important;
  }
  
  #pinForm {
    padding: 20px !important;
  }
  
  #pinInput {
    font-size: 16px !important;
    padding: 14px !important;
    min-height: 48px;
  }
  
  #pinForm button {
    padding: 14px !important;
    font-size: 15px !important;
    min-height: 48px;
  }
  
  /* Improve month grid on very small screens */
  @media (max-width: 360px) {
    .month-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }
  
  /* Better profile modal tabs scrolling */
  #profileModal .modal-header > div:nth-child(2) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  #profileModal .modal-header > div:nth-child(2)::-webkit-scrollbar {
    display: none;
  }
  
  /* Improve sidebar close on mobile */
  .sidebar {
    padding-top: 60px;
  }
  
  /* Add close button to sidebar on mobile */
  .sidebar::before {
    content: '';
    position: sticky;
    top: 0;
    height: 0;
    z-index: 10;
  }
}

/* Landscape mobile optimizations */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-content {
    max-height: 85vh;
  }
  
  .sidebar {
    max-height: 100vh;
  }
  
  .login-container {
    padding: 10px;
    align-items: center;
  }
  
  .login-box {
    max-width: 400px;
  }
}
