/* Fondo y layout general */
body {
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  background: linear-gradient(135deg, #6a0dad, #9b4dca);
  min-height: 100vh;
  overflow-y: auto;
  padding: 2em 1em;
  display: flex;
  justify-content: center;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* Contenedor principal */
.container {
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  padding: 2em;
  width: 100%;
  max-width: 720px;
  min-width: 0;
  animation: fadeIn 0.5s ease-in-out;
}

h1 {
  text-align: center;
  margin-bottom: 1em;
  color: #333;
}

h2 {
  margin-top: 1.5em;
  color: #6a0dad;
}

/* Inputs */
input {
  width: 100%;
  padding: 0.75em;
  margin: 0.5em 0;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 1em;
  transition: border-color 0.3s;
}

input:focus {
  border-color: #6a0dad;
  outline: none;
}

/* Botones */
button {
  width: 100%;
  padding: 0.75em;
  background: #6a0dad;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.3s;
}

button:hover {
  background: #4b0082;
}

/* Tabla */
table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 1em;
  min-width: 560px;
}

#tokens {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

th, td {
  border: 1px solid #ccc;
  padding: 0.5em;
  text-align: left;
}

/* Overlay */
#overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
  color: white;
}

.progress-container {
  width: 80%;
  background: #444;
  border-radius: 5px;
  overflow: hidden;
}

#progress-bar {
  height: 20px;
  width: 0%;
  background: lime;
}

#progress-text {
  margin-top: 10px;
}

/* Animación */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

#panel {
  display: none;
}

#cambio-clave, #configuracion {
  display: none;
}

/* Fondo semitransparente */
.modal {
  display: none; /* Oculto por defecto */
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
}

/* Contenido del modal */
.modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: fadeIn 0.3s ease;
}

/* Título púrpura */
.modal-content h2 {
  margin-top: 0;
  color: #6a0dad;
}

/* Botón de cierre */
.modal-close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.modal-close:hover {
  color: #000;
}

/* Animación */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}


.paginacion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.paginacion button {
  background-color: #6a1b9a;
  color: white;
  border: none;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
}

#tokens > div {
  gap: 0.75em;
  flex-wrap: wrap;
}

.paginacion button:disabled {
  background-color: #ccc;
  cursor: default;
}

/* Generador de token responsivo */
.generador {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 1em;
  align-items: center;
}

.generador input {
  flex: 1 1 200px;
  min-width: 150px;
  padding: 0.75em;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 5px;
}

.generador button {
  flex: 0 0 auto;
  padding: 0.75em 1em;
  font-size: 1em;
  background: #6a0dad;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s;
}

.generador button:hover {
  background: #4b0082;
}

