/* ==========================================================================
   Bosque Interior — panel de administración
   Se carga después de styles.css (reutiliza tokens, botones, campos y tags).
   ========================================================================== */
body.admin { background: #eef2ea; }
.adm { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

/* barra lateral */
.adm-side {
  background: var(--deep); color: var(--on-deep); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh; padding: 20px 14px; overflow-y: auto;
}
.adm-brand { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 18px; border-bottom: 1px solid rgba(238, 245, 234, .12); margin-bottom: 14px; }
.adm-brand .logo { color: var(--paper); font-size: 17px; }
.adm-brand .logo small { color: var(--on-deep-mute); letter-spacing: .08em; }
.adm-close { display: none; color: var(--paper); }
.adm-nav { display: grid; gap: 2px; }
.adm-nav-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--on-deep-mute); padding: 14px 12px 6px; }
.adm-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-decoration: none;
  color: var(--on-deep-mute); font-size: 15px; font-weight: 500; transition: background .2s, color .2s; position: relative;
}
.adm-nav a svg { width: 20px; height: 20px; flex: none; }
.adm-nav a:hover { background: rgba(255, 255, 255, .07); color: var(--paper); }
.adm-nav a[aria-current="page"] { background: rgba(255, 207, 92, .14); color: var(--sun); }
.adm-nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--sun); }
.adm-nav a.is-locked { opacity: .45; }
.adm-nav a.is-locked::after { content: ""; width: 14px; height: 14px; margin-left: auto; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E") center / contain no-repeat; }
.adm-nav .count { margin-left: auto; background: var(--clay); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 7px; min-width: 20px; text-align: center; }
.adm-side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(238, 245, 234, .12); display: grid; gap: 2px; }
.adm-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 0; background: none; color: var(--on-deep-mute); text-decoration: none; font-size: 14px; width: 100%; text-align: left; }
.adm-link:hover { background: rgba(255, 255, 255, .07); color: var(--paper); }
.adm-link svg { width: 18px; height: 18px; }
.adm-backdrop { display: none; }

/* área principal */
.adm-main { min-width: 0; display: flex; flex-direction: column; }
.adm-top { display: flex; align-items: center; gap: 16px; padding: 18px clamp(16px, 3vw, 36px); background: rgba(238, 242, 234, .92); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); }
@supports (backdrop-filter: blur(10px)) { .adm-top { background: rgba(238, 242, 234, .75); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); } }
.adm-top h1 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin: 0; }
.adm-crumb { margin: 0 0 2px; font-size: 13px; color: var(--mute); }
.adm-menu { display: none; }
.adm-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.adm-user-txt { display: grid; justify-items: end; gap: 4px; font-size: 14px; }
.adm-user .avatar { width: 42px; height: 42px; font-size: 15px; }
.adm-content { padding: clamp(16px, 3vw, 36px); display: grid; gap: 20px; align-content: start; }
.adm-loading { display: flex; gap: 10px; align-items: center; color: var(--mute); }

/* bloques */
.box { background: var(--paper); border-radius: 18px; border: 1px solid var(--line); padding: clamp(16px, 2.4vw, 24px); min-width: 0; }
.box h2 { font-size: 1.15rem; margin: 0 0 4px; letter-spacing: -0.01em; }
.box-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.box-head p { margin: 0; color: var(--mute); font-size: 14px; }
.adm-grid { display: grid; gap: 20px; align-content: start; }
.adm-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.adm-grid-3 { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 1100px) { .adm-grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .adm-grid-2 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px) { .kpis { grid-template-columns: 1fr; } }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; display: grid; gap: 6px; position: relative; overflow: hidden; }
.kpi span { font-size: 13px; color: var(--mute); display: flex; align-items: center; gap: 8px; }
.kpi span svg { width: 16px; height: 16px; color: var(--accent); }
.kpi strong { font: 800 clamp(1.5rem, 2.6vw, 2rem)/1.1 var(--font-display); letter-spacing: -0.03em; }
.kpi small { font-size: 13px; color: var(--accent-ink); }
.kpi small.warn { color: var(--clay); }
.kpi::after { content: ""; position: absolute; width: 90px; height: 90px; right: -30px; top: -30px; background: var(--accent-soft); border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%; opacity: .7; }

/* gráfica */
.chart { width: 100%; height: 220px; display: block; }
.chart .bar { fill: var(--accent); transition: fill .2s; }
.chart .bar:hover { fill: var(--accent-ink); }
.chart .bar.today { fill: var(--sun); }
.chart text { font: 11px var(--font-body); fill: var(--mute); }
.chart .grid-line { stroke: var(--line); }

/* tablas */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.table th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f7f9f4; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .thumb { display: flex; align-items: center; gap: 12px; }
.table .thumb img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--bg-2); flex: none; }
.table .thumb strong { display: block; }
.table .thumb small { color: var(--mute); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions .icon-btn { width: 36px; height: 36px; }
.row-actions .icon-btn svg { width: 18px; height: 18px; }
.row-actions .icon-btn.danger:hover { background: #fbe4e1; color: var(--danger); }
.mini-select { min-height: 34px; padding: 4px 30px 4px 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper); font-size: 13px; font-weight: 600; }
.stock-low { color: var(--clay); font-weight: 700; }
.stock-out { color: var(--danger); font-weight: 700; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search-field { max-width: 300px; }
.toolbar .chip { padding: 6px 14px; font-size: 13px; }
.switch { position: relative; width: 42px; height: 24px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; transition: .25s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .25s var(--ease-spring); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--sun); outline-offset: 2px; }

/* listas */
.list { display: grid; gap: 0; }
.list-item { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item strong { display: block; font-size: 14px; }
.list-item small { color: var(--mute); font-size: 13px; }
.time-pill { background: var(--accent-soft); color: var(--accent-ink); border-radius: 12px; padding: 8px 10px; text-align: center; font-weight: 700; font-size: 14px; min-width: 64px; line-height: 1.1; }
.time-pill small { display: block; font-weight: 500; color: var(--accent-ink); font-size: 11px; text-transform: uppercase; }
.day-group { margin-top: 8px; }
.day-group h3 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); margin: 18px 0 4px; font-family: var(--font-body); font-weight: 600; }
.msg { border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 8px; background: var(--paper); }
.msg.is-unread { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 157, 99, .1); }
.msg header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.msg header .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.msg p { margin: 0; color: var(--ink-soft); }
.msg footer { display: flex; gap: 8px; flex-wrap: wrap; }

