* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, sans-serif; }
body { background-color: #f1f5f9; color: #334155; padding-bottom: 40px; }
header { background: #0f172a; color: white; padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.badge-role { background: #2563eb; font-size: 0.75rem; padding: 0.25rem 0.6rem; border-radius: 999px; text-transform: uppercase; font-weight: bold; border: none; color: white; cursor: pointer; transition: background 0.15s; }
.badge-role:hover { background: #1d4ed8; }
.user-menu { position: relative; }
.dropdown-menu { display: none; flex-direction: column; position: absolute; top: calc(100% + 0.5rem); right: 0; background: white; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); overflow: hidden; min-width: 180px; z-index: 10; }
.dropdown-menu.open { display: flex; }
.dropdown-menu button { background: none; border: none; text-align: left; padding: 0.75rem 1rem; font-size: 0.875rem; color: #334155; cursor: pointer; text-transform: none; font-weight: 500; }
.dropdown-menu button:hover { background: #f1f5f9; }
.dropdown-menu button.dropdown-danger { color: #dc2626; }
.dropdown-menu button.dropdown-danger:hover { background: #fef2f2; }
.container { max-width: 900px; margin: 1.5rem auto; padding: 0 1rem; }
.card { background: white; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.card h2 { font-size: 1.1rem; color: #0f172a; margin-bottom: 1rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 0.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.35rem; }
.form-group input, .form-group select { width: 100%; padding: 0.65rem; border: 1px solid #cbd5e1; border-radius: 6px; }
.btn { background: #2563eb; color: white; border: none; padding: 0.75rem 1.25rem; font-weight: 600; border-radius: 6px; cursor: pointer; width: 100%; }
.btn-secondary { background: #64748b; }
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); justify-content: center; align-items: center; padding: 1rem; }
.modal-content { background: white; padding: 2rem; border-radius: 12px; text-align: center; max-width: 400px; width: 90%; max-height: 90vh; max-height: 90dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 0.875rem; }
th { background: #f8fafc; }
.badge-status { padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: bold; }
.status-pendiente { background: #fef3c7; color: #92400e; }
.status-completado { background: #dcfce7; color: #166534; }
.status-cancelado { background: #fee2e2; color: #991b1b; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.25rem; color: #0f172a; margin-bottom: 0.25rem; text-align: center; }
.login-card p.login-subtitle { text-align: center; color: #64748b; font-size: 0.875rem; margin-bottom: 1.5rem; }
.login-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; border-radius: 6px; padding: 0.6rem 0.75rem; font-size: 0.85rem; margin-bottom: 1rem; display: none; }
.login-error.visible { display: block; }
.login-demo { margin-top: 1.25rem; font-size: 0.75rem; color: #94a3b8; text-align: center; line-height: 1.5; }

/* Guardia: escáner y panel de validación */
.hint-text { font-size: 0.875rem; color: #64748b; margin-bottom: 1rem; }
#reader { border-radius: 8px; overflow: hidden; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.info-grid > div { display: flex; flex-direction: column; gap: 0.2rem; }
.info-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: #64748b; }
.info-foto { margin-bottom: 1.25rem; }
.info-foto img { max-width: 100%; max-height: 220px; border-radius: 8px; margin-top: 0.4rem; display: block; border: 1px solid #e2e8f0; }
@media (max-width: 480px) { .info-grid { grid-template-columns: 1fr; } }

/* Administrador: dashboard y gestión de usuarios */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1.25rem 0.5rem; margin-bottom: 0; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: #0f172a; }
.stat-label { font-size: 0.75rem; color: #64748b; margin-top: 0.25rem; text-transform: uppercase; font-weight: 600; }
@media (max-width: 640px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.card-header-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 0.75rem; margin-bottom: 1rem; }
.filter-row { display: flex; align-items: center; gap: 0.5rem; }
.filter-row select { padding: 0.5rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.85rem; }

.btn-inline { width: auto; padding: 0.5rem 0.9rem; font-size: 0.8rem; }
.btn-danger { background: #dc2626; margin-left: 0.4rem; }

.evento-creacion { background: #dbeafe; color: #1e40af; }
.evento-lectura { background: #ede9fe; color: #5b21b6; }
.evento-completado { background: #dcfce7; color: #166534; }
.evento-mensaje { background: #d1fae5; color: #065f46; }
.evento-edicion { background: #fef3c7; color: #92400e; }
.evento-fallido { background: #fee2e2; color: #991b1b; }