:root {
	--bg: #f5f6f8;
	--surface: #ffffff;
	--border: #e2e5ea;
	--text: #1f2430;
	--muted: #6b7280;
	--primary: #2563eb;
	--primary-hover: #1d4ed8;
	/* Color por categoría (compartido por home, páginas de recurso y navbar). */
	--medico: #2563eb;
	--medico-hover: #1d4ed8;
	--insumo: #7c3aed;
	--insumo-hover: #6d28d9;
	--centro: #16a34a;
	--centro-hover: #15803d;
	--radius: 8px;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	background: var(--bg);
	color: var(--text);
	line-height: 1.5;
}

.container {
	max-width: 800px;
	margin: 0 auto;
	padding: 0 1.25rem;
}

/* Nav */
.nav {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

.nav-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	height: 60px;
}

.nav-brand {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-weight: 700;
	font-size: 1.15rem;
	color: var(--text);
	text-decoration: none;
}

/* Venezuelan flag icon: official flag (tricolor + arc of stars). */
.flag-ve {
	display: inline-block;
	width: 24px;
	height: 24px;
	flex-shrink: 0;
	border-radius: 7px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
	background-image: url("/static/flags/venezuela.svg");
	background-size: cover;
	background-position: center;
}

/* El texto de la marca se oculta en móvil (solo queda la bandera) para evitar
   que se solape con los enlaces; se muestra a partir de 600px. */
.nav-brand-text {
	display: none;
}

/* Título solo para móvil, fuera de la barra de navegación. */
.mobile-title {
	margin: 0;
	padding: 0.75rem 1rem;
	text-align: center;
	font-weight: 700;
	font-size: 1.1rem;
	color: var(--text);
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

.nav-links {
	display: flex;
	gap: 1rem;
}

.nav-links a {
	color: var(--muted);
	text-decoration: none;
	font-size: 0.95rem;
	font-weight: 600;
}

.nav-links a:hover {
	color: var(--primary);
}

/* Hover de cada enlace según el color de su categoría (igual que el home). */
.nav-links a[href="/medicos"]:hover {
	color: var(--medico);
}
.nav-links a[href="/centros"]:hover {
	color: var(--centro);
}
.nav-links a[href="/insumos"]:hover {
	color: var(--insumo);
}

/* Icono de X (Twitter): solo el logo, alineado con los enlaces. */
.nav-x {
	display: inline-flex;
	align-items: center;
}
.nav-x:hover {
	color: var(--text);
}

/* Banner de desaparecidos, justo bajo el navbar */
.banner-desaparecidos {
	background: #fef3c7;
	border-bottom: 1px solid #fcd34d;
	color: #78350f;
	font-size: 0.95rem;
	font-weight: 600;
	text-align: center;
	padding: 0.6rem 0;
}

.banner-desaparecidos a {
	color: #b45309;
	font-weight: 700;
	text-decoration: underline;
}

.banner-desaparecidos a:hover {
	color: #92400e;
}

/* Layout sections */
main.container {
	padding-top: 2rem;
	padding-bottom: 3rem;
}

/* Footer */
.footer {
	border-top: 1px solid var(--border);
	background: var(--surface);
	padding: 2rem 0;
	margin-top: 2rem;
}

.footer p {
	color: var(--muted);
	font-size: 0.9rem;
	margin: 0 0 0.75rem;
}

.footer p:last-child {
	margin-bottom: 0;
}

.footer strong {
	color: var(--text);
}

.hero h1 {
	margin: 0 0 0.25rem;
	font-size: 2rem;
}

.hero p {
	color: var(--muted);
	margin-top: 0;
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.5rem;
	margin-top: 1.5rem;
}

.card h2 {
	margin-top: 0;
}

/* Buttons */
.btn {
	display: inline-block;
	background: var(--primary);
	color: #fff;
	border: none;
	border-radius: var(--radius);
	padding: 0.6rem 1.1rem;
	font-size: 0.95rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease;
}

.btn:hover {
	background: var(--primary-hover);
}

.btn:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
}

/* Forms */
.form-group {
	margin-bottom: 1rem;
}

.form-group label {
	display: block;
	margin-bottom: 0.35rem;
	font-weight: 600;
	font-size: 0.9rem;
}

.form-group input,
.form-group select {
	width: 100%;
	padding: 0.55rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	font-size: 0.95rem;
	background: var(--bg);
}

.form-group input:focus,
.form-group select:focus {
	outline: none;
	border-color: var(--primary);
	background: var(--surface);
}

.message {
	margin-top: 1rem;
	color: var(--primary);
}

/* Home: stat counters */
.stats {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 1rem;
	margin-top: 2rem;
}

@media (min-width: 600px) {
	.stats {
		grid-template-columns: repeat(4, 1fr);
	}
	.nav-brand-text {
		display: inline;
	}
	.mobile-title {
		display: none;
	}
}

