/* Dos colores con significado en toda la demo:
   petróleo = lo que es del vendedor; ámbar = lo que es del comprador. */
:root {
  --paper: #f5f7f9;
  --surface: #ffffff;
  --ink: #16212c;
  --muted: #586472;
  --line: #d8dee6;
  --top: #10323a;
  --seller: #0c5b66;
  --seller-soft: #dcebed;
  --buyer: #e9a70d;
  --buyer-soft: #fbedc4;
  --buyer-ink: #7a5200;
  --ok: #1d7a4c;
  --ok-soft: #e6f3ec;
  --danger: #b3261e;
  --almost: #b3261e;
  --radius: 6px;
  --font: Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.45; }
h1, h2, h3, p, dl, dd, ul, ol { margin: 0; }
h1 { font-size: 1.9rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
a { color: var(--seller); text-underline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.875rem; }
.sub { color: var(--muted); font-size: 0.82rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--buyer); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Estructura ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--top); color: #fff; padding: 0.7rem 1.5rem; }
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-mark { position: relative; width: 1.7rem; height: 1.3rem; flex: none; }
.brand-mark::before, .brand-mark::after { content: ''; position: absolute; top: 0; width: 1rem; height: 1.3rem; border-radius: 0.22rem; }
.brand-mark::before { left: 0; background: #9ccdd3; }
.brand-mark::after { right: 0; background: var(--buyer); }
.brand-name { font-weight: 700; line-height: 1.2; }
.brand-badge { font-size: 0.8rem; color: #9ccdd3; }
.locale select { width: auto; margin: 0; min-height: 2.1rem; padding: 0.25rem 0.5rem; background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.locale select option { color: var(--ink); }
.main { max-width: 68rem; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.7rem; }

.strip {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem 1.5rem; flex-wrap: wrap;
  margin-bottom: 1.5rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--line); font-size: 0.875rem; color: var(--muted);
}
.strip-links { display: inline-flex; gap: 1.1rem; white-space: nowrap; }
.strip-contact { font-weight: 700; }
.lead { margin-top: 0.6rem; max-width: 46rem; font-size: 1.05rem; }
.origin { margin-top: 0.5rem; max-width: 46rem; color: var(--buyer-ink); font-weight: 600; }

/* ---------- Recorrido ---------- */
.tour { margin-top: 1.5rem; padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--buyer); border-radius: var(--radius); }
.tour .section-head h2 { margin-bottom: 0.15rem; }
.tour-steps { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.tour-step { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.7rem; align-items: start; padding: 0.8rem 0.9rem; background: var(--paper); border-radius: var(--radius); }
.tour-step > div { display: flex; flex-direction: column; }
.tour-step .btn { grid-column: 2; justify-self: start; margin-top: 0.3rem; }
.tour-num { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700; font-size: 0.9rem; }
.tour-step.is-done .tour-num { background: var(--ok); }
.tour-cta { margin-top: 0.9rem; }
.coach {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.25rem; padding: 0.7rem 0.9rem;
  background: #fff6da; border-left: 4px solid var(--buyer); border-radius: var(--radius); font-weight: 600; scroll-margin-top: 0.75rem;
}
.coach-done { background: var(--ok-soft); border-left-color: var(--ok); }
.coach span { flex: 1 1 16rem; }
.notice { margin-top: 1.25rem; background: var(--ok-soft); color: #12512f; border-left: 4px solid var(--ok); padding: 0.55rem 0.8rem; border-radius: var(--radius); }
#tour, #notice { scroll-margin-top: 0.75rem; }

/* ---------- Botones y campos ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); background: var(--surface);
  border: 1px solid #b9c2cd; border-radius: var(--radius); padding: 0.42rem 0.85rem; min-height: 2.4rem;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--seller); border-color: var(--seller); color: #fff; }
.btn-primary:hover { background: #094a53; border-color: #094a53; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--seller); }
.btn-quiet:hover { border-color: var(--line); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.link { font: inherit; color: var(--seller); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; text-align: left; }
input, select {
  display: block; width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid #b9c2cd; border-radius: var(--radius); padding: 0.45rem 0.6rem; min-height: 2.4rem;
}
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1.1rem; }
.form-error { color: var(--danger); font-weight: 600; font-size: 0.875rem; margin-top: 0.45rem; }

/* ---------- Pestañas (solo en pantallas estrechas) ---------- */
.tabs { display: none; }
.tab {
  position: relative; flex: 1; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); background: transparent;
  border: 0; border-bottom: 3px solid transparent; padding: 0.6rem 0.4rem; margin-bottom: -1px;
}
.tab[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--seller); }
.dot { display: inline-block; width: 0.55rem; height: 0.55rem; margin-left: 0.35rem; border-radius: 50%; background: var(--almost); vertical-align: 0.1rem; }

/* ---------- Las dos pantallas ---------- */
.stage { display: grid; grid-template-columns: repeat(2, minmax(0, 24rem)); justify-content: center; gap: 2.5rem; margin-top: 1.75rem; }
.phone-cap { display: flex; flex-direction: column; margin: 0 0.4rem 0.6rem; }
.phone-frame {
  position: relative; display: flex; flex-direction: column; height: 43rem; overflow: hidden;
  background: var(--paper); border: 0.55rem solid #16212c; border-radius: 2.1rem; box-shadow: 0 18px 40px rgba(16, 50, 58, 0.18);
}
.phone-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 1rem; color: #fff; background: var(--seller); }
.phone-buyer .phone-top { background: var(--buyer); color: #3d2900; }
.phone-who { font-weight: 700; font-size: 1.05rem; }
.phone-clock { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.phone-body { position: relative; flex: 1; overflow-y: auto; padding: 0.9rem 0.8rem 1.2rem; overscroll-behavior: contain; }
.phone-lead h2 { font-size: 1.2rem; line-height: 1.25; }
.phone-lead .hint { margin-top: 0.2rem; }
.cards { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.9rem; }

.almost-bar { margin-top: 0.9rem; }
.btn-almost { display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left; border-color: #e7b3ae; background: #fff7f6; padding: 0.55rem 0.8rem; }
.btn-almost:hover { border-color: var(--almost); }
.btn-almost > span:last-child { display: flex; flex-direction: column; }
.btn-almost small { font-weight: 400; color: var(--muted); }
.almost-bar .hint { margin-top: 0.4rem; }
.stamp {
  position: absolute; top: 0.6rem; right: 0.6rem; transform: rotate(-7deg); white-space: nowrap;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--almost); border: 2px solid var(--almost); border-radius: 4px; padding: 0.05rem 0.4rem; background: rgba(255, 255, 255, 0.85);
}
.stamp-inline { position: static; flex: none; }

.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; padding: 0.75rem 0.8rem; transition: box-shadow 300ms ease-out; }
.phone-seller .card.is-todo { border-left-color: var(--seller); }
.phone-buyer .card.is-todo { border-left-color: var(--buyer); }
.card.is-almost { border-color: #e7b3ae; border-left-color: var(--almost); }
.card.is-waiting { background: #f6f7f9; border-left-color: #c3c8d1; }
.card.is-waiting .duo { opacity: 0.65; }
.card.is-closed { background: #f6f7f9; border-left-color: #c3c8d1; }
.card.is-sold { background: #f3f9f4; border-left-color: var(--ok); }
.card.is-flash { box-shadow: 0 0 0 3px rgba(233, 167, 13, 0.7); }
.card-head { display: flex; align-items: center; gap: 0.7rem; }
.card.is-almost .card-head { padding-right: 6.5rem; }
.card-name { font-weight: 700; line-height: 1.25; }
.thumb { width: 3.2rem; height: 3.2rem; flex: none; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); object-fit: cover; }
.thumb-small { width: 2.3rem; height: 2.3rem; }
.sku {
  display: inline-block; font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted);
  background: #eceff2; border-radius: 3px; padding: 0 0.35rem; margin-top: 0.15rem;
}
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.65rem; }
.price { display: flex; flex-direction: column; padding: 0.4rem 0.55rem; border-radius: var(--radius); background: #f1f3f6; }
.price small { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.price b { font-size: 1.15rem; line-height: 1.3; }
.price .was { font-size: 0.75rem; color: var(--muted); }
.price-seller { background: var(--seller-soft); }
.price-buyer { background: var(--buyer-soft); }
.price.is-new { box-shadow: 0 0 0 2px var(--almost) inset; }
.new { display: inline-block; margin-left: 0.25rem; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; color: #fff; background: var(--almost); border-radius: 3px; padding: 0 0.3rem; }
.almost-hint { margin-top: 0.5rem; font-size: 0.875rem; font-weight: 600; color: var(--almost); }
.wait { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; font-size: 0.875rem; font-weight: 600; color: #475467; }
.wait .link { font-weight: 400; }
.pulse { width: 0.5rem; height: 0.5rem; flex: none; border-radius: 50%; background: #98a2b3; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.kept { margin-top: 0.6rem; padding: 0.4rem 0.6rem; font-size: 0.875rem; background: #fff6da; border-left: 3px solid var(--buyer); border-radius: 4px; }
.counter { display: flex; gap: 0.5rem; margin-top: 0.65rem; }
.counter input { min-width: 0; }
.counter .btn { flex: none; }
.actions { display: flex; align-items: center; gap: 0.6rem 0.9rem; flex-wrap: wrap; margin-top: 0.55rem; }
.btn-accept { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-accept:hover { background: #166340; border-color: #166340; }
.actions .link { font-size: 0.875rem; color: var(--muted); }
.result { margin-top: 0.5rem; font-weight: 700; color: #475467; }
.result-sold { color: var(--ok); }

/* Confirmación dentro de la propia pantalla */
.sheet-wrap { position: absolute; inset: 0; display: flex; align-items: flex-end; background: rgba(16, 33, 44, 0.45); z-index: 3; }
.sheet { width: 100%; background: var(--surface); border-radius: 14px 14px 0 0; padding: 1.1rem 1.1rem 1.3rem; }
.sheet-kicker { font-size: 0.85rem; color: var(--muted); font-weight: 600; margin-bottom: 0.15rem; }
.sheet-amount { font-size: 1.7rem; font-weight: 700; line-height: 1.3; margin: 0.2rem 0; }
.sheet-actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.sheet-actions .btn { flex: 1; min-height: 2.7rem; }

/* ---------- Lo que ve la tienda ---------- */
.shop { margin-top: 2.5rem; scroll-margin-top: 0.75rem; }
.shop-clock { font-weight: 700; padding: 0.2rem 0.6rem; border-radius: 999px; background: #e8eef4; color: #2c3e50; white-space: nowrap; }
.totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 0.9rem; }
.totals > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; }
.totals dt { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.totals dd { font-size: 1.5rem; font-weight: 700; line-height: 1.25; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table th, .table td { padding: 0.6rem 0.8rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table th { font-size: 0.8rem; font-weight: 600; color: var(--muted); white-space: nowrap; background: #fafbfc; }
.table th.num, .table td.num { text-align: right; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.cell-item { display: flex; align-items: center; gap: 0.7rem; min-width: 13rem; }
.item-name { font-weight: 600; }
.who-seller { color: var(--seller); font-weight: 700; }
.who-buyer { color: var(--buyer-ink); font-weight: 700; }
.badge { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.badge-open { background: #e8eef4; color: #2c3e50; }
.badge-almost { background: #fbe4e2; color: #8c1d18; }
.badge-sold { background: var(--ok-soft); color: #12512f; }
.badge-unsold { background: #eceff2; color: var(--muted); }

/* ---------- Diálogo ---------- */
dialog { border: 0; border-radius: 10px; padding: 1.5rem; width: min(30rem, calc(100vw - 2rem)); color: var(--ink); box-shadow: 0 18px 50px rgba(16, 50, 58, 0.28); }
dialog::backdrop { background: rgba(16, 50, 58, 0.45); }
dialog h2 { font-size: 1.25rem; margin-bottom: 0.4rem; }

/* ---------- Pantallas medianas ---------- */
@media (max-width: 60rem) {
  .stage { gap: 1.25rem; }
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tour-steps { grid-template-columns: 1fr; }
}

/* ---------- Pantallas estrechas: una pantalla cada vez ---------- */
@media (max-width: 46rem) {
  .top { padding: 0.55rem 0.9rem; }
  .brand-badge { display: none; }
  .main { padding: 1rem 0.9rem 3rem; }
  h1 { font-size: 1.45rem; }
  .lead { font-size: 1rem; }
  .tabs { display: flex; position: sticky; top: 0; z-index: 4; margin: 1.25rem -0.9rem 0; padding: 0 0.4rem; background: var(--paper); border-bottom: 1px solid var(--line); }
  .stage { display: block; margin-top: 1rem; }
  .stage[data-tab='seller'] .phone-buyer, .stage[data-tab='buyer'] .phone-seller, .stage[data-tab='shop'] { display: none; }
  .shop:not([data-tab='shop']) { display: none; }
  .shop { margin-top: 1rem; }
  .phone-frame { height: auto; border-width: 0; border-radius: 10px; box-shadow: none; border: 1px solid var(--line); }
  .phone-body { overflow: visible; }
  .sheet-wrap { position: fixed; z-index: 6; }
  .totals { gap: 0.5rem; }
  .totals dd { font-size: 1.2rem; }
  input, select { font-size: 1rem; }

  /* Cada fila de la tabla pasa a ser una ficha. */
  .table, .table tbody, .table tr, .table td { display: block; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table { background: transparent; border: 0; }
  .table tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.8rem; margin-bottom: 0.6rem; }
  .table td, .table td.num { border: 0; padding: 0.2rem 0; text-align: right; white-space: normal; display: flex; justify-content: space-between; gap: 1rem; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 0.85rem; text-align: left; flex: none; }
  .table td.cell-first { display: block; text-align: left; padding-bottom: 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  .card { transition: none; }
}
