/* =====================================================================
   Sistema de diseño — Informe Semanal ARGUL | LIBUS
   Paleta extraída de los isologos reales de ambas marcas.
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
  /* Marca */
  --ink: #0d2340;          /* azul acero profundo — header */
  --bronze: #8fa8c4;       /* acento acero — firma de la identidad (ex-bronce) */
  --argul: #0033a0;        /* cobalto ARGUL — solo acentos puntuales */
  --libus: #e8194f;        /* carmín LIBUS — solo acentos puntuales */

  /* Superficies */
  --bg: #e9eff6;           /* papel gris-azulado */
  --surface: #ffffff;
  --surface-1: #dbe6f0;    /* azul claro */
  --border: #c9d7e6;

  /* Texto */
  --text: #0d1b2e;
  --text-secondary: #48607d;
  --text-muted: #7f93a8;
  --text-on-ink: #eef3fa;
  --text-on-ink-muted: #93a9c4;

  /* Estado */
  --success: #2f7a52;
  --warn: #a6742e;
  --danger: #a13a3a;

  --radius: 8px;
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ---------------------------------------------------------------------
   Encabezado: filete de marca + barra de logos + cinta de navegación
   --------------------------------------------------------------------- */
.brand-rule {
  height: 3px;
  background: var(--bronze);
}

.logo-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
}
.logo-bar .logos { display: flex; align-items: center; gap: 1.5rem; }
.logo-bar img { height: 28px; width: auto; display: block; }
.logo-bar .divider { width: 1px; height: 24px; background: var(--border); }
.logo-bar .system-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--bronze);
}

.nav-ribbon {
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}
.nav-ribbon nav { display: flex; }

/* ---------------------------------------------------------------------
   Grupos desplegables del nav + menú de cuenta
   --------------------------------------------------------------------- */
.nav-group { position: relative; }
.nav-group-trigger {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.9rem 1.1rem;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-on-ink-muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-group-trigger:hover { color: var(--text-on-ink); border-bottom-color: var(--libus); }
.nav-group-trigger .chev { font-size: 10px; transition: transform 0.15s ease; }
.nav-group.open .nav-group-trigger { color: var(--text-on-ink); border-bottom-color: var(--libus); }
.nav-group.open .nav-group-trigger .chev { transform: rotate(180deg); }
.nav-group-trigger.active-group { color: var(--text-on-ink); border-bottom-color: var(--bronze); }

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(13, 35, 64, 0.18);
  padding: 6px;
  z-index: 60;
  margin-top: 2px;
}
.nav-group.open .nav-dropdown { display: block; }
.nav-dropdown a {
  display: block;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  text-decoration: none;
}
.nav-dropdown a:hover { background: var(--surface-1); }
.nav-dropdown a.active { color: var(--ink); font-weight: 600; background: var(--surface-1); }

