/* ============================================================
   1. FOUNDATION
   Variables, reset, tipografía, botones compartidos,
   formularios, tablas, utilidades, scroll
   ============================================================ */

/* ── Variables y reseteo ── */

:root {
  --primary-color: #2c7a4b;
  --primary-dark: #1e5a37;
  --primary-light: #3a9b5c;
  --accent-color: #f59e0b;
  --text-dark: #1f2937;
  --text-light: #6b7280;
  --bg-light: #f9fafb;
  --bg-white: #ffffff;
  --border-color: #e5e7eb;
  --success-color: #10b981;
  --error-color: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
  --navbar-height: 64px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  background-color: var(--bg-light);
  color: var(--text-dark);
  line-height: 1.6;
}

/* ── Tipografía ── */

h1 {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  font-weight: 700;
}

h2 {
  font-size: 1.875rem;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  font-weight: 600;
  border-bottom: 3px solid var(--accent-color);
  padding-bottom: 0.75rem;
  display: inline-block;
}

/* ── Botones compartidos ── */

button {
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  border-radius: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
}

/* Acción primaria: usado en Vista 2, 3, 5 y 6 */
button[type="submit"],
#saveCompanyDataButton,
#saveDocumentButton,
#generatePdfButton {
  background-color: var(--primary-color);
  color: white;
  width: 100%;
  padding: 0.875rem;
  margin-top: 1.5rem;
  font-size: 1rem;
}

button[type="submit"]:hover,
#saveCompanyDataButton:hover,
#saveDocumentButton:hover,
#generatePdfButton:hover {
  background-color: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

button[type="submit"]:active {
  transform: scale(0.98);
}

/* Botones dentro de tablas (Historial y Detalle documento) */
table button {
  background-color: var(--primary-light);
  color: white;
  padding: 0.5rem 1rem;
  width: auto;
  margin-top: 0;
  font-size: 0.875rem;
}

table button:hover {
  background-color: var(--primary-color);
}

/* ── Formularios ── */

form {
  background-color: var(--bg-white);
  padding: 2rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-md);
}

fieldset {
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

legend {
  padding: 0 0.5rem;
  font-weight: 600;
  color: var(--primary-color);
  font-size: 1.125rem;
}

.form-group,
.form-grid>div>div:not(.form-group) {
  margin-bottom: 1.25rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-dark);
  font-size: 0.95rem;
}

input[type="text"],
input[type="number"],
input[type="date"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
  background-color: var(--bg-white);
}

input[type="date"] {
  min-width: 0;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 3.25rem;
  line-height: normal;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(44, 122, 75, 0.1);
}

input[type="number"]::placeholder {
  color: var(--text-light);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.form-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.form-column .form-group {
  flex: 1;
}

/* ── Tablas ── */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  box-shadow: var(--shadow-sm);
  border-radius: 0.5rem;
  overflow: hidden;
  background-color: var(--bg-white);
}

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

th {
  padding: 1.25rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

td {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background-color: rgba(44, 122, 75, 0.05);
}

tbody tr:last-child td {
  border-bottom: none;
}

tfoot {
  background-color: var(--bg-light);
  font-weight: 600;
}

tfoot td {
  padding: 1rem;
  border-top: 2px solid var(--primary-color);
}

/* ── Utilidades ── */

.text-center {
  text-align: center;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.gap-1 {
  gap: 0.5rem;
}

/* ── Scroll ── */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}


/* ============================================================
   2. LAYOUT & NAVEGACIÓN
   ============================================================ */

/*
  JS maneja:
  - .navbar--hidden     → oculta el navbar (Vista 1)
  - .nav-visible        → agrega padding-top al main cuando el navbar es visible
  - .is-open            → en #hamburgerButton y #mobileMenu para abrir/cerrar menú mobile
  - .active             → en .nav-link para marcar el ítem activo
  - aria-expanded       → en #hamburgerButton (true/false)
  - aria-hidden         → en #mobileMenu (true/false)
*/

/* ── Navbar ── */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  background-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

.navbar--hidden {
  display: none;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.25rem;
}

.nav-link {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
  display: block;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: white;
}

/* JS agrega .active al nav-link de la vista actual */
.nav-link.active {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

/* ── Hamburguesa (mobile) ── */

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  width: 44px;
  height: 44px;
  border-radius: 0.5rem;
  transition: var(--transition);
  margin-top: 0;
  font-size: 1rem;
  font-weight: normal;
}

.hamburger:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background-color: white;
  border-radius: 2px;
  transition: var(--transition);
  pointer-events: none;
}

/* JS agrega .is-open al hamburger → animación X */
.hamburger.is-open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.is-open .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.hamburger.is-open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Mobile menu ── */

