/* ===== ADL · Torre de Control — hoja de estilos ===== */
/* Paleta corporativa ADL: azul petróleo + naranja (tomados del logo).
   Tipografía: Big Shoulders Display para títulos/marca (la misma del
   Briefing ejecutivo), Public Sans para el resto — así el sistema y sus
   reportes comparten una sola identidad visual. */
:root {
  --navy: #00435c;        /* azul petróleo ADL (wordmark) */
  --navy-700: #00364a;
  --navy-600: #0a5f7d;    /* petróleo más claro para enlaces/acentos fríos */
  --teal: #d8480e;        /* naranja ADL — color de acción principal */
  --teal-dark: #b73a09;
  --accent: #d8480e;
  --bg: #eef1f4;
  --card: #ffffff;
  --ink: #17262f;
  --muted: #62727c;
  --line: #dbe3e8;
  --line-soft: #e8eef1;
  --danger: #d23b30;
  --danger-bg: #fdeceb;
  --warn: #c9791b;
  --warn-bg: #fdf1e3;
  --ok: #2f9e6b;
  --ok-bg: #e7f6ee;
  --shadow: 0 1px 2px rgba(9, 30, 42, .06), 0 8px 24px rgba(9, 30, 42, .07);
  --shadow-lg: 0 4px 10px rgba(9, 30, 42, .08), 0 20px 48px rgba(9, 30, 42, .12);
  --radius: 14px;
  --radius-sm: 9px;
  --font-body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Big Shoulders Display", "Public Sans", -apple-system, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-600); }
h1, h2, h3 { margin: 0 0 .4em; color: var(--navy); font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .52rem .65rem; width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(216, 72, 14, .14); }
label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; letter-spacing: .01em; }
.field { margin-bottom: .8rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem; }
@media (max-width: 720px) { .row, .row-3 { grid-template-columns: 1fr; } }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  background: var(--navy); color: #fff; border: 1px solid var(--navy);
  border-radius: var(--radius-sm); padding: .52rem .95rem; font-weight: 600; white-space: nowrap;
  transition: filter .12s ease, transform .12s ease, box-shadow .12s ease;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(9, 30, 42, .14); }
