/* =============================================================================
   Estudio Contable | Gestión Integral
   Interfaz de trabajo: densa, legible, sin adornos. Pensada para usarse
   muchas horas por día sin cansar la vista ni esconder información.
   ========================================================================== */

:root {
  --azul:        #1d4ed8;
  --azul-oscuro: #1e3a8a;
  --azul-claro:  #eff6ff;

  --tinta:       #0f172a;
  --texto:       #1e293b;
  --suave:       #64748b;
  --tenue:       #94a3b8;
  --borde:       #e2e8f0;
  --borde-fuerte:#cbd5e1;
  --fondo:       #f1f5f9;
  --panel:       #ffffff;

  --verde:   #15803d;  --verde-f:   #dcfce7;
  --rojo:    #b91c1c;  --rojo-f:    #fee2e2;
  --ambar:   #a16207;  --ambar-f:   #fef3c7;
  --naranja: #c2410c;  --naranja-f: #ffedd5;
  --violeta: #6d28d9;  --violeta-f: #ede9fe;
  --cian:    #0e7490;  --cian-f:    #cffafe;
  --gris:    #475569;  --gris-f:    #f1f5f9;

  --barra: 248px;
  --radio: 8px;
  --sombra: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texto);
  background: var(--fondo);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--tinta); }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ----------------------------------------------------------------- esqueleto */
.app { display: flex; min-height: 100vh; }

