/* stamps.cl — premium catalogue UI. Theme via CSS variables (CLAUDE.md UX). */
:root,
[data-theme="dark"] {
  --bg: #0b0f1a;
  --bg-2: #121a2e;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(255, 255, 255, 0.10);
  --text: #e8edf7;
  --muted: #8a96b3;
  --accent: #5b8cff;
  --accent-2: #7d5bff;
  --tile: #0e1424;
  --card: rgba(255, 255, 255, 0.04);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
[data-theme="classic"] {
  --bg: #f3efe6; --bg-2: #e9e2d2; --panel: rgba(60,40,20,0.05); --panel-border: rgba(80,55,25,0.18);
  --text: #2c2317; --muted: #7a6b53; --accent: #9c6b2f; --accent-2: #b3892f; --tile: #fbf8f1; --card: #fffdf8;
  --shadow: 0 10px 26px rgba(90,70,40,0.18);
}
[data-theme="modern"] {
  --bg: #f6f8fc; --bg-2: #eaf0fb; --panel: rgba(20,40,90,0.04); --panel-border: rgba(30,60,120,0.12);
  --text: #142036; --muted: #5f6f8c; --accent: #2563eb; --accent-2: #7c3aed; --tile: #ffffff; --card: #ffffff;
  --shadow: 0 10px 26px rgba(30,60,120,0.12);
}
[data-theme="kids"] {
  --bg: #fff7fb; --bg-2: #f0fbff; --panel: rgba(255,120,180,0.07); --panel-border: rgba(255,120,180,0.25);
  --text: #2a2342; --muted: #8a6f9c; --accent: #ff5fa2; --accent-2: #44c2ff; --tile: #ffffff; --card: #ffffff;
  --shadow: 0 12px 28px rgba(255,120,180,0.22);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--text);
  /* Century Gothic (installed on Windows) with a geometric fallback for other systems. */
  font-family: "Century Gothic", "Questrial", "Twentieth Century", "Futura", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 80% -10%, var(--bg-2), var(--bg)) fixed;
}

.app { display: grid; grid-template-columns: 290px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--panel); backdrop-filter: blur(14px);
  border-right: 1px solid var(--panel-border); padding: 22px 18px; display: flex; flex-direction: column;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
/* Image protection (deterrent): no native drag, no selection on catalogue images. */
img { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: .3px; }
.brand-name span { color: var(--accent); }
.brand-sub { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.4px; }

.side-search { display: flex; gap: 6px; margin-bottom: 18px; }
.side-search input {
  flex: 1; background: var(--tile); border: 1px solid var(--panel-border); color: var(--text);
  border-radius: 11px; padding: 10px 12px; outline: none; font-size: 13.5px;
}
.side-search input:focus { border-color: var(--accent); }
.side-search button {
  width: 42px; border: none; border-radius: 11px; font-size: 18px; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.side-nav { flex: 1; }
.side-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.3px; color: var(--muted); margin: 18px 4px 8px; }
.range-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.range-list li a, .link-list li a {
  display: block; padding: 9px 11px; border-radius: 10px; cursor: pointer; font-size: 13px;
  color: var(--text); border: 1px solid transparent; transition: .15s; text-decoration: none;
}
.range-list li a:hover, .link-list li a:hover { background: var(--card); border-color: var(--panel-border); }
.range-list li a.active, .link-list li a.active-collection.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: var(--shadow);
}
.link-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.link-list.muted li a { color: var(--muted); cursor: default; }
.soon { font-size: 9.5px; background: var(--card); border: 1px solid var(--panel-border); padding: 1px 6px; border-radius: 20px; margin-left: 6px; }

