:root {
  --fondo: #f6f7f5; --panel: #ffffff; --texto: #1c2321; --sub: #5d6763; --borde: #dfe3e0;
  --primario: #14532d; --primario-h: #166534; --verde: #15803d; --ambar: #b45309; --rojo: #b91c1c;
  --verde-f: #dcfce7; --ambar-f: #fef3c7; --rojo-f: #fee2e2; --gris-f: #eef0ee;
  --naranja: #c2410c; --naranja-f: #ffedd5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #111513; --panel: #1a201d; --texto: #e6ebe8; --sub: #9aa59f; --borde: #2c3530;
    --primario: #22c55e; --primario-h: #4ade80; --verde: #4ade80; --ambar: #fbbf24; --rojo: #f87171;
    --verde-f: #14301f; --ambar-f: #3a2a0c; --rojo-f: #3b1414; --gris-f: #232a26;
    --naranja: #fb923c; --naranja-f: #3b2210;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fondo); color: var(--texto); }
main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
a { color: var(--primario); }
.sub { color: var(--sub); margin: 4px 0; font-size: 0.92rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
small { color: var(--sub); font-weight: 400; }

#barra { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--borde); }
#barra nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.marca { font-weight: 700; color: var(--primario); }

.caja { max-width: 440px; margin: 32px auto; background: var(--panel); border: 1px solid var(--borde); border-radius: 14px; padding: 28px; }
form { display: grid; gap: 14px; margin-top: 16px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 0.92rem; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 14px 0; }
input, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 8px; background: var(--fondo); color: var(--texto); width: 100%; }
input[type=file] { padding: 8px; }
input[type=checkbox], input[type=radio] { width: auto; margin: 0; }
input:focus, textarea:focus { outline: 2px solid var(--primario); outline-offset: 1px; }
.pass { display: flex; gap: 6px; }

button { font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--primario); background: var(--primario); color: #fff; cursor: pointer; }
@media (prefers-color-scheme: dark) { button { color: #08130c; } }
button:hover:not(:disabled) { background: var(--primario-h); }
button:disabled { opacity: 0.55; cursor: default; }
button.sec { background: transparent; color: var(--texto); border-color: var(--borde); }
button.sec:hover:not(:disabled) { background: var(--gris-f); }
button.peligro { background: transparent; color: var(--rojo); border-color: var(--rojo); }
button.chico { padding: 6px 10px; font-size: 0.85rem; }
.fila { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fila.fin { justify-content: flex-end; margin-top: 4px; }
.esp { flex: 1; }

.aviso { inset: auto; margin: 0; overflow: visible; position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 50; max-width: min(560px, calc(100% - 32px));
  padding: 12px 18px; border-radius: 10px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.aviso.ok { background: var(--verde-f); color: var(--verde); border: 1px solid var(--verde); }
.aviso.error { background: var(--rojo-f); color: var(--rojo); border: 1px solid var(--rojo); }
.aviso.info { background: var(--panel); color: var(--texto); border: 1px solid var(--borde); border-left: 4px solid var(--primario); }

.kit { border: 2px dashed var(--ambar); background: var(--ambar-f); border-radius: 10px; padding: 16px; margin: 12px 0; }
.kit .clave { font-size: 1.05rem; font-weight: 700; word-break: break-all; letter-spacing: 0.04em; }
.qr { width: 220px; margin: 12px auto; background: #fff; border-radius: 8px; padding: 4px; }
.qr svg { width: 100%; height: auto; display: block; }

.encabezado { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
#buscar { margin-bottom: 12px; }
.lista { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 14px 16px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.tarjeta > div:first-child { min-width: 0; flex: 1 1 280px; }
.acciones { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 0; }
.chip { font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.chip.verde { background: var(--verde-f); color: var(--verde); }
.chip.ambar { background: var(--ambar-f); color: var(--ambar); }
.chip.rojo { background: var(--rojo-f); color: var(--rojo); }
.chip.gris { background: var(--gris-f); color: var(--sub); }
.resultado { margin: 8px 0 0; font-size: 0.9rem; padding: 8px 10px; border-radius: 8px; background: var(--gris-f); word-break: break-word; }
.resultado.ok { background: var(--verde-f); color: var(--verde); }
.resultado.error { background: var(--rojo-f); color: var(--rojo); }
.vacio { text-align: center; color: var(--sub); padding: 40px 16px; border: 1px dashed var(--borde); border-radius: 12px; }

dialog { border: 1px solid var(--borde); border-radius: 14px; padding: 24px; width: min(520px, calc(100% - 32px)); background: var(--panel); color: var(--texto); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { margin-top: 0; }
.tabla { max-height: 60vh; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--borde); }
tr.alerta td { color: var(--rojo); }

@media print {
  body * { visibility: hidden; }
  .imprimible, .imprimible * { visibility: visible; }
  .imprimible { position: absolute; top: 0; left: 0; right: 0; border-color: #000; background: #fff; color: #000; }
}

.pestanas { flex: 1; }
#barra button.activo { background: var(--gris-f); border-color: var(--primario); color: var(--primario); }
.globo:not(:empty) { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px; background: var(--ambar); color: #fff; font-size: 0.75rem; line-height: 18px; text-align: center; }
fieldset.opciones { border: 1px solid var(--borde); border-radius: 8px; padding: 6px 12px; margin: 0; }
fieldset.opciones legend { font-weight: 600; font-size: 0.92rem; padding: 0 4px; }
fieldset.opciones label.check { margin: 6px 0; }
.fila.dos > label { flex: 1 1 160px; }
select { font: inherit; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 8px; background: var(--fondo); color: var(--texto); width: 100%; }

body:not([data-rol="admin"]):not([data-rol="admin-equipo"]) .solo-admin { display: none !important; }
body:not([data-rol="admin"]) .solo-dueno { display: none !important; }
body[data-rol="equipo"] .solo-no-equipo { display: none !important; }
.tarjeta.pendiente { border-style: dashed; }
label.check span { font-weight: 400; }
fieldset.opciones label.check { align-items: flex-start; }
fieldset.opciones label.check input { margin-top: 4px; }
#inv-enlace { margin: 12px 0; font-size: 0.85rem; }

.tarjeta.grupo { border-color: var(--primario); background: var(--verde-f); }
#grupos:not(:empty) { margin-bottom: 10px; }
@media (max-width: 560px) {
  .acciones { width: 100%; }
  .acciones button { flex: 1 1 auto; }
  .encabezado .fila button { flex: 1 1 auto; }
  #barra nav { gap: 6px; }
  .caja { margin: 16px auto; padding: 20px; }
}

button.ancho { width: 100%; margin-top: 8px; }
ol.pasos { padding-left: 20px; margin: 8px 0; }
ol.pasos li { margin: 6px 0; }

.sin-permiso { display: none !important; }
.lista-checks { max-height: 240px; overflow: auto; border: 1px solid var(--borde); border-radius: 8px; padding: 4px 10px; margin-top: 6px; }
.lista-checks label.check { margin: 6px 0; }
#dlg-permisos { width: min(600px, calc(100% - 32px)); }

/* ---------- Consulta ---------- */
main:has(#v-consulta:not([hidden])) { max-width: 1400px; }
.filtros { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: flex-end; }
.filtros label { flex: 1 1 160px; }
.filtros label:first-child { flex: 2 1 260px; }
.filtros input[type=search] { flex: 3 1 260px; width: auto; }
.filtros select { flex: 1 1 150px; width: auto; }
.segmento { display: inline-flex; border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; }
.segmento button { border: 0; border-radius: 0; background: transparent; color: var(--texto); padding: 10px 14px; }
.segmento button.activo { background: var(--primario); color: #fff; }
@media (prefers-color-scheme: dark) { .segmento button.activo { color: #08130c; } }
.aviso-fijo { background: var(--ambar-f); color: var(--ambar); border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; }
.tabla-con { overflow: auto; max-height: 70vh; border: 1px solid var(--borde); border-radius: 10px; background: var(--panel); }
table.consulta { font-size: 0.85rem; white-space: nowrap; }
table.consulta th { position: sticky; top: 0; background: var(--gris-f); cursor: pointer; user-select: none; z-index: 1; }
table.consulta tfoot td { position: sticky; bottom: 0; background: var(--gris-f); font-weight: 700; }
table.consulta tbody tr { cursor: pointer; }
table.consulta tbody tr:hover { background: var(--verde-f); }
table.consulta tr.cancelado { background: var(--naranja-f); }
table.consulta tr.cancelado td { color: var(--naranja); }
table.consulta tr.cancelado:hover { background: var(--naranja-f); filter: brightness(0.97); }
table.consulta tr.egreso { background: var(--verde-f); }
table.consulta tr.egreso td { color: var(--verde); }
table.consulta td.recorta { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.lista-checks.alta { max-height: 55vh; }
#dlg-detalle { width: min(760px, calc(100% - 32px)); }
#dlg-detalle h3 { font-size: 0.95rem; margin: 16px 0 6px; }
table.det { font-size: 0.85rem; margin-bottom: 6px; }
table.det th { width: 32%; color: var(--sub); font-weight: 600; }
@media (max-width: 640px) {
  .tabla-con { max-height: none; border: 0; background: transparent; }
  table.consulta, table.consulta tbody, table.consulta tfoot { display: block; white-space: normal; }
  table.consulta thead { display: none; }
  table.consulta tr { display: block; background: var(--panel); border: 1px solid var(--borde); border-radius: 10px; margin-bottom: 8px; padding: 6px 10px; }
  table.consulta td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 3px 0; }
  table.consulta td::before { content: attr(data-label); color: var(--sub); font-weight: 600; }
  table.consulta td.recorta { max-width: none; }
  table.consulta tfoot td { position: static; }
  table.consulta tfoot td:empty, table.consulta tfoot td[data-label=""] { display: none; }
}

/* Barra superior compacta en celular: una línea que se desliza de lado */
@media (max-width: 640px) {
  #barra { flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding: 8px 12px; scrollbar-width: none; }
  #barra::-webkit-scrollbar { display: none; }
  #barra nav { flex-wrap: nowrap; flex: 0 0 auto; }
  #barra .marca { flex: 0 0 auto; font-size: 0.95rem; }
  #barra button.chico { white-space: nowrap; }
}

@media (max-width: 640px) {
  table.consulta tr.cancelado { border: 2px solid var(--naranja); }
  table.consulta tr.egreso { border: 2px solid var(--verde); }
}
.csf-captcha { display: flex; align-items: center; justify-content: center; min-height: 80px; margin: 8px 0 12px; padding: 10px; border: 1px solid var(--borde); border-radius: 10px; background: #fff; }
.csf-captcha img { max-width: 100%; height: auto; image-rendering: auto; }
.csf-captcha img:not([src]) { display: none; }
#f-csf input[name=captcha] { font-size: 1.3rem; letter-spacing: 0.15em; }
.resultado.naranja { background: var(--naranja-f); color: var(--naranja); }

/* ===================== MENÚ PRINCIPAL ===================== */
#menu a, .menu-mas { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--texto); text-decoration: none; font-weight: 600; font-size: 0.95rem;
  background: transparent; border: 0; width: 100%; cursor: pointer; position: relative; }
#menu a:hover, .menu-mas:hover:not(:disabled) { background: var(--gris-f); }
#menu a.activo { background: var(--verde-f); color: var(--primario); }
.ico { width: 20px; height: 20px; flex: 0 0 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#menu .globo:not(:empty) { margin-left: auto; }
.globo.rojo:not(:empty) { background: var(--rojo); }
#menu .sep { border-top: 1px solid var(--borde); margin: 8px 4px; }
.menu-pie { margin-top: auto; padding: 10px; font-size: 0.82rem; color: var(--sub); word-break: break-word; }

/* Computadora: menú fijo a la izquierda */
@media (min-width: 761px) {
  body.con-menu { padding-left: 220px; }
  #menu { position: fixed; top: 0; left: 0; bottom: 0; width: 220px; z-index: 6; display: flex; flex-direction: column; gap: 2px;
    padding: 16px 12px; background: var(--panel); border-right: 1px solid var(--borde); overflow-y: auto; }
  #menu .marca { font-size: 1.1rem; padding: 4px 10px 14px; }
  #menu-extra { display: contents; }
  .menu-mas, #barra { display: none !important; }
}
/* Celular: barra abajo; "Más" abre Usuarios y Mi usuario */
@media (max-width: 760px) {
  body.con-menu { padding-bottom: 76px; }
  #barra { justify-content: space-between; }
  #menu { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; align-items: stretch;
    background: var(--panel); border-top: 1px solid var(--borde); padding: 4px 4px calc(6px + env(safe-area-inset-bottom)); }
  #menu .marca, #menu .sep, .menu-pie { display: none; }
  #menu > a, .menu-mas { flex-direction: column; gap: 2px; font-size: 0.7rem; padding: 6px 2px; width: auto; flex: 1 1 0; color: var(--sub); }
  #menu > a.activo { background: transparent; color: var(--primario); }
  #menu > a .globo:not(:empty) { position: absolute; top: 0; left: calc(50% + 4px); margin: 0; min-width: 16px; line-height: 16px; font-size: 0.65rem; }
  #menu-extra { display: none; }
  body.mas-abierto #menu-extra { display: flex; flex-direction: column; gap: 2px; position: fixed; right: 8px; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 21;
    min-width: 200px; padding: 6px; background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.18); }
  body.mas-abierto .menu-mas { color: var(--primario); }
  .aviso { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* ===================== INICIO ===================== */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0 8px; }
.kpi { background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 12px 14px; }
.kpi b { display: block; font-size: 1.6rem; line-height: 1.2; }
.kpi b.rojo { color: var(--rojo); }
.kpi span { color: var(--sub); font-size: 0.85rem; }
h2.nivel { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin: 18px 0 8px; }
h2.nivel::before { content: ""; width: 10px; height: 10px; border-radius: 99px; background: currentColor; }
h2.nivel.r::before { background: var(--rojo); } h2.nivel.a::before { background: var(--naranja); } h2.nivel.z::before { background: #2563eb; }
.aviso-ini { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--borde); border-left: 4px solid; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.aviso-ini.r { border-left-color: var(--rojo); } .aviso-ini.a { border-left-color: var(--naranja); } .aviso-ini.z { border-left-color: #2563eb; }
.aviso-ini .t { flex: 1; min-width: 0; }
.aviso-ini .t strong { display: block; }
.aviso-ini .t span { color: var(--sub); font-size: 0.88rem; }
.aviso-ini button { white-space: nowrap; }
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .aviso-ini { flex-wrap: wrap; }
  .aviso-ini button { width: 100%; }
}
/* Los filtros nunca más anchos que la pantalla (nombres largos de cliente) */
.filtros label, .filtros select, .filtros input { min-width: 0; max-width: 100%; }
.filtros label select { width: 100%; text-overflow: ellipsis; }

/* Tarjeta de cliente: se toca para abrir su ficha */
.tarjeta.clic { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.tarjeta.clic:hover { border-color: var(--primario); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.tarjeta.clic:focus-visible { outline: 2px solid var(--primario); outline-offset: 2px; }

/* Pestañas dentro de una sección (Descargas: Facturas | Constancias | …) */
.pestanas-sec { display: flex; gap: 4px; border-bottom: 1px solid var(--borde); margin: 12px 0 16px; overflow-x: auto; scrollbar-width: none; }
.pestanas-sec::-webkit-scrollbar { display: none; }
.pestanas-sec button { background: transparent; color: var(--sub); border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 14px; white-space: nowrap; }
.pestanas-sec button:hover:not(:disabled) { background: var(--gris-f); }
.pestanas-sec button.activa { color: var(--primario); border-bottom-color: var(--primario); }
.pestanas-sec button:disabled { opacity: .5; }
#pest-facturas > .encabezado { margin-top: 0; }

/* Importar clientes */
dialog.ancho { width: min(860px, calc(100% - 24px)); }
.imp-tabla { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.imp-tabla th, .imp-tabla td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--borde); vertical-align: top; }
.imp-tabla th { position: sticky; top: 0; background: var(--panel); font-size: 0.8rem; color: var(--sub); }
.imp-tabla tr.apagado td { opacity: .65; }
.imp-tabla input[type=checkbox] { width: 18px; height: 18px; }
#dlg-importar ol.pasos button { margin-left: 6px; }
@media (max-width: 640px) {
  .imp-tabla thead { display: none; }
  .imp-tabla tr { display: grid; grid-template-columns: 28px 1fr; gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--borde); }
  .imp-tabla td { border: 0; padding: 0; }
  .imp-tabla td:first-child { grid-row: span 4; }
  .imp-tabla td[data-et]::before { content: attr(data-et) ": "; color: var(--sub); }
}

/* Consultas: un solo mes con flechas */
.mes-nav { display: flex; gap: 6px; align-items: stretch; }
.mes-nav input { flex: 1; min-width: 0; }
.mes-nav button { padding: 8px 12px; }
button.csf-ok { background: var(--verde-f); color: var(--verde); border-color: var(--verde); }
button.csf-vencida { background: var(--naranja-f); color: var(--naranja); border-color: var(--naranja); }

/* Régimen fiscal */
.chip.resico { background: #ede9fe; color: #5b21b6; }
fieldset.regimenes { border: 1px solid var(--borde); border-radius: 10px; padding: 8px 12px 10px; margin: 4px 0 8px; }
fieldset.regimenes legend { font-weight: 600; padding: 0 4px; }
#cli-regimenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 10px; max-height: 190px; overflow-y: auto; }
label.chk { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; padding: 3px 0; cursor: pointer; }
label.chk input { width: 16px; height: 16px; margin: 0; flex: 0 0 16px; }
#v-clientes .filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
#v-clientes .filtros input { flex: 1 1 220px; }
#v-clientes .filtros select { flex: 0 1 240px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.resico { background: #3b2a6b; color: #ddd6fe; } }
#v-clientes .filtros #buscar { margin-bottom: 0; }
.con-regimen { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 12px; }
.con-regimen .chip { border-radius: 8px; white-space: normal; }
button.peligro-lleno { background: var(--rojo); color: #fff; border-color: var(--rojo); }

/* Instalar la app (pantalla de entrada) */
.caja-instalar { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--borde); text-align: center; }
.caja-instalar button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.caja-instalar .sub { margin-top: 6px; font-size: 0.85rem; }

/* Proveedores en la lista 69-B */
.efos-cliente { background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.efos-cliente h3 { margin: 0 0 8px; font-size: 1rem; }
table.efos { width: 100%; }
table.efos tbody tr { cursor: pointer; }
table.efos tbody tr:hover { background: var(--gris-f); }
@media (max-width: 640px) {
  table.efos thead { display: none; }
  table.efos tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--borde); }
  table.efos td { border: 0; padding: 0; text-align: left; }
  table.efos td[data-et] { grid-column: 1 / -1; }
  table.efos td[data-et]::before { content: attr(data-et) ": "; color: var(--sub); }
}
/* En pantallas táctiles el "hover" se queda pegado después de tocar: se quita en los segmentos y pestañas */
@media (hover: none) {
  .segmento button:not(.activo):hover, .pestanas-sec button:not(.activa):hover { background: transparent; color: inherit; filter: none; }
}

/* Buzón Tributario */
ul.bz-msjs { margin: 8px 0 0; padding-left: 18px; font-size: 0.9rem; }
ul.bz-msjs li { margin: 2px 0; }
ul.bz-msjs li.nuevo { font-weight: 600; }
ul.bz-msjs li.nuevo::after { content: " · nuevo"; color: var(--rojo); font-weight: 600; }

/* ===================== VERSIÓN / ACTUALIZAR ===================== */
.barra-actualizar { position: fixed; top: 0; left: 0; right: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: var(--ambar-f); color: var(--texto, #1a1a1a); border-bottom: 1px solid var(--ambar);
  box-shadow: 0 4px 16px rgba(0,0,0,.12); font-size: 0.95rem; }
.barra-actualizar[hidden] { display: none; }
.barra-actualizar button { margin: 0; }
.menu-ver { margin-top: 6px; font-size: 0.75rem; opacity: .8; }
.version-app { text-align: center; margin-top: 18px; font-size: 0.8rem; }

/* ===================== FRENO DE LA CIEC ===================== */
.freno-ciec { border: 1px solid var(--ambar); background: var(--ambar-f); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.freno-ciec p { margin: 0 0 8px; font-weight: 600; color: var(--texto); }
.freno-ciec.pausa { border-color: var(--rojo); background: var(--rojo-f); }
.freno-ciec.pausa p { margin: 0; }
.freno-ciec .casilla { display: flex; gap: 8px; align-items: center; font-weight: 600; margin: 0; }
.freno-ciec .casilla input { width: auto; margin: 0; }
.freno-ciec[hidden], .freno-ciec .casilla[hidden] { display: none; }

/* ===================== AYUDA ===================== */
#dlg-ayuda { width: min(640px, calc(100% - 32px)); max-height: calc(100vh - 48px); }
.ayuda-cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ayuda-cab h2 { margin: 0; }
.ayuda details { border: 1px solid var(--borde); border-radius: 10px; margin: 8px 0; background: var(--panel); }
.ayuda summary { cursor: pointer; padding: 12px 14px; font-weight: 700; }
.ayuda details[open] summary { border-bottom: 1px solid var(--borde); }
.ayuda ul { margin: 10px 0 12px; padding: 0 16px 0 32px; }
.ayuda li { margin: 6px 0; line-height: 1.45; }
#f-descarga .casilla { display: flex; gap: 8px; align-items: center; font-weight: 600; margin: 4px 0 10px; }
#f-descarga .casilla input { width: auto; margin: 0; }

/* ===================== EXPEDIENTE DEL CLIENTE ===================== */
.volver { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.exp-cab h1 { word-break: break-word; }
.exp-cab .chip { margin-left: 6px; }
.exp-estado { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 14px 0 4px; }
.exp-caja { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: var(--panel); color: var(--texto);
  border: 1px solid var(--borde); border-top: 4px solid var(--borde); border-radius: 12px; padding: 10px 12px; font-weight: 400; min-width: 0; }
.exp-caja:hover:not(:disabled) { background: var(--gris-f); }
.exp-caja span { color: var(--sub); font-size: 0.8rem; }
.exp-caja b { font-size: 1rem; line-height: 1.25; overflow-wrap: anywhere; }
.exp-caja small { font-size: 0.78rem; }
.exp-caja.ok { border-top-color: var(--verde); } .exp-caja.ok b { color: var(--verde); }
.exp-caja.ojo { border-top-color: var(--ambar); } .exp-caja.ojo b { color: var(--ambar); }
.exp-caja.mal { border-top-color: var(--rojo); } .exp-caja.mal b { color: var(--rojo); }
.exp-caja.gris b { color: var(--sub); }
.exp-bloque { background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.exp-bloque h2 { font-size: 1rem; margin-bottom: 6px; }
.exp-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 6px 0 0; }
.exp-dl dt { color: var(--sub); font-size: 0.9rem; }
.exp-dl dd { margin: 0; overflow-wrap: anywhere; }
.exp-mas { margin-top: 10px; border-top: 1px solid var(--borde); padding-top: 8px; }
.exp-mas summary { cursor: pointer; font-weight: 600; }
.exp-mas ul { margin: 8px 0 0; padding-left: 20px; }
.exp-mas li { margin: 4px 0; }
#exp-notas { width: 100%; min-height: 180px; }
.fila-contacto { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
@media (max-width: 860px) { .exp-estado { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .exp-estado { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .exp-caja:last-child:nth-child(odd) { grid-column: span 2; }
  .exp-caja { padding: 8px 10px; }
  .exp-dl { grid-template-columns: 1fr; gap: 0; }
  .exp-dl dt { margin-top: 8px; }
  .fila-contacto { grid-template-columns: 1fr; }
  .exp-cab .fila { width: 100%; } .exp-cab .fila button { flex: 1; }
}

/* ===================== DOCUMENTOS DEL CLIENTE ===================== */
.exp-papeles-acc { margin-bottom: 10px; }
.pap-tit { list-style: none; color: var(--sub); font-size: 0.9rem; margin: 12px 0 4px; }
.rojo-t { color: var(--rojo); } .verde-t { color: var(--verde); }
.exp-doc.nuevo { border-color: var(--rojo); }
#pedir-items { display: grid; gap: 6px; margin-bottom: 8px; }
#pedir-items small { color: var(--sub); }
/* Página pública de subida */
body.publico { background: var(--fondo); }
main.subir { max-width: 560px; padding-top: 20px; }
.marca-pub { font-weight: 700; color: var(--primario); margin: 0 0 16px; }
.boton-archivo { display: inline-block; font-weight: 600; padding: 10px 16px; border-radius: 8px; background: var(--primario); color: #fff; cursor: pointer; text-align: center; }
.boton-archivo.sec { background: var(--panel); color: var(--texto); border: 1px solid var(--borde); }
.boton-archivo.deshab { opacity: .5; pointer-events: none; }
.sub-item.listo { border-color: var(--verde); }
.estado.bien { color: var(--verde); font-weight: 600; } .estado.mal { color: var(--rojo); }
@media (max-width: 600px) { .sub-item { flex-direction: column; align-items: stretch; } .sub-item .boton-archivo { display: block; width: 100%; } }
.sub-item { display: block; }
.sub-item .acciones { margin-top: 10px; }
@media (max-width: 600px) {
  #v-expediente .pestanas-sec button { padding: 10px 9px; }
  .exp-papeles-acc { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .exp-papeles-acc button { width: 100%; margin: 0; }
}

/* ===================== FASE 3: honorarios, declaraciones, RESICO, bitácora ===================== */
.hon-linea { margin: 4px 0 10px; }
.hon-acc { gap: 8px; flex-wrap: wrap; }
.enlace-mini { background: none; border: 0; color: var(--rojo); padding: 0 4px; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
ul.obl { list-style: none; margin: 4px 0 6px; padding: 0; }
ul.obl li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--borde); }
ul.obl li:last-child { border-bottom: 0; }
ul.obl li > div:first-child { min-width: 0; }
ul.obl b { display: block; font-weight: 600; font-size: 0.95rem; }
ul.obl .sub { margin: 0; font-size: 0.85rem; }
.obl-der { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.barra-tope { height: 10px; background: var(--gris-f); border-radius: 99px; overflow: hidden; margin: 6px 0; }
.barra-tope span { display: block; height: 100%; background: var(--verde); }
.barra-tope span.ambar { background: var(--ambar); } .barra-tope span.rojo { background: var(--rojo); }
.fila-bit { display: flex; gap: 8px; margin: 6px 0 10px; }
.fila-bit input { flex: 1; min-width: 0; margin: 0; }
.fila-bit button { margin: 0; }
ul.bitacora { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
ul.bitacora li { padding: 8px 0; border-bottom: 1px solid var(--borde); }
ul.bitacora li .sub { display: block; margin: 0; font-size: 0.8rem; }
@media (max-width: 600px) {
  ul.obl li { flex-direction: column; align-items: stretch; gap: 6px; }
  .obl-der { justify-content: space-between; }
  .hon-acc button { flex: 1 1 45%; }
}

/* Declaraciones presentadas */
.decl-acc { gap: 8px; align-items: center; }
.decl-acc select { width: auto; margin: 0; }
.decl-acc button { margin: 0; }
.decl-mes { margin-top: 12px; }
.decl-mes > b { display: block; margin-bottom: 4px; }
.decl-fila { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--borde); }
.decl-fila > div:first-child { min-width: 0; display: flex; flex-direction: column; }
.decl-fila .sub { margin: 0; font-size: 0.85rem; overflow-wrap: anywhere; }
.exp-sub { font-size: 1rem; margin: 18px 0 8px; }
@media (max-width: 600px) { .decl-fila { flex-direction: column; align-items: stretch; } .decl-fila .obl-der { flex-wrap: wrap; } }
.decl-nota { margin-top: 10px; font-size: 0.85rem; }
/* Inicio: poner todo al día */
.ini-aldia { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; margin: 14px 0; border: 1px solid var(--borde); border-left: 4px solid var(--primario); border-radius: 12px; background: var(--panel); }
.ini-aldia > div { min-width: 0; }
.ini-aldia .sub { margin: 4px 0 0; overflow-wrap: anywhere; }
.ini-aldia button { margin: 0; flex-shrink: 0; }
.ini-aldia.ok { border-left-color: var(--verde); }
@media (max-width: 600px) { .ini-aldia { flex-direction: column; align-items: stretch; } }

/* Menú: Buzón y 69-B debajo de Consultas (en celular van en "Más") */
#menu a.menu-sub { padding-left: 22px; font-weight: 500; font-size: 0.9rem; }
#menu a.menu-sub .ico { width: 17px; height: 17px; flex-basis: 17px; }
.sep-mas { border-top: 1px solid var(--borde); margin: 4px 6px; }
@media (min-width: 761px) { #menu .menu-solo-cel { display: none !important; } }
@media (max-width: 760px) { #menu > a.menu-solo-pc { display: none !important; } #menu-extra a.menu-sub { padding-left: 10px; } }
/* Consultas: botón al expediente a la derecha de las pestañas */
.pestanas-sec .pest-exp { margin-left: auto; align-self: center; border: 1px solid var(--borde); border-radius: 8px; padding: 6px 12px; color: var(--texto); white-space: nowrap; }
.vacio.sin-mov p { color: var(--texto); font-weight: 600; }
.resultado.info { background: var(--gris-f); color: var(--texto); border-left: 4px solid var(--primario); }

/* Página pública: recibir e.firma */
.sub-fiel { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.sub-fiel label { display: flex; flex-direction: column; gap: 4px; }
.sub-fiel button { align-self: flex-start; }
