/* ============================================================
   RESET Y BASE
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', -apple-system, Arial, sans-serif;
  background: #f4f6f9;
  color: #2d3748;
  line-height: 1.5;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
  padding: 1rem;
}

.login-card {
  background: #fff;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .3);
  width: 100%;
  max-width: 420px;
}

.logo-area { text-align: center; margin-bottom: 1.5rem; }
.login-card h1 { color: #1e3a5f; font-size: 1.5rem; margin-bottom: .3rem; }
.subtitulo { color: #718096; font-size: .8rem; }

label {
  display: block;
  margin: 1rem 0 .3rem;
  font-weight: 600;
  font-size: .9rem;
  color: #2d3748;
}

input[type=text], input[type=password] {
  width: 100%;
  padding: .75rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 1rem;
  transition: border .2s;
}

input:focus {
  outline: none;
  border-color: #2c5282;
  box-shadow: 0 0 0 3px rgba(44, 82, 130, .15);
}

button {
  width: 100%;
  padding: .85rem;
  margin-top: 1.5rem;
  background: #1e3a5f;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

button:hover:not(:disabled) { background: #2c5282; }
button:disabled { background: #a0aec0; cursor: not-allowed; }

.error {
  background: #fed7d7;
  color: #c53030;
  padding: .75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: .9rem;
  border-left: 4px solid #c53030;
}

.footer-text {
  text-align: center;
  margin-top: 1.5rem;
  color: #a0aec0;
  font-size: .75rem;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  background: #1e3a5f;
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand { font-weight: 700; font-size: 1.1rem; }
.user-info { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }

.btn-logout {
  background: rgba(255, 255, 255, .15);
  color: #fff;
  padding: .4rem .9rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: .85rem;
  transition: background .2s;
}
.btn-logout:hover { background: rgba(255, 255, 255, .25); }

/* ============================================================
   CONTAINER
   ============================================================ */
