/* =========================================================================
   Gestion de Ingenieria — Sistema de diseno
   Estetica: sobria, corporativa, con aire de "blueprint" (navy + teal).
   Tipografia Inter (vendorizada, sin internet). Profundidad sutil y
   micro-animaciones; el color solo aparece cuando significa algo.
   ========================================================================= */

/* ---------- Fuente Inter (local, sin internet) ---------- */
@font-face {
    font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap;
    src: url("fonts/inter-latin-400-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap;
    src: url("fonts/inter-latin-500-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
    src: url("fonts/inter-latin-600-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
    src: url("fonts/inter-latin-700-normal.woff2") format("woff2");
}

:root {
    /* Categoria de tarea */
    --cat-proyecto:      #3B6FD4;
    --cat-mejora:        #2E9E6B;
    --cat-soporte:       #C2761B;
    --cat-documentacion: #7C5CD1;

    /* Estados */
    --est-pendiente:   #64748B;
    --est-en_curso:    #3B6FD4;
    --est-bloqueada:   #D14343;
    --est-en_revision: #7C5CD1;
    --est-completada:  #2E9E6B;
    --est-cancelada:   #94A3B8;

    /* Tintes suaves para badges (fondo claro + tinta fuerte = sobrio y legible) */
    --soft-azul:    rgba(59,111,212,.12);  --ink-azul:    #2A55A8;
    --soft-verde:   rgba(46,158,107,.14);  --ink-verde:   #1F7550;
    --soft-ambar:   rgba(194,118,27,.15);  --ink-ambar:   #92580F;
    --soft-violeta: rgba(124,92,209,.13);  --ink-violeta: #5B41A0;
    --soft-rojo:    rgba(209,67,67,.12);   --ink-rojo:    #A93232;
    --soft-gris:    rgba(100,116,139,.14); --ink-gris:    #475569;

    /* Prioridad (la que fija el jefe) */
    --prio-Alta:  #D14343;
    --prio-Media: #C2761B;
    --prio-Baja:  #2E9E6B;

    /* Neutros */
    --bg:        #eff1f5;
    --surface:   #ffffff;
    --surface-2: #f7f9fb;
    --border:    #e5e9ef;
    --border-2:  #d5dce5;
    --text:      #15202f;
    --text-soft: #64748b;
    --text-mute: #97a3b4;

    /* Marca */
    --primary:    #16233A;   /* navy profundo: topbar, botones base */
    --primary-2:  #22314d;
    --accent:     #0F766E;   /* teal: acciones e interaccion */
    --accent-2:   #0D9488;
    --accent-ink: #0B5F58;

    /* Radios */
    --radius:    14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --pill:      999px;

    /* Sombras en capas */
    --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
    --shadow:    0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
    --shadow-md: 0 6px 16px rgba(16,24,40,.09), 0 2px 6px rgba(16,24,40,.05);
    --shadow-lg: 0 18px 44px rgba(16,24,40,.18);

    --ring: 0 0 0 3px rgba(15,118,110,.20);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body.no-scroll { overflow: hidden; }

h1, h2, h3, h4 { text-wrap: balance; letter-spacing: -.011em; }
p { text-wrap: pretty; }
::selection { background: rgba(15,118,110,.20); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Animaciones ---------- */
@keyframes fadeUp    { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeDown  { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes popIn     { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn   { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important; animation-iteration-count: 1 !important;
        transition-duration: .001ms !important; scroll-behavior: auto !important;
    }
}

/* =========================================================================
   Barra superior
   ========================================================================= */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    background:
        repeating-linear-gradient(90deg, rgba(255,255,255,.045) 0 1px, transparent 1px 34px),
        repeating-linear-gradient(0deg,  rgba(255,255,255,.045) 0 1px, transparent 1px 34px),
        linear-gradient(180deg, #1d2c47 0%, var(--primary) 100%);
    color: #fff;
    padding: 11px 20px;
    box-shadow: var(--shadow-md);
    position: sticky; top: 0; z-index: 50;
    animation: fadeDown .45s ease both;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar .logo {
    width: 34px; height: 34px; display: grid; place-items: center;
    font-size: 1.05rem; line-height: 1;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 10px;
}
.topbar h1 {
    font-size: 1.02rem; margin: 0; font-weight: 600; letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

.nav-link, .logout-link, .user-chip {
    color: #fff; text-decoration: none; font-size: .82rem; font-weight: 600;
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.11);
    padding: 7px 13px; border-radius: var(--pill);
    transition: background .18s ease, transform .12s ease;
}
.nav-link:hover, .logout-link:hover, .user-chip:hover { background: rgba(255,255,255,.22); }
.nav-link:active, .logout-link:active { transform: translateY(1px); }
.nav-link.activa { background: rgba(255,255,255,.24); border-color: rgba(255,255,255,.28); }
/* Volver a la portada no es navegacion DENTRO de la app: se despega del resto
   con una linea, para no leerse como una pestaña mas. */
.nav-link.inicio {
    background: transparent; border-color: transparent; opacity: .82;
    padding-right: 15px; margin-right: 3px;
    border-right: 1px solid rgba(255,255,255,.16);
    border-radius: var(--pill) 0 0 var(--pill);
}
.nav-link.inicio:hover { background: rgba(255,255,255,.14); opacity: 1; }
.logout-link { background: transparent; opacity: .88; }
.user-chip {
    max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 7px;
}
.user-chip .rol-tag {
    font-size: .62rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    opacity: .75;
}

/* =========================================================================
   Estructura
   ========================================================================= */
.container { max-width: 1180px; margin: 0 auto; padding: 22px 18px 64px; }

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 14px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-head h2 { margin: 0; font-size: 1.32rem; font-weight: 700; letter-spacing: -.02em; }
.page-head .sub { margin: 3px 0 0; color: var(--text-soft); font-size: .87rem; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- KPIs ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 20px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 15px;
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease;
    animation: fadeUp .5s ease both;
    position: relative; overflow: hidden;
}
.stat-card::after {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--acento, var(--border-2));
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .num {
    font-size: 1.75rem; font-weight: 700; line-height: 1.15; color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.stat-card .label {
    font-size: .7rem; color: var(--text-soft); margin-top: 2px;
    text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.stats .stat-card:nth-child(1) { animation-delay: .02s; }
.stats .stat-card:nth-child(2) { animation-delay: .07s; }
.stats .stat-card:nth-child(3) { animation-delay: .12s; }
.stats .stat-card:nth-child(4) { animation-delay: .17s; }
/* El acento de cada KPI lo elige la plantilla, no la posicion. */
.acc-gris    { --acento: var(--est-pendiente); }
.acc-azul    { --acento: var(--est-en_curso); }
.acc-rojo    { --acento: var(--est-bloqueada); }
.acc-verde   { --acento: var(--est-completada); }
.acc-violeta { --acento: var(--est-en_revision); }

/* ---------- Tabs de filtro ---------- */
.tabs {
    display: flex; gap: 6px; margin-bottom: 16px;
    overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin;
}
.tab {
    flex-shrink: 0; cursor: pointer;
    background: var(--surface); color: var(--text-soft);
    border: 1px solid var(--border); border-radius: var(--pill);
    padding: 7px 14px; font-size: .81rem; font-weight: 600;
    font-family: inherit;
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.tab:hover { border-color: var(--border-2); color: var(--text); }
.tab.active {
    background: var(--primary); border-color: var(--primary); color: #fff;
}
.tab .cnt {
    display: inline-block; margin-left: 6px; font-variant-numeric: tabular-nums;
    opacity: .7; font-weight: 700;
}

/* ---------- Barra de herramientas (buscar / filtros) ---------- */
.toolbar {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px;
}
.toolbar .buscar { position: relative; flex: 1 1 240px; min-width: 180px; }
.toolbar .buscar input { width: 100%; padding-left: 34px; }
.toolbar .buscar::before {
    content: "\1F50D"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    font-size: .8rem; opacity: .5; pointer-events: none;
}

/* =========================================================================
   Formularios
   ========================================================================= */
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], select, textarea {
    width: 100%; font-family: inherit; font-size: .9rem; color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-2); border-radius: var(--radius-sm);
    padding: 9px 12px;
    transition: border-color .16s ease, box-shadow .16s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
select { cursor: pointer; }
label.campo { display: block; margin-bottom: 12px; }
label.campo > span {
    display: block; font-size: .76rem; font-weight: 700; color: var(--text-soft);
    text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font-family: inherit; font-size: .86rem; font-weight: 600;
    padding: 9px 16px; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer;
    background: var(--primary); color: #fff;
    box-shadow: var(--shadow-sm);
    transition: background .16s ease, transform .12s ease, box-shadow .16s ease, opacity .16s;
}
.btn:hover { background: var(--primary-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }

.btn-accent { background: var(--accent); }
.btn-accent:hover { background: var(--accent-2); }
.btn-green { background: var(--est-completada); }
.btn-green:hover { background: #268a5c; }
.btn-blue  { background: var(--est-en_curso); }
.btn-blue:hover { background: #3161bd; }
.btn-red   { background: var(--est-bloqueada); }
.btn-red:hover { background: #bd3b3b; }
.btn-violet { background: var(--est-en_revision); }
.btn-violet:hover { background: #6e4fc0; }
.btn-ghost {
    background: var(--surface); color: var(--text); border-color: var(--border-2);
    box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-2); border-color: #c3cdd9; }
.btn-danger-ghost { background: transparent; color: var(--ink-rojo); border-color: rgba(209,67,67,.35); box-shadow: none; }
.btn-danger-ghost:hover { background: var(--soft-rojo); }

/* =========================================================================
   Badges y pildoras
   ========================================================================= */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: var(--pill);
    font-size: .69rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .045em;
    background: var(--soft-gris); color: var(--ink-gris);
    white-space: nowrap;
}
.badge-cat-proyecto      { background: var(--soft-azul);    color: var(--ink-azul); }
.badge-cat-mejora        { background: var(--soft-verde);   color: var(--ink-verde); }
.badge-cat-soporte       { background: var(--soft-ambar);   color: var(--ink-ambar); }
.badge-cat-documentacion { background: var(--soft-violeta); color: var(--ink-violeta); }

.badge-est-pendiente   { background: var(--soft-gris);    color: var(--ink-gris); }
.badge-est-en_curso    { background: var(--soft-azul);    color: var(--ink-azul); }
.badge-est-bloqueada   { background: var(--soft-rojo);    color: var(--ink-rojo); }
.badge-est-en_revision { background: var(--soft-violeta); color: var(--ink-violeta); }
.badge-est-completada  { background: var(--soft-verde);   color: var(--ink-verde); }
.badge-est-cancelada   { background: rgba(148,163,184,.20); color: #5c6b7f; }

/* Prioridad: flecha + texto, mas discreta que un badge lleno */
.prio {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: .74rem; font-weight: 700; letter-spacing: .01em;
    color: var(--text-soft);
}
.prio::before {
    content: ""; width: 7px; height: 7px; border-radius: 50%;
    background: var(--prio-Media);
}
.prio-Alta  { color: var(--ink-rojo); }
.prio-Alta::before  { background: var(--prio-Alta); }
.prio-Media::before { background: var(--prio-Media); }
.prio-Baja::before  { background: var(--prio-Baja); }

/* Deadline: el color lo decide la urgencia real */
.deadline {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: var(--pill);
    font-size: .73rem; font-weight: 700;
    background: var(--soft-gris); color: var(--ink-gris);
    white-space: nowrap;
}
.deadline.pronto  { background: var(--soft-ambar); color: var(--ink-ambar); }
.deadline.vencida { background: var(--soft-rojo);  color: var(--ink-rojo); }
.deadline.hecha   { background: var(--soft-verde); color: var(--ink-verde); }

/* Avatar con iniciales (color estable segun el id del usuario) */
.avatar {
    width: 26px; height: 26px; flex-shrink: 0;
    border-radius: 50%; display: grid; place-items: center;
    font-size: .66rem; font-weight: 700; color: #fff; letter-spacing: .02em;
    background: var(--primary-2);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.avatar.a0 { background: #3B6FD4; } .avatar.a1 { background: #0F766E; }
.avatar.a2 { background: #7C5CD1; } .avatar.a3 { background: #C2761B; }
.avatar.a4 { background: #2E9E6B; } .avatar.a5 { background: #476080; }
.avatar-lg { width: 34px; height: 34px; font-size: .78rem; }
/* Nadie es el responsable: se ve como un hueco, no como una persona mas. */
.avatar.vacio {
    background: transparent; color: var(--text-mute);
    border: 1px dashed var(--border-2); box-shadow: none;
}

.persona {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: .79rem; font-weight: 600; color: var(--text-soft);
}
.persona.sin { color: var(--text-mute); font-style: italic; }

/* =========================================================================
   Tarjeta de tarea (compacta) -> abre el detalle
   ========================================================================= */
.lista-tareas { display: flex; flex-direction: column; gap: 11px; }

.tarea {
    position: relative;
    display: flex; align-items: stretch; gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, opacity .16s;
    animation: popIn .34s ease both;
}
.tarea:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tarea.cat-proyecto      { border-left-color: var(--cat-proyecto); }
.tarea.cat-mejora        { border-left-color: var(--cat-mejora); }
.tarea.cat-soporte       { border-left-color: var(--cat-soporte); }
.tarea.cat-documentacion { border-left-color: var(--cat-documentacion); }
.tarea.cerrada { opacity: .72; }
.tarea.cerrada .tarea-titulo { color: var(--text-soft); }
.tarea.vencida { border-color: rgba(209,67,67,.38); }

/* Columna de arrastre / reordenar (solo en "Mis tareas") */
.tarea-grip {
    display: none; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; width: 34px; flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 9px 0 0 9px;
    color: var(--text-mute); cursor: grab;
    user-select: none;
}
.ordenable .tarea-grip { display: flex; }
.tarea-grip:active { cursor: grabbing; }
/* Puntitos dibujados con CSS: se ven igual sin depender de la fuente. */
.tarea-grip .dots {
    width: 11px; height: 17px; opacity: .55;
    background-image: radial-gradient(currentColor 1.4px, transparent 1.5px);
    background-size: 5.5px 5.5px; background-position: center;
}
.tarea-grip .mover {
    background: none; border: none; color: var(--text-soft); cursor: pointer;
    font-size: .68rem; padding: 3px 7px; line-height: 1; font-family: inherit;
    border-radius: 5px; transition: color .14s ease, background .14s ease;
}
.tarea-grip .mover:hover { color: var(--accent); background: rgba(15,118,110,.10); }
.tarea.dragging { opacity: .45; }
.tarea.drop-target { border-top: 3px solid var(--accent); }

.tarea-body { flex: 1; min-width: 0; padding: 13px 15px 12px; }
.tarea-head {
    display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 5px;
}
.tarea-titulo {
    margin: 0 0 5px; font-size: 1rem; font-weight: 600; letter-spacing: -.012em;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tarea-desc {
    margin: 0 0 9px; font-size: .84rem; color: var(--text-soft);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tarea-foot {
    display: flex; align-items: center; gap: 6px 13px; flex-wrap: wrap;
    font-size: .77rem; color: var(--text-soft);
}
.tarea-id {
    font-size: .7rem; font-weight: 700; color: var(--text-mute);
    font-variant-numeric: tabular-nums; margin-left: auto;
}
.tarea-chevron {
    display: grid; place-items: center; width: 26px; flex-shrink: 0;
    color: var(--text-mute); font-size: 1.3rem; padding-right: 6px;
    transition: color .16s ease, transform .16s ease;
}
.tarea:hover .tarea-chevron { color: var(--accent); transform: translateX(2px); }

.meta-chip { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.meta-chip.bloqueo { color: var(--ink-rojo); font-weight: 600; }
.meta-chip.alerta  { color: var(--ink-rojo); font-weight: 600; }
.meta-chip.bien    { color: var(--ink-verde); font-weight: 600; }
.meta-chip.libre {
    color: var(--ink-violeta); font-weight: 600;
    background: var(--soft-violeta); padding: 2px 8px; border-radius: var(--pill);
}

/* ---------- Novedades: qué cambió desde la última vez ---------- */
.punto-novedad {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(15,118,110,.16);
}
.tarea.novedad { border-color: rgba(15,118,110,.35); }
.tarea.novedad .tarea-titulo { font-weight: 700; }

.tag-nuevo {
    font-size: .6rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    background: var(--accent); color: #fff;
    padding: 2px 7px; border-radius: var(--pill);
}
.det-coment.nuevo { border-color: rgba(15,118,110,.4); background: rgba(15,118,110,.05); }

/* ---------- Barra de avance ---------- */
.avance-wrap { display: flex; align-items: center; gap: 9px; margin: 2px 0 9px; }
.avance-bar {
    flex: 1; height: 6px; border-radius: var(--pill);
    background: #e8ecf1; overflow: hidden;
}
.avance-fill {
    height: 100%; border-radius: var(--pill);
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
    transition: width .35s cubic-bezier(.4,0,.2,1);
}
.avance-fill.full { background: linear-gradient(90deg, #2E9E6B 0%, #34b47a 100%); }
.avance-num {
    font-size: .74rem; font-weight: 700; color: var(--text-soft);
    font-variant-numeric: tabular-nums; min-width: 34px; text-align: right;
}

/* ---------- Agrupador por persona (vista Equipo) ---------- */
.grupo { margin-bottom: 26px; animation: fadeUp .45s ease both; }
.grupo-head {
    display: flex; align-items: center; gap: 10px; margin-bottom: 11px;
    padding-bottom: 9px; border-bottom: 1px solid var(--border);
}
.grupo-head h3 { margin: 0; font-size: .97rem; font-weight: 700; }
.grupo-head .cnt {
    font-size: .72rem; font-weight: 700; color: var(--text-soft);
    background: var(--soft-gris); padding: 3px 9px; border-radius: var(--pill);
}
.grupo-head .carga { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ---------- Estado vacio ---------- */
.empty {
    text-align: center; padding: 46px 20px; color: var(--text-soft);
    background: var(--surface); border: 1px dashed var(--border-2);
    border-radius: var(--radius); animation: fadeUp .4s ease both;
}
.empty .ico { font-size: 1.8rem; opacity: .55; display: block; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-size: .95rem; margin-bottom: 3px; }

/* =========================================================================
   Vista de detalle (overlay a pantalla completa)
   ========================================================================= */
.detalle-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15,23,42,.55);
    backdrop-filter: blur(2px);
    display: none; justify-content: flex-end;
}
.detalle-overlay.open { display: flex; animation: overlayIn .2s ease both; }
.detalle-panel {
    width: min(720px, 100%); height: 100%;
    background: var(--bg);
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideIn .26s cubic-bezier(.32,.72,.35,1) both;
}
.detalle-cargando { padding: 40px; text-align: center; color: var(--text-soft); }

.detalle-topbar {
    display: flex; align-items: center; gap: 12px;
    background: var(--primary); color: #fff;
    padding: 11px 16px; flex-shrink: 0;
}
.detalle-back {
    background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.14);
    color: #fff; font-size: 1.05rem; line-height: 1;
    width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
    display: grid; place-items: center; font-family: inherit;
    transition: background .16s ease;
}
.detalle-back:hover { background: rgba(255,255,255,.24); }
.detalle-tt { font-size: .93rem; font-weight: 600; }
.detalle-id {
    margin-left: auto; font-size: .8rem; font-weight: 700; opacity: .75;
    font-variant-numeric: tabular-nums;
}
.detalle-body { flex: 1; overflow-y: auto; padding: 16px; }

.detalle-cabecera {
    background: var(--surface); border: 1px solid var(--border);
    border-top: 3px solid var(--border-2);
    border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
    box-shadow: var(--shadow);
}
.detalle-cabecera.cat-proyecto      { border-top-color: var(--cat-proyecto); }
.detalle-cabecera.cat-mejora        { border-top-color: var(--cat-mejora); }
.detalle-cabecera.cat-soporte       { border-top-color: var(--cat-soporte); }
.detalle-cabecera.cat-documentacion { border-top-color: var(--cat-documentacion); }
.detalle-cabecera h2 {
    margin: 9px 0 10px; font-size: 1.22rem; font-weight: 700; letter-spacing: -.02em;
}
.detalle-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.detalle-datos {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px 14px; padding-top: 12px; border-top: 1px solid var(--border);
}
.dato .k {
    font-size: .67rem; font-weight: 700; color: var(--text-mute);
    text-transform: uppercase; letter-spacing: .06em;
}
.dato .v { font-size: .86rem; font-weight: 600; margin-top: 2px; display: flex; align-items: center; gap: 6px; }

.aviso-bloqueo {
    margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--soft-rojo); color: var(--ink-rojo);
    font-size: .84rem; font-weight: 600;
    border-left: 3px solid var(--est-bloqueada);
}

.detalle-sec {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 15px 16px; margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.detalle-sec h4 {
    margin: 0 0 11px; font-size: .74rem; font-weight: 700; color: var(--text-soft);
    text-transform: uppercase; letter-spacing: .07em;
    display: flex; align-items: center; gap: 8px;
}
.detalle-sec h4 .contador { color: var(--text-mute); font-weight: 700; }
.detalle-desc { margin: 0; font-size: .9rem; white-space: pre-wrap; }
.detalle-vacio { color: var(--text-mute); font-size: .85rem; margin: 0; font-style: italic; }

/* Acciones del detalle */
.detalle-acciones {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
}
.detalle-extra:empty { display: none; }
.detalle-form {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
    box-shadow: var(--shadow-sm); animation: fadeUp .25s ease both;
}
.detalle-form label {
    display: block; font-size: .74rem; font-weight: 700; color: var(--text-soft);
    text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
}
.detalle-form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* Control de avance (slider) */
.avance-control { display: flex; align-items: center; gap: 12px; }
.avance-control input[type="range"] {
    flex: 1; -webkit-appearance: none; appearance: none;
    height: 6px; border-radius: var(--pill); background: #e2e8f0; cursor: pointer;
}
.avance-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent); border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(16,24,40,.3); cursor: grab;
}
.avance-control input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent); border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(16,24,40,.3); cursor: grab;
}
.avance-valor {
    font-size: 1rem; font-weight: 700; color: var(--accent-ink);
    font-variant-numeric: tabular-nums; min-width: 46px; text-align: right;
}

/* Sugerencia del checklist: el dato verificable al lado del autoreportado */
.avance-sugerido {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 12px; padding: 9px 12px;
    background: var(--surface-2); border: 1px dashed var(--border-2);
    border-radius: var(--radius-sm);
    font-size: .82rem; color: var(--text-soft);
}
.avance-sugerido b { color: var(--accent-ink); }
.avance-sugerido .btn { margin-left: auto; }

/* Horas: estimadas contra reales */
.horas-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px;
}
.desvio {
    font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: var(--pill);
    background: var(--soft-gris); color: var(--ink-gris);
}
.desvio.ok   { background: var(--soft-gris);  color: var(--ink-gris); }
.desvio.bien { background: var(--soft-verde); color: var(--ink-verde); }
.desvio.mal  { background: var(--soft-rojo);  color: var(--ink-rojo); }
.horas-form { display: flex; gap: 8px; }
.horas-form input { flex: 1; }

.dato .v.riesgo { color: var(--ink-rojo); font-weight: 700; }

/* Checklist de subtareas */
.check-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.check-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 8px; border-radius: var(--radius-xs);
    transition: background .14s ease;
}
.check-item:hover { background: var(--surface-2); }
.check-item input[type="checkbox"] {
    width: 17px; height: 17px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; margin: 0;
}
.check-item .txt { flex: 1; font-size: .88rem; }
.check-item.hecha .txt { text-decoration: line-through; color: var(--text-mute); }
.check-item .del {
    background: none; border: none; color: var(--text-mute); cursor: pointer;
    font-size: .95rem; line-height: 1; padding: 2px 5px; border-radius: 5px;
    opacity: 0; transition: opacity .14s ease, color .14s ease; font-family: inherit;
}
.check-item:hover .del { opacity: 1; }
.check-item .del:hover { color: var(--est-bloqueada); background: var(--soft-rojo); }
.check-add { display: flex; gap: 8px; }
.check-add input { flex: 1; }
.check-progreso {
    font-size: .74rem; font-weight: 700; color: var(--text-soft);
    font-variant-numeric: tabular-nums;
}

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.tl-item { position: relative; padding: 0 0 16px 22px; }
.tl-item::before {
    content: ""; position: absolute; left: 5px; top: 13px; bottom: -3px;
    width: 2px; background: var(--border);
}
.tl-item.tl-last::before { display: none; }
.tl-dot {
    position: absolute; left: 0; top: 5px;
    width: 12px; height: 12px; border-radius: 50%;
    background: #fff; border: 2px solid var(--accent);
}
.tl-item.tl-last .tl-dot { background: var(--accent); }
.tl-fecha { font-size: .71rem; color: var(--text-mute); font-weight: 600; }
.tl-texto { font-size: .87rem; font-weight: 600; margin: 1px 0; }
.tl-autor { font-size: .75rem; color: var(--text-soft); }

/* Comentarios */
.det-comentarios { display: flex; flex-direction: column; gap: 10px; }
.det-coment {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px;
}
.det-coment.mio { background: rgba(15,118,110,.06); border-color: rgba(15,118,110,.18); }
.det-coment-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-bottom: 4px; font-size: .75rem; color: var(--text-mute);
}
.det-coment-head b { color: var(--text); font-size: .82rem; }
.det-coment-txt { font-size: .88rem; white-space: pre-wrap; }

.coment-form {
    display: flex; gap: 8px; padding: 11px 14px;
    background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0;
}
.coment-input { flex: 1; }
.coment-send {
    padding: 0 16px; background: var(--accent); font-size: 1rem;
}
.coment-send:hover { background: var(--accent-2); }

/* =========================================================================
   Modal (nueva tarea / editar)
   ========================================================================= */
.modal-overlay {
    position: fixed; inset: 0; z-index: 120;
    background: rgba(15,23,42,.5); backdrop-filter: blur(2px);
    display: none; align-items: center; justify-content: center; padding: 18px;
}
.modal-overlay.open { display: flex; animation: overlayIn .18s ease both; }
.modal {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: min(560px, 100%); max-height: 92vh; overflow-y: auto;
    animation: popIn .24s cubic-bezier(.32,.72,.35,1) both;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 18px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface); z-index: 1;
    border-radius: var(--radius) var(--radius) 0 0;
}
.modal-head h3 { margin: 0; font-size: 1.02rem; font-weight: 700; }
.modal-close {
    background: none; border: none; font-size: 1.35rem; line-height: 1; cursor: pointer;
    color: var(--text-mute); padding: 2px 6px; border-radius: 6px; font-family: inherit;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-body { padding: 18px; }
.modal-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 14px 18px; border-top: 1px solid var(--border);
    background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius);
}

/* =========================================================================
   Paginas de autenticacion (login / registro / cuenta)
   ========================================================================= */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 24px 18px;
    background:
        radial-gradient(1100px 500px at 50% -8%, rgba(15,118,110,.10), transparent 60%),
        var(--bg);
}
.auth-card {
    width: min(420px, 100%);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px; padding: 30px 28px;
    box-shadow: var(--shadow-md);
    animation: fadeUp .5s ease both;
}
.auth-logo {
    width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
    background: linear-gradient(160deg, var(--primary-2), var(--primary));
    color: #fff; font-size: 1.25rem; margin: 0 auto 14px;
    box-shadow: var(--shadow);
}
.auth-card h1 {
    margin: 0 0 4px; font-size: 1.22rem; font-weight: 700; text-align: center;
    letter-spacing: -.02em;
}
.auth-card .auth-sub {
    margin: 0 0 22px; text-align: center; color: var(--text-soft); font-size: .85rem;
}
.auth-alt { text-align: center; margin: 16px 0 0; font-size: .84rem; color: var(--text-soft); }
.auth-alt a { color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

.alerta {
    padding: 10px 13px; border-radius: var(--radius-sm); font-size: .85rem;
    font-weight: 500; margin-bottom: 16px; border-left: 3px solid;
}
.alerta-error { background: var(--soft-rojo); color: var(--ink-rojo); border-color: var(--est-bloqueada); }
.alerta-ok { background: var(--soft-verde); color: var(--ink-verde); border-color: var(--est-completada); }
.alerta-info { background: var(--soft-azul); color: var(--ink-azul); border-color: var(--est-en_curso); }

/* =========================================================================
   Tabla (admin de usuarios)
   ========================================================================= */
.panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden; margin-bottom: 20px;
}
.panel-head {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.panel-head h3 { margin: 0; font-size: .98rem; font-weight: 700; }
.tabla-wrap { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.tabla th {
    text-align: left; padding: 10px 14px; background: var(--surface-2);
    font-size: .68rem; font-weight: 700; color: var(--text-soft);
    text-transform: uppercase; letter-spacing: .06em;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tabla td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tabla tr:last-child td { border-bottom: none; }
table.tabla tbody tr:hover { background: var(--surface-2); }
.acciones-fila { display: flex; gap: 6px; flex-wrap: wrap; }

/* =========================================================================
   Toast
   ========================================================================= */
.toast {
    position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
    background: var(--primary); color: #fff;
    padding: 11px 20px; border-radius: var(--pill);
    font-size: .87rem; font-weight: 600;
    box-shadow: var(--shadow-lg);
    opacity: 0; pointer-events: none; z-index: 200;
    transition: opacity .22s ease, transform .22s ease;
    max-width: min(90vw, 460px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--est-bloqueada); }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 860px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .detalle-panel { width: 100%; }
}

@media (max-width: 640px) {
    .topbar { padding: 10px 13px; flex-wrap: wrap; }
    .topbar h1 { font-size: .93rem; }
    .topbar-right { gap: 6px; }
    .nav-link, .logout-link, .user-chip { padding: 6px 11px; font-size: .78rem; }
    .user-chip { max-width: 120px; }
    .user-chip .rol-tag { display: none; }
    .container { padding: 16px 13px 52px; }
    .page-head h2 { font-size: 1.15rem; }
    .form-row { grid-template-columns: 1fr; }
    .tarea-desc { -webkit-line-clamp: 2; }
    .tarea-chevron { display: none; }
    /* En el celular no hay drag & drop: los botones son la unica forma de
       reordenar, asi que necesitan area de toque de verdad. */
    .tarea-grip { width: 40px; }
    .tarea-grip .mover { padding: 8px 9px; font-size: .78rem; }
    .detalle-body { padding: 13px; }
    .modal-body { padding: 15px; }
}
