:root {
  --bg: #f7f9fc;
  --surface: #e8eef6;
  --price: #c2570c;
  --card: #ffffff;
  --text: #1b2433;
  --muted: #5d6b82;
  --brand: #0061af;
  --brand-dark: #004e8c;
  --accent: #f58220;
  --ok: #16a34a;
  --line: #dbe3ef;
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
header.site {
  background: linear-gradient(135deg, #0061af, #1379c8); border-bottom: 4px solid var(--accent);
  color: #fff;
  padding: 28px 16px 24px;
  text-align: center;
}
header.site h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 2.6rem); }
header.site p { margin: 6px 0 0; opacity: .95; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 18px; }
.toolbar input, .toolbar select, .field input, .field select, .field textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
}
.toolbar input[type=search] { flex: 1 1 220px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); transition: transform .15s, box-shadow .15s; position: relative; text-align: left; padding: 0; font: inherit; color: inherit;
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,40,90,.18); border-color: var(--brand); outline: none; }
.card .thumb { aspect-ratio: 1; background: var(--surface); display: grid; place-items: center; font-size: 3rem; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .info { padding: 12px 14px 14px; }
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.card .price { font-weight: 700; font-size: 1.15rem; color: var(--price); }
.tag { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface); color: var(--muted); margin-right: 4px; }
.badge-sold {
  position: absolute; top: 10px; left: 10px; background: #e11d48; color: #fff; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; z-index: 1;
}
.card.sold .thumb img { filter: grayscale(.85); opacity: .7; }
.empty, .loading { text-align: center; color: var(--muted); padding: 50px 0; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(15,25,45,.6); display: none; align-items: center; justify-content: center; padding: 14px; z-index: 50; }
.modal.open { display: flex; }
.modal .box { background: var(--card); border-radius: 20px; max-width: 820px; width: 100%; max-height: 92vh; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; position: relative; }
.modal .close { position: absolute; top: 10px; right: 12px; border: 0; background: rgba(255,255,255,.92); color: #111; width: 36px; height: 36px; border-radius: 50%; font-size: 1.3rem; cursor: pointer; z-index: 2; }
.gallery .main { aspect-ratio: 1; background: var(--surface); display: grid; place-items: center; font-size: 5rem; }
.gallery .main img { width: 100%; height: 100%; object-fit: contain; background: var(--surface); }
.gallery .thumbs { display: flex; gap: 6px; padding: 8px; overflow-x: auto; }
.gallery .thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.gallery .thumbs img.on { border-color: var(--brand); }
.detail { padding: 24px 22px; }
.detail h2 { margin: 0 0 6px; }
.detail .price { font-size: 1.6rem; font-weight: 800; color: var(--price); margin: 6px 0 12px; }
.detail p { white-space: pre-line; color: #3a465c; }
@media (max-width: 680px) { .modal .box { grid-template-columns: 1fr; } }

.btn {
  display: inline-block; border: 0; border-radius: 12px; padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--brand-dark); }
.btn.danger, .btn.wa { color: #fff; }
.btn.wa { background: #25d366; } .btn.wa:hover { background: #1ebe5a; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); } .btn.ghost:hover { background: var(--surface); }
.btn.danger { background: #dc2626; } .btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 6px 12px; font-size: .85rem; border-radius: 9px; }
footer { text-align: center; color: var(--muted); padding: 30px 16px; font-size: .9rem; }
footer a { color: inherit; }

/* admin */
.admin-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.login { max-width: 340px; margin: 40px auto; background: var(--card); padding: 24px; border-radius: var(--radius); border: 1px solid var(--line); display: grid; gap: 12px; }
.login input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.msg { color: #dc2626; min-height: 1.2em; font-size: .9rem; }
.list { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px 8px 8px; }
.row img, .row .ph { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface); display: grid; place-items: center; font-size: 1.6rem; }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.form { display: grid; gap: 12px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; }
.field input, .field select, .field textarea { font-weight: 400; width: 100%; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.photo { position: relative; width: 92px; height: 92px; border-radius: 10px; overflow: hidden; border: 2px solid var(--line); }
.photo.cover { border-color: var(--brand); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo button { position: absolute; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: .75rem; padding: 2px 6px; }
.photo .rm { top: 0; right: 0; border-radius: 0 0 0 8px; }
.photo .mk { bottom: 0; left: 0; right: 0; text-align: center; }
.admin-modal .box { grid-template-columns: 1fr; padding: 24px; max-width: 640px; }

/* ---------- celulares ---------- */
@media (max-width: 600px) {
  header.site { padding: 18px 14px 16px; }
  header.site p { font-size: .9rem; }
  main { padding: 12px; }

  .toolbar { gap: 8px; }
  .toolbar input[type=search] { flex: 1 1 100%; }
  .toolbar select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .toolbar label { flex: 1 1 100%; font-size: .9rem; }

  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .thumb { font-size: 2.2rem; }
  .card .info { padding: 8px 10px 10px; }
  .card h3 { font-size: .9rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .card .price { font-size: 1rem; }
  .tag { font-size: .68rem; padding: 1px 6px; margin-bottom: 2px; }
  .badge-sold { top: 6px; left: 6px; font-size: .7rem; padding: 2px 8px; }

  .modal { padding: 0; align-items: flex-end; }
  .modal .box { border-radius: 20px 20px 0 0; max-height: 94vh; }
  .detail { padding: 18px 16px 24px; }
  .detail .btn { display: block; }
  .gallery .thumbs img { width: 48px; height: 48px; }

  /* administración */
  .row { grid-template-columns: 56px 1fr; }
  .row img, .row .ph { width: 56px; height: 56px; }
  .row .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .form .two { grid-template-columns: 1fr; }
  .admin-modal { align-items: stretch; }
  .admin-modal .box { padding: 18px 16px 28px; border-radius: 0; max-height: 100vh; }
  .btn { padding: 12px 18px; }
  .field input, .field select, .field textarea, .login input { font-size: 16px; } /* evita el zoom automático en iPhone */
}