.stat {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.25rem;
}

.stat-num {
	font-size: 2rem;
	font-weight: 800;
	line-height: 1.1;
	color: var(--primary);
}

.stat-label {
	margin-top: 0.35rem;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--muted);
}

.stat-ok {
	background: #ecfdf5;
	border-color: #a7f3d0;
}

.stat-ok .stat-num {
	color: #059669;
}

.stat-need {
	background: #fef2f2;
	border-color: #fecaca;
}

.stat-need .stat-num {
	color: #dc2626;
}

.stat-blue {
	background: #eff6ff;
	border-color: #bfdbfe;
}

.stat-blue .stat-num {
	color: #2563eb;
}

.stat-click {
	cursor: pointer;
	transition: border-color 0.15s ease, transform 0.05s ease;
}

.stat-click:hover {
	border-color: var(--primary);
}

.stat-click:active {
	transform: scale(0.99);
}

.stat-click:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
}

/* Home: three big tappable module cards */
.home-acciones {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	margin-top: 2rem;
}

.home-card {
	display: flex;
	align-items: center;
	min-height: 64px;
	padding: 1.25rem 1.5rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	color: var(--text);
	text-decoration: none;
	font-size: 1.1rem;
	font-weight: 600;
	font-family: inherit;
	text-align: left;
	cursor: pointer;
}

.home-card:hover {
	border-color: var(--primary);
}

.home-card.active {
	border-color: var(--primary);
	box-shadow: inset 0 0 0 1px var(--primary);
}

.form-hint {
	display: block;
	margin-top: 0.25rem;
	color: var(--muted);
	font-size: 0.8rem;
}

.home-ayuda {
	margin-top: 2rem;
	color: var(--muted);
}

.home-lista-titulo {
	margin: 2rem 0 0.5rem;
	scroll-margin-top: 1rem;
}

.home-ver-mas {
	margin-top: 1.5rem;
	color: var(--muted);
	font-size: 0.9rem;
}

@media (min-width: 600px) {
	.home-acciones {
		flex-direction: row;
	}
	.home-card {
		flex: 1;
	}
}

/* Filter bar */
.filtros {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin: 1.25rem 0;
}

.filtros select {
	flex: 1;
	min-width: 160px;
	padding: 0.55rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	font-size: 0.95rem;
	background: var(--surface);
}

.filtros-acciones {
	flex-basis: 100%;
}

/* Sin filtros activos: ocultar el botón pero conservar su espacio (sin saltos). */
.filtros-acciones-oculto {
	visibility: hidden;
}

