/* ==========================================================================
   CC-Shops · base compartida (tienda + backoffice)
   ========================================================================== */
:root {
  --bg: #f6f2ea;
  --bg-deep: #ede7db;
  --paper: #fffdf8;
  --paper-2: #fbf8f1;
  --ink: #16231c;
  --ink-2: #3f4d44;
  --muted: #767f77;
  --line: #e6dfd2;
  --line-strong: #d5cbb8;
  --brand: #1d5b45;
  --brand-dark: #123b2c;
  --brand-deep: #0d2b21;
  --brand-2: #2f7a5d;
  --brand-soft: #e2ece3;
  --brand-mist: #f0f5ef;
  --accent: #dd6b36;
  --accent-dark: #b95024;
  --accent-soft: #fbe6da;
  --gold: #b88a2f;
  --gold-soft: #f6ecd2;
  --danger: #b23a2c;
  --danger-soft: #fbe5e0;
  --warn: #a56a13;
  --warn-soft: #fbefd6;
  --ok: #2b7553;
  --ok-soft: #e2f0e7;
  --info: #2c5c88;
  --info-soft: #e3edf7;
  --shadow-xs: 0 1px 2px rgba(22, 35, 28, .06);
  --shadow-sm: 0 4px 14px -8px rgba(22, 35, 28, .18);
  --shadow-md: 0 22px 44px -28px rgba(22, 35, 28, .28), 0 2px 8px -4px rgba(22, 35, 28, .08);
  --shadow-lg: 0 40px 80px -40px rgba(13, 43, 33, .38), 0 8px 24px -12px rgba(22, 35, 28, .12);
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --radius-xl: 36px;
  --sans: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --header-h: 76px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.6;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--brand); color: #fff; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent);
  outline-offset: 2px;
}

