/* ══════════════════════════════════
   REVISIONES ESTRUCTURALES - ESTILOS
   ══════════════════════════════════ */

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f8fafc; color: #1e293b; font-size: 14px;
  overflow: hidden; height: 100vh;
}

.app { display: flex; height: 100vh; }

/* ── Auth / login gate ── */
body.booting .app,        /* oculta la app hasta resolver la sesión (sin parpadeo) */
.app.hidden { display: none !important; }

.auth-screen {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eff6ff, #e0e7ff);
  padding: 20px;
}
.auth-screen.show { display: flex; }
.auth-card {
  width: 100%; max-width: 360px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
  padding: 32px 28px; box-shadow: 0 12px 40px rgba(15,23,42,0.12);
  display: flex; flex-direction: column;
}
.auth-logo {
  width: 48px; height: 48px; border-radius: 12px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px;
}
.auth-title { font-size: 18px; font-weight: 700; text-align: center; }
.auth-sub { font-size: 12px; color: #94a3b8; text-align: center; margin: 4px 0 22px; }
.auth-label { font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 6px; }
.auth-input {
  padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 14px; margin-bottom: 16px; outline: none; transition: border-color .15s;
}
.auth-input:focus { border-color: #3b82f6; }
.auth-error { color: #dc2626; font-size: 12px; min-height: 16px; margin-bottom: 8px; }
.auth-btn { justify-content: center; width: 100%; padding: 11px; font-size: 14px; }

/* ── Sidebar ── */
.sidebar {
  width: 220px; background: #fff; border-right: 1px solid #e2e8f0;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-logo {
  padding: 16px 20px; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: #fff; border: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.sidebar-logo-icon img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-logo-text { font-weight: 700; font-size: 14px; }
.sidebar-logo-sub { font-size: 11px; color: #94a3b8; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow: auto; }
.sidebar-section {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 8px 10px 4px; margin-bottom: 2px;
}
.sidebar-section:not(:first-child) { padding-top: 16px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px; margin-bottom: 2px;
  cursor: pointer; font-size: 13px; color: #475569;
  transition: all 0.15s; user-select: none;
}
.nav-item:hover { background: #f1f5f9; }
.nav-item.active { background: #EFF6FF; color: #2563eb; font-weight: 600; }
.nav-item .icon { font-size: 15px; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid #e2e8f0;
  font-size: 10px; color: #94a3b8; display: flex; align-items: center; gap: 6px;
}
.badge-prod {
  background: #dcfce7; color: #16a34a; padding: 1px 6px;
  border-radius: 4px; font-weight: 700; font-size: 9px;
}

/* ── Main ── */
.main { flex: 1; overflow: auto; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px; background: #fff; border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px; background: #f1f5f9; border-radius: 8px;
  flex: 1; max-width: 420px; color: #94a3b8; font-size: 13px;
}
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
}
.topbar-name { font-size: 13px; font-weight: 600; }
.topbar-role { font-size: 11px; color: #94a3b8; }

.content { padding: 24px 28px; flex: 1; overflow: auto; }

/* Page sections */
.page-section { display: none; }
.page-section.active { display: block; }

/* Title */
.title-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.title-row h1 { font-size: 24px; font-weight: 700; color: #0f172a; }
.title-row .subtitle { font-size: 13px; color: #64748b; margin-top: 4px; }
.title-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid #e2e8f0;
  background: #fff; cursor: pointer; font-size: 13px; color: #475569;
  font-weight: 500; font-family: inherit; transition: all 0.15s;
}
.btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.btn.active { background: #EFF6FF; color: #2563eb; border-color: #bfdbfe; }
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; border: none; padding: 10px 18px; font-weight: 600;
  box-shadow: 0 1px 3px rgba(37,99,235,0.3);
}
.btn-primary:hover { box-shadow: 0 2px 8px rgba(37,99,235,0.4); background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.btn-danger { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: #15803d; border-color: #86efac; }
.btn-success:hover { background: #bbf7d0; }

/* Search */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #fff; border-radius: 10px;
  border: 2px solid #3b82f6; margin-bottom: 16px;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.search-bar input {
  flex: 1; border: none; outline: none; font-size: 14px;
  color: #1e293b; background: transparent; font-family: inherit;
}
.search-bar input::placeholder { color: #94a3b8; }

/* Filters */
.filters-row {
  display: flex; gap: 16px; padding: 16px 20px;
  background: #fff; border-radius: 10px; border: 1px solid #e2e8f0;
  margin-bottom: 16px; flex-wrap: wrap;
}
.filter-group { flex: 1; min-width: 130px; }
.filter-group label {
  display: block; font-size: 11px; font-weight: 600; color: #64748b;
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.filter-group select {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  border: 1px solid #e2e8f0; background: #fff; font-size: 13px;
  color: #1e293b; cursor: pointer; outline: none; font-family: inherit;
}
.filter-group select:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }

/* Table */
.table-wrapper {
  background: #fff; border-radius: 10px; border: 1px solid #e2e8f0; overflow: hidden;
}
.table-header, .table-row {
  display: grid;
  grid-template-columns: 120px 1fr 140px 120px 90px 115px 140px 120px;
  padding: 0 20px; align-items: center;
}
.table-header {
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  padding-top: 12px; padding-bottom: 12px;
}
.th {
  font-size: 11px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.5px; user-select: none;
}
.th.sortable { cursor: pointer; display: flex; align-items: center; gap: 4px; }
.th.sortable:hover { color: #3b82f6; }
.table-row {
  padding-top: 14px; padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9; transition: background 0.1s; cursor: pointer;
}
.table-row:last-child { border-bottom: none; }
.table-row:hover { background: #f8fafc; }
.cell-codigo { font-size: 13px; font-weight: 600; color: #3b82f6; }
.cell-nombre { font-size: 13px; font-weight: 500; color: #1e293b; padding-right: 12px; }
.cell-cliente { font-size: 13px; color: #475569; }

/* Estado badges */
.estado-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
  white-space: nowrap; cursor: pointer; position: relative;
}
.estado-Ingresado  { background: #EEF2FF; color: #4F46E5; border: 1px solid #C7D2FE; }
.estado-EnRevision { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }
.estado-Observado  { background: #FEF9C3; color: #A16207; border: 1px solid #FDE047; }
.estado-Aprobado   { background: #DCFCE7; color: #15803D; border: 1px solid #86EFAC; }
.estado-Rechazado  { background: #FEE2E2; color: #DC2626; border: 1px solid #FECACA; }

/* Progress */
.progress-wrap { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.progress-bar { width: 60px; height: 5px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.progress-label { font-size: 11px; color: #64748b; font-weight: 500; }

/* Cells */
.cell-prioridad { font-size: 12px; display: flex; align-items: center; gap: 4px; color: #475569; font-weight: 500; }
.cell-entrega { font-size: 12px; color: #475569; }
.cell-entrega .responsable { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.ind-none { font-size: 12px; color: #94a3b8; }
.ind-active { font-size: 12px; color: #c2410c; font-weight: 500; }

/* Actions */
.actions { display: flex; gap: 4px; flex-wrap: wrap; }
.action-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid #e2e8f0; background: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: #64748b; transition: all 0.15s;
}
.action-btn:hover { background: #f1f5f9; border-color: #cbd5e1; color: #334155; }
.pagination { display: flex; justify-content: center; padding: 16px 0; font-size: 12px; color: #94a3b8; }
.empty-state { padding: 40px; text-align: center; color: #94a3b8; font-size: 14px; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  z-index: 1000; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 95%; max-width: 640px;
  max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: slideUp 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid #e2e8f0;
}
.modal-header h2 { font-size: 18px; font-weight: 700; color: #0f172a; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid #e2e8f0;
  background: #fff; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 18px; color: #64748b; transition: all 0.15s;
}
.modal-close:hover { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 24px; border-top: 1px solid #e2e8f0;
}

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12px; font-weight: 600; color: #475569; }
.form-group input, .form-group select, .form-group textarea {
  padding: 9px 12px; border-radius: 8px; border: 1px solid #e2e8f0;
  font-size: 13px; color: #1e293b; font-family: inherit; outline: none;
  transition: border 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
.form-group textarea { resize: vertical; min-height: 60px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  padding: 12px 20px; border-radius: 10px; font-size: 13px; font-weight: 500;
  display: none; align-items: center; gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15); animation: slideUp 0.3s ease;
}
.toast.show { display: flex; }
.toast.success { background: #15803d; color: #fff; }
.toast.info { background: #1d4ed8; color: #fff; }
.toast.error { background: #dc2626; color: #fff; }

/* Detail */
.detail-card {
  background: #fff; border-radius: 12px; border: 1px solid #e2e8f0;
  padding: 24px; margin-bottom: 16px;
}
.detail-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; color: #0f172a; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.detail-item label {
  font-size: 11px; font-weight: 600; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 4px;
}
.detail-item .value { font-size: 14px; font-weight: 500; color: #1e293b; }

/* Placeholder pages */
.placeholder-page {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 400px; color: #94a3b8; text-align: center;
}
.placeholder-page .big-icon { font-size: 48px; margin-bottom: 16px; }
.placeholder-page h2 { font-size: 20px; color: #64748b; margin-bottom: 8px; }
.placeholder-page p { font-size: 14px; max-width: 400px; }

/* Estado dropdown */
.estado-dropdown {
  position: absolute; top: 100%; left: 0; z-index: 100;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); min-width: 150px;
  padding: 4px; display: none;
}
.estado-dropdown.show { display: block; }
.estado-dropdown-item {
  padding: 8px 12px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 500; transition: background 0.1s;
}
.estado-dropdown-item:hover { background: #f1f5f9; }

/* ── Calendario ── */
.cal-nav {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-bottom: 20px;
}
.cal-nav-btn {
  width: 34px; height: 34px; border: 1px solid #e2e8f0; border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 20px; line-height: 1;
  color: #475569; transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.cal-nav-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.cal-month-label { font-size: 18px; font-weight: 700; color: #0f172a; min-width: 200px; text-align: center; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; background: #e2e8f0; border-radius: 12px; overflow: hidden;
  border: 1px solid #e2e8f0;
}
.cal-dow {
  background: #f8fafc; padding: 8px 6px; text-align: center;
  font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase;
}
.cal-day {
  background: #fff; min-height: 88px; padding: 6px 7px;
  position: relative; transition: background 0.1s;
}
.cal-day:hover { background: #f8fafc; }
.cal-day.cal-empty { background: #fafafa; }
.cal-day.cal-weekend { background: #fafafa; }
.cal-day.cal-holiday { background: #fff7ed; }
.cal-day.cal-today { outline: 2px solid #3b82f6; outline-offset: -2px; }
.cal-day-num {
  font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 3px;
}
.cal-day.cal-weekend .cal-day-num { color: #94a3b8; }
.cal-day.cal-today .cal-day-num {
  background: #3b82f6; color: #fff; border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.cal-holiday-label {
  font-size: 9px; font-weight: 600; color: #c2410c;
  line-height: 1.2; margin-bottom: 3px; text-transform: uppercase;
}
.cal-chip {
  font-size: 9px; font-weight: 600; background: #dbeafe; color: #1d4ed8;
  padding: 1px 5px; border-radius: 3px; margin-top: 2px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
.cal-chip:hover { background: #bfdbfe; }

/* ── Tabs de detalle ── */
.detail-tab {
  padding: 8px 18px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: #64748b;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.detail-tab:hover { color: #1e293b; }
.detail-tab.detail-tab-active { color: #3b82f6; border-bottom-color: #3b82f6; font-weight: 600; }

/* Responsive */
@media (max-width: 1100px) {
  .sidebar { display: none; }
  .table-header, .table-row {
    grid-template-columns: 100px 1fr 110px 110px 80px 100px 120px 100px;
  }
}
