/* ============================================================
   PLAN DE IZAJE — Sistema de diseño
   Paleta: papel de obra + acero + señalética de seguridad
   Tipografía: Barlow Condensed (títulos/señalética),
               Inter (cuerpo), IBM Plex Mono (datos técnicos)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root{
  --bg:            #F3F1EA;
  --surface:       #FFFFFF;
  --surface-2:     #ECE8DD;
  --ink:           #1C2126;
  --ink-soft:      #4B535B;
  --border:        #D9D2C1;
  --steel:         #2E5266;
  --steel-dark:    #203C4A;
  --steel-light:   #DCE7EC;
  --yellow:        #F2B705;
  --yellow-dark:   #B5850A;
  --orange:        #E2711D;
  --danger:        #C1272D;
  --danger-light:  #FBE4E4;
  --success:       #3C8C5C;
  --success-light: #E1F0E5;
  --warn-light:    #FDF3D9;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(28,33,38,.06), 0 4px 14px rgba(28,33,38,.06);
  --shadow-lg: 0 8px 30px rgba(28,33,38,.14);

  --font-display: 'Barlow Condensed', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

*{ box-sizing: border-box; }
html,body{ padding:0; margin:0; }
body{
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4{
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .01em;
  margin: 0 0 4px 0;
  color: var(--steel-dark);
}
.mono{ font-family: var(--font-mono); }
a{ color: var(--steel); }

/* ---------- hazard stripe (elemento de firma visual) ---------- */
.hazard-stripe{
  height: 8px;
  width: 100%;
  background: repeating-linear-gradient(
    -45deg,
    var(--yellow) 0 14px,
    var(--ink) 14px 28px
  );
  border-radius: 999px;
}
.hazard-stripe.thin{ height: 5px; }

/* ---------- shell / topbar ---------- */
.app-shell{ min-height: 100vh; display:flex; flex-direction:column; }
.topbar{
  background: var(--steel-dark);
  color: #fff;
  padding: 14px 20px;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
}
.topbar .brand{
  display:flex; align-items:center; gap:10px;
  font-family: var(--font-display);
  font-size: 22px; font-weight:800; letter-spacing:.02em; text-transform:uppercase;
  color:#fff;
}
.topbar .brand .tag{
  font-family: var(--font-mono);
  font-size: 11px; font-weight:600; letter-spacing:.08em;
  color: var(--yellow); text-transform:uppercase;
  border:1px solid rgba(242,183,5,.5); border-radius:4px; padding:2px 6px;
}
.topbar .role-badge{
  font-family: var(--font-mono); font-size:12px; letter-spacing:.04em;
  background: rgba(255,255,255,.1); padding:5px 10px; border-radius:6px;
}
main.container{
  flex:1; width:100%; max-width: 880px; margin:0 auto; padding: 22px 16px 80px;
}

