:root {
  --bg: #ffffff; --panel: #ffffff; --border: #e2e8f0; --text: #0f172a; --muted: #64748b;
  --blue: #005d89; --blue-dark: #004a6e; --red: #dc2626; --green: #059669; --amber: #d97706;
  /* Paleta de marca */
  --brand: #005d89; --brand-sky: #01a0e1; --brand-ice: #e0f3f9; --brand-gold: #fec400; --brand-cream: #ffe783;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 32px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; overflow-y: auto; }
.sidebar .who b { display: block; font-size: 14px; }
.sidebar .who span { font-size: 12px; color: var(--muted); }
.campanita-wrap { position: relative; margin-top: 8px; }
.btn-campanita { position: relative; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; font-size: 15px; cursor: pointer; line-height: 1; }
.campanita-badge { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px; align-items: center; justify-content: center; padding: 0 3px; }
.campanita-panel { position: absolute; top: 100%; left: 0; margin-top: 6px; width: 300px; max-height: 360px; overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.15); z-index: 50; }
.campanita-cab { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.campanita-cab .btn-link { font-size: 12px; }
.campanita-lista { display: flex; flex-direction: column; }
.campanita-item { padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.campanita-item:last-child { border-bottom: none; }
.campanita-item.sin-leer { background: var(--brand-ice); }
.campanita-item:not(.sin-leer) { cursor: default; }
.campanita-titulo { font-size: 12.5px; font-weight: 700; }
.campanita-msg { font-size: 12px; color: #334155; margin-top: 2px; }
.campanita-fecha { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.campanita-vacio { padding: 16px 12px; font-size: 13px; color: var(--muted); text-align: center; }
.sidebar nav { margin-top: 12px; display: flex; flex-direction: column; gap: 1px; }
.sidebar nav a { padding: 6px 10px; border-radius: 6px; color: #334155; font-size: 13px; }
.sidebar nav a:hover { background: var(--brand-ice); text-decoration: none; }
.sidebar nav a.active { background: var(--brand-cream); color: var(--blue-dark); font-weight: 600; text-decoration: none; }
.sidebar nav .nav-grupo { font-size: 11px; font-weight: 800; letter-spacing: .05em; color: var(--blue-dark); text-transform: uppercase;
  margin: 16px 0 4px; padding: 4px 10px; background: var(--brand-ice); border-left: 3px solid var(--brand-gold); border-radius: 4px; }
.sidebar nav .nav-grupo:first-of-type { margin-top: 8px; }
.sidebar .logout { margin-top: auto; padding-top: 16px; }
.sidebar .logout button { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 0; }
.main { flex: 1; padding: 24px; overflow-x: auto; }

label { font-size: 13px; color: #334155; display: block; }
input, select, textarea { font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-sky); outline-offset: 0; }

.btn { display: inline-block; border: none; border-radius: 6px; padding: 7px 14px; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--brand-sky); }
.btn-secondary { background: #1e293b; color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-violet { background: #7c3aed; color: #fff; }
.btn-outline { background: #fff; border: 1px solid #cbd5e1; color: #334155; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-link { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 13px; padding: 0; }
.btn-link.danger { color: var(--red); }

h1.page-title { font-size: 18px; margin: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

table { border-collapse: collapse; width: 100%; background: var(--panel); font-size: 14px; }
.table-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; overflow-x: auto; }
th { text-align: left; background: #ffffff; padding: 8px 12px; font-weight: 700; color: var(--brand); border-bottom: 2px solid var(--brand-gold); }
td { padding: 8px 12px; border-top: 1px solid #f1f5f9; }
tr:hover td { background: #f8fafc; }
.empty-row td { text-align: center; color: var(--muted); padding: 24px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f1f5f9; color: #334155; }
.badge-blue { background: var(--brand-ice); color: var(--brand); }
.badge-amber { background: var(--brand-cream); color: #7a5a00; }
.badge-green { background: #d1fae5; color: #047857; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-violet { background: #ede9fe; color: #6d28d9; }
.badge-slate { background: #f1f5f9; color: #334155; }

.error-msg { color: var(--red); font-size: 14px; margin: 0 0 12px; }
.ok-msg { color: var(--green); font-size: 14px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 30; }
.modal-card { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 10px; padding: 24px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.modal-card h2 { font-size: 16px; margin: 0 0 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 8px; }
.help-text { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }

.summary-row { display: flex; gap: 24px; font-size: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.summary-row b { color: var(--text); }

.kpis { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; min-width: 160px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.kpi b { font-size: 20px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: none; padding: 8px 14px; font-size: 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-color: var(--brand-gold); font-weight: 600; }

/* ------------------------------------------------------------------- responsive / celular */
.btn-menu-movil { display: none; }
.sidebar-backdrop { display: none; }
img, iframe, canvas, video { max-width: 100%; }

@media (max-width: 860px) {
  .btn-menu-movil {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 10px; left: 10px; z-index: 120;
    width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--panel); box-shadow: 0 1px 6px rgba(0,0,0,.18); font-size: 22px; cursor: pointer;
  }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; z-index: 110; width: min(290px, 86vw);
    transform: translateX(-100%); transition: transform .22s ease; padding-top: 64px;
    box-shadow: 0 0 24px rgba(0,0,0,.25);
  }
  .sidebar nav a { padding: 11px 12px; font-size: 15px; }
  .sidebar nav .nav-grupo { font-size: 12px; }
  .sidebar .logout button { font-size: 15px; padding: 8px 0; }
  body.menu-movil-abierto .sidebar { transform: translateX(0); }
  body.menu-movil-abierto { overflow: hidden; }
  body.menu-movil-abierto .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 105;
  }
  .main { padding: 12px; padding-top: 66px; min-width: 0; }
  .layout { display: block; }
  .campanita-panel { width: min(300px, 74vw); }
}

/* Celular: formularios cómodos con el dedo, tablas convertidas en tarjetas, ventanas como hoja inferior */
@media (max-width: 720px) {
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }
  input, select, textarea { font-size: 16px; padding: 10px 10px; min-height: 44px; }   /* 16px evita el zoom automático de iPhone */
  input[type=checkbox], input[type=radio] { min-height: 0; width: 20px; height: 20px; }
  input[type=color] { min-height: 40px; }
  textarea { min-height: 88px; }
  label { font-size: 14px; }
  .btn { padding: 11px 16px; font-size: 15px; min-height: 44px; }
  .btn-link { font-size: 14px; padding: 6px 4px; min-height: 36px; }
  h1.page-title { font-size: 20px; }

  .form-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head > div, .page-head > span { display: flex; flex-wrap: wrap !important; gap: 8px !important; width: 100%; }
  .page-head .btn, .page-head select, .page-head a.btn { flex: 1 1 auto; text-align: center; }
  .page-head select { width: 100%; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; }
  .summary-row { flex-direction: column; gap: 6px; }

  .kpis { gap: 10px; }
  .kpi { flex: 1 1 calc(50% - 10px); min-width: 0; padding: 10px 12px; }
  .kpi b { font-size: 17px; }
  .tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .tabs button { padding: 10px 14px; flex: none; }

  /* Ventanas emergentes: ocupan el ancho y salen desde abajo */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-card { max-width: 100% !important; width: 100%; max-height: 94vh; max-height: 94dvh; border-radius: 16px 16px 0 0; padding: 18px 16px 24px; }

  /* Tablas → tarjetas (app.js pone el nombre de cada columna en data-label) */
  .table-wrap { border: 0; border-radius: 0; background: transparent; overflow: visible; }
  .table-wrap table { background: transparent; }
  .table-wrap thead { display: none; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; padding: 2px 0; overflow: hidden; }
  .table-wrap tr:hover td { background: transparent; }
  .table-wrap td { display: flex; gap: 12px; align-items: center; justify-content: space-between; text-align: right;
    border-top: 1px solid #f1f5f9; padding: 8px 12px; min-height: 38px; word-break: break-word; }
  .table-wrap td:first-child { border-top: 0; font-weight: 600; }
  .table-wrap td::before { content: attr(data-label); flex: 0 0 38%; max-width: 45%; text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); }
  .table-wrap td[data-label=""]::before, .table-wrap td:not([data-label])::before { display: none; }
  .table-wrap td:empty { display: none; }
  .table-wrap td[data-label=""] { justify-content: flex-end; flex-wrap: wrap; }
  .table-wrap td[colspan] { display: block; text-align: center; }
  .table-wrap td:has(input, select, textarea) { flex-direction: column; align-items: stretch; text-align: left; gap: 4px; }
  .table-wrap td:has(input, select, textarea)::before { flex: none; max-width: none; }
  .table-wrap td input, .table-wrap td select, .table-wrap td textarea { width: 100% !important; }
  .table-wrap.tabla-scroll { border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; }
  .table-wrap.tabla-scroll table { display: table; }
  .table-wrap.tabla-scroll thead { display: table-header-group; }
  .table-wrap.tabla-scroll tbody { display: table-row-group; }
  .table-wrap.tabla-scroll tr { display: table-row; border: 0; margin: 0; padding: 0; background: none; }
  .table-wrap.tabla-scroll td { display: table-cell; text-align: left; }
  .table-wrap.tabla-scroll td::before { display: none; }
  .table-wrap.tabla-scroll td:empty { display: table-cell; }

  /* Cuadrículas de dos columnas hechas en línea (reportes, etc.) pasan a una sola */
  .main div[style*="grid-template-columns:1fr 1fr"], .main div[style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  /* Tablero de tareas: una columna por pantalla, se desliza con el dedo */
  .tablero { grid-auto-columns: 88vw !important; scroll-snap-type: x mandatory; }
  .col-tablero { scroll-snap-align: start; }
  .vista-tabs button { flex: 1; padding: 10px 12px; }
  .tablero-filtros select { width: 100% !important; min-width: 0 !important; }
  .correo-barra select { width: 100% !important; min-width: 0 !important; }
  .correo-barra .btn { flex: 1 1 auto; }
  .correo-cuentas { gap: 6px; }
  .correo-cuerpo { height: 60vh !important; }
  .card { max-width: 100% !important; }
}

/* Impresión de las pantallas del sistema (por ejemplo herramientas o aparatos por proyecto) */
@media print {
  .sidebar, .btn-menu-movil, .sidebar-backdrop, .no-print { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; overflow: visible; }
  body { background: #fff; }
  .modal-backdrop { display: none !important; }
}

/* Estimaciones: plano con marcas de colores */
.emk-barra { display:flex; gap:12px; flex-wrap:wrap; align-items:center; margin-bottom:8px; }
.emk-h { display:inline-flex; align-items:center; gap:6px; font-size:13px; cursor:pointer; }
.emk-h input { width:auto; min-height:0; margin:0; }
.emk-h i { width:14px; height:14px; border-radius:3px; display:inline-block; }
.emk-lienzo { position:relative; display:inline-block; max-width:100%; line-height:0; border:1px solid var(--border); border-radius:6px; overflow:hidden; user-select:none; -webkit-user-select:none; background:#fff; }
.emk-lienzo img { max-width:100%; max-height:70vh; height:auto; display:block; -webkit-user-drag:none; }
.emk-capa { position:absolute; inset:0; pointer-events:none; }
.emk-marca { position:absolute; }
.emk-borrador { outline:1px dashed #0f172a; }
.est-leyenda { display:flex; gap:16px; flex-wrap:wrap; font-size:12.5px; margin:6px 0 10px; }
.est-leyenda i { width:14px; height:14px; border-radius:3px; display:inline-block; vertical-align:-2px; margin-right:5px; }
.est-fotos { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:10px; }
.est-foto { border:1px solid var(--border); border-radius:8px; overflow:hidden; background:#fff; display:flex; flex-direction:column; }
.est-foto img { width:100%; height:130px; object-fit:cover; display:block; cursor:zoom-in; }
.est-foto input { border:none; border-top:1px solid var(--border); border-radius:0; font-size:12px; padding:5px 6px; min-height:0; }
.est-foto button { border:none; background:#fef2f2; color:#b91c1c; font-size:12px; padding:4px; cursor:pointer; }
@media (max-width: 720px) { .est-foto input { font-size:16px; min-height:36px; } .est-fotos { grid-template-columns:repeat(2,1fr); } }

/* ===================================================================== diseño v2 (paleta de marca) */
body { font-family: "DM Sans", -apple-system, "Segoe UI", Arial, sans-serif; }
h1.page-title { font-size: 22px; color: var(--brand); font-weight: 700; }
.btn { border-radius: 10px; padding: 8px 16px; }
.btn-outline { border-color: var(--brand); color: var(--brand); }
.btn-outline:hover { background: var(--brand-ice); }
input, select, textarea { border-radius: 8px; border-color: #b9dbe8; }
.card { background: var(--panel); border: 1px solid var(--border); }
.table-wrap, .kpi, .card, .login-card { border-radius: 14px; border-color: #cfe6ef; box-shadow: 0 2px 10px rgba(0, 93, 137, .06); }
.kpi b { color: var(--brand); }
.modal-card { border-radius: 16px; }

/* Menú lateral azul de la marca */
.sidebar { background: var(--brand); border-right: none; color: #fff; }
.sidebar .who b { color: #fff; }
.sidebar .who span { color: var(--brand-ice); }
.sidebar .btn-campanita { border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.1); color: #fff; }
.sidebar .campanita-panel { color: var(--text); }
.sidebar nav a { color: var(--brand-ice); border-radius: 8px; }
.sidebar nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.sidebar nav a.active { background: var(--brand-gold); color: var(--brand); font-weight: 700; }
.sidebar nav .nav-grupo { background: rgba(255,255,255,.1); color: var(--brand-cream); border-left: 3px solid var(--brand-gold); }
.sidebar .logout button { color: var(--brand-ice); }
.sidebar .volver-portal { display: block; margin: 12px 0 0; padding: 7px 10px; border-radius: 8px; background: var(--brand-gold); color: var(--brand); font-size: 13px; font-weight: 700; }
.sidebar .volver-portal:hover { background: var(--brand-cream); text-decoration: none; }

/* Pantalla de ingreso y portal de entrada */
body.portal, body.ingreso { background: var(--brand); min-height: 100vh; }
.ingreso .login-wrap { background: var(--brand); }
.ingreso .login-card { border-radius: 18px; border: none; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.ingreso .login-card h1 { color: var(--brand); }
.portal-wrap { max-width: 1100px; margin: 0 auto; padding: 36px 20px 28px; color: #fff; text-align: center; }
.portal-marca { display: inline-flex; align-items: center; gap: 14px; text-align: left; }
.portal-logo { width: 60px; height: 60px; border-radius: 14px; background: #fff; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.portal-logo img { max-width: 52px; max-height: 52px; }
.portal-nombre { font-size: 26px; font-weight: 700; line-height: 1.1; }
.portal-sub { font-size: 13px; color: var(--brand-ice); letter-spacing: .04em; }
.portal-titulo { font-size: clamp(26px, 4.4vw, 40px); margin: 44px 0 6px; font-weight: 700; }
.portal-lead { color: var(--brand-ice); font-size: 17px; margin: 0 0 36px; }
.portal-tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 22px; text-align: left; }
.portal-tarjeta { display: flex; flex-direction: column; padding: 28px; border-radius: 22px; color: var(--brand); text-decoration: none; min-height: 330px; transition: transform .15s, box-shadow .15s; }
.portal-tarjeta:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(0,0,0,.28); text-decoration: none; }
.portal-blanca { background: #fff; }
.portal-celeste { background: var(--brand-ice); }
.portal-amarilla { background: var(--brand-gold); }
.portal-icono { width: 58px; height: 58px; border-radius: 16px; background: var(--brand); color: var(--brand-gold); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 22px; }
.portal-amarilla .portal-icono { color: #fff; }
.portal-tarjeta h2 { font-size: 28px; margin: 0 0 10px; color: var(--brand); }
.portal-tarjeta p { font-size: 16px; line-height: 1.5; margin: 0 0 22px; color: var(--brand); opacity: .85; }
.portal-continuar { margin-top: auto; font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; gap: 8px; }
.portal-pie { margin-top: 38px; color: var(--brand-ice); font-size: 14px; }
.portal-salir { font-size: 14px; background: none; border: none; color: var(--brand-cream); font: inherit; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }

.portal-ilustracion { width: 96px; height: 96px; margin-bottom: 18px; display: block; }

/* Pantallas de entrada con fondo blanco */
body.portal, body.ingreso, .ingreso .login-wrap { background: #ffffff; }
.portal-wrap { color: var(--brand); }
.portal-sub { color: var(--muted); }
.portal-lead, .portal-pie { color: #475569; }
.portal-salir { color: var(--brand); }
.portal-logo { border: 1px solid #cfe6ef; box-shadow: 0 2px 8px rgba(0, 93, 137, .10); }
.portal-blanca { border: 1px solid #cfe6ef; box-shadow: 0 2px 12px rgba(0, 93, 137, .08); }
.ingreso .login-card { border: 1px solid #cfe6ef; box-shadow: 0 4px 18px rgba(0, 93, 137, .12); }

/* ---- Avisos con sonido y comunicados ---- */
#av-toasts { position: fixed; top: 14px; right: 14px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 28px)); }
.av-toast { background: #fff; border: 1px solid var(--border); border-left: 6px solid var(--brand, #005d89); border-radius: 12px; padding: 12px 14px; box-shadow: 0 10px 28px rgba(0, 93, 137, .22); cursor: pointer; display: flex; flex-direction: column; gap: 3px; animation: av-entra .25s ease-out; }
.av-toast b { color: var(--brand, #005d89); font-size: 15px; }
.av-toast span { font-size: 13.5px; color: #475569; }
.av-toast.av-alerta { border-left-color: #fec400; background: #fffbea; }
@keyframes av-entra { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.av-modal-fondo { position: fixed; inset: 0; z-index: 10000; background: rgba(0, 40, 60, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.av-modal { background: #fff; border-radius: 20px; width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 26px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); border-top: 8px solid var(--brand, #005d89); animation: av-entra .25s ease-out; }
.av-modal.av-p-importante { border-top-color: #fec400; }
.av-modal.av-p-urgente { border-top-color: #dc2626; }
.av-chip { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em; padding: 4px 12px; border-radius: 999px; background: #e0f3f9; color: #005d89; }
.av-p-importante .av-chip { background: #ffe783; color: #7a5b00; }
.av-p-urgente .av-chip { background: #fee2e2; color: #b91c1c; }
.av-modal h2 { margin: 14px 0 10px; font-size: 24px; color: var(--brand, #005d89); }
.av-modal-msg { font-size: 16px; line-height: 1.55; color: #334155; white-space: normal; word-break: break-word; }
.av-modal-pie { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.av-modal-pie span { font-size: 12.5px; color: #64748b; }
.av-banner { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 9990; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 28px rgba(0, 93, 137, .25); padding: 12px 16px; display: flex; gap: 12px; align-items: center; max-width: min(640px, calc(100vw - 24px)); flex-wrap: wrap; font-size: 14px; }
.av-pie { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); background: #f8fbfd; }
.nav-badge { background: #dc2626; color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 999px; align-items: center; justify-content: center; padding: 0 5px; margin-left: 6px; }
.com-tarjeta { border: 1px solid var(--border); border-left: 6px solid var(--brand, #005d89); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; background: #fff; }
.com-tarjeta.p-importante { border-left-color: #fec400; }
.com-tarjeta.p-urgente { border-left-color: #dc2626; background: #fff8f8; }
.com-tarjeta.archivado { opacity: .55; }
.com-tarjeta h3 { margin: 0 0 6px; font-size: 18px; color: var(--brand, #005d89); }
.com-meta { font-size: 12.5px; color: #64748b; margin-bottom: 8px; }
.com-msg { font-size: 15px; line-height: 1.55; color: #334155; }
.com-lect { margin-top: 10px; font-size: 12.5px; color: #475569; }
.com-form { border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: #f8fbfd; margin-bottom: 22px; }
.com-form label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 10px; color: #005d89; }
.com-form input, .com-form textarea, .com-form select { width: 100%; margin-top: 5px; }
.com-form textarea { min-height: 100px; }

/* Botón Volver (todas las pantallas) */
.barra-volver { margin: -6px 0 10px; }
.btn-volver { background: #fff; border: 1px solid var(--border); color: var(--brand, #005d89); border-radius: 999px; padding: 6px 16px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-volver:hover { background: #e0f3f9; border-color: #01a0e1; }
@media (max-width: 720px) { .barra-volver { margin-top: 0; } .btn-volver { padding: 9px 18px; font-size: 15px; } }

/* ---- Chat interno (burbuja) ---- */
.chat-burbuja { position: fixed; z-index: 9980; width: 56px; height: 56px; border-radius: 50%; background: var(--brand, #005d89); color: #fff; font-size: 26px; display: flex; align-items: center; justify-content: center; cursor: grab; box-shadow: 0 8px 22px rgba(0, 93, 137, .4); touch-action: none; user-select: none; }
.chat-burbuja:active { cursor: grabbing; }
.chat-burbuja.con-nuevos { animation: chat-latido 1.6s infinite; background: #01a0e1; }
@keyframes chat-latido { 0%, 100% { box-shadow: 0 8px 22px rgba(0, 93, 137, .4); } 50% { box-shadow: 0 0 0 10px rgba(1, 160, 225, .25); } }
.chat-badge { background: #dc2626; color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 999px; align-items: center; justify-content: center; padding: 0 5px; }
.chat-burbuja .chat-badge { position: absolute; top: -4px; right: -4px; }
.chat-panel { position: fixed; z-index: 9985; width: 340px; height: 470px; min-width: 280px; min-height: 320px; max-width: 96vw; max-height: 92vh; resize: both; overflow: hidden; background: #fff; border: 1px solid var(--border, #d7e9f1); border-radius: 16px; box-shadow: 0 18px 50px rgba(0, 40, 60, .35); flex-direction: column; font-size: 14px; }
.chat-cab { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--brand, #005d89); color: #fff; cursor: move; touch-action: none; user-select: none; }
.chat-cab b { font-size: 15px; }
.chat-x, .chat-atras { background: rgba(255, 255, 255, .18); border: 0; color: #fff; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 15px; }
.chat-cuerpo { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
#chat-lista { display: block; }
.chat-fila { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #eef3f7; }
.chat-fila:hover { background: #f0f9fd; }
.chat-avatar { width: 38px; height: 38px; border-radius: 50%; background: #e0f3f9; color: #005d89; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.chat-fila-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-fila-t b { color: #0f172a; } .chat-fila-t small { color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 10px 12px; background: #f5f9fc; display: flex; flex-direction: column; gap: 6px; }
.chat-msg { max-width: 82%; padding: 7px 10px; border-radius: 12px; line-height: 1.35; word-break: break-word; }
.chat-msg.mio { align-self: flex-end; background: #005d89; color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.otro { align-self: flex-start; background: #fff; border: 1px solid #dbe7ef; border-bottom-left-radius: 4px; color: #0f172a; }
.chat-msg a { color: inherit; text-decoration: underline; }
.chat-de { display: block; color: #005d89; font-weight: 700; font-size: 11.5px; }
.chat-hora { display: block; text-align: right; opacity: .65; font-size: 10.5px; margin-top: 2px; }
.chat-menc { font-weight: 700; color: #01a0e1; } .chat-msg.mio .chat-menc { color: #fec400; }
.chat-menc.yo { background: #fff3b0; color: #7a5b00; border-radius: 4px; padding: 0 3px; }
.chat-vacio { color: #94a3b8; text-align: center; margin: auto; padding: 20px; }
.chat-entrada { display: flex; gap: 8px; align-items: flex-end; padding: 8px; border-top: 1px solid #e5edf3; background: #fff; }
.chat-entrada textarea { flex: 1; resize: none; border: 1px solid #cbd9e3; border-radius: 12px; padding: 8px 10px; font: inherit; max-height: 110px; margin: 0; }
.chat-entrada button { background: #005d89; color: #fff; border: 0; border-radius: 50%; width: 38px; height: 38px; cursor: pointer; font-size: 16px; flex: none; }
.chat-sugs { border-top: 1px solid #e5edf3; background: #fff; max-height: 150px; overflow-y: auto; }
.chat-sugs div { padding: 7px 12px; cursor: pointer; } .chat-sugs div:hover { background: #f0f9fd; } .chat-sugs small { color: #64748b; }
@media (max-width: 720px) { .chat-panel { left: 8px !important; right: 8px; top: auto !important; bottom: 8px; width: auto; height: 72vh; resize: none; } }
@media print { .chat-burbuja, .chat-panel { display: none !important; } }

/* Chat transparente: se ve lo que hay detrás (el nivel se ajusta con el control del encabezado) */
.chat-panel { --op: .72; background: rgba(255, 255, 255, var(--op)); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); border-color: rgba(1, 160, 225, .35); }
.chat-cab { background: rgba(0, 93, 137, calc(var(--op) + .2)); }
.chat-msgs { background: transparent; }
.chat-msg.otro { background: rgba(255, 255, 255, calc(var(--op) + .15)); }
.chat-msg.mio { background: rgba(0, 93, 137, calc(var(--op) + .2)); }
.chat-entrada, .chat-sugs { background: rgba(255, 255, 255, calc(var(--op) - .1)); }
.chat-fila { border-bottom-color: rgba(120, 150, 170, .25); }
.chat-fila:hover { background: rgba(224, 243, 249, .7); }
.chat-op { width: 62px; accent-color: #fec400; cursor: pointer; }

.chat-asa { position: absolute; right: 2px; bottom: 0; font-size: 15px; line-height: 1; color: #005d89; opacity: .7; pointer-events: none; }
.chat-panel { resize: both; }

/* En línea */
.chat-avatar { position: relative; }
.chat-punto { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; border: 2px solid #fff; box-sizing: content-box; }
.chat-avatar .chat-punto { position: absolute; right: -2px; bottom: -2px; }
.chat-punto.on { background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: chat-pulso 2s infinite; }
@keyframes chat-pulso { 70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.chat-ok { color: #16a34a !important; font-weight: 600; }
.chat-sub { font-weight: 400; opacity: .85; font-size: 11.5px; }
.chat-filtro { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid rgba(120, 150, 170, .25); position: sticky; top: 0; z-index: 1; background: rgba(255, 255, 255, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.chat-filtro button { flex: 1; border: 1px solid #cbd9e3; background: rgba(255, 255, 255, .8); border-radius: 999px; padding: 5px 8px; cursor: pointer; font: inherit; font-size: 12.5px; color: #475569; }
.chat-filtro button.act { background: #005d89; color: #fff; border-color: #005d89; }
.chat-filtro .chat-punto { width: 8px; height: 8px; border-width: 1px; margin-right: 2px; }
