:root {
  --bg: #f4f4f4;
  --panel: #ffffff;
  --ink: #161817;
  --muted: #666666;
  --line: #dedede;
  --red: #d80000;
  --black: #060606;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Inter", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  min-height: 42px;
  border-radius: 8px;
}

button {
  border: 0;
  color: #fff;
  background: var(--red);
  font-weight: 800;
  cursor: pointer;
}

.admin-app {
  min-height: 100vh;
}

.login-panel {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--black);
}

.login-card {
  width: min(420px, 100%);
  padding: 30px;
  border-radius: 8px;
  background: #fff;
  border-top: 5px solid var(--red);
  box-shadow: var(--shadow);
}

.login-card img {
  width: 108px;
  height: 72px;
  object-fit: contain;
}

h1,
h2,
p {
  margin-top: 0;
}

.login-card h1,
.admin-header h1,
.panel h2 {
  margin-bottom: 8px;
}

.login-card p,
.panel p,
.status {
  color: var(--muted);
  line-height: 1.55;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(216, 0, 0, 0.1);
}

.login-card button,
.save-bar button,
.product-heading button {
  width: 100%;
  margin-top: 14px;
  padding: 0 16px;
}

.dashboard {
  padding: 22px clamp(16px, 3vw, 42px) 110px;
}