/* ---------- landing (selector de rol) ---------- */
.landing-hero{
  text-align:center; padding: 48px 16px 12px;
}
.landing-hero h1{ font-size: 42px; color:var(--ink); }
.landing-hero p{ color: var(--ink-soft); max-width:520px; margin: 10px auto 0; }
.role-grid{
  display:grid; grid-template-columns: 1fr 1fr; gap:18px; margin-top:32px;
}
@media (max-width: 640px){ .role-grid{ grid-template-columns: 1fr; } }
.role-card{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius);
  padding: 26px 22px; text-decoration:none; color:var(--ink); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
  display:flex; flex-direction:column; gap:10px;
}
.role-card:hover{ transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.role-card .icon{ font-size:30px; }
.role-card h3{ font-size:24px; }
.role-card p{ color:var(--ink-soft); font-size:14px; margin:0; }
.role-card .cta{
  margin-top:8px; font-family:var(--font-mono); font-size:12px; font-weight:600;
  color: var(--steel); letter-spacing:.04em; text-transform:uppercase;
}

/* ---------- step cards ---------- */
.step-card{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 18px; box-shadow: var(--shadow); overflow:hidden;
}
.step-head{
  display:flex; align-items:center; gap:12px; padding: 16px 20px; background: var(--surface-2);
  border-bottom:1px solid var(--border);
}
.step-num{
  font-family: var(--font-mono); font-weight:700; font-size:14px;
  background: var(--steel-dark); color:#fff; width:28px; height:28px; border-radius:6px;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.step-head h3{ font-size:20px; margin:0; }
.step-head .sub{ font-size:12.5px; color:var(--ink-soft); font-family: var(--font-body); }
.step-body{ padding: 18px 20px 22px; }

/* ---------- form elements ---------- */
.field{ margin-bottom: 14px; }
.field label{
  display:block; font-size:12.5px; font-weight:600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing:.03em; margin-bottom:5px;
}
.field .hint{ font-size:12px; color:#8a8378; margin-top:4px; }
input[type=text], input[type=number], input[type=date], select, textarea{
  width:100%; padding: 10px 12px; border:1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size:14.5px; background:#fff; color:var(--ink);
}
input[type=number]{ font-family: var(--font-mono); }
textarea{ resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus{
  outline: none; border-color: var(--steel); box-shadow: 0 0 0 3px var(--steel-light);
}
.row{ display:grid; grid-template-columns: repeat(2, 1fr); gap:14px; }
.row.cols-3{ grid-template-columns: repeat(3, 1fr); }
@media (max-width:640px){ .row, .row.cols-3{ grid-template-columns: 1fr; } }

/* ---------- buttons ---------- */
.btn{
  font-family: var(--font-body); font-weight:600; font-size:14px;
  padding: 11px 18px; border-radius: var(--radius-sm); border:none; cursor:pointer;
  display:inline-flex; align-items:center; gap:8px; transition: filter .15s ease, transform .1s ease;
}
.btn:active{ transform: scale(.98); }
.btn:hover{ filter: brightness(1.06); }
.btn-primary{ background: var(--steel); color:#fff; }
.btn-primary:hover{ background: var(--steel-dark); }
.btn-yellow{ background: var(--yellow); color: var(--ink); }
.btn-outline{ background:#fff; color:var(--steel); border:1px solid var(--steel); }
.btn-ghost{ background: transparent; color: var(--ink-soft); border:1px solid var(--border); }
.btn-danger{ background: var(--danger); color:#fff; }
.btn-block{ width:100%; justify-content:center; }
.btn-lg{ padding:14px 22px; font-size:15.5px; }
.btn:disabled{ opacity:.5; cursor:not-allowed; }

/* ---------- geolocation result boxes ---------- */
.geo-box{
  border:1px dashed var(--border); border-radius: var(--radius-sm); padding:14px;
  margin-top:10px; font-size:13.5px; background: var(--bg);
}
.geo-box.ok{ border-color: var(--success); background: var(--success-light); }
.geo-box.warn{ border-color: var(--yellow-dark); background: var(--warn-light); }
.geo-box.danger{ border-color: var(--danger); background: var(--danger-light); }
.geo-box .geo-title{ font-weight:700; margin-bottom:4px; display:flex; align-items:center; gap:6px; }
.geo-grid{ display:grid; grid-template-columns: repeat(2,1fr); gap:6px 16px; margin-top:8px; }
.geo-grid div span.k{ color: var(--ink-soft); font-size:12px; display:block; }
.geo-grid div span.v{ font-family: var(--font-mono); font-weight:600; }

/* ---------- gauge (signature element) ---------- */
.gauge-wrap{ display:flex; flex-direction:column; align-items:center; gap:4px; width:100%; max-width:300px; }
.gauge-wrap svg{ width:100%; height:auto; overflow:visible; }
.gauge-value{ font-family: var(--font-mono); font-size:32px; font-weight:700; margin-top:-30px; line-height:1; }
.gauge-row{ display:flex; flex-wrap:wrap; gap:20px; align-items:center; justify-content:center; }
.gauge-label{
  font-family: var(--font-display); text-transform:uppercase; letter-spacing:.05em;
  font-size:18px; padding:4px 14px; border-radius:999px; margin-top:4px;
}
.gauge-label.normal{ background:var(--success-light); color:var(--success); }
.gauge-label.precaucion{ background:var(--warn-light); color:var(--yellow-dark); }
.gauge-label.critico{ background:#FCE8D6; color:var(--orange); }
.gauge-label.prohibido{ background:var(--danger-light); color:var(--danger); }

/* ---------- result tables / lists ---------- */
.result-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:16px; margin-top:16px; }
@media (max-width:640px){ .result-grid{ grid-template-columns:1fr; } }
.result-block{ background: var(--bg); border:1px solid var(--border); border-radius: var(--radius-sm); padding:14px 16px; }
.result-block h4{ font-size:15px; margin-bottom:8px; color: var(--ink); }
.kv{ display:flex; justify-content:space-between; padding:5px 0; border-bottom:1px dotted var(--border); font-size:13.5px; }
.kv:last-child{ border-bottom:none; }
.kv .k{ color: var(--ink-soft); }
.kv .v{ font-family: var(--font-mono); font-weight:600; }
ul.precaucion-list{ margin:8px 0 0; padding-left:20px; }
ul.precaucion-list li{ margin-bottom:6px; font-size:13.5px; }

.badge{
  display:inline-flex; align-items:center; gap:5px; font-family:var(--font-mono);
  font-size:11.5px; font-weight:600; padding:3px 9px; border-radius:999px; letter-spacing:.03em;
  text-transform:uppercase;
}
.badge.normal{ background: var(--success-light); color:var(--success); }
.badge.precaucion{ background: var(--warn-light); color:var(--yellow-dark); }
.badge.critico{ background:#FCE8D6; color:var(--orange); }
.badge.prohibido{ background: var(--danger-light); color:var(--danger); }
.badge.pendiente{ background: var(--steel-light); color:var(--steel-dark); }
.badge.aprobado{ background: var(--success-light); color:var(--success); }

/* ---------- toast / alerts ---------- */
.alert{ padding:12px 14px; border-radius: var(--radius-sm); font-size:13.5px; margin-bottom:14px; }
.alert-danger{ background: var(--danger-light); color:var(--danger); border:1px solid #f0b8ba; }
.alert-info{ background: var(--steel-light); color:var(--steel-dark); border:1px solid #b9d2dc; }

/* ---------- plan list (receptor) ---------- */
.plan-item{
  background:#fff; border:1px solid var(--border); border-radius: var(--radius); padding:16px 18px;
  margin-bottom:12px; box-shadow: var(--shadow); display:flex; justify-content:space-between; align-items:center;
  gap:12px; text-decoration:none; color:var(--ink); cursor:pointer;
}
.plan-item:hover{ border-color: var(--steel); }
.plan-item .info h4{ font-size:18px; }
.plan-item .info .meta{ font-size:12.5px; color:var(--ink-soft); font-family: var(--font-mono); }
.plan-item .right{ text-align:right; display:flex; flex-direction:column; align-items:flex-end; gap:6px; }

.sig-progress{ display:flex; gap:6px; }
.sig-dot{
  width:9px; height:9px; border-radius:50%; background: var(--border);
}
.sig-dot.done{ background: var(--success); }

footer.app-footer{
  text-align:center; padding:16px; font-size:11.5px; color:#9a9284; font-family: var(--font-mono);
}

.empty-state{ text-align:center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state .icon{ font-size:40px; margin-bottom:10px; }

#map{ height: 280px; border-radius: var(--radius-sm); border:1px solid var(--border); margin-top:10px; }

.sig-pad-wrap{ border:1px dashed var(--border); border-radius: var(--radius-sm); background:#fff; }
canvas#sigCanvas{ width:100%; height:160px; display:block; touch-action:none; border-radius: var(--radius-sm); }

.spinner{
  width:16px; height:16px; border:2px solid rgba(255,255,255,.4); border-top-color:#fff;
  border-radius:50%; display:inline-block; animation: spin .7s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

.back-link{ display:inline-flex; align-items:center; gap:6px; color: var(--steel); text-decoration:none; font-size:13.5px; font-weight:600; margin-bottom:14px; }

/* ---------- notificaciones ---------- */
.notif-badge{
  position:absolute; top:-6px; right:-6px; background: var(--danger); color:#fff;
  font-family: var(--font-mono); font-size:10.5px; font-weight:700; min-width:17px; height:17px;
  border-radius:999px; display:flex; align-items:center; justify-content:center; padding:0 4px;
}
.notif-item{
  background:#fff; border:1px solid var(--border); border-radius: var(--radius); padding:16px 18px;
  margin-bottom:12px; box-shadow: var(--shadow); display:flex; justify-content:space-between; align-items:center; gap:12px;
}
.notif-item.recien-aprobado{ border-color: var(--success); background: var(--success-light); animation: pulse-borde 1.6s ease-in-out 2; }
@keyframes pulse-borde{ 0%,100%{ box-shadow:0 0 0 0 rgba(60,140,92,.4);} 50%{ box-shadow:0 0 0 6px rgba(60,140,92,0);} }
.notif-item .info h4{ font-size:17px; margin-bottom:2px; }
.notif-item .info .meta{ font-size:12px; color:var(--ink-soft); font-family: var(--font-mono); }

/* ---------- fotos ---------- */
.foto-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:16px; }
@media (max-width:640px){ .foto-grid{ grid-template-columns: 1fr; } }
.foto-slot{
  border:2px dashed var(--border); border-radius: var(--radius-sm); background: var(--bg);
  aspect-ratio: 4/3; display:flex; align-items:center; justify-content:center; flex-direction:column;
  gap:8px; cursor:pointer; overflow:hidden; position:relative; color: var(--ink-soft); text-align:center; padding:10px;
}
.foto-slot:hover{ border-color: var(--steel); }
.foto-slot img{ width:100%; height:100%; object-fit:cover; position:absolute; inset:0; }
.foto-slot .foto-label{ font-size:12.5px; font-weight:600; }
.foto-slot .foto-remove{
  position:absolute; top:6px; right:6px; background: rgba(28,33,38,.75); color:#fff; border:none;
  border-radius:6px; width:26px; height:26px; font-size:14px; cursor:pointer; z-index:2;
}
.foto-detalle{ width:100%; border-radius: var(--radius-sm); border:1px solid var(--border); }


/* ===== Logo de marca ===== */
.brand-logo{ width:26px; height:26px; vertical-align:middle; border-radius:6px; margin-right:2px; }

/* ===== Configuración de firmantes ===== */
.chk-rol-grid{ display:flex; flex-wrap:wrap; gap:10px; }
.chk-rol{
  display:flex; align-items:center; gap:8px; cursor:pointer;
  border:2px solid var(--line); border-radius:10px; padding:10px 14px;
  background:#fff; font-weight:600; font-size:14px; flex:1; min-width:150px;
}
.chk-rol:has(input:checked){ border-color:var(--steel); background:var(--warn-light); }
.chk-rol input{ width:18px; height:18px; accent-color:var(--steel); }

/* ===== Aviso de plan aprobado (rigger) ===== */
.toast-aprobado{
  position:fixed; left:50%; transform:translateX(-50%); bottom:22px; z-index:9999;
  background:#DCFCE7; color:#14532D; border:2px solid #16A34A;
  border-radius:12px; padding:14px 20px; font-weight:700; font-size:14px;
  box-shadow:0 10px 30px rgba(0,0,0,.22); max-width:92vw; text-align:center;
  animation: subirToast .35s ease-out, pulsoToast 1.6s ease-in-out 3;
}
@keyframes subirToast{ from{ opacity:0; transform:translate(-50%, 20px);} to{ opacity:1; transform:translate(-50%,0);} }
@keyframes pulsoToast{ 0%,100%{ box-shadow:0 10px 30px rgba(0,0,0,.22);} 50%{ box-shadow:0 0 0 8px rgba(22,163,74,.25);} }

/* ===== Acceso a la Guía del Rigger ===== */
.manual-card{
  display:flex; align-items:center; gap:16px; text-decoration:none;
  background:#1C2126; color:#F1EDE4; border-radius:14px;
  padding:18px 20px; margin-top:18px;
  border:1px solid #333A42; transition:transform .12s ease, box-shadow .12s ease;
}
.manual-card:active{ transform:scale(.99); }
.manual-card .manual-icon{ font-size:30px; flex-shrink:0; }
.manual-card .manual-text{ flex:1; min-width:0; }
.manual-card h3{ margin:0 0 4px; font-size:16px; color:#F2B705; }
.manual-card p{ margin:0; font-size:13px; line-height:1.45; color:#A8B0B9; }
.manual-card .manual-arrow{ font-size:20px; color:#F2B705; flex-shrink:0; }

.link-guia{
  color:var(--steel); font-weight:600; text-decoration:underline;
  text-underline-offset:2px; white-space:nowrap;
}

/* ===== Barra superior con sesión iniciada (pantallas angostas) ===== */
.topbar{ flex-wrap: nowrap; }
#chipUsuario{ min-width:0; }
#chipUsuario .chip-nombre{
  display:block; font-weight:700; line-height:1.2;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:38vw;
}
#chipUsuario .chip-roles{
  display:block; opacity:.7; line-height:1.2; font-size:11px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:38vw;
}
@media (max-width: 560px){
  .topbar{ padding:10px 12px; gap:8px; }
  .topbar .brand{ font-size:18px; }
  /* El rótulo "PLAN DE IZAJE" se parte en varias líneas y rompe la barra */
  .topbar .brand .tag{ display:none; }
  .brand-logo{ width:22px; height:22px; }
  #chipUsuario{ gap:7px; font-size:11px; }
}

/* Ojo para mostrar u ocultar la contraseña (login) */
.clave-wrap{ position:relative; }
.clave-wrap input{ width:100%; padding-right:48px; }
.btn-ojo{ position:absolute; top:50%; right:4px; transform:translateY(-50%);
  width:40px; height:40px; display:flex; align-items:center; justify-content:center;
  background:none; border:0; border-radius:8px; color:inherit; opacity:.7; cursor:pointer; padding:0; }
.btn-ojo:hover, .btn-ojo:focus-visible{ opacity:1; }
.btn-ojo:focus-visible{ outline:2px solid currentColor; outline-offset:1px; }
.btn-ojo svg{ width:22px; height:22px; }
