/* FirmaFast Web — mismos colores e ideas visuales que la app */
:root {
  --azul: #1E7CC0;
  --azul-oscuro: #14599A;
  --celeste: #35A2DC;
  --fondo: #F4F8FC;
  --texto: #1C2B3A;
  --borde: #E3EAF2;
  --degradado: linear-gradient(135deg, #35A2DC 0%, #1E7CC0 45%, #14599A 100%);
  --sombra: 0 6px 24px rgba(20, 89, 154, .08);
  --radio: 18px;

  /* Tonos pastel por sección: [fuerte, suave] */
  --cielo: #1E88C8;   --cielo-s: #E2F2FC;
  --azul-t: #1E6FB8;  --azul-s: #E3EDFA;
  --menta: #0F9B7F;   --menta-s: #DDF5EE;
  --durazno: #E07A1F; --durazno-s: #FFEEDD;
  --lila: #7655D3;    --lila-s: #EDE7FB;
  --rosa: #D9467F;    --rosa-s: #FCE5EE;
  --limon: #8A9A16;   --limon-s: #F3F7D9;
  --rojo: #D64545;    --rojo-s: #FDE6E6;
  --verde: #2E9D4A;   --verde-s: #E2F5E6;
  --gris: #5B6B7B;    --gris-s: #EDF1F5;

  --bs-primary: #1E7CC0;
  --bs-primary-rgb: 30, 124, 192;
  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--texto);
  --bs-body-bg: var(--fondo);
  --bs-border-color: var(--borde);
  --bs-link-color: var(--azul);
  --bs-link-hover-color: var(--azul-oscuro);
}

body { background: var(--fondo); color: var(--texto); min-height: 100vh; }
h1, h2, h3, h4, h5, .fw-bold { letter-spacing: -.01em; }
a { text-decoration: none; }