.btn:active { transform: translateY(0); filter: brightness(1.02); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; box-shadow: none; }
.btn.secondary { background: #fff; color: var(--navy); border-color: var(--line); }
.btn.teal { background: var(--teal); border-color: var(--teal); }
.btn.ghost { background: transparent; color: var(--navy-600); border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: rgba(10, 95, 125, .08); box-shadow: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.sm { padding: .34rem .65rem; font-size: .82rem; border-radius: 7px; }

/* ---------- shell ---------- */
#app { min-height: 100%; }
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, #002b3c 100%);
  color: #c9dee6; padding: 1rem .7rem; display: flex; flex-direction: column; gap: .15rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: .3rem .3rem 1rem; }
.brand img { height: 40px; width: auto; background: #fff; border-radius: 8px; padding: 5px 8px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.brand .t { font-family: var(--font-display); font-weight: 800; color: #fff; font-size: 1.05rem; line-height: 1.1; letter-spacing: .02em; }
.brand .t small { display: block; font-family: var(--font-body); font-weight: 500; color: #7fb0c1; font-size: .66rem; letter-spacing: .07em; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .6rem; border-radius: var(--radius-sm);
  color: #cfe0ee; text-decoration: none; font-weight: 600; font-size: .87rem; border: none; background: none; width: 100%; text-align: left;
  transition: background .12s ease, color .12s ease;
}
.nav-item .ico { width: 18px; text-align: center; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; box-shadow: 0 3px 10px rgba(216, 72, 14, .35); }
.nav-item.active .ico { opacity: 1; }
.nav-sep { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: #6f93b0; padding: .9rem .6rem .3rem; }
.nav-badge { margin-left: auto; background: var(--warn); color: #fff; border-radius: 999px; font-size: .68rem; padding: .05rem .4rem; font-weight: 700; }
/* Menú agrupado */
.nav-group { display: flex; align-items: center; gap: .6rem; padding: .55rem .6rem; border-radius: 8px; color: #eaf2f8; font-weight: 700; font-size: .88rem; border: none; background: none; width: 100%; text-align: left; cursor: pointer; margin-top: .25rem; }
.nav-group .ico { width: 18px; text-align: center; }
.nav-group .chev { margin-left: auto; font-size: .7rem; opacity: .6; transition: transform .15s; }
.nav-group:hover { background: rgba(255,255,255,.07); }
.nav-group.open { color: #fff; }
.nav-group.open .chev { transform: rotate(90deg); }
.nav-grouprow { position: relative; }
.nav-sub { display: none; flex-direction: column; gap: .1rem; margin: .1rem 0 .3rem .55rem; padding-left: .5rem; border-left: 1px solid rgba(255,255,255,.12); }
.nav-sub.is-open { display: flex; }
.nav-sub .nav-item { font-size: .83rem; padding: .42rem .55rem; font-weight: 500; }
.nav-sub .nav-item.active { font-weight: 700; }

/* Botón para comprimir/expandir el menú lateral */
.navtoggle { margin-left: auto; background: none; border: none; color: #8fb9c9; cursor: pointer; font-size: 1rem; line-height: 1; padding: .15rem .4rem; border-radius: 6px; }
.navtoggle:hover { background: rgba(255,255,255,.12); color: #fff; }

/* Menú comprimido: riel de iconos con submenú flotante al pasar el cursor —
   solo tiene sentido con espacio horizontal de sobra; en móvil el menú es un
   cajón (drawer) de ancho completo, ver @media (max-width: 860px) abajo. */
@media (min-width: 861px) {
  .layout.nav-collapsed { grid-template-columns: 62px 1fr; }
  .nav-collapsed .sidebar { padding: 1rem .4rem; overflow: visible; }
  .nav-collapsed .brand { justify-content: center; padding: .3rem 0 1rem; }
  .nav-collapsed .brand .t { display: none; }
  .nav-collapsed .brand img { height: 34px; }
  .nav-collapsed .navtoggle { position: absolute; top: .55rem; right: .3rem; margin: 0; }
  .nav-collapsed .nav-item > span:not(.ico):not(.nav-badge),
  .nav-collapsed .nav-group > span:not(.ico),
  .nav-collapsed .nav-group .chev { display: none; }
  .nav-collapsed .nav-item, .nav-collapsed .nav-group { justify-content: center; padding: .55rem 0; gap: 0; margin-top: .1rem; }
  .nav-collapsed .nav-item .ico, .nav-collapsed .nav-group .ico { width: auto; font-size: 1.05rem; }
  .nav-collapsed .nav-badge { position: absolute; top: .2rem; right: .2rem; margin: 0; }
  .nav-collapsed .nav-grouprow > .nav-item, .nav-collapsed > .sidebar > .nav-item { position: relative; }
  .nav-collapsed .nav-sub, .nav-collapsed .nav-sub.is-open { display: none; position: absolute; left: 58px; top: 0; z-index: 60;
    background: #023344; border: 1px solid rgba(255,255,255,.16); border-radius: 10px; padding: .35rem; margin: 0;
    min-width: 210px; box-shadow: 0 14px 34px rgba(0,0,0,.4); }
  .nav-collapsed .nav-grouprow:hover .nav-sub { display: flex; }
  .nav-collapsed .nav-sub .nav-item > span:not(.ico):not(.nav-badge) { display: inline; }
  .nav-collapsed .nav-sub .nav-item { justify-content: flex-start; padding: .42rem .55rem; gap: .5rem; }
}

/* Botón de hamburguesa (solo móvil) y telón de fondo del cajón de menú —
   creados en app.js -> renderShell. */
.navtoggle-mobile { display: none; background: none; border: none; color: var(--navy); font-size: 1.35rem; line-height: 1; padding: .2rem .55rem; margin-right: .1rem; cursor: pointer; border-radius: 6px; }
.navtoggle-mobile:hover { background: rgba(11,46,79,.08); }
.nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(9,24,36,.55); z-index: 290; }
.nav-backdrop.show { display: block; }

/* ---------- móvil: el menú lateral pasa de columna fija a cajón (drawer) ----------
   Antes de esto, .layout reservaba 232px fijos para el menú SIEMPRE, sin
   importar el ancho de pantalla — en un teléfono eso deja al contenido en una
   columna angostísima, obligando a hacer zoom/pan constante (de ahí que "se
   mueva todo y se vea desenfocado"). Con esto, en pantallas angostas el menú
   se oculta fuera de la pantalla y se abre como cajón con el botón ☰. */
@media (max-width: 860px) {
  .layout, .layout.nav-collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 268px; max-width: 84vw;
    z-index: 300; transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 12px 0 32px rgba(0,0,0,.35);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .navtoggle { display: none; }
  .navtoggle-mobile { display: inline-block; }
  .content { padding: 1rem .8rem; max-width: 100%; }
  .topbar { padding: .6rem .8rem; gap: .5rem; flex-wrap: wrap; }
  #page-title { font-size: 1.1rem; }
  .userchip .who { display: none; }
  .userchip .btn { padding: .3rem .5rem; font-size: .78rem; }
}

/* Barra de sub-pestañas del bloque */
.subbar { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid var(--line, #e2e8ec); padding-bottom: .5rem; }
.subbar a { padding: .4rem .8rem; border-radius: 8px 8px 0 0; font-weight: 600; font-size: .84rem; color: var(--muted, #5a6b76); text-decoration: none; cursor: pointer; white-space: nowrap; }
.subbar a:hover { background: rgba(0,0,0,.04); color: var(--ink, #16323f); }
.subbar a.active { background: var(--navy, #00435c); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .7rem 1.3rem;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; }
.userchip { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.userchip .who { text-align: right; line-height: 1.15; }
.userchip .who b { display: block; font-size: .85rem; color: var(--navy); }
.userchip .who span { font-size: .74rem; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.topbar { box-shadow: inset 0 -2px 0 var(--accent); }
#page-title { color: var(--navy); font-family: var(--font-display); }
.content { padding: 1.4rem; max-width: 1240px; width: 100%; }

/* ---------- pantalla completa (reportes) ---------- */
/* Oculta menú y barra superior para ver/proyectar un reporte a todo lo ancho.
   Se activa con el botón "⛶ Pantalla completa" de cada reporte (ver app.js). */
body.presentacion .layout { display: block; }
body.presentacion .sidebar, body.presentacion .topbar { display: none !important; }
body.presentacion .content { max-width: 1400px; margin: 0 auto; padding: 1.6rem 2rem 3rem; }
.salir-presentacion {
  position: fixed; top: 14px; right: 18px; z-index: 500;
}

/* ---------- impresión ---------- */
@media print {
  body.presentacion .content { padding: 0; }
  .sidebar, .topbar, .salir-presentacion, #toasts, #modal-root, .bell-panel { display: none !important; }
  .layout, .main, .content { display: block !important; width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
  body { background: #fff !important; }
  .card, .kpi, ol.risk-list > li { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
  .section-title button, .card-head button, .grid button { display: none !important; }
  a[href]::after { content: ''; }
}

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 1.15rem 1.2rem; }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; align-items: center; gap: .6rem; padding: .95rem 1.2rem; border-bottom: 1px solid var(--line-soft); }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 1.15rem 1.2rem; }
.grid { display: grid; gap: 1rem; }
.grid.k4 { grid-template-columns: repeat(4, 1fr); }
.grid.k3 { grid-template-columns: repeat(3, 1fr); }
.grid.k2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .grid.k4 { grid-template-columns: repeat(2, 1fr); } .grid.k3 { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .grid.k4, .grid.k2 { grid-template-columns: 1fr; } }

/* Fila de 4 tarjetas KPI (usada en Monitoreo en vivo e Indicadores de
   Monitoreo) — a diferencia de .grid.k4 nunca cae a una sola columna:
   en teléfono se ven chicas en 2x2 en vez de una debajo de otra a pantalla
   completa (reporte real de Monitoreo — "se mueve todo, queda desenfocado"). */
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
@media (max-width: 1000px) { .row-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) {
  .row-4 { gap: .5rem; }
  .row-4 .kpi { padding: .65rem .7rem; }
  .row-4 .kpi .n { font-size: 1.35rem; }
  .row-4 .kpi .l { font-size: .64rem; }
}

/* ---------- KPI ---------- */
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.05rem 1.1rem; box-shadow: var(--shadow); transition: box-shadow .15s ease, transform .15s ease; }
.kpi .n { font-family: var(--font-display); font-size: 2.05rem; font-weight: 800; color: var(--navy); letter-spacing: -.02em; line-height: 1.1; }
.kpi .l { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.kpi.accent { background: linear-gradient(160deg, var(--navy), var(--navy-700)); border-color: var(--navy); }
.kpi.accent .n, .kpi.accent .l { color: #fff; }
.kpi.warn .n { color: var(--warn); }
.kpi.danger .n { color: var(--danger); }

/* ---------- tabla ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.tbl th { text-align: left; color: var(--muted); font-size: .71rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; padding: .6rem .65rem; border-bottom: 2px solid var(--line-soft); white-space: nowrap; background: #f8fafb; }
table.tbl td { padding: .6rem .65rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tr { transition: background .1s ease; }
table.tbl tr:hover td { background: #f6f9fb; }
table.tbl tr.clickable { cursor: pointer; }
table.tbl tr.alert td { background: #fffafa; }
table.tbl tr.alert:hover td { background: #fdf1f1; }

/* ---------- badges / pills ---------- */
.badge { display: inline-block; padding: .16rem .55rem; border-radius: 999px; font-size: .71rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.badge.gray { background: #eef2f6; color: #556; }
.badge.blue { background: #e5eefb; color: #1b4f8a; }
.badge.teal { background: #dff4f2; color: var(--teal-dark); }
.badge.green { background: var(--ok-bg); color: var(--ok); }
.badge.amber { background: var(--warn-bg); color: var(--warn); }
.badge.red { background: var(--danger-bg); color: var(--danger); }

.pipeline { display: flex; flex-wrap: wrap; gap: .3rem; margin: .2rem 0 .6rem; }
.stage-pill { font-size: .68rem; font-weight: 700; padding: .18rem .5rem; border-radius: 6px; background: #eef2f6; color: #8a99a8; }
.stage-pill.done { background: #dff4f2; color: var(--teal-dark); }
.stage-pill.current { background: var(--navy); color: #fff; }
.stage-pill.cancel { background: var(--danger-bg); color: var(--danger); }

/* ---------- funnel ---------- */
.funnel { display: flex; flex-direction: column; gap: .35rem; width: 100%; flex: 1 1 100%; min-width: 0; }
.funnel .fr { display: grid; grid-template-columns: 130px minmax(60px, 1fr) 44px; align-items: center; gap: .6rem; font-size: .82rem; }
.funnel .bar { height: 20px; border-radius: 5px; background: var(--navy-600); min-width: 3px; }
.funnel .fr:nth-child(odd) .bar { background: var(--teal); }
.funnel .cnt { text-align: right; font-weight: 700; color: var(--navy); }

/* ---------- svc cards ---------- */
.svc-card { border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem; background: #fff; }
.svc-card.alert { border-color: #f0c2c2; background: #fffafa; }
.svc-card .top { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.svc-card .folio { font-weight: 800; color: var(--navy); }
.svc-card .meta { color: var(--muted); font-size: .8rem; }
.svc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(9, 24, 36, .58); backdrop-filter: blur(1.5px); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; gap: .6rem; padding: 1.05rem 1.2rem; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: #fff; }
.modal-head h2 { margin: 0; }
.modal-head .x { margin-left: auto; background: none; border: none; font-size: 1.3rem; color: var(--muted); line-height: 1; }
.modal-body { padding: 1.2rem; }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; padding: 1rem 1.2rem; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: .3rem 0 .7rem 1rem; font-size: .83rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .55rem; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }
.timeline li .t { color: var(--muted); font-size: .74rem; }

/* ---------- login ---------- */
.login-wrap { position: relative; min-height: 100vh; display: grid; place-items: center; background: linear-gradient(150deg, var(--navy) 0%, #002230 55%, #063845 100%); padding: 1rem; overflow: hidden; }
.login-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.login-bg svg { width: 100%; height: 100%; display: block; }
.login-col { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 396px; }
.login-card { position: relative; z-index: 1; background: #fff; border-radius: 18px; padding: 2.25rem 2.1rem; width: 100%; max-width: 396px; box-shadow: 0 28px 80px rgba(0, 8, 14, .5); overflow: hidden; }
.login-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--teal) 0%, #f08a4b 55%, var(--navy-600) 100%); }
.login-card .logo { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin-bottom: 1.4rem; }
.login-card .logo img { height: 46px; }
.login-card .logo b { color: var(--navy); font-family: var(--font-display); font-size: 1.2rem; letter-spacing: .01em; text-align: center; }
.login-card .logo span { color: var(--muted); font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; text-align: center; }
.login-err { background: var(--danger-bg); color: var(--danger); padding: .5rem .7rem; border-radius: 8px; font-size: .83rem; margin-bottom: .8rem; }
.login-foot { position: relative; z-index: 1; margin-top: 1.1rem; text-align: center; color: rgba(255, 255, 255, .9); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; text-shadow: 0 1px 6px rgba(4, 20, 30, .7); }

/* ---------- misc ---------- */
.toast-wrap { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; }
.toast { background: var(--navy); color: #fff; padding: .7rem 1rem; border-radius: 9px; box-shadow: var(--shadow); font-size: .85rem; max-width: 320px; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- burbuja de mensaje interno nuevo ---------- */
.chat-bubble-wrap { position: fixed; right: 1rem; top: 4.2rem; display: flex; flex-direction: column; gap: .5rem; z-index: 210; max-width: 320px; }
.chat-bubble {
  background: #fff; border: 1px solid var(--border, #d3dedd); border-radius: 12px; box-shadow: var(--shadow);
  padding: .65rem .8rem; display: flex; gap: .6rem; align-items: flex-start; cursor: pointer;
  animation: chatBubbleIn .25s ease-out;
}
.chat-bubble:hover { border-color: var(--navy); }
.chat-bubble .avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 700; }
.chat-bubble .body { min-width: 0; flex: 1; }
.chat-bubble .nombre { font-weight: 700; font-size: .84rem; }
.chat-bubble .texto { font-size: .82rem; color: var(--ink, #1b2a2e); margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chat-bubble .x { flex: none; background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; line-height: 1; padding: 0 0 0 .3rem; }
@keyframes chatBubbleIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.stack > * + * { margin-top: .8rem; }
.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.pre {
  white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem;
  background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: .8rem; max-height: 320px; overflow: auto;
}
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: #eef2f6; border-radius: 6px; padding: .2rem .55rem; font-size: .78rem; }
.hidden { display: none !important; }

/* ---------- Componentes "TMS profesional" reutilizables ----------
 * Estrenados en Casetas de la ruta (Pricing); de aquí en adelante son el
 * estándar visual del sistema — cualquier modal/tarjeta nueva los reutiliza
 * en vez de estilos inline. Construidos sobre los tokens de siempre
 * (--navy, --ok/--warn/--danger, --card, --line, --shadow), sin paleta nueva. */
.win-sub { font-size: .8rem; color: var(--muted); margin: 0 0 .2rem; }
.kpi-flex { display: flex; gap: .65rem; align-items: flex-start; padding: .8rem .9rem; }
.kpi-flex .l { font-size: .7rem; }
.kpi-flex .v { font-size: 1rem; font-weight: 700; color: var(--navy); margin-top: .1rem; }
.ico-avatar {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px; background: #eaf1f5;
  display: grid; place-items: center; font-size: 1.05rem;
}
.kpi-flex.highlight { background: #f4f8fb; border-color: #d7e6ee; }
.kpi-flex.highlight .ico-avatar { background: var(--navy); }
.info-banner {
  display: flex; gap: .5rem; align-items: flex-start; background: #eef5fb; border: 1px solid #d7e6ee;
  border-radius: 8px; padding: .6rem .8rem; font-size: .8rem; color: var(--navy-700);
}
table.tbl.tbl-compact th, table.tbl.tbl-compact td { padding: .5rem .55rem; }
.drag-row { cursor: grab; }
.drag-row.dragging { opacity: .35; }
.drag-row.drop-before td { box-shadow: inset 0 2px 0 0 var(--teal); }
.drag-row.drop-after td { box-shadow: inset 0 -2px 0 0 var(--teal); }
.drag-handle { color: var(--muted); font-size: .95rem; cursor: grab; user-select: none; }
.search-add-wrap { position: relative; }
.search-add-results {
  margin-top: .3rem; max-height: 190px; overflow: auto; border: 1px solid var(--line);
  border-radius: 8px; background: #fff;
}
.search-add-results .search-add-row {
  display: flex; justify-content: space-between; align-items: center; padding: .4rem .6rem; font-size: .84rem;
}
.search-add-results .search-add-row:hover { background: #f7fafc; }
.search-add-results .search-add-row + .search-add-row { border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; gap: 1rem; flex-wrap: wrap; }

/* ---------- campana de alertas ---------- */
.bell { position: relative; cursor: pointer; font-size: 1.15rem; padding: .3rem .45rem; border-radius: 8px; line-height: 1; }
.bell:hover { background: #f0f3f7; }
.bell-badge { position: absolute; top: -2px; right: -2px; background: var(--warn); color: #fff; border-radius: 999px; font-size: .64rem; font-weight: 800; min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 3px; }
.bell-badge.alta { background: var(--danger); }
.bell-panel { position: absolute; top: 54px; right: 90px; width: min(420px, 92vw); max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 48px rgba(11,30,48,.25); z-index: 60; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem .9rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.bell-item { padding: .6rem .9rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.bell-item:hover { background: #f7fafc; }
.bell-item.alta { border-left: 3px solid var(--danger); }
.bell-item.media { border-left: 3px solid var(--warn); }
.bell-item .bi-top { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .2rem; font-size: .74rem; }

/* ---------- barra de índice ---------- */
.idx-bar { background: #eef2f6; border-radius: 5px; height: 14px; width: 120px; overflow: hidden; }
.idx-bar span { display: block; height: 100%; background: var(--danger); }

/* ---------- adjuntos ---------- */
.adj-row { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.adj-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
.adj-ico { width: 48px; height: 48px; display: grid; place-items: center; background: #f0f3f7; border-radius: 7px; font-size: 1.3rem; }
.adj-meta { flex: 1; min-width: 0; }
.adj-meta a { font-weight: 600; word-break: break-all; }
.adj-upload { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--line); }
.adj-upload input[type=file] { border: none; padding: 0; }

/* ---------- filtros de tabla ---------- */
.filter-bar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { padding: .4rem .55rem; }

/* ---------- diagrama de llantas ---------- */
.tire-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: .55rem; }
.tire { border: 1px solid var(--line); border-radius: 10px; padding: .55rem .5rem; text-align: center; cursor: pointer; background: #fff; transition: transform .1s ease; }
.tire:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.tire-pos { font-size: .72rem; font-weight: 800; color: var(--navy); letter-spacing: .03em; }
.tire-mm { font-size: 1.05rem; font-weight: 800; margin: .15rem 0; }
.tire-meta { font-size: .68rem; color: var(--muted); }
.tire.tire-ok { border-color: #b7e2cd; }
.tire.tire-ok .tire-mm { color: var(--ok); }
.tire.tire-warn { border-color: #f0d8a8; background: var(--warn-bg); }
.tire.tire-warn .tire-mm { color: var(--warn); }
.tire.tire-bad { border-color: #f0c2c2; background: var(--danger-bg); }
.tire.tire-bad .tire-mm { color: var(--danger); }
.tire.tire-empty { border-style: dashed; background: #f6f8f9; }
.tire.tire-empty .tire-mm { color: #b9c4c9; }

/* ---------- gráficos ---------- */
.chart-legend { display: flex; flex-direction: column; gap: .35rem; font-size: .8rem; color: var(--ink); }
.chart-legend span { display: flex; align-items: center; gap: .45rem; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-radar { display: block; margin: 0 auto; }
.chart-heat { min-width: 520px; }

/* bloque estándar: gráfico + tabla de datos */
.chart-block { }
.chart-block-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; flex-wrap: wrap; }
.chart-block-head h3 { margin: 0; font-size: .95rem; color: var(--navy); }
.chart-block-head .btn { margin-left: auto; }
.chart-note { font-size: .74rem; color: var(--muted); width: 100%; }
.chart-canvas { display: flex; justify-content: center; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.chart-table { margin-top: .7rem; }
.chart-table .tbl { font-size: .82rem; }
.chart-table .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .4rem; vertical-align: middle; }

/* interactividad de shapes SVG */
.chart [data-hit] { cursor: pointer; transition: opacity .1s ease, stroke-width .1s ease; }
.chart [data-hit]:hover { opacity: .78; }
.chart .ch-cell:hover { stroke: var(--navy); stroke-width: 2; }
.chart .ch-dot:hover { r: 6; }
.chart .ch-bar:hover, .chart .ch-seg:hover { opacity: .85; }

/* Entrada animada de gráficos (barras, segmentos, celdas, radar) — ver public/js/anim.js */
@keyframes chIn { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
.chart .ch-anim-in { transform-box: fill-box; transform-origin: center; animation: chIn .45s cubic-bezier(.2,.8,.2,1) both; }
@media (prefers-reduced-motion: reduce) {
  .chart .ch-anim-in { animation: none; }
}

/* ---------- Organigrama ---------- */
.org-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .78rem; color: var(--muted); align-items: center; }
.org-legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: .3rem; vertical-align: middle; }
.org-box-wrap { display: inline-flex; flex-direction: column; align-items: center; gap: .2rem; }
.org-box { display: inline-flex; align-items: center; gap: .5rem; background: #fff; border: 1px solid var(--line); border-left: 5px solid #8a99a8; border-radius: 8px; padding: .45rem .7rem; box-shadow: var(--shadow); cursor: pointer; max-width: 240px; text-align: left; }
.org-box:hover { box-shadow: 0 2px 6px rgba(11,46,79,.14), 0 10px 28px rgba(11,46,79,.10); }
.org-box.ocupado { border-left-color: var(--navy); }
.org-box.vacante { border-left-color: var(--warn); background: #fffaf2; }
.org-box.especial { border-left-color: #7b3fa0; }
.org-box.unidad { border-left-color: #2f9e6b; background: #f3fbf6; }
.org-box .org-puesto { font-weight: 700; font-size: .84rem; color: var(--navy); }
.org-box .org-ocupante { font-size: .8rem; color: var(--ink); }
.org-box .org-area { font-size: .7rem; color: var(--muted); }

/* Árbol horizontal (raíz arriba, hijos en fila debajo, con líneas conectoras
   dibujadas en CSS puro — técnica clásica de <ul><li> + border). */
.org-scroll { overflow-x: auto; padding-bottom: .5rem; }
.org-tree-h { display: inline-flex; gap: 2.5rem; min-width: 100%; }
.org-tree-h-root, .org-tree-h ul { list-style: none; margin: 0; padding: 0; }
.org-tree-h-root { display: flex; }
.org-tree-h li { display: flex; flex-direction: column; align-items: center; position: relative; padding: 1.6rem .6rem 0; }
.org-tree-h ul.org-children { display: flex; padding-top: 1.6rem; position: relative; }
.org-tree-h ul.org-children.hidden { display: none; }
.org-tree-h li::before, .org-tree-h li::after {
  content: ''; position: absolute; top: 0; right: 50%; width: 50%; height: 1.6rem; border-top: 2px solid var(--line);
}
.org-tree-h li::after { right: auto; left: 50%; border-left: 2px solid var(--line); }
.org-tree-h li:only-child::before, .org-tree-h li:only-child::after { display: none; }
.org-tree-h li:only-child { padding-top: 0; }
.org-tree-h li:first-child::before, .org-tree-h li:last-child::after { border: 0 none; }
.org-tree-h li:first-child:not(:last-child)::after { border-radius: 6px 0 0 0; }
.org-tree-h li:last-child:not(:first-child)::before { border-radius: 0 6px 0 0; }
.org-tree-h > .org-tree-h-root > li { padding-top: 0; }
.org-tree-h > .org-tree-h-root > li::before, .org-tree-h > .org-tree-h-root > li::after { display: none; }
.org-tree-h ul.org-children::before {
  content: ''; position: absolute; top: 0; left: 50%; width: 0; height: 1.6rem; border-left: 2px solid var(--line);
}
.org-toggle { font: inherit; font-size: .68rem; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .05rem .4rem; cursor: pointer; color: var(--muted); line-height: 1.3; }
.org-toggle:hover { background: var(--panel, #f4f7f9); color: var(--navy); }

/* ---------- Plan de mantenimiento: filtros + calendario ---------- */
.filtros-mto { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.filtros-mto select, .filtros-mto input { min-width: 130px; }
.mcal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.mcal-head b { font-size: 1rem; color: var(--navy); min-width: 150px; text-align: center; }
.mcal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mcal-dow { font-size: .72rem; font-weight: 700; color: var(--muted); text-align: center; padding: 2px 0; text-transform: uppercase; }
.mcal-cell { min-height: 92px; border: 1px solid var(--line); border-radius: 7px; padding: 3px 4px; background: #fff; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.mcal-cell.empty { background: #f6f8f9; border-style: dashed; }
.mcal-cell.hoy { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.mcal-num { font-size: .74rem; font-weight: 700; color: var(--muted); }
.mcal-cell.hoy .mcal-num { color: var(--navy); }
.mcal-items { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.mcal-chip { border: 0; text-align: left; font-size: .68rem; font-weight: 700; padding: 2px 5px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcal-chip:hover { filter: brightness(.95); }
.mcal-leg { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; font-size: .76rem; color: var(--ink); }
.mcal-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
@media (max-width: 720px) {
  .mcal-cell { min-height: 64px; }
  .mcal-chip { font-size: .6rem; }
}

/* ---------- Matriz de capacitación ---------- */
.cap-matriz th { font-size: .68rem; padding: 4px 3px; white-space: nowrap; }
.cap-matriz td { padding: 4px 3px; }
.cap-matriz td:first-child { white-space: nowrap; }

/* ---------- Planeación de rutas: línea de tiempo de disponibilidad ---------- */
.ptl-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.ptl-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.ptl-row:last-child { border-bottom: 0; }
.ptl-row.ptl-head { position: sticky; top: 0; background: #f4f6f8; z-index: 1; }
.ptl-eco { flex: 0 0 150px; padding: 4px 8px; border-right: 1px solid var(--line); font-size: .78rem; background: #fff; }
.ptl-head .ptl-eco { background: #f4f6f8; font-weight: 700; color: var(--navy); }
.ptl-days { display: flex; flex: 1; }
.ptl-d { flex: 0 0 15px; min-height: 30px; border-right: 1px solid #eef2f4; }
.ptl-d.wk { border-left: 2px solid var(--navy-600); }
.ptl-head .ptl-d { min-height: 20px; font-size: .58rem; text-align: center; color: var(--muted); line-height: 20px; }
.ptl-head .ptl-d.hoy { background: var(--navy); color: #fff; font-weight: 700; }

/* ---------- sección queja / salida no conforme (CAL-PRO-05) ---------- */
.sgc-snc { border: 1px solid var(--line); border-radius: 9px; background: #fbfcfd; padding: .55rem .7rem; }
.sgc-snc > summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--navy); user-select: none; }

/* ---------- editor de levantamiento ---------- */
.lev-sys { border: 1px solid var(--line); border-radius: 9px; margin-bottom: .5rem; background: #fff; }
.lev-sys > summary { cursor: pointer; padding: .6rem .8rem; font-size: .9rem; user-select: none; display: flex; align-items: center; gap: .5rem; }
.lev-sys > summary::-webkit-details-marker { display: none; }
.lev-sys[open] > summary { border-bottom: 1px solid var(--line); }
.lev-grid { padding: .6rem .8rem; display: flex; flex-direction: column; gap: .4rem; }
.lev-row { display: grid; grid-template-columns: 180px 190px 1fr auto; gap: .5rem; align-items: center; }
.lev-row .lev-pt { font-size: .82rem; color: var(--ink); }
.lev-row select, .lev-row input { padding: .35rem .5rem; font-size: .82rem; }
@media (max-width: 760px) { .lev-row { grid-template-columns: 1fr; } }

/* clickables */
.kpi.clickable, .funnel .fr.clickable { cursor: pointer; }
.kpi.clickable:hover { box-shadow: 0 2px 6px rgba(11,46,79,.14), 0 10px 28px rgba(11,46,79,.10); transform: translateY(-1px); transition: all .12s ease; }
.funnel .fr.clickable:hover .bar { filter: brightness(1.12); }
.funnel .fr.clickable:hover span:first-child { color: var(--navy); font-weight: 600; }

/* ---- Árbol de análisis (decomposition tree) ---- */
.arbol-scroll { overflow-x: auto; padding-bottom: .5rem; }
.arbol-flow { display: flex; gap: 34px; align-items: flex-start; min-width: min-content; }
.arbol-col { display: flex; flex-direction: column; gap: 8px; min-width: 190px; position: relative; }
.arbol-col + .arbol-col::before {
  content: ""; position: absolute; left: -34px; top: 34px; bottom: 8px; width: 34px;
  border-left: 2px solid #d7e0e6;
}
.arbol-col-h {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #66788a;
  font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding-bottom: 2px; border-bottom: 2px solid #e2e8ea;
}
.arbol-x {
  border: 0; background: transparent; color: #b0bcc4; font-size: 15px; line-height: 1;
  cursor: pointer; padding: 0 2px; border-radius: 4px;
}
.arbol-x:hover { color: #b42318; background: #f7e9e7; }
.arbol-nodo {
  border: 1px solid #dbe3e8; border-radius: 8px; background: #fff; padding: 8px 10px;
  box-shadow: 0 1px 2px rgba(11,46,79,.05); transition: box-shadow .12s ease, border-color .12s ease;
}
.arbol-nodo[style*="cursor:pointer"]:hover { border-color: #00435c; box-shadow: 0 3px 10px rgba(11,46,79,.14); }
.arbol-nodo.sel { border-color: #00435c; border-width: 2px; background: #f2f8fb; }
.arbol-nodo.root { background: #00435c; border-color: #00435c; color: #fff; }
.arbol-nodo.root .arbol-nodo-t, .arbol-nodo.root .arbol-nodo-s { color: #cfe3ec; }
.arbol-nodo-t { font-size: .8rem; font-weight: 600; color: #23323b; word-break: break-word; }
.arbol-nodo-v { font-size: 1.02rem; font-weight: 800; color: #00435c; margin-top: 1px; }
.arbol-nodo.root .arbol-nodo-v { color: #fff; }
.arbol-nodo-s { font-size: .7rem; color: #8a99a8; }
.arbol-bar { height: 5px; border-radius: 3px; background: #eef2f4; margin-top: 5px; overflow: hidden; }
.arbol-bar > i { display: block; height: 100%; background: #d8480e; }
.arbol-nodo.sel .arbol-bar > i { background: #00435c; }
.arbol-col-plus { min-width: 150px; }
select.arbol-plus {
  border: 1px dashed #9fb2bd; border-radius: 8px; padding: 8px 10px; background: #f7fafb;
  color: #33505a; font-weight: 600; cursor: pointer; font-size: .82rem;
}

/* ---- Centro de mando ---- */
.cm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.cm-card { background: #fff; border: 1px solid #dbe3e8; border-radius: 10px; box-shadow: 0 1px 3px rgba(11,46,79,.06); overflow: hidden; }
.cm-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid #eef2f4; background: #f8fafb; }
.cm-eco { font-size: 1.05rem; font-weight: 800; color: #00435c; }
.cm-body { padding: 8px 12px 11px; display: flex; flex-direction: column; gap: 7px; }
.cm-row { display: flex; gap: 8px; align-items: flex-start; font-size: .82rem; }
.cm-k { flex: 0 0 18px; text-align: center; opacity: .8; }
.cm-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.cm-alert { border-radius: 6px; padding: 5px 8px; font-size: .74rem; line-height: 1.35; }
.cm-alert > div { white-space: normal; }
.cm-block { background: #fdeceb; color: #b42318; }

/* ---- Mensajería interna ---- */
.msg-layout { display: grid; grid-template-columns: 280px 1fr; gap: 12px; align-items: start; min-height: 480px; }
.msg-lista { display: flex; flex-direction: column; overflow: hidden; }
.msg-contactos { overflow-y: auto; max-height: 560px; }
.msg-contacto {
  padding: .6rem .9rem; border-bottom: 1px solid var(--line, #eef2f4); cursor: pointer; display: flex; flex-direction: column; gap: .15rem;
}
.msg-contacto:hover { background: #f7fafb; }
.msg-contacto.activo { background: #eaf3f6; border-left: 3px solid var(--navy); }
.msg-panel { display: flex; flex-direction: column; min-height: 480px; }
.msg-hilo { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; max-height: 480px; }
.msg-bubble { align-self: flex-start; background: #f0f3f5; color: #16323f; border-radius: 12px 12px 12px 3px; padding: .5rem .75rem; max-width: 70%; font-size: .86rem; }
.msg-bubble.mio { align-self: flex-end; background: var(--navy); color: #fff; border-radius: 12px 12px 3px 12px; }
.msg-hora { font-size: .68rem; opacity: .65; margin-top: .2rem; text-align: right; }
.msg-compositor { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--line, #eef2f4); align-items: flex-end; }
.msg-compositor textarea { flex: 1; resize: none; }
.msg-img { max-width: 260px; max-height: 220px; border-radius: 8px; display: block; margin-top: .3rem; cursor: zoom-in; }
.msg-adjunto-preview { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem; border-top: 1px solid var(--line, #eef2f4); background: #f7fafb; }
.msg-adjunto-preview img { max-height: 64px; border-radius: 6px; }
@media (max-width: 720px) { .msg-layout { grid-template-columns: 1fr; } }
.msg-layout-modal { grid-template-columns: 240px 1fr; min-height: 420px; }
.msg-layout-modal .msg-contactos, .msg-layout-modal .msg-hilo { max-height: 420px; }
.cm-obs { background: #fdf4e3; color: #8a5a00; }