.barra {
  width: var(--barra);
  flex-shrink: 0;
  background: var(--tinta);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  overflow-y: auto;
  z-index: 40;
}
.barra__marca {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.barra__logo {
  width: 34px; height: 34px; border-radius: 7px;
  background: var(--azul); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
  overflow: hidden;
}
.barra__logo img { width: 100%; height: 100%; object-fit: cover; }
.barra__nombre { font-size: 14px; font-weight: 600; color: #fff; line-height: 1.25; }
.barra__sistema { font-size: 11px; color: #94a3b8; }

.barra nav { padding: 10px 0 24px; flex: 1; }
.barra__grupo {
  padding: 14px 16px 6px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: #64748b; font-weight: 600;
}
.barra a.item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; color: #cbd5e1; font-size: 13.5px;
  border-left: 3px solid transparent;
}
.barra a.item:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.barra a.item.activo {
  background: rgba(59,130,246,.14); color: #fff;
  border-left-color: #3b82f6; font-weight: 600;
}
.barra .icono { width: 17px; text-align: center; flex-shrink: 0; opacity: .85; font-size: 14px; }
.barra .pastilla {
  margin-left: auto; background: var(--rojo); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 9px;
}
.barra .pastilla--neutra { background: #475569; }

.principal { flex: 1; margin-left: var(--barra); min-width: 0; display: flex; flex-direction: column; }

/* ----------------------------------------------------------------- barra superior */
.superior {
  background: var(--panel); border-bottom: 1px solid var(--borde);
  padding: 10px 20px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 30; flex-wrap: wrap;
}
.buscador { position: relative; flex: 1; min-width: 180px; max-width: 420px; }
.buscador input {
  width: 100%; padding: 7px 12px 7px 32px; font-size: 13.5px;
  border: 1px solid var(--borde-fuerte); border-radius: 6px; background: #f8fafc;
}
.buscador input:focus { outline: 2px solid var(--azul); outline-offset: -1px; background: #fff; }
.buscador::before {
  content: "⌕"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--tenue); font-size: 16px;
}

.periodo { display: flex; align-items: center; gap: 6px; }
.periodo label { font-size: 12px; color: var(--suave); font-weight: 600; }
.periodo select { padding: 6px 8px; font-size: 13px; border: 1px solid var(--borde-fuerte); border-radius: 6px; }

.superior__derecha { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--azul-claro);
  color: var(--azul-oscuro); display: grid; place-items: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.usuario-caja { display: flex; align-items: center; gap: 8px; }
.usuario-caja__nombre { font-size: 13px; font-weight: 600; line-height: 1.2; }
.usuario-caja__rol { font-size: 11px; color: var(--suave); }

.campana { position: relative; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 6px; color: var(--suave); font-size: 17px; }
.campana:hover { background: var(--fondo); text-decoration: none; }
.campana .cuenta {
  position: absolute; top: 2px; right: 1px; background: var(--rojo); color: #fff;
  font-size: 9.5px; font-weight: 700; min-width: 15px; height: 15px; border-radius: 8px;
  display: grid; place-items: center; padding: 0 3px;
}

/* ----------------------------------------------------------------- contenido */
.contenido { padding: 20px; flex: 1; }
.encabezado { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.encabezado h1 { flex: 1; min-width: 200px; }
.encabezado .acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.migas { font-size: 12.5px; color: var(--suave); margin-bottom: 4px; }
.migas a { color: var(--suave); }

.panel {
  background: var(--panel); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: var(--sombra); margin-bottom: 16px;
}
.panel__cabecera {
  padding: 12px 16px; border-bottom: 1px solid var(--borde);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.panel__cabecera h2 { flex: 1; min-width: 140px; }
.panel__cuerpo { padding: 16px; }
.panel__pie { padding: 10px 16px; border-top: 1px solid var(--borde); background: #fafbfc;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }

/* ----------------------------------------------------------------- indicadores */
.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tarjeta {
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 13px 15px; box-shadow: var(--sombra); display: block; color: inherit;
  border-left: 3px solid var(--borde-fuerte);
}
a.tarjeta:hover { text-decoration: none; border-color: var(--borde-fuerte); box-shadow: 0 2px 8px rgba(15,23,42,.08); }
.tarjeta__etiqueta { font-size: 11.5px; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.tarjeta__valor { font-size: 26px; font-weight: 700; color: var(--tinta); line-height: 1.15; margin-top: 3px; }
.tarjeta__pie { font-size: 11.5px; color: var(--tenue); margin-top: 2px; }
.tarjeta--alerta { border-left-color: var(--rojo); }
.tarjeta--alerta .tarjeta__valor { color: var(--rojo); }
.tarjeta--aviso { border-left-color: var(--ambar); }
.tarjeta--aviso .tarjeta__valor { color: var(--ambar); }
.tarjeta--ok { border-left-color: var(--verde); }
.tarjeta--azul { border-left-color: var(--azul); }

/* ----------------------------------------------------------------- tablas */
.tabla-marco { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tabla th {
  text-align: left; padding: 9px 12px; background: #f8fafc;
  border-bottom: 1px solid var(--borde); font-weight: 600; font-size: 12px;
  color: var(--suave); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
table.tabla th a { color: var(--suave); }
table.tabla th a:hover { color: var(--azul); }
table.tabla td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
table.tabla tbody tr:hover { background: #fbfcfe; }
table.tabla tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.principal-celda { font-weight: 600; color: var(--tinta); }
.sub { font-size: 12px; color: var(--suave); }

/* ----------------------------------------------------------------- etiquetas de estado */
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 11px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.5;
}
.chip--gris    { background: var(--gris-f);    color: var(--gris); }
.chip--verde   { background: var(--verde-f);   color: var(--verde); }
.chip--rojo    { background: var(--rojo-f);    color: var(--rojo); }
.chip--ambar   { background: var(--ambar-f);   color: var(--ambar); }
.chip--naranja { background: var(--naranja-f); color: var(--naranja); }
.chip--violeta { background: var(--violeta-f); color: var(--violeta); }
.chip--cian    { background: var(--cian-f);    color: var(--cian); }
.chip--azul    { background: var(--azul-claro);color: var(--azul-oscuro); }

/* ----------------------------------------------------------------- botones */
.boton {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 14px; border-radius: 6px; font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; background: var(--azul); color: #fff;
  font-family: inherit; line-height: 1.4;
}
.boton:hover { background: var(--azul-oscuro); text-decoration: none; color: #fff; }
.boton:disabled { opacity: .55; cursor: not-allowed; }
.boton--suave { background: var(--panel); color: var(--texto); border-color: var(--borde-fuerte); }
.boton--suave:hover { background: var(--fondo); color: var(--texto); }
.boton--peligro { background: var(--rojo); }
.boton--peligro:hover { background: #991b1b; }
.boton--ok { background: var(--verde); }
.boton--ok:hover { background: #166534; }
.boton--chico { padding: 4px 10px; font-size: 12.5px; }
.boton--enlace { background: none; color: var(--azul); border: none; padding: 2px 4px; }
.boton--enlace:hover { background: none; color: var(--azul-oscuro); text-decoration: underline; }

/* ----------------------------------------------------------------- formularios */
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.campos--2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.campo--ancho { grid-column: 1 / -1; }
.campo label { font-size: 12.5px; font-weight: 600; color: var(--texto); }
.campo .ayuda { font-size: 11.5px; color: var(--suave); }
.campo input[type=text], .campo input[type=email], .campo input[type=password],
.campo input[type=number], .campo input[type=date], .campo select, .campo textarea {
  padding: 7px 10px; border: 1px solid var(--borde-fuerte); border-radius: 6px;
  font-size: 13.5px; font-family: inherit; color: var(--texto); background: #fff; width: 100%;
}
.campo textarea { resize: vertical; min-height: 70px; }
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: 2px solid var(--azul); outline-offset: -1px; border-color: var(--azul);
}
.campo input[aria-invalid=true], .campo select[aria-invalid=true] { border-color: var(--rojo); background: #fffbfb; }
.campo .error { font-size: 12px; color: var(--rojo); font-weight: 500; }
.casilla { display: flex; align-items: center; gap: 7px; font-size: 13.5px; }
.casilla input { width: 15px; height: 15px; accent-color: var(--azul); flex-shrink: 0; }
.seccion-form { border-top: 1px solid var(--borde); margin-top: 18px; padding-top: 16px; }
.seccion-form:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.seccion-form h3 { margin-bottom: 12px; color: var(--suave); text-transform: uppercase;
  font-size: 11.5px; letter-spacing: .05em; }
fieldset { border: none; margin: 0; padding: 0; }

/* ----------------------------------------------------------------- filtros */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filtros .campo { min-width: 140px; flex: 0 1 auto; }
.filtros .campo--texto { flex: 1 1 200px; }

/* ----------------------------------------------------------------- mensajes */
.aviso {
  padding: 11px 14px; border-radius: var(--radio); margin-bottom: 14px;
  font-size: 13.5px; border: 1px solid; display: flex; gap: 9px; align-items: flex-start;
}
.aviso--exito { background: var(--verde-f); border-color: #86efac; color: #14532d; }
.aviso--error { background: var(--rojo-f);  border-color: #fca5a5; color: #7f1d1d; }
.aviso--aviso { background: var(--ambar-f); border-color: #fcd34d; color: #713f12; }
.aviso--info  { background: var(--azul-claro); border-color: #bfdbfe; color: #1e3a8a; }
.aviso strong { font-weight: 700; }

.vacio { padding: 36px 20px; text-align: center; color: var(--suave); }
.vacio__titulo { font-weight: 600; color: var(--texto); margin-bottom: 4px; font-size: 14.5px; }
.vacio__texto { font-size: 13px; max-width: 440px; margin: 0 auto 14px; }

/* ----------------------------------------------------------------- pestañas */
.pestanas { display: flex; gap: 2px; border-bottom: 1px solid var(--borde); overflow-x: auto; }
.pestanas a {
  padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--suave);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.pestanas a:hover { color: var(--texto); text-decoration: none; }
.pestanas a.activa { color: var(--azul); border-bottom-color: var(--azul); }

/* ----------------------------------------------------------------- paginación */
.paginacion { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.paginacion a, .paginacion span {
  padding: 5px 10px; border: 1px solid var(--borde-fuerte); border-radius: 5px;
  font-size: 13px; color: var(--texto); background: #fff;
}
.paginacion a:hover { background: var(--fondo); text-decoration: none; }
.paginacion .actual { background: var(--azul); color: #fff; border-color: var(--azul); font-weight: 600; }
.paginacion .inerte { color: var(--tenue); background: #f8fafc; }

/* ----------------------------------------------------------------- calendario */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--borde); border: 1px solid var(--borde); }
.cal__encabezado {
  background: #f8fafc; padding: 7px 6px; text-align: center;
  font-size: 11.5px; font-weight: 600; color: var(--suave); text-transform: uppercase;
}
.cal__dia { background: #fff; min-height: 96px; padding: 5px 6px; }
.cal__dia--fuera { background: #fafbfc; }
.cal__dia--hoy { background: var(--azul-claro); }
.cal__numero { font-size: 12px; font-weight: 600; color: var(--suave); margin-bottom: 3px; }
.cal__dia--hoy .cal__numero { color: var(--azul); }
.cal__evento {
  display: block; font-size: 11px; padding: 2px 5px; border-radius: 4px;
  margin-bottom: 2px; background: var(--gris-f); color: var(--texto);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 2px solid var(--borde-fuerte);
}
.cal__evento:hover { text-decoration: none; filter: brightness(.96); }
.cal__evento--vencido { background: var(--rojo-f); color: var(--rojo); border-left-color: var(--rojo); }
.cal__evento--hoy { background: var(--ambar-f); color: var(--ambar); border-left-color: var(--ambar); }

/* ----------------------------------------------------------------- barras simples */
.barras { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.barras__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.barras__pila { width: 100%; max-width: 46px; display: flex; flex-direction: column-reverse;
  justify-content: flex-start; flex: 1; gap: 2px; }
.barras__parte { width: 100%; border-radius: 2px; min-height: 2px; }
.barras__parte--ok { background: var(--verde); }
.barras__parte--pend { background: #93c5fd; }
.barras__parte--venc { background: var(--rojo); }
.barras__etiqueta { font-size: 11px; color: var(--suave); white-space: nowrap; }
.leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--suave); margin-top: 10px; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }

/* ----------------------------------------------------------------- línea de tiempo */
.linea { list-style: none; margin: 0; padding: 0; }
.linea li { padding: 9px 0 9px 18px; border-left: 2px solid var(--borde); position: relative; }
.linea li::before {
  content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--borde-fuerte); border: 2px solid #fff;
}
.linea li:last-child { border-left-color: transparent; }
.linea__fecha { font-size: 11.5px; color: var(--tenue); }
.linea__texto { font-size: 13.5px; }

/* ----------------------------------------------------------------- definiciones */
.datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 13px 20px; }
.dato__etiqueta { font-size: 11.5px; color: var(--suave); text-transform: uppercase;
  letter-spacing: .03em; font-weight: 600; }
.dato__valor { font-size: 13.5px; color: var(--texto); word-break: break-word; }

/* ----------------------------------------------------------------- ingreso */
.ingreso { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--fondo); }
.ingreso__caja { width: 100%; max-width: 392px; }
.ingreso__panel { background: #fff; border: 1px solid var(--borde); border-radius: 12px;
  padding: 30px; box-shadow: 0 4px 16px rgba(15,23,42,.07); }
.ingreso__marca { text-align: center; margin-bottom: 22px; }
.ingreso__logo { width: 46px; height: 46px; border-radius: 10px; background: var(--azul);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; margin: 0 auto 12px; }
.ingreso__pie { text-align: center; font-size: 12px; color: var(--tenue); margin-top: 18px; }

/* ----------------------------------------------------------------- utilidades */
.fila { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fila--fin { justify-content: flex-end; }
.entre { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.oculto { display: none; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.chico { font-size: 12.5px; }
.suave { color: var(--suave); }
.alerta-texto { color: var(--rojo); font-weight: 600; }
.separador { height: 1px; background: var(--borde); margin: 14px 0; }
.ancho-total { width: 100%; }
.en-linea { display: inline; }

/* ----------------------------------------------------------------- responsive */
.menu-boton { display: none; background: none; border: none; font-size: 21px; cursor: pointer;
  color: var(--texto); padding: 2px 6px; }

@media (max-width: 960px) {
  .barra { transform: translateX(-100%); transition: transform .18s ease; box-shadow: 4px 0 18px rgba(0,0,0,.2); }
  .barra.abierta { transform: translateX(0); }
  .principal { margin-left: 0; }
  .menu-boton { display: block; }
  .contenido { padding: 14px; }
  .velo { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; }
  .usuario-caja__nombre, .usuario-caja__rol { display: none; }
  .cal__dia { min-height: 70px; }
  .buscador { order: 3; flex-basis: 100%; max-width: none; }
}

@media (max-width: 600px) {
  .tarjetas { grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); }
  .tarjeta__valor { font-size: 22px; }
  table.tabla { font-size: 13px; }
  table.tabla th, table.tabla td { padding: 8px 9px; }
}

@media print {
  .barra, .superior, .encabezado .acciones, .filtros, .paginacion { display: none !important; }
  .principal { margin-left: 0; }
  .panel { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}
