/* =========================================================================
   Sistema de Pedidos de Mantenimiento — Sistema de diseno
   Estetica: industrial-corporativo moderno. Neutros frios + acentos de marca.
   Tipografia Inter (vendored, offline). Profundidad sutil, micro-animaciones.
   ========================================================================= */

/* ---------- 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 {
    /* Colores de marca por tipo de pedido (vivos: se usan en graficos y acentos) */
    --color-correctivo: #E24B4A;
    --color-mejora:     #378ADD;
    --color-preventivo: #639922;
    --color-seguridad:  #BA7517;

    /* Colores por estado (mismos tonos de marca) */
    --estado-pendiente:  #6c757d;
    --estado-autorizado: #378ADD;
    --estado-rechazado:  #E24B4A;
    --estado-progreso:   #BA7517;
    --estado-completado: #639922;
    --estado-cancelado:  #475569;

    /* Prioridad */
    --prio-alta:  #E24B4A;
    --prio-media: #BA7517;
    --prio-baja:  #639922;

    /* Tintes suaves para badges (fondo claro + texto fuerte = sobrio y legible) */
    --soft-correctivo: rgba(226,75,74,.12);   --ink-correctivo: #B23733;
    --soft-mejora:     rgba(55,138,221,.12);  --ink-mejora:     #1E66B0;
    --soft-preventivo: rgba(99,153,34,.14);   --ink-preventivo: #4C7A15;
    --soft-seguridad:  rgba(186,117,23,.15);  --ink-seguridad:  #8A560E;
    --soft-neutral:    rgba(100,116,139,.14); --ink-neutral:    #475569;

    /* Neutros (escala fria) */
    --bg:          #eef1f5;
    --surface:     #ffffff;
    --surface-2:   #f8fafc;
    --border:      #e6eaef;
    --border-2:    #d7dde5;
    --text:        #18212f;
    --text-soft:   #64748b;
    --text-mute:   #94a3b8;

    /* Marca / acento */
    --primary:      #1e293b;   /* slate profundo para topbar y botones base */
    --primary-2:    #334155;
    --accent:       #378ADD;   /* azul interactivo */
    --accent-ink:   #1E66B0;

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

    /* Sombras en capas (suaves) */
    --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 16px 40px rgba(16,24,40,.16);

    --ring: 0 0 0 3px rgba(55,138,221,.22);
}

* { 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;
}

h1, h2, h3 { text-wrap: balance; letter-spacing: -.011em; }
p { text-wrap: pretty; }

::selection { background: rgba(55,138,221,.22); }

: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(.98); } to { opacity: 1; transform: none; } }
@keyframes overlayIn{ from { opacity: 0; } to { opacity: 1; } }

