:root {
  --coral: #f26b3a;
  --coral-2: #dd5626;
  --coral-claro: #ffede4;
  --celeste: #d4ecfb;
  --celeste-2: #b5dcf6;
  --celeste-osc: #2f78ad;
  --fondo: #eef0f4;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --borde: #e6e8ed;
  --texto: #1f2430;
  --texto-2: #6b7280;
  --texto-3: #9aa1ad;
  --verde: #23875a;
  --verde-claro: #e3f5ec;
  --ambar: #b7741a;
  --ambar-claro: #fff3dd;
  --rojo: #d23c3c;
  --rojo-claro: #fde8e8;
  --radio: 18px;
  --radio-chico: 12px;
  --sombra: 0 1px 2px rgba(20, 28, 45, .04), 0 4px 14px rgba(20, 28, 45, .04);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--texto);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); }
a { color: var(--celeste-osc); text-decoration: none; }
a:hover { color: var(--coral); }
h1 { font-size: 24px; margin: 0; font-weight: 700; letter-spacing: -.3px; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; }
.cargando-inicial { padding: 80px; text-align: center; color: var(--texto-2); }
svg.ico { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Encabezado superior ---------- */
.estructura { min-height: 100vh; }
.barra { background: var(--panel); border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 20; }
.barra-int { max-width: 1380px; margin: 0 auto; padding: 0 28px; height: 68px; display: flex; align-items: center; gap: 28px; }
.marca { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--texto); letter-spacing: -.3px; white-space: nowrap; }
.marca .logo { width: 30px; height: 30px; border-radius: 10px; background: var(--coral); color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 800; }
.marca small { font-weight: 500; color: var(--texto-3); font-size: 12px; margin-left: 2px; }
.menu { display: flex; gap: 4px; flex: 1; }
.menu a { color: var(--texto-2); padding: 8px 14px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.menu a:hover { color: var(--texto); background: var(--panel-2); }
.menu a.activo { color: var(--coral); font-weight: 600; }
.busca-barra { position: relative; width: 280px; }
.busca-barra input { border-radius: 999px; padding: 9px 14px 9px 38px; background: var(--panel-2); border-color: var(--panel-2); }
.busca-barra input:focus { background: #fff; }
.busca-barra svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--texto-3); width: 16px; height: 16px; }
.avatar-btn { border: none; background: none; padding: 2px; display: flex; align-items: center; gap: 8px; border-radius: 999px; }
.avatar-btn:hover { background: var(--panel-2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--celeste); color: var(--celeste-osc); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.menu-usuario { position: relative; }
.desplegable { position: absolute; right: 0; top: 46px; background: #fff; border: 1px solid var(--borde); border-radius: 14px; box-shadow: 0 12px 32px rgba(20,28,45,.12); padding: 8px; min-width: 220px; display: none; }
.desplegable.abierto { display: block; }
.desplegable .quien { padding: 8px 10px 10px; border-bottom: 1px solid var(--borde); margin-bottom: 6px; }
.desplegable .quien b { display: block; }
.desplegable .quien span { color: var(--texto-2); font-size: 12px; }
.desplegable a, .desplegable button { display: flex; width: 100%; gap: 8px; align-items: center; padding: 9px 10px; border-radius: 8px; color: var(--texto); border: none; background: none; font: inherit; cursor: pointer; text-align: left; }
.desplegable a:hover, .desplegable button:hover { background: var(--panel-2); color: var(--texto); }
.principal { max-width: 1380px; margin: 0 auto; padding: 26px 28px 60px; min-width: 0; }
.cabecera { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.cabecera .sub { color: var(--texto-2); margin-top: 4px; }
.miga { color: var(--texto-3); font-size: 13px; margin-bottom: 4px; }
.miga a { color: var(--texto-2); }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Banner de bienvenida ---------- */
.banner { background: linear-gradient(120deg, #cfe8fa 0%, #bfe0f8 55%, #d6edfb 100%); border-radius: 22px; padding: 26px; display: grid; grid-template-columns: minmax(240px, 1fr) 2.2fr; gap: 18px; margin-bottom: 20px; align-items: stretch; }
.banner .fecha { color: #4b6b85; font-size: 13px; }
.banner h1 { font-size: 30px; margin: 34px 0 6px; }
.banner .sub { color: #4b6b85; }
.banner .cta { margin-top: 18px; }
.banner-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { background: rgba(255,255,255,.88); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 10px; min-height: 150px; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -30px; bottom: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--celeste); opacity: .55; }
.stat .icono { width: 40px; height: 40px; border-radius: 12px; background: var(--coral); color: #fff; display: grid; place-items: center; }
.stat .icono svg { width: 20px; height: 20px; }
.stat .valor { font-size: 30px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; margin-top: auto; position: relative; z-index: 1; }
.stat .etiqueta { color: var(--texto-2); font-size: 13px; position: relative; z-index: 1; }

/* ---------- Paneles y tarjetas ---------- */
.panel { background: var(--panel); border-radius: var(--radio); padding: 22px; box-shadow: var(--sombra); margin-bottom: 20px; }
.panel-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-cab h2 { margin: 0; }
.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.tarjeta { background: var(--panel); border-radius: var(--radio); padding: 18px 20px; box-shadow: var(--sombra); display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center; }
.tarjeta::before { content: ""; grid-row: 1 / span 3; width: 40px; height: 40px; border-radius: 12px; background: var(--coral-claro); align-self: start; }
.tarjeta:nth-child(2)::before { background: var(--celeste); }
.tarjeta:nth-child(3)::before { background: #fde9d4; }
.tarjeta:nth-child(4)::before { background: #e4e7fb; }
.tarjeta .etiqueta { color: var(--texto-2); font-size: 13px; }
.tarjeta .valor { font-size: 24px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.tarjeta .muted { font-size: 12px; }
.dos-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.dos-col > * { min-width: 0; }
.inicio-rejilla { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; }
.inicio-rejilla > * { min-width: 0; }
@media (max-width: 1100px) { .dos-col, .inicio-rejilla, .banner { grid-template-columns: 1fr; } }

/* ---------- Gráfica de barras ---------- */
.grafica { position: relative; }
.grafica svg { width: 100%; height: 220px; display: block; overflow: visible; }
.grafica .barra-g { fill: var(--coral); transition: opacity .15s; }
.grafica .barra-g.vacia { fill: var(--coral-claro); }
.grafica .zona:hover + .barra-g, .grafica .barra-g:hover { opacity: .8; }
.grafica text { font-size: 11px; fill: var(--texto-3); }
.grafica .rejilla-g { stroke: var(--borde); stroke-dasharray: 3 4; }
.tip { position: absolute; background: var(--texto); color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12px; pointer-events: none; white-space: nowrap; transform: translate(-50%, -110%); display: none; }
.lista-estados { display: flex; flex-direction: column; gap: 12px; }
.fila-estado { display: grid; grid-template-columns: 110px 1fr 34px; gap: 10px; align-items: center; font-size: 13px; }
.fila-estado .pista { background: var(--panel-2); border-radius: 999px; height: 10px; overflow: hidden; }
.fila-estado .lleno { background: var(--celeste-2); height: 100%; border-radius: 999px; }
.fila-estado b { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Tablas ---------- */
.tabla-envoltura { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { font-size: 12px; font-weight: 500; color: var(--texto-3); background: var(--panel-2); white-space: nowrap; border-bottom: none; }
th:first-child { border-radius: 10px 0 0 10px; }
th:last-child { border-radius: 0 10px 10px 0; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }
tr.clic { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vacio { padding: 30px; text-align: center; color: var(--texto-3); }
.muted { color: var(--texto-2); }
.nowrap { white-space: nowrap; }

/* ---------- Botones y formularios ---------- */
button, .boton { font: inherit; border: 1px solid var(--borde); background: #fff; color: var(--texto); padding: 8px 16px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
button:hover, .boton:hover { background: var(--panel-2); }
button.primario { background: var(--coral); border-color: var(--coral); color: #fff; box-shadow: 0 4px 12px rgba(242, 107, 58, .25); }
button.primario:hover { background: var(--coral-2); border-color: var(--coral-2); }
button.peligro { color: var(--rojo); border-color: #f4cdcd; }
button.peligro:hover { background: var(--rojo-claro); }
button.chico { padding: 5px 12px; font-size: 13px; }
button.texto { border: none; background: none; color: var(--celeste-osc); padding: 4px 6px; border-radius: 6px; }
button.texto:hover { color: var(--coral); background: none; }
button:disabled { opacity: .55; cursor: default; }

input, select, textarea { font: inherit; border: 1px solid var(--borde); border-radius: var(--radio-chico); padding: 9px 12px; background: #fff; color: var(--texto); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--coral-claro); border-color: var(--coral); }
textarea { min-height: 76px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--texto-2); margin-bottom: 5px; }
.campo { margin-bottom: 14px; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 16px; }
.rejilla .ancho { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; accent-color: var(--coral); }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filtros input, .filtros select { width: auto; min-width: 160px; }
.filtros input[type=search] { min-width: 280px; border-radius: 999px; }
.seccion-form { font-weight: 600; color: var(--coral); margin: 6px 0 12px; grid-column: 1 / -1; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }

/* ---------- Etiquetas de estado ---------- */
.estado { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--panel-2); color: var(--texto-2); }
.estado.abierto, .estado.en_tramite, .estado.enviada, .estado.operador { background: var(--celeste); color: var(--celeste-osc); }
.estado.en_puerto, .estado.pendiente, .estado.borrador { background: var(--coral-claro); color: var(--coral-2); }
.estado.nacionalizado, .estado.despachado, .estado.listo, .estado.aceptada, .estado.admin { background: var(--verde-claro); color: var(--verde); }
.estado.anulado, .estado.rechazada, .estado.inactivo { background: var(--rojo-claro); color: var(--rojo); }

/* ---------- Pestañas ---------- */
.pestanas { display: inline-flex; gap: 4px; background: var(--panel); padding: 5px; border-radius: 999px; margin-bottom: 20px; box-shadow: var(--sombra); flex-wrap: wrap; }
.pestanas button { border: none; border-radius: 999px; background: none; padding: 8px 18px; color: var(--texto-2); }
.pestanas button:hover { background: var(--panel-2); }
.pestanas button.activa { background: var(--coral); color: #fff; font-weight: 600; }

/* ---------- Ficha de datos ---------- */
.ficha { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 20px; }
.ficha div span { display: block; font-size: 12px; color: var(--texto-3); margin-bottom: 3px; }
.ficha div b { font-weight: 500; word-break: break-word; }

/* ---------- Modal ---------- */
.fondo-modal { position: fixed; inset: 0; background: rgba(20, 28, 45, .4); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; backdrop-filter: blur(2px); }
.modal { background: #fff; border-radius: 22px; width: 100%; max-width: 780px; box-shadow: 0 24px 60px rgba(0,0,0,.18); }
.modal.chico { max-width: 460px; }
.modal-cab { padding: 20px 24px 8px; display: flex; justify-content: space-between; align-items: center; }
.modal-cuerpo { padding: 14px 24px; }
.modal-pie { padding: 14px 24px 22px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Avisos ---------- */
#avisos { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.aviso { background: var(--texto); color: #fff; padding: 12px 18px; border-radius: 14px; box-shadow: 0 10px 28px rgba(0,0,0,.18); max-width: 380px; }
.aviso.error { background: var(--rojo); }
.aviso.ok { background: var(--verde); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--fondo); }
.login .lado { background: linear-gradient(140deg, #cfe8fa 0%, #b9ddf7 60%, #d9eefc 100%); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .lado::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(255,255,255,.35); right: -120px; bottom: -120px; }
.login .lado h2 { font-size: 34px; line-height: 1.15; max-width: 440px; margin: 0; letter-spacing: -.6px; position: relative; z-index: 1; }
.login .lado p { color: #4b6b85; max-width: 420px; position: relative; z-index: 1; }
.login .derecha { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .caja { background: #fff; border-radius: 22px; padding: 38px 34px; width: 100%; max-width: 390px; box-shadow: var(--sombra); }
.login h1 { margin-bottom: 4px; }
.login .sub { color: var(--texto-2); margin-bottom: 24px; }
.login button { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.login .error-login { color: var(--rojo); margin-top: 12px; min-height: 18px; font-size: 13px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login .lado { display: none; } }

/* ---------- Varios ---------- */
.resultados-grupo { margin-bottom: 20px; }
.subir { border: 2px dashed var(--celeste-2); border-radius: var(--radio); padding: 22px; text-align: center; color: var(--texto-2); margin-bottom: 16px; background: #f7fbfe; }
.subir.arrastre { border-color: var(--coral); background: var(--coral-claro); }
.alerta { padding: 12px 16px; border-radius: var(--radio-chico); background: var(--coral-claro); color: #8a3a17; margin-bottom: 16px; }
.alerta.info { background: var(--celeste); color: #24557a; }
.totales-fila td { font-weight: 700; background: var(--panel-2); }
.chip-dias { font-size: 12px; color: var(--texto-3); }
.chip-dias.pronto { color: var(--coral); font-weight: 600; }

@media (max-width: 1000px) {
  .barra-int { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 12px; }
  .menu { order: 3; width: 100%; overflow-x: auto; }
  .busca-barra { width: auto; flex: 1; }
  .principal { padding: 18px 16px; }
}
@media print {
  .barra, .acciones, .pestanas, button { display: none !important; }
  .panel, .tarjeta { box-shadow: none; border: 1px solid var(--borde); }
  body { background: #fff; }
}
