/* Panel de administración — tema oscuro neutro con acento dorado */
:root {
  --bg: #111214;
  --surface: #191b1f;
  --surface-2: #202329;
  --line: #2c3038;
  --line-strong: #3a3f49;
  --text: #ececee;
  --muted: #9a9fa9;
  --accent: #FFBF00;
  --accent-ink: #1a1400;
  --ok: #46c586;
  --warn: #f0a93b;
  --err: #f0655d;
  --info: #62a8f5;
  --radius: 10px;
  --side-w: 232px;
  --top-h: 52px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; text-wrap: balance; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
small { font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Estructura ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-sp { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); display: inline-block; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-btn { display: none; width: 40px; height: 40px; border-radius: 8px; cursor: pointer; flex-direction: column; justify-content: center; align-items: center; gap: 4px; }
.nav-btn span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; }
.nav-btn:hover { background: var(--surface-2); }

.sidebar {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--side-w); z-index: 20;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar nav { padding: 8px 10px; flex: 1; }
.nav-group { padding: 14px 10px 6px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 8px; color: var(--text); font-size: 14.5px;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.is-active { background: rgba(255, 191, 0, .12); color: var(--accent); font-weight: 600; }
.nav-count { background: var(--err); color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.sidebar-user { font-size: 12.5px; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-backdrop { display: none; }

.main { margin-left: var(--side-w); padding: calc(var(--top-h) + 20px) 24px 60px; max-width: 1500px; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 16px; }

@media (max-width: 900px) {
  .nav-btn { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .18s ease; width: min(82vw, 290px); box-shadow: 8px 0 30px rgba(0, 0, 0, .5); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: var(--top-h) 0 0 0; background: rgba(0, 0, 0, .55); z-index: 15; }
  .main { margin-left: 0; padding: calc(var(--top-h) + 14px) 12px 60px; }
  .page-title { font-size: 19px; }
  .topbar-store { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Tarjetas y rejillas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card > :last-child { margin-bottom: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 14px 16px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.stat-accent .stat-value { color: var(--accent); }
.stat-warn { border-color: rgba(240, 101, 93, .55); }
a.stat { color: inherit; display: block; }
a.stat:hover { text-decoration: none; border-color: var(--line-strong); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 16px; }
.card .table-wrap { margin-bottom: 0; }
.card-flush .table-wrap { border: 0; border-radius: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table th { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); position: sticky; top: 0; }
.table th a { color: inherit; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, .025); }
.table td.wrap, .table th.wrap { white-space: normal; min-width: 180px; overflow-wrap: anywhere; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-bottom: 0; }
.table-edit td { padding: 6px 6px; }
.table-edit .input { padding: 7px 8px; min-height: 36px; font-size: 13.5px; }
.table-edit tr.is-dirty { background: rgba(255, 191, 0, .07); }
.table-edit tr.is-off { opacity: .6; }
.w-xs { width: 70px; min-width: 70px; } .w-sm { width: 96px; min-width: 96px; } .w-md { width: 140px; min-width: 140px; } .w-lg { width: 210px; min-width: 210px; }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; font-size: 14.5px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #292d35; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #ffcb33; }
.btn-danger { background: transparent; border-color: rgba(240, 101, 93, .6); color: var(--err); }
.btn-danger:hover { background: rgba(240, 101, 93, .12); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Insignias ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; border: 1px solid transparent; }
.badge-ok { color: var(--ok); background: rgba(70, 197, 134, .12); border-color: rgba(70, 197, 134, .3); }
.badge-warn { color: var(--warn); background: rgba(240, 169, 59, .12); border-color: rgba(240, 169, 59, .3); }
.badge-err { color: var(--err); background: rgba(240, 101, 93, .12); border-color: rgba(240, 101, 93, .3); }
.badge-info { color: var(--info); background: rgba(98, 168, 245, .12); border-color: rgba(98, 168, 245, .3); }
.badge-muted { color: var(--muted); background: rgba(154, 159, 169, .1); border-color: rgba(154, 159, 169, .25); }

/* ---------- Formularios ---------- */
.form-row { margin-bottom: 14px; }
.form-row > label, .label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.form-row .help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: #0d0e10; color: var(--text); font: inherit; font-size: 15px;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; min-height: 220px; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 191, 0, .18); }
.input::placeholder { color: #666b75; }
.input[readonly] { color: var(--muted); background: var(--surface-2); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14.5px; min-height: 32px; }
.check input, input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .input { width: auto; min-width: 130px; flex: 0 1 auto; }
.toolbar .grow { flex: 1 1 200px; }
.toolbar .field { display: flex; flex-direction: column; gap: 4px; }
.toolbar .field > .grow { flex: 0 0 auto; width: 100%; }   /* dentro de un campo, el control no debe estirarse a lo alto */
.toolbar .field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sticky-save { position: sticky; bottom: 0; z-index: 5; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 14px 0 10px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }
@media (max-width: 560px) {
  .toolbar .input, .toolbar .field, .toolbar .btn { width: 100%; flex: 1 1 100%; }
  .actions .btn { flex: 1 1 auto; }
}

/* ---------- Mensajes ---------- */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-weight: 500; overflow-wrap: anywhere; }
.flash-ok { color: #b9f0d3; background: rgba(70, 197, 134, .1); border-color: rgba(70, 197, 134, .4); }
.flash-error { color: #ffc9c5; background: rgba(240, 101, 93, .1); border-color: rgba(240, 101, 93, .45); }
.flash-warn { color: #ffe0ad; background: rgba(240, 169, 59, .1); border-color: rgba(240, 169, 59, .45); }
.notice { padding: 11px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface-2); margin-bottom: 12px; font-size: 14px; }
.notice-warn { border-color: rgba(240, 169, 59, .5); background: rgba(240, 169, 59, .08); }
.notice-err { border-color: rgba(240, 101, 93, .5); background: rgba(240, 101, 93, .08); }

/* ---------- Varios ---------- */
.muted { color: var(--muted); }
.pos { color: var(--ok); } .neg { color: var(--err); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { background: #0d0e10; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow: auto; max-height: 420px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 10px; font-size: 12.5px; }
.pre-log { white-space: pre; overflow-wrap: normal; max-height: 560px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 16px; }
.pager a, .pager-cur { min-width: 38px; min-height: 38px; padding: 6px 11px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; }
.pager a:hover { border-color: var(--line-strong); text-decoration: none; }
.pager-cur { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.pager .muted { margin-left: 6px; font-size: 13px; }
.dl { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 7px 14px; margin: 0; font-size: 14.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 600; }
.chip:hover { border-color: var(--line-strong); text-decoration: none; }
.chip.is-active { background: rgba(255, 191, 0, .14); border-color: var(--accent); color: var(--accent); }
details.box { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; background: var(--surface-2); }
details.box > summary { padding: 11px 14px; cursor: pointer; font-weight: 600; list-style-position: inside; }
details.box > .box-body { padding: 4px 14px 14px; }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { padding: 9px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.notes li:last-child { border-bottom: 0; }
.notes .meta { font-size: 12px; color: var(--muted); }
.thumb { width: 34px; height: 42px; object-fit: cover; border-radius: 5px; background: var(--surface-2); vertical-align: middle; }
.qr-img { max-width: 240px; width: 100%; background: #fff; padding: 8px; border-radius: 8px; display: block; }
.secret code { letter-spacing: .02em; }
.todo { list-style: none; padding: 0; margin: 0; }
.todo li { padding: 9px 0 9px 22px; border-bottom: 1px solid var(--line); position: relative; }
.todo li:last-child { border-bottom: 0; }
.todo li::before { content: ""; position: absolute; left: 4px; top: 17px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.todo li.is-err::before { background: var(--err); }

/* ---------- Acceso ---------- */
.login-body { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; padding: 26px 22px; margin: 0; }
.login-box h1 { font-size: 18px; margin-bottom: 18px; }
.login-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--muted); margin-bottom: 6px; font-size: 14px; }

/* Multimedia y encuadre de imágenes */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item { border: 1px solid var(--border, #333); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.media-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #222; display: block; }
.media-name { font-size: 11px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.imgpick { border: 1px solid var(--border, #333); border-radius: 14px; padding: 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: start; }
.imgpick-prev { overflow: hidden; border-radius: 12px; background: #1b1b22; border: 1px solid var(--border, #333); }
.imgpick-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imgpick-prev.card { width: 132px; aspect-ratio: 4 / 5; }
.imgpick-prev.banner { width: 260px; max-width: 100%; aspect-ratio: 16 / 6; }
.imgpick-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.imgpick input[type="range"] { width: 100%; }
.imgpick .rng { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; align-items: center; font-size: 12.5px; margin-top: 4px; }
.media-dialog { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .7); display: none; align-items: center; justify-content: center; padding: 16px; }
.media-dialog.open { display: flex; }
.media-dialog-box { background: var(--surface, #1c1c24); color: inherit; border-radius: 16px; width: min(900px, 100%); max-height: 86vh; display: flex; flex-direction: column; border: 1px solid var(--border, #333); }
.media-dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border, #333); font-weight: 700; }
.media-dialog-body { padding: 14px 16px; overflow-y: auto; }
.media-dialog .media-item { cursor: pointer; }
.media-dialog .media-item:hover { outline: 2px solid var(--accent, #ffb400); }
@media (max-width: 640px) { .imgpick { grid-template-columns: 1fr; } }