.pdf-card { margin-top: 1.5em; }
.study-upload { margin-top: 1em; padding: 1em; border: 1px solid #ddd; border-radius: 6px; }
.study-upload strong, .study-upload span { display: block; overflow-wrap: anywhere; }
.study-upload > div:first-child span, .pdf-list { margin-top: .35em; color: #666; font-size: .85em; }
.pdf-list { display: grid; gap: .3em; }
.study-upload label { display: block; margin-top: .75em; color: #333; font-size: .9em; }
.study-upload input[type="file"] { margin: .4em 0 0; }

@media (max-width: 500px) {
  body {
    padding: 0;
  }

  .container {
    min-height: 100vh;
    border-radius: 0;
    padding: 1.25em 1em;
  }

  h1 {
    font-size: 1.6em;
  }

  h2 {
    font-size: 1.2em;
  }

  .generador {
    flex-direction: column;
    align-items: stretch;
  }

  .generador input,
  .generador button {
    width: 100%;
  }

  .progress-container {
    width: calc(100% - 2em);
  }

  .modal-content {
    margin: 25% auto;
    width: calc(100% - 2em);
  }
}

/* Production dashboard refresh */
:root { --ink: #17202b; --muted-text: #6b7785; --line-soft: #e2e8ee; --accent-green: #167d68; --accent-green-dark: #0e5b4d; }
body { align-items: flex-start; background: radial-gradient(circle at 10% 0%, #dbeee9 0, transparent 35%), #f3f6f8; color: var(--ink); font-family: "Trebuchet MS", "Segoe UI", sans-serif; padding: 3rem 1.25rem; }
.container { max-width: 980px; padding: 0; overflow: hidden; border: 1px solid var(--line-soft); border-radius: 8px; box-shadow: 0 18px 45px rgba(23, 32, 43, .11); }
.brand-header, .panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.brand-header { padding: 2.25rem 2.5rem; background: #172c35; color: #fff; }
.brand-header h1, .panel-header h2, h3 { margin: 0; color: inherit; }
.brand-header h1 { text-align: left; font-size: clamp(1.5rem, 3vw, 2.2rem); }
.eyebrow { margin: 0 0 .45rem; color: #5fcbb3; font-size: .7rem; font-weight: 700; letter-spacing: .12em; }
.subtitle { max-width: 560px; margin: .5rem 0 0; color: #b7c6ca; font-size: .9rem; }
.status-dot { color: #9ee3d0; font-size: .75rem; white-space: nowrap; }
#login, #panel, #cambio-clave { width: 100%; }
.auth-panel, .dashboard, .password-panel { padding: 2rem 2.5rem; }
.auth-panel { max-width: 470px; margin: 0 auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.section-heading h3 { font-size: 1.05rem; }
.secure-label, .muted { color: var(--muted-text); font-size: .75rem; }
label { display: block; margin: .8rem 0 .25rem; color: #485766; font-size: .78rem; font-weight: 700; }
input { width: 100%; margin: 0; padding: .8rem .9rem; border: 1px solid #cbd5dd; border-radius: 4px; background: #fff; color: var(--ink); }
input:focus { border-color: var(--accent-green); box-shadow: 0 0 0 3px rgba(22, 125, 104, .14); }
button { width: auto; border-radius: 4px; font-size: .82rem; }
.primary-button, .secondary-button { padding: .75rem 1rem; }
.primary-button { background: var(--accent-green); }
.primary-button:hover { background: var(--accent-green-dark); }
.secondary-button { border: 1px solid #bfd0d4; background: transparent; color: var(--accent-green-dark); }
.secondary-button:hover { background: #e8f3f0; }
.panel-header { align-items: center; margin-bottom: 1.5rem; }
.panel-header h2 { font-size: 1.45rem; }
.generator-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 1.1fr); align-items: end; gap: 1.5rem; padding: 1.25rem; border: 1px solid #cfe3de; border-left: 4px solid var(--accent-green); background: #f2faf8; }
.generator-card p { margin: .35rem 0 0; color: var(--muted-text); font-size: .82rem; }
.generador { margin: 0; }
.generador input { flex: 1 1 auto; }
.generador button { flex: 0 0 auto; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; margin: 1rem 0 2rem; }
.stat-card { display: flex; flex-direction: column; gap: .4rem; padding: 1rem; border: 1px solid var(--line-soft); background: #fff; }
.stat-card span { color: var(--muted-text); font-size: .75rem; }
.stat-card strong { color: var(--accent-green-dark); font-size: 1.35rem; }
.tokens-section { border-top: 1px solid var(--line-soft); padding-top: 1.5rem; }
table { min-width: 680px; margin-top: .5rem; }
th { background: #edf3f3; color: #42525c; font-size: .72rem; text-transform: uppercase; }
th, td { border: 0; border-bottom: 1px solid var(--line-soft); padding: .8rem .65rem; }
td a { color: var(--accent-green-dark); font-weight: 700; }
.password-panel { max-width: 650px; margin: 0 auto; }
.settings-form { max-width: 720px; }
.settings-form input { margin-bottom: .25rem; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.settings-form button { margin-top: 1rem; }
#overlay { background: rgba(23, 44, 53, .78); }
#progress-bar { background: #5fcbb3; }
.modal-content { border-radius: 6px; }
.modal-content h2 { color: var(--accent-green-dark); }
.access-card { display: flex; align-items: center; gap: 1rem; border: 1px solid var(--line-soft); padding: 1rem; }
.access-details { min-width: 0; flex: 1; }
.access-details p { margin: .45rem 0; overflow-wrap: anywhere; }
.access-details a { color: var(--accent-green-dark); }
.access-code { font-size: 1.15rem; letter-spacing: .12em; }
.access-qr { width: 150px; height: 150px; flex: 0 0 auto; }
.print-access-button { width: 100%; margin-top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 700px) {
  body { padding: 0; }
  .brand-header, .auth-panel, .dashboard, .password-panel { padding: 1.35rem 1rem; }
  .generator-card { grid-template-columns: 1fr; gap: .8rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .panel-header { align-items: flex-start; }
  .header-actions { flex-direction: column; align-items: stretch; }
  .panel-header .secondary-button { padding: .55rem .65rem; }
  .settings-grid { grid-template-columns: 1fr; gap: 0; }
  .access-card { align-items: stretch; flex-direction: column; }
  .access-qr { align-self: center; }
}