:root {
  --marca: #E4572E;
  --marca-osc: #b9401c;
  --fondo: #f4f3f1;
  --tarjeta: #ffffff;
  --texto: #1c1917;
  --suave: #6b6560;
  --borde: #e4e1dc;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --alerta: #b45309;
  --alerta-bg: #fef3c7;
  --error: #b91c1c;
  --error-bg: #fee2e2;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --morado: #6d28d9;
  --morado-bg: #ede9fe;
  --radio: 14px;
  font-size: 17px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.4; }
body { padding-bottom: env(safe-area-inset-bottom); }

/* Barra superior */
#barra { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px;
  background: var(--marca); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
  min-height: 56px; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
#titulo { flex: 1; font-weight: 700; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 6px; }
#barra button { background: rgba(255,255,255,.18); color: #fff; border: 0; width: 44px; height: 40px;
  border-radius: 10px; font-size: 26px; line-height: 1; cursor: pointer; }
#vista { max-width: 680px; margin: 0 auto; padding: 14px 14px 90px; }

/* Bloques */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; margin-bottom: 12px; }
.tarjeta h3 { margin: 0 0 10px; font-size: 17px; }
.seccion { font-size: 14px; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; margin: 18px 4px 8px; }
.fila { display: flex; gap: 10px; align-items: center; }
.fila > .crece { flex: 1; min-width: 0; }
.entre { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.suave { color: var(--suave); font-size: 15px; }
.peq { font-size: 14px; }
.centro { text-align: center; }
.vacio { text-align: center; color: var(--suave); padding: 30px 10px; }
hr { border: 0; border-top: 1px solid var(--borde); margin: 12px 0; }

/* Inicio */
.saludo { font-size: 22px; font-weight: 700; margin: 6px 4px 14px; }
.cuadros { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cuadro { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 118px; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 18px; padding: 14px 8px;
  text-decoration: none; color: var(--texto); font-weight: 700; font-size: 17px; text-align: center; }
.cuadro .ico { font-size: 38px; line-height: 1; }
.cuadro.principal { grid-column: 1 / -1; background: var(--marca); color: #fff; border-color: var(--marca); min-height: 96px; flex-direction: row; font-size: 21px; }
.cuadro .globo { position: absolute; top: 8px; right: 10px; background: var(--error); color: #fff; border-radius: 99px; min-width: 26px; height: 26px; padding: 0 7px; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.cuadro.principal .globo { background: #fff; color: var(--marca); }

/* Botones */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; padding: 12px 16px;
  border-radius: 14px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto);
  font-size: 18px; font-weight: 700; cursor: pointer; text-decoration: none; font-family: inherit; }
.btn + .btn, .btn + .fila, .fila + .btn { margin-top: 10px; }
.btn.primario { background: var(--marca); border-color: var(--marca); color: #fff; }
.btn.verde { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn.whatsapp { background: #25D366; border-color: #25D366; color: #073b1d; }
.btn.peligro { color: var(--error); border-color: #fca5a5; }
.btn.chico { min-height: 42px; font-size: 16px; padding: 8px 12px; width: auto; }
.btn:disabled { opacity: .55; }
.enlace { background: none; border: 0; color: var(--marca-osc); font-weight: 700; font-size: 16px; padding: 6px; cursor: pointer; font-family: inherit; }

/* Formularios */
label.campo { display: block; margin-bottom: 12px; }
label.campo > span { display: block; font-size: 15px; font-weight: 600; color: var(--suave); margin-bottom: 4px; }
input, select, textarea { width: 100%; font-size: 18px; padding: 12px; border: 1px solid #cfcac3; border-radius: 12px;
  background: #fff; color: var(--texto); font-family: inherit; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--marca) 30%, transparent); border-color: var(--marca); }
input.placa { text-transform: uppercase; font-size: 26px; font-weight: 800; letter-spacing: 2px; text-align: center; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dos > .btn { margin-top: 0 !important; width: 100%; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid #cfcac3; background: #fff; border-radius: 99px; padding: 9px 14px; font-size: 16px; font-weight: 600;
  cursor: pointer; color: var(--texto); font-family: inherit; }
.chip.si { background: var(--marca); border-color: var(--marca); color: #fff; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.chips.scroll .chip { white-space: nowrap; }

/* Estados */
.estado { display: inline-block; border-radius: 8px; padding: 3px 9px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.e-recibida, .e-solicitado { background: #eeece9; color: #44403c; }
.e-diagnostico, .e-cotizado { background: var(--info-bg); color: var(--info); }
.e-esperando_aprobacion, .e-pedido { background: var(--morado-bg); color: var(--morado); }
.e-esperando_repuesto, .e-en_camino { background: var(--alerta-bg); color: var(--alerta); }
.e-en_reparacion { background: #ffedd5; color: #c2410c; }
.e-lista, .e-recibido { background: var(--ok-bg); color: var(--ok); }
.e-entregada { background: #e7e5e4; color: #57534e; }
.e-cancelada, .e-cancelado { background: var(--error-bg); color: var(--error); }
.marca-roja { background: var(--error-bg); color: var(--error); }
.marca-amarilla { background: var(--alerta-bg); color: var(--alerta); }

/* Motos en lista */
.moto { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.moto img, .moto .sinfoto { width: 74px; height: 74px; border-radius: 12px; object-fit: cover; background: #eeece9; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 30px; }
.placa-txt { font-size: 21px; font-weight: 800; letter-spacing: 1px; }

/* Fotos */
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.foto { position: relative; aspect-ratio: 1; border: 2px dashed #cfcac3; border-radius: 14px; background: #fff; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px; overflow: hidden; cursor: pointer; font-weight: 700; font-size: 15px; }
.foto img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.foto .etq { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; padding: 3px; text-align: center; }
.foto.lista { border: 2px solid #16a34a; }
.foto .check { position: absolute; top: 6px; right: 6px; background: #16a34a; color: #fff; border-radius: 99px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 15px; z-index: 2; }
.foto input { display: none; }
.foto.subiendo::after { content: "Subiendo…"; position: absolute; inset: 0; background: rgba(255,255,255,.8); display: flex; align-items: center; justify-content: center; z-index: 3; }
.mini { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }

/* Líneas de cobro */
.linea { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0eeea; }
.linea:last-child { border-bottom: 0; }
.linea .monto { font-weight: 700; white-space: nowrap; }
.quitar { background: none; border: 0; color: var(--suave); font-size: 22px; padding: 4px 8px; cursor: pointer; }
.totales .entre { padding: 4px 0; }
.totales .grande { font-size: 22px; font-weight: 800; }

/* Firma */
canvas.firma { width: 100%; height: 220px; background: #fff; border: 2px dashed #b5afa7; border-radius: 14px; touch-action: none; display: block; }

/* Hoja inferior (modal) */
#hoja { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
#hoja[hidden] { display: none; }
#hoja .panel { background: var(--fondo); width: 100%; max-width: 680px; max-height: 88vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
#hoja .panel h2 { margin: 0 0 12px; font-size: 20px; }

/* Aviso */
#aviso { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%);
  background: #1c1917; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 60; max-width: 92vw;
  transition: transform .25s, visibility .25s; text-align: center; visibility: hidden; }
#aviso.ver { transform: translateX(-50%) translateY(0); visibility: visible; }
#aviso.error { background: var(--error); }

/* Login */
.login { max-width: 380px; margin: 8vh auto 0; }
.login .logo { font-size: 30px; font-weight: 800; text-align: center; margin-bottom: 4px; color: var(--marca); }

.cargando { text-align: center; color: var(--suave); padding: 40px; }
.oculto { display: none !important; }