/* editor de contenido */
.cms-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .cms-grid { grid-template-columns: 1fr; } }
.cms-group + .cms-group { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.cms-group h3 { font-size: 1rem; margin-bottom: 14px; display: flex; gap: 8px; align-items: center; }
.cms-group h3 svg { width: 18px; height: 18px; color: var(--accent); }
.preview-frame { border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); position: sticky; top: 100px; }
.preview-bar { display: flex; gap: 6px; align-items: center; padding: 10px 12px; background: var(--paper); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--mute); }
.preview-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.preview-bar span { margin-left: 8px; background: var(--bg); border-radius: 999px; padding: 3px 12px; }
.preview-promo { background: var(--deep); color: var(--on-deep); font-size: 11px; text-align: center; padding: 6px 10px; }
.preview-hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; padding: 22px 18px; align-items: center; }
.preview-hero .hand { font-size: 1.1rem; }
.preview-hero h4 { font: 800 1.7rem/1 var(--font-display); letter-spacing: -0.03em; margin: 6px 0 10px; }
.preview-hero h4 em { font-style: normal; color: var(--accent); }
.preview-hero p { font-size: 12px; color: var(--ink-soft); margin: 0; }
.preview-hero img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%; }
.img-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; max-height: 210px; overflow-y: auto; padding: 4px; }
.img-picker label { position: relative; cursor: pointer; }
.img-picker input { position: absolute; opacity: 0; }
.img-picker img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 3px solid transparent; transition: border-color .2s; }
.img-picker input:checked + img { border-color: var(--accent); }
.img-picker input:focus-visible + img { outline: 3px solid var(--sun); }

.rte { border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--paper); }
.rte-bar { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--bg); flex-wrap: wrap; }
.rte-bar button { border: 0; background: none; min-width: 34px; height: 32px; border-radius: 8px; font-weight: 700; font-size: 14px; }
.rte-bar button:hover { background: var(--paper); }
.rte-area { min-height: 220px; max-height: 360px; overflow-y: auto; padding: 14px 16px; outline: none; font-size: 15px; line-height: 1.6; }
.rte-area h2 { font-size: 1.25rem; margin: 1em 0 .4em; }
.rte-area:focus { box-shadow: inset 0 0 0 2px rgba(31, 157, 99, .3); }

/* permisos */
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-yes { color: var(--accent); font-weight: 700; }
.perm-no { color: var(--line-strong); }

/* base de datos */
.db-tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.db-table { border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 4px; background: var(--paper); }
.db-table svg { width: 22px; height: 22px; color: var(--accent); }
.db-table strong { font: 800 1.6rem/1 var(--font-display); }
.db-table code { font-size: 13px; color: var(--ink-soft); }
.schema { font: 13px/1.6 ui-monospace, "SF Mono", Menlo, monospace; background: #0f2219; color: #d5efdf; border-radius: 14px; padding: 18px; overflow-x: auto; white-space: pre; margin: 0; }
.schema b { color: var(--sun); font-weight: 600; }

/* sin acceso */
.denied { text-align: center; padding: clamp(32px, 6vw, 72px) 20px; }
.denied .icon-blob { margin: 0 auto 18px; width: 80px; height: 80px; }
.denied .icon-blob svg { width: 34px; height: 34px; }
.denied h2 { font-size: 1.5rem; }
.denied p { color: var(--ink-soft); max-width: 46ch; margin-inline: auto; }

/* modal */
.adm-modal { width: min(720px, calc(100% - 24px)); }
.adm-modal-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.adm-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.adm-modal-head h2 { font-size: 1.3rem; margin: 0; }
.adm-modal-body { padding: 20px 22px; overflow-y: auto; }
.adm-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--bg); }
.detail-dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 14px; margin: 0 0 16px; }
.detail-dl dt { color: var(--mute); }
.detail-dl dd { margin: 0; font-weight: 600; }

/* responsive */
@media (max-width: 960px) {
  .adm { grid-template-columns: 1fr; }
  .adm-side { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); z-index: 50; transform: translateX(-105%); transition: transform .45s var(--ease-out); }
  .adm.side-open .adm-side { transform: none; box-shadow: var(--shadow-3); }
  .adm-backdrop { display: block; position: fixed; inset: 0; background: rgba(8, 30, 22, .5); z-index: 45; opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; }
  .adm.side-open .adm-backdrop { opacity: 1; visibility: visible; transition: opacity .3s; }
  .adm-menu, .adm-close { display: inline-grid; }
  .adm-user-txt { display: none; }
}
@media (max-width: 560px) {
  .preview-hero { grid-template-columns: 1fr; }
  .adm-top { padding: 12px 14px; gap: 8px; }
}
.adm-section { display: grid; gap: 20px; align-content: start; min-width: 0; }
