:root {
  --tamiva-azul: #26285A;
  --tamiva-azul-oscuro: #1a1c42;
  --tamiva-rojo: #EA5435;
  --fondo: #F4F6FA;
}

body { background: var(--fondo); font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.text-tamiva { color: var(--tamiva-azul) !important; }

.btn-tamiva { background: var(--tamiva-azul); border-color: var(--tamiva-azul); color: #fff; }
.btn-tamiva:hover, .btn-tamiva:focus { background: var(--tamiva-azul-oscuro); border-color: var(--tamiva-azul-oscuro); color: #fff; }

/* ---------- Menú lateral ---------- */
.sidebar { width: 260px; min-width: 260px; flex: 0 0 260px; min-height: 100vh; background: var(--tamiva-azul); color: #fff; }
@media (min-width: 992px) {
  /* Bootstrap deja .offcanvas-lg transparente en pantallas grandes: se fuerza el azul */
  .sidebar, .offcanvas-lg.sidebar { background-color: var(--tamiva-azul) !important; color: #fff !important; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
}
.offcanvas-lg.sidebar { --bs-offcanvas-bg: var(--tamiva-azul); --bs-offcanvas-color: #fff; }
.sidebar-brand { display: flex; align-items: flex-start; gap: .75rem; padding: 1.1rem 1.1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.15); }
.sidebar-marca img { width: 100%; max-width: 215px; height: auto; display: block; }
.sidebar-sistema { margin-top: .55rem; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.85); }
.sidebar-sistema span { font-weight: 700; color: #fff; }
.sidebar-marca { flex: 1; min-width: 0; }
.sidebar-brand small { color: rgba(255,255,255,.7); }
.sidebar .nav-link { color: rgba(255,255,255,.85); padding: .6rem 1.1rem; border-left: 4px solid transparent; display: flex; align-items: center; gap: .6rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.14); border-left-color: var(--tamiva-rojo); color: #fff; font-weight: 600; }
.sidebar .nav-link.disabled { color: rgba(255,255,255,.4); cursor: not-allowed; }
.sidebar-user { padding: 1rem 1.1rem; border-top: 1px solid rgba(255,255,255,.15); }
.sidebar .offcanvas-body, .sidebar nav { flex: 0 0 auto; }

.contenido { min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid #e2e7ef; padding: .6rem .9rem; display: flex; align-items: center; position: sticky; top: 0; z-index: 1020; }

/* ---------- Tarjetas de indicadores ---------- */
.kpi { background: #fff; border: 1px solid #e2e7ef; border-radius: 1rem; padding: 1rem 1.1rem; height: 100%; }
.kpi .valor { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.kpi .etiqueta { color: #6b7685; font-size: .82rem; }
.kpi i { font-size: 1.4rem; }

.panel-tarjeta { background: #fff; border: 1px solid #e2e7ef; border-radius: 1rem; }
.panel-tarjeta .table { margin-bottom: 0; }
.table > :not(caption) > * > * { vertical-align: middle; }
thead.tabla-cabecera th { background: #eef2f9; color: #33415c; font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }

/* ---------- Login ---------- */
.login-body { background: linear-gradient(160deg, #e9eaf4 0%, var(--fondo) 60%); min-height: 100vh; }
.login-cabecera { background: #fff; color: var(--tamiva-azul); border-radius: 1.4rem; padding: 1.6rem 1.2rem 1.3rem; box-shadow: 0 .25rem 1rem rgba(38,40,90,.10); }
.login-logo-img { width: 100%; max-width: 330px; height: auto; }
.text-naranja { color: var(--tamiva-rojo); }
.login-linea { width: 54px; height: 4px; border-radius: 4px; background: var(--tamiva-rojo); margin: .9rem auto 0; }

.cursor-pointer { cursor: pointer; }
.imagen-evidencia { max-width: 100%; max-height: 260px; border: 1px solid #dde3ee; border-radius: .6rem; background: #fff; }

@media print {
  .sidebar, .topbar, .no-imprimir, .toast-container { display: none !important; }
  body { background: #fff; }
}

/* ---------- Calendario mensual ---------- */
.cal-cab, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-cab div { text-align: center; font-size: .78rem; font-weight: 600; color: #6b7685; padding: .25rem 0; text-transform: uppercase; }
.cal-dia { background: #fff; border: 1px solid #e2e7ef; border-radius: .6rem; min-height: 104px; padding: .35rem .4rem; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-dia:hover { border-color: var(--tamiva-azul); box-shadow: 0 0 0 2px rgba(38,40,90,.14); }
.cal-dia.vacio { background: transparent; border-color: transparent; cursor: default; box-shadow: none; }
.cal-dia.fin-semana { background: #f8f9fc; }
.cal-dia.hoy { border-color: var(--tamiva-rojo); box-shadow: 0 0 0 2px rgba(234,84,53,.18); }
.cal-num { font-weight: 700; font-size: .85rem; color: var(--tamiva-azul); display: flex; justify-content: space-between; align-items: center; }
.cal-num .cuenta { background: var(--tamiva-azul); color: #fff; border-radius: 1rem; font-size: .7rem; padding: 0 .45rem; font-weight: 600; }
.cal-chip { font-size: .7rem; line-height: 1.25; padding: 1px 5px; border-radius: .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--c, #153F8F); background: color-mix(in srgb, var(--c, #153F8F) 12%, #fff); color: #1f2937; }
.cal-chip.PENDIENTE { --c: #153F8F; }
.cal-chip.REALIZADA { --c: #198754; }
.cal-chip.SUSPENDIDA { --c: #d98a00; }
.cal-chip.REPROGRAMADA { --c: #7c3aed; }
.cal-chip.ACT { --c: #0f766e; }
.cal-chip.CANCELADA { --c: #9ca3af; text-decoration: line-through; }
.cal-mas { font-size: .7rem; color: #6b7685; }
.leyenda i { display: inline-block; width: .7rem; height: .7rem; border-radius: .2rem; margin-right: .25rem; vertical-align: -1px; }
@media (max-width: 767.98px) {
  .cal-dia { min-height: 54px; align-items: center; padding: .25rem .15rem; }
  .cal-chip, .cal-mas { display: none; }
  .cal-num { flex-direction: column; gap: 2px; }
}
.fila-visita { border: 1px solid #e2e7ef; border-radius: .6rem; padding: .6rem .7rem; background: #fff; }
.fila-visita.cancelada { background: #f4f5f7; opacity: .8; }
.lista-clientes { max-height: 260px; overflow-y: auto; border: 1px solid #e2e7ef; border-radius: .5rem; }
.lista-clientes label { display: flex; gap: .6rem; align-items: flex-start; padding: .4rem .6rem; border-bottom: 1px solid #eef1f6; cursor: pointer; margin: 0; }
.lista-clientes label:last-child { border-bottom: 0; }
.lista-clientes label.deshabilitado { opacity: .5; cursor: not-allowed; }

/* ---------- Reportes ---------- */
.rep-tarjeta { background: #fff; border: 1px solid #e2e7ef; border-radius: .8rem; padding: .7rem .9rem; height: 100%; }
.rep-tarjeta .num { font-size: 1.6rem; font-weight: 700; color: var(--tamiva-azul); line-height: 1.1; }
.rep-tarjeta .txt { font-size: .78rem; color: #6b7685; text-transform: uppercase; letter-spacing: .02em; }
.rep-barra { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; gap: .5rem; align-items: center; font-size: .82rem; margin-bottom: .35rem; }
.rep-barra .pista { background: #eef1f7; border-radius: .4rem; height: .8rem; overflow: hidden; }
.rep-barra .relleno { height: 100%; border-radius: .4rem; background: var(--tamiva-azul); }
.sem { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .3rem; vertical-align: -1px; }
.sem.VERDE { background: #198754; } .sem.AMARILLO { background: #f0ad00; } .sem.ROJO { background: #dc3545; } .sem.SIN_META { background: #9ca3af; }
.solo-impresion { display: none; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  .solo-impresion { display: block !important; }
  .contenido > .p-3, .contenido > .p-lg-4 { padding: 0 !important; }
  .panel-tarjeta, .rep-tarjeta { box-shadow: none !important; border: 1px solid #ccc !important; }
  html, body { overflow: visible !important; width: auto !important; }
  .d-flex { display: block !important; }
  .contenido { min-width: 0 !important; width: 100% !important; }
  .table-responsive { overflow: visible !important; }
  .table { font-size: 8pt; width: 100% !important; table-layout: auto; }
  .table th, .table td { white-space: normal !important; word-break: break-word; overflow-wrap: anywhere; padding: 3px 4px !important; }
  .imagen-evidencia { max-height: 200px; }
  .table thead { display: table-header-group; }
  .table tr { break-inside: avoid; }
  .tabla-cabecera th { background: #153F8F !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rep-barra .relleno, .sem, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Tareas ---------- */
.tarea-dist { max-height: 300px; overflow: auto; border: 1px solid #e2e7ef; border-radius: .6rem; }
.tarea-dist table { margin: 0; }
.tarea-dist thead th { position: sticky; top: 0; background: #f4f6fa; z-index: 1; }
.venta-anulada td { text-decoration: line-through; color: #9ca3af; }
.venta-anulada td:last-child, .venta-anulada td .motivo { text-decoration: none; }
