:root{
  --navy:#12332f;
  --blue:#2a9d8f;
  --line:#d7e5df;
  --text:#102421;
  --muted:#62756f;
  --danger:#b00020;
  --bg:#f5f8f3;
}

*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  padding:0;
  width:100%;
  min-height:100%;
  font-family:Arial,Helvetica,sans-serif;
  background:var(--bg);
  color:var(--text);
  overflow-x:hidden;
}

.hidden{
  display:none !important;
}

/* LOGIN */

.login{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  background:radial-gradient(circle,#fff,#eaf5ef);
}

.login-card{
  width:360px;
  max-width:95%;
  background:#fff;
  border:1px solid var(--line);
  border-radius:18px;
  padding:24px;
  text-align:center;
  box-shadow:0 15px 40px rgba(0,0,0,.12);
}

.login-card img{
  width:180px;
  max-width:100%;
  height:auto;
  display:block;
  margin:auto;
}

.login-card h1{
  font-size:24px;
  margin:10px 0;
}

.login-card small{
  color:var(--danger);
  font-weight:bold;
}

/* INPUTS */

input,
textarea,
select{
  width:100%;
  padding:8px;
  border:1px solid var(--line);
  border-radius:8px;
  font-size:13px;
  background:#fff;
  font-family:inherit;
}

textarea{
  min-height:90px;
  resize:vertical;
}

input:focus,
textarea:focus,
select:focus{
  outline:none;
  border-color:var(--blue);
  box-shadow:0 0 0 3px rgba(42,157,143,.14);
}

/* BOTONES */

button{
  border:0;
  background:linear-gradient(135deg,var(--navy),var(--blue));
  color:white;
  font-weight:700;
  padding:8px 12px;
  border-radius:8px;
  cursor:pointer;
  margin:3px;
  font-size:13px;
}

button.secondary{
  background:#fff;
  color:var(--blue);
  border:1px solid var(--blue);
}

button.danger{
  background:#fff;
  color:var(--danger);
  border:1px solid var(--danger);
}

button:hover{
  opacity:.92;
}

/* CONTENEDOR */

main{
  max-width:1150px;
  margin:auto;
  padding:14px;
}

/* MENU */

nav{
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px 14px;
  margin-bottom:12px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  box-shadow:0 8px 20px rgba(0,0,0,.05);
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
}

.brand img{
  width:65px;
  height:auto;
}

.brand b{
  display:block;
}

.brand span{
  display:block;
  color:var(--muted);
  font-size:12px;
}

.nav-actions{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:4px;
}

/* ENCABEZADO */

.header{
  display:grid;
  grid-template-columns:minmax(0,1fr) 300px;
  gap:12px;
  margin-bottom:12px;
}

.company,
.quote-box,
.card,
.totals{
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  box-shadow:0 8px 20px rgba(0,0,0,.04);
}

.company img{
  width:140px;
  max-width:100%;
  height:auto;
  display:block;
  margin-bottom:8px;
}

.company h2{
  margin:0 0 6px;
  font-size:18px;
}

.company p{
  margin:3px 0;
  font-size:13px;
}

.quote-box h1{
  text-align:center;
  color:var(--navy);
  font-size:24px;
  margin:0 0 10px;
}

/* LABELS */

label{
  font-weight:700;
  display:block;
  margin:6px 0 3px;
  font-size:13px;
}

/* GRID */

.grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}

/* TITULOS */

h3{
  background:linear-gradient(135deg,var(--navy),var(--blue));
  color:white;
  padding:9px;
  border-radius:8px;
  margin:0 0 10px;
  text-transform:uppercase;
  font-size:13px;
}

/* TABLAS */

.table-wrap{
  width:100%;
  overflow-x:auto;
}

table{
  width:100%;
  border-collapse:collapse;
}

th{
  background:linear-gradient(135deg,var(--navy),var(--blue));
  color:white;
  padding:7px;
  font-size:12px;
  white-space:nowrap;
}

td{
  border:1px solid var(--line);
  padding:5px;
  font-size:12px;
  text-align:center;
}

td:nth-child(2){
  text-align:left;
}

td input{
  border:0;
  background:transparent;
  width:100%;
  font-size:12px;
}

td:nth-child(2) input{
  min-width:140px;
}