/* ---------- Barra superior ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(180deg, #243244 0%, var(--primary) 100%);
    color: #fff;
    padding: 12px 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 {
    font-size: 1.15rem; line-height: 1;
    width: 36px; height: 36px;
    display: grid; place-items: center;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 11px;
}
.topbar h1 {
    font-size: 1.06rem; margin: 0; font-weight: 600; letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.role-badge {
    background: rgba(255,255,255,.16);
    padding: 5px 12px; border-radius: var(--pill);
    font-size: .72rem; font-weight: 700; letter-spacing: .06em;
}
.nav-link, .logout-link {
    color: #fff; text-decoration: none; font-size: .82rem; font-weight: 600;
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.10);
    padding: 7px 13px; border-radius: var(--pill);
    transition: background .18s ease, transform .12s ease;
}
.nav-link:hover, .logout-link:hover { background: rgba(255,255,255,.22); }
.nav-link:active, .logout-link:active { transform: translateY(1px); }
.logout-link { background: transparent; opacity: .9; }
.logout-link:hover { background: rgba(255,255,255,.16); opacity: 1; }
.user-chip {
    color: #fff; font-size: .82rem; font-weight: 600; text-decoration: none;
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.12);
    padding: 6px 13px; border-radius: var(--pill);
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: background .18s ease;
}
a.user-chip::before { content: "\1F464\00a0"; opacity: .85; }
a.user-chip:hover { background: rgba(255,255,255,.22); }

/* ---------- Contenedor ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 22px 18px 48px; }

/* ---------- Estadisticas (supervisor / mantenimiento) ---------- */
.stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 14px; margin-bottom: 22px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 14px; text-align: center;
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease;
    animation: fadeUp .5s ease both;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .num {
    font-size: 1.9rem; font-weight: 700; line-height: 1.1; color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.stat-card .label {
    font-size: .72rem; color: var(--text-soft); margin-top: 3px;
    text-transform: uppercase; letter-spacing: .05em; 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; }

/* ---------- Secciones ---------- */
.section { margin-bottom: 24px; }
.section-title {
    font-size: 1.02rem; font-weight: 700; margin: 0 0 12px; letter-spacing: -.01em;
    display: flex; align-items: center; gap: 8px;
}

/* ---------- Tarjetas de pedido ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border-2);
    border-radius: var(--radius);
    padding: 16px 18px; margin-bottom: 14px;
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card.tipo-correctivo { border-left-color: var(--color-correctivo); }
.card.tipo-mejora     { border-left-color: var(--color-mejora); }
.card.tipo-preventivo { border-left-color: var(--color-preventivo); }
.card.tipo-seguridad  { border-left-color: var(--color-seguridad); }

.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.card h3 { margin: 2px 0; font-size: 1.08rem; font-weight: 600; }
.card .desc { margin: 6px 0 12px; color: var(--text); }
.card .meta { font-size: .8rem; color: var(--text-soft); display: flex; flex-wrap: wrap; gap: 6px 18px; }
.card .meta b { color: var(--text); font-weight: 600; }

/* ---------- Badges (tintados, sobrios) ---------- */
.badge {
    display: inline-flex; align-items: center;
    padding: 4px 11px; border-radius: var(--pill);
    font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    background: var(--soft-neutral); color: var(--ink-neutral);
}
.badge-tipo-correctivo,
.badge-estado-rechazado,
.badge-prio-Alta  { background: var(--soft-correctivo); color: var(--ink-correctivo); }
.badge-tipo-mejora,
.badge-estado-autorizado { background: var(--soft-mejora); color: var(--ink-mejora); }
.badge-tipo-preventivo,
.badge-estado-completado,
.badge-prio-Baja  { background: var(--soft-preventivo); color: var(--ink-preventivo); }
.badge-tipo-seguridad,
.badge-estado-progreso,
.badge-prio-Media { background: var(--soft-seguridad); color: var(--ink-seguridad); }
.badge-estado-pendiente { background: var(--soft-neutral); color: var(--ink-neutral); }
.badge-estado-cancelado { background: rgba(71,85,105,.16); color: #475569; }

/* ---------- Fecha limite destacada (pildora) ---------- */
.limite {
    display: inline-flex; align-items: center; gap: 6px;
    margin-left: auto;                 /* la empuja al extremo derecho del head */
    padding: 5px 11px; border-radius: var(--pill);
    font-size: .74rem; font-weight: 700; letter-spacing: .01em;
    background: var(--soft-seguridad); color: var(--ink-seguridad);
    border: 1px solid rgba(186,117,23,.22);
    white-space: nowrap;
}
.limite svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.limite-vencido {
    background: var(--soft-correctivo); color: var(--ink-correctivo);
    border-color: rgba(226,75,74,.28);
    animation: pulseVenc 1.8s ease-in-out infinite;
}
.limite-tag {
    text-transform: uppercase; letter-spacing: .05em; font-size: .64rem;
    background: var(--color-correctivo); color: #fff;
    padding: 1px 7px; border-radius: var(--pill);
}
@keyframes pulseVenc {
    0%, 100% { box-shadow: 0 0 0 0 rgba(226,75,74,0); }
    50%      { box-shadow: 0 0 0 4px rgba(226,75,74,.14); }
}
@media (max-width: 560px) { .limite { margin-left: 0; } }

/* Cancelar pedido (accion destructiva pero secundaria: contorno, no relleno) */
.btn-cancelar {
    background: var(--surface); color: var(--ink-correctivo);
    border: 1px solid rgba(226,75,74,.40); box-shadow: none;
}
.btn-cancelar:hover { background: var(--soft-correctivo); filter: none; }

/* =========================================================================
   Tarjeta compacta (resumen, clickeable -> detalle)
   ========================================================================= */
.card-mini {
    position: relative; display: flex; gap: 12px; align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border); border-left: 4px solid var(--border-2);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
    box-shadow: var(--shadow); cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease;
}
.card-mini:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-mini:focus-visible { outline: none; box-shadow: var(--shadow-md), var(--ring); transform: translateY(-2px); }
.card-mini.tipo-correctivo { border-left-color: var(--color-correctivo); }
.card-mini.tipo-mejora     { border-left-color: var(--color-mejora); }
.card-mini.tipo-preventivo { border-left-color: var(--color-preventivo); }
.card-mini.tipo-seguridad  { border-left-color: var(--color-seguridad); }

.mini-main { flex: 1 1 auto; min-width: 0; }
.mini-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding-right: 28px; }
/* El #id va anclado al borde superior derecho de la tarjeta: queda alineado
   por igual tengan o no miniatura (antes lo empujaba la foto). */
