/* IMDEJ · Quejas y Sugerencias — estilos institucionales */
:root {
    --guinda: #8B0000;
    --guinda-oscuro: #650000;
    --guinda-suave: #F6ECEC;
    --dorado: #D4AF37;
    --dorado-oscuro: #9C7F1E;
    --dorado-suave: #FAF4E1;
    --negro: #1A1A1A;
    --texto: #2B2B2B;
    --gris: #6B6B6B;
    --linea: #E4E2DF;
    --fondo: #FFFFFF;
    --fondo-alt: #F7F7F6;
    --ok: #1E7A46;
    --error: #B42318;
    --radio: 8px;
    --fuente: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--fuente);
    font-size: 16px;
    line-height: 1.55;
    color: var(--texto);
    background: var(--fondo);
}
a { color: var(--guinda); }
a:hover { color: var(--guinda-oscuro); }
:focus-visible { outline: 3px solid var(--dorado); outline-offset: 2px; }
img { max-width: 100%; }
h1, h2, h3 { color: var(--negro); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
.muted { color: var(--gris); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Encabezado institucional ---------- */
.franja {
    background: var(--guinda);
    color: #fff;
    border-bottom: 4px solid var(--dorado);
}
.franja-in {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.franja img.logo { height: 46px; width: auto; background: #fff; border-radius: 6px; padding: 3px; }
.franja .marca { line-height: 1.2; }
.franja .marca b { display: block; font-size: 1.05rem; font-weight: 800; }
.franja .marca span { font-size: .78rem; color: var(--dorado); font-weight: 600; }

/* ---------- Página pública ---------- */
.publico { max-width: 680px; margin: 0 auto; padding: 32px 20px 64px; }
.publico .intro { margin-bottom: 28px; }
.publico .intro p { margin: 0; color: var(--gris); max-width: 60ch; }

.bloque { border-top: 1px solid var(--linea); padding: 22px 0 6px; }
.bloque > h2 { margin-bottom: 14px; }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 18px; }
.campo label, .etq { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; color: var(--negro); }
.campo .ayuda { font-size: .82rem; color: var(--gris); margin-top: 4px; }
.req { color: var(--guinda); }
input[type=text], input[type=tel], input[type=email], input[type=password],
input[type=date], input[type=search], select, textarea {
    width: 100%;
    font: inherit;
    color: var(--texto);
    background: #fff;
    border: 1.5px solid #CFCCC8;
    border-radius: var(--radio);
    padding: 11px 12px;
    transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--guinda);
    box-shadow: 0 0 0 3px rgba(139, 0, 0, .12);
}
.campo.con-error input, .campo.con-error select, .campo.con-error textarea { border-color: var(--error); }
.campo .err { color: var(--error); font-size: .82rem; margin-top: 4px; }
.fila-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.campo label.check, .check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; font-weight: 400; color: var(--texto); }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--guinda); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.contador { float: right; font-weight: 500; color: var(--gris); font-size: .8rem; }

