/* Multicars — estilos. Móvil primero; claro/oscuro automático. */
:root {
  --bg: #f3f5f9; --card: #ffffff; --card-2: #f8fafc; --texto: #0f172a; --suave: #64748b; --borde: #e2e8f0;
  --primario: #1d4ed8; --primario-h: #1e40af; --primario-suave: #dbeafe; --sobre-primario: #ffffff;
  --acento: #f97316;
  --ok: #15803d; --ok-bg: #dcfce7; --err: #b91c1c; --err-bg: #fee2e2; --aviso: #b45309; --aviso-bg: #fef3c7; --info: #1d4ed8; --info-bg: #dbeafe;
  --radio: 12px; --sombra: 0 1px 2px rgba(15,23,42,.06), 0 6px 18px rgba(15,23,42,.05);
  --side-w: 252px; --fuente: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #131c31; --card-2: #0f1729; --texto: #e6eaf3; --suave: #93a1b8; --borde: #243049;
    --primario: #3b82f6; --primario-h: #60a5fa; --primario-suave: #172554; --sobre-primario: #ffffff;
    --ok: #4ade80; --ok-bg: #052e16; --err: #f87171; --err-bg: #450a0a; --aviso: #fbbf24; --aviso-bg: #422006; --info: #93c5fd; --info-bg: #172554;
    --sombra: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--fuente); background: var(--bg); color: var(--texto); font-size: 15px; line-height: 1.45; }