.filtros-limpiar {
	background: none;
	border: 1px solid var(--border);
	color: var(--muted);
	border-radius: var(--radius);
	padding: 0.45rem 0.9rem;
	font-size: 0.9rem;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.filtros-limpiar:hover {
	color: var(--text);
	border-color: var(--muted);
}

/* List items */
.lista-item {
	position: relative;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1rem;
	margin-top: 0.75rem;
}

.lista-item h3 {
	margin: 0 0 0.25rem;
	padding-right: 5rem;
}

/* Fecha en la esquina superior derecha (solo tarjetas de insumos). */
.lista-item-fecha {
	position: absolute;
	top: 0.75rem;
	right: 1rem;
	font-size: 0.75rem;
	color: var(--muted);
	white-space: nowrap;
}

.lista-item-fecha-entregado {
	color: #3730a3;
	font-weight: 600;
}

.lista-item .meta {
	color: var(--muted);
	font-size: 0.9rem;
	margin: 0 0 0.5rem;
}

.estado-flag {
	display: inline-block;
	width: 22px;
	height: auto;
	vertical-align: middle;
	border: 1px solid var(--border);
	border-radius: 2px;
	margin: 0 0.15rem;
}

.lista-item p {
	margin: 0.25rem 0;
}

.lista-item .btn {
	margin-top: 0.5rem;
}

.vacio {
	color: var(--muted);
}

/* Contact buttons (reuse .btn) */
.btn-wa {
	background: transparent;
	color: #1eb358;
	border: 1px solid #25d366;
}

.btn-wa:hover {
	background: #25d366;
	color: #fff;
}

.btn-tel {
	background: var(--primary);
}

.btn-sec {
	background: var(--border);
	color: var(--text);
}

.btn-sec:hover {
	background: #d3d8e0;
}

/* Paginación (← Anteriores / Página X de Y / Siguientes →) */
.paginacion {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin-top: 1.5rem;
}

/* Destino del scroll al cambiar de página (ver Paginador): deja un pequeño
   margen sobre el título para que no quede pegado al borde superior. */
.paginador-anchor {
	scroll-margin-top: 1.5rem;
}

.paginacion-info {
	color: var(--muted);
	font-size: 0.95rem;
	white-space: nowrap;
}

.paginacion .btn[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Tengo / necesito tag */
.etiqueta {
	display: inline-block;
	padding: 0.15rem 0.6rem;
	border-radius: var(--radius);
	font-size: 0.9rem;
	font-weight: 700;
	text-transform: uppercase;
	vertical-align: middle;
	margin-right: 0.4rem;
}

.etiqueta-tengo {
	background: #dcfce7;
	color: #166534;
}

.etiqueta-necesito {
	background: #fee2e2;
	color: #991b1b;
}

.etiqueta-entregado {
	background: #e0e7ff;
	color: #3730a3;
}

/* Modal (native <dialog>) */
.modal {
	width: min(94vw, 520px);
	max-height: 90vh;
	overflow: auto;
	border: none;
	border-radius: var(--radius);
	padding: 1.75rem 2.25rem;
	background: var(--surface);
	color: var(--text);
}

.modal::backdrop {
	background: rgba(0, 0, 0, 0.5);
}

.modal h2 {
	margin-top: 0;
}

.modal-acciones {
	display: flex;
	gap: 0.75rem;
	margin-top: 1rem;
}

.modal-acciones .btn {
	flex: 1;
	text-align: center;
}

.form-error {
	color: #b91c1c;
	margin: 0.5rem 0 0;
}

/* Home: big color-coded "add" buttons */
.home-cta {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.75rem;
	margin-top: 1.5rem;
}

@media (min-width: 600px) {
	.home-cta {
		grid-template-columns: repeat(3, 1fr);
	}
	/* La sección de médico va aparte y siempre a ancho completo (una columna). */
	.home-cta-medico {
		grid-template-columns: 1fr;
	}
}

/* Separa la sección de médico de la fila de insumos/centros. */
.home-cta-medico {
	margin-top: 0.75rem;
}

.btn-add {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-height: 60px;
	padding: 1rem 1.25rem;
	border: none;
	border-radius: var(--radius);
	color: #fff;
	font-size: 1.05rem;
	font-weight: 700;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s ease;
}

.btn-add-icon {
	font-size: 1.4rem;
	line-height: 1;
}

.btn-add-medico,
.btn-medico {
	background: var(--medico);
}
.btn-add-medico:hover,
.btn-medico:hover {
	background: var(--medico-hover);
}

.btn-add-insumo,
.btn-insumo {
	background: var(--insumo);
}
.btn-add-insumo:hover,
.btn-insumo:hover {
	background: var(--insumo-hover);
}

.btn-add-centro,
.btn-centro {
	background: var(--centro);
}
.btn-add-centro:hover,
.btn-centro:hover {
	background: var(--centro-hover);
}

/* Solicitar insumo (necesito) en rojo; ofrecer reusa el morado de insumos. */
.btn-add-solicitar {
	background: #dc2626;
}
.btn-add-solicitar:hover {
	background: #b91c1c;
}

/* Médico card: photo + action row */
.lista-item-head {
	display: flex;
	align-items: center;
	gap: 0.85rem;
}

.medico-foto {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	object-fit: cover;
	border: 1px solid var(--border);
	flex-shrink: 0;
}

.lista-item-acciones {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.5rem;
}

/* Tappable phone number — opens the dialer on mobile */
.tel-link {
	color: var(--primary);
	font-weight: 600;
	text-decoration: none;
}

.tel-link:hover {
	text-decoration: underline;
}

/* Historial de auditoría: filas de tres columnas (acción · mensaje · recurso),
   con separadores sutiles entre ítems. */
.audit-lista {
	list-style: none;
	margin: 1rem 0 0;
	padding: 0;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
}

.audit-item {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.6rem 1rem;
	border-bottom: 1px solid var(--border);
}

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

/* Columna izquierda: acción como pastilla de color. */
.audit-accion {
	flex: 0 0 6rem;
	align-self: flex-start;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: lowercase;
	text-align: center;
	padding: 0.15rem 0.5rem;
	border-radius: 4px;
	background: #fef3c7;
	color: #92400e;
}

.audit-accion.accion-create {
	background: #dcfce7;
	color: #166534;
}

.audit-accion.accion-update {
	background: #fef3c7;
	color: #92400e;
}

/* Columna central: mensaje, centrado como en la referencia. */
.audit-mensaje {
	flex: 1 1 auto;
	margin: 0;
	text-align: center;
}

/* Columna derecha: recurso + fecha, apilados y alineados a la derecha. */
.audit-meta {
	flex: 0 0 9rem;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	text-align: right;
}

.audit-recurso {
	color: var(--muted);
	font-size: 0.9rem;
	text-transform: capitalize;
}

.audit-fecha {
	color: var(--muted);
	font-size: 0.75rem;
	white-space: nowrap;
}
