:root {
  /* Le dice al navegador que esta pagina solo tiene tema claro: sin esto,
     un SO o navegador en modo oscuro repinta los controles nativos (inputs,
     botones) con su propio fondo oscuro -contra el que un icono en gris
     (--tenue) puede perder casi todo su contraste, ya que el CSS de abajo
     nunca declara un fondo propio para <input>. */
  color-scheme: light;

  --fondo: #f4f5f7;
  --panel: #ffffff;
  --borde: #d8dbe0;
  --texto: #24292f;
  --tenue: #6b7280;
  --acento: #7b1e26;
  --error: #b42318;
  --exito: #12805c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  font-size: 15px;
}

/* Altura fija de la barra superior: el menu lateral se pega justo debajo de ella. */
:root { --altura-barra: 56px; }

.barra {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--altura-barra);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  background: var(--acento);
  color: #fff;
  padding: 0 1.2rem;
}

.barra a { color: #fff; text-decoration: none; }
.barra .marca { height: 32px; width: auto; display: block; justify-self: start; }

/* Nombre de la seccion, centrado en la barra superior. */
.barra-titulo {
  margin: 0;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.barra-usuario { justify-self: end; text-align: right; white-space: nowrap; }

/* Boton hamburguesa: solo se ve en movil (ver la regla de 760 px). */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #fff;
  border: 0;
  padding: .25rem;
  width: auto;
  cursor: pointer;
}
.menu-toggle:hover { filter: none; background: rgba(255, 255, 255, .12); border-radius: 4px; }

.contenedor { display: flex; min-height: calc(100vh - var(--altura-barra)); }

.menu {
  width: 210px;
  background: var(--panel);
  border-right: 1px solid var(--borde);
  padding: 1rem 0;
  /* Siempre visible al bajar la pagina: queda pegado debajo de la barra fija. */
  position: sticky;
  top: var(--altura-barra);
  align-self: flex-start;
  height: calc(100vh - var(--altura-barra));
  overflow-y: auto;
}

.menu a {
  display: block;
  padding: .6rem 1.2rem;
  color: var(--texto);
  text-decoration: none;
}

.menu a:hover { background: var(--fondo); }
.menu a.activo { border-left: 3px solid var(--acento); font-weight: 600; }

.principal { flex: 1; padding: 1.5rem; }
.tarjeta {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 6px;
  padding: 1.2rem;
  margin-bottom: 1rem;
}

label { display: block; margin: .8rem 0 .3rem; font-size: .9rem; color: var(--tenue); }

input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--borde);
  border-radius: 4px;
  font-size: 15px;
  background: var(--panel);
  color: var(--texto);
}

button {
  background: var(--acento);
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: .6rem 1.2rem;
  font-size: 15px;
  cursor: pointer;
}

button:hover { filter: brightness(1.1); }

