:root {
  --primary: #c0392b;
  --primary-dark: #962d22;
  --secondary: #d35400;
  --accent-gold: #f39c12;
  --gold-glow: rgba(243, 156, 18, 0.4);
  --bg-gradient: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  --surface: #ffffff;
  --surface-border: #fcd34d;
  --text-dark: #1f2937;
  --text-muted: #6b7280;
  --success: #059669;
  --danger: #dc2626;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --radius: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Hind', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  background: var(--bg-gradient);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.main-header {
  background: linear-gradient(135deg, #b71540 0%, #c0392b 50%, #e67e22 100%);
  color: #fff;
  padding: 0.85rem 1rem;
  box-shadow: 0 4px 12px rgba(183, 21, 64, 0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding-right: 8px;
}

.sun-icon {
  font-size: 1.9rem;
  filter: drop-shadow(0 0 6px #f1c40f);
  flex-shrink: 0;
}

.committee-title {
  font-family: 'Yatra One', cursive;
  font-size: 1.15rem;
  letter-spacing: 0.3px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.25);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  font-size: 0.8rem;
  color: #fef08a;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hamburger Button (Touch Friendly) */
.hamburger-btn {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.hamburger-btn:active {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0.96);
}

.hamburger-btn .bar {
  width: 22px;
  height: 2.5px;
  background-color: #fff;
  border-radius: 2px;
}

/* Drawer Menu (Slide-out) */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.drawer-menu {
  position: fixed;
  top: 0;
  right: -320px;
  width: 85vw;
  max-width: 320px;
  height: 100%;
  background: #fff;
  z-index: 1001;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-menu.active {
  right: 0;
}

.drawer-header {
  background: linear-gradient(135deg, #b71540, #c0392b);
  color: #fff;
  padding: 1.15rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Yatra One', cursive;
  font-size: 1.15rem;
}

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-nav {
  padding: 0.85rem 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 1rem 1.25rem;
  min-height: 50px;
  color: #374151;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-item:active, .nav-item.active {
  background: #fef3c7;
  color: #b71540;
  border-left: 5px solid #b71540;
}

.nav-item .icon {
  font-size: 1.3rem;
}

.divider {
  height: 1px;
  background: #e5e7eb;
  margin: 0.75rem 1rem;
}

.nav-item.admin-item {
  color: #b71540;
  font-weight: 600;
  background: #fff1f2;
  border: 1.5px solid #fecdd3;
  margin: 0.75rem 1rem;
  width: calc(100% - 2rem);
  border-radius: 10px;
}

.nav-item.admin-item:active {
  background: #ffe4e6;
}

.drawer-footer {
  padding: 1rem;
  text-align: center;
  background: #fafafa;
  border-top: 1px solid #f3f4f6;
  color: #9ca3af;
  font-family: 'Yatra One', cursive;
}

/* Main Container */
.container {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0 0.85rem;
  flex: 1;
  width: 100%;
}

/* Stats Cards (Mobile Optimized) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid #fed7aa;
}

.stat-icon {
  font-size: 1.6rem;
  padding: 8px;
  background: #fef3c7;
  border-radius: 10px;
  flex-shrink: 0;
}

.stat-info {
  min-width: 0;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #9a3412;
  white-space: nowrap;
}

.stat-card.expense-card .stat-icon { background: #fee2e2; }
.stat-card.expense-card .stat-value { color: #b91c1c; }

.stat-card.balance-card .stat-icon { background: #dcfce7; }
.stat-card.balance-card .stat-value { color: #15803d; }

.stat-card.donor-card .stat-icon { background: #e0f2fe; }
.stat-card.donor-card .stat-value { color: #0369a1; }

/* Content Section Common */
.content-section {
  margin-bottom: 2rem;
  scroll-margin-top: 70px;
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .section-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.title-with-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-with-badge h2, .section-header h2 {
  font-family: 'Yatra One', cursive;
  font-size: 1.25rem;
  color: #7f1d1d;
  line-height: 1.3;
}

/* Search Box (Mobile Friendly & Tap Ready) */
.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1.5px solid #f59e0b;
  border-radius: 24px;
  padding: 4px 14px;
  width: 100%;
  min-height: 44px;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 640px) {
  .search-box {
    max-width: 320px;
  }
}

.search-icon {
  font-size: 1rem;
  margin-right: 8px;
  color: #9ca3af;
}

.search-box input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 1rem; /* 16px to prevent iOS auto-zoom */
  padding: 6px 0;
  background: transparent;
}

.clear-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Top Donors Podium (Cards for Top 3) */
.top-ranks-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (min-width: 600px) {
  .top-ranks-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
}

.podium-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid #fed7aa;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Rank 1 Crown Card (Champion styling) */
.podium-card.rank-1 {
  border: 2px solid #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.2);
}

.podium-card.rank-1 .rank-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.3);
}

.podium-card.rank-2 {
  border-color: #cbd5e1;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.podium-card.rank-2 .rank-badge {
  background: #64748b;
  color: #fff;
}

.podium-card.rank-3 {
  border-color: #fdba74;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
}

.podium-card.rank-3 .rank-badge {
  background: #b45309;
  color: #fff;
}

.podium-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.podium-amount {
  font-size: 1.35rem;
  font-weight: 800;
  color: #b71540;
}

.podium-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1f2937;
  margin-top: 2px;
}

.podium-village {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Tables / Card List (Responsive Mobile View) */
.table-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-header-info {
  padding: 0.85rem 1rem;
  background: #fafafa;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-header-info h3 {
  font-size: 1rem;
  color: #374151;
  font-weight: 600;
}

.count-badge {
  background: #fef08a;
  color: #854d0e;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
}

.table-responsive {
  width: 100%;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

/* Desktop Table View */
@media (min-width: 641px) {
  .custom-table th, .custom-table td {
    padding: 12px 16px;
    font-size: 0.95rem;
  }

  .custom-table th {
    background: #fffbeb;
    color: #78350f;
    font-weight: 600;
    border-bottom: 2px solid #fde68a;
    white-space: nowrap;
  }

  .custom-table td {
    border-bottom: 1px solid #f3f4f6;
  }

  .custom-table tr:hover {
    background: #fffdf7;
  }

  .custom-table .text-right {
    text-align: right;
  }
}

/* Mobile-First Card Rows for Tables */
@media (max-width: 640px) {
  .custom-table thead {
    display: none; /* Hide header row on phones */
  }

  .custom-table, .custom-table tbody, .custom-table tr {
    display: block;
    width: 100%;
  }

  .custom-table tr {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: 
      "rank name amount"
      "rank village date";
    column-gap: 10px;
    row-gap: 4px;
    align-items: center;
  }

  .custom-table tr:active {
    background: #fffdf5;
  }

  .custom-table td {
    padding: 0;
    border: none;
    font-size: 0.95rem;
  }

  /* Map TD to Grid Areas */
  .custom-table td:nth-child(1) { grid-area: rank; }
  .custom-table td:nth-child(2) { grid-area: name; font-size: 1rem; }
  .custom-table td:nth-child(3) { grid-area: village; font-size: 0.8rem; color: #6b7280; }
  .custom-table td:nth-child(4) { grid-area: amount; text-align: right; }
  .custom-table td:nth-child(5) { grid-area: date; text-align: right; font-size: 0.75rem; color: #9ca3af; }
}

.table-rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 32px;
  background: #f3f4f6;
  color: #4b5563;
}

.table-rank-pill.r1 {
  background: #fef08a;
  color: #854d0e;
  border: 1px solid #facc15;
}

.table-rank-pill.r2 {
  background: #e2e8f0;
  color: #334155;
}

.table-rank-pill.r3 {
  background: #ffedd5;
  color: #9a3412;
}

.donor-amount-cell {
  font-weight: 700;
  color: #047857;
  font-size: 1.05rem;
}

.expense-amount-cell {
  font-weight: 700;
  color: #b91c1c;
  font-size: 1.05rem;
}

.highlight-tag {
  background: #fee2e2;
  color: #991b1b;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 12px;
  display: inline-block;
}

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

/* Info Card */
.info-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--surface-border);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.info-card h3 {
  font-family: 'Yatra One', cursive;
  color: #991b1b;
  margin-bottom: 0.65rem;
  font-size: 1.15rem;
}

.info-desc {
  line-height: 1.65;
  color: #4b5563;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.info-rules h4 {
  color: #1f2937;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.info-rules ul {
  padding-left: 1.2rem;
  color: #4b5563;
  line-height: 1.7;
  font-size: 0.9rem;
}

/* Admin Modal (Mobile Touch Ready) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

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

.modal-content {
  background: #fff;
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

@media (max-width: 480px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-content {
    border-radius: 18px 18px 0 0;
    max-height: 88vh;
  }
}

.modal-header {
  background: linear-gradient(135deg, #b71540, #962d22);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Yatra One', cursive;
  font-size: 1.15rem;
}

.modal-body {
  padding: 1.25rem 1rem;
  overflow-y: auto;
}

.admin-login-note {
  font-size: 0.95rem;
  color: #4b5563;
  margin-bottom: 1.25rem;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: #374151;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 12px 14px;
  min-height: 48px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem; /* 16px to prevent iOS auto zoom */
  outline: none;
  background: #fff;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus {
  border-color: #b71540;
  box-shadow: 0 0 0 3px rgba(183, 21, 64, 0.15);
}

.btn-primary {
  background: linear-gradient(135deg, #b71540, #c0392b);
  color: #fff;
  border: none;
  padding: 12px 18px;
  min-height: 48px;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s;
}

.btn-primary:active {
  opacity: 0.9;
  transform: scale(0.98);
}

.btn-primary.btn-danger-theme {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 38px;
}

.btn-secondary:active {
  background: #e5e7eb;
}

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

.full-width {
  width: 100%;
}

.error-msg {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid #fecaca;
}

.success-msg {
  background: #dcfce7;
  color: #15803d;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
  border: 1px solid #bbf7d0;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Admin Tabs (Touch Friendly) */
.admin-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.badge-active {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #15803d;
}

.badge-active .dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 6px;
}

.admin-tab {
  background: none;
  border: none;
  padding: 10px 12px;
  min-height: 42px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  flex: 1;
  text-align: center;
}

.admin-tab.active {
  color: #b71540;
  background: #ffe4e6;
}

.manage-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.manage-subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
}

.subtab-btn {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  padding: 8px 12px;
  min-height: 38px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  flex: 1;
}

.subtab-btn.active {
  background: #b71540;
  color: #fff;
  border-color: #b71540;
}

.manage-items-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.manage-item-info {
  display: flex;
  flex-direction: column;
}

.manage-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1f2937;
}

.manage-item-amount {
  font-size: 0.9rem;
  color: #059669;
  font-weight: 700;
}

.btn-delete {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 6px 12px;
  min-height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.btn-delete:active {
  background: #dc2626;
  color: #fff;
}

/* Toast Notification (Mobile Centered) */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 100px);
  background: #1f2937;
  color: #fff;
  padding: 12px 18px;
  border-radius: 25px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  opacity: 0;
  white-space: nowrap;
  max-width: 90vw;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* Footer */
.main-footer {
  background: #1f2937;
  color: #f3f4f6;
  text-align: center;
  padding: 1.5rem 1rem;
  margin-top: auto;
  border-top: 4px solid #b71540;
}

.main-footer p {
  font-family: 'Yatra One', cursive;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.footer-blessing {
  font-family: 'Hind', sans-serif !important;
  font-size: 0.85rem;
  color: #9ca3af;
}

/* Ultra Small Screens (< 380px) */
@media (max-width: 380px) {
  .committee-title {
    font-size: 1.05rem;
  }
  .stat-card {
    padding: 0.65rem;
    gap: 6px;
  }
  .stat-icon {
    font-size: 1.3rem;
    padding: 6px;
  }
  .stat-value {
    font-size: 1rem;
  }
}
