/* Reset y Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout Principal */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: #0f172a;
  margin-top: 0;
}

p {
  margin-top: 0;
}

.app-header {
  padding: 1.5rem 1.5rem 0.5rem;
  color: #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.logout-button,
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid rgba(100, 116, 139, 0.4);
  background: #ffffff;
  color: #334155;
}

.logout-button:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.4);
  color: #dc2626;
}

.back-button:hover {
  background: #e2e8f0;
  border-color: rgba(100, 116, 139, 0.5);
  color: #1d4ed8;
}

.status-bar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.75rem;
  justify-content: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: #f1f5f9;
  border: 1px solid rgba(100, 116, 139, 0.4);
  color: #334155;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #38bdf8, #1d4ed8);
  color: #e5e7eb;
  font-weight: 700;
  font-size: 0.95rem;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.25rem;
  color: #0f172a;
}

.brand-text p {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: #64748b;
}

/* Main Content */
.app-main {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
}

/* Orb Container */
.orb-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #1e293b;
  padding: 1rem 0;
}

.orb {
  position: relative;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, #e2e8f0, #f8fafc 70%);
  box-shadow: 0 0 32px rgba(56, 189, 248, 0.3), 0 0 80px rgba(37, 99, 235, 0.2);
  animation: orbFloat 6s ease-in-out infinite;
  overflow: visible;
}