a { color: var(--primario); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.ico { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.suave { color: var(--suave); } .centro-texto { text-align: center; } .derecha { text-align: right; } .nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; } .oculto { display: none !important; }
.error-codigo { font-size: 3.5rem; font-weight: 800; color: var(--primario); line-height: 1; margin-bottom: .5rem; }
.icono-grande { width: 64px; height: 64px; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 50%; background: var(--info-bg); color: var(--info); }
.icono-grande .ico { width: 32px; height: 32px; } .icono-grande.rojo { background: var(--err-bg); color: var(--err); }

/* ---------- estructura ---------- */
.app { display: flex; min-height: 100vh; }
.side { width: var(--side-w); flex: none; background: var(--card); border-right: 1px solid var(--borde); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 40; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.contenido { padding: 1.25rem 1.5rem 3rem; width: 100%; max-width: 1280px; margin: 0 auto; }
.marca { display: flex; align-items: center; gap: .7rem; padding: 1rem 1rem .75rem; }
.marca-logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--primario), #2563eb 60%, var(--acento)); color: #fff; display: grid; place-items: center; flex: none; }
.marca-logo.grande { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto .5rem; } .marca-logo.grande .ico { width: 30px; height: 30px; }
.marca-txt { display: flex; flex-direction: column; min-width: 0; } .marca-txt strong { font-size: 1.05rem; } .marca-txt small { color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { padding: .5rem .6rem; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.menu a, .enlace-menu { display: flex; align-items: center; gap: .7rem; padding: .62rem .75rem; border-radius: 10px; color: var(--texto); font-weight: 500; background: none; border: 0; width: 100%; font: inherit; text-align: left; cursor: pointer; }
.menu a:hover, .enlace-menu:hover { background: var(--card-2); text-decoration: none; }
.menu a.activo { background: var(--primario-suave); color: var(--primario); font-weight: 600; }
.menu-sep { margin: .9rem .75rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); font-weight: 600; }
.side-pie { border-top: 1px solid var(--borde); padding: .6rem; }
.usuario { display: flex; align-items: center; gap: .65rem; padding: .35rem .5rem .6rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primario-suave); color: var(--primario); display: grid; place-items: center; font-weight: 700; flex: none; }
.usuario-txt { display: flex; flex-direction: column; min-width: 0; } .usuario-txt strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .usuario-txt small { color: var(--suave); }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 30; min-height: 56px; }
.topbar-titulo { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.velo { display: none; }
.bottom { display: none; }

/* ---------- componentes ---------- */
.tarjeta { background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1.1rem 1.2rem; box-shadow: var(--sombra); margin-bottom: 1rem; }
.tarjeta > h2:first-child, .tarjeta > h3:first-child { margin-bottom: .8rem; }
.tarjeta-cab { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .8rem; flex-wrap: wrap; }
.tarjeta-cab h2, .tarjeta-cab h3 { margin: 0; }
.pagina-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.pagina-cab h1 { margin: 0; } .pagina-cab .sub { color: var(--suave); margin-top: .15rem; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .6rem 1rem; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; min-height: 42px; line-height: 1.1; }
.btn-primario { background: var(--primario); color: var(--sobre-primario); } .btn-primario:hover { background: var(--primario-h); }
.btn-sec { background: var(--card); color: var(--texto); border-color: var(--borde); } .btn-sec:hover { background: var(--card-2); }
.btn-peligro { background: var(--err-bg); color: var(--err); border-color: transparent; } .btn-peligro:hover { filter: brightness(.96); }
.btn-ok { background: var(--ok-bg); color: var(--ok); }
.btn-enlace { background: none; color: var(--primario); padding: .3rem .5rem; min-height: 0; }
.btn-sm { padding: .4rem .7rem; min-height: 34px; font-size: .88rem; border-radius: 8px; }
.btn-bloque { width: 100%; }
.btn-icono { background: none; border: 0; padding: .45rem; border-radius: 8px; cursor: pointer; color: var(--texto); display: inline-grid; place-items: center; }
.btn-icono:hover { background: var(--card-2); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.banner { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem 1rem; margin: .75rem 1.5rem 0; border-radius: 10px; font-size: .92rem; }
.banner .ico { margin-top: 1px; }
.form-login .banner, .simple-caja .banner, .tarjeta .banner { margin-left: 0; margin-right: 0; }
.banner-verde { background: var(--ok-bg); color: var(--ok); } .banner-rojo { background: var(--err-bg); color: var(--err); }
.banner-amarillo, .banner-naranja { background: var(--aviso-bg); color: var(--aviso); } .banner-azul { background: var(--info-bg); color: var(--info); }
.banner a { font-weight: 700; color: inherit; text-decoration: underline; }

/* chips de estado */
.chip { display: inline-block; padding: .18rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: #e2e8f0; color: #334155; }
.chip-azul { background: #dbeafe; color: #1e40af; } .chip-violeta { background: #ede9fe; color: #5b21b6; } .chip-cian { background: #cffafe; color: #155e75; }
.chip-naranja { background: #ffedd5; color: #9a3412; } .chip-amarillo { background: #fef3c7; color: #92400e; } .chip-verde { background: #dcfce7; color: #166534; }
.chip-verde-oscuro { background: #bbf7d0; color: #14532d; } .chip-rojo { background: #fee2e2; color: #991b1b; }
@media (prefers-color-scheme: dark) {
  .chip { background: #1e293b; color: #cbd5e1; } .chip-azul { background: #172554; color: #93c5fd; } .chip-violeta { background: #2e1065; color: #c4b5fd; }
  .chip-cian { background: #083344; color: #67e8f9; } .chip-naranja { background: #431407; color: #fdba74; } .chip-amarillo { background: #422006; color: #fcd34d; }
  .chip-verde { background: #052e16; color: #86efac; } .chip-verde-oscuro { background: #14532d; color: #bbf7d0; } .chip-rojo { background: #450a0a; color: #fca5a5; }
}

/* formularios */
.campo { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; min-width: 0; }
.campo > span, .campo > label { font-size: .82rem; font-weight: 600; color: var(--suave); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .62rem .75rem; border: 1px solid var(--borde); border-radius: 10px; background: var(--card); color: var(--texto); font: inherit; min-height: 42px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primario); outline-offset: -1px; border-color: transparent; }
.fila { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.fila.c2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.fila .ancho { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 18px; height: 18px; }
.ayuda { font-size: .8rem; color: var(--suave); }
.form-pie { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.form-login { max-width: 420px; margin-left: auto; margin-right: auto; }

/* filtros */
.filtros { margin-bottom: 1rem; }
.filtros summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: .5rem; }
.filtros summary::-webkit-details-marker { display: none; }
.filtros[open] summary { margin-bottom: .9rem; }
.filtro-rapido { display: flex; gap: .6rem; }
.filtro-rapido input { flex: 1; }

/* tablas */
.tabla-wrap { overflow-x: auto; margin: 0 -.2rem; }
.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); padding: .55rem .7rem; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.tabla td { padding: .65rem .7rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover { background: var(--card-2); }
.tabla .num { text-align: right; white-space: nowrap; }
.tabla small { color: var(--suave); display: block; }
.vacio { text-align: center; padding: 2rem 1rem; color: var(--suave); }
.paginacion { display: flex; gap: .4rem; justify-content: center; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.paginacion a, .paginacion span { padding: .4rem .75rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--card); color: var(--texto); font-size: .88rem; }
.paginacion .actual { background: var(--primario); color: #fff; border-color: transparent; }

/* indicadores */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio); padding: .9rem 1rem; box-shadow: var(--sombra); display: block; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--primario); }
.kpi .v { font-size: 1.7rem; font-weight: 800; line-height: 1.1; } .kpi .t { color: var(--suave); font-size: .82rem; margin-top: .2rem; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.grid-2 > .tarjeta { margin-bottom: 0; }

/* datos clave-valor */
.datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem 1.2rem; margin: 0; }
.datos dt { font-size: .76rem; color: var(--suave); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.datos dd { margin: .1rem 0 0; font-weight: 500; word-break: break-word; }
.texto-largo { white-space: pre-wrap; }

/* línea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--borde); }
.timeline > li { position: relative; padding: 0 0 1.2rem 1rem; }
.timeline > li::before { content: ""; position: absolute; left: -1.62rem; top: .35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--primario); border: 3px solid var(--bg); }
.timeline .cab { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .25rem; }
.timeline .cab strong { font-size: 1rem; }
.lista-trabajos { margin: .3rem 0 0; padding-left: 1.1rem; } .lista-trabajos li { margin-bottom: .15rem; }

/* fotos */
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
.foto { position: relative; border-radius: 10px; overflow: hidden; background: var(--card-2); border: 1px solid var(--borde); aspect-ratio: 4/3; display: block; }
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto .etq { position: absolute; left: 6px; bottom: 6px; background: rgba(15,23,42,.75); color: #fff; font-size: .7rem; padding: 1px 7px; border-radius: 99px; }
.foto form { position: absolute; top: 4px; right: 4px; }
.subida { border: 2px dashed var(--borde); border-radius: var(--radio); padding: 1rem; text-align: center; margin-top: .8rem; }
.subida.arrastrando { border-color: var(--primario); background: var(--primario-suave); }
.progreso { height: 6px; border-radius: 99px; background: var(--borde); overflow: hidden; margin-top: .6rem; display: none; } .progreso > div { height: 100%; background: var(--primario); width: 0; transition: width .15s; }
.visor { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 100; display: none; align-items: center; justify-content: center; padding: 1rem; }
.visor.abierto { display: flex; } .visor img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.visor button { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 50%; width: 42px; height: 42px; font-size: 1.3rem; cursor: pointer; }

/* orden: barra de estado */
.pasos { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: 1rem; }
.pasos span { flex: none; padding: .3rem .7rem; border-radius: 99px; font-size: .78rem; background: var(--card-2); color: var(--suave); border: 1px solid var(--borde); }
.pasos span.hecho { background: var(--primario-suave); color: var(--primario); border-color: transparent; } .pasos span.actual { background: var(--primario); color: #fff; border-color: transparent; font-weight: 700; }
.totales { margin-left: auto; width: min(100%, 330px); }
.totales div { display: flex; justify-content: space-between; padding: .25rem 0; } .totales .total { font-weight: 800; font-size: 1.15rem; border-top: 1px solid var(--borde); margin-top: .3rem; padding-top: .5rem; }
.sugerencias { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: var(--card); border: 1px solid var(--borde); border-radius: 10px; box-shadow: var(--sombra); max-height: 280px; overflow-y: auto; }
.sugerencias button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .6rem .8rem; border-bottom: 1px solid var(--borde); font: inherit; color: inherit; cursor: pointer; }
.sugerencias button:hover { background: var(--card-2); } .sugerencias small { color: var(--suave); display: block; }
.rel { position: relative; }
.matriz td, .matriz th { text-align: center; } .matriz td:first-child, .matriz th:first-child { text-align: left; }
.matriz input { width: 18px; height: 18px; }

/* pantallas simples */
body.simple { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.simple-caja { width: 100%; max-width: 440px; }
.simple-marca { text-align: center; margin-bottom: 1.2rem; } .simple-marca h1 { font-size: 1.7rem; margin: 0; } .simple-marca p { color: var(--suave); margin: .2rem 0 0; }
.simple-pie { text-align: center; color: var(--suave); font-size: .8rem; margin-top: 1rem; }

/* ---------- celular / tableta ---------- */
@media (max-width: 960px) {
  .side { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-102%); transition: transform .2s; box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .side.abierto { transform: none; }
  .velo.abierto { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .solo-pc { display: none !important; }
  .topbar { padding: .55rem 1rem; }
  .contenido { padding: 1rem 1rem 6rem; }
  .banner { margin: .6rem 1rem 0; }
  .bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--borde); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: flex-end; }
  .bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; color: var(--suave); padding: 4px 0; text-decoration: none; }
  .bottom a.activo { color: var(--primario); font-weight: 700; }
  .bottom a.fab { flex: none; width: 54px; height: 54px; border-radius: 50%; background: var(--acento); color: #fff; justify-content: center; margin-top: -22px; box-shadow: 0 6px 16px rgba(249,115,22,.45); }
  .bottom a.fab .ico { width: 26px; height: 26px; }
  .tarjeta { padding: .95rem 1rem; }
}
@media (max-width: 700px) {
  .tabla-cards thead { display: none; }
  .tabla-cards, .tabla-cards tbody, .tabla-cards tr, .tabla-cards td { display: block; width: 100%; }
  .tabla-cards tr { border: 1px solid var(--borde); border-radius: 10px; padding: .4rem .7rem; margin-bottom: .6rem; background: var(--card); }
  .tabla-cards td { border: 0; padding: .3rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .tabla-cards td::before { content: attr(data-l); color: var(--suave); font-size: .78rem; font-weight: 600; text-align: left; flex: none; }
  .tabla-cards td.sin-etq::before { display: none; } .tabla-cards td.sin-etq { display: block; text-align: left; }
  .tabla-cards .num { text-align: right; }
  .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 1.25rem; }
}

/* ---------- impresión ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .side, .topbar, .bottom, .velo, .banner, .no-imprimir { display: none !important; }
  .contenido { padding: 0; max-width: none; } .tarjeta { box-shadow: none; border: 0; padding: 0; }
  .app { display: block; }
}
.impresion { max-width: 820px; margin: 0 auto; background: #fff; color: #111; padding: 1.5rem; }
.impresion h1 { font-size: 1.3rem; } .impresion .tabla th { color: #444; } .impresion .tabla td, .impresion .tabla th { border-bottom: 1px solid #ddd; }
.impresion .cab-doc { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid #111; padding-bottom: .6rem; margin-bottom: 1rem; }
.impresion .firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; margin-top: 3rem; text-align: center; } .impresion .firmas div { border-top: 1px solid #111; padding-top: .3rem; }
.impresion .fotos { grid-template-columns: repeat(4, 1fr); }

/* desplegables y detalles */
.desplegable { position: relative; }
.desplegable > summary { list-style: none; cursor: pointer; }
.desplegable > summary::-webkit-details-marker { display: none; }
.desplegable .lista { position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; background: var(--card); border: 1px solid var(--borde); border-radius: 10px; box-shadow: var(--sombra); min-width: 210px; padding: .3rem; }
.desplegable .lista a { display: block; padding: .55rem .75rem; border-radius: 8px; color: var(--texto); }
.desplegable .lista a:hover { background: var(--card-2); text-decoration: none; }
details > summary.btn { list-style: none; width: fit-content; }
details > summary.btn::-webkit-details-marker { display: none; }
.tag-lic { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.tag-lic.verde { background: var(--ok-bg); color: var(--ok); } .tag-lic.azul { background: var(--info-bg); color: var(--info); }
.tag-lic.amarillo, .tag-lic.naranja { background: var(--aviso-bg); color: var(--aviso); } .tag-lic.rojo { background: var(--err-bg); color: var(--err); }
.barra { height: 8px; border-radius: 99px; background: var(--borde); overflow: hidden; } .barra > div { height: 100%; background: var(--primario); }
.credencial { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; background: var(--card-2); border: 1px dashed var(--borde); border-radius: 10px; padding: .6rem .9rem; display: inline-block; user-select: all; }
