:root{
  --bg1:#040b18;
  --bg2:#071a33;
  --panel:rgba(255,255,255,.08);
  --stroke:rgba(255,255,255,.14);
  --text:#eaf2ff;
  --muted:#b9c8e6;
  --primary:#1ea7ff;
  --primary2:#0b67ff;
  --danger:#ff4d4d;
  --success:#23d18b;
  --warn:#ffb020;
  --shadow:0 20px 60px rgba(0,0,0,.45);
  --radius:18px;
}

*{box-sizing:border-box}
html,body{height:100%; width:100%}
body{
  margin:0;
  font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial;
  color:var(--text);
  overflow-x:hidden;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(30,167,255,.18) 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(11,103,255,.18) 0%, transparent 55%),
    radial-gradient(900px 600px at 60% 120%, rgba(0,240,255,.10) 0%, transparent 55%),
    linear-gradient(180deg,var(--bg1),var(--bg2));
}

.container{
  max-width:1200px;
  margin:0 auto;
  padding:28px 18px 60px;
  width:100%;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:18px;
  border:1px solid var(--stroke);
  background:linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.05));
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  backdrop-filter:blur(10px);
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}
.brand img{
  height:42px;
  width:auto;
  filter:drop-shadow(0 6px 18px rgba(0,0,0,.45));
}
.brand h1{
  margin:0;
  font-size:28px;
  letter-spacing:.3px;
  line-height:1.15;
}
.brand small{
  display:block;
  color:var(--muted);
  margin-top:2px;
}

.userbox{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.pill{
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background:rgba(0,0,0,.18);
  font-weight:700;
  font-size:13px;
}

.btn{
  appearance:none;
  border:1px solid transparent;
  cursor:pointer;
  padding:10px 14px;
  border-radius:12px;
  font-weight:800;
  background:linear-gradient(90deg,var(--primary2),var(--primary));
  color:#fff;
  box-shadow:0 14px 30px rgba(30,167,255,.18);
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
}

.btn.secondary{
  background:linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.05));
  border-color:var(--stroke);
  color:var(--text);
  box-shadow:none;
}

.btn.danger{background:linear-gradient(90deg,#c51414,#ff4d4d)}
.btn.success{background:linear-gradient(90deg,#0a9b62,#23d18b)}
.btn.warn{background:linear-gradient(90deg,#d28100,#ffb020)}

.grid{
  margin-top:18px;
  display:grid;
  grid-template-columns:360px 1fr;
  gap:16px;
}
@media (max-width:980px){
  .grid{grid-template-columns:1fr}
}

.card{
  border:1px solid var(--stroke);
  background:linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  backdrop-filter:blur(10px);
}
.card .inner{padding:16px}

.row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-end;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width:140px;
  flex:1;
}

label{
  color:var(--muted);
  font-size:12px;
  font-weight:700;
}

input,select,textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(10,18,35,.55);
  color:var(--text);
  outline:none;
}

textarea{min-height:76px;resize:vertical}

.kpis{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:10px;
  margin-top:10px;
}
@media(max-width:980px){.kpis{grid-template-columns:repeat(2,1fr)}}

.kpi{
  padding:12px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(0,0,0,.12);
}
.kpi b{font-size:22px}
.kpi span{display:block;color:var(--muted);font-size:12px;margin-top:3px}

.task{
  border:1px solid rgba(255,255,255,.12);
  background:rgba(0,0,0,.14);
  border-radius:16px;
  overflow:hidden;
  margin-bottom:12px;
}

.task .t-head{
  padding:12px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
}

.task .title{font-weight:900}

.badges{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:8px;
}

.badge{
  font-size:12px;
  font-weight:900;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
}
.badge.prog{background:rgba(11,103,255,.18);border-color:rgba(11,103,255,.45)}
.badge.done{background:rgba(35,209,139,.18);border-color:rgba(35,209,139,.45)}

.task .t-body{
  padding:0 12px 12px;
  color:var(--muted);
  font-size:14px;
}

.task .actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
}

.hr{height:1px;background:rgba(255,255,255,.12);margin:10px 0}

.notice{
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(0,0,0,.14);
  color:var(--muted);
}
.help{color:var(--muted);font-size:12px}

/* =========================
   MODAL + SCROLL EN CELULAR
========================= */
.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.62);
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:50;
  overflow:hidden; /* desktop */
}

.modal{
  max-width:980px;
  width:100%;
}

/* Firma */
.signature-wrap{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}
@media(max-width:900px){
  .signature-wrap{grid-template-columns:1fr}
}

.sigbox{
  border:1px dashed rgba(255,255,255,.25);
  border-radius:16px;
  overflow:hidden;
  background:rgba(0,0,0,.18);
}

.sigbox header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:10px 12px;
  border-bottom:1px solid rgba(255,255,255,.10);
}

