/* Somar Orden · estilos compartidos */
:root {
  --tinta: #262833;
  --grafito: #5B6170;
  --amarillo: #F6C744;
  --amarillo-2: #FBE7A6;
  --fondo: #F4F2EC;
  --sup: #FFFFFF;
  --linea: #E2DED3;
  --suave: #8A8F9C;
  --ok: #1E8E5A;
  --ok-2: #DDF2E6;
  --mal: #C8384F;
  --mal-2: #F9E1E5;
  --aviso: #B7791F;
  --aviso-2: #FBF0D9;
  --azul: #2F5DC9;
  --azul-2: #E3EAFA;
  --r: 14px;
  --sombra: 0 1px 2px rgba(38,40,51,.06), 0 4px 14px rgba(38,40,51,.06);
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--fondo); color: var(--tinta); font-size: 15px; line-height: 1.4; min-height: 100dvh; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
img { max-width: 100%; display: block; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sm { font-size: 13px; }
.xs { font-size: 12px; }
.muted { color: var(--grafito); }
.faint { color: var(--suave); }
.b { font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.right { text-align: right; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Estructura */
.app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; background: var(--tinta); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.top .sub { font-size: 12px; color: #C9CCD4; }
.top .btn-ic { color: #fff; }
.main { flex: 1; padding: 14px 14px 110px; display: flex; flex-direction: column; gap: 12px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--sup); border-top: 1px solid var(--linea); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.tabs .in { display: flex; width: 100%; max-width: 640px; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 9px; font-size: 11.5px; color: var(--grafito); font-weight: 600; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--tinta); }
.tab.on svg { color: var(--tinta); }
.tab.nueva .bola { width: 46px; height: 46px; border-radius: 50%; background: var(--amarillo); color: var(--tinta); display: grid; place-items: center; margin-top: -20px; box-shadow: 0 4px 12px rgba(246,199,68,.55); border: 3px solid var(--sup); }
.tab.nueva .bola svg { width: 24px; height: 24px; }

/* Tarjetas y paneles */
.card { background: var(--sup); border-radius: var(--r); box-shadow: var(--sombra); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card.tap { cursor: pointer; transition: transform .08s; }
.card.tap:active { transform: scale(.99); }
.card h2, .h2 { font-size: 15px; font-weight: 700; }
.h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.sect { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--grafito); margin: 6px 2px -2px; }
.panel { border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.panel.warn { background: var(--aviso-2); color: #6B4A12; }
.panel.info { background: var(--azul-2); color: #1D3A80; }
.panel.ok { background: var(--ok-2); color: #155C3B; }
.panel.bad { background: var(--mal-2); color: #8A2335; }
.hr { height: 1px; background: var(--linea); margin: 2px 0; }
.empty { text-align: center; color: var(--grafito); padding: 28px 12px; font-size: 14px; }
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--linea); }
.li:last-child { border-bottom: 0; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.kv .k { color: var(--grafito); }
.kv.tot { font-size: 17px; font-weight: 800; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px; border-radius: 12px; font-weight: 700; font-size: 15px; background: var(--fondo); color: var(--tinta); border: 1px solid var(--linea); transition: filter .1s, transform .08s; text-decoration: none; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.pri { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.btn.ama { background: var(--amarillo); border-color: var(--amarillo); color: var(--tinta); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.wa { background: #1FA855; border-color: #1FA855; color: #fff; }
.btn.mal { background: var(--sup); border-color: var(--mal-2); color: var(--mal); }
.btn.quiet { background: transparent; border-color: transparent; }
.btn.s { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.full { width: 100%; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.btn-ic svg { width: 22px; height: 22px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns > .btn { flex: 1; }

/* Formularios */
.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--grafito); }
.inp { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--linea); background: var(--sup); color: var(--tinta); font-size: 16px; font-weight: 500; outline: none; }
.inp:focus { border-color: var(--tinta); box-shadow: 0 0 0 3px rgba(38,40,51,.08); }
textarea.inp { min-height: 76px; resize: vertical; }
.inp.big { font-size: 22px; font-weight: 700; text-align: center; letter-spacing: .04em; }
.pre { position: relative; }
.pre > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--grafito); font-weight: 600; pointer-events: none; }
.pre > .inp { padding-left: 34px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.err { color: var(--mal); font-size: 13.5px; font-weight: 600; }
.chk { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--tinta); padding: 6px 0; }
.chk input { width: 22px; height: 22px; accent-color: var(--tinta); }
.seg { display: flex; background: var(--fondo); border-radius: 11px; padding: 3px; gap: 3px; border: 1px solid var(--linea); }
.seg button { flex: 1; min-height: 38px; border-radius: 8px; font-weight: 700; font-size: 13.5px; color: var(--grafito); }
.seg button.on { background: var(--sup); color: var(--tinta); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Chips de filtro */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 13px; border-radius: 999px; background: var(--sup); border: 1px solid var(--linea); font-weight: 700; font-size: 13.5px; color: var(--grafito); }
.chip.on { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.chip .n { background: var(--fondo); color: var(--tinta); border-radius: 999px; padding: 0 7px; font-size: 12px; line-height: 20px; }
.chip.on .n { background: var(--amarillo); }

/* Etiquetas de estado */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag.recibida { background: #ECEDF0; color: var(--grafito); }
.tag.en_proceso { background: var(--azul-2); color: var(--azul); }
.tag.lista { background: var(--ok-2); color: var(--ok); }
.tag.entregada { background: #EFEAE0; color: #7A6A4F; }
.tag.cancelada { background: var(--mal-2); color: var(--mal); }
.tag.urg { background: var(--amarillo); color: var(--tinta); }
.tag.urg::before { display: none; }
.tag.plain::before { display: none; }

/* Tarjeta de orden */
.ord { display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: start; }
.ord .numero { width: 54px; height: 54px; border-radius: 12px; background: var(--tinta); color: var(--amarillo); display: grid; place-items: center; font-weight: 800; font-size: 17px; position: relative; }
.ord .numero::after { content: ""; position: absolute; top: 6px; left: 50%; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: var(--fondo); }
.ord .numero span { margin-top: 8px; }
.ord .nom { font-weight: 700; font-size: 15.5px; }
.ord .det { font-size: 13px; color: var(--grafito); }
.ord .cuando { font-size: 12.5px; font-weight: 700; text-align: right; }
.cuando.vencida { color: var(--mal); }
.cuando.hoy { color: var(--aviso); }

/* Línea de estados */
.pasos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.paso { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--suave); text-align: center; }
.paso .bar { height: 6px; width: 100%; border-radius: 99px; background: var(--linea); }
.paso.on { color: var(--tinta); }
.paso.on .bar { background: var(--tinta); }
.paso.ahora .bar { background: var(--amarillo); }

/* Servicios en cuadrícula */
.servs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.serv { text-align: left; background: var(--sup); border: 1px solid var(--linea); border-radius: 12px; padding: 11px; display: flex; flex-direction: column; gap: 3px; min-height: 72px; }
.serv:active { background: var(--amarillo-2); }
.serv .n { font-weight: 700; font-size: 14px; line-height: 1.2; }
.serv .p { font-size: 13px; color: var(--grafito); }

/* Prenda en la orden */
.prenda { border: 1px solid var(--linea); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--sup); }
.fotos { display: flex; gap: 8px; flex-wrap: wrap; }
.foto { width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--fondo); position: relative; border: 1px solid var(--linea); }
.foto img { width: 100%; height: 100%; object-fit: cover; }
.foto .x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; display: grid; place-items: center; }
.foto.add { display: grid; place-items: center; color: var(--grafito); border-style: dashed; cursor: pointer; }
.foto.add svg { width: 26px; height: 26px; }

/* Medidas */
.medidas { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.medida { background: var(--fondo); border-radius: 9px; padding: 7px 9px; }
.medida .k { font-size: 11.5px; color: var(--grafito); font-weight: 600; }
.medida .v { font-size: 15px; font-weight: 800; }

/* Hoja inferior */
.velo { position: fixed; inset: 0; background: rgba(20,22,28,.45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.hoja { background: var(--fondo); width: 100%; max-width: 640px; max-height: 92dvh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: sube .2s ease-out; }
.hoja .cab { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; border-bottom: 1px solid var(--linea); }
.hoja .cab h3 { font-size: 17px; font-weight: 800; flex: 1; }
.hoja .cuerpo { overflow-y: auto; padding: 14px 14px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
@keyframes fade { from { opacity: 0 } }
@keyframes sube { from { transform: translateY(40px); opacity: .6 } }

/* Aviso flotante */
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--tinta); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; z-index: 90; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100% - 28px); animation: fade .2s; }
.toast.mal { background: var(--mal); }

/* Entrada */
.entrada { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 18px; max-width: 420px; margin: 0 auto; gap: 18px; }
.marca { display: flex; align-items: center; gap: 12px; }
.marca img { width: 52px; height: 52px; }
.marca .t { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.marca .s { font-size: 13px; color: var(--grafito); }
.pie { text-align: center; font-size: 12px; color: var(--suave); }
.pie img { height: 18px; display: inline-block; vertical-align: middle; opacity: .8; }

/* Resumen numérico */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--sup); border-radius: 12px; padding: 10px 12px; box-shadow: var(--sombra); }
.stat .k { font-size: 12px; color: var(--grafito); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 800; }
.stat.alerta .v { color: var(--mal); }

.spin { width: 28px; height: 28px; border: 3px solid var(--linea); border-top-color: var(--tinta); border-radius: 50%; animation: gira .7s linear infinite; margin: 40px auto; }
@keyframes gira { to { transform: rotate(360deg); } }

@media (min-width: 700px) {
  .main { padding-top: 20px; }
}
@media print {
  .top, .tabs, .no-print { display: none !important; }
  body { background: #fff; }
}
