/* centurion — estilos base (mobile-first). Colores vía variables de tema. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg, #f6f6f7);
  color: var(--text, #191a1e);
  line-height: 1.45;
}
img { max-width: 100%; display: block; }
a { color: var(--primary, #e8590c); }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }

.container { max-width: 1080px; margin: 0 auto; padding: 12px 14px 40px; }
.container.narrow { max-width: 560px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ---------- Header público ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.25rem; min-width: 0; }
.brand img { max-height: 52px; width: auto; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 640px) {
  .topbar { padding: 14px 24px; }
  .brand img { max-height: 60px; }
}
.topnav { display: flex; align-items: center; gap: 12px; }
.langbtn { text-decoration: none; font-size: .8rem; font-weight: 700; color: var(--muted); border: 1px solid var(--border); border-radius: 20px; padding: 4px 10px; }
.cartlink { position: relative; font-size: 1.35rem; text-decoration: none; }
.cartcount {
  position: absolute; top: -6px; right: -10px;
  background: var(--primary); color: var(--primary-contrast);
  border-radius: 999px; font-size: .68rem; font-weight: 800;
  min-width: 17px; height: 17px; line-height: 17px; text-align: center; padding: 0 3px;
}
.userlink { font-size: 1.25rem; text-decoration: none; }

/* Cotización del real en pesos argentinos (los clientes son minoristas de Argentina).
   Va debajo del header y NO es sticky: en el celular la barra fija se come media pantalla. */
.ratebar {
  display: flex; align-items: center; justify-content: center; gap: 6px 14px; flex-wrap: wrap;
  padding: 7px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  font-size: .82rem; color: var(--muted);
}
.ratebar strong { color: var(--text); }
.ratebar a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--border); }

/* ---------- Botones ---------- */
.btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--primary); color: var(--primary-contrast);
  font-weight: 700; font-size: .95rem;
  padding: 10px 18px; border-radius: var(--radius, 12px);
}
.btn:active { transform: scale(.98); }
.btn.small { padding: 7px 12px; font-size: .85rem; }
.btn.big { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: #dc2626; color: #fff; }
.btn.wa { background: #25d366; color: #063; }
.btn[disabled] { opacity: .6; cursor: wait; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .9rem; text-decoration: underline; padding: 4px; }

/* ---------- Chips de categorías ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; text-decoration: none; font-size: .88rem; font-weight: 600;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px;
}
.chip.on { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }

/* ---------- Catálogo: topbar + sidebar de filtros + grilla ---------- */
.catalogo { max-width: 1280px; }

.cat-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0 14px; flex-wrap: wrap;
}
.cat-count { font-weight: 700; font-size: .95rem; }
.sortform { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.sortlabel { display: flex; align-items: center; gap: 8px; margin: 0; white-space: nowrap; }
.sortlabel select { width: auto; margin-top: 0; padding: 7px 10px; }

.cat-layout { display: grid; grid-template-columns: 232px 1fr; gap: 28px; align-items: start; }

.filters { position: sticky; top: 74px; max-height: calc(100vh - 94px); overflow-y: auto; padding-right: 4px; }
.filters-head { display: flex; align-items: center; justify-content: space-between; }
.filters-head h2 { margin: 0 0 4px; font-size: 1.05rem; }
.filters-close { display: none; background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: var(--text); }
.limparlink { display: inline-block; font-size: .83rem; font-weight: 600; margin-bottom: 8px; }

.fgroup { border-top: 1px solid var(--border); padding: 14px 0; }
.fgroup h3 { margin: 0 0 10px; font-size: .9rem; text-transform: uppercase; letter-spacing: .4px; }
.flist { display: flex; flex-direction: column; gap: 2px; }
.flist a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text); font-size: .92rem;
  padding: 6px 8px; border-radius: 8px;
}
.flist a:hover { background: var(--surface); }
.flist a.on { font-weight: 800; background: var(--surface); box-shadow: inset 3px 0 0 var(--primary); }
.fcount { color: var(--muted); font-size: .78rem; font-weight: 400; }
.fcheck {
  display: flex; align-items: center; gap: 10px; font-weight: 400; color: var(--text);
  font-size: .92rem; margin: 0; padding: 6px 8px; border-radius: 8px; cursor: pointer;
}
.fcheck:hover { background: var(--surface); }
.fcheck input[type="checkbox"] { width: auto; margin: 0; flex: 0 0 auto; accent-color: var(--primary); }
.fcheck span:first-of-type { flex: 1; }

.btn-filters { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 110; background: rgba(0,0,0,.45); }

@media (max-width: 900px) {
  .cat-layout { grid-template-columns: 1fr; gap: 0; }
  .btn-filters { display: inline-block; }
  .filters {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 120;
    width: min(320px, 86vw); max-height: none;
    background: var(--bg); border-right: 1px solid var(--border);
    padding: 16px; overflow-y: auto;
    transform: translateX(-105%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.25);
  }
  .filters.open { transform: none; }
  .filters-close { display: block; }
}