/* ---------------------------------------------------------------- botones */
.btn { border-radius: 12px; font-weight: 600; padding: .55rem 1rem; }
.btn-sm { border-radius: 10px; padding: .35rem .75rem; }
.btn-primary { background: var(--azul); border-color: var(--azul); }
.btn-primary:hover, .btn-primary:focus { background: var(--azul-oscuro); border-color: var(--azul-oscuro); }
.btn-marca { background: var(--degradado); color: #fff; border: 0; box-shadow: 0 6px 18px rgba(30, 124, 192, .35); }
.btn-marca:hover { color: #fff; filter: brightness(1.06); }
.btn-suave { background: var(--azul-s); color: var(--azul-t); border: 0; }
.btn-suave:hover { background: #d4e4f8; color: var(--azul-oscuro); }
.btn-verde { background: var(--verde); color: #fff; border: 0; }
.btn-verde:hover { background: #26843e; color: #fff; }
.form-control, .form-select { border-radius: 12px; border-color: var(--borde); padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--celeste); box-shadow: 0 0 0 .2rem rgba(53, 162, 220, .2); }
.form-label { font-weight: 600; font-size: .875rem; margin-bottom: .3rem; }
.form-text { font-size: .8rem; }

/* ---------------------------------------------------------------- estructura */
.lateral {
  position: fixed; inset: 0 auto 0 0; width: 256px; z-index: 1030;
  background: #fff; border-right: 1px solid var(--borde);
  display: flex; flex-direction: column; transition: transform .25s ease;
}
.lateral .marca {
  background: var(--degradado); color: #fff; padding: 18px 20px; display: flex; align-items: center; gap: 12px;
}
.lateral .marca img { width: 40px; height: 40px; object-fit: contain; }
.lateral .marca b { font-size: 1.05rem; display: block; line-height: 1.1; }
.lateral .marca small { opacity: .85; font-size: .75rem; }
.lateral nav { padding: 10px; overflow-y: auto; flex: 1; }
.lateral .grupo { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gris); margin: 14px 12px 6px; font-weight: 700; }
.lateral a.item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px;
  color: var(--texto); font-weight: 600; font-size: .92rem; margin-bottom: 2px;
}
.lateral a.item .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 1.05rem; }
.lateral a.item:hover { background: var(--fondo); }
.lateral a.item.activo { background: var(--azul-s); color: var(--azul-oscuro); }
.lateral .pie { padding: 12px 16px; border-top: 1px solid var(--borde); font-size: .8rem; color: var(--gris); }

.principal { margin-left: 256px; min-height: 100vh; display: flex; flex-direction: column; }
.barra {
  position: sticky; top: 0; z-index: 1020; background: rgba(244, 248, 252, .85); backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--borde);
}
.barra h1 { font-size: 1.2rem; margin: 0; font-weight: 800; }
.barra .usuario { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 12px; background: var(--degradado); color: #fff; display: grid; place-items: center; font-weight: 800; }
.contenido { padding: 24px; flex: 1; width: 100%; max-width: 1280px; }
.btn-menu { display: none; }

@media (max-width: 991.98px) {
  .lateral { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  body.menu-abierto .lateral { transform: none; }
  body.menu-abierto .velo { display: block; }
  .principal { margin-left: 0; }
  .btn-menu { display: inline-flex; }
  .contenido { padding: 16px; padding-bottom: 96px; }
  .barra { padding: 10px 16px; }
  .barra .usuario .nombre { display: none; }
}
.velo { display: none; position: fixed; inset: 0; background: rgba(20, 40, 60, .35); z-index: 1025; }

/* Navegación inferior en el teléfono */
.nav-movil {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1020; background: #fff;
  border-top: 1px solid var(--borde); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.nav-movil a { flex: 1; text-align: center; font-size: .7rem; font-weight: 600; color: var(--gris); padding: 4px 0; border-radius: 12px; }
.nav-movil a i { display: block; font-size: 1.3rem; }
.nav-movil a.activo { color: var(--azul); background: var(--azul-s); }
.nav-movil a.central i { width: 48px; height: 48px; margin: -22px auto 2px; border-radius: 16px; background: var(--degradado); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 18px rgba(30, 124, 192, .4); }
@media (max-width: 991.98px) { .nav-movil { display: flex; } }

/* ---------------------------------------------------------------- tarjetas */
.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); }
.tarjeta-cuerpo { padding: 20px; }
.tarjeta-titulo { font-weight: 800; font-size: 1rem; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tarjeta-titulo .acciones { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 575.98px) {
  .tarjeta-titulo { flex-wrap: wrap; }
  .tarjeta-titulo .acciones { margin-left: 0; width: 100%; justify-content: flex-start; }
  .periodo-rango { width: 100%; }
  .periodo-rango input { flex: 1; min-width: 0; }
}

.encabezado-marca { background: var(--degradado); color: #fff; border-radius: 24px; padding: 24px; position: relative; overflow: hidden; }
.encabezado-marca::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.encabezado-marca .sub { opacity: .85; }

.ico-tono { width: 44px; height: 44px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 1.25rem; flex: none; }
.ico-tono.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; }
.ico-tono.lg { width: 56px; height: 56px; border-radius: 18px; font-size: 1.6rem; }

.dato { border-radius: var(--radio); padding: 16px; height: 100%; }
.dato .t { font-size: .8rem; font-weight: 700; opacity: .85; display: flex; align-items: center; gap: 6px; }
.dato .v { font-size: 1.45rem; font-weight: 800; margin-top: 4px; letter-spacing: -.02em; }
.dato small { opacity: .8; }

.accion {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radio);
  color: var(--texto); transition: transform .15s ease, box-shadow .15s ease; height: 100%;
}
.accion:hover { transform: translateY(-2px); box-shadow: var(--sombra); color: var(--texto); }
.accion b { display: block; }
.accion small { opacity: .75; }

/* Tonos: fondo suave + texto fuerte */
.t-cielo { background: var(--cielo-s); color: var(--cielo); }
.t-azul { background: var(--azul-s); color: var(--azul-t); }
.t-menta { background: var(--menta-s); color: var(--menta); }
.t-durazno { background: var(--durazno-s); color: var(--durazno); }
.t-lila { background: var(--lila-s); color: var(--lila); }
.t-rosa { background: var(--rosa-s); color: var(--rosa); }
.t-limon { background: var(--limon-s); color: var(--limon); }
.t-rojo { background: var(--rojo-s); color: var(--rojo); }
.t-verde { background: var(--verde-s); color: var(--verde); }
.t-gris { background: var(--gris-s); color: var(--gris); }
.dato.t-cielo .v, .dato.t-azul .v, .dato.t-menta .v, .dato.t-durazno .v, .dato.t-lila .v,
.dato.t-rosa .v, .dato.t-limon .v, .dato.t-rojo .v, .dato.t-verde .v, .dato.t-gris .v { color: var(--texto); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.chip-verde { background: var(--verde-s); color: var(--verde); }
.chip-cielo { background: var(--cielo-s); color: var(--cielo); }
.chip-durazno { background: var(--durazno-s); color: var(--durazno); }
.chip-rojo { background: var(--rojo-s); color: var(--rojo); }
.chip-gris { background: var(--gris-s); color: var(--gris); }
.chip-lila { background: var(--lila-s); color: var(--lila); }
.chip-limon { background: var(--limon-s); color: var(--limon); }
.chip-azul { background: var(--azul-s); color: var(--azul-t); }

/* ---------------------------------------------------------------- tablas */
.tabla { margin: 0; font-size: .9rem; }
.tabla thead th { background: var(--azul-s); color: var(--azul-oscuro); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; border: 0; padding: 10px 12px; white-space: nowrap; }
.tabla thead th:first-child { border-top-left-radius: 12px; }
.tabla thead th:last-child { border-top-right-radius: 12px; }
.tabla td { padding: 11px 12px; vertical-align: middle; border-color: var(--borde); }
.tabla tbody tr.fila-link { cursor: pointer; }
.tabla tbody tr.fila-link:hover td { background: #F7FAFE; }
.tabla tfoot td { font-weight: 800; background: var(--gris-s); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filtros .form-control, .filtros .form-select { width: auto; }
.pildora { border: 1px solid var(--borde); background: #fff; color: var(--texto); border-radius: 999px; padding: 6px 14px; font-size: .85rem; font-weight: 600; }
.pildora.activa, .pildora:hover { background: var(--azul); border-color: var(--azul); color: #fff; }

.vacio { text-align: center; padding: 48px 16px; color: var(--gris); }
.vacio i { font-size: 2.6rem; display: block; margin-bottom: 8px; opacity: .7; }

.aviso-tono { border-radius: 16px; padding: 12px 16px; display: flex; gap: 12px; align-items: flex-start; font-size: .9rem; }
.aviso-tono i { font-size: 1.2rem; }

/* ---------------------------------------------------------------- factura */
.linea { display: grid; grid-template-columns: minmax(140px, 1fr) 86px 96px 86px 92px 76px; gap: 6px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--borde); }
.linea .desc b { display: block; font-size: .92rem; }
.linea .desc small { color: var(--gris); }
.linea input { text-align: right; }
.linea-cab { font-size: .72rem; text-transform: uppercase; color: var(--gris); font-weight: 700; border-bottom: 1px solid var(--borde); }
@media (max-width: 767.98px) {
  .linea { grid-template-columns: 1fr 1fr 1fr; }
  .linea .desc { grid-column: 1 / -1; }
  .linea-cab { display: none; }
  .linea .quitar { grid-column: 3; justify-self: end; }
}
.totales .fila { display: flex; justify-content: space-between; padding: 4px 0; }
.totales .total { font-size: 1.5rem; font-weight: 800; border-top: 2px solid var(--borde); margin-top: 6px; padding-top: 10px; }
.resultados { position: absolute; z-index: 1000; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--borde); border-radius: 14px; box-shadow: 0 14px 40px rgba(20, 60, 100, .18); max-height: 340px; overflow-y: auto; margin-top: 4px; }
.resultados button { display: flex; width: 100%; border: 0; background: none; text-align: left; padding: 10px 14px; gap: 10px; align-items: center; border-bottom: 1px solid var(--borde); }
.resultados button:hover, .resultados button.sel { background: var(--azul-s); }
.resultados .precio { margin-left: auto; font-weight: 800; white-space: nowrap; }
.barra-emitir { position: sticky; bottom: 0; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-top: 1px solid var(--borde); padding: 12px 0; margin-top: 16px; z-index: 10; }
@media (max-width: 991.98px) { .barra-emitir { bottom: 64px; } }

/* ---------------------------------------------------------------- ingreso */
.pantalla-ingreso { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.pantalla-ingreso .lado-marca { background: var(--degradado); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.pantalla-ingreso .lado-marca::before { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(255, 255, 255, .07); right: -140px; bottom: -140px; }
.pantalla-ingreso .lado-marca img { width: 96px; margin-bottom: 24px; }
.pantalla-ingreso .lado-marca h1 { font-weight: 800; font-size: 2.4rem; }
.pantalla-ingreso .lado-marca li { margin: 8px 0; display: flex; gap: 10px; align-items: center; }
.pantalla-ingreso .formulario { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.pantalla-ingreso .formulario > div { width: 100%; max-width: 400px; }
@media (max-width: 991.98px) {
  .pantalla-ingreso { grid-template-columns: 1fr; }
  .pantalla-ingreso .lado-marca { padding: 28px 24px; border-radius: 0 0 28px 28px; }
  .pantalla-ingreso .lado-marca img { width: 64px; margin-bottom: 12px; }
  .pantalla-ingreso .lado-marca h1 { font-size: 1.6rem; }
  .pantalla-ingreso .lado-marca ul { display: none; }
}

/* ---------------------------------------------------------------- pantalla de carga */
.carga {
  position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; flex-direction: column;
  background: rgba(20, 89, 154, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: #fff; text-align: center; padding: 24px;
  opacity: 0; transition: opacity .25s ease;
}
.carga.visible { display: flex; opacity: 1; }
.carga .circulo { position: relative; width: 132px; height: 132px; }
.carga .anillo {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(255, 255, 255, 0) 0deg, var(--celeste) 230deg, #fff 300deg, rgba(255, 255, 255, 0) 301deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  animation: girar 1.4s linear infinite;
}
.carga .anillo-fondo { position: absolute; inset: 0; border-radius: 50%; border: 7px solid rgba(255, 255, 255, .12); }
.carga .logo { position: absolute; inset: 20px; border-radius: 50%; background: var(--degradado); display: grid; place-items: center; box-shadow: 0 0 34px rgba(53, 162, 220, .6); animation: latir 1.1s ease-in-out infinite alternate; }
.carga .logo img { width: 58%; }
.carga .mensaje { font-size: 1.2rem; font-weight: 800; margin-top: 26px; min-height: 1.6em; transition: opacity .3s ease, transform .3s ease; }
.carga .mensaje.cambiando { opacity: 0; transform: translateY(8px); }
.carga .puntos { display: flex; gap: 6px; margin-top: 12px; }
.carga .puntos span { width: 8px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .35); transition: all .3s ease; }
.carga .puntos span.hecho { background: #fff; }
.carga .puntos span.actual { width: 22px; background: #fff; }
.carga .nota { margin-top: 14px; opacity: .85; font-size: .9rem; max-width: 360px; }
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes latir { from { transform: scale(.92); } to { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .carga .anillo, .carga .logo { animation-duration: 6s; } }

/* ---------------------------------------------------------------- avisos */
.toast-contenedor { position: fixed; top: 16px; right: 16px; z-index: 2100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast-portal { background: #fff; border-radius: 14px; box-shadow: 0 14px 40px rgba(20, 60, 100, .2); padding: 12px 16px; display: flex; gap: 10px; align-items: flex-start; border-left: 5px solid var(--verde); animation: entrar .25s ease; font-size: .92rem; }
.toast-portal.error { border-left-color: var(--rojo); }
.toast-portal i { font-size: 1.2rem; }
@keyframes entrar { from { transform: translateY(-10px); opacity: 0; } }

.modal-content { border-radius: 22px; border: 0; }
.modal-header { border: 0; padding-bottom: 0; }
.modal-footer { border: 0; }
.texto-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; word-break: break-all; }

@media print {
  .lateral, .barra, .nav-movil, .no-imprimir, .toast-contenedor { display: none !important; }
  .principal { margin: 0; }
  body { background: #fff; }
}

@media (max-width: 575.98px) {
  .accion { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; }
  .accion b { font-size: .95rem; }
  .dato .v { font-size: 1.25rem; }
}
