/* ==========================================================================
   TECNONAVAL — Sistema de diseño del panel
   Identidad heredada de la landing original: navy + cyan + naranja cliente
   ========================================================================== */

:root {
  /* Marca */
  --navy: #071c2c;
  --navy-2: #0b2c42;
  --navy-3: #0f3b56;
  --cyan: #22b6d8;
  --cyan-dark: #0a75a8;
  --aqua: #9ee8ee;
  --orange: #ec8f32;
  --green: #22a97a;
  --red: #d9534f;
  --violet: #7b6ef6;

  /* Neutros */
  --ink: #0f2739;
  --ink-soft: #3d5665;
  --muted: #6b7e89;
  --line: #e2ebef;
  --line-soft: #eef4f6;
  --paper: #f5f8fa;
  --surface: #ffffff;
  --surface-2: #f9fbfc;

  /* Métrica */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 76px;
  --header-h: 68px;
  --shadow-xs: 0 1px 2px rgba(11, 44, 66, .06);
  --shadow-sm: 0 2px 10px rgba(11, 44, 66, .06);
  --shadow: 0 12px 34px rgba(11, 44, 66, .09);
  --shadow-lg: 0 24px 60px rgba(11, 44, 66, .16);
  --ease: cubic-bezier(.4, 0, .2, 1);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-tema="oscuro"] {
  --ink: #e7f0f5;
  --ink-soft: #b3c6d1;
  --muted: #8ba3b1;
  --line: #1e394f;
  --line-soft: #16293a;
  --paper: #0a1c2a;
  --surface: #0e2434;
  --surface-2: #122c3e;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
p { margin: 0; }
img { max-width: 100%; display: block; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c6d6dd; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #a9bfc9; }
::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   Estructura: aside + header + main + footer
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "aside header"
    "aside main"
    "aside footer";
  min-height: 100vh;
  transition: grid-template-columns .22s var(--ease);
}
.app.compacto { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* --- ASIDE ---------------------------------------------------------------- */
.aside {
  grid-area: aside;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--navy) 0%, #061726 100%);
  color: #c6d6df;
  border-right: 1px solid rgba(255, 255, 255, .06);
  z-index: 40;
  overflow: hidden;
}

.aside-marca {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  min-height: var(--header-h);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.marca-logo {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px 10px 20px 10px;
  background: linear-gradient(135deg, var(--cyan), #0877a8);
  color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .04em;
  box-shadow: 0 6px 18px rgba(34, 182, 216, .35);
}
.marca-texto { display: flex; flex-direction: column; min-width: 0; }
.marca-texto strong { color: #fff; font-size: 13px; letter-spacing: .16em; }
.marca-texto small { color: #7f97a6; font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; }
.app.compacto .marca-texto { display: none; }

.aside-scroll { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.aside-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); }

.nav-grupo { margin-bottom: 22px; }
.nav-titulo {
  padding: 0 12px 8px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: #5f7889;
}
.app.compacto .nav-titulo { text-align: center; font-size: 0; padding-bottom: 6px; }
.app.compacto .nav-titulo::after { content: "•••"; font-size: 9px; letter-spacing: 0; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #a9bfcd; font-size: 13px; font-weight: 500;
  transition: background .16s var(--ease), color .16s var(--ease);
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.activo { background: rgba(34, 182, 216, .16); color: #fff; font-weight: 600; }
.nav-item.activo::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--cyan);
}
.nav-item .ico { flex: 0 0 20px; width: 20px; height: 20px; opacity: .9; }
.nav-item .etq { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .pill {
  background: rgba(255, 255, 255, .12); border-radius: 99px;
  font-size: 10px; font-weight: 700; padding: 2px 7px;
}
.nav-item .pill.alerta { background: var(--red); color: #fff; }
.app.compacto .nav-item { justify-content: center; padding: 11px; }
.app.compacto .nav-item .etq,
.app.compacto .nav-item .pill { display: none; }

/* Selector de proyecto en el aside */
.proyecto-lista { display: flex; flex-direction: column; gap: 2px; }
.proyecto-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: #9db4c2; font-size: 12.5px;
}
.proyecto-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.proyecto-item.activo { background: rgba(255,255,255,.09); color: #fff; }
.proyecto-punto { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: var(--cyan); }
.proyecto-item .nombre { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proyecto-item .pct { font-size: 10.5px; font-weight: 700; color: var(--aqua); }
.app.compacto .proyecto-item .nombre, .app.compacto .proyecto-item .pct { display: none; }
.app.compacto .proyecto-item { justify-content: center; }

.aside-pie {
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: 12px;
}
.usuario-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .05);
}
.usuario-chip:hover { background: rgba(255,255,255,.09); }
.usuario-chip .datos { flex: 1; min-width: 0; }
.usuario-chip .datos strong { display: block; color: #fff; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-chip .datos small { color: #7f97a6; font-size: 10px; }
.app.compacto .usuario-chip .datos { display: none; }
.app.compacto .usuario-chip { justify-content: center; }

.avatar {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--cyan-dark));
  color: #fff; font-size: 11.5px; font-weight: 800; letter-spacing: .02em;
}
.avatar.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 9.5px; }
.avatar.lg { width: 54px; height: 54px; border-radius: 16px; font-size: 17px; }
.avatar.cliente { background: linear-gradient(135deg, var(--orange), #c9691a); }
.avatar.gris { background: linear-gradient(135deg, #90a6b3, #6b8394); }

/* --- HEADER --------------------------------------------------------------- */
.header {
  grid-area: header;
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  min-height: var(--header-h);
  padding: 0 26px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.btn-menu {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: transparent; border: 1px solid var(--line);
  cursor: pointer; color: var(--ink-soft);
}
.btn-menu:hover { background: var(--surface-2); color: var(--ink); }

.migas { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.migas .sep { opacity: .45; }
.migas strong { color: var(--ink); font-weight: 650; font-size: 15px; letter-spacing: -.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-acciones { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.buscador {
  display: flex; align-items: center; gap: 9px;
  height: 38px; padding: 0 13px; min-width: 240px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--muted);
}
.buscador:focus-within { border-color: var(--cyan); background: #fff; box-shadow: 0 0 0 3px rgba(34,182,216,.12); }
.buscador input { border: 0; background: transparent; outline: none; width: 100%; font-size: 13px; }

.icon-btn {
  position: relative; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); cursor: pointer; transition: .15s var(--ease);
}
.icon-btn:hover { border-color: var(--cyan); color: var(--cyan-dark); }
.icon-btn .badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center;
  background: var(--red); color: #fff;
  border-radius: 99px; font-size: 9.5px; font-weight: 800;
  border: 2px solid var(--surface);
}

.en-vivo {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  border: 1px solid #cfe9f0; border-radius: 99px;
  background: #f0fbfd; color: #0d7d99;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.en-vivo i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: latido 1.9s infinite; }
.en-vivo.desconectado { background: #fdf1f1; border-color: #f3d4d4; color: #a94442; }
.en-vivo.desconectado i { background: var(--red); animation: none; }
@keyframes latido { 50% { box-shadow: 0 0 0 6px rgba(34, 169, 122, 0); } }

/* --- MAIN ----------------------------------------------------------------- */
.main { grid-area: main; padding: 26px; max-width: 1560px; width: 100%; }
.main > * + * { margin-top: 22px; }

.pagina-cabecera {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 22px; flex-wrap: wrap;
}
.pagina-cabecera h1 { font-size: clamp(23px, 2.4vw, 31px); }
.pagina-cabecera .sub { color: var(--muted); font-size: 13px; margin-top: 5px; }

/* --- FOOTER --------------------------------------------------------------- */
.footer {
  grid-area: footer;
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  padding: 20px 26px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted); font-size: 12px;
}
.footer a { color: var(--cyan-dark); font-weight: 600; }
.footer a:hover { text-decoration: underline; }

/* ==========================================================================
   Componentes
   ========================================================================== */
.tarjeta {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.tarjeta.pad { padding: 20px 22px; }
.tarjeta-cab {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
}
.tarjeta-cab h3 { font-size: 14.5px; }
.tarjeta-cab .sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.tarjeta-cuerpo { padding: 18px 20px; }
.tarjeta-pie { padding: 13px 20px; border-top: 1px solid var(--line-soft); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.principal { grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); align-items: start; }

/* KPI */
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 4px; min-height: 118px;
}
.kpi .etiqueta { font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); }
.kpi .valor { font-size: 34px; font-weight: 700; letter-spacing: -.045em; margin-top: auto; color: var(--ink); }
.kpi .nota { font-size: 11.5px; color: var(--muted); }
.kpi.destacado { background: linear-gradient(140deg, var(--navy), var(--navy-3)); border-color: transparent; color: #fff; }
.kpi.destacado .etiqueta { color: #8fb0c2; }
.kpi.destacado .valor { color: #fff; }
.kpi.destacado .nota { color: #9fbccb; }
.kpi.agencia .valor { color: var(--cyan-dark); }
.kpi.cliente .valor { color: var(--orange); }
.kpi.alerta .valor { color: var(--red); }
.kpi.ok .valor { color: var(--green); }
.kpi .chispa { position: absolute; right: -18px; top: -18px; width: 88px; height: 88px;
  border-radius: 50%; background: rgba(34, 182, 216, .07); }

/* Barras */
.barra { height: 6px; border-radius: 99px; background: #e7eef1; overflow: hidden; }
.barra > i { display: block; height: 100%; border-radius: 99px; background: var(--cyan);
  transition: width .45s var(--ease); }
.barra.fina { height: 4px; }
.barra.gruesa { height: 9px; }
.barra.cliente > i { background: var(--orange); }
.barra.ok > i { background: var(--green); }
.kpi.destacado .barra { background: rgba(255, 255, 255, .16); }

/* Anillo de progreso */
.anillo {
  position: relative; display: grid; place-items: center;
  width: 150px; height: 150px; border-radius: 50%;
  background: conic-gradient(var(--cyan) var(--pct, 0deg), rgba(255, 255, 255, .12) 0);
}
.anillo::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--navy-2); }
.anillo .centro { position: relative; text-align: center; color: #fff; }
.anillo .centro strong { display: block; font-size: 33px; font-weight: 700; letter-spacing: -.04em; }
.anillo .centro span { font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; color: #9dbccc; }
.anillo.claro { background: conic-gradient(var(--cyan) var(--pct, 0deg), #e7eef1 0); }
.anillo.claro::before { background: var(--surface); }
.anillo.claro .centro { color: var(--ink); }
.anillo.claro .centro span { color: var(--muted); }

/* Insignias */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 99px;
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: var(--line-soft); color: var(--ink-soft); white-space: nowrap;
}
.tag.agencia { background: #def3f8; color: #08779a; }
.tag.cliente { background: #fff0dd; color: #aa661d; }
.tag.ok, .tag.completada { background: #dff5e9; color: #1b8250; }
.tag.progreso, .tag.en_progreso { background: #dff5fa; color: #08779a; }
.tag.revision, .tag.en_revision { background: #fff0dd; color: #aa661d; }
.tag.bloqueada, .tag.peligro { background: #fdeaea; color: #b3423e; }
.tag.pendiente { background: #edf1f3; color: #6e7f87; }
.tag.critica { background: #fdeaea; color: #b3423e; }
.tag.alta { background: #fff0dd; color: #aa661d; }
.tag.media { background: #e8f1f5; color: #4a6a7c; }
.tag.baja { background: #eef2f4; color: #7b8d97; }
.tag.violeta { background: #eeecfe; color: #5b4fd4; }
.tag.plano { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: .15s var(--ease); white-space: nowrap;
}
.btn:hover { border-color: #b9d3dc; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primario { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primario:hover { background: var(--navy-3); border-color: var(--navy-3); }
.btn.cian { background: var(--cyan); border-color: var(--cyan); color: #06283a; }
.btn.cian:hover { background: #1aa3c4; border-color: #1aa3c4; }
.btn.peligro { background: #fff; border-color: #f0cfcf; color: var(--red); }
.btn.peligro:hover { background: #fdf3f3; }
.btn.fantasma { background: transparent; border-color: transparent; color: var(--muted); }
.btn.fantasma:hover { background: var(--line-soft); color: var(--ink); }
.btn.sm { height: 31px; padding: 0 11px; font-size: 11.5px; border-radius: 8px; }
.btn.bloque { width: 100%; }

/* Formularios */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo > label { font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: 13px; outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 182, 216, .13);
}
.select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7e89' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.ayuda { font-size: 11px; color: var(--muted); }
.error-msg { background: #fdf2f2; border: 1px solid #f5d6d6; color: #a3403c;
  border-radius: 10px; padding: 11px 14px; font-size: 12.5px; }
.aviso { background: #f0fafc; border: 1px solid #cae9f1; color: #14708c;
  border-radius: 10px; padding: 11px 14px; font-size: 12.5px; }

/* ==========================================================================
   Fases y tareas
   ========================================================================== */
.fase {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; transition: box-shadow .2s var(--ease);
}
.fase + .fase { margin-top: 10px; }
.fase[open] { box-shadow: var(--shadow); border-color: #b9dde7; }

.fase-cab {
  display: grid; grid-template-columns: 40px 1fr 150px 26px;
  align-items: center; gap: 18px; padding: 17px 20px;
  cursor: pointer; list-style: none; user-select: none;
}
.fase-cab::-webkit-details-marker { display: none; }
.fase-cab:hover { background: var(--surface-2); }
.fase-num {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 10px; background: var(--line-soft); color: var(--cyan-dark);
  font-size: 12.5px; font-weight: 800;
}
.fase[open] .fase-num { background: var(--navy); color: #fff; }
.fase-info { min-width: 0; }
.fase-titulo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fase-titulo strong { font-size: 14.5px; }
.fase-desc { color: var(--muted); font-size: 12px; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.fase-pct { display: flex; flex-direction: column; gap: 6px; }
.fase-pct .n { font-size: 12px; font-weight: 800; text-align: right; color: var(--ink-soft); }
.fase-flecha { color: var(--cyan-dark); font-size: 19px; transition: transform .2s var(--ease); }
.fase[open] .fase-flecha { transform: rotate(180deg); }
.fase-cuerpo { border-top: 1px solid var(--line-soft); padding: 16px 20px 20px; background: var(--surface-2); }

.tareas { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

.tarea {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 15px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.tarea:hover { border-color: #b9d3dc; box-shadow: var(--shadow-sm); }
.tarea.completa { background: #f6fdf9; border-color: #cfeadd; }
.tarea.vencida { border-color: #f0cfcf; background: #fffafa; }
.tarea.bloqueada { border-left: 3px solid var(--red); }
.tarea:target { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,182,216,.18); }

.tarea-cab { display: flex; align-items: flex-start; gap: 10px; }
.tarea-titulo { flex: 1; font-size: 13px; font-weight: 600; line-height: 1.45; color: var(--ink); }
.tarea.completa .tarea-titulo { color: #7c9a8b; text-decoration: line-through; }
.tarea-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.pasos { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pasos-cajas { display: flex; gap: 5px; }
.paso {
  width: 24px; height: 24px; padding: 0;
  border: 2px solid #a8bdc5; border-radius: 6px;
  background: var(--surface); cursor: pointer;
  transition: .14s var(--ease);
}
.paso:hover { border-color: var(--cyan); transform: translateY(-1px); }
.paso.activo { background: var(--cyan); border-color: #1598b8; }
.tarea[data-owner="cliente"] .paso.activo { background: var(--orange); border-color: #d27b25; }
.paso:disabled { cursor: not-allowed; opacity: .75; }
.pasos-pct { font-size: 11px; font-weight: 800; color: var(--ink-soft); min-width: 34px; }

.refs { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ref-tag {
  background: var(--line-soft); border-radius: 99px; padding: 3px 8px;
  font-size: 9.5px; font-weight: 700; color: #47616d;
}

.comentarios { display: flex; flex-direction: column; gap: 8px; }
.comentario {
  display: flex; gap: 9px; padding: 9px 10px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 9px;
}
.comentario .cuerpo { flex: 1; min-width: 0; }
.comentario .cuerpo .quien { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.comentario .cuerpo .quien strong { font-size: 11.5px; }
.comentario .cuerpo .quien time { font-size: 10px; color: var(--muted); }
.comentario .cuerpo p { font-size: 12px; color: var(--ink-soft); margin-top: 3px; word-wrap: break-word; }

.escribiendo {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-style: italic; color: var(--cyan-dark);
}
.escribiendo b { width: 5px; height: 5px; border-radius: 50%; background: var(--cyan);
  animation: puntito 1s infinite; }
.escribiendo b:nth-child(2) { animation-delay: .15s; }
.escribiendo b:nth-child(3) { animation-delay: .3s; }
@keyframes puntito { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ==========================================================================
   Tablero kanban
   ========================================================================== */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr);
  gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.columna { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.columna-cab { display: flex; align-items: center; justify-content: space-between;
  padding: 13px 15px; border-bottom: 1px solid var(--line); }
.columna-cab h4 { font-size: 12.5px; }
.columna-cuerpo { padding: 12px; display: flex; flex-direction: column; gap: 9px;
  max-height: calc(100vh - 300px); overflow-y: auto; min-height: 90px; }
.columna-cuerpo:empty::after { content: "Sin tareas"; display: block; text-align: center;
  color: var(--muted); font-size: 11.5px; padding: 18px 0; }

/* ==========================================================================
   Cronograma / Gantt
   ========================================================================== */
.gantt { display: flex; flex-direction: column; gap: 7px; }
.gantt-fila { display: grid; grid-template-columns: 210px 1fr 62px; align-items: center; gap: 14px; }
.gantt-etq { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-etq small { display: block; color: var(--muted); font-weight: 400; font-size: 10.5px; }
.gantt-pista { position: relative; height: 26px; background: var(--line-soft);
  border-radius: 7px; overflow: hidden; }
.gantt-barra { position: absolute; top: 3px; height: 20px; border-radius: 6px;
  background: linear-gradient(90deg, var(--cyan), var(--cyan-dark)); display: flex; align-items: center;
  padding: 0 8px; color: #fff; font-size: 9.5px; font-weight: 700; overflow: hidden; }
.gantt-barra.vencida { background: linear-gradient(90deg, #e57373, var(--red)); }
.gantt-barra .relleno { position: absolute; inset: 0; background: rgba(255,255,255,.28); }
.gantt-hoy { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--orange); z-index: 2; }

/* Línea de tiempo vertical */
.linea { position: relative; padding-left: 26px; }
.linea::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line); }
.linea-item { position: relative; padding-bottom: 18px; }
.linea-item::before { content: ""; position: absolute; left: -22px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--cyan);
  border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--cyan); }
.linea-item.ok::before { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.linea-item.alerta::before { background: var(--red); box-shadow: 0 0 0 2px var(--red); }

/* ==========================================================================
   Listas y tablas
   ========================================================================== */
.tabla { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tabla th {
  text-align: left; padding: 11px 14px; font-size: 10px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  position: sticky; top: 0; z-index: 1;
}
.tabla td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tabla tbody tr:hover { background: var(--surface-2); }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }

.lista { display: flex; flex-direction: column; }
.lista-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line-soft);
}
.lista-item:last-child { border-bottom: 0; }
.lista-item .contenido { flex: 1; min-width: 0; }
.lista-item .contenido strong { display: block; font-size: 12.5px; font-weight: 600; }
.lista-item .contenido small { color: var(--muted); font-size: 11px; }

.vacio { text-align: center; padding: 42px 20px; color: var(--muted); }
.vacio .icono { font-size: 34px; opacity: .35; margin-bottom: 10px; }
.vacio p { font-size: 13px; }

/* ==========================================================================
   Menús, modales y avisos flotantes
   ========================================================================== */
.menu {
  position: absolute; right: 0; top: calc(100% + 9px); z-index: 60;
  min-width: 290px; max-width: 360px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.menu-cab { padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; }
.menu-cab strong { font-size: 12.5px; }
.menu-lista { max-height: 340px; overflow-y: auto; }
.menu-item { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px; }
.menu-item:last-child { border-bottom: 0; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .punto { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan); margin-top: 6px; }
.menu-item .punto.aviso { background: var(--orange); }
.menu-item .punto.alerta { background: var(--red); }
.menu-item .txt { flex: 1; min-width: 0; }
.menu-item .txt strong { display: block; font-size: 12.5px; font-weight: 600; }
.menu-item .txt small { color: var(--muted); font-size: 11px; }

.modal-fondo {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(7, 28, 44, .55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(620px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal-cab { display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--line-soft); }
.modal-cab h3 { font-size: 16px; }
.modal-cuerpo { padding: 22px 24px; display: flex; flex-direction: column; gap: 15px; }
.modal-pie { display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--line-soft); background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.avisos { position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 9px; max-width: 340px; }
.aviso-flotante {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 15px; border-radius: 11px;
  background: var(--navy); color: #fff; font-size: 12.5px;
  box-shadow: var(--shadow-lg); animation: entra .25s var(--ease);
}
.aviso-flotante.ok { background: #14805e; }
.aviso-flotante.error { background: #b3423e; }
@keyframes entra { from { opacity: 0; transform: translateY(12px); } }

.estado-guardado { font-size: 11px; font-weight: 700; }
.estado-guardado.guardando { color: var(--orange); }
.estado-guardado.guardado { color: var(--green); }
.estado-guardado.error { color: var(--red); }

/* Pestañas */
.pestanas { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.pestana {
  padding: 11px 15px; font-size: 12.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer;
  background: transparent; border-top: 0; border-left: 0; border-right: 0;
}
.pestana:hover { color: var(--ink); }
.pestana.activa { color: var(--cyan-dark); border-bottom-color: var(--cyan); }

/* Filtros */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filtro-chip {
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface); color: var(--muted); font-size: 11.5px; font-weight: 600;
  cursor: pointer; transition: .14s var(--ease);
}
.filtro-chip:hover { border-color: #b9d3dc; color: var(--ink); }
.filtro-chip.activo { background: var(--navy); border-color: var(--navy); color: #fff; }

.presencia { display: flex; align-items: center; }
.presencia .avatar { margin-left: -8px; border: 2px solid var(--surface); }
.presencia .avatar:first-child { margin-left: 0; }

canvas { max-width: 100%; }

/* ==========================================================================
   Utilidades
   ========================================================================== */
.flex { display: flex; }
.entre { justify-content: space-between; }
.centro { align-items: center; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-10 { gap: 10px; } .gap-14 { gap: 14px; } .gap-18 { gap: 18px; }
.col { flex-direction: column; }
.envolver { flex-wrap: wrap; }
.auto { margin-left: auto; }
.txt-mudo { color: var(--muted); }
.txt-sm { font-size: 11.5px; }
.txt-xs { font-size: 10.5px; }
.txt-der { text-align: right; }
.negrita { font-weight: 700; }
.truncar { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oculto { display: none !important; }
.pila > * + * { margin-top: 12px; }
.mt-0 { margin-top: 0 !important; }
.rel { position: relative; }
.scroll-y { overflow-y: auto; }
.no-select { user-select: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1280px) {
  .grid.c5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.principal { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "header" "main" "footer"; }
  .aside {
    position: fixed; left: 0; top: 0; width: var(--sidebar-w);
    transform: translateX(-100%); transition: transform .24s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .app.abierto .aside { transform: translateX(0); }
  .app.abierto::after {
    content: ""; position: fixed; inset: 0; z-index: 35;
    background: rgba(7, 28, 44, .45);
  }
  .buscador { display: none; }
  .main { padding: 18px 16px; }
  .header { padding: 0 16px; }
  .gantt-fila { grid-template-columns: 130px 1fr 46px; }
}

@media (max-width: 720px) {
  body { font-size: 13.5px; }
  .grid.c2, .grid.c3, .grid.c4, .grid.c5 { grid-template-columns: 1fr; }
  .grid.c2.mantener, .grid.c4.mantener { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { min-height: 96px; padding: 14px 15px; }
  .kpi .valor { font-size: 26px; }
  .fase-cab { grid-template-columns: 32px 1fr 22px; gap: 11px; padding: 14px; }
  .fase-pct { display: none; }
  .fase-cuerpo { padding: 12px 13px 16px; }
  .tareas { grid-template-columns: 1fr; }
  .paso { width: 27px; height: 27px; }
  .pagina-cabecera { align-items: flex-start; }
  .pagina-cabecera h1 { font-size: 21px; }
  .tarjeta-cab, .tarjeta-cuerpo { padding: 14px 15px; }
  .menu { position: fixed; left: 12px; right: 12px; top: 70px; min-width: 0; max-width: none; }
  .tabla-scroll { overflow-x: auto; }
  .tabla { min-width: 620px; }
  .gantt-fila { grid-template-columns: 96px 1fr 40px; gap: 9px; }
  .footer { flex-direction: column; align-items: flex-start; gap: 8px; }
  .avisos { left: 12px; right: 12px; max-width: none; }
}

@media print {
  .aside, .header, .footer, .btn, .icon-btn, .filtros { display: none !important; }
  .app { grid-template-columns: 1fr; grid-template-areas: "main"; }
  .main { padding: 0; }
  .tarjeta { box-shadow: none; break-inside: avoid; }
  .fase-cuerpo { display: block !important; }
}
