.admin-body {
  background:
    radial-gradient(circle at 72% -10%, rgba(28, 105, 220, .12), transparent 34rem),
    var(--bg);
  min-height: 100vh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.admin-shell { width: min(1220px, calc(100% - 28px)); margin: 0 auto; padding: 24px 0 40px; }
.muted { color: var(--muted); }
.compact-copy { margin: 5px 0 0; max-width: 68ch; font-size: .88rem; line-height: 1.45; }
.optional { color: #587193; font-size: .72rem; font-weight: 600; }
.back-link { display: inline-block; margin-bottom: 26px; color: #7790b4; text-decoration: none; }
.back-link:hover { color: #8dccff; }

.auth-card,
.panel {
  background: linear-gradient(180deg, rgba(14,25,49,.97), rgba(8,16,32,.99));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow), 0 0 24px rgba(0,168,255,.04);
}
.auth-card { max-width: 560px; margin: 7vh auto 0; padding: 30px; }
.admin-title { color: var(--text-strong); font-size: clamp(2rem, 6vw, 4.4rem); }
.auth-form { display: grid; gap: 14px; margin-top: 22px; }

label { display: grid; gap: 7px; color: #8fa4c5; font-size: .82rem; font-weight: 750; }
input, textarea, select {
  width: 100%; min-height: 46px; border: 1px solid #24446f; background: #071126; color: var(--text);
  border-radius: 12px; padding: 10px 12px; outline: 0; caret-color: var(--accent-bright); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
select { cursor: pointer; }
input::placeholder, textarea::placeholder { color: #587092; opacity: 1; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,129,247,.13); }

.btn {
  min-height: 42px; border: 0; border-radius: 999px; padding: 10px 15px; cursor: pointer; font-weight: 850;
  text-decoration: none; text-align: center; transition: .18s ease; font: inherit;
}
.btn.primary { background: linear-gradient(180deg, #2487ef, #1769c7); color: #eaf6ff; box-shadow: 0 5px 20px rgba(24,113,211,.18); }
.btn.primary:hover { background: linear-gradient(180deg, #36a0ff, #2178d7); }
.btn.ghost { background: #0a152a; border: 1px solid #294970; color: #b9cce8; }
.btn.ghost:hover { border-color: #3977bb; color: #8dccff; background: #0d1c36; }
.btn.danger { background: #170e17; border: 1px solid #653449; color: #d88ba4; }
.btn.danger:hover { border-color: #86425c; background: #21101c; }
.btn.tiny { min-height: 34px; padding: 7px 10px; font-size: .76rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .48; cursor: not-allowed; }
.text-button { border: 0; background: none; color: #75aeea; font: inherit; font-size: .8rem; font-weight: 800; cursor: pointer; padding: 4px 0; }
.text-button:hover { color: #9acbff; }

.admin-header { display: flex; align-items: end; justify-content: space-between; gap: 22px; margin-bottom: 15px; }
.admin-header h1 { margin: 0 0 4px; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.05em; color: var(--text-strong); }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.admin-topbar {
  position: sticky; top: 8px; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 18px; padding: 8px; border: 1px solid var(--line); border-radius: 18px;
  background: rgba(7,15,31,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 10px 28px rgba(0,0,0,.24);
}
.admin-tabs { display: flex; gap: 6px; min-width: 0; }
.admin-tab {
  min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 12px; background: transparent;
  color: #7690b3; font-weight: 850; cursor: pointer; font: inherit; white-space: nowrap;
}
.admin-tab:hover { background: #0b1930; color: #a8c7ec; }
.admin-tab.active { background: #10294b; color: #9cd1ff; border-color: #285989; box-shadow: inset 0 0 18px rgba(25,126,227,.08); }
.save-state { flex: 0 0 auto; padding: 7px 11px; border-radius: 999px; font-size: .74rem; font-weight: 850; }
.save-state.saved { border: 1px solid #315f53; color: #76bca4; background: rgba(25,74,59,.15); }
.save-state.dirty { border: 1px solid #725a2f; color: #d2ad61; background: rgba(92,62,14,.15); }

.tab-view { display: none; }
.tab-view.active { display: block; }
.panel { padding: 22px; }
.panel h2 { margin: 0; color: #dcecff; font-size: 1.45rem; }
.section-head, .manage-head, .browser-head { display: flex; align-items: end; justify-content: space-between; gap: 14px; }

/* CARGA */
.load-grid { display: grid; grid-template-columns: .9fr .9fr 1.55fr; gap: 14px; margin-top: 20px; align-items: start; }
.load-card {
  position: relative; min-width: 0; display: grid; gap: 13px; padding: 18px; border: 1px solid #1e3d66; border-radius: 18px;
  background: linear-gradient(180deg, #0a1730, #071224);
}
.step-number {
  position: absolute; top: 14px; right: 14px; width: 29px; height: 29px; display: grid; place-items: center;
  border: 1px solid #2c5b8c; border-radius: 999px; color: #80bdf5; background: #091a32; font-weight: 900; font-size: .78rem;
}
.load-card-title { padding-right: 38px; }
.load-card-title span { display: block; color: #dcecff; font-size: 1.08rem; font-weight: 900; }
.load-card-title small { display: block; margin-top: 3px; color: #607b9e; }
.product-destination, .product-create-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.product-create-fields .wide { grid-column: 1 / -1; }
.product-create-options, .dialog-options { display: flex; flex-wrap: wrap; gap: 9px; }
.switch-row {
  display: inline-flex; grid-auto-flow: column; align-items: center; gap: 8px; min-height: 40px; padding: 7px 10px;
  border: 1px solid #203d62; border-radius: 12px; background: #08152a; color: #afc3df; cursor: pointer;
}
.switch-row input { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); }
.inline-message { min-height: 1.2em; margin: -2px 0 0; color: #79bfa6; font-size: .78rem; }
.inline-message.error { color: #d88ba4; }

/* GESTIÓN */
.manage-layout { display: grid; grid-template-columns: minmax(250px, .72fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.category-browser-panel { position: sticky; top: 78px; max-height: calc(100vh - 104px); overflow: auto; }
.category-browser { display: grid; gap: 8px; margin-top: 16px; }
.category-group { border: 1px solid #1d3a61; border-radius: 14px; overflow: hidden; background: #081326; }
.category-group > summary { list-style: none; cursor: pointer; user-select: none; }
.category-group > summary::-webkit-details-marker { display: none; }
.category-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 7px; padding: 11px 10px 11px 12px; }
.category-row:hover { background: #0c1b32; }
.category-select-btn, .subcategory-select-btn {
  min-width: 0; border: 0; background: transparent; color: #c8dcf6; text-align: left; cursor: pointer; font: inherit;
}
.category-select-btn { font-weight: 850; }
.category-select-btn span, .subcategory-select-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.category-count { color: #6986aa; font-size: .72rem; white-space: nowrap; }
.icon-btn {
  width: 34px; height: 34px; border: 1px solid #27486f; border-radius: 10px; background: #0a1930; color: #8eb2dc;
  cursor: pointer; display: grid; place-items: center; font: inherit;
}
.icon-btn:hover { border-color: #3b73ad; color: #b8ddff; }
.category-children { display: grid; gap: 5px; padding: 6px 8px 9px 22px; border-top: 1px solid rgba(66,110,170,.14); }
.subcategory-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 6px; min-height: 38px; }
.subcategory-select-btn { padding: 8px; border-radius: 9px; color: #8fa9c9; }
.subcategory-select-btn:hover { background: #0d1c34; color: #c0ddfb; }
.category-group.selected, .subcategory-row.selected { outline: 1px solid #2b6ba8; }

.manage-products-panel { min-width: 0; }
.manage-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 180px; gap: 10px; margin-top: 18px; }
.search-wrap { position: relative; }
.search-wrap span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #6484ad; font-size: 1.25rem; pointer-events: none; }
.search-wrap input { padding-left: 38px; }
.manage-resultbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 2px 10px; color: #c9ddf6; font-size: .86rem; }
.product-list { display: grid; gap: 9px; }
.product-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 12px;
  padding: 13px 14px; border: 1px solid #1d3d69; border-radius: 15px; background: linear-gradient(180deg, #09172e, #071124);
}
.product-main { min-width: 0; }
.product-main strong { display: block; color: #dcecff; font-size: .96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-path { display: block; margin-top: 3px; color: #647f9f; font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-price { color: #8dccff; font-weight: 900; white-space: nowrap; }
.product-actions { display: flex; align-items: center; gap: 7px; }
.status-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 8px; border-radius: 999px; font-size: .68rem; font-weight: 850; white-space: nowrap; }
.status-chip.available { border: 1px solid #315f53; color: #77bfa4; background: rgba(25,74,59,.14); }
.status-chip.unavailable { border: 1px solid #70562f; color: #d2ad61; background: rgba(92,62,14,.14); }
.status-chip.hidden { border: 1px solid #54456f; color: #a898ca; background: rgba(65,52,88,.14); }
.quick-stock-btn { min-height: 34px; padding: 6px 10px; border: 1px solid #284a73; border-radius: 999px; background: #0a1930; color: #9db9d9; font: inherit; font-size: .74rem; font-weight: 800; cursor: pointer; }
.quick-stock-btn:hover { border-color: #3b73ad; }
.empty-state { padding: 30px 18px; text-align: center; border: 1px dashed #27476f; border-radius: 16px; color: #7690b2; background: rgba(5,12,25,.5); }

/* AJUSTES */
.settings-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
.settings-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.password-form { display: grid; gap: 12px; margin-top: 18px; }
.form-message { min-height: 1.3em; margin: 12px 0 0; color: #d88ba4; font-size: .86rem; }

/* GUARDADO */
.save-dock {
  position: fixed; z-index: 70; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(720px, calc(100% - 24px)); display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 10px 10px 15px; border: 1px solid #23466f; border-radius: 18px; background: rgba(7,15,31,.95);
  backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); box-shadow: 0 16px 40px rgba(0,0,0,.4);
}
.save-dock-copy { min-width: 0; }
.save-dock-copy strong { display: block; color: #c5dbf6; font-size: .83rem; }
.save-dock-copy span { display: block; margin-top: 2px; color: #657f9f; font-size: .72rem; }
.save-dock.dirty { border-color: #705b30; }
.save-dock.dirty .save-dock-copy strong { color: #d4b66d; }

/* DIALOGOS */
.admin-dialog { width: min(720px, calc(100% - 24px)); max-height: min(88vh, 860px); border: 0; padding: 0; border-radius: 22px; background: transparent; color: var(--text); }
.admin-dialog::backdrop { background: rgba(1,5,12,.78); backdrop-filter: blur(4px); }
.dialog-card { display: grid; gap: 15px; padding: 22px; border: 1px solid #28507f; border-radius: 22px; background: linear-gradient(180deg, #0e1c35, #081226); box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.small-dialog-card { max-width: 560px; margin: 0 auto; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.dialog-head h2 { margin: 2px 0 0; color: #dcecff; }
.dialog-close { width: 40px; height: 40px; border: 1px solid #294970; border-radius: 999px; background: #09162a; color: #a8bfde; font-size: 1.45rem; cursor: pointer; }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.dialog-grid .wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.split-actions { justify-content: space-between; }
.split-actions > div { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 980px) {
  .load-grid { grid-template-columns: 1fr 1fr; }
  .product-create-card { grid-column: 1 / -1; }
  .manage-layout { grid-template-columns: 230px minmax(0,1fr); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .admin-body { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .admin-shell { width: min(100% - 12px, 1220px); padding-top: 12px; }
  .auth-card, .panel { border-radius: 17px; padding: 16px; }
  .admin-header { align-items: start; flex-direction: column; gap: 10px; }
  .admin-header h1 { font-size: 1.85rem; }
  .admin-actions { width: 100%; }
  .admin-actions .btn { flex: 1; }
  .admin-topbar { top: 5px; margin-bottom: 12px; padding: 6px; border-radius: 15px; }
  .admin-tabs { flex: 1; display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; }
  .admin-tab { min-width: 0; padding: 9px 5px; font-size: .76rem; }
  .save-state { display: none; }

  .load-grid { grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
  .product-create-card { grid-column: auto; }
  .load-card { padding: 15px; }
  .product-destination, .product-create-fields { grid-template-columns: 1fr; }
  .product-create-fields .wide { grid-column: auto; }

  .manage-layout { grid-template-columns: 1fr; gap: 10px; }
  .category-browser-panel { position: static; max-height: none; }
  .category-browser { max-height: 46vh; overflow: auto; padding-right: 2px; }
  .browser-head { align-items: center; }
  .manage-toolbar { position: sticky; top: 63px; z-index: 25; grid-template-columns: 1fr 135px; margin: 14px -8px 0; padding: 10px 8px; background: rgba(7,15,31,.96); border-top: 1px solid rgba(52,95,145,.18); border-bottom: 1px solid rgba(52,95,145,.18); }
  .product-row { grid-template-columns: minmax(0,1fr) auto; gap: 8px; padding: 12px; }
  .product-price { grid-column: 2; grid-row: 1; }
  .product-actions { grid-column: 1 / -1; justify-content: space-between; padding-top: 6px; border-top: 1px solid rgba(53,96,148,.14); }
  .product-actions .btn { min-width: 96px; }

  .settings-form-grid, .dialog-grid { grid-template-columns: 1fr; }
  .dialog-grid .wide { grid-column: auto; }
  .admin-dialog { width: calc(100% - 12px); max-height: 94vh; }
  .dialog-card { padding: 16px; border-radius: 18px; }
  .split-actions { flex-direction: column-reverse; }
  .split-actions > div { width: 100%; }
  .split-actions .btn { flex: 1; }

  .save-dock { bottom: calc(7px + env(safe-area-inset-bottom)); width: calc(100% - 14px); padding: 8px 8px 8px 11px; border-radius: 15px; }
  .save-dock-copy span { display: none; }
  .save-dock .btn { min-height: 46px; }
}

@media (max-width: 430px) {
  .manage-toolbar { grid-template-columns: 1fr; }
  .manage-toolbar .search-field { grid-column: 1; }
  .product-row { grid-template-columns: minmax(0,1fr) auto; }
  .product-actions { gap: 6px; }
  .quick-stock-btn { flex: 1; }
}
