* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
}

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ========== LOGIN ========== */
#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}
#login-screen.active {
  display: flex;
}

.login-container {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.logo {
  width: 64px;
  height: 64px;
  background: var(--primary);
  color: white;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 22px;
  color: var(--gray-900);
}

.login-header p {
  color: var(--gray-500);
  font-size: 14px;
  margin-top: 4px;
}

.login-tabs {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  transition: all 0.2s;
}

.tab-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* ========== FORMS ========== */
.form-group {
  margin-bottom: 16px;
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

.form-hint {
  text-align: center;
  color: var(--gray-500);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ========== BUTTONS ========== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

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

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

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

.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-outline:hover {
  background: var(--gray-50);
}

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

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  padding: 6px 10px;
  font-size: 16px;
}

/* ========== NAVBAR ========== */
.navbar {
  background: white;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-emp {
  background: #1e3a5f;
}

.navbar-emp .nav-brand,
.navbar-emp .nav-user span {
  color: white;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 16px;
}

.logo-sm {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--gray-500);
}

/* ========== ADMIN CONTENT ========== */
.admin-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--gray-200);
}

.admin-tab {
  padding: 12px 24px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== CARDS ========== */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

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

.section-header h2 {
  font-size: 18px;
}

/* ========== TABLES ========== */
.table-search {
  margin-bottom: 16px;
}

.table-search input {
  width: 100%;
  max-width: 400px;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
}

.table-search input:focus {
  border-color: var(--primary);
}

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

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

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  font-size: 14px;
}

th {
  font-weight: 600;
  color: var(--gray-500);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
}

tr:hover td {
  background: var(--gray-50);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-danger {
  background: #fef2f2;
  color: #991b1b;
}

.badge-primary {
  background: #dbeafe;
  color: #1e40af;
}

.badge-warning {
  background: #fef9c3;
  color: #854d0e;
}

.badge-info {
  background: #e0e7ff;
  color: #3730a3;
}

/* ========== UPLOAD ========== */
.upload-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.upload-tab {
  padding: 8px 20px;
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  transition: all 0.2s;
}

.upload-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  position: relative;
  transition: border-color 0.2s;
  cursor: pointer;
}

.upload-area:hover {
  border-color: var(--primary);
}

.upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

.upload-placeholder p {
  color: var(--gray-500);
  font-size: 14px;
}

.upload-hint {
  font-size: 12px !important;
  color: var(--gray-400) !important;
}

.archivos-lista {
  text-align: left;
  margin-top: 12px;
}

.archivo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--gray-700);
}

.info-box {
  background: var(--primary-light);
  border: 1px solid #93c5fd;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.info-box code {
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

#upload-resultado {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 14px;
}

#upload-resultado.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

#upload-resultado.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ========== EMPLEADO PORTAL ========== */
.empleado-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

.perfil-header {
  margin-bottom: 20px;
}

.recibos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.recibo-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow 0.2s;
}

.recibo-card:hover {
  box-shadow: var(--shadow-lg);
}

.recibo-card .recibo-fecha {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
}

.recibo-card .recibo-archivo {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 4px;
  word-break: break-all;
}

.recibo-card .recibo-desc {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.recibo-card .btn {
  width: 100%;
  justify-content: center;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

/* ========== MODAL ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 90%;
}

.modal-content h3 {
  margin-bottom: 12px;
}

.modal-content p {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ========== EMPLEADO TABS ========== */
.emp-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--gray-200);
}

.emp-tab {
  padding: 12px 24px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.emp-tab.active {
  color: #1e3a5f;
  border-bottom-color: #1e3a5f;
}

.emp-tab-content { display: none; }
.emp-tab-content.active { display: block; }

/* ========== FIRMA - SUB-TABS ========== */
.firma-subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gray-200);
}

.firma-subtab {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.firma-subtab.active {
  color: #1e3a5f;
  border-bottom-color: #1e3a5f;
}

.firma-sub-content { display: none; }
.firma-sub-content.active { display: block; }

/* ========== FIRMA - ESCRITA ========== */
#firma-escrita-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.firma-escrita-fuentes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.firma-fuente-opcion {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  background: white;
}

.firma-fuente-opcion:hover {
  border-color: var(--gray-400);
}

.firma-fuente-opcion.active {
  border-color: #1e3a5f;
  background: #f0f4f8;
}

.firma-fuente-preview {
  font-size: 22px;
  color: #1e3a5f;
}

/* ========== FIRMA - EDITOR ========== */
.firma-descripcion {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.firma-editor {
  margin-top: 24px;
}

.firma-editor h4 {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--gray-700);
}

.firma-canvas-wrapper {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  background: #fafbfc;
  position: relative;
  cursor: crosshair;
  touch-action: none;
}

.firma-canvas-wrapper canvas {
  display: block;
  width: 100%;
  border-radius: 6px;
}

.firma-canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 14px;
  pointer-events: none;
}

.firma-editor-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  justify-content: flex-end;
}

/* ========== FIRMA - PREVIEW ========== */
.firma-preview-box {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--gray-50);
  margin-bottom: 8px;
}

.firma-preview-box h4 {
  font-size: 14px;
  color: var(--gray-700);
  margin-bottom: 12px;
}

.firma-preview {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}

.firma-preview img {
  max-width: 100%;
  max-height: 120px;
}

.firma-fecha-guardada {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 8px;
}

/* ========== FIRMA - MODAL RECIBO ========== */
.modal-firma-content {
  max-width: 480px;
}

.firma-preview-modal {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin-bottom: 20px;
}

.firma-preview-modal img {
  max-width: 100%;
  max-height: 100px;
}

/* ========== FIRMA - CIRCULO ESTADO ========== */
.firma-circulo {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  vertical-align: middle;
}

.firma-circulo.firma-si {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

.firma-circulo.firma-no {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* ========== FIRMA - RECIBO CARD ========== */
.recibo-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.firma-estado {
  font-size: 12px;
  padding: 4px 0;
  margin-bottom: 8px;
}

.firma-estado.firmado {
  color: var(--success);
  font-weight: 500;
}

/* ========== FIRMA ADMIN MODAL ========== */
.modal-firma-admin-content {
  max-width: 620px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transition: opacity 0.3s, transform 0.3s;
  transform: translateY(20px);
  opacity: 0;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: #166534;
  color: white;
}

.toast.error {
  background: #991b1b;
  color: white;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .form-row { flex-direction: column; gap: 0; }
  .login-container { margin: 16px; padding: 24px; }
  .admin-content { padding: 16px; }
  .navbar { padding: 0 16px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .section-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  td, th { padding: 8px 10px; font-size: 13px; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .admin-tabs { overflow-x: auto; }
  .nav-user span { display: none; }
}