.side-footer { margin-top: 16px; border-top: 1px solid var(--panel-border); padding-top: 14px; }
.theme-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.theme-dots { display: flex; gap: 8px; }
.dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--panel-border); cursor: pointer; }
.t-dark { background: #0b0f1a; } .t-classic { background: #c79a5a; } .t-modern { background: #2563eb; } .t-kids { background: #ff5fa2; }
.admin-link {
  width: 100%; background: var(--card); border: 1px solid var(--panel-border); color: var(--text);
  border-radius: 11px; padding: 10px; cursor: pointer; font-size: 13px; transition: .15s;
}
.admin-link:hover { border-color: var(--accent); }
.admin-link.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

/* ---------- Main ---------- */
.content { padding: 26px 30px 50px; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.menu-toggle { display: none; background: var(--card); border: 1px solid var(--panel-border); color: var(--text); border-radius: 10px; width: 42px; height: 42px; font-size: 18px; cursor: pointer; }
.topbar-title h1 { font-size: 24px; margin: 0; font-weight: 800; }
.view-meta { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn-new { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; border-radius: 11px; padding: 11px 16px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.btn-reset { background: var(--card); color: var(--text); border: 1px solid var(--panel-border); border-radius: 11px; padding: 11px 16px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-reset:hover { border-color: var(--accent); color: var(--accent); }
.hidden { display: none !important; }

/* ---------- Grid 5x5 ---------- */
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; }
.loading { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px; }
.card-stamp {
  background: var(--card); border: 1px solid var(--panel-border); border-radius: 16px; overflow: hidden;
  cursor: pointer; transition: transform .18s, box-shadow .18s, border-color .18s; position: relative;
}
.card-stamp:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: var(--accent); }
.card-thumb { aspect-ratio: 3 / 4; background: var(--tile); display: grid; place-items: center; padding: 10px; }
.card-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card-thumb .noimg { color: var(--muted); font-size: 12px; text-align: center; }
.card-body { padding: 10px 12px 12px; }
.card-name { font-size: 13px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 33px; }
.card-meta { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.scott-badge { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.card-year { font-size: 11px; color: var(--muted); }
.img-count { position: absolute; top: 9px; right: 9px; background: rgba(0,0,0,.55); color: #fff; font-size: 10.5px; padding: 2px 7px; border-radius: 20px; backdrop-filter: blur(4px); }

/* ---------- Pager ---------- */
.pager { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 30px; }
.pager button {
  min-width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--panel-border);
  background: var(--card); color: var(--text); cursor: pointer; font-size: 13.5px; transition: .15s;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); }
.pager button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .ellipsis { color: var(--muted); align-self: center; padding: 0 4px; }

/* ---------- Detail modal ---------- */
.detail-content, .edit-content { background: var(--bg-2); color: var(--text); border: 1px solid var(--panel-border); border-radius: 20px; box-shadow: var(--shadow); }
/* Keep the whole detail card inside the viewport at 100% zoom: cap its height and let the
   body scroll as a single unit instead of growing the page past the screen. */
.detail-content { max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
/* The body is a flex child that must scroll independently. `min-height: 0` defeats the
   default `min-height: auto`, which otherwise keeps the child as tall as its content and
   makes `overflow-y: auto` a no-op — the cause of the detail "showing only partially" on
   phones where the single-column ficha exceeds the modal height. */
.detail-content .detail-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-x { position: absolute; top: 14px; right: 16px; z-index: 5; background: var(--card); border: 1px solid var(--panel-border); color: var(--text); width: 36px; height: 36px; border-radius: 50%; font-size: 20px; cursor: pointer; }
/* Wider detail modal + more room for the info/ficha column so long "Antecedentes" fit. */
#detailModal .modal-dialog { max-width: 1280px; }
.detail-body { display: grid; grid-template-columns: 1fr 1.45fr; gap: 20px; padding: 20px 22px; }
/* Gallery is a simple vertical stack: the big preview first, thumbnails strictly BELOW it
   (a normal flow column, so a thumbnail can never overlay the main image). position:relative
   + the explicit block flow keep the strip anchored under the main image on every browser. */
.detail-gallery { display: flex; flex-direction: column; align-self: start; min-width: 0; position: relative; }
/* Clean framed card: the stamp is contained (never stretched) inside a panel with a thin
   border and a soft drop shadow for a subtle 3D lift. No inner box around the image. */
.detail-gallery .main-img {
  width: 100%; min-height: 240px; height: auto; display: grid; place-items: center; padding: 18px;
  cursor: zoom-in; position: static; border-radius: 14px;
  background: var(--card); border: 1px solid var(--panel-border);
  box-shadow: 0 12px 30px rgba(0,0,0,.22);
}
.detail-gallery .main-img img { max-width: 100%; max-height: 380px; object-fit: contain; display: block; }
/* Clear breathing room + a divider so the miniatures sit well below the big stamp and
   never appear to touch or overlap it. */
.detail-thumbs { position: static; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--panel-border); }
.detail-thumbs img { width: 58px; height: 58px; object-fit: cover; border-radius: 9px; border: 2px solid var(--panel-border); cursor: pointer; background: var(--tile); }
.detail-thumbs img.sel { border-color: var(--accent); }
.detail-info h2 { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.detail-info .scott-line { color: var(--accent); font-weight: 700; margin-bottom: 14px; }
.emision { margin: 0 0 14px; font-size: 14px; }
.emision b { font-weight: 800; }
.emision .date { color: var(--accent); font-weight: 700; }
/* Specs as a clean two-column table. */
.spec-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.spec-table tr { border-bottom: 1px solid var(--panel-border); }
.spec-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 600; padding: 8px 14px 8px 0; white-space: nowrap; vertical-align: top; width: 42%; }
.spec-table td { font-size: 14px; font-weight: 600; padding: 8px 0; }
.story-title { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 4px 0 8px; }
.story { background: var(--card); border: 1px solid var(--panel-border); border-radius: 12px; padding: 16px 18px; font-size: 13.5px; line-height: 1.7; max-height: 280px; overflow-y: auto; white-space: pre-line; text-align: justify; hyphens: auto; }
/* Catalogue ficha: clean two-column table matching the Denominación/Color spec rows.
   The label column shrinks to its own content (width:1% + nowrap) so the value sits about
   a tab away — not pushed to the centre — with every row top-aligned to the left. */
.ficha-table { width: 100%; border-collapse: collapse; margin: 2px 0 6px; }
.ficha-table tr { border-bottom: 1px solid var(--panel-border); }
.ficha-table tr:last-child { border-bottom: none; }
.ficha-table th { width: 1%; white-space: nowrap; text-align: left; vertical-align: top; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; padding: 10px 22px 10px 0; }
.ficha-table td { font-size: 13.5px; line-height: 1.6; color: var(--text); font-weight: 500; vertical-align: top; text-align: left; padding: 10px 0; }
.detail-admin { margin-top: 16px; display: flex; gap: 10px; }

/* Ficha spec block + narrative sections. */
.ficha-table.spec-block { margin-bottom: 14px; }
.ficha-narrative { background: var(--card); border: 1px solid var(--panel-border); border-radius: 12px; padding: 6px 18px 14px; max-height: 300px; overflow-y: auto; }
.ficha-section { padding-top: 12px; }
.ficha-section h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--accent); margin: 6px 0 5px; font-weight: 800; }
.ficha-section p { margin: 0; font-size: 13.5px; line-height: 1.7; text-align: justify; hyphens: auto; }

/* ---------- Reference-value panel (vertical: one condition per row) ---------- */
.price-panel { background: var(--card); border: 1px solid var(--panel-border); border-radius: 14px; padding: 12px 16px 14px; margin: 4px 0 18px; }
.price-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.price-rate { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent); font-size: 11.5px; }
.price-row { display: grid; grid-template-columns: minmax(120px, 1fr) auto auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--panel-border); }
.price-row:first-of-type { border-top: none; }
.price-cond { font-size: 13px; font-weight: 700; color: var(--text); }
.price-amt { font-size: 15px; font-weight: 800; color: var(--text); white-space: nowrap; text-align: right; }
.price-usd { font-size: 12px; font-weight: 600; color: var(--muted); }
.price-src { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; text-decoration: none; border: 1px solid var(--panel-border); }
a.price-src { color: var(--accent); background: var(--tile); }
a.price-src:hover { border-color: var(--accent); }
.price-src.no-link { color: var(--muted); background: transparent; cursor: help; }
.price-note { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--panel-border); }