.mobile-menu {
  display: none;
  background-color: var(--primary-dark);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

/* JS agrega .is-open al mobile-menu */
.mobile-menu.is-open {
  max-height: 280px;
}

.mobile-menu ul {
  list-style: none;
  padding: 0.5rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mobile-menu li {
  display: block;
}

.mobile-menu .nav-link {
  display: block;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  border-radius: 0.5rem;
  color: rgba(255, 255, 255, 0.9);
}

.mobile-menu .nav-link:hover,
.mobile-menu .nav-link.active {
  background-color: rgba(255, 255, 255, 0.15);
  color: white;
}

/* ── Layout principal ── */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
}

/* JS agrega .nav-visible al <body> cuando el navbar es visible */
body.nav-visible main {
  padding-top: var(--navbar-height);
}

section {
  display: none;
  min-height: 100vh;
  padding: 2rem;
  animation: fadeIn 0.3s ease;
}

section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ============================================================
   3. VISTAS (orden del HTML)
   ============================================================ */

/* ── Vista 1 — Bienvenida (#welcome-view) ── */

#welcome-view {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100vh;
  height: 100vh;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  padding: 0 !important;
  background:
    radial-gradient(ellipse at 15% 50%, rgba(58, 155, 92, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 20%, rgba(20, 70, 40, 0.4) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 90%, rgba(44, 122, 75, 0.2) 0%, transparent 40%),
    linear-gradient(145deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  overflow: hidden;
  position: relative;
}

#welcome-view.active {
  display: flex !important;
}

/* Círculos decorativos de fondo */
#welcome-view::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  top: -150px;
  right: -150px;
  pointer-events: none;
}

#welcome-view::after {
  content: '';
  position: absolute;
  width: 350px;
  height: 350px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  bottom: -100px;
  left: -100px;
  pointer-events: none;
}

.welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 1;
  animation: fadeIn 0.6s ease;
}

.welcome-logo {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

#welcome-view h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1.5px;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  margin-bottom: 0.5rem;
}

.welcome-subtitle {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 1.5rem;
}

.welcome-divider {
  width: 40px;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin-bottom: 1.5rem;
}

#welcome-view h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  border-bottom: none;
  padding-bottom: 0;
  display: block;
  letter-spacing: 0.5px;
  margin-bottom: 2.5rem;
}

.welcome-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
}

#startButton {
  background-color: var(--accent-color);
  color: var(--text-dark);
  padding: 1rem 2.5rem;
  font-size: 1.125rem;
  box-shadow: var(--shadow-lg);
}

#startButton:hover {
  background-color: #f97316;
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

#startButton:active {
  transform: translateY(0);
}

#configButton {
  background-color: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.65rem 2rem;
  font-size: 0.9rem;
  font-weight: 500;
}

#configButton:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: white;
  border-color: rgba(255, 255, 255, 0.5);
}

/* ── Vista 2 — Medidas (#measurements-view) ── */

.diameters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.diameters-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.diameter-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background-color: var(--bg-light);
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}

.diameter-input-group label {
  flex: 0 0 100px;
  margin-bottom: 0;
  font-size: 0.9rem;
}

.diameter-input-group input {
  flex: 1;
  padding: 0.5rem;
  text-align: center;
  min-width: 0;
}

.diameter-input-group button {
  background-color: var(--bg-light);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  width: auto;
  margin: 0 0.25rem;
  flex: 0 0 auto;
}

.diameter-input-group button:hover {
  background-color: var(--primary-light);
  color: white;
  border-color: var(--primary-light);
}

/* ── Vista 3 — Datos empresa (#company-data-view) ── */
/* Usa form, fieldset y .form-grid de Foundation — sin estilos propios */

/* ── Vista 4 — Historial (#history-view) ── */

#history-view table {
  table-layout: fixed;
}

#history-view thead th,
#history-view tbody td {
  text-align: center;
  width: 25%;
}

/* Filtros */
.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.history-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 180px;
}

.history-filter-group label {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 500;
}

.history-filter-group input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg-white);
  color: var(--text-dark);
  height: 54px;
}

.history-filter-group input:focus {
  outline: none;
  border-color: var(--primary-color);
}

#filter-clear {
  padding: 8px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-light);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-end;
  transition: var(--transition);
  height: 54px;
}

#filter-clear:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Paginación */
.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  padding: 8px 0;
}

#pagination-info {
  font-size: 0.9rem;
  color: var(--text-light);
  min-width: 100px;
  text-align: center;
}

#pagination-prev,
#pagination-next {
  padding: 8px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--primary-color);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

#pagination-prev:hover:not(:disabled),
#pagination-next:hover:not(:disabled) {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

#pagination-prev:disabled,
#pagination-next:disabled {
  color: var(--border-color);
  cursor: not-allowed;
}