/* ---------- Grilla de productos ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius, 12px); overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .15s ease, transform .15s ease;
}
@media (hover: hover) {
  .card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.10); transform: translateY(-2px); }
}
.card-img { position: relative; display: block; width: 100%; padding: 0; border: 0; background: #fff; cursor: zoom-in; }
.card-img img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.imgcount { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: .7rem; border-radius: 8px; padding: 2px 6px; }
.card-body { padding: 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-body h3 { margin: 0; font-size: .95rem; font-weight: 700; }
.cardmeta { color: var(--muted); font-size: .82rem; }
.grade { color: var(--muted); font-size: .8rem; }
.price { font-size: 1.05rem; font-weight: 800; margin-top: 2px; }
.badge.out { align-self: flex-start; background: var(--border); color: var(--muted); font-size: .75rem; font-weight: 700; border-radius: 8px; padding: 3px 8px; }
.locked { font-size: .85rem; font-weight: 600; margin-top: auto; }
.btn.add { margin-top: auto; }

/* ---------- Modal producto ---------- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal { align-items: center; } }
.pm-box { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; position: relative; }
@media (min-width: 640px) { .pm-box { border-radius: 18px; } }
.pm-close { position: absolute; top: 8px; right: 8px; z-index: 2; background: rgba(0,0,0,.5); color: #fff; border: 0; border-radius: 999px; width: 34px; height: 34px; font-size: 1rem; cursor: pointer; }
.pm-imgwrap { position: relative; background: #fff; }
.pm-img { width: 100%; max-height: 60vh; object-fit: contain; }
.pm-prev, .pm-next { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.45); color: #fff; border: 0; border-radius: 999px; width: 38px; height: 38px; font-size: 1.4rem; cursor: pointer; }
.pm-prev { left: 8px; } .pm-next { right: 8px; }
.pm-counter { position: absolute; bottom: 8px; right: 10px; background: rgba(0,0,0,.55); color: #fff; font-size: .75rem; border-radius: 8px; padding: 2px 8px; }
.pm-info { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.pm-info h2 { margin: 0; }
.pm-desc { margin: 0; color: var(--muted); white-space: pre-line; }

/* ---------- Formularios ---------- */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
input[type="file"] { padding: 8px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); margin-bottom: 14px; cursor: pointer; }
.checkline input[type="checkbox"] { display: inline-block; width: auto; margin: 0; flex: 0 0 auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; align-items: end; }
@media (max-width: 560px) { .row3 { grid-template-columns: 1fr 1fr; } }
.inline-form { display: inline-flex; gap: 8px; align-items: center; }
.inline-form input, .inline-form select { margin-top: 0; width: auto; }

