/* Global Reset and Typography */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 38px;
  background: #eff6ff;
  border-radius: 10px;
  padding: 6px 10px;
  border: 1px solid #bfdbfe;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: #64748b;
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }

.btn-secondary { background: #f1f5f9; border: 1px solid #cbd5e1; color: #334155; }
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-outline { background: transparent; border: 1px solid #cbd5e1; color: #475569; }

.btn-export { background: #ffffff; border: 1px solid #cbd5e1; color: #1e293b; }
.xlsx-btn { color: #15803d; }

.toast-notification {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 12px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.controls-card {
  background: white;
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.search-box {
  display: flex;
  align-items: center;
  position: relative;
  flex: 1;
  max-width: 580px;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: #94a3b8;
}

.search-box input {
  width: 100%;
  padding: 9px 36px 9px 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
}

.search-box input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #94a3b8;
  cursor: pointer;
}

.export-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  background-color: white;
  min-width: 220px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  z-index: 100;
  overflow: hidden;
}

.dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-menu a {
  color: #334155;
  padding: 10px 16px;
  text-decoration: none;
  display: block;
  font-size: 0.85rem;
  cursor: pointer;
}

.dropdown-menu a:hover {
  background-color: #f1f5f9;
  color: #2563eb;
}

.table-card {
  background: white;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow: hidden;
}

.table-responsive {
  overflow-x: auto;
}

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

.data-table th, .data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}

.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  user-select: none;
}

.sortable { cursor: pointer; }
.sortable:hover { background: #f1f5f9; color: #1e293b; }
.sort-icon { font-size: 0.7rem; margin-left: 4px; }

.ifsc-badge {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-family: monospace;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.address-subtext {
  font-size: 0.78rem;
  color: #64748b;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.meta-item {
  font-size: 0.8rem;
  color: #475569;
}

.actions-cell {
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.icon-btn:hover { background: #f1f5f9; }

.pagination-footer {
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.pagination-info { font-size: 0.85rem; color: #64748b; }
.page-size-selector { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: #64748b; }
.page-size-selector select { padding: 4px 8px; border: 1px solid #cbd5e1; border-radius: 4px; }
.pagination-controls { display: flex; align-items: center; gap: 6px; }
.page-nav-btn { background: white; border: 1px solid #cbd5e1; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-weight: bold; }
.page-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-indicator { font-size: 0.85rem; color: #475569; padding: 0 6px; }

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.modal-container {
  background: #ffffff;
  border-radius: 12px;
  width: 90%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.header-title { display: flex; align-items: center; gap: 10px; }
.header-title h3 { margin: 0; font-size: 1.25rem; color: #1e293b; font-weight: 600; }
.close-btn { background: none; border: none; font-size: 1.75rem; cursor: pointer; color: #64748b; line-height: 1; }
.close-btn:hover { color: #0f172a; }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.span-2 { grid-column: span 2; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 0.88rem; font-weight: 500; color: #334155; margin-bottom: 6px; }
.req { color: #ef4444; }
.field-hint { font-size: 0.75rem; color: #64748b; margin-top: 4px; }

.form-control {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}
.form-control:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Import Step Styles */
.drop-zone {
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.2s ease;
}
.drop-zone:hover { border-color: #2563eb; background: #eff6ff; }
.drop-icon { font-size: 48px; margin-bottom: 12px; }
.drop-text { font-size: 1.1rem; font-weight: 600; color: #1e293b; }
.file-formats { font-size: 0.85rem; color: #64748b; margin-top: 6px; }

.file-info-badge {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 16px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.section-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; color: #1e293b; }
.section-hint { font-size: 0.85rem; color: #64748b; margin-bottom: 16px; }

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.mapping-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.db-col-label { flex: 1.2; font-weight: 500; font-size: 0.9rem; color: #334155; }
.arrow { color: #94a3b8; font-weight: bold; }
.file-col-select { flex: 2; }
.file-col-select select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  font-size: 0.88rem;
}
.file-col-select select.unmapped { border-color: #f87171; background-color: #fef2f2; }

.import-options {
  margin-bottom: 20px;
  background: #f1f5f9;
  padding: 10px 16px;
  border-radius: 6px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #334155;
}

.preview-box { margin-top: 16px; }
.preview-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 8px; color: #475569; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.preview-table th, .preview-table td { padding: 6px 10px; border: 1px solid #e2e8f0; white-space: nowrap; }
.preview-table th { background: #f1f5f9; color: #475569; font-weight: 600; }

.stats-cards { display: flex; gap: 16px; justify-content: center; margin: 24px 0; }
.stat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 16px 20px;
  border-radius: 8px;
  min-width: 120px;
  display: flex;
  flex-direction: column;
}
.stat-val { font-size: 1.75rem; font-weight: 700; color: #1e293b; }
.stat-label { font-size: 0.8rem; color: #64748b; text-transform: uppercase; font-weight: 600; }
.stat-card.success .stat-val { color: #16a34a; }
.stat-card.info .stat-val { color: #2563eb; }
.stat-card.warning .stat-val { color: #d97706; }

.progress-bar-container {
  width: 100%; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; margin: 20px 0;
}
.progress-bar-fill { height: 100%; background: #2563eb; transition: width 0.3s ease; }

.spinner {
  width: 48px; height: 48px; border: 4px solid #e2e8f0; border-top-color: #2563eb; border-radius: 50%;
  animation: spin 1s infinite linear; margin: 20px auto;
}
.table-spinner {
  width: 32px; height: 32px; border: 3px solid #e2e8f0; border-top-color: #2563eb; border-radius: 50%;
  animation: spin 1s infinite linear; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-log {
  text-align: left; background: #fef2f2; border: 1px solid #fecaca; padding: 12px; border-radius: 6px;
  max-height: 120px; overflow-y: auto; font-size: 0.8rem; color: #991b1b;
}

.confirm-backdrop {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(15,23,42,0.6); display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.confirm-dialog {
  background: white; padding: 24px; border-radius: 10px; max-width: 440px; text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
}
.dialog-icon { font-size: 40px; margin-bottom: 10px; }
.confirm-dialog h3 { margin: 0 0 10px; color: #1e293b; }
.confirm-dialog p { color: #64748b; font-size: 0.9rem; margin-bottom: 20px; }
.dialog-actions { display: flex; justify-content: center; gap: 12px; }

.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 0.88rem; }
.loading-cell, .empty-cell { text-align: center; padding: 48px !important; color: #64748b; }
.text-center { text-align: center; }