/* ── Vista 5 — Detalle documento (#document-detail-view) ── */

#document-detail-view table {
  table-layout: fixed;
}

#document-detail-view thead th,
#document-detail-view tbody td,
#document-detail-view tfoot td {
  text-align: center;
  width: 25%;
}

#document-detail-view thead th:first-child,
#document-detail-view tbody td:first-child,
#document-detail-view tfoot td:first-child {
  text-align: left;
}

#document-detail-view {
  background-color: var(--bg-white);
}

#documentDetailForm {
  background-color: transparent;
  padding: 0;
  box-shadow: none;
  border-radius: 0;
  margin-top: 0;
}

.document-header {
  background-color: var(--primary-color);
  color: white;
  padding: 1.5rem;
  border-radius: 0.5rem;
  margin-bottom: 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.document-header div {
  font-size: 1rem;
}

.document-header span {
  font-weight: 600;
}

.document-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background-color: var(--bg-light);
  border-radius: 0.5rem;
  border-left: 4px solid var(--primary-color);
}

.info-column div {
  margin-bottom: 0.75rem;
}

.info-column strong {
  color: var(--primary-color);
  font-weight: 600;
  min-width: 100px;
  display: inline-block;
}

.document-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}

.document-actions button {
  flex: 1;
  margin-top: 0 !important;
}

/* Inputs de encabezado — bloqueados por defecto */
.document-header .form-group,
.document-info .form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.document-header label,
.document-info label {
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  letter-spacing: 0.05em;
}

.document-info label {
  color: var(--primary-color);
}

.document-header input,
.document-info input {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  padding: 4px 0;
  width: 100%;
  border-radius: 0;
  height: 36px;
  box-sizing: border-box;
}

.document-info input {
  border-bottom: 1px solid var(--border-color);
  color: var(--text-dark);
  font-weight: 500;
}

/* Estado habilitado al presionar Editar */
.document-header input:not(:disabled),
.document-info input:not(:disabled) {
  border-bottom: 2px solid var(--accent-color);
  outline: none;
}

/* N° Documento — siempre bloqueado, sin indicador de editable */
#doc-number {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Botón Guardar Cambios deshabilitado hasta presionar Editar */
#saveDocumentButton:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Editar — amber para indicar acción disponible */
#editDocumentButton {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

#editDocumentButton:hover {
  background-color: #d97706;
  border-color: #d97706;
}

/* Cuando está en modo edición — más suave para no competir con Guardar */
#editDocumentButton:disabled {
  background-color: #fde68a;
  border-color: #fde68a;
  color: #92400e;
  cursor: not-allowed;
  opacity: 1;
}

#backButton {
  background-color: var(--border-color);
  color: var(--text-dark);
  padding: 0.75rem 1rem;
  width: auto;
  margin-top: 0;
  font-size: 1.25rem;
  flex: 0 0 auto;
}

#backButton:hover {
  background-color: var(--text-light);
  color: white;
}

/* ── Vista 6 — Configuración (#config-view) ── */

.config-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background-color: rgba(44, 122, 75, 0.08);
  border: 1px solid rgba(44, 122, 75, 0.2);
  border-left: 4px solid var(--primary-color);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.config-notice-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.config-notice p {
  font-size: 0.95rem;
  color: var(--text-light);
  line-height: 1.6;
}

/* ── Vista 7 — Acerca de (#about-view) ── */

.about-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.about-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.about-card h3 {
  font-size: 1.15rem;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
}

.about-card p {
  font-size: 0.95rem;
  color: var(--text-light);
  line-height: 1.6;
}

.about-formula {
  padding: 1rem;
  margin-top: 1rem;
  background: var(--bg-light);
  border-radius: 0.5rem;
  border-left: 3px solid var(--primary-color);
}

.about-formula h4 {
  font-size: 0.9rem;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.about-formula code {
  display: block;
  background: var(--text-dark);
  color: var(--accent-color);
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.about-formula p {
  font-size: 0.85rem;
}

.about-formula--legend {
  background: transparent;
  border-left: none;
  padding: 0.75rem 0 0;
}

.about-formula--legend p {
  font-size: 0.8rem;
  color: var(--text-light);
}

.about-card--credits {
  text-align: center;
  background: var(--bg-light);
  border: none;
}

.about-card--credits p {
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.about-card--credits a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.about-card--credits a:hover {
  text-decoration: underline;
}

.about-formula--warning {
  border-left-color: #ff9800;
  background: rgba(255, 152, 0, 0.1);
}

.about-formula--warning h4 {
  color: #ff9800;
}


/* ============================================================
   4. COMPONENTES GLOBALES
   Toast, banner de actualización, créditos
   ============================================================ */

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: var(--text-dark);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 9999;
  white-space: nowrap;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--success {
  border-left: 4px solid var(--success-color);
}

.toast--error {
  border-left: 4px solid var(--error-color);
}

/* ── Banner de actualización ── */

.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background-color: var(--primary-dark);
  color: white;
  padding: 12px 20px;
  font-size: 0.9rem;
  z-index: 10000;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.update-banner--visible {
  transform: translateY(0);
}

#update-btn {
  background-color: var(--accent-color);
  color: var(--text-dark);
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
}

#update-btn:hover {
  background-color: #f97316;
}

#dismiss-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  margin: 0;
}

