* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --azul: #1a4b8c;
    --azul-oscuro: #123762;
    --azul-claro: #eaf1fb;
    --gris-fondo: #f4f6f9;
    --gris-borde: #dde3ea;
    --texto: #2b3440;
    --texto-suave: #6b7684;
    --rojo: #d64545;
    --verde: #2e9e5b;
    --amarillo: #e0a800;
    --morado: #7c4dcc;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--gris-fondo); color: var(--texto); font-size: 15px; }

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 230px; background: var(--azul-oscuro); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.logo { padding: 18px 12px; border-bottom: 1px solid rgba(255,255,255,.12); display: flex; align-items: center; justify-content: center; }
.logo img { width: 120px; max-width: 100%; height: auto; display: block; object-fit: contain; }
.sidebar nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { color: rgba(255,255,255,.82); text-decoration: none; padding: 11px 14px; border-radius: 8px; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.activo { background: var(--azul); color: #fff; }
.nav-badge { background: var(--rojo); color: #fff; font-size: 11px; font-weight: 700; border-radius: 20px; padding: 1px 7px; margin-left: 4px; }
.sidebar-pie { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.12); }
.usuario-info { display: flex; flex-direction: column; margin-bottom: 10px; }
.usuario-info span { font-size: 12.5px; color: rgba(255,255,255,.6); }
.btn-salir { color: rgba(255,255,255,.7); font-size: 13px; text-decoration: none; }
.btn-salir:hover { color: #fff; }

/* Contenido */
.contenido { flex: 1; padding: 28px 34px; max-width: 1200px; }
h1 { font-size: 24px; margin-bottom: 4px; }
.subtitulo { color: var(--texto-suave); margin-bottom: 24px; }
h2 { font-size: 17px; margin-bottom: 14px; }

/* Tarjetas y paneles */
.panel { background: #fff; border: 1px solid var(--gris-borde); border-radius: 12px; padding: 22px; margin-bottom: 22px; }
.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tarjeta { background: #fff; border: 1px solid var(--gris-borde); border-radius: 12px; padding: 18px 20px; }
a.tarjeta { text-decoration: none; display: block; transition: box-shadow .15s, transform .15s; }
a.tarjeta:hover { box-shadow: 0 6px 20px rgba(26,75,140,.15); transform: translateY(-2px); border-color: var(--azul); }
.tarjeta .cifra { font-size: 30px; font-weight: 700; color: var(--azul); }
.tarjeta .etiqueta { color: var(--texto-suave); font-size: 13.5px; margin-top: 2px; }

/* Formularios */
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
input[type=text], input[type=tel], input[type=password], input[type=datetime-local], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--gris-borde); border-radius: 8px; font-size: 14.5px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul-claro); border-color: var(--azul); }
.campo { margin-bottom: 14px; }
/* Selector de fecha + hora (más cómodo y grande al hacer clic) */
.fecha-hora { display: flex; gap: 8px; }
.fecha-hora input[type=date] { flex: 2; }
.fecha-hora input[type=time] { flex: 1; min-width: 96px; }
input[type=date], input[type=time], input[type=datetime-local] { font-size: 16px; padding: 11px 12px; min-height: 46px; }
input[type=date]::-webkit-calendar-picker-indicator, input[type=time]::-webkit-calendar-picker-indicator { cursor: pointer; padding: 4px; transform: scale(1.3); opacity: .7; }
.fila { display: flex; gap: 14px; flex-wrap: wrap; }
.fila .campo { flex: 1; min-width: 180px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--azul); }

button, .btn { background: var(--azul); color: #fff; border: none; padding: 10px 18px; border-radius: 8px; font-size: 14.5px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; font-family: inherit; }
button:hover, .btn:hover { background: var(--azul-oscuro); }
.btn-secundario { background: #fff; color: var(--texto); border: 1px solid var(--gris-borde); }
.btn-secundario:hover { background: var(--gris-fondo); }
.btn-verde { background: var(--verde); }
.btn-verde:hover { background: #24804a; }
.btn-chico { padding: 6px 12px; font-size: 13px; }

/* Tablas */
table { width: 100%; border-collapse: collapse; background: #fff; }
th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--texto-suave); padding: 10px 12px; border-bottom: 2px solid var(--gris-borde); }
td { padding: 12px; border-bottom: 1px solid var(--gris-borde); vertical-align: middle; }
tr:hover td { background: var(--azul-claro); }
td a { color: var(--azul); font-weight: 600; text-decoration: none; }

/* Insignias de estado */
.insignia { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 600; }
.estado-pendiente { background: #fff3cd; color: #8a6d00; }
.estado-en_proceso { background: #d8e7fb; color: #1a4b8c; }
.estado-finalizado { background: #d9f2e3; color: #1e6e42; }
.insignia-si { background: #d9f2e3; color: #1e6e42; }
.insignia-no { background: #fde2e2; color: #a33; }

/* Notas de colores */
.nota { border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; border-left: 5px solid; }
.nota-rojo { background: #fdeaea; border-color: var(--rojo); }
.nota-amarillo { background: #fdf6e0; border-color: var(--amarillo); }
.nota-verde { background: #e6f7ec; border-color: var(--verde); }
.nota-azul { background: #e8f0fc; border-color: var(--azul); }
.nota-gris { background: #f0f2f5; border-color: #9aa4b0; }
.nota-meta { font-size: 12.5px; color: var(--texto-suave); margin-top: 6px; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-weight: 500; }
.flash-ok { background: #d9f2e3; color: #1e6e42; }
.flash-error { background: #fde2e2; color: #a33; }

/* Login */
.login-caja { max-width: 380px; margin: 10vh auto; background: #fff; border: 1px solid var(--gris-borde); border-radius: 14px; padding: 34px; }
.login-caja .logo-login { font-size: 26px; font-weight: 700; color: var(--azul-oscuro); text-align: center; margin-bottom: 6px; }
.login-caja p { text-align: center; color: var(--texto-suave); margin-bottom: 22px; }
.login-caja button { width: 100%; margin-top: 6px; }

/* Barra de acciones */
.acciones-barra { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.filtros a { padding: 7px 14px; border-radius: 20px; text-decoration: none; color: var(--texto-suave); font-weight: 600; font-size: 13.5px; border: 1px solid var(--gris-borde); background: #fff; }
.filtros a.activo { background: var(--azul); color: #fff; border-color: var(--azul); }

.vacio { text-align: center; color: var(--texto-suave); padding: 30px; }

/* DS-160 vista gestora (rediseño) */
.ds-gestora .ds-sec-g { border: 1px solid var(--gris-borde); border-radius: 12px; margin-bottom: 12px; overflow: hidden; background: #fff; }
.ds-gestora summary { background: var(--azul-claro); padding: 13px 16px; font-weight: 700; cursor: pointer; color: var(--azul-oscuro); font-size: 14.5px; list-style: none; user-select: none; }
.ds-gestora summary::-webkit-details-marker { display: none; }
.ds-gestora summary::before { content: '▸'; display: inline-block; margin-right: 8px; transition: transform .15s; }
.ds-gestora details[open] > summary::before { transform: rotate(90deg); }
.ds-gestora summary:hover { background: #dfeafb; }
.ds-sec-cuerpo { padding: 16px; }
.ds-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.ds-grid .ds-campo { display: flex; flex-direction: column; min-width: 0; }
.ds-grid .ds-campo label { font-size: 12.5px; color: var(--texto-suave); font-weight: 600; margin-bottom: 5px; }
.ds-input { width: 100%; padding: 10px 12px; border: 1px solid var(--gris-borde); border-radius: 8px; font-size: 14.5px; background: #fff; text-transform: uppercase; box-sizing: border-box; }
.ds-input { transition: box-shadow .15s ease, min-height .15s ease; }
.ds-input:focus { outline: 2px solid var(--azul-claro); border-color: var(--azul); }
input.ds-fecha { text-transform: none; }
/* Al seleccionar un campo, se agranda para leer/editar texto largo; al salir vuelve a normal */
.ds-grid .ds-campo:focus-within, .ds-campos .ds-campo:focus-within { grid-column: 1 / -1; }
.ds-grid .ds-campo:focus-within .ds-input, .ds-campos .ds-campo:focus-within .ds-input {
    min-height: 52px; font-size: 16px; box-shadow: 0 6px 22px rgba(26,75,140,.20); position: relative; z-index: 3;
}
/* Repetibles (acompañantes, viajes, países) */
.ds-repet-item { border: 1px dashed var(--gris-borde); border-radius: 10px; padding: 14px; margin-bottom: 10px; background: var(--gris-fondo); }
.ds-repet-titulo { font-weight: 700; color: var(--azul-oscuro); font-size: 13.5px; margin-bottom: 10px; }
/* Botones de IA */
.ds-ia { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ds-ia-btn { background: #f0e8fb; color: var(--morado); border: 1px solid #ddc9f5; border-radius: 20px; padding: 4px 11px; font-size: 12px; font-weight: 700; cursor: pointer; }
.ds-ia-btn:hover { background: var(--morado); color: #fff; }
.ds-ia-btn:disabled { opacity: .6; cursor: default; }
/* Barra "Completar sección con IA" */
.ds-sec-ia { display: flex; gap: 8px; margin-bottom: 14px; }
.ds-sec-ia-input { flex: 1; padding: 9px 12px; border: 1px dashed var(--morado); border-radius: 8px; font-size: 13.5px; background: #faf7fe; }
.ds-sec-ia-btn { background: var(--morado); white-space: nowrap; }
.ds-sec-ia-btn:hover { background: #5f39a8; }
/* Modal asistente IA */
.ia-modal { position: fixed; inset: 0; background: rgba(15,25,45,.55); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.ia-modal.visible { display: flex; }
.ia-modal-caja { background: #fff; border-radius: 16px; padding: 26px; max-width: 520px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.ia-modal-caja h2 { margin-bottom: 6px; }
.ia-modal-caja textarea { width: 100%; padding: 11px; border: 1px solid var(--gris-borde); border-radius: 8px; font-size: 14.5px; font-family: inherit; }
.ia-res { background: var(--azul-claro); border-left: 4px solid var(--azul); border-radius: 8px; padding: 12px 14px; margin-top: 12px; font-size: 15px; line-height: 1.4; }
.ds-agregar { margin-top: 2px; }
@media (max-width: 640px) { .ds-grid { grid-template-columns: 1fr; } }

/* Buscador dinámico */
.buscador { position: relative; margin-bottom: 16px; }
.buscador input { padding-left: 38px; }
.buscador::before { content: "🔍"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .55; pointer-events: none; }
.aviso-confirmar { background: #fff3cd; border: 1px solid #e6cf7a; border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }

/* Marcador de llamadas hoy/mañana en la barra lateral */
.marcador-llamadas { padding: 12px 20px; border-top: 1px solid rgba(255,255,255,.12); }
.marcador-llamadas .titulo { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: rgba(255,255,255,.55); margin-bottom: 8px; }
.marcador-fila { display: flex; gap: 8px; }
.marcador-caja { flex: 1; background: rgba(255,255,255,.08); border-radius: 8px; padding: 8px 10px; text-align: center; text-decoration: none; display: block; transition: background .15s; }
a.marcador-caja:hover { background: rgba(255,255,255,.18); }
.marcador-caja .num { font-size: 22px; font-weight: 700; color: #fff; line-height: 1; }
.marcador-caja .lbl { font-size: 11px; color: rgba(255,255,255,.6); margin-top: 3px; }

/* Alerta modal de llamada */
.alerta-modal { position: fixed; inset: 0; background: rgba(15,25,45,.55); display: none; align-items: center; justify-content: center; z-index: 1000; }
.alerta-modal.visible { display: flex; animation: alerta-aparece .2s ease; }
@keyframes alerta-aparece { from { opacity: 0; } to { opacity: 1; } }
.alerta-caja { background: #fff; border-radius: 16px; padding: 28px 30px; max-width: 440px; width: 92%; box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center; }
.alerta-caja .campana { font-size: 46px; animation: campana-mueve .8s ease-in-out infinite; display: inline-block; }
@keyframes campana-mueve { 0%,100% { transform: rotate(0); } 25% { transform: rotate(14deg); } 75% { transform: rotate(-14deg); } }
.alerta-caja h2 { font-size: 21px; margin: 10px 0 4px; }
.alerta-caja .sub { color: var(--texto-suave); margin-bottom: 18px; }
.alerta-item { background: var(--azul-claro); border-left: 4px solid var(--azul); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; text-align: left; font-size: 15.5px; }
.alerta-item .alerta-hora { display: inline-block; background: var(--azul); color: #fff; border-radius: 20px; padding: 1px 10px; font-size: 12.5px; font-weight: 700; margin-left: 6px; }
.alerta-item .alerta-tel { color: var(--texto-suave); font-size: 14px; margin-top: 4px; }
.alerta-caja button { width: 100%; margin-top: 8px; font-size: 16px; padding: 13px; background: var(--rojo); }
.alerta-caja button:hover { background: #b83636; }

/* Recordatorios (chips en el formulario de evento) */
.recordatorios { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; background: var(--gris-fondo); border: 1px solid var(--gris-borde); border-radius: 20px; padding: 6px 12px; font-weight: 500; font-size: 13.5px; cursor: pointer; }
.chip-check input { accent-color: var(--azul); }
.chip-otro { font-size: 13.5px; color: var(--texto-suave); }

/* Calendario mensual */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-encabezado { text-align: center; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--texto-suave); padding: 4px 0; }
.cal-celda { min-height: 96px; background: var(--gris-fondo); border: 1px solid var(--gris-borde); border-radius: 8px; padding: 5px; overflow: hidden; }
.cal-celda.cal-vacia { background: transparent; border: none; }
.cal-celda.cal-hoy { border-color: var(--azul); box-shadow: inset 0 0 0 1px var(--azul); }
.cal-dia { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; color: var(--texto-suave); margin-bottom: 4px; }
.cal-add { text-decoration: none; color: var(--azul); font-weight: 700; width: 20px; height: 20px; line-height: 18px; text-align: center; border-radius: 6px; }
.cal-add:hover { background: var(--azul-claro); }
.cal-chip { display: block; font-size: 11.5px; padding: 3px 6px; border-radius: 5px; margin-bottom: 3px; text-decoration: none; color: var(--texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; }
.cal-chip.chip-rojo { background: #fdeaea; border-color: var(--rojo); }
.cal-chip.chip-amarillo { background: #fdf6e0; border-color: var(--amarillo); }
.cal-chip.chip-verde { background: #e6f7ec; border-color: var(--verde); }
.cal-chip.chip-azul { background: #e8f0fc; border-color: var(--azul); }
.cal-chip.chip-gris { background: #eef0f3; border-color: #9aa4b0; }
.cal-chip.chip-morado { background: #f0e8fb; border-color: var(--morado); }
.alerta-item .alerta-falta { color: var(--texto-suave); font-size: 12.5px; }
a.alerta-item-link { display: block; text-decoration: none; color: inherit; cursor: pointer; }
a.alerta-item-link:hover { background: var(--azul-claro); }
.alerta-ir { display: block; color: var(--azul); font-weight: 700; font-size: 12.5px; margin-top: 6px; }

/* Bandeja de notificaciones */
.noti { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border: 1px solid var(--gris-borde); border-radius: 10px; margin-bottom: 8px; }
.noti-nueva { background: var(--azul-claro); border-color: #c7dbf5; }
.noti-icono { font-size: 22px; }
.noti-cuerpo { flex: 1; }
.noti-titulo { font-weight: 600; }
.noti-punto { display: inline-block; width: 8px; height: 8px; background: var(--rojo); border-radius: 50%; margin-left: 4px; vertical-align: middle; }
.noti-detalle { color: var(--texto-suave); font-size: 14px; margin-top: 2px; }
.noti-fecha { color: var(--texto-suave); font-size: 12.5px; margin-top: 4px; }
.noti-acciones { display: flex; gap: 6px; align-items: center; }

/* Leyenda de estados */
.leyenda-estados { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.leyenda-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--texto-suave); }
.punto { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.punto-rojo { background: var(--rojo); } .punto-amarillo { background: var(--amarillo); }
.punto-verde { background: var(--verde); } .punto-azul { background: var(--azul); }
.punto-gris { background: #9aa4b0; } .punto-morado { background: var(--morado); }

/* Insignias de estado (evento) */
.badge-estado { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; margin-left: 6px; }
.badge-rojo { background: #fdeaea; color: #b02a2a; }
.badge-amarillo { background: #fdf6e0; color: #8a6d00; }
.badge-verde { background: #e6f7ec; color: #1e6e42; }
.badge-azul { background: #e8f0fc; color: #1a4b8c; }
.badge-gris { background: #eef0f3; color: #555; }
.badge-morado { background: #f0e8fb; color: #6b3fa0; }

/* Línea de tiempo (historial del cliente) */
.timeline { display: flex; flex-direction: column; }
.t-item { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--gris-borde); }
.t-item:last-child { border-bottom: none; }
.t-fecha { min-width: 96px; text-align: center; }
.t-dia { font-weight: 700; font-size: 14px; }
.t-hora { color: var(--texto-suave); font-size: 13px; }
.t-cuando { display: inline-block; margin-top: 5px; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 20px; }
.t-pasada { background: #eef0f3; color: #777; }
.t-proxima { background: #d8e7fb; color: var(--azul); }
.t-cuerpo { flex: 1; border-left: 2px solid var(--gris-borde); padding-left: 16px; }
.t-titulo { font-size: 15px; margin-bottom: 4px; }
.t-notas { background: var(--gris-fondo); border-radius: 8px; padding: 8px 12px; font-size: 14px; margin: 6px 0; }
.t-meta { font-size: 12.5px; color: var(--texto-suave); }
.t-meta a { color: var(--azul); }

@media (max-width: 760px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .contenido { padding: 18px; }
    .cal-celda { min-height: 64px; }
    .cal-chip { font-size: 10px; }
}

/* ---- Módulo financiero (fase 2+) ---- */
.check-si-no { display: inline-block; min-width: 26px; text-align: center; padding: 2px 8px; border-radius: 20px; font-size: 12.5px; font-weight: 700; }
.check-si-no.si { background: #d9f2e3; color: #1e6e42; }
.check-si-no.no { background: #fde2e2; color: #a33; }
.check-si-no.parcial { background: #fdf6e0; color: #8a6d00; white-space: nowrap; }
.pendientes-chip { display: inline-block; background: #fdf6e0; color: #8a6d00; border: 1px solid #f0dc9a; border-radius: 20px; padding: 2px 9px; font-size: 12.5px; font-weight: 700; cursor: help; white-space: nowrap; }
.badge-azul { background: #e8f0fc; color: var(--azul); }
.badge-gris { background: #eef0f3; color: #556; }
.tabla-scroll { overflow-x: auto; }
.filtros-fecha a { font-size: 12.5px; padding: 5px 11px; }
.fechas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 16px; }
.fechas-grid div { font-size: 13.5px; padding: 6px 0; border-bottom: 1px dashed var(--gris-borde); }
.fechas-grid strong { display: block; color: var(--texto-suave); font-weight: 600; font-size: 12px; }
.embudo { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.embudo li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px; border-radius: 8px; background: var(--gris-fondo); font-size: 13px; }
.embudo li.hecho { background: #e6f7ec; }
.embudo li.revertido { background: #fdf6e0; }
.embudo .e-num { font-weight: 700; color: var(--texto-suave); min-width: 20px; }
.embudo .e-meta { display: block; color: var(--texto-suave); font-size: 12px; }
.tabla-auditoria td { font-size: 12.5px; vertical-align: top; }
.tabla-auditoria .valor { max-width: 220px; word-break: break-word; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }
.saldo-pos { color: var(--rojo); font-weight: 700; }
.saldo-cero { color: var(--verde); font-weight: 700; }
.mov-anulado td { opacity: .55; text-decoration: line-through; }

.banner-alerta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; font-size: 14.5px; }
.banner-aviso { background: #fdf6e0; border: 1px solid #f0dc9a; color: #6b5400; }
.banner-critica { background: #fde2e2; border: 1px solid #f3b4b4; color: #8a1f1f; }
.banner-info { background: #e8f0fc; border: 1px solid #c9d9f5; color: var(--azul-oscuro); }
.banner-alerta .btn { background: var(--rojo); }
.banner-aviso .btn { background: #b8860b; }
.banner-info .btn { background: var(--azul); }
