:root {
  color-scheme: only light;   /* la interfaz es clara: evita que el navegador del teléfono la oscurezca a la fuerza */
  --brand: #0f4c81;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e2e6ec;
  --verde: #15803d;
  --verde-bg: #dcfce7;
  --ambar: #b45309;
  --ambar-bg: #fef3c7;
  --rojo: #b91c1c;
  --rojo-bg: #fee2e2;
  --azul: #1d4ed8;
  --azul-bg: #dbeafe;
  --gris: #4b5563;
  --gris-bg: #e5e7eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: .25rem 0 .75rem; }
small, .muted { color: var(--muted); }
.sub { color: var(--muted); margin: 0 0 1rem; }

/* ---------- barra superior ---------- */
.topbar {
  background: var(--card);
  border-bottom: 3px solid var(--brand);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .6rem 1.25rem;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .75rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { height: 40px; width: auto; max-width: 160px; object-fit: contain; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 1.05rem; color: var(--brand); }
.brand small { font-size: .78rem; color: var(--muted); }
.topbar nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: .45rem .8rem; border-radius: 8px; color: var(--text); font-weight: 500; }
.topbar nav a.on, .topbar nav a:hover { background: var(--bg); color: var(--brand); text-decoration: none; }
.userbox { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.userbox a { color: var(--text); }
.chip { background: var(--azul-bg); color: var(--azul); border-radius: 999px; padding: .2rem .7rem; font-size: .8rem; font-weight: 600; white-space: nowrap; }

.container { max-width: 1240px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

/* ---------- tarjetas y grillas ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1.1rem; }
.card.compact { padding: .8rem 1rem; }
.grid { display: grid; gap: 1rem; margin-bottom: 1.1rem; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpi-tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; border-left: 4px solid var(--brand); }
.kpi-tile .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi-tile .value { font-size: 1.45rem; font-weight: 700; margin-top: .15rem; }
.kpi-tile.verde { border-color: var(--verde); }
.kpi-tile.rojo { border-color: var(--rojo); }
.kpi-tile.ambar { border-color: var(--ambar); }
.kpi-tile.azul { border-color: var(--azul); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.right { text-align: right; }
.mt { margin-top: 1rem; }

/* ---------- tablas ---------- */
.tabla-wrap { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th, .tabla td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tabla th { background: #f8fafc; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); position: sticky; top: 0; z-index: 1; }
.tabla tbody tr:hover { background: #fafbfd; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla tr.grupo td { background: #eef2f7; font-weight: 600; }
.tabla tr.subtotal td { font-weight: 600; background: #f8fafc; }
.tabla tr.total td { font-weight: 700; border-top: 2px solid var(--brand); font-size: 1rem; }
.tabla input[type=number] { width: 100%; min-width: 70px; }
.tabla input[type=text], .tabla select { width: 100%; min-width: 130px; }
/* Tablas con campos editables: cuando no cabe, aparece desplazamiento horizontal en vez de encoger los campos. */
.tabla-editable { min-width: 1040px; }
.tabla-editable th { white-space: nowrap; }
.tabla-editable .col-nombre input { min-width: 205px; }
.tabla-editable .col-visible input { min-width: 160px; }
.tabla-editable .col-perfil select { min-width: 130px; }
.tabla-editable .col-clave input { min-width: 165px; }
.tabla-editable .col-centros { max-width: 330px; font-size: .82rem; }
.tabla-editable .col-centros details summary { cursor: pointer; color: var(--brand); font-weight: 600; list-style: none; }
.tabla-editable .col-centros details summary::after { content: " ▾"; font-size: .75rem; }
.tabla-editable .col-centros details[open] summary::after { content: " ▴"; }
.tabla-editable .col-centros details ul { margin: .3rem 0 0; padding-left: 1rem; color: var(--muted); }
.tabla-editable .col-centros details li { margin: .1rem 0; }
.tabla input.cant { width: 90px; text-align: right; }
.tabla .acciones { white-space: nowrap; }

/* ---------- badges / barras ---------- */
.badge { display: inline-block; border-radius: 999px; padding: .15rem .65rem; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.verde { background: var(--verde-bg); color: var(--verde); }
.badge.rojo { background: var(--rojo-bg); color: var(--rojo); }
.badge.ambar { background: var(--ambar-bg); color: var(--ambar); }
.badge.azul { background: var(--azul-bg); color: var(--azul); }
.badge.gris { background: var(--gris-bg); color: var(--gris); }
.barra { height: 10px; background: var(--gris-bg); border-radius: 999px; overflow: hidden; min-width: 90px; }
.barra div { height: 100%; border-radius: 999px; transition: width .25s; }
.barra.verde div { background: var(--verde); }
.barra.ambar div { background: var(--ambar); }
.barra.rojo div { background: var(--rojo); }
.txt-verde { color: var(--verde); }
.txt-rojo { color: var(--rojo); font-weight: 700; }
.txt-ambar { color: var(--ambar); }

/* ---------- botones y formularios ---------- */
.btn {
  display: inline-block; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: .5rem 1rem; border-radius: 8px; font-weight: 600; font-size: .92rem; cursor: pointer; line-height: 1.2;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.small { padding: .3rem .7rem; font-size: .82rem; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.success { background: var(--verde); border-color: var(--verde); }
.btn.danger { background: var(--rojo); border-color: var(--rojo); }
.btn.ambar { background: var(--ambar); border-color: var(--ambar); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--line); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid #cbd2dc; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.campo { margin-bottom: .9rem; }
.form-inline { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.form-inline .campo { margin-bottom: 0; flex: 1; min-width: 140px; }
.form-inline .campo.corto { flex: 0 0 110px; }
.form-inline .campo.medio { flex: 0 0 200px; }
.checkbox { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; color: var(--text); }
.checkbox input { width: auto; }
.chk-list { display: flex; flex-direction: column; gap: .15rem; font-size: .85rem; min-width: 150px; }
.chk-list .checkbox { font-weight: 400; white-space: nowrap; }

/* ---------- avisos ---------- */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; border: 1px solid transparent; }
.flash.ok { background: var(--verde-bg); color: var(--verde); border-color: #bbf7d0; }
.flash.error { background: var(--rojo-bg); color: var(--rojo); border-color: #fecaca; }
.flash.aviso { background: var(--ambar-bg); color: var(--ambar); border-color: #fde68a; }
.panel { border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: 1rem; border: 1px solid transparent; }
.panel.rojo { background: var(--rojo-bg); border-color: #fecaca; color: #7f1d1d; }
.panel.ambar { background: var(--ambar-bg); border-color: #fde68a; color: #78350f; }
.panel.verde { background: var(--verde-bg); border-color: #bbf7d0; color: #14532d; }
.panel.azul { background: var(--azul-bg); border-color: #bfdbfe; color: #1e3a8a; }
.panel h3 { margin-bottom: .3rem; }

/* ---------- resumen de presupuesto (solicitud) ---------- */
.presupuesto-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem 1.25rem; align-items: end; }
.presupuesto-box .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; }
.presupuesto-box .value { font-size: 1.3rem; font-weight: 700; }
.presupuesto-box .barra { margin-top: .35rem; }
.sticky-bottom { position: sticky; bottom: 0; background: var(--card); box-shadow: 0 -4px 12px rgba(16, 24, 40, .08); z-index: 5; }

/* ---------- línea de tiempo ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .4rem 0 .4rem 1.2rem; border-left: 2px solid var(--line); position: relative; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .8rem; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline .cuando { color: var(--muted); font-size: .8rem; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: none; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 12px; max-width: 560px; width: 100%; padding: 1.25rem 1.4rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal h2 { color: var(--rojo); }
.modal .exceso { font-size: 1.6rem; font-weight: 800; color: var(--rojo); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; position: relative; }
.login-wrap.con-foto { background-size: cover; background-position: center; background-repeat: no-repeat; }
.login-wrap.con-foto::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(45, 53, 164, .55), rgba(15, 23, 42, .35)); }
.login-wrap.con-foto .login-card { position: relative; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); background: rgba(255, 255, 255, .96); }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(16, 24, 40, .12); padding: 2rem; width: 100%; max-width: 400px; border-top: 5px solid var(--brand); }
.login-card .brand { justify-content: center; margin-bottom: 1.25rem; }
.login-card .brand img { height: 56px; max-width: 220px; }

/* ---------- pestañas admin ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .55rem 1rem; border-radius: 8px 8px 0 0; color: var(--muted); font-weight: 600; }
.tabs a.on { color: var(--brand); border-bottom: 3px solid var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--brand); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .container { padding: .9rem .75rem 3rem; }
  .topbar { padding: .5rem .75rem; gap: .5rem .75rem; }
  .brand img { height: 30px; }
  .brand span { display: none; }
  .topbar nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; gap: .15rem; padding-bottom: .1rem; }
  table.tabla.stack tr.grupo td { justify-content: flex-start; }
  .topbar nav a { padding: .35rem .65rem; font-size: .88rem; white-space: nowrap; }
  .userbox { margin-left: auto; gap: .5rem; }
  .userbox .chip { display: none; }
  .userbox > a { font-size: .9rem; }
  .card { padding: .9rem; }
  .sticky-bottom small { display: none; }
  .sticky-bottom .row { width: 100%; }
  .sticky-bottom .row .btn { flex: 1; text-align: center; }
  .presupuesto-box .value { font-size: 1.15rem; }
  .form-inline .campo, .form-inline .campo.corto, .form-inline .campo.medio { flex: 1 1 100%; }
  table.tabla.stack thead { display: none; }
  table.tabla.stack tr { display: block; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .6rem; padding: .35rem .5rem; background: #fff; }
  table.tabla.stack td { display: flex; justify-content: space-between; gap: .75rem; border: 0; padding: .3rem 0; }
  table.tabla.stack td::before { content: attr(data-l); font-weight: 600; color: var(--muted); font-size: .78rem; }
  table.tabla.stack td.num { text-align: right; }
}

@media print {
  .topbar, .foot, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ---------- zona de acciones destructivas ---------- */
.card.peligro { border-left: 4px solid var(--rojo); }
form.inline { display: inline; }
.btn.danger.ghost { background: transparent; color: var(--rojo); border-color: #fecaca; }
.btn.danger.ghost:hover { background: var(--rojo-bg); }

/* ---------- chat interno ---------- */
[hidden] { display: none !important; }   /* si no, display:flex anula el atributo hidden */
#chat-btn {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: #fff; box-shadow: 0 6px 20px rgba(16, 24, 40, .28);
  display: flex; align-items: center; justify-content: center; transition: transform .15s, box-shadow .15s;
}
#chat-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(16, 24, 40, .34); }
#chat-btn.activo { background: #1f2937; }
.chat-globo {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--rojo); color: #fff; font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
}

#chat-panel {
  position: fixed; right: 20px; bottom: 86px; z-index: 60;
  width: 340px; max-width: calc(100vw - 40px); height: min(560px, calc(100vh - 130px));
  background: #fff; border-radius: 14px; border: 1px solid var(--line);
  box-shadow: 0 16px 48px rgba(16, 24, 40, .24);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-cabecera {
  display: flex; align-items: center; gap: .5rem; padding: .7rem .8rem;
  background: var(--brand); color: #fff;
}
.chat-titulo-box { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; }
.chat-titulo-box strong { display: block; font-size: .95rem; line-height: 1.2; }
.chat-titulo-box small { display: block; font-size: .75rem; opacity: .85; }
.chat-icono {
  background: rgba(255, 255, 255, .18); border: 0; color: #fff; cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px; font-size: .82rem; line-height: 1; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;  /* los emojis no se centran solos */
}
.chat-icono:hover { background: rgba(255, 255, 255, .32); }
#chat-volver { visibility: hidden; }          /* solo se ve dentro de una conversación (lo activa chat.js) */
#chat-volver.visible { visibility: visible; }

/* Presencia: verde en línea · ámbar ausente · gris desconectado */
.chat-punto { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(0, 0, 0, .12); }
.chat-punto.on { background: #22c55e; }
.chat-punto.away { background: #f59e0b; }
.chat-punto.off { background: transparent; border-color: #cbd5e1; }

.chat-lista { flex: 1; overflow-y: auto; }
.chat-contacto {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
  padding: .65rem .8rem; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.chat-contacto:hover { background: var(--bg); }
.chat-nombre { flex: 1; min-width: 0; font-size: .9rem; font-weight: 600; color: var(--text); }
.chat-nombre small { display: block; font-weight: 400; font-size: .74rem; color: var(--muted); }
.chat-contacto .chat-globo { position: static; border: 0; }

.chat-conv { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-mensajes { flex: 1; overflow-y: auto; padding: .8rem; background: var(--bg); display: flex; flex-direction: column; gap: .4rem; }
.chat-msg { max-width: 82%; padding: .45rem .65rem; border-radius: 12px; font-size: .88rem; line-height: 1.35; word-wrap: break-word; }
.chat-msg.suyo { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg.mio { align-self: flex-end; background: #dbeafe; border-bottom-right-radius: 4px; }
.chat-msg .meta { display: block; text-align: right; font-size: .68rem; color: var(--muted); margin-top: .15rem; }
.chat-msg .check { font-weight: 700; letter-spacing: -1px; }
.chat-msg.leido .check { color: #2563eb; }

.chat-escribir { display: flex; gap: .4rem; padding: .55rem; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-escribir textarea {
  flex: 1; resize: none; max-height: 90px; padding: .45rem .6rem; font-size: .88rem;
  border: 1px solid var(--line); border-radius: 8px; font-family: inherit;
}

@media (max-width: 640px) {
  #chat-panel { right: 10px; left: 10px; width: auto; bottom: 78px; height: min(70vh, calc(100vh - 110px)); }
  #chat-btn { right: 14px; bottom: 14px; }
}
@media print { #chat, #chat-panel, #chat-btn { display: none !important; } }

/* ---------- ojito para ver la contraseña ---------- */
.campo-clave { position: relative; }
.campo-clave input { padding-right: 2.6rem; }
.ojito {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; padding: 4px; cursor: pointer; color: var(--muted);
  display: flex; align-items: center; border-radius: 6px;
}
.ojito:hover { color: var(--brand); background: var(--bg); }
.ojito.activo { color: var(--brand); }

/* ---------- emoticones del chat ---------- */
.chat-emoji-btn {
  background: none; border: 0; cursor: pointer; font-size: 1.25rem; line-height: 1;
  color: var(--muted); padding: .25rem .3rem; border-radius: 6px;
}
.chat-emoji-btn:hover, .chat-emoji-btn.activo { background: var(--bg); color: var(--brand); }
.chat-emojis {
  display: flex; flex-wrap: wrap; gap: 2px; padding: .4rem;
  max-height: 156px; overflow-y: auto; border-top: 1px solid var(--line); background: var(--bg);
}
.chat-emoji {
  background: none; border: 0; cursor: pointer; font-size: 1.15rem; line-height: 1;
  padding: .2rem; border-radius: 6px; width: 30px;
}
.chat-emoji:hover { background: #fff; transform: scale(1.15); }
.chat-icono.apagado { opacity: .55; }
.chat-aviso { margin: 0; padding: .4rem .8rem; font-size: .72rem; color: var(--muted); background: #fffbeb; border-bottom: 1px solid var(--line); }
.chat-revision { display: flex; flex-direction: column; gap: .5rem; background: var(--bg); padding: 1rem; border-radius: var(--radius); max-height: 60vh; overflow-y: auto; }
.chat-revision .chat-msg { max-width: 70%; }

/* ---------- fotos adjuntas en el chat ---------- */
.chat-adjunto {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem;
  border-top: 1px solid var(--line); background: var(--azul-bg); font-size: .8rem;
}
.chat-adjunto img { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; }
.chat-adjunto span { flex: 1; color: var(--azul); font-weight: 600; }
.chat-adjunto button { background: none; border: 0; cursor: pointer; color: var(--rojo); font-size: 1rem; padding: .2rem .4rem; }
.chat-foto { display: block; margin-bottom: .3rem; }
.chat-foto img { max-width: 100%; max-height: 220px; border-radius: 8px; display: block; }
/* Al arrastrar una imagen sobre el chat */
#chat-panel.soltando { outline: 3px dashed var(--brand); outline-offset: -4px; }
#chat-panel.soltando::after {
  content: "Suelta la foto para adjuntarla";
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(255, 255, 255, .92); color: var(--brand); font-weight: 700; font-size: .95rem;
  padding: 2rem; pointer-events: none;
}
.chat-revision .chat-foto img { max-height: 260px; }

/* ---------- aviso de instalación como app ---------- */
.pwa-aviso {
  position: fixed; left: 12px; right: 12px; bottom: 84px; z-index: 55;
  display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 36px rgba(16, 24, 40, .22);
}
.pwa-aviso img { width: 44px; height: 44px; border-radius: 11px; flex: 0 0 auto; }
.pwa-texto { flex: 1; min-width: 0; font-size: .85rem; line-height: 1.3; }
.pwa-texto strong { display: block; }
.pwa-texto span { color: var(--muted); }
.pwa-ico { display: inline-block; border: 1px solid var(--muted); border-radius: 4px; padding: 0 .3rem; font-size: .8rem; }
.pwa-cerrar { background: none; border: 0; color: var(--muted); font-size: 1rem; cursor: pointer; padding: .3rem; }
@media (min-width: 700px) { .pwa-aviso { left: auto; max-width: 420px; } }

/* ---------- viñeta del producto elegido (editor de solicitudes) ---------- */
.vineta { display: flex; align-items: center; gap: .8rem; margin-top: .8rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; }
.vineta-img { width: 84px; height: 84px; flex: 0 0 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f7f9fc; cursor: zoom-in; }
.vineta-img.sin-foto { cursor: default; }
.vineta-img img, .vineta-img svg { width: 100%; height: 100%; display: block; object-fit: cover; }
.vineta-info { flex: 1; min-width: 0; line-height: 1.3; }
.vineta-info b { display: block; font-size: .92rem; }
.vineta-info small { color: var(--muted); font-size: .78rem; }
.vineta-precio { display: block; font-weight: 700; font-size: .95rem; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.vineta-lupa { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 8px; padding: .4rem; cursor: pointer; display: flex; }
.vineta-lupa:hover { color: var(--brand); border-color: var(--brand); }
.modal-foto { max-width: 460px; text-align: center; }
.modal-foto-img { width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #f7f9fc; border: 1px solid var(--line); }
.modal-foto-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.modal-foto p { font-weight: 600; margin: .8rem 0; }
@media (max-width: 640px) { .vineta-img { width: 68px; height: 68px; flex-basis: 68px; } }

/* ---------- fotos en el catálogo (Administración → Productos) ---------- */
.col-foto { white-space: nowrap; width: 62px; }
.celda-foto { width: 46px; height: 46px; padding: 0; border-radius: 7px; overflow: hidden; cursor: pointer; vertical-align: middle; border: 1px solid var(--line); background: #f7f9fc; }
.celda-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.celda-foto.sin { border-style: dashed; color: var(--muted); font-size: 1.3rem; line-height: 1; }
.celda-foto.sin:hover { color: var(--brand); border-color: var(--brand); }
.quitar-foto { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .8rem; padding: .1rem .25rem; vertical-align: middle; }
.quitar-foto:hover { color: var(--rojo); }
#tabla-prod .col-nombre input { min-width: 290px; }
.col-cat, .col-prov { min-width: 230px; }
.col-cat .sel-opc, .col-prov .sel-opc { min-width: 210px; }
.opc-nueva { margin-top: .3rem; }

/* ---------- seguridad: contraseñas mostradas una vez, dos pasos, estado ---------- */
.clave-grande { font-size: 1.3rem; background: #fff; padding: .25rem .6rem; border-radius: 6px; user-select: all; }
.codigos-respaldo { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .4rem; margin-top: .5rem; }
.codigos-respaldo code { font-size: 1.05rem; background: #fff; padding: .35rem .5rem; border-radius: 6px; text-align: center; user-select: all; }
.totp-setup { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; margin: .5rem 0 1rem; }
.totp-qr svg { width: 200px; height: 200px; border: 1px solid #dfe3ec; border-radius: 8px; }
.totp-clave { display: inline-block; font-size: 1.05rem; letter-spacing: .08em; background: #eef0f6; padding: .4rem .6rem; border-radius: 6px; word-break: break-all; user-select: all; }
.estado-seguridad td:first-child { width: 2.5rem; text-align: center; }
pre.cron { background: #1f2937; color: #e5e7eb; padding: .7rem .9rem; border-radius: 8px; font-size: .8rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
form.inline { display: inline; }
.userbox form.inline button { font: inherit; }

/* =======================================================================
   Módulo de Encuestas por licitación (encuestas.cleanvip.cl)
   ======================================================================= */

.container.angosto { max-width: 780px; }
.topbar.publica .brand { cursor: default; }
.topbar.publica .userbox { margin-left: auto; }

/* ---------- acceso por número de licitación ---------- */
.acceso-card { max-width: 460px; }
.acceso-card .codigo { font-size: 1.25rem; letter-spacing: .12em; text-align: center; text-transform: uppercase; font-weight: 700; }
.acceso-card .clave-acceso { text-align: center; letter-spacing: .18em; text-transform: uppercase; }

/* ---------- ficha de la licitación ---------- */
.lic-cabecera { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.lic-codigo { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.05rem; font-weight: 700; color: var(--brand); }
.dato { margin-bottom: .6rem; }
.dato .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.dato .valor { font-weight: 600; }
.enlace-caja { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.enlace-caja input { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }
.copiado { color: var(--verde); font-weight: 600; font-size: .85rem; }

/* ---------- formulario de respuesta ---------- */
.seccion-titulo { margin: 1.5rem 0 .25rem; padding-bottom: .35rem; border-bottom: 2px solid var(--brand); color: var(--brand); font-size: 1.05rem; font-weight: 700; }
.pregunta { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: .75rem; border-left: 4px solid transparent; }
.pregunta.falta { border-left-color: var(--rojo); background: #fffafa; }
.pregunta .enunciado { font-weight: 600; margin-bottom: .1rem; display: block; color: var(--text); font-size: .98rem; }
.pregunta .numero { color: var(--muted); font-weight: 700; margin-right: .35rem; }
.pregunta .req { color: var(--rojo); margin-left: .2rem; font-weight: 700; }
.pregunta .ayuda { color: var(--muted); font-size: .85rem; margin: .1rem 0 .5rem; }
.pregunta .campo-respuesta { margin-top: .6rem; }
.opciones { display: flex; flex-direction: column; gap: .3rem; }
.opciones label { display: flex; align-items: center; gap: .5rem; font-weight: 400; color: var(--text); font-size: .95rem;
  padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 8px; margin: 0; cursor: pointer; }
.opciones label:hover { background: var(--bg); }
.opciones input { width: auto; margin: 0; flex: 0 0 auto; }
.opciones.horizontal { flex-direction: row; flex-wrap: wrap; }
.opciones.horizontal label { min-width: 64px; justify-content: center; }
.escala-fila { display: flex; gap: .4rem; flex-wrap: wrap; align-items: stretch; }
.escala-fila label { flex: 1 1 54px; flex-direction: column; gap: .15rem; text-align: center; font-weight: 600; }
.foto-caja { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.foto-caja img { max-height: 120px; border-radius: 8px; border: 1px solid var(--line); }
.foto-caja input[type=file] { border: 1px dashed #cbd2dc; padding: .45rem; border-radius: 8px; background: #fff; width: auto; flex: 1; min-width: 200px; }
.barra-acciones { position: sticky; bottom: 0; background: var(--card); box-shadow: 0 -4px 12px rgba(16,24,40,.08);
  border-radius: var(--radius); padding: .8rem 1rem; margin-top: 1rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; z-index: 5; }
.barra-acciones .avance { color: var(--muted); font-size: .88rem; flex: 1; min-width: 160px; }

/* ---------- resumen de respuestas ---------- */
.resumen-item { border-bottom: 1px solid var(--line); padding: .9rem 0; }
.resumen-item:last-child { border-bottom: 0; }
.resumen-item h4 { margin: 0 0 .5rem; font-size: .97rem; }
.resumen-item h4 .numero { color: var(--muted); margin-right: .35rem; }
.conteo { display: grid; grid-template-columns: minmax(90px, 200px) 1fr auto; gap: .35rem .6rem; align-items: center; font-size: .9rem; }
.conteo .op { font-weight: 600; }
.conteo .barra { min-width: 60px; }
.conteo .n { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.respuestas-texto { list-style: none; margin: 0; padding: 0; }
.respuestas-texto li { padding: .4rem .6rem; border-left: 3px solid var(--line); margin-bottom: .35rem; background: #fafbfd; border-radius: 0 6px 6px 0; font-size: .92rem; }
.respuestas-texto .quien { color: var(--muted); font-size: .8rem; display: block; }
.galeria { display: flex; gap: .5rem; flex-wrap: wrap; }
.galeria a { display: block; }
.galeria img { height: 96px; width: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.sin-respuesta { color: var(--muted); font-style: italic; font-size: .88rem; }

/* ---------- editor de preguntas ---------- */
.formato-ayuda { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: .75rem .9rem; font-size: .86rem; }
.formato-ayuda pre { margin: .4rem 0 0; white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace; font-size: .82rem; color: var(--text); }
textarea.pegar { min-height: 260px; font-family: ui-monospace, Consolas, monospace; font-size: .86rem; }
.tabla-preguntas td { vertical-align: top; }
.tabla-preguntas .col-orden { width: 46px; color: var(--muted); font-weight: 700; }
.tabla-preguntas .col-tipo { white-space: nowrap; }

.inline { display: inline; }
.no-print { }
@media print { .no-print, .topbar, .barra-acciones, .foot { display: none !important; } .card { box-shadow: none; } }

/* El logo vuelve al portal: al pasar el mouse se convierte en "← Portal" con la flecha en movimiento. */
.brand-portal { position: relative; }
.brand-portal .brand-contenido { display: flex; flex-direction: row; align-items: center; gap: .75rem; transition: opacity .15s; }
.brand-portal .brand-volver { position: absolute; inset: 0; display: flex; flex-direction: row; align-items: center; gap: .45rem; font-size: 1.15rem; font-weight: 700; color: var(--brand); opacity: 0; pointer-events: none; transition: opacity .15s; }
.brand-portal .brand-volver .flecha { display: inline-block; font-size: 1.05rem; line-height: 1; }
.brand-portal:hover .brand-contenido, .brand-portal:focus-visible .brand-contenido { opacity: 0; }
.brand-portal:hover .brand-volver, .brand-portal:focus-visible .brand-volver { opacity: 1; }
.brand-portal:hover .flecha { animation: flecha-atras 1.4s ease-in-out infinite; }
@keyframes flecha-atras { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-7px); } }