.btn {
    display: inline-block;
    font: inherit;
    font-weight: 700;
    border: 0;
    border-radius: var(--radio);
    padding: 12px 20px;
    cursor: pointer;
    text-decoration: none;
    background: var(--guinda);
    color: #fff;
    transition: background .15s;
}
.btn:hover { background: var(--guinda-oscuro); color: #fff; }
.btn-lg { width: 100%; padding: 15px; font-size: 1.05rem; }
.btn-sec { background: #fff; color: var(--guinda); border: 1.5px solid var(--guinda); }
.btn-sec:hover { background: var(--guinda-suave); color: var(--guinda-oscuro); }
.btn-dor { background: var(--dorado); color: var(--negro); }
.btn-dor:hover { background: var(--dorado-oscuro); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.btn-link { background: none; color: var(--guinda); padding: 0; text-decoration: underline; }
.btn-link:hover { background: none; color: var(--guinda-oscuro); }
.btn[disabled] { opacity: .6; cursor: wait; }

.aviso { padding: 12px 14px; border-radius: var(--radio); margin-bottom: 16px; font-size: .92rem; border-left: 4px solid; }
.aviso-ok { background: #EAF5EE; border-color: var(--ok); color: #14532D; }
.aviso-error { background: #FDECEC; border-color: var(--error); color: #7A1A12; }
.aviso-info { background: var(--dorado-suave); border-color: var(--dorado); color: #5C4A10; }

/* Folio de confirmación */
.folio-box { border: 2px solid var(--dorado); border-radius: var(--radio); padding: 24px; text-align: center; margin: 24px 0; }
.folio-box small { display: block; color: var(--gris); font-weight: 600; }
.folio-box strong { display: block; font-size: 2.2rem; font-weight: 800; color: var(--guinda); letter-spacing: .02em; }

.pie { text-align: center; font-size: .8rem; color: var(--gris); padding: 24px 20px; border-top: 1px solid var(--linea); }

/* =====================================================================
   Formulario público (pasos)
   ===================================================================== */
.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; }

.qs-hero { margin-bottom: 30px; }
.qs-hero h1 { font-size: 2.1rem; margin-bottom: .35em; }
.qs-hero > p { margin: 0 0 16px; color: var(--gris); max-width: 58ch; font-size: 1.02rem; }
.qs-garantias { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; }
.qs-garantias li { position: relative; padding-left: 24px; font-size: .9rem; font-weight: 600; color: var(--texto); }
.qs-garantias li::before {
    content: ''; position: absolute; left: 0; top: .2em; width: 16px; height: 16px; border-radius: 50%;
    background: var(--dorado-suave); border: 1.5px solid var(--dorado);
}
.qs-garantias li::after {
    content: ''; position: absolute; left: 5.5px; top: calc(.2em + 3.5px); width: 4px; height: 7px;
    border: solid var(--dorado-oscuro); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.qs-folio-link { margin: 0; font-size: .9rem; color: var(--gris); }
.qs-folio-link a { font-weight: 700; }

.qs-resumen ul { margin: 6px 0 0; padding-left: 18px; }
.qs-resumen li { margin: 2px 0; }
.qs-resumen a { color: #7A1A12; }
.qs-resumen:focus { outline: 3px solid var(--dorado); outline-offset: 2px; }

/* Pasos con riel de avance */
.qs-form .paso { position: relative; border: 0; margin: 0; padding: 0 0 34px 54px; min-width: 0; }
.qs-form .paso::before {
    content: ''; position: absolute; left: 17px; top: 42px; bottom: 6px; width: 2px;
    background: var(--linea); transition: background .25s;
}
.qs-form .paso.completo::before { background: var(--dorado); }
.paso-tit { float: left; width: 100%; padding: 0; margin: 0 0 16px; font-size: 1.2rem; font-weight: 800; color: var(--negro); line-height: 36px; }
.paso-cuerpo { clear: both; }
.paso-num {
    position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem; font-weight: 800; line-height: 1;
    background: #fff; color: var(--gris); border: 2px solid #CFCCC8;
    transition: background .2s, border-color .2s, color .2s;
}
.paso:focus-within .paso-num { border-color: var(--guinda); color: var(--guinda); }
.paso.completo .paso-num { background: var(--dorado); border-color: var(--dorado); color: transparent; }
.paso.completo .paso-num::after {
    content: ''; position: absolute; left: 12px; top: 7px; width: 7px; height: 13px;
    border: solid var(--negro); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}

/* Selector de tipo: el elemento protagonista */
.tipo-sel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tipo-sel input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tipo-sel label {
    display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: start;
    cursor: pointer; border: 2px solid var(--linea); border-radius: 10px; padding: 16px 16px 15px;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.tipo-ico { grid-row: span 2; width: 30px; height: 30px; color: var(--guinda); margin-top: 2px; }
.tipo-sel label b { font-size: 1.25rem; font-weight: 800; color: var(--negro); line-height: 1.25; }
.tipo-sel label span { font-size: .87rem; color: var(--gris); line-height: 1.4; }
.tipo-sel label:hover { border-color: var(--dorado); }
.tipo-sel input:focus-visible + label { outline: 3px solid var(--dorado); outline-offset: 2px; }
.tipo-sel input:checked + label { background: var(--guinda); border-color: var(--guinda); box-shadow: inset 0 -4px 0 var(--dorado); }
.tipo-sel input:checked + label b { color: #fff; }
.tipo-sel input:checked + label span { color: #F3DADA; }
.tipo-sel input:checked + label .tipo-ico { color: var(--dorado); }

/* Campos del formulario público */
.qs-form .campo { margin-bottom: 20px; }
.qs-form .campo:last-child { margin-bottom: 0; }
.qs-form .fila-2 { margin-bottom: 20px; }
.qs-form .fila-2 .campo { margin-bottom: 0; }
.qs-form select {
    appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238B0000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
}
.qs-form input[type=text], .qs-form input[type=tel], .qs-form input[type=email], .qs-form select, .qs-form textarea { min-height: 48px; }
.qs-form textarea { min-height: 150px; line-height: 1.5; }
.qs-form [aria-invalid="true"] { border-color: var(--error) !important; }
.qs-form [aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .15); }
.qs-form .opc { font-weight: 500; color: var(--gris); }
.f-err { margin: 6px 0 0; color: var(--error); font-size: .85rem; font-weight: 600; }
.f-err[hidden] { display: none; }

/* Temas como botones */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip[hidden] { display: none; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip label {
    display: inline-flex; align-items: center; min-height: 42px; padding: 8px 15px;
    border: 1.5px solid #CFCCC8; border-radius: 999px; background: #fff; cursor: pointer;
    font-size: .92rem; font-weight: 600; color: var(--texto); user-select: none;
    transition: border-color .15s, background .15s, color .15s;
}
.chip label:hover { border-color: var(--dorado); }
.chip input:focus-visible + label { outline: 3px solid var(--dorado); outline-offset: 2px; }
.chip input:checked + label { background: var(--guinda); border-color: var(--guinda); color: #fff; }
#grupo-temas[aria-invalid="true"] .chip label { border-color: var(--error); }
#grupo-temas:focus { outline: none; }

/* Descripción */
.desc-pie { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.guia { margin: 0; font-size: .84rem; color: var(--gris); }
.desc-pie .contador { float: none; white-space: nowrap; font-size: .8rem; color: var(--gris); font-variant-numeric: tabular-nums; }
.desc-pie .contador.cerca { color: var(--guinda); font-weight: 700; }

/* Foto */
.foto-zona { position: relative; }
.foto-zona input[type=file] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.foto-vacia {
    display: flex !important; align-items: center; gap: 14px; margin: 0 !important; cursor: pointer;
    border: 2px dashed #D9CFA8; border-radius: 10px; padding: 16px 18px; background: #FFFDF7;
    transition: border-color .15s, background .15s;
}
.foto-vacia[hidden] { display: none !important; }
.foto-vacia svg { width: 30px; height: 30px; color: var(--dorado-oscuro); flex: none; }
.foto-vacia b { display: block; color: var(--guinda); font-size: .95rem; }
.foto-vacia small { display: block; color: var(--gris); font-weight: 500; font-size: .8rem; }
.foto-vacia:hover { border-color: var(--dorado); background: var(--dorado-suave); }
.foto-zona input:focus-visible + .foto-vacia { outline: 3px solid var(--dorado); outline-offset: 2px; }
.foto-lista { display: flex; align-items: center; gap: 14px; border: 1.5px solid var(--linea); border-radius: 10px; padding: 10px 14px 10px 10px; }
.foto-lista[hidden] { display: none; }
.foto-lista img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; background: var(--fondo-alt); }
.foto-info { flex: 1; min-width: 0; }
.foto-info b { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foto-info small { color: var(--gris); }
#foto-quitar { border: 0; background: none; font: inherit; font-weight: 700; color: var(--guinda); text-decoration: underline; cursor: pointer; padding: 8px 4px; }
#foto-quitar:hover { color: var(--guinda-oscuro); }
.nota-foto { margin: 6px 0 0; font-size: .82rem; color: var(--gris); }

/* Contacto y autorización */
.ayuda-contacto { margin: -6px 0 12px; font-size: .88rem; color: var(--gris); }
.check-caja {
    display: flex !important; gap: 12px; align-items: flex-start; cursor: pointer; margin: 0 !important;
    font-weight: 500 !important; font-size: .92rem !important; color: var(--texto) !important;
    border: 1.5px solid var(--linea); border-radius: 10px; padding: 14px 16px;
    transition: border-color .15s, background .15s;
}
.check-caja input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--guinda); cursor: pointer; }
.check-caja:has(input:checked) { border-color: var(--guinda); background: var(--guinda-suave); }
.check-caja:has(input[aria-invalid="true"]) { border-color: var(--error); }

/* Envío */
.enviar { padding-left: 54px; }
.enviar-nota { margin: 10px 0 0; text-align: center; font-size: .85rem; color: var(--gris); }

@media screen and (max-width: 560px) {
    .qs-hero h1 { font-size: 1.7rem; }
    .qs-form .paso { padding-left: 44px; }
    .qs-form .paso::before { left: 14px; top: 36px; }
    .paso-num { width: 30px; height: 30px; font-size: .85rem; }
    .paso.completo .paso-num::after { left: 9.5px; top: 5px; width: 6px; height: 11px; }
    .paso-tit { font-size: 1.08rem; line-height: 30px; }
    .tipo-sel { grid-template-columns: 1fr; }
    .enviar { padding-left: 0; }
    .qs-form .fila-2 { gap: 20px; }
    .desc-pie { flex-direction: column; gap: 2px; }
    .desc-pie .contador { align-self: flex-end; }
}

/* ---------- Admin ---------- */
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;
    padding: 8px 10px;
    border-bottom: 3px solid transparent;
}
.nav a:hover { color: var(--dorado); }
.nav a.activo { border-bottom-color: var(--dorado); }
.nav .badge { background: var(--dorado); color: var(--negro); border-radius: 10px; padding: 0 7px; font-size: .75rem; margin-left: 4px; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1.5px solid rgba(255,255,255,.5); color: #fff; border-radius: 6px; padding: 6px 10px; font: inherit; }

.admin { max-width: 1200px; margin: 0 auto; padding: 26px 20px 60px; }
.cabeza { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.cabeza h1 { margin: 0; }

.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 0; border-top: 1px solid var(--linea); border-bottom: 1px solid var(--linea); margin-bottom: 18px; }
.filtros .f { display: flex; flex-direction: column; min-width: 150px; }
.filtros .f label { font-size: .78rem; font-weight: 600; color: var(--gris); margin-bottom: 4px; }
.filtros select, .filtros input { padding: 8px 10px; font-size: .9rem; }
.filtros .f-busca { flex: 1; min-width: 200px; }

/* Indicadores: franja dividida, no tarjetas */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 3px solid var(--guinda); border-bottom: 1px solid var(--linea); margin-bottom: 28px; }
.kpi { padding: 16px 18px; border-right: 1px solid var(--linea); }
.kpi:last-child { border-right: 0; }
.kpi b { display: block; font-size: 2rem; font-weight: 800; color: var(--negro); font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi span { font-size: .85rem; color: var(--gris); font-weight: 600; }
.kpi.q b { color: var(--guinda); }
.kpi.s b { color: var(--dorado-oscuro); }

.graficas { display: grid; grid-template-columns: 1fr 1fr; gap: 32px 36px; }
.grafica h2 { font-size: 1rem; padding-bottom: 8px; border-bottom: 1px solid var(--linea); margin-bottom: 12px; }
.grafica .lienzo { position: relative; }
.grafica.ancha { grid-column: 1 / -1; }
.vacio { color: var(--gris); font-size: .9rem; padding: 24px 0; }

table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th { text-align: left; font-weight: 700; color: var(--gris); font-size: .78rem; padding: 8px 10px; border-bottom: 2px solid var(--linea); white-space: nowrap; }
.tabla td { padding: 10px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.tabla tbody tr:hover { background: var(--fondo-alt); }
.tabla tr.clic { cursor: pointer; }
.tabla .der { text-align: right; }
.tabla tfoot td { font-weight: 700; border-top: 2px solid var(--linea); border-bottom: 0; }
.extracto { color: var(--gris); max-width: 42ch; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.scroll-x { overflow-x: auto; }

.pill { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.pill-nueva { background: var(--guinda); color: #fff; }
.pill-en_revision { background: var(--dorado-suave); color: #6B560F; border: 1px solid var(--dorado); }
.pill-atendida { background: #EAF5EE; color: var(--ok); }
.pill-cerrada { background: #EEE; color: #555; }
.pill-queja { background: var(--guinda-suave); color: var(--guinda); }
.pill-sugerencia { background: var(--dorado-suave); color: #6B560F; }

.paginas { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.paginas a, .paginas span { padding: 6px 11px; border: 1px solid var(--linea); border-radius: 6px; text-decoration: none; font-size: .88rem; }
.paginas span.act { background: var(--guinda); color: #fff; border-color: var(--guinda); }

/* Detalle */
.detalle { display: grid; grid-template-columns: 1.4fr 1fr; gap: 36px; }
.dato { margin-bottom: 14px; }
.dato small { display: block; font-size: .78rem; color: var(--gris); font-weight: 600; }
.texto-ciudadano { white-space: pre-wrap; background: var(--fondo-alt); border-left: 4px solid var(--dorado); padding: 14px 16px; border-radius: 0 var(--radio) var(--radio) 0; }
.foto-evid img { border-radius: var(--radio); border: 1px solid var(--linea); max-height: 360px; }
.linea-tiempo { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--linea); }
.linea-tiempo li { position: relative; padding: 0 0 16px 10px; font-size: .88rem; }
.linea-tiempo li::before { content: ''; position: absolute; left: -23px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--dorado); border: 2px solid #fff; }
.linea-tiempo .quien { color: var(--gris); font-size: .8rem; }

/* Login */
.login { max-width: 380px; margin: 60px auto; padding: 0 20px; }

/* Catálogos / tablas editables */
.inline { display: flex; gap: 8px; align-items: center; }
.inline input[type=text] { padding: 7px 10px; }
.secciones-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }

/* ---------- Responsivo ---------- */
@media screen and (max-width: 900px) {
    .graficas, .detalle, .secciones-2 { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: 1fr 1fr; }
    .kpi:nth-child(2) { border-right: 0; }
    .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--linea); }
    .nav-toggle { display: block; }
    .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
    .nav.abierto { display: flex; }
    .franja-in { flex-wrap: wrap; }
}
@media screen and (max-width: 560px) {
    .fila-2 { grid-template-columns: 1fr; }
    h1 { font-size: 1.45rem; }
    .franja .marca span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------- Impresión (reportes) ---------- */
@media print {
    @page { size: letter; margin: 14mm; }
    body { font-size: 11px; }
    .no-print, .nav, .nav-toggle, .filtros { display: none !important; }
    .franja { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .admin { padding: 10px 0; max-width: none; }
    .kpis, .pill, .tabla th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .grafica, .kpis, .tabla tr { break-inside: avoid; }
    .scroll-x { overflow: visible !important; }
    .tabla { font-size: 10px; }
    .tabla th, .tabla td { padding: 6px 6px; }
    h1, h2 { break-after: avoid; page-break-after: avoid; }
    .grafica .lienzo canvas { width: 100% !important; height: 100% !important; }
    .graficas { grid-template-columns: 1fr 1fr; gap: 18px; }
    .grafica.ancha { grid-column: 1 / -1; }
    .kpis { grid-template-columns: repeat(4, 1fr); }
    a { color: inherit; text-decoration: none; }
}