.session-menu { position: relative; }
.session-trigger {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-on-ink);
  font-size: 13px;
  padding: 6px 2px;
}
.session-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); display: inline-block; }
.session-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(13, 35, 64, 0.18);
  padding: 6px;
  z-index: 60;
  margin-top: 8px;
}
.session-menu.open .session-dropdown { display: block; }
.session-dropdown a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  text-decoration: none;
}
.session-dropdown a:hover { background: var(--surface-1); }
.session-dropdown a.logout-item { color: var(--danger); border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; border-radius: 0; }
.nav-ribbon a.nav-tab {
  position: relative;
  display: inline-block;
  padding: 0.9rem 1.1rem;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-on-ink-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-ribbon a.nav-tab:hover {
  color: var(--text-on-ink);
  border-bottom-color: var(--libus);
}
.nav-ribbon a.nav-tab.active {
  color: var(--text-on-ink);
  border-bottom-color: var(--bronze);
}
.nav-ribbon .session { display: flex; align-items: center; gap: 1rem; }
.nav-ribbon .session span { color: var(--text-on-ink-muted); font-size: 13px; }
.nav-ribbon .session a {
  color: var(--text-on-ink-muted);
  text-decoration: none;
  font-size: 13px;
}
.nav-ribbon .session a:hover { color: var(--text-on-ink); }

/* ---------------------------------------------------------------------
   Componentes generales
   --------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.page-eyebrow {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}
.page-title {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 600;
  margin: 4px 0 0;
  color: var(--ink);
}

.section-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 2rem 0 0.9rem;
  color: var(--ink);
}

.kpi-grid, .card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 0.5rem;
}

/* Ficha con esquina cortada — motivo tomado del isologo de ARGUL */
.kpi-box {
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: 0.9rem;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

.kpi-label { font-size: 13px; color: var(--text-secondary); margin: 0 0 4px; }
.kpi-value { font-family: var(--font-mono); font-size: 23px; font-weight: 600; margin: 0; color: var(--ink); }

.kpi-box-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, transform 0.1s ease;
  cursor: pointer;
}
.kpi-box-link, .kpi-box-link * { text-decoration: none !important; }
.kpi-box-link:hover { background: var(--surface); box-shadow: 0 4px 14px rgba(13, 35, 64, 0.12); }
.kpi-box-link:active { transform: scale(0.99); }
.kpi-box-link-icon { font-size: 14px; color: var(--text-secondary); font-weight: 400; }
.kpi-value.danger { color: var(--danger); }

.badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 0;
}
.badge-estado { white-space: nowrap; }
.badge.ok { color: var(--success); }
.badge.warn { color: var(--warn); }
.badge.risk { color: var(--danger); }

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-bottom: 8px;
  font-size: 14px;
}
.list-row .tag { color: var(--text-secondary); white-space: nowrap; font-family: var(--font-mono); font-size: 13px; font-weight: 600; }

.login-box {
  max-width: 360px;
  margin: 10vh auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

label { display: block; font-size: 14px; margin: 0.8rem 0 0.3rem; color: var(--text-secondary); }
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  font-family: var(--font-body);
  background: var(--surface);
}
textarea { resize: vertical; }

button, .btn {
  display: inline-block;
  background: var(--ink);
  color: var(--text-on-ink);
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.15rem;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  margin-top: 1rem;
  transition: background 0.15s ease;
}
button:hover, .btn:hover { background: var(--bronze); }
.btn-secondary { background: var(--surface-1); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface); color: var(--bronze); }

.error { color: var(--danger); font-size: 14px; margin-top: 0.6rem; }
.muted { color: var(--text-muted); font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 0.5rem 0.6rem; border-bottom: 2px solid var(--ink);
  font-family: var(--font-display); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary);
}
td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------------------------------------------------------------------
   Modal — ventana de detalles / avances
   --------------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 20, 0.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 21px;
  cursor: pointer;
  padding: 0;
  margin: 0;
  line-height: 1;
}
.modal-close:hover { color: var(--ink); background: none; }

