:root {
  --navy: #1b2a4a;
  --navy-2: #24365e;
  --orange: #f07c1f;
  --orange-soft: #fff1e5;
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e3e6ec;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --amber: #92400e;
  --amber-soft: #fef3c7;
  --blue: #1d4ed8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: #eef0f4; padding: 1px 5px; border-radius: 5px; font-size: 12px; }

/* ---------- Barra superior ---------- */
.top {
  display: flex; align-items: center; gap: 16px; padding: 12px 18px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.mark {
  background: var(--orange); color: #fff; font-weight: 800; letter-spacing: .5px;
  border-radius: 8px; padding: 6px 9px; font-size: 15px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 12px; opacity: .75; }
.searchbox {
  flex: 1; display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 10px;
  padding: 0 12px; height: 46px; box-shadow: 0 0 0 3px rgba(240,124,31,0);
  transition: box-shadow .15s;
}
.searchbox:focus-within { box-shadow: 0 0 0 3px rgba(240,124,31,.55); }
.searchbox svg { width: 20px; height: 20px; fill: none; stroke: #6b7280; stroke-width: 2; flex: none; }
.searchbox input { flex: 1; border: 0; outline: 0; font-size: 17px; color: var(--text); background: transparent; }
.searchbox kbd { font: 11px/1 inherit; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; }
.status {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; max-width: 330px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; margin-right: 6px; vertical-align: 1px; }
.status.busy .dot { background: var(--orange); animation: pulse 1.2s infinite; }
.status.ok .dot { background: #22c55e; }
.status.err .dot { background: #ef4444; }
@keyframes pulse { 50% { opacity: .35; } }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); color: #fff;
}
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.dlg-head .icon-btn { background: #f1f3f6; border-color: var(--line); color: var(--text); }

/* ---------- Filtros ---------- */
.filters {
  display: flex; align-items: center; gap: 14px; padding: 9px 18px; background: #fff;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 999px;
  padding: 4px 11px; font-size: 12.5px;
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); user-select: none; }
.count { margin-left: auto; color: var(--muted); font-size: 12.5px; }

/* ---------- Layout ---------- */
.layout { flex: 1; display: grid; grid-template-columns: minmax(380px, 42%) 1fr; min-height: 0; }
.results { overflow-y: auto; padding: 10px; border-right: 1px solid var(--line); outline: 0; }
.detail { overflow-y: auto; padding: 18px 22px 30px; }

/* ---------- Resultados ---------- */
.res {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  padding: 9px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
}
.res:hover { background: #fff; border-color: var(--line); }
.res.sel { background: #fff; border-color: var(--orange); box-shadow: var(--shadow); }
.thumb {
  width: 64px; height: 64px; border-radius: 8px; background: #fff; border: 1px solid var(--line);
  display: grid; place-items: center; overflow: hidden;
}
.thumb img { max-width: 62px; max-height: 62px; object-fit: contain; }
.thumb-fig { width: 62px; height: 62px; background-repeat: no-repeat; display: block; }
.thumb img.fig { width: 62px; height: 62px; object-fit: cover; }
.thumb .ph { width: 26px; height: 26px; fill: none; stroke: #c5cad3; stroke-width: 1.6; }
.res-main { min-width: 0; }
.res-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-tags { display: flex; gap: 5px; margin-top: 3px; flex-wrap: nowrap; overflow: hidden; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #eef1f6; color: #374151; white-space: nowrap; }
.tag.model { background: #e8eefc; color: #1e3a8a; }
.res-price { text-align: right; }
.res-price b { display: block; font-size: 15px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.no { background: var(--red-soft); color: var(--red); }
.badge.cat { background: #eef1f6; color: #4b5563; }
.badge.oferta { background: var(--amber-soft); color: var(--amber); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin: 0 0 6px; }
.tips { display: grid; gap: 8px; max-width: 460px; margin: 18px auto 0; text-align: left; }
.tips div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tips b { color: var(--navy); }

/* ---------- Detalle ---------- */
.d-head h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.25; }
.d-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.d-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.media { padding: 12px; }
.media-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.media-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 10px; font-size: 12.5px; }
.media-tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.media-img {
  height: 300px; display: grid; place-items: center; background: #fff; border-radius: 8px; position: relative;
}
.media-img { overflow: hidden; }
.media-img img { max-width: 100%; max-height: 284px; width: auto; height: auto; object-fit: contain; }
.media-img .none { color: var(--muted); text-align: center; padding: 20px; }
.conf { position: absolute; left: 8px; top: 8px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.9); border: 1px solid var(--line); }
.conf.media { color: var(--amber); }
.conf.baja { color: var(--red); }
.refs { margin-top: 10px; display: grid; gap: 4px; }
.ref {
  display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 8px;
  border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; text-align: left;
}
.ref.on { border-color: var(--orange); background: var(--orange-soft); }
.ref .r-model { font-weight: 600; }
.media-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.price-card { padding: 16px 18px; }
.price-label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }
.price { font-size: 44px; font-weight: 800; color: var(--navy); line-height: 1.1; margin: 2px 0 2px; letter-spacing: -.5px; }
.price.na { font-size: 22px; color: var(--muted); font-weight: 600; }
.price-note { color: var(--muted); font-size: 12px; }
.data { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.data div { display: flex; flex-direction: column; }
.data span { color: var(--muted); font-size: 12px; }
.data b { font-size: 16px; }
.data b.gain { color: var(--green); }
.btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 9px;
  padding: 7px 13px; font-weight: 600; font-size: 13px;
}
.btn:hover { border-color: #c9ced8; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: #de6c12; }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.facts { margin-top: 14px; padding: 6px 16px; }
.fact { display: grid; grid-template-columns: 140px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f0f2f5; }
.fact:last-child { border-bottom: 0; }
.fact span { color: var(--muted); font-size: 12.5px; }
.fact .val { word-break: break-word; }
.copyable { cursor: copy; border-bottom: 1px dashed #c3c8d1; }
.note-alt { background: var(--amber-soft); color: var(--amber); border-radius: 6px; padding: 1px 6px; font-size: 12px; font-weight: 600; }

.web { margin-top: 14px; padding: 14px 16px; }
.web h4 { margin: 0 0 8px; }
.cands { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.cand { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.cand img { width: 100%; height: 100px; object-fit: contain; background: #fff; }
.cand button { border: 0; border-top: 1px solid var(--line); background: #f8fafc; padding: 6px; font-size: 12px; font-weight: 600; }
.cand button:hover { background: var(--orange); color: #fff; }
.cand small { padding: 2px 6px 4px; color: var(--muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Diálogos ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 2; }
.dlg-actions { display: flex; gap: 8px; align-items: center; }
.fig-dialog { width: min(1200px, 94vw); height: min(860px, 92vh); }
.fig-dialog[open] { display: flex; flex-direction: column; }
.fig-wrap { flex: 1; min-height: 0; padding: 10px; background: #fff; }
.fig-wrap svg { width: 100%; height: 100%; }
.set-dialog { width: min(760px, 94vw); max-height: 90vh; }
.set-body { padding: 4px 20px 20px; overflow-y: auto; max-height: calc(90vh - 60px); }
.set-body section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.set-body section:last-child { border-bottom: 0; }
.set-body h3 { margin: 0 0 4px; font-size: 15px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 8px 0 10px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
input[type=number], input[type=text], input[type=password], select, textarea {
  font: inherit; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff;
}
textarea { width: 100%; font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; margin: 6px 0 10px; }
.failed { margin-top: 10px; font-size: 12.5px; color: var(--red); }

/* ---------- Bienvenida ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; z-index: 50; }
.onb { background: #fff; border-radius: 16px; width: min(640px, 92vw); padding: 26px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.onb h1 { margin: 0; font-size: 24px; color: var(--navy); }
.step { display: grid; grid-template-columns: 38px 1fr; gap: 14px; margin-top: 18px; }
.step .num { width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: #fff; display: grid; place-items: center; font-weight: 800; }
.step h3 { margin: 4px 0 4px; }
.step p { margin: 0 0 10px; color: var(--muted); }
.ok { color: var(--green); font-weight: 600; margin-left: 8px; }
.bar { height: 8px; background: #eef0f4; border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.bar-fill { height: 100%; width: 0; background: var(--orange); transition: width .3s; }
.onb-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60; font-weight: 600;
}

@media (max-width: 1100px) {
  .d-grid { grid-template-columns: 1fr; }
  .brand { min-width: 0; }
  .brand-text { display: none; }
}

.tag.count { background: var(--orange-soft); color: #c2410c; font-weight: 600; }
.refs-head { margin-top: 12px; font-size: 13px; }
.refs-head b { color: var(--navy); }
.refs { max-height: 220px; overflow-y: auto; }
.r-years { background: #eef1f6; border-radius: 6px; padding: 0 6px; font-size: 11.5px; color: #374151; }
.model-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.models-table { margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; max-height: 340px; overflow-y: auto; }
.mt-head, .mt-row { display: grid; grid-template-columns: 1fr 150px 60px; gap: 8px; align-items: center; padding: 6px 10px; }
.mt-head { position: sticky; top: 0; background: #f8fafc; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.mt-row { border-bottom: 1px solid #f0f2f5; }
.mt-row input { width: 100%; }

.fig-wrap { overflow: hidden; }
.fig-wrap svg { cursor: grab; touch-action: none; user-select: none; }
.fig-wrap svg.panning { cursor: grabbing; }
.fig-wrap svg.ctrl { cursor: zoom-in; }
.zoom-ctl { display: flex; align-items: center; gap: 4px; }
.zoom-ctl .btn { padding: 5px 10px; }
#figZoom { min-width: 48px; text-align: center; font-size: 12.5px; color: var(--muted); }
.zoom-help { max-width: 330px; line-height: 1.3; }
@media (max-width: 1150px) { .zoom-help { display: none; } }

.badge.punto { background: #166534; color: #fff; }
.stock-banner { display: flex; gap: 10px; align-items: center; background: var(--green-soft); border: 1px solid #86efac; color: #14532d; border-radius: 10px; padding: 9px 12px; margin-bottom: 12px; }
.stock-banner .ck { width: 26px; height: 26px; border-radius: 50%; background: #16a34a; color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.stock-banner div { display: flex; flex-direction: column; line-height: 1.25; }
.stock-banner span { font-size: 12.5px; }
.stock-banner.no { background: #f8fafc; border-color: var(--line); color: var(--muted); }
.stock-banner.no .ck { background: #cbd5e1; }
.media-img .none svg { width: 46px; height: 46px; fill: none; stroke: #c5cad3; stroke-width: 1.6; }

.toggle.sep { border-left: 1px solid var(--line); padding-left: 14px; }
.res-price b.cost { color: #9a3412; }
.cost-lbl { display: block; font-size: 10.5px; color: var(--muted); margin: -2px 0 2px; text-transform: uppercase; letter-spacing: .3px; }
.tire-banner { background: #eef4ff; border: 1px solid #c7d7fe; color: #1e3a8a; border-radius: 10px; padding: 9px 12px; margin: 2px 2px 10px; font-size: 13px; line-height: 1.5; }
.tire-banner.warn { background: var(--amber-soft); border-color: #fcd34d; color: var(--amber); }
.tag.size { background: #1e3a8a; color: #fff; font-weight: 600; }

.tire-ref { margin-top: 10px; font-size: 12.5px; }
.tire-ref summary { cursor: pointer; color: var(--blue); }
.tire-ref div div { padding: 2px 0; }

/* ---------- Otros puntos (inventario de todos los puntos) ---------- */
.badge.otros { background: #e0ecff; color: #1d4ed8; }
.others { border: 1px solid #c7dbff; background: #f5f9ff; border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
.others-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; color: #1e3a8a; margin-bottom: 4px; }
.others-head span { font-size: 12px; color: var(--muted); }
.other { display: grid; grid-template-columns: minmax(0, 1fr) 34px 62px 70px; gap: 8px; align-items: baseline; font-size: 12.5px; padding: 3px 0; border-top: 1px dashed #dbe6fb; }
.other > :nth-child(n+2) { text-align: right; white-space: nowrap; }
.other.o-cols { font-size: 10px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); border-top: 0; padding-bottom: 0; }
.other.o-cols + .other { border-top: 0; }
.o-cant { white-space: nowrap; color: #334155; }
.o-cost { color: #475569; }
.o-venta { color: #0f172a; }
.linkbtn { background: none; border: 0; padding: 4px 0 0; color: #1d4ed8; font-weight: 600; font-size: 12.5px; }
.linkbtn:hover { text-decoration: underline; }
.inv-opts { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.inv-opts select { min-width: 280px; }
.tipos { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 10px; }
.punto-dialog { width: min(560px, 92vw); padding: 0; border: 0; border-radius: 14px; box-shadow: var(--shadow); }
.punto-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.punto-body { padding: 4px 20px 20px; }
.punto-body input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; margin: 6px 0 10px; }
.punto-list { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.punto { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.punto:hover, .punto.on { border-color: var(--orange, #f07c1f); background: #fff7ed; }
.punto span { font-size: 12px; color: var(--muted); white-space: nowrap; }