/* ---------- Auction price history (newest → oldest) ---------- */
.remates .rem-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 12px; }
.rem-chip { background: var(--tile); border: 1px solid var(--panel-border); border-radius: 10px; padding: 8px 11px; display: flex; flex-direction: column; gap: 2px; }
.rem-cond { font-size: 12px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .4px; }
.rem-range { font-size: 14.5px; font-weight: 800; color: var(--text); }
.rem-range .price-usd { font-weight: 600; }
.rem-n { font-size: 11px; color: var(--muted); }
.rem-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rem-table thead th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; padding: 0 8px 6px 0; border-bottom: 1px solid var(--panel-border); }
.rem-table thead th:last-child { text-align: right; }
.rem-table td { padding: 7px 8px 7px 0; border-top: 1px solid var(--panel-border); vertical-align: middle; }
.rem-table tbody tr:first-child td { border-top: none; }
.rem-date { color: var(--muted); white-space: nowrap; text-transform: capitalize; }
.rem-c { font-weight: 700; color: var(--text); }
.rem-p { text-align: right; font-weight: 800; color: var(--text); white-space: nowrap; }
.rem-p .price-usd { font-weight: 600; }
@media (max-width: 720px) {
  .remates .rem-chips { grid-template-columns: 1fr 1fr; }
  .rem-table { font-size: 12px; }
}