.mini-id { position: absolute; top: 14px; right: 16px; font-size: .78rem; font-weight: 700; color: var(--text-mute); }
.mini-title {
    margin: 2px 0 4px; font-size: 1rem; font-weight: 600; line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-desc {
    margin: 0 0 9px; color: var(--text-soft); font-size: .85rem; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}
.mini-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.mini-prio { font-size: .76rem; font-weight: 700; white-space: nowrap; }
.mini-prio.prio-Alta  { color: var(--prio-alta); }
.mini-prio.prio-Media { color: var(--prio-media); }
.mini-prio.prio-Baja  { color: var(--prio-baja); }
.mini-limite { font-size: .76rem; font-weight: 600; color: var(--ink-seguridad); white-space: nowrap; }
.mini-limite.venc { color: var(--ink-correctivo); font-weight: 700; }
.mini-coment { font-size: .76rem; color: var(--text-soft); }
.mini-asig { font-size: .76rem; font-weight: 600; color: var(--accent-ink); white-space: nowrap; }
.mini-thumb { flex: 0 0 auto; width: 62px; height: 62px; border-radius: var(--radius-sm); overflow: hidden; align-self: center; }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-chevron { align-self: center; color: var(--text-mute); font-size: 1.5rem; line-height: 1; flex: 0 0 auto; }

/* =========================================================================
   Vista de detalle (overlay a pantalla completa / hoja en desktop)
   ========================================================================= */
body.no-scroll { overflow: hidden; }
.detalle-overlay {
    display: none; position: fixed; inset: 0; z-index: 280;
    background: rgba(15,23,42,.5); backdrop-filter: blur(3px);
    justify-content: center; align-items: stretch;
}
.detalle-overlay.open { display: flex; animation: overlayIn .2s ease; }
.detalle-panel {
    display: flex; flex-direction: column; width: 100%; max-width: 560px;
    background: var(--bg); box-shadow: var(--shadow-lg);
    animation: slideUp .28s cubic-bezier(.2,.8,.2,1) both;
}
@media (min-width: 600px) {
    .detalle-overlay { align-items: center; padding: 24px; }
    .detalle-panel { max-height: 92vh; border-radius: var(--radius); overflow: hidden; }
}
@keyframes slideUp { from { transform: translateY(18px); opacity: .5; } to { transform: none; opacity: 1; } }

.detalle-topbar {
    flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
    padding: 13px 16px; color: #fff;
    background: linear-gradient(120deg, var(--primary-2), var(--primary));
}
.detalle-back {
    background: rgba(255,255,255,.14); border: none; color: #fff;
    width: 34px; height: 34px; border-radius: var(--pill); cursor: pointer;
    font-size: 1.15rem; line-height: 1; display: grid; place-items: center;
    transition: background .16s ease;
}
.detalle-back:hover { background: rgba(255,255,255,.30); }
.detalle-tt { font-weight: 700; font-size: 1.02rem; flex: 1 1 auto; }
.detalle-id { font-weight: 700; opacity: .85; }

.detalle-body { flex: 1 1 auto; overflow-y: auto; padding: 18px; }
.detalle-cargando { padding: 64px 20px; text-align: center; color: var(--text-soft); }

.detalle-cabecera { padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.detalle-cabecera h2 { margin: 10px 0 8px; font-size: 1.32rem; line-height: 1.25; text-wrap: balance; }
.detalle-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.detalle-creado { font-size: .82rem; color: var(--text-soft); }
.detalle-limite {
    margin-top: 10px; display: inline-block; font-size: .84rem;
    padding: 6px 12px; border-radius: var(--radius-xs);
    background: var(--soft-seguridad); color: var(--ink-seguridad); font-weight: 600;
}
.detalle-limite.venc { background: var(--soft-correctivo); color: var(--ink-correctivo); }
.detalle-asignacion { margin-top: 14px; }
.asignar-tit { display: block; font-size: .78rem; font-weight: 700; color: var(--text-soft); margin-bottom: 8px; }
.asignar-ops { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.op-check {
    display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
    padding: 7px 12px; border: 1px solid var(--border-2); border-radius: var(--pill);
    font-size: .85rem; background: var(--surface); user-select: none;
    transition: border-color .14s ease, background .14s ease;
}
.op-check:hover { border-color: var(--accent); }
.op-check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.op-check:has(input:checked) { background: var(--soft-mejora); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.detalle-asignado-ro { margin-top: 12px; font-size: .86rem; color: var(--text-soft); }
.detalle-asignado-ro b { color: var(--text); }

.detalle-sec { margin-bottom: 22px; }
.detalle-sec h4 {
    margin: 0 0 10px; font-size: .76rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft);
}
.detalle-desc { margin: 0; line-height: 1.6; color: var(--text); }
.detalle-vacio { color: var(--text-mute); font-size: .85rem; font-style: italic; margin: 0; }
.detalle-sec .card-foto { max-width: 280px; margin: 0; }

.detalle-acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.detalle-extra:empty { display: none; }
.detalle-form {
    margin: 0 0 18px; padding: 14px; border: 1px solid var(--border-2);
    border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-sm);
}
.detalle-form label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; }
.detalle-form textarea, .detalle-form input[type="date"] {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-2);
    border-radius: var(--radius-xs); font-family: inherit; font-size: .9rem; color: var(--text);
    background: var(--surface);
}
.detalle-form textarea { min-height: 70px; resize: vertical; line-height: 1.5; }
.detalle-form textarea:focus, .detalle-form input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.detalle-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* Historial / linea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { position: relative; padding: 0 0 18px 26px; }
.tl-item::before {
    content: ""; position: absolute; left: 6px; top: 5px; bottom: -3px;
    width: 2px; background: var(--border-2);
}
.tl-item.tl-last::before { display: none; }
.tl-dot {
    position: absolute; left: 0; top: 3px; width: 14px; height: 14px; box-sizing: border-box;
    border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); z-index: 1;
}
.tl-item.tl-last .tl-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(55,138,221,.16); }
.tl-fecha { font-size: .75rem; color: var(--text-soft); }
.tl-texto { font-weight: 600; font-size: .92rem; margin: 1px 0; }
.tl-autor { font-size: .8rem; color: var(--text-soft); }

