/* Operación: Inicio, Contratos, Cotizaciones, Cobranza. Usa los tokens de index.html. */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end)); border-color: transparent; color: #fff; }
.btn.primary:hover { opacity: .92; color: #fff; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* KPIs clicables */
.kpi-row.kpi-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-card.clickable { cursor: pointer; transition: border-color .15s, transform .15s; }
.kpi-card.clickable:hover { border-color: var(--primary); transform: translateY(-1px); }
.kpi-card .kpi-value.red { color: var(--danger); } .kpi-card .kpi-value.amber { color: var(--warn); }
.kpi-card .kpi-value.green { color: var(--success); }
.kpi-card.alert-left { border-left: 4px solid var(--danger); }
.kpi-card.warn-left { border-left: 4px solid var(--warn); }

/* chips */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  white-space: nowrap; background: #f1f5f9; color: #475569; }
.chip.red { background: #fee2e2; color: #b91c1c; } .chip.amber { background: #fef3c7; color: #b45309; }
.chip.green { background: #dcfce7; color: #15803d; } .chip.blue { background: #dbeafe; color: #1d4ed8; }
.chip.purple { background: #f3e8f5; color: var(--primary); }
.resp { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.resp b { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 10px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; }
.resp.none b { background: #cbd5e1; } .resp.none { font-style: italic; }

/* feed de alertas */
.alert-list { display: flex; flex-direction: column; }
.alert-item { display: grid; grid-template-columns: 6px 1fr auto auto; gap: 16px; align-items: center; padding: 14px 24px 14px 0;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.alert-item:last-child { border-bottom: none; } .alert-item:hover { background: #f8fafc; }
.alert-bar { align-self: stretch; border-radius: 0 3px 3px 0; background: #94a3b8; }
.alert-item.critica .alert-bar { background: var(--danger); } .alert-item.alta .alert-bar { background: var(--warn); }
.alert-item.media .alert-bar { background: var(--info); }
.alert-main { min-width: 0; padding-left: 4px; }
.alert-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-filters button { padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted);
  font-size: 12px; font-weight: 500; font-family: var(--font); cursor: pointer; }
.cat-filters button:hover { border-color: var(--primary); color: var(--primary); }
.cat-filters button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* tablas */
.ops-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ops-table th { text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ops-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ops-table tr:last-child td { border-bottom: none; }
.ops-table tbody tr.row-click { cursor: pointer; } .ops-table tbody tr.row-click:hover { background: #f8fafc; }
.ops-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ops-table .strong { font-weight: 600; } .ops-table .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.ops-table .acts { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.empty { padding: 32px 24px; text-align: center; color: var(--muted); font-size: 13px; }

/* aging */
.aging { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 16px 24px; }
.aging-cell { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
.aging-cell .l { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.aging-cell .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.aging-cell.t1 { border-top: 3px solid var(--warn); } .aging-cell.t2 { border-top: 3px solid #ea580c; } .aging-cell.t3 { border-top: 3px solid var(--danger); }

/* ficha de contrato */
.ficha { max-width: 1040px !important; }
.ficha-body { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 20px; background: var(--bg); }
.ficha-top { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.mini { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
.mini .l { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.mini .v { font-size: 16px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: 99px; background: #e2e8f0; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end)); }

/* formularios */
.ops-form-body { padding: 20px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.ops-form-body .full { grid-column: 1 / -1; }
.ops-form-body label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ops-form-body input, .ops-form-body select, .ops-form-body textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-family: var(--font); font-size: 14px; color: var(--fg); background: #fff; }
.ops-form-body input:focus, .ops-form-body select:focus, .ops-form-body textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139,46,139,.12); }
.ops-form-foot { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; padding-top: 6px; }
.ops-form-foot .spacer { flex: 1; }
.form-error { grid-column: 1 / -1; color: var(--danger); font-size: 13px; display: none; }

@media (max-width: 900px) {
  .kpi-row.kpi-5 { grid-template-columns: repeat(2, 1fr); }
  .ficha-top { grid-template-columns: repeat(2, 1fr); }
  .ops-form-body { grid-template-columns: 1fr; }
  .alert-item { grid-template-columns: 6px 1fr auto; } .alert-item .resp { display: none; }
  .aging { grid-template-columns: 1fr; }
}

/* ───────── barra superior (solo escritorio; en móvil manda index.html) ───────── */
@media (min-width: 1024px) {
  .header .header-inner { gap: 16px; padding: 0 20px; }
  .header .header-brand { flex-shrink: 0; }
  .header .header-nav { flex: 1; min-width: 0; justify-content: center; gap: 0; }
  .header .header-nav a { padding: 8px 10px; letter-spacing: 0; }
  .header .header-right { flex-shrink: 0; gap: 10px; }
  .bottom-nav { display: none; }
}
@media (max-width: 1500px) and (min-width: 1024px) { .header .header-date { display: none; } }
@media (max-width: 1240px) and (min-width: 1024px) { .header .header-name { display: none; } }

/* ───────── barra inferior móvil ───────── */
.bottom-nav { display: none; }
.bottom-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── tablet y móvil ───────── */
@media (max-width: 1023px) {
  html, body { overflow-x: hidden; }
  .main { grid-template-columns: minmax(0, 1fr); padding-bottom: 88px; }
  .main > .view { min-width: 0; }
  .header .header-name { font-size: 14px; }
  .header .sync-btn, .header .logout-btn { display: none !important; }   /* están en el menú */
  .mobile-nav-overlay { z-index: 150; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 160; background: var(--surface);
    border-top: 1px solid var(--border); box-shadow: 0 -2px 12px rgba(15,23,42,.08); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 8px;
    color: var(--muted); text-decoration: none; font-size: 10.5px; font-weight: 600; min-height: 48px; justify-content: center; }
  .bottom-nav a.active { color: var(--primary); background: #f3e8f5; }
  .toast { bottom: 84px; left: 16px; right: 16px; max-width: none; }

  /* tablas -> tarjetas */
  .ops-table thead { display: none; }
  .ops-table, .ops-table tbody { display: block; }
  .ops-table tbody tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .ops-table tbody tr:last-child { border-bottom: none; }
  .ops-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border: none; text-align: right !important; }
  .ops-table td::before { content: attr(data-label); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); text-align: left; flex-shrink: 0; }
  .ops-table td.c-main { display: block; text-align: left !important; padding-bottom: 8px; }
  .ops-table td.c-main::before { display: none; }
  .ops-table td.acts { justify-content: flex-end; padding-top: 10px; flex-wrap: wrap; }
  .ops-table td.acts::before, .ops-table td:empty { display: none; }
  .ops-table .sub { text-align: inherit; }
  .btn.sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
}

@media (max-width: 639px) {
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 14px; }
  .page-head h1 { font-size: 20px; }
  .page-head .btn { width: 100%; justify-content: center; min-height: 44px; }
  .kpi-row, .kpi-row.kpi-5 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-row.kpi-5 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi-card { padding: 14px 16px; }
  .kpi-card .kpi-value { font-size: 24px !important; }
  .kpi-card .kpi-label { font-size: 11px; }
  .cat-filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .cat-filters::-webkit-scrollbar { display: none; }
  .cat-filters button { white-space: nowrap; flex-shrink: 0; padding: 7px 14px; }
  .card-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .card-header > .btn { align-self: flex-start; }

  /* alertas: título en 2 líneas, plazo debajo */
  .alert-item { grid-template-columns: 6px 1fr; gap: 6px 12px; padding: 12px 16px 12px 0; }
  .alert-title, .alert-sub { white-space: normal; }
  .alert-item > .chip { grid-column: 2; justify-self: start; margin-left: 4px; }
  .alert-item > .resp, .alert-item > span:not(.chip) { display: none; }

  /* fichas y formularios a pantalla completa */
  /* `align-items: stretch` + `overflow: hidden` en el modal lo dejaba del alto de la pantalla y RECORTABA el resto del
     contenido (en el teléfono en vertical no se podía bajar). Con flex-start el modal mide lo que mide su contenido. */
  .modal-overlay.ops-ov { padding: 0; align-items: flex-start; overscroll-behavior: contain; }
  .modal-overlay.ops-ov .modal { max-width: none !important; width: 100%; min-height: 100%; border-radius: 0; margin: 0; }
  .ficha-body { padding: 14px 12px calc(110px + env(safe-area-inset-bottom)); gap: 14px; }   /* holgura para la barra flotante de Safari */
  .ficha-top { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .ficha-top > :last-child { grid-column: 1 / -1; }
  .modal-head { padding: 14px 16px; position: sticky; top: 0; z-index: 3; }
  .ops-form-body { padding: 16px; gap: 12px; }
  .ops-form-body input, .ops-form-body select, .ops-form-body textarea { font-size: 16px; padding: 11px 12px; }   /* evita zoom iOS */
  .ops-form-foot { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); margin-top: 6px; }
  .ops-form-foot .btn { min-height: 44px; flex: 1; justify-content: center; }
  .ops-form-foot .spacer { display: none; }
  .aging { padding: 12px 16px; gap: 8px; }
}

.ops-table .cv { display: block; }
@media (max-width: 1023px) { .ops-table td.acts .cv { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; } .ops-table td:not(.c-main) .cv { text-align: right; } }

/* evita que montos largos ensanchen la grilla */
.kpi-row > *, .ficha-top > *, .aging > * { min-width: 0; }
@media (max-width: 639px) {
  .kpi-card .kpi-value { font-size: 20px !important; overflow-wrap: anywhere; }
  .kpi-card .kpi-sub { overflow-wrap: anywhere; }
}

/* Evita el desborde horizontal: una tabla ancha no debe ensanchar la grilla de la página */
.main { grid-template-columns: minmax(0, 1fr); }
.content-main, .content-side { min-width: 0; }
@media (min-width: 1024px) { .content-grid { grid-template-columns: minmax(0, 1fr) 360px; } }

/* Pipeline: la tabla ancha hace scroll dentro de su tarjeta y la descripcion puede partirse en lineas */
#pipeline-container { overflow-x: auto; }
@media (min-width: 1024px) {
  .pipeline-table td.pipeline-desc-cell { white-space: normal; min-width: 200px; }
  .pipeline-table td.pipeline-stage-cell, .pipeline-table td.pipeline-value-cell, .pipeline-table td.pipeline-date-cell { white-space: nowrap; }
}
@media (min-width: 1024px) {
  .pipeline-table .pipeline-desc { display: block; max-width: none; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.35; }
}
@media (max-width: 1023px) {
  .pipeline-table .pipeline-desc { display: block; max-width: none; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.35; }
}

/* Toda vista activa es una grilla de UNA columna con ancho acotado (si no, el contenido ancho desborda la pantalla) */
.main > .view.active { grid-template-columns: minmax(0, 1fr); }
#inicio-ops, #inicio-prioridades { min-width: 0; }


/* ═════════════ Calendario ═════════════ */
.cal-acciones { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-acciones a.btn { text-decoration: none; }
.cal-barra { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav .btn { min-width: 38px; justify-content: center; }
.cal-filtros { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--fg); font: 500 12px var(--font); cursor: pointer; transition: opacity .15s, border-color .15s; }
.cal-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.cal-chip b { font-weight: 700; color: var(--muted); }
.cal-chip:hover { border-color: var(--c, var(--primary)); }
.cal-chip.off { opacity: .45; text-decoration: line-through; }
.cal-chip.mios { margin-left: auto; --c: var(--primary); }
.cal-chip.mios.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.cal-card { overflow: hidden; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-cab > div { padding: 10px 8px; text-align: center; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 112px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; min-width: 0; transition: background .1s; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: #fafbfd; }
.cal-cell.otro { background: #f8fafc; }
.cal-cell.otro .cal-num { color: #b6c0cd; }
.cal-num { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.cal-cell.hoy .cal-num span { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 11px;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end)); color: #fff; padding: 0 5px; }
.cal-evs { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-ev { display: block; font-size: 11px; line-height: 1.35; padding: 2px 6px; border-radius: 4px; background: var(--cb); color: var(--c);
  border-left: 3px solid var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; font-weight: 500; }
.cal-ev:hover { filter: brightness(.96); }
.cal-ev.venc { background: #fdeaea; color: #b91c1c; border-left-color: #b91c1c; }
.cal-mas { font-size: 11px; color: var(--muted); padding: 1px 6px; font-weight: 600; }

/* vista agenda */
.cal-dia-grupo { border-bottom: 1px solid var(--border); }
.cal-dia-grupo:last-child { border-bottom: none; }
.cal-dia-tit { padding: 10px 20px; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--muted); background: #f8fafc; }
.cal-dia-grupo.hoy .cal-dia-tit { color: var(--primary); }
.cal-fila { display: grid; grid-template-columns: 5px 68px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 11px 20px 11px 0; cursor: pointer; border-top: 1px solid #f1f5f9; }
.cal-fila:hover { background: #fafbfd; }
.cal-fbar { align-self: stretch; background: var(--c); border-radius: 0 3px 3px 0; }
.cal-fila.venc .cal-fbar { background: var(--danger); }
.cal-fhora { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; color: var(--fg); }
.cal-fhora small { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.cal-ftit { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.cal-fdet { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.cal-fcat { color: var(--c); font-weight: 600; }
.cal-fder { display: flex; align-items: center; gap: 8px; }
.cal-panel .cal-fila { padding-left: 0; }

@media (max-width: 1023px) { .cal-cell { min-height: 92px; } }
@media (max-width: 700px) {
  .cal-acciones { width: 100%; } .cal-acciones .btn { flex: 1; justify-content: center; min-height: 44px; }
  .cal-chip.mios { margin-left: 0; }
  .cal-filtros { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 4px; scrollbar-width: none; }
  .cal-filtros::-webkit-scrollbar { display: none; }
  .cal-chip { flex-shrink: 0; white-space: nowrap; padding: 7px 12px; }
  /* mes compacto: los eventos pasan a puntos; tocar el dia abre su lista */
  .cal-cell { min-height: 58px; padding: 4px 2px; text-align: center; }
  .cal-num { margin-bottom: 2px; }
  .cal-evs { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .cal-ev { font-size: 0; width: 8px; height: 8px; padding: 0; border-radius: 50%; background: var(--c); border: none; }
  .cal-ev.venc { background: #b91c1c; }
  .cal-mas { font-size: 10px; padding: 0; }
  .cal-fila { grid-template-columns: 5px 52px minmax(0, 1fr); gap: 10px; padding-right: 12px; }
  .cal-fder { grid-column: 3; }
  .cal-dia-tit { padding: 10px 14px; }
}


/* texto de ayuda en formularios y boton de confirmacion peligrosa */
.ops-form-body .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-fill:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

/* aviso de privacidad del muro */
.muro-aviso { padding: 10px 16px; font-size: 12px; line-height: 1.45; color: #475569; background: #f8fafc; border-bottom: 1px solid var(--border); }
.muro-aviso.alerta { background: #fef3c7; color: #92400e; border-bottom-color: #fde68a; }

/* muro: atajos del @bot, etiqueta de privado y boton de confirmar */
.muro-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); background: #fff; }
.muro-chips button { padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--fg);
  font: 500 12px var(--font); cursor: pointer; transition: border-color .15s, color .15s; }
.muro-chips button:hover { border-color: var(--primary); color: var(--primary); }
.muro-chips .chip-evento { border-color: var(--primary); color: var(--primary); }
.msg-priv { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px; background: #ede9fe; color: #6d28d9;
  font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; vertical-align: middle; }
.msg-acciones { margin-top: 8px; }
.msg-confirmar { padding: 6px 14px; border: none; border-radius: 6px; font: 600 12px var(--font); cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end)); }
.msg-confirmar:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 639px) {
  .muro-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .muro-chips::-webkit-scrollbar { display: none; }
  .muro-chips button { flex-shrink: 0; padding: 8px 14px; }
  .msg-bubble { max-width: 92%; }
}

/* adjuntos */
.ficha-adj { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 16px; }
.ficha-adj .l { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: auto; }
.btn.sm { text-decoration: none; }

/* calendario: leyenda de categorías y franja del día visto */
.cal-filtros { align-items: center; justify-content: space-between; gap: 10px 16px; }
.cal-leyenda { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cal-leyenda-t { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 2px; }
.cal-chip { gap: 8px; padding: 6px 8px 6px 12px; font-weight: 600; }
.cal-chip.on { background: color-mix(in srgb, var(--c) 10%, #fff); border-color: color-mix(in srgb, var(--c) 45%, #fff); }
.cal-chip i { width: 12px; height: 12px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }
.cal-chip b { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--c); color: #fff; font-size: 11px; text-align: center; }
.cal-chip b.cero { background: #e5e9f0; color: var(--muted); }
.cal-chip.off { opacity: 1; text-decoration: none; background: #f4f6f9; border-style: dashed; color: var(--muted); }
.cal-chip.off i { background: transparent; box-shadow: none; border: 2px solid #b6c0cd; }
.cal-chip.off b { background: #e5e9f0; color: var(--muted); }
.cal-chip.mios { padding: 6px 14px; margin-left: 0; }

.cal-dia-banner { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; }
.cal-dia-fecha { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.cal-dia-num { flex-shrink: 0; width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end)); }
.cal-dia-nom { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-dia-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-cell.sel { box-shadow: inset 0 0 0 2px var(--primary); background: color-mix(in srgb, var(--primary) 5%, #fff); }
.cal-cell.hoy:not(.sel) { background: #fdf6fb; }
.cal-dia-grupo.sel .cal-dia-tit { color: var(--primary); box-shadow: inset 4px 0 0 var(--primary); }
@media (max-width: 700px) {
  .cal-dia-banner { flex-wrap: wrap; } .cal-dia-fecha { flex-basis: 100%; order: -1; }
  .cal-dia-banner > .btn[data-act="cal-dia-ver"] { flex: 1; }
  .cal-leyenda-t { display: none; }
  .cal-filtros { flex-wrap: nowrap; overflow-x: auto; }
  .cal-leyenda { flex-wrap: nowrap; }
}

/* aviso de privacidad (bloqueante) y avisos de texto libre */
.aviso-ov { z-index: 1000; }
.aviso-modal { max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.aviso-body { padding: 16px 24px 4px; overflow-y: auto; }
.aviso-sec { margin-bottom: 12px; }
.aviso-sec strong { font-size: 13px; }
.aviso-sec p { font-size: 13.5px; color: var(--muted); margin: 2px 0 0; line-height: 1.5; }
.aviso-lnk { font-size: 13px; margin: 8px 0 12px; }
.aviso-lnk a { color: var(--primary); }
.aviso-ver { color: var(--muted); }
.aviso-foot { padding: 12px 24px 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.aviso-err { color: #b91c1c; font-size: 12.5px; }
.aviso-err:empty { display: none; }
.aviso-foot .btn-save { min-height: 44px; width: 100%; }
body.aviso-abierto { overflow: hidden; }
@media (max-width: 700px) {
  .aviso-ov { padding: 0; align-items: stretch; }
  .aviso-modal { max-width: none; max-height: none; width: 100%; border-radius: 0; }
  .aviso-body { flex: 1; padding: 14px 16px 4px; }
  .aviso-foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
}
.foot-priv { text-align: center; padding: 14px 16px 90px; font-size: 12px; }
.foot-priv a { color: var(--muted); text-decoration: underline; }
.hint-libre { font-size: 11.5px; color: var(--muted); padding: 0 16px 12px; }

/* documentos múltiples, vista previa, órdenes de compra y de trabajo */
.doc-lista { display: flex; flex-direction: column; }
.doc-fila { display: flex; align-items: center; gap: 10px 14px; padding: 12px 20px; border-top: 1px solid #f1f5f9; flex-wrap: wrap; }
.doc-fila:first-child { border-top: none; }
.doc-info { display: flex; align-items: center; gap: 8px 12px; min-width: 0; flex: 1 1 320px; flex-wrap: wrap; }
.doc-titulo { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.doc-meta { font-size: 12px; color: var(--muted); }
.doc-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.doc-modal { max-width: 960px !important; }
.doc-prev { background: #eef1f6; padding: 0; }
.doc-frame { display: block; width: 100%; height: min(74vh, 780px); border: 0; background: #fff; }
.doc-img { display: block; max-width: 100%; max-height: 74vh; margin: 0 auto; }
.doc-prev .empty { background: var(--surface); }
.doc-subida { display: flex; flex-direction: column; gap: 6px; }
.doc-up { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 6px; font-size: 13px; background: #f8fafc; border: 1px solid var(--border); }
.doc-up span:first-child { overflow-wrap: anywhere; font-weight: 600; }
.doc-up .e { color: var(--muted); text-align: right; flex-shrink: 0; }
.doc-up.run { border-color: #bfdbfe; background: #eff6ff; } .doc-up.run .e { color: #1d4ed8; }
.doc-up.ok { border-color: #bbf7d0; background: #f0fdf4; } .doc-up.ok .e { color: #15803d; }
.doc-up.err { border-color: #fecaca; background: #fef2f2; } .doc-up.err .e { color: #b91c1c; }

.oc-lista { display: flex; flex-direction: column; gap: 16px; padding: 16px 20px 20px; }
.oc-bloque { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.oc-cab { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 12px 16px; background: #f8fafc; }
.oc-id { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; }
.oc-id .sub, .ot-id .sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.oc-monto { font-weight: 700; font-variant-numeric: tabular-nums; }
.oc-acts { margin-left: auto; display: flex; gap: 6px; }
.ot-bloque { padding: 4px 16px 12px; border-top: 1px solid var(--border); }
.ot-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.ot-cab .l { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ot-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 12px; margin-bottom: 6px; border-left: 3px solid #5eead4; background: #f7fffd; border-radius: 0 6px 6px 0; }
.ot-id { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ot-dato { font-size: 13px; }
.ot-acts { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.ot-vacia { padding: 8px 0 4px; font-size: 13px; color: var(--muted); }
@media (max-width: 700px) {
  .doc-fila { padding: 12px 14px; } .doc-acts { margin-left: 0; width: 100%; }
  .oc-lista { padding: 12px; } .oc-acts, .ot-acts { margin-left: 0; width: 100%; }
  .doc-frame { height: 70vh; }
}
.ot-tit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-info .chip { flex-shrink: 0; }

/* ═════ carga de OT en lote ═════ */
.ot-cab-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.lote-modal { max-width: 880px !important; }
.lote-body { padding-bottom: 4px; }
.lote-comun.ops-form-body { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-bottom: 8px; }
.lote-drop { margin: 6px 24px 12px; padding: 16px; border: 2px dashed var(--border); border-radius: 10px; background: #f8fafc; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px; transition: border-color .15s, background .15s; }
.lote-drop.sobre { border-color: var(--primary); background: #fbf3fb; }
.lote-ayuda { font-size: 12px; color: var(--muted); }
.lote-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.lote-lista { margin: 0 24px; max-height: 38vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.lote-lista:empty { display: none; }
.lote-fila { display: grid; grid-template-columns: 28px minmax(0, 1.6fr) minmax(150px, 1fr) minmax(0, 1.2fr) 34px; gap: 10px; align-items: center;
  padding: 8px 12px; border-top: 1px solid #f1f5f9; font-size: 13px; }
.lote-fila:first-child { border-top: none; }
.lote-fila.ok { background: #f0fdf4; } .lote-fila.err { background: #fef2f2; } .lote-fila.run { background: #eff6ff; } .lote-fila.omit { opacity: .75; }
.lote-st { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.lote-fila.ok .lote-st { color: #15803d; } .lote-fila.err .lote-st { color: #b91c1c; }
.lote-spin { width: 14px; height: 14px; border: 2px solid #bfdbfe; border-top-color: #1d4ed8; border-radius: 50%; animation: lote-giro .8s linear infinite; }
@keyframes lote-giro { to { transform: rotate(360deg); } }
.lote-arch { min-width: 0; display: flex; flex-direction: column; }
.lote-nom { font-weight: 600; overflow-wrap: anywhere; }
.lote-tam { font-size: 11px; color: var(--muted); }
.lote-msg { font-size: 12px; color: #b91c1c; overflow-wrap: anywhere; }
.lote-ver { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lote-folio { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.lote-acc { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 12px; }
.lote-quitar { padding: 2px 8px; }
.lote-prog { margin: 12px 24px 0; height: 8px; border-radius: 6px; background: #e5e9f0; overflow: hidden; }
.lote-prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end)); transition: width .2s; }
.lote-res { margin: 8px 24px 4px; min-height: 18px; font-size: 13px; color: var(--muted); }
.lote-res.ok { color: #15803d; } .lote-res.err { color: #b91c1c; }
.lote-foot { padding: 8px 24px 20px; align-items: center; }
.lote-cuenta { font-size: 12px; color: var(--muted); }
@media (max-width: 700px) {
  .lote-comun.ops-form-body { grid-template-columns: 1fr; }
  .lote-drop, .lote-lista, .lote-prog, .lote-res { margin-left: 12px; margin-right: 12px; }
  .lote-lista { max-height: 44vh; }
  .lote-fila { grid-template-columns: 24px minmax(0, 1fr) 34px; }
  .lote-fila .lote-folio, .lote-fila .lote-ver { grid-column: 2 / 4; }
  .lote-fila .lote-quitar { grid-column: 3; grid-row: 1; }
  .lote-foot { padding: 8px 12px 16px; flex-wrap: wrap; }
}

/* ═════ calendario: eventos de varios días (un solo evento, dibujado continuo) ═════ */
.cal-ev.multi { position: relative; }
.cal-ev.cont-sig { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: -7px; }
.cal-ev.cont-prev { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -7px; border-left-color: transparent; }
.cal-ev.medio { opacity: .78; font-style: italic; }
.cal-cell:nth-child(7n) .cal-ev.cont-sig { margin-right: 0; border-radius: 4px; }
.cal-cell:nth-child(7n+1) .cal-ev.cont-prev { margin-left: 0; border-radius: 4px; border-left-color: var(--c); }
.cal-fila.cont .cal-fbar { background: repeating-linear-gradient(180deg, var(--c) 0 6px, transparent 6px 10px); }
.cal-fila.cont .cal-ftit { font-weight: 500; color: var(--muted); }
.cal-cont { font-size: 11px; font-weight: 500; color: var(--muted); }
@media (max-width: 700px) {
  .cal-ev.cont-sig, .cal-ev.cont-prev { margin: 0; }
}

.lote-ov [hidden] { display: none !important; }
.cal-ev.cal-ev-esp { visibility: hidden; background: none; border: none; }
@media (max-width: 700px) { .cal-ev.cal-ev-esp { display: none; } }
.lote-ver .chip { white-space: normal; line-height: 1.3; }

/* órdenes de trabajo: colapsar/mostrar y desplazamiento vertical dentro de cada OC */
.ot-toggle { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 8px; margin-left: -8px; border-radius: 6px; cursor: pointer; font: inherit; color: var(--fg); }
.ot-toggle:hover { background: #eef2f7; }
.ot-toggle:focus-visible, .ot-lista:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ot-chev { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-top: -3px; transition: transform .15s; flex-shrink: 0; }
.ot-bloque.colapsado .ot-chev { transform: rotate(-45deg); margin-top: 0; }
.ot-tog-txt { font-size: 12px; font-weight: 600; color: var(--primary); }
.ot-resumen { display: none; font-size: 12px; color: var(--muted); margin-right: auto; margin-left: 12px; }
.ot-bloque.colapsado .ot-resumen { display: inline; }
.ot-bloque.colapsado .ot-lista { display: none; }
.ot-lista { max-height: min(420px, 55vh); overflow-y: auto; padding-right: 6px; overscroll-behavior: contain; scrollbar-gutter: stable; }
@media (max-width: 700px) { .ot-lista { max-height: 50vh; } .ot-resumen { display: none !important; } }

/* con una ventana abierta, la página de atrás no debe desplazarse (evita el «rebote» y que se bloquee el scroll en iOS) */
body:has(.modal-overlay.open) { overflow: hidden; }

/* ═════ buscar nuevas en Mercado Público ═════ */
.mp-modal { max-width: 1040px !important; }
.mp-estado { margin: 4px 24px 8px; padding: 10px 14px; border-radius: 8px; background: #eff6ff; color: #1e3a8a; font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mp-estado.err { background: #fef2f2; color: #991b1b; } .mp-estado.vacio { background: #f8fafc; color: var(--muted); }
.mp-estado code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }
.mp-estado[hidden] { display: none; }
.mp-barra { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 0 24px 8px; }
.mp-barra .lote-folio { flex: 1 1 260px; width: auto; }
.mp-todas { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.mp-lista { max-height: 46vh; }
.mp-fila { display: grid; grid-template-columns: 28px 122px minmax(0, 2.2fr) minmax(0, 1.3fr) 96px 92px 100px; gap: 10px; align-items: start; padding: 9px 12px; border-top: 1px solid var(--border); font-size: 13px; }
.mp-fila:first-child { border-top: none; }
.mp-cab { position: sticky; top: 0; z-index: 1; background: #f8fafc; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); align-items: center; }
.mp-fila.ok { background: #f0fdf4; } .mp-fila.err { background: #fef2f2; }
.mp-cod { font-variant-numeric: tabular-nums; font-weight: 600; overflow-wrap: anywhere; }
.mp-desc, .mp-org { min-width: 0; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 2px; }
.mp-res { font-size: 12px; color: var(--muted); } .mp-res.ok { color: #15803d; } .mp-res.err { color: #b91c1c; }
.mp-val, .mp-cie { font-variant-numeric: tabular-nums; }
.mp-vacia { padding: 18px; text-align: center; color: var(--muted); }
.mp-fila input[type=checkbox] { width: 18px; height: 18px; margin-top: 1px; }
@media (max-width: 700px) {
  .mp-estado, .mp-barra { margin-left: 12px; margin-right: 12px; }
  .mp-cab { display: none; }
  .mp-fila { grid-template-columns: 24px minmax(0, 1fr); gap: 4px 10px; padding: 12px 10px; }
  .mp-fila > .mp-cod { grid-column: 2; }
  .mp-fila > .mp-desc, .mp-fila > .mp-org, .mp-fila > .mp-val, .mp-fila > .mp-cie, .mp-fila > .mp-eta { grid-column: 2; }
  .mp-fila > .mp-org::before { content: "Organismo: "; color: var(--muted); } .mp-fila > .mp-org { display: block; }
  .mp-fila > .mp-val::before { content: "Valor: "; color: var(--muted); } .mp-fila > .mp-cie::before { content: "Cierre: "; color: var(--muted); }
  .mp-lista { max-height: 44vh; }
}

/* cotizaciones por diagnóstico (ficha del contrato) y origen de la OC */
.oc-origen { font-size: 12px; color: #0f766e; font-weight: 600; overflow-wrap: anywhere; }
.oc-origen.sin { color: var(--muted); font-weight: 400; }
.cd-barra { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px 4px; flex-wrap: wrap; }
.cd-resumen { font-size: 12.5px; color: var(--muted); }
.cd-cuerpo { padding: 4px 20px 16px; }
.cd-filtros { margin-bottom: 10px; flex-wrap: wrap; }
.cd-bloque.colapsado .cd-cuerpo { display: none; }
.cd-bloque.colapsado .ot-chev { transform: rotate(-45deg); margin-top: 0; }
.cd-lista { max-height: min(460px, 60vh); }
.cd-fila { border-left-color: #fcd34d; background: #fffdf5; }
.cd-monto { font-weight: 700; font-variant-numeric: tabular-nums; }
.cd-fechas { display: flex; flex-direction: column; font-size: 12.5px; min-width: 130px; }
.checks-box { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface); overscroll-behavior: contain; }
.check-fila { display: flex !important; align-items: flex-start; gap: 8px; padding: 5px 0; font-size: 13px; font-weight: 400 !important; text-transform: none !important; letter-spacing: 0 !important; cursor: pointer; }
.check-fila input { width: auto !important; margin-top: 3px; flex-shrink: 0; }
.check-fila span { overflow-wrap: anywhere; }
@media (max-width: 700px) { .cd-barra, .cd-cuerpo { padding-left: 12px; padding-right: 12px; } .cd-lista { max-height: 50vh; } .cd-resumen { width: 100%; } }

/* Flechas para recorrer registros dentro de un formulario (cotizaciones por diagnóstico) */
.modal-head .form-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; margin-right: 10px; color: #fff; }
.form-nav .nav-flecha { width: 36px; height: 36px; border: 0; border-radius: 8px; background: rgba(255,255,255,.22); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.form-nav .nav-flecha:hover:not(:disabled) { background: rgba(255,255,255,.38); }
.form-nav .nav-flecha:disabled { opacity: .35; cursor: default; }
.form-nav .nav-pos { font-size: 13px; font-weight: 600; min-width: 58px; text-align: center; }
@media (max-width: 900px) { .form-nav .nav-flecha { width: 44px; height: 44px; } .modal-head .form-nav { margin-right: 6px; } }