.container {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}
.container h2 { color: #1e3a5f; margin-bottom: .5rem; }
.muted { color: #718096; margin-bottom: 2rem; }
.muted.small { font-size: .8rem; margin-bottom: 0; }

/* ============================================================
   CARD GRID (DASHBOARD)
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 420px));
  gap: 1.5rem;
  justify-content: start;
}

.card {
  background: #fff;
  padding: 1.5rem;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  border-top: 4px solid #2c5282;
  display: flex;
  flex-direction: column;
}

.card h3 { color: #1e3a5f; margin-bottom: .5rem; font-size: 1.05rem; }
.card p { color: #718096; font-size: .9rem; margin-bottom: 1rem; }
.card .btn-primary,
.card button { margin-top: auto; }

/* ============================================================
   BOTONES PRINCIPALES
   ============================================================ */
.btn-primary, .btn-secondary {
  padding: .75rem 1.5rem;
  border-radius: 6px;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all .2s;
  display: inline-block;
  text-align: center;
}
.btn-primary { background: #1e3a5f; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2c5282; }
.btn-primary:disabled { background: #a0aec0; cursor: not-allowed; }
.btn-secondary { background: #e2e8f0; color: #4a5568; }
.btn-secondary:hover { background: #cbd5e0; }

.btn-small {
  display: inline-block;
  padding: .4rem .85rem;
  background: #2c5282;
  color: #fff;
  text-decoration: none;
  border-radius: 5px;
  font-size: .78rem;
  font-weight: 600;
  transition: background .2s;
}
.btn-small:hover { background: #1e3a5f; }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
  margin-bottom: 1rem;
  font-size: .9rem;
}
.breadcrumb a {
  color: #2c5282;
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }

/* ============================================================
   FORMULARIOS DE DICTAMEN
   ============================================================ */
.form-upload, .form-dictamen {
  background: #fff;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  margin-top: 1rem;
}

/* Dropzone */
.dropzone {
  border: 2px dashed #cbd5e0;
  border-radius: 10px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  background: #fafbfc;
}
.dropzone:hover, .dropzone.dragover {
  border-color: #2c5282;
  background: #ebf4ff;
}
.dropzone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dropzone-icon { font-size: 3rem; margin-bottom: 1rem; }
.dropzone p { margin: .25rem 0; }
.dropzone .small { font-size: .8rem; }

.file-info {
  margin-top: 1rem;
  padding: .75rem;
  background: #c6f6d5;
  border-radius: 6px;
  color: #22543d;
  font-weight: 600;
}

/* Fieldsets del formulario */
fieldset {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
legend {
  padding: 0 .5rem;
  font-weight: 700;
  color: #1e3a5f;
  font-size: 1rem;
}
fieldset label {
  display: block;
  margin: 1rem 0 .3rem;
  font-weight: 600;
  font-size: .85rem;
  color: #4a5568;
}
fieldset input[type=text],
fieldset textarea,
fieldset select {
  width: 100%;
  padding: .65rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: .95rem;
  font-family: inherit;
}
fieldset textarea { resize: vertical; }
fieldset input:focus,
fieldset textarea:focus,
fieldset select:focus {
  outline: none;
  border-color: #2c5282;
  box-shadow: 0 0 0 3px rgba(44, 82, 130, .15);
}

.info-extra {
  background: #ebf8ff;
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  color: #2c5282;
}

/* Acciones de formulario */
.acciones {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ============================================================
   VISTA RESULTADO
   ============================================================ */
.resultado-card {
  background: #fff;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  margin-top: 1rem;
}

.exito-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: #c6f6d5;
  border-left: 4px solid #38a169;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}
.exito-icono { font-size: 2rem; }
.exito-banner h2 { color: #22543d; font-size: 1.15rem; margin-bottom: .2rem; }
.exito-banner p { color: #2f855a; font-size: .9rem; }

.folio-box {
  background: #1e3a5f;
  color: #fff;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-bottom: 1.5rem;
}
.folio-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: .75;
}
.folio-valor {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 3px;
  font-family: 'Courier New', monospace;
}
.folio-hint { font-size: .8rem; opacity: .7; }

.resumen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.resumen-item {
  padding: .75rem 1rem;
  background: #f7fafc;
  border-radius: 6px;
  border-left: 3px solid #cbd5e0;
}
.resumen-item.destacado {
  background: #fffaf0;
  border-left-color: #dd6b20;
}
.resumen-item .label {
  display: block;
  font-size: .75rem;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: .25rem;
}
.resumen-item .valor {
  font-size: .95rem;
  color: #2d3748;
  font-weight: 600;
  word-break: break-word;
}

.detalle {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: .75rem 1rem;
  margin-bottom: .75rem;
}
.detalle summary {
  cursor: pointer;
  font-weight: 600;
  color: #2c5282;
  font-size: .9rem;
}
.detalle p {
  margin-top: .75rem;
  color: #4a5568;
  font-size: .88rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.info-tecnica {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #edf2f7;
  border-radius: 6px;
}
.info-tecnica .hash {
  display: block;
  font-family: 'Courier New', monospace;
  font-size: .75rem;
  background: #fff;
  padding: .5rem;
  border-radius: 4px;
  margin: .5rem 0;
  word-break: break-all;
  color: #2c5282;
}
.info-tecnica .small { font-size: .8rem; }

/* ============================================================
   ESTADOS (VIGENTE / REVOCADO)
   ============================================================ */
.estado-vigente { color: #38a169 !important; }
.estado-revocado { color: #c53030 !important; }

.estado-pill {
  display: inline-block;
  padding: .3rem .7rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .5px;
}
.estado-pill.vigente { background: #c6f6d5; color: #22543d; }
.estado-pill.revocado { background: #fed7d7; color: #742a2a; }

/* ============================================================
   HISTORIAL: HEADER + BUSCADOR
   ============================================================ */
.historial-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}
.historial-header h3 {
  color: #1e3a5f;
  font-size: 1.2rem;
  margin: 0;
}

.buscador {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.buscador input {
  padding: .6rem .9rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: .9rem;
  min-width: 280px;
  margin: 0;
  width: auto;
}
.buscador input:focus {
  outline: none;
  border-color: #2c5282;
  box-shadow: 0 0 0 3px rgba(44, 82, 130, .15);
}
.buscador button {
  padding: .6rem 1.1rem;
  background: #2c5282;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  width: auto;
  margin: 0;
}
.buscador button:hover { background: #1e3a5f; }
.buscador .btn-clear {
  background: #e2e8f0;
  color: #4a5568;
  text-decoration: none;
  padding: .6rem .9rem;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 600;
}
.buscador .btn-clear:hover { background: #cbd5e0; }

/* ============================================================
   TABLA DE DICTÁMENES
   ============================================================ */
.tabla-wrapper {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  overflow: hidden;
}

.tabla-dictamenes {
  width: 100%;
  border-collapse: collapse;
}
.tabla-dictamenes th,
.tabla-dictamenes td {
  padding: 1rem 1.25rem;
  text-align: left;
  font-size: .88rem;
  border-bottom: 1px solid #edf2f7;
  vertical-align: middle;
}
.tabla-dictamenes th {
  background: #f7fafc;
  color: #4a5568;
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid #e2e8f0;
}
.tabla-dictamenes tbody tr:last-child td { border-bottom: none; }
.tabla-dictamenes tbody tr:hover { background: #f7fafc; }

.col-folio code {
  background: #edf2f7;
  padding: .3rem .6rem;
  border-radius: 4px;
  font-size: .82rem;
  color: #2c5282;
  font-weight: 700;
  letter-spacing: .5px;
  font-family: 'Courier New', monospace;
}

.col-resultado .badge {
  display: inline-block;
  padding: .3rem .75rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge-apto { background: #c6f6d5; color: #22543d; }
.badge-no-apto { background: #fed7d7; color: #742a2a; }
.badge-condicional { background: #fefcbf; color: #744210; }
.badge-default { background: #e2e8f0; color: #4a5568; }

/* ============================================================
   PAGINACIÓN
   ============================================================ */
.paginacion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #f7fafc;
  border-top: 1px solid #edf2f7;
  font-size: .85rem;
  color: #4a5568;
  flex-wrap: wrap;
  gap: .75rem;
}
.paginacion-info strong { color: #2d3748; }

.paginacion-controles {
  display: flex;
  gap: .35rem;
  align-items: center;
  flex-wrap: wrap;
}
.paginacion-controles a,
.paginacion-controles span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 .7rem;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  color: #2c5282;
  background: #fff;
  border: 1px solid #e2e8f0;
  transition: all .15s;
}
.paginacion-controles a:hover {
  background: #2c5282;
  color: #fff;
  border-color: #2c5282;
}
.paginacion-controles .pagina-actual {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
}
.paginacion-controles .disabled {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  background: #fff;
  padding: 3.5rem 2rem;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  margin-top: 1rem;
}
.empty-state .icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h4 { color: #2d3748; margin-bottom: .5rem; font-size: 1.05rem; }
.empty-state p { color: #718096; font-size: .9rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .topbar { padding: .85rem 1rem; }
  .container { padding: 0 1rem; margin: 1.5rem auto; }
  .card-grid { grid-template-columns: 1fr; }
  .tabla-dictamenes th,
  .tabla-dictamenes td { padding: .75rem .6rem; font-size: .8rem; }
  .historial-header { flex-direction: column; align-items: stretch; }
  .buscador input { min-width: 0; flex: 1; }
  .paginacion { justify-content: center; }
}

/* ============ QR PREVIEW ============ */
.qr-preview {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #ebf8ff;
  border-radius: 6px;
  border-left: 4px solid #2c5282;
}
.qr-preview code {
  display: block;
  background: #fff;
  padding: .5rem .75rem;
  border-radius: 4px;
  font-size: .8rem;
  color: #2c5282;
  margin: .5rem 0;
  word-break: break-all;
  font-family: 'Courier New', monospace;
}


/* ============ GESTIÓN DE DICTAMEN ============ */
.gestion-acciones {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #f7fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.gestion-acciones h3 {
  color: #1e3a5f;
  font-size: 1rem;
  margin-bottom: 1rem;
}
.gestion-acciones label {
  display: block;
  font-weight: 600;
  font-size: .85rem;
  margin: 1rem 0 .3rem;
  color: #4a5568;
}
.gestion-acciones textarea,
.gestion-acciones input[type=text] {
  width: 100%;
  padding: .65rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-family: inherit;
  font-size: .95rem;
}

.btn-warning {
  padding: .75rem 1.5rem;
  background: #dd6b20;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: background .2s;
  display: inline-block;
  margin-right: .5rem;
}
.btn-warning:hover { background: #c05621; }

.btn-danger {
  padding: .75rem 1.5rem;
  background: #c53030;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: background .2s;
}
.btn-danger:hover { background: #9b2c2c; }

.btn-danger-outline {
  display: inline-block;
  padding: .65rem 1.25rem;
  background: transparent;
  color: #c53030;
  border: 2px solid #c53030;
  border-radius: 6px;
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  transition: all .2s;
}
.btn-danger-outline:hover {
  background: #c53030;
  color: #fff;
}

.acciones-form {
  display: flex;
  gap: .75rem;
  margin-top: 1rem;
}

.aviso-revocado {
  background: #fed7d7;
  border-left: 4px solid #c53030;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.aviso-revocado strong { color: #742a2a; }
.aviso-revocado p {
  margin: .5rem 0 0;
  font-size: .88rem;
  color: #742a2a;
}

.aviso-peligro {
  background: #fff5f5;
  border: 2px solid #fc8181;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.aviso-peligro .icono {
  font-size: 2.5rem;
  margin-bottom: .5rem;
}
.aviso-peligro h2 {
  color: #742a2a;
  font-size: 1.2rem;
  margin-bottom: .75rem;
}
.aviso-peligro p {
  color: #742a2a;
  font-size: .9rem;
  margin-bottom: .5rem;
}
.aviso-peligro ul {
  margin: .5rem 0 0 1.5rem;
  color: #742a2a;
  font-size: .88rem;
}

/* Select de filtro */
.buscador select {
  padding: .6rem .9rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: .9rem;
  background: #fff;
  cursor: pointer;
}
.buscador select:focus {
  outline: none;
  border-color: #2c5282;
  box-shadow: 0 0 0 3px rgba(44,82,130,.15);
}


.form-verificar-dashboard {
  display: flex;
  gap: .5rem;
  margin-top: auto;
}
.form-verificar-dashboard input {
  flex: 1;
  padding: .6rem .8rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: .85rem;
  text-transform: uppercase;
  margin: 0;
}
.form-verificar-dashboard input:focus {
  outline: none;
  border-color: #2c5282;
  box-shadow: 0 0 0 3px rgba(44, 82, 130, .15);
}
.form-verificar-dashboard button {
  padding: .6rem 1rem;
  margin: 0;
  width: auto;
  font-size: .85rem;
}

.hint {
  display: block;
  color: #718096;
  font-size: .75rem;
  margin-top: .25rem;
  font-style: italic;
}