/* Panel de administración — María Market */
:root {
  --brand: #0075C5;
  --ink: #0B1420;
  --ink-2: #4B5868;
  --line: #DAE2EA;
  --bg: #EEF2F6;
  --card: #FFFFFF;
  --danger: #B42318;
  --lime: #3BA3EA;
  --r: 14px;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Figtree", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--body); color: var(--ink); background: var(--bg); }
h1, h2 { font-family: var(--display); line-height: 1.15; margin: 0 0 .6em; }
h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; font-weight: 600; }
a { color: var(--brand); }
img { max-width: 100%; display: block; }
.muted { color: var(--ink-2); }
.small, small { font-size: .85rem; }
[hidden] { display: none !important; }

/* Formularios */
label, .field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; margin-bottom: 16px; }
label small, .field small { font-weight: 400; color: var(--ink-2); }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: #fff;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; }
input[type=checkbox] { width: auto; accent-color: var(--brand); }
input[type=color] { width: 54px; height: 40px; padding: 3px; }
.row-check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-family: var(--display); font-weight: 600; font-size: 1.05rem; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 .92rem var(--body); padding: 10px 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: #FEF3F2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 6px 12px; font-size: .84rem; }
.btn.icon { padding: 6px 10px; }
.btn.block { width: 100%; margin-bottom: 8px; }
.btn:disabled { opacity: .35; cursor: default; }

.alert { padding: 12px 16px; border-radius: 10px; margin: 0 0 16px; font-weight: 500; }
.alert.ok { background: #E7F6EC; color: #0B5132; }
.alert.err { background: #FEF3F2; color: #912018; }

/* Login / instalación */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--card); padding: 32px 28px; border-radius: 22px; box-shadow: 0 20px 60px -30px rgba(20,35,27,.35); }
.auth-card.wide { max-width: 560px; }
.auth-card h1 { font-size: 1.7rem; }
.auth-logo { background: #000; margin: -32px -28px 24px; padding: 18px 24px; border-radius: 22px 22px 0 0; display: grid; place-items: center; }
.auth-logo img { width: min(100%, 320px); height: auto; }
.pw-field { position: relative; margin: -10px 0 16px; }
.pw-field input { padding-right: 48px; }
.pw-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); cursor: pointer; }
.pw-toggle:hover { color: var(--ink); background: var(--bg); }
.pw-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-toggle .eye-off, .pw-toggle[aria-pressed="true"] .eye { display: none; }
.pw-toggle[aria-pressed="true"] .eye-off { display: block; }
.back { display: block; text-align: center; margin-top: 10px; font-size: .9rem; }