.avances-list {
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.avance-item {
  border-left: 2px solid var(--bronze);
  padding: 0.2rem 0 0.2rem 0.8rem;
  margin-bottom: 14px;
}
.avance-item .fecha {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.avance-item .texto { font-size: 15px; line-height: 1.55; color: var(--text); margin: 4px 0 6px; }
.avance-texto-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.avance-toggle {
  background: none;
  border: none;
  color: var(--argul);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.avance-toggle:hover { text-decoration: underline; background: none; }

/* Ventana grande con el avance completo — aparece por encima del modal chico */
.modal-overlay-grande { z-index: 200; background: rgba(11, 14, 20, 0.7); }
.modal-box-grande {
  max-width: 720px;
  max-height: 80vh;
}
.texto-grande {
  font-size: 18px;
  line-height: 1.7;
  color: var(--text);
}

/* ---------------------------------------------------------------------
   Seguridad: badge de alertas en el nav + medidor de fortaleza de clave
   --------------------------------------------------------------------- */
.alert-count {
  display: inline-block;
  min-width: 16px;
  padding: 1px 5px;
  margin-left: 3px;
  border-radius: 10px;
  background: var(--danger);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  vertical-align: middle;
}

.strength-track {
  height: 6px;
  background: var(--surface-1);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}
.strength-fill {
  height: 100%;
  width: 0%;
  background: var(--danger);
  transition: width .2s ease, background .2s ease;
}
.strength-label {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------------
   Reordenamiento de listas (drag&drop + flechas)
   --------------------------------------------------------------------- */
.orden-cell { width: 54px; white-space: nowrap; }
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 15px;
  padding: 0 4px;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.orden-arriba, .orden-abajo {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  margin: 0 0 0 2px;
  cursor: pointer;
}
.orden-arriba:hover, .orden-abajo:hover { background: var(--surface-1); color: var(--text); }
tr.fila-arrastrando { opacity: 0.35; }
tbody.reordenable tr { transition: background 0.2s ease; }
tbody.reordenable.orden-guardado tr { background: color-mix(in srgb, var(--success) 12%, transparent); }
tbody.reordenable.orden-guardando { opacity: 0.7; }

/* ---------------------------------------------------------------------
   Responsive — celulares y tablets
   --------------------------------------------------------------------- */
.nav-toggle { display: none; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 820px) {
  .container { padding: 1.25rem 0.9rem 3rem; }
  .page-title { font-size: 21px; }
  .card { padding: 0.9rem; }
  .card[style*="max-width"], form.card[style*="max-width"] { max-width: 100% !important; }

  /* Barra de logos */
  .logo-bar { padding: 0.65rem 0.9rem; gap: 10px; }
  .logo-bar .logos { gap: 0.75rem !important; }
  .logo-bar img { height: 22px; }
  .logo-bar .divider { height: 18px; }
  .logo-bar .system-name { font-size: 12px; }

  /* Cinta de navegación: hamburguesa + menú vertical */
  .nav-ribbon { flex-wrap: wrap; padding: 0 0.9rem; }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--text-on-ink);
    font-size: 22px;
    line-height: 1;
    padding: 0.7rem 0.4rem;
    margin: 0;
    min-height: 44px;
  }
  .nav-toggle:hover { background: none; color: var(--bronze); }
  .nav-ribbon .session-menu { margin-left: auto; }
  .nav-ribbon nav {
    display: none;
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 0.4rem;
  }
  .nav-ribbon.nav-open nav { display: flex; }
  .nav-group-trigger, .nav-ribbon a.nav-tab {
    width: 100%;
    justify-content: space-between;
    padding: 0.8rem 0.3rem;
    min-height: 44px;
    border-bottom: none;
  }
  .nav-group-trigger:hover, .nav-group.open .nav-group-trigger, .nav-ribbon a.nav-tab:hover {
    background: transparent;
    border-bottom-color: transparent;
  }
  .session-trigger:hover { background: transparent; }
  .nav-dropdown {
    position: static;
    min-width: 0;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    box-shadow: none;
    margin: 0 0 0.3rem;
  }
  .nav-dropdown a { color: var(--text-on-ink); padding: 11px 12px; }
  .nav-dropdown a:hover, .nav-dropdown a.active { background: rgba(255, 255, 255, 0.1); color: var(--text-on-ink); }
  .session-dropdown { right: 0; min-width: 200px; max-width: calc(100vw - 1.8rem); }

  /* Tablas con scroll horizontal, formularios y botones cómodos para el dedo */
  .table-scroll > table { min-width: 600px; }
  input, select, textarea { font-size: 16px; } /* evita el zoom automático en iOS */
  button, .btn { min-height: 40px; }

  /* Listas, grillas con estilos en línea y modales */
  .list-row { flex-wrap: wrap; }
  .pais-head { flex-wrap: wrap; row-gap: 4px; }
  .badge-estado { white-space: normal; }
  .container, .card { min-width: 0; overflow-wrap: anywhere; }
  [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .modal-overlay { padding: 0.75rem; }
  .modal-box, .modal-box-grande { max-height: 90vh; padding: 1.1rem; }
  .texto-grande { font-size: 16px; }
  .avances-list { max-height: 55vh; }
}

@media (max-width: 480px) {
  .kpi-grid, .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 20px; }
}