#dismiss-btn:hover {
  color: white;
}

/* ── Créditos ── */

.welcome-credits {
  margin-top: 2rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.5px;
}

/* Si hay 2 .welcome-credits seguidos (versión + copyright),
   el segundo no separa */
.welcome-credits+.welcome-credits {
  margin-top: 0.25rem;
}

.welcome-credits a {
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.welcome-credits a:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.5);
}

.section-credits {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Si hay 2 .section-credits seguidos (versión + copyright),
   el segundo no duplica el separador */
.section-credits+.section-credits {
  margin-top: 0.25rem;
  padding-top: 0;
  border-top: none;
}

.section-credits a {
  color: var(--primary-color);
  text-decoration: none;
}

.section-credits a:hover {
  text-decoration: underline;
}


/* ============================================================
   5. RESPONSIVE
   Todos los media queries consolidados al final,
   del más ancho al más estrecho
   ============================================================ */

/* ── @media (max-width: 768px) ── */

@media (max-width: 768px) {

  /* Navbar: ocultar links, mostrar hamburguesa */
  .nav-links {
    display: none;
  }

  .hamburger {
    display: flex;
  }

  .mobile-menu {
    display: block;
  }

  /* Layout */
  section {
    padding: 1rem;
  }

  /* Vista 1 — Bienvenida */
  #welcome-view h1 {
    font-size: 2.25rem;
  }

  #welcome-view h2 {
    font-size: 1.1rem;
  }

  .welcome-logo {
    font-size: 3rem;
  }

  .welcome-subtitle {
    font-size: 0.8rem;
    letter-spacing: 1.5px;
  }

  /* Foundation — Formularios */
  form {
    padding: 1.5rem;
  }

  fieldset {
    padding: 1rem;
  }

  .form-grid,
  .diameters-grid,
  .document-info {
    grid-template-columns: 1fr;
  }

  /* Foundation — Tipografía */
  h1 {
    font-size: 1.875rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  /* Foundation — Tablas */
  table {
    font-size: 0.875rem;
  }

  th,
  td {
    padding: 0.75rem;
  }

  /* Vista 2 — Medidas */
  .diameter-input-group {
    flex-wrap: wrap;
  }

  .diameter-input-group label {
    flex: 1 1 100%;
    min-width: unset;
    margin-bottom: 0.5rem;
  }

  .diameter-input-group button {
    flex: 0 1 auto;
  }

  .diameter-input-group input {
    flex: 1 1 50%;
  }

  /* Vista 5 — Detalle documento */
  .document-header {
    grid-template-columns: 1fr;
  }

  .document-actions {
    flex-direction: column;
  }

  #backButton {
    flex: 1;
  }
}

/* ── @media (min-width: 481px) ── */

@media (min-width: 481px) {

  /* Vista 4 — Historial: botones de acciones en fila */
  .history-actions {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    justify-content: center;
  }
}

/* ── @media (max-width: 480px) ── */

@media (max-width: 480px) {

  /* Foundation — Tipografía */
  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  /* Foundation — Formularios */
  section {
    padding: 0.75rem;
  }

  form {
    padding: 1rem;
  }

  fieldset {
    padding: 0.75rem;
  }

  legend {
    font-size: 1rem;
  }

  /* Foundation — Tablas */
  table {
    font-size: 0.75rem;
  }

  th,
  td {
    padding: 0.5rem;
  }

  /* Vista 1 — Bienvenida */
  #welcome-view h1 {
    font-size: 2rem;
  }

  #welcome-view h2 {
    font-size: 1rem;
    margin-bottom: 2rem;
  }

  .welcome-logo {
    font-size: 2.5rem;
  }

  /* Vista 4 — Historial: filtros apilados y botones columna */
  .history-filters {
    flex-direction: column;
  }

  .history-filter-group {
    min-width: 100%;
  }

  .history-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: center;
  }

  .history-actions .btn-view,
  .history-actions .btn-pdf {
    width: 100%;
    font-size: 0.8rem;
    padding: 0.4rem 0.25rem;
  }

  /* Vista 5 — Detalle documento */
  .document-header,
  .document-info {
    padding: 1rem;
  }

  .document-header div,
  .info-column div {
    font-size: 0.9rem;
  }
}