/* ---------- Headline MNH KPI (main view) ---------- */
.kpi-panel { background: linear-gradient(135deg, var(--card), var(--tile)); border: 1px solid var(--panel-border); border-radius: 14px; padding: 14px 16px; margin: 4px 0 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; }
.kpi-value { font-size: 26px; font-weight: 900; color: var(--text); line-height: 1.1; margin-top: 4px; }
.kpi-usd { font-size: 13px; font-weight: 700; color: var(--accent); margin-left: 6px; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.kpi-hint { font-size: 11px; color: var(--accent); font-weight: 700; }

/* Compact link that replaces the old KPI panel: jumps to the Precios tab. */
.price-jump { display: inline-block; background: none; border: none; color: var(--accent); font-size: 13px; font-weight: 700; cursor: pointer; padding: 2px 0 12px; }
.price-jump:hover { text-decoration: underline; }

/* "Not registered" placeholder ficha. */
.not-registered { background: var(--card); border: 1px dashed var(--panel-border); border-radius: 14px; padding: 18px; margin: 6px 0 12px; }
.nr-badge { display: inline-block; background: #ff6b6b22; color: #ff6b6b; border: 1px solid #ff6b6b55; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; padding: 4px 10px; border-radius: 20px; margin-bottom: 10px; }
.nr-text { font-size: 14px; line-height: 1.6; color: var(--text); margin: 0; }
.nr-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* General print-run line at the top of the Tiradas y variedades tab. */
.tirada-total { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.tirada-total b { font-size: 16px; font-weight: 800; color: var(--text); }

/* ---------- Ficha tabs (Antecedentes / Tiradas / Precios) ---------- */
.ficha-tabs { margin: 16px 0 6px; }
.tab-bar { display: flex; gap: 6px; border-bottom: 1px solid var(--panel-border); margin-bottom: 14px; }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 700; padding: 9px 12px; cursor: pointer; margin-bottom: -1px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.story-subtitle { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; margin: 14px 0 8px; }

/* Keep long histories elegant: the table scrolls inside the tab instead of growing the modal. */
.rem-scroll { max-height: 420px; overflow-y: auto; }
.rem-scroll .rem-table thead th { position: sticky; top: 0; background: var(--card); }

/* ---------- Variety photo grid ---------- */
.variety-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; max-height: 540px; overflow-y: auto; padding-right: 4px; }
.variety-thumb { padding: 0; border: 1px solid var(--panel-border); background: var(--tile); border-radius: 11px; cursor: zoom-in; overflow: hidden; aspect-ratio: 1; display: grid; place-items: center; }
.variety-thumb:hover { border-color: var(--accent); }
.variety-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }

/* ---------- Detail prev/next navigation ----------
   Floating circular controls centred vertically on each side of the modal box.
   On wide screens they sit just OUTSIDE the card (in the side margin); narrower
   viewports tuck them inside as a translucent overlay (see responsive rules). */
.detail-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 6; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--panel-border); background: var(--card); color: var(--text); font-size: 24px; line-height: 1; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.28); backdrop-filter: blur(8px); transition: transform .16s ease, background .16s ease, box-shadow .16s ease, opacity .16s ease; display: grid; place-items: center; }
.detail-nav:hover:not(:disabled) { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; box-shadow: 0 10px 30px rgba(0,0,0,.38); transform: translateY(-50%) scale(1.08); }
.detail-nav:active:not(:disabled) { transform: translateY(-50%) scale(.95); }
/* Keep disabled arrows visible (greyed) so the prev/next affordance is always present,
   instead of vanishing at the first/last item. */