.orb-core {
  width: 190px;
  height: 190px;
  border-radius: 999px;
  background: radial-gradient(circle at 25% 25%, #ffffff, #e5e7eb 55%, #cbd5f5 80%);
  box-shadow: 0 0 24px rgba(148, 163, 184, 0.7), 0 0 40px rgba(148, 163, 184, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.orb-logo-wrapper {
  width: 88%;
  height: 88%;
  border-radius: 999px;
  overflow: hidden;
}

.orb-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.orb-ring {
  position: absolute;
  border-radius: 999px;
  border: 1px solid rgba(191, 219, 254, 0.4);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.6);
}

.orb-ring-1 {
  width: 230px;
  height: 230px;
  animation: orbRingSpin 18s linear infinite;
}

.orb-ring-2 {
  width: 190px;
  height: 190px;
  border-color: rgba(129, 140, 248, 0.6);
  animation: orbRingSpinReverse 22s linear infinite;
}

.orb-pulse {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.35), transparent 70%);
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.orb-status {
  margin-top: 1.6rem;
  max-width: 340px;
  font-size: 1.05rem;
  color: #64748b;
  text-shadow: none;
}

.orb.typing .orb-core {
  animation: orbCorePulse 0.7s ease-in-out infinite;
}

.orb.typing .orb-pulse {
  opacity: 1;
  animation: orbPulse 1.2s ease-out infinite;
}

.orb.result-found {
  box-shadow: 0 0 40px rgba(74, 222, 128, 0.7), 0 0 80px rgba(34, 197, 94, 0.5);
}

.orb.no-result {
  box-shadow: 0 0 36px rgba(148, 163, 184, 0.7), 0 0 76px rgba(148, 163, 184, 0.5);
}

/* Search Card */
.search-card {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 1rem;
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #64748b;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper input[type="text"] {
  width: 100%;
  padding: 0.75rem 0.9rem 0.75rem 2.5rem;
  border-radius: 999px;
  border: 1px solid rgba(100, 116, 139, 0.4);
  background: #f8fafc;
  color: #0f172a;
  outline: none;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.search-input-wrapper input[type="text"]::placeholder {
  color: #94a3b8;
}

.search-input-wrapper input[type="text"]:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
  background: #ffffff;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  font-size: 0.95rem;
  color: #6b7280;
}

.search-helper {
  margin: 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* Results */
.results {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto 2rem;
  background: #ffffff;
  border-radius: 1rem;
  padding: 0.75rem 1rem 1rem;
  border: 1px solid rgba(100, 116, 139, 0.2);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  color: #0f172a;
}

.results-placeholder {
  padding: 0.75rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.result-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.result-link:hover {
  transform: translateX(4px);
  opacity: 0.95;
}

.result {
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid rgba(100, 116, 139, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.result-link:hover .result {
  background-color: rgba(59, 130, 246, 0.06);
  border-radius: 0.5rem;
}

.result:last-child {
  border-bottom: none;
}

.result-action {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #1d4ed8;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.result-link:hover .result-action {
  opacity: 1;
}

.result-title {
  font-weight: 600;
  font-size: 0.98rem;
}

.result-meta {
  font-size: 0.8rem;
  color: #64748b;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.3);
  margin-top: 0.2rem;
}

.no-results {
  padding: 0.75rem;
  font-size: 0.85rem;
  color: #64748b;
}

.error-message {
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #dc2626;
  font-size: 0.85rem;
}

.app-footer {
  padding: 0.75rem 1.5rem 1.25rem;
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 60%, #60a5fa 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.login-box {
  background: #ffffff;
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.login-logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 1rem;
  display: block;
  border-radius: 50%;
  object-fit: contain;
}

.login-box h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #0f172a;
}

.subtitle {
  color: #64748b;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* Alerts */
.alert {
  padding: 0.75rem;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.alert-error {
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #dc2626;
}

.alert-success {
  background: rgba(22, 163, 74, 0.08);
  border: 1px solid rgba(22, 163, 74, 0.4);
  color: #15803d;
}

/* Forms */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 600;
  color: #334155;
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.75rem;
  border: 1px solid rgba(100, 116, 139, 0.4);
  border-radius: 0.7rem;
  font-size: 0.95rem;
  background: #f8fafc;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input::placeholder,
.form-group select::placeholder,
.form-group textarea::placeholder {
  color: #94a3b8;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
  background: #ffffff;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
  box-shadow: 0 4px 10px -2px rgba(29, 78, 216, 0.4);
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid rgba(100, 116, 139, 0.35);
  box-shadow: none;
}

.btn-secondary:hover {
  background: #e2e8f0;
  border-color: rgba(100, 116, 139, 0.5);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

.btn-success {
  background: linear-gradient(135deg, #15803d, #22c55e);
  color: #fff;
  box-shadow: 0 4px 10px -2px rgba(21, 128, 61, 0.35);
}

.btn-success:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-success:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: linear-gradient(135deg, #1d4ed8, #38bdf8);
  filter: grayscale(0.3);
}

.btn-disabled:hover {
  filter: grayscale(0.3);
  transform: none;
}

.btn-disabled:active {
  transform: none;
}

/* Modal de Notificación */
.error-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.error-modal.show {
  display: flex;
}

.error-modal-content {
  background: #ffffff;
  border-radius: 1.5rem;
  padding: 2.5rem;
  max-width: 500px;
  width: 90%;
  border: 2px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08);
  animation: slideIn 0.3s ease-out;
}

.error-modal-content.success {
  border-color: rgba(22, 163, 74, 0.3);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.error-modal-content.error {
  border-color: rgba(220, 38, 38, 0.3);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.error-modal-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  text-align: center;
  animation: iconBounce 0.6s ease-out;
}

.error-modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  text-align: center;
}

.error-modal-content.success .error-modal-title {
  color: #15803d;
}

.error-modal-content.error .error-modal-title {
  color: #dc2626;
}

.error-modal-message {
  font-size: 0.95rem;
  color: #334155;
  margin-bottom: 2rem;
  text-align: center;
  line-height: 1.6;
}

.error-modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.error-modal-btn {
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.error-modal-btn-primary {
  background: linear-gradient(135deg, #1d4ed8, #38bdf8);
  color: #e5e7eb;
  box-shadow: 0 10px 15px -3px rgba(30, 64, 175, 0.8);
}

.error-modal-btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.error-modal-btn-secondary {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.error-modal-btn-secondary:hover {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.5);
}

@keyframes iconBounce {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

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

@keyframes iconBounce {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

/* Container */
.container {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 0.75rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: #ffffff;
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 50%;
}

.header h1 {
  color: #0f172a;
  font-size: 1.25rem;
  margin: 0;
  font-weight: 600;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #64748b;
  font-size: 0.9rem;
}

/* Main Content */
.main-content {
  background: #ffffff;
  border-radius: 1rem;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(100, 116, 139, 0.2);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Zona Info */
.zona-info {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #60a5fa 100%);
  color: #e5e7eb;
  padding: 1.5rem;
  border-radius: 1rem 1rem 0 0;
  margin: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.zona-info h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  margin-top: 0;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
}

.zona-info p {
  margin: 0;
  opacity: 0.95;
  font-size: 0.95rem;
}

.zona-tiempo {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tiempo-label {
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.95;
}

.tiempo-valor {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1.25rem;
  border-radius: 0.75rem;
  min-width: 120px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tiempo-valor.warning {
  background: rgba(251, 146, 60, 0.3);
  color: #fed7aa;
}

.tiempo-valor.critical {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
  animation: tiempoAlerta 1s infinite;
}

@keyframes tiempoAlerta {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* Preguntas Section */
.preguntas-section {
  border: none;
  border-radius: 0;
  padding: 1.5rem;
  margin: 0;
  background: transparent;
  flex: 1;
  overflow-y: auto;
}

.preguntas-section legend {
  font-size: 1.1rem;
  font-weight: 600;
  color: #334155;
  padding: 0 0 1rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(100, 116, 139, 0.2);
  width: 100%;
}

/* Formulario Ronda */
.formulario-ronda {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.formulario-ronda .form-group {
  margin-bottom: 1.25rem;
}

.formulario-ronda button[type="submit"] {
  margin: 0 1.5rem 1.5rem 1.5rem;
  margin-top: auto;
  flex-shrink: 0;
}

/* QR Scanner */
.qr-scanner {
  text-align: center;
  padding: 2rem;
}

.qr-scanner h2 {
  color: #0f172a;
  margin-bottom: 0.75rem;
}

.qr-scanner p {
  color: #64748b;
  margin-bottom: 2rem;
}

.qr-input {
  width: 100%;
  max-width: 400px;
  padding: 0.75rem;
  border: 2px solid rgba(100, 116, 139, 0.4);
  border-radius: 0.7rem;
  font-size: 0.95rem;
  text-align: center;
  background: #f8fafc;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s ease;
}

.qr-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
}

/* Status Box */
.status-box {
  background: #f8fafc;
  border-left: 4px solid #3b82f6;
  padding: 15px;
  margin-bottom: 20px;
  border-radius: 5px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(100, 116, 139, 0.15);
  color: #0f172a;
  font-size: 0.95rem;
}

.status-item:last-child {
  border-bottom: none;
}

.status-label {
  color: #334155;
  font-weight: 600;
}

.status-value {
  color: #0f172a;
  font-family: monospace;
  font-size: 0.9rem;
}

.status-value.success {
  color: #15803d;
}

.status-value.error {
  color: #dc2626;
}

.status-value.info {
  color: #1d4ed8;
}

/* Button Group */
.button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 30px;
}

.button-group:has(.btn:only-child) {
  grid-template-columns: 1fr;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1rem 0;
  color: #94a3b8;
  font-size: 0.85rem;
}

/* Responsive */
@media (min-width: 641px) {
  .container {
    max-width: 600px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0.5rem;
    max-width: 100%;
  }

  .app-main {
    padding: 0.75rem;
  }

  .header {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    flex-direction: row;
    align-items: center;
  }

  .header-logo {
    width: 35px;
    height: 35px;
  }

  .header h1 {
    font-size: 1.1rem;
  }

  .user-info {
    font-size: 0.85rem;
  }

  .user-info span {
    display: none;
  }

  .main-content {
    padding: 0;
    border-radius: 0.75rem;
  }

  .zona-info {
    padding: 1.25rem;
    margin: 0;
    border-radius: 0.75rem 0.75rem 0 0;
  }

  .zona-info h2 {
    font-size: 1.5rem;
  }

  .zona-info p {
    font-size: 0.9rem;
  }

  .zona-tiempo {
    margin-top: 1rem;
    padding-top: 1rem;
  }

  .tiempo-label {
    font-size: 0.9rem;
  }

  .tiempo-valor {
    font-size: 1.75rem;
    padding: 0.4rem 1rem;
    min-width: 100px;
  }

  .preguntas-section {
    padding: 1rem;
  }

  .preguntas-section legend {
    font-size: 1rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .formulario-ronda .form-group {
    margin-bottom: 1rem;
  }

  .formulario-ronda button[type="submit"] {
    margin: 0 1rem 1rem 1rem;
  }

  .login-box {
    padding: 1.5rem;
  }

  .btn {
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
  }

  .btn-small {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
  }
}

/* Animations */
@keyframes orbFloat {

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

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

@keyframes orbCorePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 35px rgba(56, 189, 248, 0.9), 0 0 70px rgba(59, 130, 246, 0.7);
  }

  50% {
    transform: scale(1.05);
    box-shadow: 0 0 45px rgba(56, 189, 248, 1), 0 0 90px rgba(96, 165, 250, 0.9);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 35px rgba(56, 189, 248, 0.9), 0 0 70px rgba(59, 130, 246, 0.7);
  }
}

@keyframes orbRingSpin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes orbRingSpinReverse {
  0% {
    transform: rotate(360deg);
  }

  100% {
    transform: rotate(0deg);
  }
}

@keyframes orbPulse {
  0% {
    opacity: 0.8;
    transform: scale(0.9);
  }

  100% {
    opacity: 0;
    transform: scale(1.2);
  }
}

/* Modal Overlay y Contenido */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #1e293b;
  padding: 2rem;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: #94a3b8;
  cursor: pointer;
}

.modal-close:hover {
  color: #334155;
}

/* Botones en grupo */
.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

/* Badges adicionales */
.badge-success {
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.35);
}

.badge-danger {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

/* Tabla */
.table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border-radius: 0.75rem;
  overflow: hidden;
}

.table thead {
  background: #f1f5f9;
}

.table th {
  padding: 1rem;
  text-align: left;
  color: #334155;
  font-weight: 600;
  font-size: 0.9rem;
}

.table td {
  padding: 0.75rem 1rem;
  color: #0f172a;
  border-top: 1px solid rgba(100, 116, 139, 0.15);
}

.table tbody tr:hover {
  background: rgba(59, 130, 246, 0.04);
}

/* Clases auxiliares */
.inline-form {
  display: inline;
}

.hidden {
  display: none;
}

.password-optional {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: normal;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  box-shadow: none;
}

.btn-danger:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}

/* ========================================
   ESTILOS PARA PÁGINAS ADMIN
   ======================================== */

/* Detalle de Vigía */
.vigia-detalle-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.vigia-profile {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  border-radius: 1rem;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.vigia-profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.vigia-profile-info {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.vigia-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #e5e7eb;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.vigia-profile-details h1 {
  font-size: 2rem;
  color: #e5e7eb;
  margin: 0 0 0.5rem 0;
}

.vigia-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
}

.vigia-status.active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.vigia-status.inactive {
  background: rgba(239, 68, 68, 0.2);
  color: #fff;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

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

.stat-card {
  background: #ffffff;
  border: 1px solid rgba(100, 116, 139, 0.2);
  border-radius: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

.stat-card h3 {
  font-size: 2.5rem;
  color: #3b82f6;
  margin: 0 0 0.5rem 0;
  font-weight: 700;
}

.stat-card p {
  font-size: 0.9rem;
  color: #64748b;
  margin: 0;
}

.stat-card.success h3 {
  color: #16a34a;
}

.stat-card.warning h3 {
  color: #d97706;
}

.stat-card.info h3 {
  color: #1d4ed8;
}

.stat-card.neutral h3 {
  color: #64748b;
}

.section-title {
  font-size: 1.5rem;
  color: #0f172a;
  margin: 2rem 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid rgba(59, 130, 246, 0.3);
}

.registros-table-wrapper {
  background: #ffffff;
  border-radius: 0.75rem;
  border: 1px solid rgba(100, 116, 139, 0.2);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

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

.registros-table thead {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
}

.registros-table th {
  padding: 1rem 1.5rem;
  text-align: left;
  color: #e5e7eb;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 2px solid rgba(59, 130, 246, 0.5);
}

.registros-table td {
  padding: 1rem 1.5rem;
  color: #0f172a;
  border-bottom: 1px solid rgba(100, 116, 139, 0.12);
  font-size: 0.9rem;
  background: #ffffff;
}

.registros-table tbody tr:hover td {
  background: rgba(59, 130, 246, 0.04);
}

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

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #94a3b8;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Gestión de Vigías */
.vigias-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.vigias-table-wrapper {
  background: #ffffff;
  border-radius: 0.75rem;
  border: 1px solid rgba(100, 116, 139, 0.2);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

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

.vigias-table thead {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
}

.vigias-table th {
  padding: 1rem 1.5rem;
  text-align: left;
  color: #e5e7eb;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 2px solid rgba(59, 130, 246, 0.5);
}

.vigias-table td {
  padding: 1rem 1.5rem;
  color: #0f172a;
  border-bottom: 1px solid rgba(100, 116, 139, 0.12);
  font-size: 0.9rem;
  background: #ffffff;
}

.vigias-table tbody tr:hover td {
  background: rgba(59, 130, 246, 0.04);
}

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

/* Responsive para páginas admin */
@media (max-width: 768px) {

  .vigia-detalle-container,
  .vigias-container {
    padding: 1rem;
  }

  .vigia-profile {
    padding: 1.5rem;
  }

  .vigia-avatar {
    width: 60px;
    height: 60px;
    font-size: 2rem;
  }

  .vigia-profile-details h1 {
    font-size: 1.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .registros-table,
  .vigias-table {
    font-size: 0.85rem;
  }

  .registros-table th,
  .registros-table td,
  .vigias-table th,
  .vigias-table td {
    padding: 0.75rem 0.5rem;
  }
}

/* Estilos de botones en grupo */
.btn-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-group .btn,
.btn-group form {
  margin: 0;
}

.btn-group form button {
  white-space: nowrap;
}

/* Estilos del Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #ffffff;
  padding: 2rem;
  border-radius: 1rem;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(100, 116, 139, 0.2);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(100, 116, 139, 0.2);
}

.modal-header h2 {
  font-size: 1.5rem;
  color: #0f172a;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #334155;
}

.form-modal {
  margin: 0;
}

.form-modal h3 {
  display: none;
}

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

.modal-content .form-group {
  margin-bottom: 0;
}

.modal-content .form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: #334155;
  font-weight: 500;
  font-size: 0.9rem;
}

.modal-content .form-group input {
  width: 100%;
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px solid rgba(100, 116, 139, 0.4);
  border-radius: 0.5rem;
  color: #0f172a;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-content .form-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(100, 116, 139, 0.15);
}

/* Responsive adicional para modales */
@media (max-width: 768px) {
  .btn-group {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-group .btn {
    width: 100%;
  }
}

/* Header adicional para páginas admin */
.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-left img {
  width: 40px;
  height: 40px;
}


/* ========================================
   RESPONSIVE MÓVIL - MEJORAS COMPLETAS
   ======================================== */

/* --- BASE MÓVIL (≤ 480px) --- */
@media (max-width: 480px) {

  /* Login */
  .login-page {
    align-items: flex-start;
    padding-top: 2rem;
    background: linear-gradient(160deg, #1e40af 0%, #3b82f6 60%, #60a5fa 100%);
  }

  .login-container {
    padding: 1rem;
    max-width: 100%;
  }

  .login-box {
    padding: 1.5rem 1.25rem;
    border-radius: 1rem;
  }

  .login-logo {
    width: 52px;
    height: 52px;
  }

  .login-box h1 {
    font-size: 1.3rem;
    text-align: center;
  }

  .subtitle {
    text-align: center;
    font-size: 0.85rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 1rem;
    /* evita zoom en iOS */
    padding: 0.8rem;
  }

  .btn {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1rem;
  }

  /* Header vigia / admin */
  .header {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    flex-wrap: nowrap;
  }

  .header h1 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  .header-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  .user-info {
    gap: 0.5rem;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  /* Ocultar nombre en header en pantallas muy pequeñas */
  .user-info>span:first-child {
    display: none;
  }

  .btn-small {
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* Container vigia */
  .container {
    padding: 0.5rem;
  }

  /* Zona info (registro) */
  .zona-info {
    padding: 1rem 1rem;
    border-radius: 0.75rem 0.75rem 0 0;
  }

  .zona-info h2 {
    font-size: 1.25rem;
    line-height: 1.3;
  }

  .zona-info p {
    font-size: 0.85rem;
  }

  .zona-tiempo {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
  }

  .tiempo-label {
    font-size: 0.85rem;
  }

  .tiempo-valor {
    font-size: 1.5rem;
    padding: 0.35rem 0.75rem;
    min-width: 80px;
  }

  /* Preguntas */
  .preguntas-section {
    padding: 0.75rem;
  }

  .preguntas-section legend {
    font-size: 0.95rem;
  }

  .formulario-ronda button[type="submit"] {
    margin: 0 0.75rem 0.75rem 0.75rem;
    width: calc(100% - 1.5rem);
  }

  /* Dashboard vigia - container-simple */
  .container-simple {
    padding: 0.75rem;
  }

  /* Secciones del dashboard vigia */
  .section {
    padding: 1.25rem 1rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
  }

  .section-title {
    font-size: 1rem;
    margin-bottom: 1rem;
  }

  .zona-item {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .zona-nombre {
    font-size: 0.9rem;
  }

  /* Botón escanear QR - full width */
  .section .btn {
    font-size: 1rem;
    padding: 0.9rem 1rem;
  }

  /* Modal scanner */
  #scanner-modal>div {
    padding: 0.75rem !important;
  }

  #scanner-modal h2 {
    font-size: 1.1rem !important;
  }

  /* Admin dashboard */
  .container {
    padding: 0.5rem;
  }

  /* Stats admin */
  .stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    margin-bottom: 1rem !important;
  }

  .stat {
    padding: 0.9rem 0.75rem !important;
  }

  .stat-value {
    font-size: 1.5rem !important;
  }

  .stat-label {
    font-size: 0.75rem !important;
  }

  /* Leyenda admin */
  .leyenda {
    padding: 0.75rem !important;
    gap: 0.5rem !important;
    margin-bottom: 1rem !important;
    justify-content: flex-start !important;
  }

  .leyenda-item {
    font-size: 0.78rem !important;
  }

  /* Filtros admin */
  .filters {
    padding: 1rem !important;
    margin-bottom: 1rem !important;
  }

  .filters-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }

  .filter-item input,
  .filter-item select {
    font-size: 1rem;
    /* evita zoom iOS */
    padding: 0.7rem !important;
  }

  .actions {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .actions .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Tarjetas vigia admin */
  .vigia-card {
    padding: 1rem !important;
    margin-bottom: 0.75rem !important;
    border-radius: 0.75rem !important;
  }

  .vigia-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
    margin-bottom: 0.75rem !important;
  }

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

  .vigia-meta {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.25rem !important;
  }

  .vigia-name {
    font-size: 1rem !important;
  }

  /* Zonas grid admin */
  .zones {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)) !important;
    gap: 0.3rem !important;
  }

  .zone {
    padding: 0.5rem 0.25rem !important;
    min-height: 68px !important;
  }

  .zone-name {
    font-size: 0.62rem !important;
  }

  .zone-time {
    font-size: 0.58rem !important;
  }

  /* Sede labels */
  .sede-label {
    font-size: 0.7rem !important;
    padding: 0.2rem 0.5rem !important;
  }

  .sede-progress-text {
    font-size: 0.75rem !important;
  }

  /* Header admin */
  .header-actions {
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .header-actions .btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
    width: auto;
  }

  .header-actions span {
    display: none;
    /* ocultar nombre admin en móvil */
  }

  /* Tablas admin - scroll horizontal */
  .registros-table-wrapper,
  .vigias-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .registros-table,
  .vigias-table,
  .table {
    min-width: 500px;
  }

  /* Detalle vigia */
  .vigia-detalle-container,
  .vigias-container {
    padding: 0.75rem !important;
  }

  .vigia-profile {
    padding: 1rem !important;
    border-radius: 0.75rem !important;
  }

  .vigia-profile-header {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  .vigia-profile-info {
    gap: 0.75rem !important;
  }

  .vigia-avatar {
    width: 52px !important;
    height: 52px !important;
    font-size: 1.75rem !important;
  }

  .vigia-profile-details h1 {
    font-size: 1.25rem !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  .stat-card {
    padding: 1rem 0.75rem !important;
  }

  .stat-card h3 {
    font-size: 1.75rem !important;
  }

  /* Modal */
  .error-modal-content {
    padding: 1.5rem 1.25rem;
    border-radius: 1rem;
    width: 92%;
  }

  .error-modal-icon {
    font-size: 2.5rem;
  }

  .error-modal-title {
    font-size: 1.15rem;
  }

  .error-modal-message {
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
  }

  .error-modal-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .error-modal-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: center;
  }

  /* Modal zona/vigia */
  .modal-content {
    padding: 1.25rem 1rem;
    border-radius: 0.75rem;
    width: 95%;
  }

  .modal-header h2 {
    font-size: 1.15rem;
  }

  .modal-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

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

  /* Btn group en tablas */
  .btn-group {
    flex-direction: column;
    gap: 0.4rem;
  }

  .btn-group .btn,
  .btn-group form button {
    width: 100%;
    justify-content: center;
  }

  /* App header (scan page) */
  .app-header {
    padding: 1rem 1rem 0.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .brand-text h1 {
    font-size: 1.1rem;
  }

  .brand-text p {
    font-size: 0.78rem;
  }

  .orb {
    width: 200px;
    height: 200px;
  }

  .orb-core {
    width: 135px;
    height: 135px;
  }

  .orb-ring-1 {
    width: 165px;
    height: 165px;
  }

  .orb-ring-2 {
    width: 135px;
    height: 135px;
  }

  .orb-pulse {
    width: 230px;
    height: 230px;
  }

  .orb-status {
    font-size: 0.9rem;
    margin-top: 1rem;
  }

  .search-card {
    padding: 1rem;
    border-radius: 0.75rem;
  }

  .search-input-wrapper input[type="text"] {
    font-size: 1rem;
    /* evita zoom iOS */
  }

  .results {
    padding: 0.5rem 0.75rem 0.75rem;
    border-radius: 0.75rem;
  }

  /* Reportes avanzados */
  .section-title {
    font-size: 1.1rem;
  }
}

/* --- TABLET (481px – 768px) --- */
@media (min-width: 481px) and (max-width: 768px) {

  .login-container {
    max-width: 420px;
    padding: 1.25rem;
  }

  .container {
    padding: 0.75rem;
  }

  .container-simple {
    padding: 1rem;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .filters-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .actions {
    flex-wrap: wrap;
  }

  .zones {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)) !important;
  }

  .vigia-header {
    flex-wrap: wrap;
  }

  .header-actions .btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
  }

  .header-actions span {
    font-size: 0.82rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .registros-table-wrapper,
  .vigias-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .registros-table,
  .vigias-table,
  .table {
    min-width: 480px;
  }
}

/* Asegurar que inputs no hagan zoom en iOS en todos los tamaños */
@media (max-width: 768px) {

  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="date"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ============================================
   LAYOUT CON SIDEBAR - PANEL ADMINISTRACIÓN
   ============================================ */
:root {
  --primary: #4f46e5;
  --primary-light: rgba(79, 70, 229, 0.1);
  --primary-dark: #3730a3;
  --surface: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --bg-app: #f8fafc;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --info: #3b82f6;
  --info-light: #eff6ff;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-app);
  font-family: var(--font-family);
}

/* --- SIDEBAR --- */
.sidebar {
  width: 280px;
  background-color: #ffffff;
  color: #1e293b;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 100;
  border-right: 1px solid #e2e8f0;
  box-shadow: 2px 0 8px rgba(0,0,0,0.03);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 1.5rem;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #cbd5e1;
}

.sidebar-brand-text {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
  display: block;
}

.sidebar-brand-sub {
  font-size: 0.65rem;
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: #64748b;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.sidebar-item:hover {
  background-color: #f8fafc;
  color: #1e293b;
  transform: translateX(2px);
}

.sidebar-item.active {
  background-color: #eff6ff;
  color: #2563eb;
  font-weight: 700;
}

.sidebar-item ion-icon {
  font-size: 1.25rem;
}

.sidebar-footer {
  border-top: 1px solid #f1f5f9;
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  background-color: #eff6ff;
  color: #2563eb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid #dbeafe;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem;
  background-color: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.sidebar-logout-btn:hover {
  background-color: #fecaca;
  color: #b91c1c;
}

/* --- CONTENIDO PRINCIPAL --- */
.main-content {
  margin-left: 280px;
  flex: 1;
  padding: 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  min-width: 0;
}

.page-header-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.025em;
  margin: 0;
}

/* --- RESPONSIVE SIDEBAR --- */
@media (max-width: 992px) {
  .sidebar {
    width: 70px;
    padding: 1rem 0.5rem;
    align-items: center;
  }
  .sidebar-brand-text,
  .sidebar-brand-sub,
  .sidebar-item span,
  .sidebar-user-info,
  .sidebar-logout-btn span {
    display: none;
  }
  .sidebar-logo { width: 32px; height: 32px; }
  .sidebar-brand { padding-bottom: 1rem; border-bottom: none; margin-bottom: 1rem; }
  .sidebar-item { justify-content: center; padding: 0.75rem; }
  .sidebar-user { justify-content: center; }
  .main-content { margin-left: 70px; padding: 1.5rem; }
}

@media (max-width: 768px) {
  .main-content {
    padding: 1.5rem 1rem;
  }
}