.aviso { padding: .7rem .9rem; border-radius: 4px; margin-bottom: 1rem; }
.aviso.error { background: #fdecea; color: var(--error); border: 1px solid #f5c2c0; }
.aviso.exito { background: #e7f6f1; color: var(--exito); border: 1px solid #b7e3d5; }

.acceso {
  max-width: 360px;
  margin: 8vh auto;
}

.campo-password {
  position: relative;
}
.campo-password input { padding-right: 2.4rem; }
.campo-password button {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  color: #000 !important;
  border: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.campo-password button svg {
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
  stroke: #000 !important;
}
.campo-password button:hover,
.campo-password button:active { color: var(--acento) !important; }
.campo-password button:hover svg,
.campo-password button:active svg { stroke: var(--acento) !important; }

.tabla { width: 100%; border-collapse: collapse; margin-top: .5rem; }
.tabla th, .tabla td { padding: .5rem .6rem; border-bottom: 1px solid var(--borde); text-align: left; }
.tabla th { font-size: .85rem; color: var(--tenue); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.tabla tbody tr:hover { background: var(--fondo); }
.tabla td.num,
.tabla th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tabla td.num.monto-centro,
.tabla th.num.monto-centro { text-align: center; }

.tabla form.linea { display: flex; gap: .4rem; align-items: center; margin: 0; }
.tabla form.linea select { width: auto; padding: .3rem .4rem; }
.tabla form.linea button { padding: .3rem .7rem; font-size: .9rem; }

/* Corte diario de ventas */
.resumen-corte {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  background: var(--fondo);
  border: 1px solid var(--borde);
  border-radius: 6px;
  padding: .8rem 1rem;
  margin-top: .8rem;
}

.resumen-etiqueta { display: block; font-size: .8rem; color: var(--tenue); }
.resumen-valor { display: block; font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }

#diferencia-en-vivo.diferencia-marcada { color: var(--error); }

.campo-propinas {
  border: 1px dashed var(--borde);
  border-radius: 6px;
  padding: .8rem 1rem;
  margin-top: 1.2rem;
  background: var(--fondo);
}

.boton-peligro { background: var(--error); }

form.linea { display: flex; align-items: center; margin-top: .8rem; }

/* Listado de cortes de ventas */
.filtros-corte {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filtros-corte > div { min-width: 160px; }
.filtros-corte label { margin-top: 0; }

.atajos { margin: .8rem 0 0; }
.atajos a {
  margin-right: 1rem;
  font-size: .85rem;
  color: var(--acento);
  text-decoration: none;
}
.atajos a:hover { text-decoration: underline; }

.tabla-scroll { overflow-x: auto; }

.tabla td.diferencia-marcada,
.tabla th.diferencia-marcada {
  color: var(--error);
  font-weight: 700;
}

.tabla tr.fila-anulada { opacity: .55; }

.tabla td.fecha-con-comentario {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: help;
}

.tabla td.propinas-col,
.tabla th.propinas-total,
.tabla td.referencia-col,
.tabla th.referencia-total {
  border-left: 1px dashed var(--borde);
  color: var(--tenue);
}

/* Captura de egresos: resalta el campo cuya cifra cuenta para los
   totales (monto pagado), igual de destacado que el bloque de propinas
   de la captura de ventas. */
.campo-destacado {
  border: 1px dashed var(--borde);
  border-radius: 6px;
  padding: .8rem 1rem;
  margin-top: 1.2rem;
  background: var(--fondo);
}

/* Boton de accion principal en la cabecera de un listado. Es un enlace y
   no un <button> porque solo navega: no envia ningun formulario. Repite
   el aspecto de button para que la interfaz se lea igual. */
.acciones-cabecera { margin: 0 0 1rem; }

.boton {
  display: inline-block;
  background: var(--acento);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  padding: .6rem 1.2rem;
  font-size: 15px;
}

.boton:hover { filter: brightness(1.1); }

/* Modulo de reportes */
.lista-reportes { list-style: none; margin: 0; padding: 0; }
.lista-reportes li { padding: .6rem 0; border-bottom: 1px solid var(--borde); }
.lista-reportes li:last-child { border-bottom: 0; }
.lista-reportes a { color: var(--acento); font-weight: 600; text-decoration: none; }
.lista-reportes a:hover { text-decoration: underline; }
.descripcion-reporte { color: var(--tenue); font-size: .9rem; margin: .3rem 0 0; }

/* Leyenda opcional bajo un grafico (p.ej. "Numero de semana"), declarada
   por la definicion del reporte via grafico.eje_x_titulo. */
.grafico-eje-titulo { text-align: center; color: var(--tenue); margin: .4rem 0 0; }

/* Al imprimir un reporte, solo el contenido (totales, grafico, tabla)
   tiene sentido en papel: la barra, el menu lateral y los controles de
   filtro/exportar/imprimir no. */
@media print {
  .barra, .menu, .no-imprimir { display: none !important; }
  .contenedor { display: block; }
  .principal { padding: 0; }
}

/* Dashboard de inicio */

/* Utilidad o margen negativos: deben distinguirse a simple vista, no ser
   un numero mas en la fila. */
.valor-negativo { color: var(--error); }

/* Variacion contra el mes anterior. cambio-positivo/negativo ya vienen
   resueltos segun si, para ese concepto, subir es bueno o malo (ver
   $claseVariacion en dashboard.php); aqui solo se pinta. */
.cambio-positivo { color: var(--exito); font-weight: 600; }
.cambio-negativo { color: var(--error); font-weight: 600; }
.cambio-neutro   { color: var(--tenue); }

/* Aviso de dias sin capturar: ni error (no rompio nada) ni exito (falta
   un dato), un tono propio de advertencia. */
.aviso.advertencia {
  background: #fdf6e3;
  color: #8a6d1f;
  border: 1px solid #ecd9a0;
}

/* Formularios: asterisco de campo obligatorio y campo faltante al guardar */
.obligatorio { color: #c62828; font-weight: bold; }
.campo-faltante {
  border-color: #c62828 !important;
  box-shadow: 0 0 0 2px rgba(198, 40, 40, .25);
}
.aviso-faltantes { margin-bottom: 1rem; }

/* Documentos adjuntos del corte (ventas/form.php) */
.adjuntos {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  background: #fbfbfc;
  border: 1px solid var(--borde);
  border-radius: 8px;
}
.adjuntos-cabecera { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.adjuntos h3 { margin: 0; font-size: 1.05rem; }
.adjuntos-contador { font-size: .85rem; color: var(--tenue); background: #eceef2; border-radius: 999px; padding: .15rem .6rem; }
.adjuntos-vacio { color: var(--tenue); font-size: .9rem; margin: .4rem 0 .8rem; }
.adjuntos-lista { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.adjunto {
  display: flex; align-items: center; gap: .75rem;
  background: var(--panel); border: 1px solid var(--borde); border-radius: 6px;
  padding: .55rem .7rem;
}
.adjunto-icono {
  flex: none; width: 36px; height: 36px; border-radius: 6px;
  background: #f3e8e9; color: var(--acento);
  display: flex; align-items: center; justify-content: center;
}
.adjunto-datos { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adjunto-nombre { overflow-wrap: anywhere; font-weight: 600; font-size: .92rem; }
.adjunto-meta { color: var(--tenue); }
.adjunto-ver {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--acento); background: var(--panel); border: 1px solid var(--borde);
  text-decoration: none;
}
.adjunto-ver:hover { background: #f3e8e9; }
.adjuntos-acciones { display: flex; flex-wrap: wrap; gap: .6rem; }
.boton-adj {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--acento); color: #fff; border: 1px solid var(--acento);
  border-radius: 6px; padding: .6rem 1rem; font-size: .95rem; cursor: pointer;
}
.boton-adj:hover { filter: brightness(1.1); }
.boton-adj-secundario { background: var(--panel); color: var(--acento); }
.boton-adj-secundario:hover { background: #f3e8e9; filter: none; }
.boton-adj:disabled { opacity: .6; cursor: wait; }
.adjuntos-estado { min-height: 1.2em; color: var(--tenue); font-size: .88rem; margin: .6rem 0 .2rem; }
.visualmente-oculto {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- Movil (760 px o menos) ------------------------------------------
 * En pantallas chicas el menu lateral pasa a una franja horizontal bajo la
 * barra, la barra apila logo/usuario y el titulo, y las tablas se
 * desplazan dentro de su propio recuadro en vez de empujar la pagina. */
@media (max-width: 760px) {
  .barra {
    height: auto;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "toggle marca usuario"
      "titulo titulo titulo";
    gap: .35rem .7rem;
    padding: .6rem .9rem;
  }
  .menu-toggle { display: inline-flex; grid-area: toggle; }
  .barra .marca { grid-area: marca; height: 28px; }
  .barra-usuario { grid-area: usuario; font-size: .8rem; white-space: normal; text-align: right; }
  .barra-titulo {
    grid-area: titulo;
    font-size: 1.2rem;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    text-align: left;
  }

  .contenedor { flex-direction: column; min-height: 0; }

  /* En movil el menu se abre desde el boton hamburguesa: cerrado por defecto,
     y al abrirlo es una lista vertical que empuja el contenido hacia abajo. */
  .menu {
    display: none;
    width: auto;
    height: auto;
    position: static;
    top: auto;
    align-self: auto;
    padding: .3rem 0;
    border-right: 0;
    border-bottom: 1px solid var(--borde);
  }
  .menu.abierto { display: block; }
  .menu a { padding: .75rem 1.2rem; }
  .menu a.activo { border-left: 3px solid var(--acento); border-bottom: 0; }

  .principal { width: 100%; min-width: 0; padding: 1rem; }
  .tarjeta { padding: .9rem; }

  /* Tablas: se desplazan dentro de su recuadro, sin mover la pagina. */
  .tabla { display: block; overflow-x: auto; white-space: nowrap; }
  .tabla-scroll { overflow-x: auto; }

  .resumen-corte { gap: .9rem 1.2rem; }
  .resumen-valor { font-size: 1.1rem; }

  .filtros-corte { gap: .6rem; }
  .filtros-corte > div { min-width: 0; flex: 1 1 100%; }

  .atajos a { display: inline-block; margin: .3rem .8rem .3rem 0; }

  .adjuntos { padding: .8rem; }
  .adjuntos-acciones .boton-adj { flex: 1 1 auto; justify-content: center; }

  .acceso { margin: 4vh auto; padding: 0 .5rem; }
}

/* Inicio: cada indicador del mes en su propia tarjeta. */
.titulo-seccion { font-size: 1.1rem; margin: 1rem 0 .6rem; }
.metricas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .8rem;
  margin-bottom: 1rem;
}
.metricas .metrica { margin-bottom: 0; padding: .9rem 1rem; display: flex; flex-direction: column; }

/* ---- Subir corte desde ticket (modules/ventas/subir_corte.php) ---------- */
.subir-revision { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.subir-vista { background: #f7f5f1; border: 1px solid var(--borde, #e3ddd3); border-radius: 6px; padding: .5rem; }
.subir-imagen { display: block; width: 100%; height: auto; border-radius: 4px; }
.subir-pdf { display: block; width: 100%; height: 70vh; border: 0; }
.subir-datos label { margin-top: .6rem; }
.subir-datos .campo-revisar { color: #8a5a00; margin: .2rem 0 0; }
.subir-texto-ocr { margin: 1rem 0; }
.subir-texto-ocr pre { white-space: pre-wrap; font-size: .85rem; max-height: 260px; overflow: auto; background: #f7f5f1; padding: .6rem; border-radius: 4px; }
.subir-confirmo { display: flex; gap: .5rem; align-items: flex-start; margin: 1rem 0; font-weight: normal; }
.subir-confirmo input { width: auto; margin-top: .25rem; }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }
@media (max-width: 760px) {
  .subir-revision { grid-template-columns: 1fr; }
  .subir-pdf { height: 55vh; }
}