.admin-header,
.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.admin-header {
  margin-bottom: 22px;
  padding: 16px 18px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(115deg, #000 0%, #111 68%, #610000 100%);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-brand img {
  width: 72px;
  height: 52px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.admin-brand p {
  margin: 0;
  color: rgba(255, 255, 255, 0.66);
  font-weight: 800;
}

.admin-brand h1 {
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions a,
.header-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
  font-weight: 800;
}

.header-actions a {
  color: var(--black);
  background: #fff;
}

.header-actions button {
  color: #fff;
  background: #3a3a3a;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr;
  gap: 18px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(12, 14, 13, 0.05);
}

.panel h2 {
  color: var(--black);
}

.panel-heading {
  margin-bottom: 18px;
}

.form-grid,
.color-grid {
  display: grid;
  gap: 14px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.color-grid input {
  height: 52px;
  padding: 5px;
}

.product-panel {
  margin-top: 18px;
}

.banner-panel {
  margin-top: 18px;
}

.category-panel {
  margin-top: 18px;
  background: #fff5f5;
  border-color: #ffd6d6;
}

.brand-panel {
  margin-top: 18px;
}

.category-create,
.brand-create,
.custom-icon-create {
  display: grid;
  grid-template-columns: 1fr 220px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.brand-create {
  grid-template-columns: 1fr auto;
}

.category-create button,
.brand-create button,
.custom-icon-create button {
  margin: 0;
  padding: 0 16px;
}

.category-icons-editor,
.brand-editor,
.custom-icons-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.category-icon-row,
.brand-row,
.custom-icon-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.category-icon-row {
  background: color-mix(in srgb, var(--category-card-color, #d80000) 12%, #fff);
  border-color: color-mix(in srgb, var(--category-card-color, #d80000) 32%, var(--line));
}

.brand-row {
  background: color-mix(in srgb, var(--brand-card-color, #111111) 10%, #fff);
  border-color: color-mix(in srgb, var(--brand-card-color, #111111) 28%, var(--line));
}

.category-icon-row strong,
.brand-row strong,
.custom-icon-row strong {
  color: var(--ink);
  line-height: 1.3;
}

.category-icon-row small {
  color: var(--muted);
  font-weight: 700;
}

.custom-icon-row img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.category-row-actions,
.brand-row-actions,
.custom-icon-row-actions {
  display: flex;
  gap: 8px;
}

.color-inline {
  display: grid;
  grid-template-columns: 1fr 54px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.color-inline input {
  height: 38px;
  padding: 4px;
}

.category-row-actions button,
.brand-row-actions button,
.custom-icon-row-actions button {
  width: 100%;
  padding: 0 12px;
}

.banners-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.banner-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.banner-card img {
  width: 100%;
  aspect-ratio: 16 / 8.5;
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  background: #f5f5f5;
}

.banner-card button {
  padding: 0 12px;
  background: #4d4d4d;
}

.product-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.product-heading button {
  width: auto;
  margin-top: 0;
}

.products-editor {
  display: grid;
  gap: 14px;
}

.product-edit-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-edit-card.is-collapsed .product-edit-body {
  display: none;
}

.category-summary,
.brand-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.product-list-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 170px auto;
  gap: 14px;
  align-items: center;
}

.product-list-main,
.product-list-price {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.product-list-main strong,
.product-list-price strong,
.category-summary strong,
.brand-summary strong {
  color: var(--ink);
}

.product-list-main span,
.product-list-price span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.product-mini-image {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8f8f7;
}

.product-mini-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-mini-image span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.product-list-actions {
  display: flex;
  gap: 8px;
}

.product-list-actions button {
  padding: 0 12px;
}

.product-edit-body {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.edit-toggle {
  min-height: 36px;
  padding: 0 12px;
  background: var(--black);
}

.edit-body.is-collapsed {
  display: none;
}

.image-preview {
  display: grid;
  min-height: 120px;
  align-content: start;
  gap: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(135deg, #fff 0%, #f3f3f3 60%, #ffeaea 100%);
}

.image-preview img {
  width: 100%;
  height: 120px;
  object-fit: contain;
}

.image-preview span {
  color: var(--muted);
  font-weight: 800;
}

.admin-image-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
}

.admin-image-thumb {
  display: grid;
  gap: 5px;
  min-height: auto;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 6px;
  color: var(--red);
  background: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}

.admin-image-thumb img {
  width: 100%;
  height: 54px;
  object-fit: contain;
}

.image-helper {
  padding: 10px;
  margin: 0;
  color: var(--admin-muted);
  font-size: 0.82rem;
}

.product-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.check-field {
  display: flex;
  min-height: 47px;
  align-items: center;
  gap: 10px;
  align-self: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.product-fields .wide {
  grid-column: 1 / -1;
}

.product-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-actions button {
  padding: 0 14px;
}

.remove-button {
  background: #4d4d4d;
}

.save-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 14px clamp(16px, 3vw, 42px);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.save-bar button {
  width: auto;
  margin: 0;
}

.success-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
}

.success-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.success-card h2 {
  margin-bottom: 18px;
}

.success-card button {
  padding: 0 22px;
}

@media (max-width: 900px) {
  .admin-grid,
  .category-create,
  .brand-create,
  .custom-icon-create,
  .product-list-row,
  .product-edit-body,
  .product-fields,
  .banners-editor,
  .category-icons-editor,
  .brand-editor,
  .custom-icons-editor {
    grid-template-columns: 1fr;
  }

  .admin-header,
  .product-heading,
  .save-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Admin refinado */
:root {
  --admin-blue: #d80000;
  --admin-blue-dark: #070707;
  --admin-soft: #f7f7f7;
  --admin-text: #111936;
  --admin-muted: #686868;
  --admin-border: #e2e2e2;
}

body {
  color: var(--admin-text);
  background:
    radial-gradient(circle at 82% 4%, rgba(216, 0, 0, 0.1), transparent 28%),
    var(--admin-soft);
}

.dashboard {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  gap: 24px 28px;
  padding: 0 28px 110px 0;
}

.dashboard > :not(.admin-sidebar) {
  grid-column: 2;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  grid-column: 1;
  grid-row: 1 / span 20;
  display: grid;
  min-height: 100vh;
  align-content: start;
  gap: 22px;
  padding: 34px 26px;
  color: #fff;
  background: var(--red);
  box-shadow: 18px 0 44px rgba(216, 0, 0, 0.14);
}

.sidebar-logo img {
  width: 152px;
  height: 70px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.sidebar-user {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  padding: 18px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
}

.sidebar-user-icon::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: 0 18px 0 -5px currentColor;
}

.sidebar-user strong,
.sidebar-user small {
  display: block;
}

.sidebar-user small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.sidebar-nav a,
.sidebar-help a,
.admin-sidebar > button {
  display: flex;
  min-height: 50px;
  align-items: center;
  gap: 12px;
  border-radius: 10px;
  padding: 0 14px;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.sidebar-nav a {
  background: transparent;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.15);
}

.sidebar-nav span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  font-size: 1.1rem;
}

.sidebar-help {
  display: grid;
  gap: 12px;
  margin-top: 58px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-help span {
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.45;
}

.sidebar-help a {
  justify-content: center;
  min-height: 42px;
  background: rgba(255, 255, 255, 0.18);
}

.admin-sidebar > button {
  margin-top: 28px;
  justify-content: flex-start;
  background: transparent;
}

.admin-header {
  margin: 0;
  padding: 26px 0 6px;
  color: var(--admin-text);
  background: transparent;
}

.admin-header h1 {
  margin: 0 0 6px;
  font-size: 1.85rem;
}

.admin-header p {
  margin: 0;
  color: var(--admin-muted);
}

.header-actions a,
.header-actions button,
.help-button {
  border: 1px solid var(--admin-border);
  color: var(--red);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 18px rgba(17, 25, 54, 0.04);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 300px;
  gap: 18px;
}

.stat-card,
.tip-card,
.panel {
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 14px 34px rgba(17, 25, 54, 0.06);
}

.stat-card {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 16px;
  align-items: center;
  padding: 24px;
}

.stat-card a {
  grid-column: 1 / -1;
  min-height: auto;
  color: var(--red);
  font-weight: 900;
  text-decoration: none;
}

.stat-card span {
  display: block;
  color: var(--admin-muted);
  font-weight: 700;
}

.stat-card strong {
  display: inline-block;
  margin-top: 4px;
  color: #0f1633;
  font-size: 2rem;
  line-height: 1;
}

.stat-card small {
  margin-left: 8px;
  color: #18a15f;
  font-weight: 800;
}

.stat-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 16px;
}

.stat-category {
  background: #ffe1e1;
}

.stat-brand {
  background: #f3f3f3;
}

.stat-product {
  background: #ffe8d6;
}

.stat-icon::before {
  content: "";
  width: 28px;
  height: 22px;
  border: 3px solid var(--red);
  border-radius: 5px;
}

.stat-brand::before {
  border-color: #111111;
  transform: rotate(45deg);
}

.stat-product::before {
  border-color: var(--red);
  border-radius: 8px;
}

.tip-card {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 24px;
}

.tip-card strong {
  color: var(--red);
}

.tip-card span {
  color: var(--admin-muted);
  line-height: 1.55;
}

.admin-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
}

.panel {
  padding: 22px;
}

.panel h2 {
  color: #111936;
}

.panel p {
  color: var(--admin-muted);
}

input,
textarea,
select {
  border-color: var(--admin-border);
  color: var(--admin-text);
}

button {
  background: var(--red);
}

.remove-button {
  background: #555b68;
}

.category-panel {
  background: rgba(255, 255, 255, 0.88);
  border-color: var(--admin-border);
}

.category-icons-editor {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.brand-editor {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.category-icon-row,
.brand-row {
  padding: 16px;
  border-color: var(--admin-border);
  background: #fff;
}

.category-summary,
.brand-summary {
  display: grid;
  grid-template-columns: 1fr auto;
}

.category-summary div,
.brand-summary div {
  display: grid;
  gap: 4px;
}

.category-summary small,
.brand-summary small {
  color: var(--admin-muted);
  font-weight: 700;
}

.edit-toggle {
  color: #fff;
  background: #111111;
}

.product-edit-card,
.banner-card,
.custom-icon-row {
  border-color: var(--admin-border);
  border-radius: 12px;
  background: #fff;
}

.product-edit-card.is-sold-out {
  border-color: rgba(216, 0, 0, 0.42);
  background: #fff7f7;
}

.product-edit-card.is-disabled {
  opacity: 0.68;
  background: #f2f2f2;
}

.product-list-row {
  grid-template-columns: 68px minmax(0, 1fr) 170px auto;
}

.product-mini-image,
.image-preview {
  border-color: var(--admin-border);
  border-radius: 10px;
  background: #fafafa;
}

.save-bar {
  left: 288px;
  border-top-color: var(--admin-border);
  box-shadow: 0 -12px 28px rgba(17, 25, 54, 0.08);
}

@media (max-width: 1180px) {
  .dashboard {
    grid-template-columns: 1fr;
    padding: 0 18px 110px;
  }

  .dashboard > :not(.admin-sidebar) {
    grid-column: 1;
  }

  .admin-sidebar {
    position: static;
    grid-row: auto;
    min-height: auto;
    margin: 18px 0 0;
    border-radius: 16px;
  }

  .stats-grid,
  .admin-grid,
  .category-icons-editor,
  .brand-editor {
    grid-template-columns: 1fr;
  }

  .save-bar {
    left: 0;
  }
}
