:root {
  --black: #070706;
  --black-2: #11100d;
  --ink: #17120b;
  --muted: #746b5f;
  --paper: #fbf7ef;
  --panel: #fffdf8;
  --line: rgba(122, 86, 36, .18);
  --gold: #b47729;
  --gold-2: #d8ba73;
  --gold-3: #8c5e23;
  --danger: #a72b2b;
  --ok: #1b7a55;
  --radius: 20px;
  --radius-lg: 30px;
  --shadow: 0 22px 64px rgba(41, 29, 11, .12);
  --shadow-sm: 0 12px 32px rgba(41, 29, 11, .07);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% -6%, rgba(216,186,115,.24), transparent 26%),
    radial-gradient(circle at 8% 88%, rgba(180,119,41,.12), transparent 28%),
    linear-gradient(180deg, #fffaf1, var(--paper));
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
a { color: inherit; text-decoration: none; }
button,
input,
textarea,
select { font: inherit; }
::selection { color: #171109; background: var(--gold-2); }

.admin-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 28px 20px;
  border-right: 1px solid rgba(216,186,115,.20);
  color: #f7ecd9;
  background:
    radial-gradient(circle at 40% 0%, rgba(216,186,115,.16), transparent 30%),
    linear-gradient(180deg, #12100d, #060606 72%);
  box-shadow: 22px 0 60px rgba(0,0,0,.16);
}
.sidebar::before {
  content: "";
  display: block;
  width: 62px;
  height: 4px;
  margin-bottom: 22px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
}
.brand {
  color: var(--gold-2);
  font-family: var(--serif);
  font-size: 34px;
  line-height: .9;
  letter-spacing: -.05em;
}
.brand small {
  display: block;
  margin-top: 9px;
  color: #cdb586;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .24em;
}
.sidebar .muted {
  margin: 18px 0 0;
  color: rgba(255,247,233,.62);
  line-height: 1.55;
}
.sidebar nav {
  display: grid;
  gap: 8px;
  margin-top: 30px;
}
.sidebar a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  color: #d8cebe;
  font-size: 13px;
  font-weight: 800;
  transition: background .22s ease, color .22s ease, border-color .22s ease, transform .22s ease;
}
.sidebar a::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-radius: 50%;
  background: rgba(216,186,115,.35);
  transition: background .22s ease, box-shadow .22s ease;
}
.sidebar a:hover,
.sidebar a.is-active {
  color: #fffdf8;
  border-color: rgba(216,186,115,.24);
  background: rgba(216,186,115,.10);
  transform: translateX(3px);
}
.sidebar a:hover::before,
.sidebar a.is-active::before {
  background: var(--gold-2);
  box-shadow: 0 0 0 5px rgba(216,186,115,.12);
}
.main {
  min-width: 0;
  padding: 30px clamp(22px, 4vw, 56px) 46px;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding: 18px 20px;
  border: 1px solid rgba(122,86,36,.14);
  border-radius: var(--radius-lg);
  background: rgba(255,253,248,.72);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}
.top h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 4vw, 50px);
  font-weight: 400;
  line-height: .95;
  letter-spacing: -.045em;
}
.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 15px;
  border: 1px solid rgba(180,119,41,.55);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--gold-3);
  box-shadow: 0 8px 18px rgba(43,31,13,.04);
  cursor: pointer;
  font-size: 12px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .04em;
  transition: transform .22s ease, box-shadow .22s ease, background .22s ease, color .22s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(180,119,41,.18); }