.sigbox canvas{
  width:100%;
  height:220px;
  touch-action:none;
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
}

/* Login */
.login-shell{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px}
.login-card{width:min(520px,100%)}
.center{text-align:center}
.error{color:#ffd1d1}

/* =========================
   RESPONSIVE EXTRA (MÓVIL)
========================= */

/* Topbar apilado */
@media (max-width: 720px){
  .container{ padding:18px 14px 40px; }

  .topbar{
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  .brand{
    width: 100%;
    justify-content:flex-start;
  }
  .brand img{ height: 34px; }
  .brand h1{ font-size: 22px; }

  .userbox{
    width: 100%;
    justify-content:flex-start;
    gap: 8px;
  }

  .userbox .btn{ width: 100%; }
}

/* Form a una columna */
@media (max-width: 520px){
  .row{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .field{
    min-width: 0;
    width: 100%;
    flex: initial;
  }

  input, select, textarea{
    font-size:16px; /* evita zoom iPhone */
  }

  .kpis{ grid-template-columns: 1fr; }

  .task .t-head{
    flex-direction: column;
    align-items:flex-start;
  }
  .task .actions{
    width:100%;
    justify-content:flex-start;
  }
  .task .actions .btn{
    width:100%;
  }
}

/* ====== FIX IMPORTANTE: en móvil el modal debe scrollear ====== */
@media (max-width: 720px){
  .modal-backdrop{
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    align-items:flex-start;
    justify-content:center;
    padding:12px;
  }

  .modal{
    margin:12px auto;
    max-height:calc(100vh - 24px);
  }

  .modal .card{
    max-height:calc(100vh - 24px);
    overflow:hidden;
  }

  .modal .card .inner{
    max-height:calc(100vh - 24px);
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    padding-bottom:100px; /* espacio para el botón sticky */
  }

  /* Botonera pegada abajo para que SIEMPRE se vea Finalizar */
  .modal .actions{
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 12px;
    margin: 0 -16px -16px;
    background: rgba(6,16,32,.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,.12);
    display:flex;
    flex-direction:column;
    gap:10px;
  }

  .modal .actions .btn{
    width:100%;
    padding:14px;
    font-size:16px;
  }

  .sigbox header{
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .sigbox canvas{ height: 200px; }
}
/* ===== FIX SCROLL MODAL EN CELULAR (FORZADO) ===== */

/* IMPORTANTÍSIMO: no bloquees el scroll del backdrop */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  z-index: 9999;

  /* en vez de flex, usa block para que el navegador scrollee mejor */
  display: none;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  padding: 12px;

  /* permite scroll con dedo */
  touch-action: pan-y;
}

/* El contenedor del modal no debe fijar alturas raras */
.modal{
  width: 100%;
  max-width: 980px;
  margin: 12px auto;
}

/* El card interno scrollea si es muy largo */
.modal .card{
  overflow: visible;
}

/* El contenido interno SIEMPRE con scroll en móvil */
.modal .card .inner{
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 120px); /* deja espacio para botones */
  padding-bottom: 110px;           /* espacio para botones sticky */
  touch-action: pan-y;
}

/* Botones siempre visibles abajo (Finalizar) */
.modal .actions{
  position: sticky;
  bottom: 0;
  z-index: 20;

  background: rgba(6,16,32,.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.12);

  padding: 12px;
  margin-top: 12px;

  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Botones full width y grandes en celular */
.modal .actions .btn{
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

/* Reduce firma en móvil para que NO tape todo */
@media (max-width: 520px){
  .sigbox canvas{ height: 150px !important; }
  textarea{ min-height: 64px; }
}