/* SECCION INFERIOR */

.bottom{
  display:grid;
  grid-template-columns:1.3fr .7fr;
  gap:12px;
}

.totals p{
  display:flex;
  justify-content:space-between;
  border-bottom:1px solid var(--line);
  padding:9px;
  margin:0;
  font-size:13px;
  font-weight:700;
}

.totals .total{
  background:linear-gradient(135deg,var(--navy),var(--blue));
  color:white;
  border-radius:10px;
  font-size:16px;
  margin-top:8px;
}

.totals button{
  width:100%;
}

/* HISTORIAL */

.history-tools{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  margin-bottom:10px;
}

/* ASISTENCIA TECNICA */

.note{
  font-size:13px;
  color:var(--muted);
  margin:10px 0 0;
}

.signature-canvas{
  width:100%;
  height:180px;
  background:#fff;
  border:2px dashed #c8d3e1;
  border-radius:10px;
  display:block;
  margin:8px 0;
}

.tech-signature{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  margin-bottom:10px;
  background:#f7fbf8;
}

.tech-signature .grid{
  margin-bottom:8px;
}

.service-actions{
  margin-top:12px;
}

#serviceView .card{
  margin-bottom:12px;
}

#serviceView input[type="file"]{
  padding:10px;
  background:#fbfdfb;
}

/* PREVISUALIZACION DE FOTOS Y ADJUNTOS */

.file-preview{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:8px;
}

.file-thumb{
  width:90px;
  text-align:center;
  font-size:10px;
  color:var(--muted);
}

.file-thumb img{
  width:90px;
  height:70px;
  object-fit:cover;
  border-radius:6px;
  border:1px solid var(--line);
  display:block;
  margin-bottom:3px;
  background:#fff;
}

.file-thumb-doc{
  width:90px;
  height:70px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--bg);
  border:1px solid var(--line);
  border-radius:6px;
  font-weight:700;
  color:var(--blue);
  margin-bottom:3px;
}

.file-thumb span{
  display:block;
  word-break:break-all;
  line-height:1.3;
}

/* ===========================================
   FIRMA.HTML - Vista de solo lectura para el
   cliente que firma la recepción del servicio.
=========================================== */

.view-box{
  width:100%;
  min-height:40px;
  padding:9px 12px;
  margin-bottom:10px;
  border-radius:8px;
  background:#f3f5f9;
  border:1px solid var(--line);
  color:var(--ink);
  font-size:14px;
  display:flex;
  align-items:center;
}

.view-box-text{
  min-height:70px;
  align-items:flex-start;
  white-space:pre-wrap;
}

.view-box-folio{
  justify-content:center;
  font-size:20px;
  font-weight:900;
  color:#e53935;
  background:#fff8f8;
  border:2px solid #f3c8c6;
}

.firma-fotos .file-thumb{
  width:140px;
}

.firma-fotos .file-thumb img{
  width:140px;
  height:110px;
  cursor:zoom-in;
}

.signature-wrap{
  position:relative;
}

.signature-overlay{
  position:absolute;
  top:0;
  right:0;
  bottom:0;
  left:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:10px;
  border-radius:10px;
  background:rgba(255,255,255,.88);
  color:var(--muted);
  font-weight:700;
  cursor:pointer;
  -webkit-tap-highlight-color: transparent;
}

.signature-overlay.signature-locked{
  background:rgba(232,251,240,.92);
  color:#178a44;
  cursor:default;
}

.lock-signature-btn{
  width:100%;
  margin-top:8px;
  margin-bottom:6px;
  background:#fff;
  color:#178a44;
  border:1px solid #b9efce;
}

.lock-signature-btn:disabled{
  background:#e3f8ec;
  color:#1da851;
  cursor:default;
  opacity:1;
}

/* Etiquetas de estado en el historial de asistencias */

.estado-badge{
  display:inline-block;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  white-space:nowrap;
}

.estado-ok{
  background:#e3f8ec;
  color:#1da851;
  border:1px solid #b9efce;
}

.estado-pendiente{
  background:#fdecec;
  color:#e53935;
  border:1px solid #f5c2c2;
}