/* Estructura */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: #000; color: #E8EFEA; padding: 22px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font: 700 1.15rem var(--display); padding: 0 8px 18px; }
.brand img { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; background: #fff; }
.brand.has-logo { padding: 0 0 12px; margin-left: -4px; }
.brand.has-logo img { width: 100%; height: auto; max-height: 96px; background: none; border-radius: 0; }
.mark { width: 36px; height: 36px; border-radius: 10px; background: var(--lime); color: var(--ink); display: grid; place-items: center; font-size: 1.2rem; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #C9D6CE; text-decoration: none; font-weight: 500; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.1); color: #fff; }
.side nav a.on svg { stroke: var(--lime); }
.side svg, .menu-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.view-store { margin-top: auto; color: var(--lime); font-weight: 600; padding: 10px 12px; text-decoration: none; }
.me { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid rgba(255,255,255,.1); padding: 14px 8px 0; }
.me span { display: flex; flex-direction: column; font-weight: 600; }
.me small { color: #9FB1A6; font-weight: 400; }
.me a { color: #C9D6CE; font-size: .88rem; }

.main { padding: 28px clamp(16px, 4vw, 44px) 60px; max-width: 1180px; width: 100%; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.top h1 { margin: 0; }
.menu-btn { display: none; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer; color: var(--ink); }

.panel { background: var(--card); border-radius: var(--r); padding: 22px; margin-bottom: 18px; border: 1px solid var(--line); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.empty { color: var(--ink-2); margin: 0; }
.empty-state { text-align: center; padding: 48px 24px; }

/* Inicio */
.share { background: #000; color: #fff; border-radius: 20px; padding: 26px; margin-bottom: 18px; }
.share .muted { color: #B6C6BC; margin-top: -4px; }
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.copy-row input { flex: 1 1 260px; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #fff; }
.share .alert { margin: 14px 0 0; }
.share .btn:not(.primary) { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.share .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.stat b { display: block; font: 700 2rem var(--display); }
.stat span { color: var(--ink-2); font-size: .88rem; }
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }

/* Etiquetas */
.tag { display: inline-block; font-size: .76rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #EEF2EF; color: var(--ink-2); font-style: normal; text-transform: capitalize; }
.tag.s-available, .t-entregado { background: #E3F6EA; color: #137A3A; }
.tag.s-low, .t-nuevo { background: #FFF4D6; color: #7A4B00; }
.tag.s-order, .t-confirmado { background: #E6F0FF; color: #1D4ED8; }
.tag.s-out, .tag.off, .t-cancelado { background: #FDECEC; color: #C0262D; }
.tag.star { background: #DCEEFC; color: #00548E; }

/* Lista de productos */
.toolbar { display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.filters input { max-width: 260px; }
.filters select { width: auto; }
.plist { display: flex; flex-direction: column; gap: 10px; }
.pitem { display: grid; grid-template-columns: 76px 1fr auto; gap: 16px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.pitem.is-off { opacity: .62; }
.thumb { width: 76px; height: 76px; border-radius: 10px; overflow: hidden; background: var(--bg); display: grid; place-items: center; color: var(--ink-2); font-size: .75rem; text-decoration: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.pname { font-weight: 600; color: var(--ink); text-decoration: none; font-size: 1.02rem; }
.pmeta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 4px 0 2px; font-size: .9rem; }
.pmeta s { color: var(--ink-2); }
.pactions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pactions form { margin: 0; }

/* Editor */
.editor { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.col-side { position: sticky; top: 20px; }
.sticky-actions { margin-top: 4px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-bottom: 12px; }
.gallery:empty { display: none; }
.gallery figure { margin: 0; position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--bg); cursor: grab; border: 2px solid transparent; }
.gallery figure:first-child { border-color: var(--brand); }
.gallery figure:first-child::after { content: "Portada"; position: absolute; top: 6px; left: 6px; background: var(--brand); color: #fff; font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.gallery.new figure:first-child { border-color: transparent; }
.gallery.new figure:first-child::after { content: none; }
.gallery figure.dragging { opacity: .4; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.gallery .rm { position: absolute; bottom: 6px; left: 6px; right: 6px; margin: 0; flex-direction: row; gap: 6px; align-items: center; justify-content: center; background: rgba(255,255,255,.92); border-radius: 8px; padding: 4px; font-size: .78rem; }
.gallery figure:has(input:checked) img { opacity: .3; filter: grayscale(1); }
.drop { position: relative; border: 2px dashed var(--line); border-radius: 14px; padding: 26px 16px; text-align: center; align-items: center; cursor: pointer; font-weight: 500; transition: border-color .15s, background .15s; }
.drop.over, .drop:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 5%, #fff); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.switch { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 40px; height: 23px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { outline: 2.5px solid var(--brand); outline-offset: 2px; }
.stock-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.stock-pick legend { font: 600 .9rem var(--body); margin-bottom: 6px; }
.stock-pick .opt { margin: 0; position: relative; }
.stock-pick input { position: absolute; opacity: 0; }
.stock-pick span { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 8px; border: 1.5px solid var(--line); border-radius: 10px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.stock-pick i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.stock-pick .in input:checked + span { border-color: #1E9E50; background: #E3F6EA; color: #137A3A; }
.stock-pick .out input:checked + span { border-color: #D93A40; background: #FDECEC; color: #C0262D; }
.stock-pick input:focus-visible + span { outline: 2.5px solid var(--brand); outline-offset: 2px; }
.color-row { display: flex; align-items: center; gap: 10px; }
.logo-prev { max-height: 70px; width: auto; border-radius: 8px; background: var(--bg); padding: 6px; }

/* Categorías */
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form input[name=name] { flex: 1 1 200px; width: auto; }
.emoji-in { width: 58px !important; text-align: center; font-size: 1.25rem; cursor: pointer; caret-color: transparent; }
.emoji-in:placeholder-shown { border-style: dashed; }
.emoji-in::placeholder { color: var(--ink-2); font-size: 1.3rem; }
.emoji-pop { position: absolute; z-index: 40; width: 316px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: 0 18px 40px -16px rgba(11,20,32,.35); }
.emoji-pop p { margin: 0 0 8px; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.emoji-pop .grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; margin-bottom: 10px; }
.emoji-pop .grid button { font-size: 1.3rem; line-height: 1; padding: 6px 0; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.emoji-pop .grid button:hover, .emoji-pop .grid button:focus-visible { background: var(--bg) !important; }
.emoji-pop .grid button[aria-pressed="true"] { background: #DCEEFC !important; }
.emoji-pop .clear { font: 600 .82rem var(--body); color: var(--ink-2); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }
.cat-list { list-style: none; padding: 0; margin: 0; }
.cat-list li { padding: 10px 0; border-top: 1px solid var(--line); }

/* Usuarios */
.grid-form { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 12px; align-items: end; }
.grid-form label { margin: 0; }
.grid-form label:has(small) { margin-bottom: -20px; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .82rem; color: var(--ink-2); font-weight: 600; padding: 8px; }
.tbl td { padding: 12px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.row-actions { text-align: right; }
.pop { position: relative; display: inline-block; }
.pop summary { list-style: none; }
.pop summary::-webkit-details-marker { display: none; }
.pop > div { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; width: 260px; box-shadow: 0 12px 30px -12px rgba(20,35,27,.3); display: flex; flex-direction: column; gap: 10px; text-align: left; }
.pop form { display: flex; flex-direction: column; gap: 6px; margin: 0; }

/* Pedidos */
.tabs { display: flex; gap: 6px; margin: 0 0 16px; overflow-x: auto; }
.tabs a { padding: 7px 14px; border-radius: 99px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.tabs a.on { background: var(--ink); color: #fff; }
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.order { margin: 0; }
.order header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.order ul { list-style: none; padding: 0; margin: 14px 0; }
.order li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: .93rem; }
.order footer { display: flex; justify-content: space-between; align-items: center; }
.order footer form { margin: 0; }
.order .note { background: var(--bg); padding: 10px 12px; border-radius: 10px; font-size: .9rem; margin: 0 0 12px; }
.status-form { margin: 0; }
.status-form select { width: auto; padding: 6px 10px; font-weight: 600; font-size: .85rem; }
.st-nuevo { background: #FFF4D6; } .st-confirmado { background: #E6F0FF; } .st-entregado { background: #E7F6EC; } .st-cancelado { background: #FEF3F2; }

@media (max-width: 960px) {
  .editor, .split { grid-template-columns: 1fr; }
  .col-side { position: static; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid-form label:has(small) { margin-bottom: 0; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .25s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .menu-btn { display: inline-flex; }
  .main { padding-top: 16px; }
  .top h1 { font-size: 1.35rem; }
  .pitem { grid-template-columns: 64px 1fr; }
  .thumb { width: 64px; height: 64px; }
  .pactions { grid-column: 1 / -1; justify-content: flex-start; }
  .grid2, .grid-form { grid-template-columns: 1fr; }
  .filters input { max-width: none; }
  .orders { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.tag.s-available, .tag.s-out { text-transform: none; }