/* Comentarios (burbujas) */
.det-comentarios { display: flex; flex-direction: column; gap: 10px; }
.det-coment { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.det-coment-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: .77rem; color: var(--text-soft); }
.det-coment-head b { color: var(--text); }
.det-coment-txt { font-size: .9rem; line-height: 1.5; color: var(--text); }

/* Caja de comentario fija abajo */
.detalle-footer {
    flex: 0 0 auto; margin-top: 0; gap: 8px; align-items: center;
    padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface);
}
.coment-send {
    flex: 0 0 auto; width: 42px; height: 42px; min-height: 42px; padding: 0;
    border-radius: 50%; background: var(--accent); font-size: 1rem;
}

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: none; border-radius: var(--radius-xs);
    padding: 10px 16px; min-height: 40px;
    font-family: inherit; font-size: .86rem; font-weight: 600;
    cursor: pointer; color: #fff; background: var(--primary);
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, box-shadow .2s ease, filter .2s ease, background .2s ease;
}
.btn:hover { filter: brightness(1.08); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(0); filter: brightness(.97); }
.btn-block { display: flex; width: 100%; padding: 13px; font-size: 1rem; min-height: 48px; }
.btn-green  { background: var(--estado-completado); }
.btn-blue   { background: var(--accent); }
.btn-red    { background: var(--color-correctivo); }
.btn-gray   { background: #64748b; }
.btn-sm { padding: 7px 13px; min-height: 34px; font-size: .8rem; }

.card-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 11px 12px;
    border: 1px solid var(--border-2); border-radius: var(--radius-xs);
    font-size: .95rem; font-family: inherit; color: var(--text);
    background: var(--surface);
    transition: border-color .18s ease, box-shadow .18s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.field input[type="file"] { padding: 9px 12px; background: var(--surface-2); cursor: pointer; }
.opcional { font-weight: 400; color: var(--text-soft); font-size: .78rem; }

/* ---------- Comentarios ---------- */
.comentarios { margin-top: 12px; border-top: 1px dashed var(--border-2); padding-top: 10px; }
.comentario { font-size: .82rem; margin-bottom: 6px; line-height: 1.5; }
.comentario .autor { font-weight: 700; }
.comentario .fecha { color: var(--text-mute); font-size: .72rem; }
.toggle-comentarios {
    background: none; border: none; color: var(--accent-ink);
    font-size: .8rem; cursor: pointer; padding: 4px 0; font-weight: 600;
}
.toggle-comentarios:hover { text-decoration: underline; }

/* Caja de respuesta inline (hilo de conversacion) */
.coment-form { display: flex; gap: 8px; margin-top: 10px; }
.coment-input {
    flex: 1 1 auto; min-width: 0;
    padding: 9px 12px; border: 1px solid var(--border-2);
    border-radius: var(--radius-xs); font-family: inherit; font-size: .85rem;
    color: var(--text); background: var(--surface);
    transition: border-color .18s ease, box-shadow .18s ease;
}
.coment-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.coment-form .btn { flex-shrink: 0; }
.motivo-rechazo {
    margin-top: 10px; padding: 9px 12px; border-radius: var(--radius-xs);
    background: var(--soft-correctivo); color: var(--ink-correctivo);
    font-size: .82rem; font-weight: 600;
    border: 1px solid rgba(226,75,74,.18);
}

/* ---------- Tabs / filtros ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; animation: fadeUp .45s ease both; }
.tab {
    border: 1px solid var(--border-2); background: var(--surface);
    color: var(--text-soft); padding: 9px 15px; min-height: 38px;
    border-radius: var(--pill); cursor: pointer;
    font-family: inherit; font-size: .82rem; font-weight: 600;
    transition: all .16s ease;
}
.tab:hover { border-color: var(--accent); color: var(--accent-ink); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: var(--shadow-sm); }
.tab-mias { border-color: var(--accent); color: var(--accent-ink); }
.tab-mias.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Modal ---------- */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,.55); backdrop-filter: blur(2px);
    z-index: 100; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; animation: overlayIn .2s ease; }
