:root {
  --tinta: #0b1020;
  --tinta-2: #121a2e;
  --fondo: #f3f4f8;
  --tarjeta: #ffffff;
  --texto: #0f172a;
  --suave: #5b6475;
  --linea: #e5e8f0;
  --naranja: #ff5b14;
  --naranja-oscuro: #e04600;
  --naranja-suave: #fff1e8;
  --degradado: linear-gradient(135deg, #ff5b14 0%, #ff8a00 100%);
  --verde: #16a34a;
  --verde-suave: #dcfce7;
  --wa: #25d366;
  --azul: #2563eb;
  --azul-suave: #dbeafe;
  --rojo: #dc2626;
  --sombra: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --sup: env(safe-area-inset-top);
  --inf: env(safe-area-inset-bottom);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--fondo);
  color: var(--texto);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(84px + var(--inf));
}
@media (min-width: 640px) {
  body { background: #e7e9f0; }
  .vista, .barra-sup, .tabs { max-width: 560px; margin-left: auto; margin-right: auto; }
}
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Barra superior */
.barra-sup {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--sup)) 16px 10px;
  background: rgba(11, 16, 32, .96);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #fff;
}
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 18px; min-width: 0; }
.logo img { border-radius: 8px; }
.logo span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.instalar { background: var(--degradado); color: #fff; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }

.vista { padding: 16px 16px 24px; outline: none; }
.titulo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.titulo h1 { font-size: 26px; }
.titulo .atras { display: inline-flex; align-items: center; gap: 4px; color: var(--suave); text-decoration: none; font-weight: 600; margin-left: -6px; }
.seccion-t { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--suave); margin: 22px 0 10px; }