.container { width: min(1240px, 100% - 48px); margin-inline: auto; }
.container--narrow { width: min(820px, 100% - 48px); margin-inline: auto; }
.serif { font-family: var(--serif); font-weight: 500; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.tiny { font-size: 12.5px; }
.small { font-size: 13.5px; }
.strong { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--brand);
}
.eyebrow::before { content: ""; width: 18px; height: 1.5px; background: currentColor; opacity: .6; }
.lead { color: var(--ink-2); font-size: 17px; line-height: 1.65; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ------------------------------- Botones -------------------------------- */
.btn {
  --btn-bg: var(--brand);
  --btn-fg: #fffdf7;
  --btn-bd: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 46px; padding: 0 20px;
  border: 1px solid var(--btn-bd); border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 14px; font-weight: 650; letter-spacing: .01em;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -14px rgba(13, 43, 33, .5); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn-primary { --btn-bg: var(--brand); --btn-bd: var(--brand); }
.btn-primary:hover { --btn-bg: var(--brand-dark); --btn-bd: var(--brand-dark); }
.btn-accent { --btn-bg: var(--accent); --btn-bd: var(--accent); --btn-fg: #fff; }
.btn-accent:hover { --btn-bg: var(--accent-dark); --btn-bd: var(--accent-dark); }
.btn-dark { --btn-bg: var(--ink); --btn-bd: var(--ink); --btn-fg: #fffdf7; }
.btn-outline { --btn-bg: transparent; --btn-bd: var(--line-strong); --btn-fg: var(--ink); }
.btn-outline:hover { --btn-bg: var(--paper); --btn-bd: var(--brand); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--ink-2); }
.btn-ghost:hover { --btn-bg: var(--brand-mist); --btn-fg: var(--brand); box-shadow: none; }
.btn-danger { --btn-bg: var(--danger); --btn-bd: var(--danger); --btn-fg: #fff; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-xs { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { min-height: 54px; padding: 0 28px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 42px; height: 42px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  transition: .18s ease;
}
.btn-icon:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-icon.is-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ------------------------------- Formularios ---------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label {
  font-size: 12.5px; font-weight: 650; color: var(--ink-2); letter-spacing: .015em;
}
.field .hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 13px;
  border: 1px solid var(--line-strong); border-radius: 11px;
  background: var(--paper); color: var(--ink);
  font-size: 14px; transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.input:hover, .select:hover, .textarea:hover { border-color: #bfb5a2; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent);
}
.input::placeholder, .textarea::placeholder { color: #a6a99f; }
.input[disabled], .select[disabled] { background: var(--bg-deep); color: var(--muted); cursor: not-allowed; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%233f4d44' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field-error { border-color: var(--danger) !important; }
.error-text { color: var(--danger); font-size: 12px; }
.check {
  display: inline-flex; align-items: flex-start; gap: 9px; font-size: 13.5px; cursor: pointer; color: var(--ink-2);
}
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin-top: 2px; flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 42px; height: 24px; border-radius: 999px; background: var(--line-strong);
  position: relative; transition: background .2s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.input-group { display: flex; }
.input-group .input { border-radius: 11px 0 0 11px; }
.input-group .btn { border-radius: 0 11px 11px 0; min-height: 44px; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box .input { padding-left: 40px; }

/* ------------------------------- Badges --------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 24px; padding: 3px 9px; border-radius: 999px;
  background: var(--bg-deep); color: var(--ink-2);
  font-size: 11.5px; font-weight: 650; line-height: 1.3; white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--brand { background: var(--brand-soft); color: var(--brand); }
.badge--plain::before { display: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; flex: none; }
.dot--warn { background: var(--warn); } .dot--danger { background: var(--danger); } .dot--muted { background: var(--muted); }

/* ------------------------------- Tablas --------------------------------- */
.table-wrap { overflow: auto; border-radius: var(--radius-sm); }
.table { font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: var(--paper-2); white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand-mist) 55%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .money { font-weight: 650; }
.table .thumb { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; background: var(--bg-deep); border: 1px solid var(--line); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ------------------------------- Toasts y modal ------------------------- */
.toasts {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 16px; border-radius: 14px; background: var(--ink); color: #fffdf7;
  box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in .25s ease both;
}
.toast svg { flex: none; margin-top: 1px; }
.toast--success { background: var(--brand-dark); }
.toast--error { background: #7c2b21; }
.toast--warn { background: #76501b; }
.toast.is-out { animation: toast-out .2s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 150; background: rgba(13, 30, 23, .5);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fade-in .18s ease both;
}
.modal {
  width: min(560px, 100%); max-height: min(88vh, 900px); background: var(--paper);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-in .22s cubic-bezier(.2,.8,.2,1) both;
}
.modal--wide { width: min(980px, 100%); }
.modal--xl { width: min(1180px, 100%); }
.modal-head { padding: 22px 24px 16px; border-bottom: 1px solid var(--line); position: relative; }
.modal-head h2 { font-family: var(--serif); font-size: 25px; font-weight: 500; letter-spacing: -.02em; line-height: 1.15; }
.modal-head p { color: var(--muted); font-size: 13px; margin-top: 5px; }
.modal-close {
  position: absolute; right: 16px; top: 16px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper); display: grid; place-items: center;
}
.modal-close:hover { background: var(--bg-deep); }
.modal-body { padding: 22px 24px; overflow: auto; }
.modal-foot {
  margin-top: auto; padding: 16px 24px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 10px; background: var(--paper-2);
}
.modal-foot .left { margin-right: auto; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ------------------------------- Estados vacíos / carga ----------------- */
.empty {
  text-align: center; padding: 58px 24px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius); background: var(--paper-2);
}
.empty-icon {
  width: 58px; height: 58px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; margin: 0 auto 14px;
}
.empty h3 { font-family: var(--serif); font-size: 23px; font-weight: 500; margin-bottom: 6px; }
.empty p { color: var(--muted); font-size: 14px; max-width: 420px; margin: 0 auto 18px; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line);
  border-top-color: var(--brand); animation: spin .7s linear infinite;
}
.spinner--lg { width: 34px; height: 34px; border-width: 3px; }
.loading-block { display: grid; place-items: center; gap: 12px; padding: 70px 20px; color: var(--muted); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  background: linear-gradient(90deg, var(--bg-deep) 25%, #f4efe5 37%, var(--bg-deep) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ------------------------------- Utilidades ----------------------------- */
.pill-tabs {
  display: inline-flex; padding: 4px; background: var(--bg-deep); border-radius: 999px; gap: 2px;
}
.pill-tabs button, .pill-tabs a {
  border: 0; background: transparent; border-radius: 999px; padding: 8px 14px;
  font-size: 12.5px; font-weight: 650; color: var(--muted); transition: .15s;
}
.pill-tabs button.is-active, .pill-tabs a.is-active { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-xs); }
.pill-tabs button:hover, .pill-tabs a:hover { color: var(--ink); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 11px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--paper);
  font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px;
  background: var(--bg-deep); font-size: 11px; color: var(--ink-2); font-weight: 600;
}
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px;
  padding: 0 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px;
  background: var(--paper); font: 11px var(--mono); color: var(--muted);
}
.divider { height: 1px; background: var(--line); border: 0; margin: 20px 0; }
.notice {
  display: flex; gap: 11px; align-items: flex-start; padding: 13px 15px; border-radius: 12px;
  background: var(--brand-mist); border: 1px solid var(--brand-soft); color: var(--ink-2); font-size: 13px;
}
.notice svg { color: var(--brand); flex: none; margin-top: 1px; }
.notice--warn { background: var(--warn-soft); border-color: #eeddb9; }
.notice--warn svg { color: var(--warn); }
.notice--danger { background: var(--danger-soft); border-color: #f0cbc3; }
.notice--danger svg { color: var(--danger); }

@media (max-width: 700px) {
  .container, .container--narrow { width: min(100% - 32px, 1240px); }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .modal { max-height: 92vh; border-radius: 22px 22px 0 0; }
  .toasts { right: 12px; left: 12px; bottom: 12px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Identidad de la tienda: logo en la tienda y en el backoffice */
.logo-img { height: 40px; width: auto; max-width: 180px; display: block; object-fit: contain; }
.admin-brand-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }
.logo-preview { height: 64px; width: auto; max-width: 200px; object-fit: contain; border: 1px solid var(--line, #d9d4c7); border-radius: 8px; padding: 6px; background: #fff; }
.logo-acciones { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.admin-version { padding: 6px 4px 0; }

/* Instalación de la app (PWA) en la barra lateral del backoffice */
.admin-install { width: 100%; margin: 10px 0 6px; justify-content: center; }
.admin-install-ayuda { margin: 8px 0 4px; line-height: 1.4; }
