:root {
  --bg: #f4f1e8; --surface: #fff; --ink: #26251f; --muted: #7c7668;
  --olive: #74845c; --olive-dark: #4e5a33; --tint: #eef1e4;
  --gold: #d9a43f; --danger: #c0392b; --border: #e3dccb; --radius: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Poppins", system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
aside {
  background: var(--olive-dark); color: #f0eee2; padding: 20px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
aside .brand { padding: 4px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.14); margin-bottom: 12px; }
aside .brand img { height: 34px; width: auto; display: block; }
aside .brand span { font-size: 10px; letter-spacing: 2px; opacity: .7; text-transform: uppercase; }
aside nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  font-size: 13.5px; opacity: .88; border-left: 3px solid transparent;
}
aside nav a:hover { background: rgba(255,255,255,.08); opacity: 1; }
aside nav a.on { background: rgba(255,255,255,.12); border-left-color: var(--gold); opacity: 1; font-weight: 600; }
aside .sep { margin: 12px 20px; border-top: 1px solid rgba(255,255,255,.14); }

main { padding: 26px 34px; max-width: 1220px; }
.pagetitle { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.pagetitle h1 { font-size: 22px; font-weight: 800; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; background: var(--olive);
  color: #fff; border: 0; border-radius: 999px; padding: 9px 20px;
  font-size: 13px; font-weight: 600;
}
.btn:hover { background: var(--olive-dark); }
.btn.ghost { background: transparent; color: var(--olive-dark); border: 1.5px solid var(--olive); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 14px; font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat b { font-size: 24px; display: block; color: var(--olive-dark); }
.stat span { color: var(--muted); font-size: 12.5px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
th { background: var(--tint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--olive-dark); }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #faf8f1; }
td img.thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.status {
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 11px;
  background: var(--tint); color: var(--olive-dark); white-space: nowrap;
}
.status.cancelled, .status.failed, .status.refunded { background: #f7e4e1; color: var(--danger); }
.status.pendiente, .status.demo, .status.on-hold { background: #f5ecd7; color: #9a7415; }

form.inline { display: inline; }
input, select, textarea {
  font-family: inherit; font-size: 13.5px; border: 1.5px solid var(--border);
  border-radius: 9px; padding: 8px 11px; background: var(--surface); outline: none;
}
input:focus, textarea:focus { border-color: var(--olive); }
textarea { width: 100%; min-height: 130px; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.field input, .field select { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type=search] { min-width: 240px; }
.msg { background: var(--tint); border-radius: 9px; padding: 10px 14px; color: var(--olive-dark); font-size: 13px; margin-bottom: 14px; }
.pager { display: flex; gap: 8px; margin-top: 14px; }
.pager a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 12.5px; }
.pager a.on { background: var(--olive); color: #fff; border-color: var(--olive); }

.mediagrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.mediagrid figure { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.mediagrid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.mediagrid figcaption { font-size: 10.5px; padding: 6px 8px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* gestor de imágenes del producto */
.img-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.img-thumb {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
  background: #fff;
}
.img-thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.img-thumb:first-child { border: 2px solid var(--gold); }
.portada-tag {
  position: absolute;
  top: 5px;
  left: 5px;
  background: var(--gold);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  z-index: 2;
}
.img-acts { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; }
.img-acts button {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 22px;
  height: 22px;
  font-size: 11px;
  line-height: 1;
}
.img-acts .rm-img:hover { color: var(--danger); }
.img-acts .mk-cover:hover { color: var(--gold); }

/* popup mediateca */
.mm-bg {
  position: fixed;
  inset: 0;
  background: rgba(38, 37, 31, 0.55);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
}
.mm-bg[hidden] { display: none; }
.mm-box {
  background: var(--surface);
  border-radius: 14px;
  width: min(940px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mm-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.mm-head input { flex: 1; }
.mm-head .modal-x { background: none; border: 0; font-size: 16px; color: var(--muted); cursor: pointer; }
.mm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  padding: 16px 18px;
  overflow-y: auto;
}
.mm-grid .mm-item {
  height: 146px;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
}
.mm-grid .mm-item.sel { border-color: var(--olive); box-shadow: 0 0 0 2px var(--olive-dark); }
.mm-grid .mm-item img {
  width: 100%;
  height: 118px;
  object-fit: cover;
  display: block;
  background: var(--tint);
}
.mm-grid .mm-item span {
  display: block;
  font-size: 9.5px;
  color: var(--muted);
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mm-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.pk-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12.5px;
  background: var(--surface);
}
.pk-list label { display: block; padding: 3px 0; cursor: pointer; }
.pk-list label:hover { color: var(--olive-dark); }

/* constructor de productos: pestañas verticales */
#ptabs a {
  display: block;
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  border-left: 3px solid transparent;
  user-select: none;
}
#ptabs a.on { background: var(--surface); border-left-color: var(--olive); font-weight: 600; }
#ptabs a:hover { background: rgba(255, 255, 255, 0.6); }

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px 44px; width: 360px; text-align: center; }
.login-card img { height: 60px; margin-bottom: 14px; }
.login-card h1 { font-size: 18px; margin-bottom: 18px; }
.login-card input { width: 100%; margin-bottom: 12px; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; }

.notes { list-style: none; }
.notes li { border-left: 3px solid var(--olive); background: var(--tint); border-radius: 0 9px 9px 0; padding: 8px 12px; margin-bottom: 8px; font-size: 12.5px; }
.notes li span { display: block; color: var(--muted); font-size: 11px; }
pre.out { background: #26251f; color: #d9e3c8; border-radius: 10px; padding: 16px; font-size: 12px; overflow-x: auto; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } aside { position: static; height: auto; } main { padding: 18px; } .grid2, .grid3 { grid-template-columns: 1fr; } }