/* Tarjetas */
.tarjeta { background: var(--tarjeta); border-radius: 18px; padding: 16px; box-shadow: var(--sombra); border: 1px solid var(--linea); }
.tarjeta + .tarjeta { margin-top: 12px; }
.metricas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metrica { background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 16px; padding: 14px; text-decoration: none; color: inherit; box-shadow: var(--sombra); }
.metrica small { display: block; color: var(--suave); font-size: 13px; font-weight: 600; }
.metrica b { display: block; font-size: 25px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.metrica.destacada { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.metrica.destacada small { color: #9aa6bf; }
.metrica.destacada b { color: #ffb07a; }

.bienvenida { background: var(--tinta); color: #fff; border-radius: 20px; padding: 20px; position: relative; overflow: hidden; }
.bienvenida::after { content: ""; position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; background: radial-gradient(circle, rgba(255,91,20,.55), transparent 70%); }
.bienvenida h2 { font-size: 22px; margin-bottom: 6px; position: relative; }
.bienvenida p { color: #b8c2d6; margin-bottom: 14px; position: relative; }
.bienvenida .fila { display: flex; gap: 8px; position: relative; }
.bienvenida input { flex: 1; min-width: 0; }

/* Listas de órdenes */
.orden {
  display: flex; align-items: center; gap: 12px;
  background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 16px;
  padding: 13px 14px; text-decoration: none; color: inherit; box-shadow: var(--sombra);
}
.orden + .orden { margin-top: 10px; }
.orden .avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--naranja-suave); color: var(--naranja); display: grid; place-items: center; flex: none; overflow: hidden; }
.orden .avatar img { width: 100%; height: 100%; object-fit: cover; }
.orden .info { flex: 1; min-width: 0; }
.orden .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.orden .info small { display: block; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.orden .der { text-align: right; flex: none; }
.orden .der b { display: block; font-size: 15px; }
.saldo-rojo { color: var(--rojo); font-size: 12.5px; font-weight: 700; }

.etiqueta { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.e-recibida { background: #eef0f5; color: #475069; }
.e-reparacion { background: var(--azul-suave); color: #1d4ed8; }
.e-lista { background: var(--verde-suave); color: #15803d; }
.e-entregada { background: #1e293b; color: #e2e8f0; }

.vacio { text-align: center; padding: 34px 20px; color: var(--suave); }
.vacio .ic { width: 42px; height: 42px; margin: 0 auto 10px; color: #c2c8d6; }
.vacio b { display: block; color: var(--texto); font-size: 17px; margin-bottom: 4px; }

/* Filtros y búsqueda */
.buscador { position: relative; margin-bottom: 12px; }
.buscador .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--suave); width: 20px; height: 20px; }
.buscador input { padding-left: 42px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1.5px solid var(--linea); background: #fff; border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.chip.activo { background: var(--tinta); color: #fff; border-color: var(--tinta); }

/* Formularios */
.campo { margin-bottom: 14px; }
.campo label, .etq { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dos > *, .trabajo > *, .metricas > *, .acciones-2 > * { min-width: 0; }
input, select, textarea {
  width: 100%;
  font-size: 16px;
  padding: 13px 14px;
  border: 1.5px solid var(--linea);
  border-radius: 12px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--naranja); box-shadow: 0 0 0 4px rgba(255, 91, 20, .14); }
.trabajo { display: grid; grid-template-columns: 1fr 104px 44px; gap: 8px; margin-bottom: 8px; }
.quitar { border: 1.5px solid var(--linea); background: #fff; border-radius: 12px; font-size: 20px; color: var(--suave); cursor: pointer; }
.agregar { background: var(--naranja-suave); color: var(--naranja-oscuro); border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 700; cursor: pointer; }

.fotos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.foto { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #e9ecf3; }
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.agregar-foto { aspect-ratio: 1; border-radius: 12px; border: 2px dashed #cdd3e0; background: #fff; display: grid; place-items: center; color: var(--suave); cursor: pointer; font-size: 12px; font-weight: 600; text-align: center; padding: 6px; }
.agregar-foto .ic { margin: 0 auto 2px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 15px 16px; border-radius: 14px; border: 0;
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none;
  transition: transform .1s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-naranja { background: var(--degradado); color: #fff; box-shadow: 0 8px 20px rgba(255, 91, 20, .3); }
.btn-wa { background: var(--wa); color: #053d1f; }
.btn-tinta { background: var(--tinta); color: #fff; }
.btn-borde { background: #fff; border: 1.5px solid var(--linea); color: var(--texto); }
.btn-peligro { background: #fff; border: 1.5px solid #fecaca; color: var(--rojo); }
.btn-chico { width: auto; padding: 10px 14px; font-size: 14px; border-radius: 11px; }
.acciones { display: grid; gap: 10px; }
.acciones-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.guardar-fijo { position: sticky; bottom: calc(80px + var(--inf)); margin-top: 18px; }

/* Detalle */
.cabeza-orden { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cabeza-orden h2 { font-size: 22px; }
.cabeza-orden small { color: var(--suave); }
.estados { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.estado-btn { border: 1.5px solid var(--linea); background: #fff; border-radius: 11px; padding: 9px 4px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--suave); }
.estado-btn.activo { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.dato { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--linea); }
.dato:last-child { border-bottom: 0; }
.dato span:first-child { color: var(--suave); }
.dato span:last-child { font-weight: 600; text-align: right; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; }
.total b { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.pagos-hist { font-size: 13.5px; color: var(--suave); margin-top: 6px; }

/* Barra de pestañas */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--linea);
  padding: 6px 4px calc(6px + var(--inf));
}
.tabs a { position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: #8a93a6; font-size: 11.5px; font-weight: 600; }
.tabs a.activa { color: var(--naranja); }
.tab-nueva .mas { width: 54px; height: 54px; border-radius: 18px; background: var(--degradado); color: #fff; display: grid; place-items: center; margin-top: -26px; box-shadow: 0 10px 22px rgba(255, 91, 20, .4); }
.tab-nueva .mas .ic { width: 28px; height: 28px; stroke-width: 2.6; }
[hidden] { display: none !important; }
.punto { position: absolute; top: 4px; right: calc(50% - 18px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--rojo); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 5px; }

/* Aviso flotante */
.aviso {
  position: fixed; left: 50%; bottom: calc(96px + var(--inf)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--tinta); color: #fff; padding: 12px 18px; border-radius: 14px;
  font-weight: 600; font-size: 15px; max-width: calc(100% - 32px); text-align: center;
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
  transition: opacity .2s ease, transform .2s ease;
}
.aviso.visible { opacity: 1; transform: translate(-50%, 0); }

.promo { background: var(--naranja-suave); border: 1px solid #ffd6bf; border-radius: 18px; padding: 16px; margin-top: 20px; }
.promo b { display: block; font-size: 16px; margin-bottom: 4px; }
.promo p { color: #7a4a2e; font-size: 14.5px; margin-bottom: 12px; }
.nota { font-size: 13.5px; color: var(--suave); }