.authbox {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius, 12px); padding: 18px; margin: 14px 0;
}
.authbox.success { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.orderid { font-size: 1.2rem; font-weight: 800; letter-spacing: .5px; }

/* ---------- Banners / avisos ---------- */
.banner { border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: .9rem; }
.banner.ok { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.banner.err { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
.banner.warn { background: #fef9c3; color: #713f12; border: 1px solid #fde047; }
.errlist { margin: 6px 0 0; padding-left: 18px; }
.errlist li { margin: 2px 0; }

/* ---------- Carrito ---------- */
.cartrow {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px; margin-bottom: 8px;
}
.cartrow img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.cr-main { min-width: 0; }
.cr-name { font-weight: 600; font-size: .9rem; }
.cr-grade { color: var(--muted); font-size: .78rem; }
.cr-price { font-size: .85rem; }
.cr-qty { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.qbtn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 1.1rem; cursor: pointer; }
.cr-sub { grid-column: 2 / 4; text-align: right; font-weight: 700; }
.carttotal { display: flex; justify-content: space-between; align-items: center; font-size: 1.15rem; padding: 14px 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  border-radius: 999px; padding: 10px 20px; font-weight: 600; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 30px; }
.footgrid { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; padding-top: 20px; padding-bottom: 20px; }
.footcontact { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.footcontact h4 { margin: 0; }
.footcontact a { text-decoration: none; font-weight: 600; }
.copy { color: var(--muted); font-size: .8rem; }

/* ---------- Panel (distribuidor + admin) ---------- */
.panelbar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 14px;
}
.panelbrand { font-weight: 800; }
.panelbar-right { display: flex; align-items: center; gap: 12px; }
.panelbar-right a { text-decoration: none; }
.sairline { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panelnav {
  display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 8px;
  position: sticky; top: 0; z-index: 40; scrollbar-width: none;
}
.panelnav::-webkit-scrollbar { display: none; }
.panelnav a {
  white-space: nowrap; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem;
  padding: 12px 10px; border-bottom: 3px solid transparent;
}
.panelnav a.on { color: var(--text); border-bottom-color: var(--primary); }

.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
@media (min-width: 640px) { .statgrid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; text-align: center; text-decoration: none; color: var(--text);
}
.stat strong { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .8rem; }
.stat.hot { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

.helpbox { background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; padding: 14px 18px; margin: 16px 0; }
.helpbox h3 { margin-top: 0; }
.helpbox ol { padding-left: 20px; }

.dropzone { position: relative; border: 2px dashed var(--border); border-radius: var(--radius, 12px); padding: 28px 16px; text-align: center; background: var(--bg); }
.dropzone.dragover { border-color: var(--primary); background: var(--surface); }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; margin: 0; }
.dropzone-text { color: var(--muted); font-weight: 600; pointer-events: none; }
.filelist { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.filelist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: .82rem; }
.filelist li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.filterbar input, .filterbar select { width: auto; flex: 1; min-width: 130px; margin-top: 0; }

.pcard {
  display: grid; grid-template-columns: 110px 1fr; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin-bottom: 10px;
}
@media (max-width: 560px) { .pcard { grid-template-columns: 84px 1fr; } }
.pcard-imgwrap { position: relative; }
.pcard-imgs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.pid { font-size: .7rem; color: var(--muted); word-break: break-all; margin-top: 4px; }
.warnchip { font-size: .72rem; color: #b45309; font-weight: 700; margin-top: 4px; }
.pcard-main .actions { display: flex; gap: 8px; margin-top: 4px; }

/* Rascunhos: lista de fichas plegables (<details>), un rascunho por fila */
.draftlist { display: flex; flex-direction: column; gap: 10px; }
.draftcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.draftcard[open] { border-color: var(--primary); }
.draftcard .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.drafthead { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; }
.drafthead::-webkit-details-marker { display: none; }
.drafthead:hover { background: var(--bg); border-radius: 12px; }
.draftthumb { flex: 0 0 auto; width: 52px; height: 52px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--border); }
.drafthead-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.drafthead-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draftfalta { color: #b45309; font-weight: 700; }
.drafthead-chev { color: var(--muted); transition: transform .15s; }
.draftcard[open] .drafthead-chev { transform: rotate(180deg); }
.draftbody { padding: 10px 12px 12px; border-top: 1px solid var(--border); }
.draftimgs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 6px; -webkit-overflow-scrolling: touch; }
.draftimgs img { width: 84px; height: 84px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--border); }
.draftimg-item { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 0 0 auto; width: 84px; }
.draftimg-item .linkbtn { font-size: .68rem; padding: 2px; text-align: center; line-height: 1.2; }
.mainbadge { font-size: .68rem; font-weight: 700; color: var(--primary); }

.ocard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.ocard-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ocard-cust { margin: 6px 0; font-size: .9rem; }
.ocard-items { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: .82rem; white-space: pre-wrap; overflow-x: auto; }
.ocard-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.status-pill { font-size: .72rem; font-weight: 800; border-radius: 999px; padding: 3px 10px; text-transform: uppercase; letter-spacing: .4px; background: var(--border); color: var(--muted); }
.st-to_confirm { background: #fef9c3; color: #713f12; }
.st-confirmed { background: #e0e7ff; color: #3730a3; }
.st-paid { background: #dcfce7; color: #14532d; }
.st-shipped { background: #dbeafe; color: #1e3a8a; }
.st-cancelled { background: #fee2e2; color: #7f1d1d; }

.rowcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center;
}
.rowcard-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.rowcard-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.credbox .btn { margin-top: 8px; margin-right: 8px; }

/* Selector de tema del painel del distribuidor (Configurações) */
.themegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; margin: 10px 0 16px; }
.themecard { border: 2px solid var(--border); border-radius: 12px; padding: 8px; cursor: pointer; display: block; }
.themecard.on, .themecard:has(input:checked) { border-color: var(--primary); }
.themecard strong { font-size: .82rem; font-weight: 700; }
.themecard input { accent-color: var(--primary); margin-right: 6px; vertical-align: middle; }
.themeprev { display: block; border: 1px solid; border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.themeprev-bar { display: block; border-radius: 6px; padding: 8px; margin-bottom: 8px; }
.themeprev-bar i { display: block; height: 6px; width: 65%; border-radius: 3px; opacity: .75; }
.themeprev-btn { display: inline-block; border-radius: 999px; padding: 4px 12px; font-size: .72rem; font-weight: 800; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.checkline input { width: auto; accent-color: var(--primary); }
.btn.ghost.danger { background: transparent; color: #dc2626; border-color: #dc2626; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.swatch { display: inline-flex; align-items: center; gap: 3px; font-size: .75rem; color: var(--muted); }
.swatch i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); display: inline-block; }
.logopreview { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-bottom: 10px; max-height: 80px; width: auto; }