.detail-nav:disabled { opacity: .3; pointer-events: none; cursor: default; }
/* Anchored just inside the left/right edges of the card so they are never clipped by the
   modal's overflow and stay visible on every screen size. */
.detail-nav.prev { left: 10px; }
.detail-nav.next { right: 10px; }
.detail-nav { background: color-mix(in srgb, var(--card) 82%, transparent); }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: grid; place-items: center; z-index: 2000; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; box-shadow: 0 20px 60px rgba(0,0,0,.6); border-radius: 8px; }

/* ---------- Edit form ---------- */
.edit-content { padding: 26px; }
.edit-title { font-size: 20px; font-weight: 800; margin: 0 0 18px; }
.edit-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.edit-form .full { grid-column: 1 / -1; }
.edit-form label { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); display: block; margin-bottom: 4px; }
.edit-form input, .edit-form textarea { width: 100%; background: var(--tile); border: 1px solid var(--panel-border); color: var(--text); border-radius: 10px; padding: 9px 11px; font-size: 13.5px; outline: none; }
.edit-form input:focus, .edit-form textarea:focus { border-color: var(--accent); }
.edit-form textarea { min-height: 90px; resize: vertical; }
/* Admin photo manager: existing thumbnails with a remove button + multi-file picker. */
.edit-images .edit-hint { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; }
.img-manager { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 10px; }
.img-tile { position: relative; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; border: 2px solid var(--panel-border); background: var(--tile); }
.img-tile[data-cover="1"] { border-color: var(--accent); }
.img-tile img { width: 100%; height: 100%; object-fit: contain; }
.img-del { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.img-del:hover { background: #ff6b6b; }
.edit-images input[type="file"] { width: 100%; background: var(--tile); border: 1px solid var(--panel-border); color: var(--text); border-radius: 10px; padding: 9px 11px; font-size: 13px; }

.edit-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-primary-pro { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; border-radius: 11px; padding: 11px 20px; font-weight: 600; cursor: pointer; }
.btn-danger-pro { background: transparent; color: #ff6b6b; border: 1px solid #ff6b6b55; border-radius: 11px; padding: 11px 18px; cursor: pointer; }

/* ---------- Settings / Skin panel ---------- */
.settings-content { padding: 26px; }
.settings-title { font-size: 20px; font-weight: 800; margin: 0 0 18px; }
.set-group { margin-bottom: 20px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.set-label { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.set-row .set-label { margin-bottom: 2px; }
.set-hint { font-size: 12px; color: var(--muted); }
.skin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.skin-card { display: flex; flex-direction: column; align-items: center; gap: 7px; background: var(--card); border: 1px solid var(--panel-border); border-radius: 12px; padding: 10px 6px; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text); }
.skin-card:hover { border-color: var(--accent); }
.skin-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.skin-prev { width: 100%; height: 34px; border-radius: 8px; border: 1px solid rgba(0,0,0,.15); }
.skin-prev.t-dark { background: linear-gradient(135deg, #1a1d24, #2a2f3a); }
.skin-prev.t-classic { background: linear-gradient(135deg, #f3ece0, #d8c6a6); }
.skin-prev.t-modern { background: linear-gradient(135deg, #6366f1, #06b6d4); }
.skin-prev.t-kids { background: linear-gradient(135deg, #ff7eb3, #ffd166); }
.set-seg { display: flex; gap: 8px; }
.set-seg button { flex: 1; background: var(--card); border: 1px solid var(--panel-border); border-radius: 10px; padding: 9px 8px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.set-seg button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.set-toggle { background: var(--card); border: 1px solid var(--panel-border); border-radius: 20px; padding: 8px 16px; font-size: 13px; font-weight: 700; color: var(--text); cursor: pointer; white-space: nowrap; }
.set-toggle.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }

/* Accessibility: font/UI scaling (Senior Mode). Zoom scales the whole interface evenly. */
html[data-fs="grande"] body { zoom: 1.12; }
html[data-fs="xl"] body { zoom: 1.25; }

/* High-contrast (senior): brighter secondary text + heavier separators for readability. */
html[data-contrast="on"] { --muted: var(--text); }
html[data-contrast="on"] .card-stamp,
html[data-contrast="on"] .sidebar,
html[data-contrast="on"] .ficha-table tr,
html[data-contrast="on"] .rem-table td,
html[data-contrast="on"] .detail-nav { border-color: var(--text); }

/* ---------- PRO: personal collection ---------- */
/* Grid badge marking owned / wanted stamps. */
.mine-badge { position: absolute; top: 8px; left: 8px; z-index: 2; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 20px; color: #fff; box-shadow: var(--shadow); }
.mine-badge.owned { background: linear-gradient(135deg, #16a34a, #22c55e); }
.mine-badge.wishlist { background: linear-gradient(135deg, #db2777, #f472b6); }

/* Collection filter chips (Todas / Tengo / Me faltan / Quiero). */
.mine-filter { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--panel-border); border-radius: 12px; padding: 6px; flex-wrap: wrap; }
.mine-filter button { background: transparent; border: none; border-radius: 8px; padding: 8px 13px; font-size: 13px; font-weight: 700; color: var(--text); cursor: pointer; }
.mine-filter button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

/* "Mi colección" summary line. */
.user-stats { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.user-stats b { color: var(--accent); }

/* Detail collection panel (large controls, senior-friendly). */
.coll-panel { margin-top: 18px; background: var(--card); border: 1px solid var(--panel-border); border-radius: 14px; padding: 16px; }
.coll-title { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 800; margin-bottom: 10px; }
.coll-status { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.coll-st { flex: 1; min-width: 150px; background: var(--tile); border: 1px solid var(--panel-border); border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 700; color: var(--text); cursor: pointer; }
.coll-st.active[data-st="owned"] { background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; border-color: transparent; }
.coll-st.active[data-st="wishlist"] { background: linear-gradient(135deg, #db2777, #f472b6); color: #fff; border-color: transparent; }
.coll-fields { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.coll-fields label { flex: 1; min-width: 130px; display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 700; }
.coll-fields input { background: var(--tile); border: 1px solid var(--panel-border); color: var(--text); border-radius: 10px; padding: 11px; font-size: 15px; }
.coll-notes-l { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.coll-notes-l textarea { background: var(--tile); border: 1px solid var(--panel-border); color: var(--text); border-radius: 10px; padding: 11px; font-size: 15px; min-height: 72px; resize: vertical; }
.coll-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Account modal tabs + register success message. */
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab { flex: 1; background: var(--card); border: 1px solid var(--panel-border); border-radius: 10px; padding: 10px; font-size: 14px; font-weight: 700; color: var(--text); cursor: pointer; }
.auth-tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.login-ok { color: #22c55e; font-size: 13px; margin: 8px 0; line-height: 1.5; }
.login-ok a { color: var(--accent); font-weight: 700; }

/* Admin BI dashboard. */
.bi-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.bi-kpi { background: var(--tile); border: 1px solid var(--panel-border); border-radius: 12px; padding: 12px; text-align: center; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.bi-kpi span { display: block; font-size: 24px; font-weight: 900; color: var(--text); margin-bottom: 2px; }
.bi-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.bi-empty { color: var(--muted); font-size: 13px; }
@media (max-width: 720px) { .bi-kpis { grid-template-columns: 1fr 1fr; } .bi-cols { grid-template-columns: 1fr; } }

/* ---------- Year filter (ad-hoc) ---------- */
/* Sort control mirrors the year filter chrome. Hidden in Biblioteca mode (stamps only). */
.sort-filter { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--panel-border); border-radius: 12px; padding: 6px 10px; }
.sort-filter .yf-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sort-filter select { background: var(--tile); border: 1px solid var(--panel-border); color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 13px; outline: none; cursor: pointer; }
.sort-filter select:focus { border-color: var(--accent); }
.sort-filter #sortDir { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; border-radius: 8px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }

/* Scott-range filter mirrors the year filter chrome. Catalogue-only (hidden in Biblioteca). */
.scott-filter { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--panel-border); border-radius: 12px; padding: 6px 10px; }
.scott-filter .yf-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.scott-filter input { width: 64px; background: var(--tile); border: 1px solid var(--panel-border); color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 13px; text-align: center; outline: none; }
.scott-filter input:focus { border-color: var(--accent); }
.scott-filter .yf-dash { color: var(--muted); }
.scott-filter button { border: none; border-radius: 8px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; }
.scott-filter .yf-apply { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.scott-filter .yf-clear { background: transparent; color: var(--muted); }

.year-filter { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--panel-border); border-radius: 12px; padding: 6px 10px; }
.year-filter .yf-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.year-filter input { width: 64px; background: var(--tile); border: 1px solid var(--panel-border); color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 13px; text-align: center; outline: none; }
.year-filter input:focus { border-color: var(--accent); }
.year-filter .yf-dash { color: var(--muted); }
.year-filter button { border: none; border-radius: 8px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; }
.year-filter .yf-apply { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.year-filter .yf-clear { background: transparent; color: var(--muted); }

/* ---------- Login ---------- */
.login-content { background: var(--bg-2); border: 1px solid var(--panel-border); border-radius: 20px; box-shadow: var(--shadow); padding: 30px; max-width: 380px; }
.login-content h2 { font-size: 20px; font-weight: 800; margin: 0 0 4px; }
.login-content p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login-content label { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); display: block; margin: 12px 0 4px; }
.login-content input { width: 100%; background: var(--tile); border: 1px solid var(--panel-border); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none; }
.login-content input:focus { border-color: var(--accent); }
.login-err { color: #ff6b6b; font-size: 12.5px; margin-top: 10px; min-height: 16px; }
.login-content .btn-primary-pro { width: 100%; margin-top: 16px; }

/* ---------- Biblioteca (Artículos, Historia postal, Prefilatelia) ---------- */
/* Section count badge in the sidebar navigation. */
.detail-info .story { max-height: 420px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 992px) {
  /* The sidebar is now fixed (not part of the grid), so clipping horizontal overflow is
     safe and stops the whole page from rendering wider than the screen — the root cause of
     "no es responsive" (the layout looked zoomed-out with a horizontal scrollbar). */
  body { overflow-x: hidden; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(290px, 86vw); z-index: 1500; transform: translateX(-110%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: block; }
  /* Let the header stack: the actions row carries width:100% and would otherwise overflow
     a non-wrapping flex row. */
  .topbar { flex-wrap: wrap; }
  .topbar-title { min-width: 0; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .detail-body { grid-template-columns: 1fr; }
  /* Keep the prev/next arrows on-screen inside the full-width modal. */
  .detail-nav.prev { left: 8px; }
  .detail-nav.next { right: 8px; }
  .detail-nav { width: 40px; height: 40px; font-size: 22px; opacity: .92; }
}
@media (max-width: 640px) {
  .content { padding: 18px 14px 40px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .spec-grid { grid-template-columns: 1fr; }
  .edit-form { grid-template-columns: 1fr; }
  /* Full-screen detail modal on phones: override Bootstrap's centred dialog margins and
     the desktop max-width so the ficha uses the whole viewport (reported UX bug). */
  #detailModal .modal-dialog { max-width: 100%; width: 100%; min-height: 100%; margin: 0; }
  /* `dvh` tracks the *visible* viewport so the ficha is not cut off behind the mobile
     browser's address bar (100vh overshoots the visible area on iOS/Android). vh stays as
     a fallback for older browsers. */
  #detailModal .detail-content { max-height: 100vh; height: 100vh; max-height: 100dvh; height: 100dvh; border-radius: 0; border-left: 0; border-right: 0; }
  .detail-body { padding: 18px 16px; gap: 16px; }
  /* Keep the stamp image CONTAINED in its own box: an auto-height frame plus a capped
     inner image so a tall stamp can never overflow and sit on top of the description
     text below it (reported overlap bug). */
  .detail-gallery .main-img { height: auto; min-height: 200px; overflow: hidden; }
  .detail-gallery .main-img img { max-height: 260px; }
  /* Price rows stack their cond / amount / source so nothing is cut off on a phone. */
  .price-row { grid-template-columns: 1fr auto; }
  .price-cond { grid-column: 1 / -1; }
  .price-src { justify-self: end; }
  .topbar-title h1 { font-size: 19px; }
  /* Each control takes the full row and stays inside the viewport (no horizontal scroll). */
  .topbar-actions { width: 100%; gap: 8px; }
  .mine-filter, .sort-filter, .scott-filter, .year-filter { flex-wrap: wrap; width: 100%; justify-content: flex-start; }
  .pager button { min-width: 34px; height: 36px; font-size: 12px; padding: 0 6px; }
}