/* ===========================================
   ASISTENCIA TÉCNICA - DISEÑO DIFERENCIADO
   Más moderno y "elegante" que el cotizador,
   con un acento color teal, tarjetas numeradas,
   bordes redondeados y un folio destacado en
   rojo (similar a un ticket de servicio).
=========================================== */

#serviceView{
  --service-accent:#0f9d8f;
  --service-accent-dark:#0a7c70;
  --service-bg:#f3fbfa;
  counter-reset: stepCounter;
}

#serviceView .header{
  background:var(--service-bg);
  border-radius:18px;
  padding:6px;
}

#serviceView .company,
#serviceView .quote-box{
  border-radius:18px;
}

/* Folio de asistencia como "ticket" destacado en rojo */

#serviceView .quote-box{
  border:2px solid #e53935;
  text-align:center;
}

#serviceView .quote-box h1{
  color:#e53935;
  background:none;
  font-size:13px;
  letter-spacing:2px;
  margin-bottom:8px;
}

#serviceView .quote-box label{
  text-align:left;
}

#serviceView #serviceFolio{
  text-align:center;
  font-size:20px;
  font-weight:900;
  color:#e53935;
  border:2px solid #f3c8c6;
  background:#fff8f8;
}

#serviceView .card{
  border-radius:18px;
  border:1px solid #dff3f0;
  box-shadow:0 10px 26px rgba(15,157,143,.08);
  transition:box-shadow .2s ease, transform .2s ease;
}

#serviceView .card:hover{
  box-shadow:0 14px 32px rgba(15,157,143,.14);
}

/* Encabezados de tarjeta numerados, estilo "pasos" de un dashboard */

#serviceView .card > h3{
  background:linear-gradient(135deg,var(--service-accent-dark),var(--service-accent));
  border-radius:12px;
  letter-spacing:.6px;
  display:flex;
  align-items:center;
  gap:8px;
  counter-increment: stepCounter;
}

#serviceView .card > h3::before{
  content: counter(stepCounter);
  display:flex;
  align-items:center;
  justify-content:center;
  width:22px;
  height:22px;
  min-width:22px;
  border-radius:50%;
  background:#fff;
  color:var(--service-accent-dark);
  font-size:12px;
  font-weight:900;
}

#serviceView .tech-signature{
  border-radius:14px;
  background:#f6fffd;
  border:1px solid #dff3f0;
}

/* Tarjeta de envío por WhatsApp: tema verde WhatsApp */

.whatsapp-card{
  background:linear-gradient(165deg,#e8fbf0,#ffffff) !important;
  border:1px solid #b9efce !important;
}

.whatsapp-card > h3{
  background:linear-gradient(135deg,#1da851,#25d366) !important;
}

.whatsapp-btn{
  width:100% !important;
  margin-top:10px;
  background:linear-gradient(135deg,#1da851,#25d366) !important;
  border:0 !important;
  color:#fff !important;
}

.whatsapp-btn:hover{
  opacity:.92;
}

/* Campo de teléfono con prefijo fijo +56 9 */

.phone-input-group{
  display:flex;
  align-items:stretch;
  border:1px solid var(--line);
  border-radius:8px;
  overflow:hidden;
  background:#fff;
}

.phone-prefix{
  display:flex;
  align-items:center;
  padding:0 10px;
  background:#e8fbf0;
  color:#178a44;
  font-weight:700;
  font-size:13px;
  border-right:1px solid #b9efce;
  white-space:nowrap;
}

.phone-input-group input{
  border:0;
  border-radius:0;
}

.phone-input-group input:focus{
  outline:none;
  box-shadow:none;
}


/* RESPONSIVE */

@media(max-width:1000px){

  .header{
    grid-template-columns:1fr;
  }

  .bottom{
    grid-template-columns:1fr;
  }

  .grid{
    grid-template-columns:1fr;
  }

  nav{
    flex-direction:column;
    align-items:flex-start;
  }

  .nav-actions{
    width:100%;
    justify-content:flex-start;
  }

  .history-tools{
    grid-template-columns:1fr;
  }
}

@media(max-width:768px){

  main{
    padding:10px;
  }

  .company img{
    width:120px;
  }

  .quote-box h1{
    font-size:20px;
  }

  button{
    width:100%;
  }

  .nav-actions{
    display:grid;
    grid-template-columns:1fr;
    width:100%;
  }
}
