/* Panel de administración (usa las variables y componentes de /styles.css) */
body.admin { background: var(--bg); }
.atop { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; background: var(--ink); color: #fff; padding: 10px 16px; }
.abrand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; white-space: nowrap; }
.abrand img { width: 28px; height: 28px; border-radius: 50%; background: #fff; }
.anav { display: flex; gap: 4px; flex: 1; }
.anav a { color: #cfcfd4; text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.anav a.on { background: rgba(255,255,255,.14); color: #fff; }
.auser { display: flex; gap: 12px; align-items: center; }
.alink { background: none; border: 0; color: #cfcfd4; font-size: 13.5px; text-decoration: none; padding: 4px; }
.alink:hover { color: #fff; }
.amain { max-width: 1100px; margin: 0 auto; padding: 16px 16px 110px; }
@media (max-width: 960px) {
  .atop { flex-wrap: wrap; gap: 8px; }
  .amain { padding-bottom: 130px; }
  .anav { order: 3; position: fixed; left: 0; right: 0; bottom: 0; background: var(--ink); justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 30; }
  .anav a { display: flex; flex-direction: column; align-items: center; font-size: 12px; padding: 6px 10px; }
  .auser { margin-left: auto; }
}

.auth { max-width: 380px; margin: 8vh auto 0; }
.auth .logo { display: block; height: 44px; margin: 0 auto 18px; }
.auth h1 { font-size: 20px; text-align: center; margin: 0 0 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; font-weight: 400; }

.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.bar h1 { font-size: 20px; margin: 0; flex: 1; }
.bar .btn { flex: none; }
.bar input[type=search], .bar select { width: auto; min-width: 0; flex: 1 1 200px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.tabs button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; font-size: 13.5px; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs .n { opacity: .7; margin-left: 4px; }

.rows { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:first-child { border-top: 0; }
.row:hover { background: #fafafb; }
.row img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: #f2f2f4; }
.row .t { font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.row .r { text-align: right; font-size: 13.5px; }
.row.order { grid-template-columns: 1fr auto; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eee; color: #444; white-space: nowrap; }
.pill.ok { background: #e2f5ea; color: #0f6b39; }
.pill.warn { background: #fff4cc; color: #7a5b00; }
.pill.bad { background: #fde8ea; color: var(--brand-dark); }
.pill.info { background: #e6effc; color: #1f4f9c; }
.pill.gray { background: #ececef; color: #555; }

.grid2 { display: grid; gap: 14px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.check input { width: 20px; height: 20px; }
.counter { font-weight: 400; color: var(--muted); font-size: 12px; float: right; }
.counter.over { color: var(--brand-dark); font-weight: 700; }
textarea.desc-ed { min-height: 280px; font-size: 14px; line-height: 1.5; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #f2f2f4; border: 2px solid transparent; }
.photo.main { border-color: var(--brand); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .ctl { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; background: rgba(0,0,0,.55); }
.photo .ctl button { border: 0; background: none; color: #fff; padding: 4px 7px; font-size: 13px; }
.photo .badge-main { position: absolute; top: 4px; left: 4px; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.photo.add { display: grid; place-items: center; border: 2px dashed #cfcfd4; color: var(--muted); cursor: pointer; text-align: center; font-size: 13px; }

.stockbox { display: grid; gap: 10px; }
.stocknow { font-size: 30px; font-weight: 800; }
.stockctl { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stockctl input { width: 110px; }
.moves { font-size: 13px; }
.moves div { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.moves .plus { color: var(--ok); font-weight: 700; }
.moves .minus { color: var(--brand-dark); font-weight: 700; }

.savebar { position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
@media (max-width: 960px) { .savebar { bottom: 62px; } }
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.steps button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; font-weight: 600; font-size: 13.5px; }
.steps button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.steps button.cancel.on { background: var(--brand-dark); border-color: var(--brand-dark); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.cat-row { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.cat-row:first-child { border-top: 0; }
.cat-row input { flex: 1; }
.cat-row .n { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
/* Informes */
.rtypes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.rtype { display: grid; gap: 3px; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 12px; font: inherit; cursor: pointer; }
.rtype .ic { font-size: 22px; }
.rtype small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.rtype.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.rform { display: grid; gap: 14px; }
.tabs button.on { background: var(--ink); color: #fff; }
.rdoc { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-top: 16px; }
.rhead { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 14px; }
.rbrand { display: flex; gap: 10px; align-items: center; }
.rbrand img { height: 40px; }
.rtitle { text-align: right; }
.rtitle h2 { margin: 0 0 2px; font-size: 19px; }
.ractions { display: flex; gap: 10px; justify-content: flex-end; margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.kpi span { color: var(--muted); font-size: 12px; }
.kpi b { font-size: 18px; }
.kpi.ok b { color: var(--ok); } .kpi.bad b { color: var(--brand-dark); } .kpi.warn b { color: #8a6500; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 16px; }
.rt { width: 100%; border-collapse: collapse; font-size: 13px; }
.rt th { text-align: left; background: #f3f3f5; padding: 7px 8px; font-size: 12px; color: #444; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rt td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rt .n { text-align: right; white-space: nowrap; }
.rt td.ok { color: var(--ok); }
.rt tr.tot td { font-weight: 800; background: #fafafb; border-top: 2px solid var(--ink); }
.rt tr.muted td { color: var(--muted); font-style: italic; }
.rt tr.void td { color: #999; text-decoration: line-through; }
.rt tr.late td { background: #fff8e6; }
.rt.mini { font-size: 12.5px; }
.rt .its div { font-size: 12px; line-height: 1.4; }
.rt td:has(.its), .rt td.its, .rt td:has(.obs) { min-width: 260px; }
.obs { background: #fff7e0; border-radius: 6px; padding: 2px 6px; display: inline-block; font-size: 12px; margin-bottom: 3px; }
.rsec { margin-bottom: 22px; break-inside: avoid-page; }
.rsec-h { display: flex; justify-content: space-between; align-items: end; padding: 8px 0; }
.rsec-h .big { font-size: 18px; font-weight: 800; } .rsec-h .big.neg { color: var(--brand-dark); }
.rfoot { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 8px; }
@media screen and (max-width: 720px) {
  .rdoc { padding: 12px; } .rtitle { text-align: left; }
  .ractions { flex-wrap: wrap; } .ractions .btn { flex: 1 1 140px; }
  /* Tablas → tarjetas: cada fila es una tarjeta y cada dato lleva el nombre de su columna */
  .rt, .rt tbody, .rt tfoot, .rt tr, .rt td { display: block; width: 100%; min-width: 0 !important; }
  .rt thead { display: none; }
  .rt tr { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 8px; padding: 6px 10px; background: #fff; }
  .rt td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: right; word-break: break-word; }
  .rt td::before { content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 600; text-align: left; flex: none; max-width: 42%; font-style: normal; }
  .rt td[data-label=""]::before { display: none; }
  .rt td[data-label=""] { justify-content: flex-start; text-align: left; }
  .rt td:empty { display: none; }
  .rt .n { white-space: normal; }
  .rt td:has(.its), .rt td.its, .rt td:has(.obs) { display: block; text-align: left; }
  .rt td:has(.its)::before, .rt td.its::before, .rt td:has(.obs)::before { display: block; max-width: none; margin-bottom: 2px; }
  .rt tr.tot { border: 0; border-top: 2px solid var(--ink); border-radius: 0; background: #fafafb; }
  .rt tr.tot td { border-top: 0; background: none; }
  .rt tr.late { background: #fff8e6; } .rt tr.late td { background: none; }
}
@media print {
  body.admin { background: #fff; }
  .atop, .anav, .noprint, .toast, .back { display: none !important; }
  .amain { padding: 0; max-width: none; }
  .rdoc { box-shadow: none; padding: 0; margin: 0; }
  .rt { font-size: 10.5px; min-width: 0; }
  .rt th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kpi, .obs, .rt tr.late td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { margin: 12mm; }
}

/* Vender */
.pos-results { margin-top: 8px; max-height: 70vh; overflow-y: auto; }
.pos-item { width: 100%; border: 0; background: #fff; font: inherit; cursor: pointer; border-radius: 10px; }
.pos-item + .pos-item { border-top: 1px solid var(--line); border-radius: 0; }
.pos-line { grid-template-columns: 52px 1fr auto; }
.pos-line img { width: 52px; height: 52px; }
.pct { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; font-size: 13px; color: var(--muted); grid-auto-flow: column; }
.pct input { width: 58px; padding: 6px 8px; }
.cust-sel { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
@media (min-width: 900px) { .grid2.pos { grid-template-columns: 1fr 1.1fr; } .grid2.pos > div:first-child { position: sticky; top: 70px; } }
@media (max-width: 720px) { .anav a { padding: 6px 4px; font-size: 11px; } }
.iconbtn { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 34px; height: 34px; }

/* Compartir la app del panel */
.share-app { display: flex; gap: 12px; align-items: flex-start; background: #f3fbf6; border: 1px solid #cdeedb; }
.share-app img { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.auth .install-card { margin-top: 14px; text-align: center; }

/* Celular: nada se sale de la pantalla */
html, body.admin { overflow-x: hidden; }
.rform > *, .field-row > *, .grid2 > *, .rgrid > *, .kpis > * { min-width: 0; }
.field-row input, .rform input, .rform select { min-width: 0; max-width: 100%; }
@media (max-width: 960px) {
  .anav { gap: 0; }
  .anav a { flex: 1 1 0; min-width: 0; padding: 6px 2px; }
  .anav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .atop .auser { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
}

