:root {
  --bg: #14181C;
  --surface: #1E242B;
  --surface-raised: #262E36;
  --border: #2E3841;
  --text: #EDEFF2;
  --text-dim: #8B96A3;
  --amber: #F2A93B;
  --amber-dim: #7A5A22;
  --green: #4CAF6D;
  --red: #E5544B;
  --font-ui: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ---------- Encabezado ---------- */
.topbar {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; }
.topbar .status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  display: inline-block; margin-right: 6px;
}
.topbar .status-dot.offline { background: var(--red); }
.topbar .status { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; }

/* ---------- Listado de tickets ---------- */
.ticket-list { padding: 12px 16px 90px; flex: 1; overflow-y: auto; }
.ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
}
.ticket-card:active { background: var(--surface-raised); }
.ticket-card .row1 { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.ticket-card .folio { font-family: var(--font-mono); font-size: 13px; color: var(--text-dim); }
.ticket-card .prioridad {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600;
}
.prioridad.urgente { background: rgba(229,84,75,0.18); color: var(--red); }
.prioridad.alta { background: rgba(242,169,59,0.18); color: var(--amber); }
.prioridad.media, .prioridad.baja { background: rgba(139,150,163,0.15); color: var(--text-dim); }
.ticket-card .cliente { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.ticket-card .equipo { font-size: 13px; color: var(--text-dim); }
.ticket-card .estado-pill {
  margin-top: 8px; display: inline-block; font-size: 12px; color: var(--amber);
  border: 1px solid var(--amber-dim); padding: 3px 10px; border-radius: 20px;
}

/* ---------- Barra de progreso de pasos ---------- */
.progress-bar { display: flex; gap: 4px; padding: 12px 16px 0; }
.progress-bar .seg { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.progress-bar .seg.done { background: var(--amber); }
.step-label { padding: 6px 20px 14px; font-size: 13px; color: var(--text-dim); }

/* ---------- Contenido de pasos ---------- */
.step-content { flex: 1; overflow-y: auto; padding: 4px 20px 100px; }
.step-content h2 { font-size: 19px; margin: 4px 0 6px; }
.step-content .hint { font-size: 13px; color: var(--text-dim); margin-bottom: 16px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field textarea, .field input[type="text"] {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 15px;
  font-family: var(--font-ui);
}
.field textarea { min-height: 80px; resize: vertical; }

/* Checklist / pruebas */
.check-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; margin-bottom: 8px;
}
.check-item .desc { font-size: 14px; flex: 1; padding-right: 10px; }
.toggle {
  width: 46px; height: 28px; border-radius: 20px; background: var(--border);
  position: relative; flex-shrink: 0; border: none;
}
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--text-dim); transition: 0.15s;
}
.toggle.on { background: var(--amber-dim); }
.toggle.on::after { left: 21px; background: var(--amber); }

.test-item .result-buttons { display: flex; gap: 8px; margin-top: 8px; }
.result-btn {
  flex: 1; padding: 9px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); font-size: 13px; font-weight: 600;
}
.result-btn.pass.active { background: rgba(76,175,109,0.18); border-color: var(--green); color: var(--green); }
.result-btn.fail.active { background: rgba(229,84,75,0.18); border-color: var(--red); color: var(--red); }

/* Fotos */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.photo-thumb {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden; position: relative;
  background: var(--surface); border: 1px solid var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .remove {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(20,24,28,0.8); color: var(--text); border: none; font-size: 13px; line-height: 1;
}
.add-photo-btn {
  aspect-ratio: 1; border-radius: 8px; border: 1px dashed var(--border);
  background: transparent; color: var(--text-dim); font-size: 28px; font-weight: 300;
  display: flex; align-items: center; justify-content: center;
}

/* Firma */
.sig-pad-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
canvas#sigPad { width: 100%; height: 160px; display: block; touch-action: none; background: #fff; }
.sig-name { margin-top: 10px; }

/* Check-in destacado */
.checkin-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; text-align: center; margin-bottom: 16px;
}
.checkin-box .coords { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.checkin-box .time { font-size: 22px; font-weight: 700; margin-top: 4px; }

/* ---------- Barra inferior de acciones ---------- */
.bottom-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  display: flex; gap: 10px;
}
.btn {
  flex: 1; padding: 15px; border-radius: 10px; border: none; font-size: 15px; font-weight: 600;
  font-family: var(--font-ui);
}
.btn-primary { background: var(--amber); color: #221a0c; }
.btn-primary:disabled { background: var(--surface-raised); color: var(--text-dim); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); flex: 0 0 88px; }

/* Header de paso con volver */
.step-header {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px 0;
}
.back-btn {
  background: none; border: none; color: var(--text-dim); font-size: 22px; padding: 4px 8px 4px 0;
}
.step-header .folio-tag { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }

.empty-state { text-align: center; padding: 60px 30px; color: var(--text-dim); }
.empty-state .big { font-size: 40px; margin-bottom: 10px; }

.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  background: var(--surface-raised); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 30px; font-size: 13px; z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.toast.show { opacity: 1; }