.modal {
    background: var(--surface); border-radius: var(--radius);
    padding: 22px; width: 100%; max-width: 460px;
    box-shadow: var(--shadow-lg);
    animation: popIn .28s cubic-bezier(.2,.8,.2,1) both;
}
.modal h3 { margin: 0 0 16px; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
    background: var(--primary); color: #fff;
    padding: 12px 22px; border-radius: var(--pill); font-weight: 600; font-size: .9rem;
    box-shadow: var(--shadow-lg);
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease, transform .25s ease; z-index: 420;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--color-correctivo); }
.toast.error::before { content: "\26a0\00a0"; }

/* ---------- Estados vacios / listas ---------- */
.empty {
    text-align: center; color: var(--text-soft); padding: 40px 20px;
    background: var(--surface); border: 1px dashed var(--border-2);
    border-radius: var(--radius); font-size: .9rem;
}
.scroll-list { max-height: 68vh; overflow-y: auto; padding-right: 4px; }

/* ---------- Landing (index, orphan) + Auth ---------- */
.landing {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 100vh; gap: 22px; text-align: center; padding: 24px;
    background:
        radial-gradient(1100px 520px at 50% -8%, rgba(55,138,221,.12), transparent 62%),
        linear-gradient(180deg, #f8fafc 0%, #e9edf3 100%);
}
.landing h1 { font-size: 1.6rem; margin: 0; }
.landing p { color: var(--text-soft); margin: 0; }
.role-links { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.role-link {
    display: block; text-decoration: none; color: #fff;
    padding: 28px 34px; border-radius: var(--radius); min-width: 200px;
    box-shadow: var(--shadow-md); font-weight: 700; font-size: 1.1rem;
    transition: transform .18s ease, box-shadow .18s ease;
}
.role-link:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.role-link small { display: block; font-weight: 400; font-size: .82rem; opacity: .9; margin-top: 6px; }
.role-link.sup { background: linear-gradient(135deg, #4a9be6, var(--color-mejora)); }
.role-link.mant { background: linear-gradient(135deg, var(--primary-2), var(--primary)); }

.auth-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px; box-shadow: var(--shadow-lg);
    padding: 34px 30px; width: 100%; max-width: 380px; text-align: center;
    animation: popIn .45s cubic-bezier(.2,.8,.2,1) both;
}
.auth-card .auth-logo {
    width: 64px; height: 64px; margin: 0 auto 10px;
    display: grid; place-items: center; border-radius: 18px;
    background: linear-gradient(135deg, #34507a, var(--primary));
    color: #fff; font-size: 2rem; box-shadow: var(--shadow-md);
}
.auth-card h1 { font-size: 1.4rem; margin: 0 0 4px; }
.auth-card p { color: var(--text-soft); font-size: .88rem; margin: 0 0 22px; }
.auth-card .field { text-align: left; margin-bottom: 16px; }
.auth-error {
    background: var(--soft-correctivo); color: var(--ink-correctivo);
    border: 1px solid rgba(226,75,74,.18);
    border-radius: var(--radius-xs); padding: 10px 12px;
    font-size: .82rem; font-weight: 600; margin-bottom: 16px;
}
.auth-ok {
    background: var(--soft-preventivo); color: var(--ink-preventivo);
    border: 1px solid rgba(99,153,34,.22);
    border-radius: var(--radius-xs); padding: 10px 12px;
    font-size: .82rem; font-weight: 600; margin-bottom: 16px;
}
.auth-hint { margin-top: 10px; font-size: .78rem; color: var(--text-mute); }
.auth-alt { margin-top: 18px; font-size: .85rem; color: var(--text-soft); }
.auth-alt a, .auth-back { color: var(--accent-ink); font-weight: 700; text-decoration: none; }
.auth-alt a:hover, .auth-back:hover { text-decoration: underline; }
.auth-back { display: inline-block; margin-top: 16px; font-size: .82rem; }

/* Eleccion de rol (registro) */
.rol-choice { display: flex; flex-direction: column; gap: 8px; }
.rol-opt {
    display: flex; align-items: flex-start; gap: 10px;
    border: 1px solid var(--border-2); border-radius: var(--radius-xs);
    padding: 11px 13px; cursor: pointer; text-align: left;
    transition: border-color .16s ease, background .16s ease;
}
.rol-opt:hover { border-color: var(--accent); }
.rol-opt:has(input:checked) { border-color: var(--accent); background: rgba(55,138,221,.06); box-shadow: var(--ring); }
.rol-opt input { margin-top: 3px; accent-color: var(--accent); }
.rol-opt span { display: flex; flex-direction: column; }
.rol-opt small { color: var(--text-soft); font-weight: 400; font-size: .78rem; }

/* ---------- Foto de evidencia ---------- */
.card-foto { margin: 6px 0 12px; }
.card-foto img {
    width: 148px; height: 148px; object-fit: cover;
    border-radius: var(--radius-sm); border: 1px solid var(--border-2);
    cursor: zoom-in; display: block;
    transition: transform .18s ease, box-shadow .18s ease;
}
.card-foto img:hover { transform: scale(1.03); box-shadow: var(--shadow-md); }

.foto-preview { margin-top: 10px; position: relative; display: inline-block; }
.foto-preview img {
    max-width: 150px; max-height: 150px;
    border-radius: var(--radius-sm); border: 1px solid var(--border-2); display: block;
}
.foto-quitar {
    position: absolute; top: -9px; right: -9px;
    width: 26px; height: 26px; border-radius: var(--pill);
    border: 2px solid #fff; background: var(--color-correctivo); color: #fff;
    font-size: 1.05rem; line-height: 1; cursor: pointer;
    box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
    transition: transform .12s ease;
}
.foto-quitar:hover { transform: scale(1.1); }

.lightbox {
    display: none; position: fixed; inset: 0;
    background: rgba(10,15,25,.88); z-index: 360;
    align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.lightbox.open { display: flex; animation: overlayIn .2s ease; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }

/* ---------- Dashboard ---------- */
.dash-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
    animation: fadeUp .4s ease both;
}
.dash-updated { color: var(--text-soft); font-size: .82rem; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.dash-updated::before {
    content: ""; width: 8px; height: 8px; border-radius: 50%;
    background: var(--estado-completado); box-shadow: 0 0 0 3px rgba(99,153,34,.18);
}

.export-wrap { position: relative; }
.export-menu {
    display: none; position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    min-width: 200px; overflow: hidden; z-index: 60;
    animation: popIn .18s ease both;
}
.export-menu.open { display: block; }
.export-menu a {
    display: block; padding: 12px 16px; text-decoration: none;
    color: var(--text); font-size: .88rem; font-weight: 600;
    transition: background .14s ease;
}
.export-menu a:hover { background: var(--surface-2); color: var(--accent-ink); }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi {
    background: var(--surface); border: 1px solid var(--border);
    border-top: 3px solid var(--text-soft);
    border-radius: var(--radius); padding: 18px 14px; text-align: center;
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease;
    animation: fadeUp .5s ease both;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.kpi .num { font-size: 2.1rem; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .label { font-size: .72rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; margin-top: 5px; font-weight: 600; }
.kpi-total { border-top-color: var(--primary); }
.kpi-pend  { border-top-color: var(--estado-pendiente); }
.kpi-auto  { border-top-color: var(--estado-autorizado); }
.kpi-prog  { border-top-color: var(--estado-progreso); }
.kpi-comp  { border-top-color: var(--estado-completado); }
.kpi-venc  { border-top-color: var(--estado-rechazado); }
.kpi-venc .num { color: var(--estado-rechazado); }
.kpis .kpi:nth-child(1) { animation-delay: .02s; }
.kpis .kpi:nth-child(2) { animation-delay: .06s; }
.kpis .kpi:nth-child(3) { animation-delay: .10s; }
.kpis .kpi:nth-child(4) { animation-delay: .14s; }
.kpis .kpi:nth-child(5) { animation-delay: .18s; }
.kpis .kpi:nth-child(6) { animation-delay: .22s; }

.charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.chart-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
    animation: fadeUp .55s ease both;
}
.chart-title { margin: 0 0 14px; font-size: .95rem; font-weight: 700; }
.chart-box { position: relative; height: 264px; }

/* ---------- Tabla de administracion ---------- */
.tabla-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.tabla {
    width: 100%; border-collapse: collapse; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.tabla th, .tabla td {
    padding: 12px 14px; text-align: left; font-size: .86rem;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tabla th {
    background: var(--surface-2); color: var(--text-soft);
    text-transform: uppercase; font-size: .7rem; letter-spacing: .05em; font-weight: 700;
}
.tabla tbody tr { transition: background .14s ease; }
.tabla tbody tr:hover { background: var(--surface-2); }
.tabla tr:last-child td { border-bottom: none; }
.tabla select {
    padding: 7px 9px; border: 1px solid var(--border-2);
    border-radius: var(--radius-xs); font-family: inherit; font-size: .82rem; background: #fff;
}
.tabla select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.col-fecha { color: var(--text-soft); }
.estado-on  { color: var(--estado-completado); font-weight: 700; }
.estado-off { color: var(--estado-rechazado); font-weight: 700; }
.fila-acciones { display: flex; flex-wrap: wrap; gap: 6px; }
.reset-info { font-size: .86rem; color: var(--text-soft); margin: 0 0 14px; }
.reset-pass {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 1.3rem; font-weight: 700; letter-spacing: .04em; text-align: center;
    user-select: all; color: var(--primary);
    background: var(--surface-2); border: 1px dashed var(--border-2);
    border-radius: var(--radius-xs); padding: 14px;
}

/* ---------- Alta manual de usuarios (admin) ---------- */
.alta-form {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
    display: grid; grid-template-columns: 1.4fr 1.8fr .9fr auto;
    gap: 14px; align-items: end;
}
.alta-form .field { margin-bottom: 0; }
.alta-form .btn { min-height: 42px; }
.alta-hint { font-size: .8rem; color: var(--text-soft); margin: 10px 0 0; }
@media (max-width: 860px) {
    .alta-form { grid-template-columns: 1fr; align-items: stretch; }
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 960px) {
    .kpis { grid-template-columns: repeat(3, 1fr); }
    .charts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .topbar { padding: 11px 14px; }
    .topbar h1 { font-size: .98rem; }
    .topbar .logo { width: 32px; height: 32px; }
    .container { padding: 16px 13px 40px; }
    .card-actions .btn { flex: 1 1 auto; }
    .chart-box { height: 244px; }
    .nav-link, .user-chip { font-size: .78rem; padding: 6px 10px; }
    /* targets tactiles mas comodos en mobile */
    .btn { min-height: 44px; }
    .tab { min-height: 42px; }
}

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