.btn.gold {
  color: #16100a;
  border-color: transparent;
  background: linear-gradient(135deg, #f2d98e, var(--gold-2) 45%, var(--gold));
  box-shadow: 0 16px 34px rgba(180,119,41,.22), inset 0 1px 0 rgba(255,255,255,.34);
}
.btn.dark { color: #fff6e7; border-color: #111; background: linear-gradient(135deg, #171410, #050505); }
.btn.danger { border-color: rgba(167,43,43,.45); color: var(--danger); background: #fff7f7; }
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.stat,
.card,
.form {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,253,248,.82);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
}
.stat {
  position: relative;
  overflow: hidden;
  min-height: 138px;
  padding: 22px;
}
.stat::after {
  content: "";
  position: absolute;
  right: -55px;
  bottom: -55px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(216,186,115,.18), transparent 68%);
}
.stat b {
  display: block;
  color: var(--gold-3);
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 400;
  line-height: 1;
}
.stat span {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.card,
.form { padding: 22px; }
.card h2,
.form h2 {
  margin: 0 0 13px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -.035em;
}
.card p { color: var(--muted); line-height: 1.65; }
.table {
  width: 100%;
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,253,248,.86);
  box-shadow: var(--shadow-sm);
}
.table th,
.table td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.table tr:last-child td { border-bottom: 0; }
.table th {
  color: var(--gold-3);
  background: #fff5e4;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.table td { color: var(--ink); font-size: 14px; }
.table small,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field.full { grid-column: 1 / -1; }
.field label {
  color: var(--gold-3);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  background: #fffdf8;
  color: var(--ink);
  padding: 13px 14px;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.field textarea { min-height: 124px; resize: vertical; }
.field input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--gold);
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(180,119,41,.55);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(216,186,115,.14);
}
.alert {
  margin-bottom: 15px;
  padding: 14px 16px;
  border: 1px solid rgba(180,119,41,.24);
  border-radius: 18px;
  background: #fff6e4;
  color: #644919;
  box-shadow: var(--shadow-sm);
}
.alert.ok { background: #eefaf4; color: var(--ok); border-color: rgba(27,122,85,.22); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid rgba(180,119,41,.20);
  border-radius: 999px;
  background: #fff4de;
  color: var(--gold-3);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.tabs a {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.tabs a.is-active { color: #fff7e8; background: #11100d; border-color: #11100d; }
hr {
  border: 0;
  height: 1px;
  margin: 22px 0;
  background: linear-gradient(90deg, transparent, rgba(180,119,41,.28), transparent);
}
code,
pre {
  border-radius: 12px;
  background: #171410;
  color: #ffe6bb;
}
code { padding: 3px 6px; }
pre { padding: 14px; overflow: auto; }
details.card summary { cursor: pointer; color: var(--gold-3); font-weight: 900; }
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 72% 18%, rgba(216,186,115,.34), transparent 30%),
    radial-gradient(circle at 8% 90%, rgba(180,119,41,.18), transparent 30%),
    #080807;
}
.login .form { width: min(430px, 94vw); background: #fffdf8; }
.login h1 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 400;
  letter-spacing: -.045em;
}

@media (max-width: 1060px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(216,186,115,.20);
  }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 22px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .top { display: block; }
  .top .badge { margin-top: 12px; }
  .sidebar nav,
  .grid,
  .form-grid { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .main { padding: 18px; }
  .btn { width: 100%; }
  .actions .btn { width: auto; }
}

.order-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}
.status-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid rgba(180,119,41,.16);
  border-radius: 16px;
  background: #fffaf1;
}
.status-form label {
  display: grid;
  gap: 5px;
  color: #8b5c20;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.status-form select {
  min-height: 38px;
  border: 1px solid rgba(180,119,41,.22);
  border-radius: 12px;
  padding: 0 10px;
  background: #fff;
}
.order-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.order-meta-grid p,
.order-notes {
  margin: 0;
  padding: 13px;
  border: 1px solid rgba(180,119,41,.14);
  border-radius: 16px;
  background: #fffdf8;
}
.order-meta-grid strong,
.order-notes strong {
  display: block;
  margin-bottom: 5px;
  color: #8b5c20;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.order-meta-grid span { word-break: break-word; }
.order-notes { margin-top: 12px; }
@media (max-width: 800px) { .order-meta-grid { grid-template-columns: 1fr; } }

/* ===== Admin premium completo ===== */
.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, #111 0%, #23170c 100%);
  color: #fff;
  overflow: hidden;
  position: relative;
}
.dashboard-hero:after { content:""; position:absolute; width:280px; height:280px; border-radius:999px; right:-80px; top:-100px; background:radial-gradient(circle, rgba(216,186,115,.25), transparent 68%); }
.dashboard-hero h2 { margin: 12px 0 8px; font-family: Georgia, serif; font-weight: 400; font-size: clamp(28px, 4vw, 48px); }
.dashboard-hero p { color: rgba(255,255,255,.70); max-width: 680px; }
.dashboard-actions { display: flex; gap: 10px; flex-wrap: wrap; z-index: 1; }
.dashboard-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat small { display:block; margin-top:6px; color:#8d826d; font-size:12px; }
.admin-columns { display:grid; grid-template-columns: 1.3fr .7fr; gap:18px; margin:18px 0; }
.section-head { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:12px; }
.table.compact th,.table.compact td { padding:10px; }
.lead-list { display:grid; gap:10px; }
.lead-list article { padding:13px; border:1px solid rgba(180,119,41,.14); border-radius:16px; background:#fffdf8; }
.lead-list strong,.lead-list span,.lead-list small { display:block; }
.lead-list span { color:#8b5c20; font-weight:800; margin:4px 0; }
.order-toolbar { display:flex; justify-content:space-between; align-items:end; gap:18px; margin-bottom:16px; }
.filter-form { display:grid; grid-template-columns:minmax(240px,1fr) 200px auto auto; align-items:end; gap:10px; flex:1; }
.order-toolbar-summary { display:grid; gap:5px; text-align:right; }
.order-toolbar-summary span { color:#8d826d; font-weight:800; }
.order-toolbar-summary strong { font-size:24px; font-family:Georgia,serif; }
.status-badge { display:inline-flex; align-items:center; border-radius:999px; padding:6px 10px; font-size:11px; font-weight:950; text-transform:uppercase; letter-spacing:.07em; border:1px solid rgba(0,0,0,.08); background:#f4f4f4; color:#333; }
.status-pagado,.status-entregado { background:#ecfff4; color:#17633d; border-color:rgba(23,99,61,.18); }
.status-pendiente { background:#fff4db; color:#8b5c20; border-color:rgba(180,119,41,.20); }
.status-rechazado,.status-cancelado { background:#fff0f0; color:#9b1c1c; border-color:rgba(155,28,28,.18); }
.order-actions { display:flex; gap:10px; flex-wrap:wrap; margin:14px 0; }
.form-helper { margin-bottom:16px; }
.form-helper h2 { margin-top:0; }
.check-field label { display:flex !important; align-items:center; gap:10px; min-height:46px; }
.check-field input { width:auto !important; accent-color:#b47729; }
@media (max-width: 1180px) { .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .admin-columns { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .dashboard-hero,.order-toolbar { align-items:stretch; flex-direction:column; } .filter-form { grid-template-columns:1fr; } .order-toolbar-summary { text-align:left; } }


/* ===== Responsive final admin ===== */
html, body { overflow-x: hidden; }
.admin-shell, .main, .sidebar, .card, .form, .stat { min-width: 0; }
.table-wrap, .card { max-width: 100%; }
input, textarea, select, button { max-width: 100%; }
@media (max-width: 1180px) {
  .admin-shell { grid-template-columns: 1fr !important; }
  .sidebar {
    position: relative;
    height: auto;
    max-height: none;
    padding: 22px;
    border-right: 0;
    border-bottom: 1px solid rgba(216,186,115,.20);
  }
  .sidebar nav { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .main { padding: 24px clamp(16px, 4vw, 34px) 36px; }
  .dashboard-grid, .grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .admin-columns { grid-template-columns: 1fr !important; }
}
@media (max-width: 760px) {
  .sidebar { padding: 18px 14px; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
  .sidebar a { min-height: 42px; padding: 10px 11px; font-size: 12px; }
  .main { padding: 18px 14px 30px; }
  .top { align-items: flex-start; flex-direction: column; border-radius: 22px; padding: 16px; }
  .top h1 { font-size: clamp(31px, 11vw, 44px); }
  .dashboard-hero, .order-toolbar, .section-head, .order-head { align-items: stretch !important; flex-direction: column !important; }
  .dashboard-actions, .order-actions, .actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .btn { width: 100%; min-height: 44px; }
  .actions .btn { width: 100%; }
  .dashboard-grid, .grid, .form-grid, .order-meta-grid, .filter-form { grid-template-columns: 1fr !important; }
  .card, .form, .stat { border-radius: 22px; padding: 17px; overflow-x: auto; }
  .table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; }
  .table table, table.table { min-width: 680px; }
  .status-form { align-items: stretch; flex-direction: column; }
  .status-form select, .status-form button { width: 100%; }
  .order-toolbar-summary { text-align: left !important; }
}
@media (max-width: 440px) {
  .sidebar nav { grid-template-columns: 1fr; }
  .brand { font-size: 28px; }
  .brand small { letter-spacing: .16em; }
  .main { padding-inline: 10px; }
  .card, .form, .stat { padding: 14px; }
}

/* ===== Cropie interno para productos e insights ===== */
.gch-crop-field .gch-crop-file {
  cursor: pointer;
}
.gch-cropie-box {
  display: none;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(180,119,41,.20);
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdf8, #fbf3e5);
  box-shadow: 0 14px 32px rgba(41,29,11,.07);
}
.gch-cropie-box.is-ready { display: block; }
.gch-cropie-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.gch-cropie-head strong {
  color: var(--gold-3);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.gch-cropie-head span {
  color: var(--muted);
  font-size: 12px;
}
.gch-cropie-stage {
  position: relative;
  width: min(100%, 720px);
  max-height: 460px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(180,119,41,.28);
  border-radius: 20px;
  background:
    linear-gradient(45deg, rgba(180,119,41,.08) 25%, transparent 25%, transparent 75%, rgba(180,119,41,.08) 75%),
    linear-gradient(45deg, rgba(180,119,41,.08) 25%, transparent 25%, transparent 75%, rgba(180,119,41,.08) 75%),
    #fffaf3;
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.gch-cropie-stage.is-dragging { cursor: grabbing; }
.gch-cropie-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 2px solid rgba(226,179,86,.82);
  border-radius: 20px;
  box-shadow: inset 0 0 0 999px rgba(0,0,0,.015);
}
.gch-cropie-stage img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  max-height: none;
  transform-origin: 0 0;
  will-change: transform, width, height;
  user-select: none;
  pointer-events: none;
}
.gch-cropie-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}
.gch-cropie-controls label {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--gold-3);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.gch-cropie-controls input[type="range"] {
  padding: 0;
  accent-color: var(--gold);
}
@media (max-width: 720px) {
  .gch-cropie-head,
  .gch-cropie-controls { grid-template-columns: 1fr; display: grid; }
  .gch-cropie-controls label { grid-template-columns: 1fr; }
}

/* === VISTA ACTUAL Y CROP FINAL MÁS CLARO === */
.gch-admin-image-preview {
  max-width: 420px;
  border: 1px solid rgba(180,119,41,.22);
  border-radius: 18px;
  background: #fffaf3;
  overflow: hidden;
  padding: 10px;
}
.gch-admin-image-preview img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  object-fit: contain;
}
.gch-admin-product-preview {
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gch-admin-product-preview img {
  max-width: 100%;
  max-height: 100%;
}
.gch-cropie-box {
  border-color: rgba(226,179,86,.34);
  box-shadow: 0 16px 34px rgba(84,62,26,.08);
}
.gch-cropie-stage {
  background:
    linear-gradient(45deg, rgba(226,179,86,.08) 25%, transparent 25%, transparent 75%, rgba(226,179,86,.08) 75%),
    linear-gradient(45deg, rgba(226,179,86,.08) 25%, transparent 25%, transparent 75%, rgba(226,179,86,.08) 75%),
    #fffaf3;
  background-position: 0 0, 10px 10px, 0 0;
  background-size: 20px 20px, 20px 20px, auto;
}


/* === FIX CROP INSIGHTS: vista previa visible, sin transparencia === */
.gch-cropie-box.is-ready {
  display: block !important;
}
.gch-cropie-box.is-loading .gch-cropie-stage::before {
  content: "Cargando imagen...";
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  color: #8c5e23;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: rgba(255,250,243,.78);
}
.gch-cropie-stage {
  min-height: 220px !important;
  isolation: isolate;
}
.gch-cropie-stage img {
  display: block !important;
  opacity: 1;
  visibility: visible;
  z-index: 1;
}
.gch-cropie-stage::after {
  z-index: 2;
}
