/*
 * Panel interno de Space Link.
 * Sensacion de panel profesional (fondo gris claro, tarjetas blancas, jerarquia
 * clara) con la identidad morada de Space Store.
 * Todos los colores viven como tokens en :root.
 */

:root {
  /* --- Marca: morado de Space Store (#6D388B, el accent del tema Shopify) --- */
  --accent: #6d388b;
  --accent-strong: #582c70;
  --accent-deep: #46225a;
  --accent-soft: #f5eff8;
  --accent-soft-strong: #ece0f2;
  --accent-border: #dcc8e6;
  --accent-ring: rgba(109, 56, 139, 0.18);
  --on-accent: #ffffff;

  /* --- Superficies y bordes --- */
  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface-alt: #fafafc;
  --surface-quiet: #f7f7fa;
  --border: #e5e7ee;
  --border-strong: #d0d3de;

  /* --- Texto --- */
  --text: #1a1c24;
  --text-secondary: #5b5f70;
  --text-muted: #868b9c;

  /* --- Semanticos: ambar = pendiente, verde = listo, rojo = error --- */
  --ok: #0f7b47;
  --ok-bg: #e8f5ee;
  --ok-border: #b6ddc7;

  --warn: #9a5b00;
  --warn-solid: #c07a08;
  --warn-bg: #fff5e3;
  --warn-border: #f3d6a4;

  --danger: #b42318;
  --danger-bg: #fdeceb;
  --danger-border: #f4c5c0;

  --info: #1f5ead;
  --info-bg: #eaf2fd;
  --info-border: #c2d9f6;

  --neutral: #5b5f70;
  --neutral-bg: #eff0f4;
  --neutral-border: #dcdee6;

  /* --- Forma --- */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(20, 22, 32, 0.05);
  --shadow-sm: 0 1px 2px rgba(20, 22, 32, 0.05), 0 1px 3px rgba(20, 22, 32, 0.05);
  --shadow-md: 0 6px 20px rgba(20, 22, 32, 0.08);
  --shadow-accent: 0 2px 8px rgba(109, 56, 139, 0.24);

  --topbar-h: 58px;
  --content: 1140px;

  --font: -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 25px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 650;
}

p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Barra superior
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--content);
  margin: 0 auto;
  min-height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-mark-lg {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 16px;
  box-shadow: var(--shadow-accent);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 550;
  white-space: nowrap;
}

.topnav a:hover {
  background: var(--surface-quiet);
  color: var(--text);
  text-decoration: none;
}

/* Estado activo derivado de la vista renderizada (sin props extra). */
body:has(.view-dashboard) .topnav a[data-nav='dashboard'],
body:has(.view-link-detail) .topnav a[data-nav='dashboard'],
body:has(.view-order-detail) .topnav a[data-nav='dashboard'],
body:has(.view-new-link) .topnav a[data-nav='new-link'] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.topbar-exit {
  margin-left: auto;
}

/* La pantalla de login no necesita navegacion. */
body:has(.view-login) .topbar {
  display: none;
}

/* ==========================================================================
   Estructura de pagina
   ========================================================================== */

.admin-main {
  max-width: var(--content);
  margin: 0 auto;
  padding: 26px 20px 72px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head-text {
  min-width: 0;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  margin-bottom: 4px;
}

.page-sub {
  margin-top: 5px;
  color: var(--text-secondary);
}

.page-title-name {
  margin-left: 10px;
  font-size: 21px;
  font-weight: 600;
  color: var(--text);
}

.section-spaced {
  margin-top: 30px;
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-secondary);
}

.back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.section {
  margin-bottom: 30px;
  scroll-margin-top: 74px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.section-meta {
  color: var(--text-muted);
  font-size: 13px;
}

.count-pill {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
}

/* Columna principal + barra lateral. */
.layout-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 322px;
  gap: 20px;
  align-items: start;
}

/* Sin barra lateral (p. ej. link cancelado y sin nota), la columna principal ocupa todo. */
.layout-split:has(> .layout-side:empty) {
  grid-template-columns: minmax(0, 1fr);
}

.layout-side:empty {
  display: none;
}

.layout-main,
.layout-side {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.layout-side {
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
}

/* ==========================================================================
   Tarjetas
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-quiet {
  background: var(--surface-alt);
  box-shadow: none;
}

.card-head {
  margin-bottom: 14px;
}

.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-sub {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 13px;
}

.card-note {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.note-text {
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.card-danger-zone {
  border-color: var(--danger-border);
  background: var(--surface);
}

.card-danger-zone h2 {
  color: var(--danger);
}

.card-danger-zone .btn-danger {
  margin-top: 14px;
}

/* ==========================================================================
   Botones
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-lg {
  min-height: 46px;
  padding: 0 20px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn-primary,
.btn-copy {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-accent);
}

.btn-primary:hover:not(:disabled),
.btn-copy:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn-primary:active:not(:disabled),
.btn-copy:active:not(:disabled) {
  background: var(--accent-deep);
}

/* Confirmacion tras copiar: el boton se pone verde por un momento. */
.copy-button.is-copied,
.copy-button.is-copied:hover {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  box-shadow: none;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-quiet);
  border-color: var(--text-muted);
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-quiet);
  color: var(--text);
}

.btn-danger {
  background: var(--surface);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.btn-dashed {
  border: 1px dashed var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.btn-dashed:hover:not(:disabled) {
  background: var(--accent-soft-strong);
  border-color: var(--accent);
}

/* ==========================================================================
   Chips, badges, alertas
   ========================================================================== */

/* Numero de pedido correlativo (DO01, DO02, ...): el identificador del equipo. */
.ref-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ref-chip-sm {
  padding: 3px 8px;
  font-size: 12px;
}

.ref-chip-lg {
  padding: 6px 14px;
  font-size: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-accent);
  vertical-align: middle;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border: 1px solid;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}

.badge-accent {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.badge-neutral {
  background: var(--neutral-bg);
  border-color: var(--neutral-border);
  color: var(--neutral);
}

.alert {
  padding: 12px 15px;
  border: 1px solid;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-weight: 550;
}

.alert-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}

.alert-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

/* ==========================================================================
   Tarjetas-resumen del dashboard
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

a.stat:hover {
  text-decoration: none;
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Cuando hay pedidos esperando, la tarjeta grita. */
.stat-alert {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.stat-alert .stat-label,
.stat-alert .stat-value {
  color: var(--warn);
}

.stat-alert .stat-hint {
  color: var(--warn);
  opacity: 0.85;
}

/* ==========================================================================
   Bloque "necesitan tu atencion"
   ========================================================================== */

.attention-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.attn {
  display: grid;
  gap: 6px;
  padding: 15px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.attn:hover {
  text-decoration: none;
  box-shadow: var(--shadow-md);
}

.attn-pending_transfer {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.attn-shopify_failed {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.attn-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.attn-name {
  font-size: 15px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.attn-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.attn-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(20, 22, 32, 0.09);
}

.attn-foot strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.attn-cta {
  font-size: 13px;
  font-weight: 650;
}

.attn-pending_transfer .attn-cta {
  color: var(--warn);
}

.attn-shopify_failed .attn-cta {
  color: var(--danger);
}

/* ==========================================================================
   Listas de pedidos y links
   ========================================================================== */

.rows {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.rows-head,
.row {
  display: grid;
  gap: 14px;
  align-items: center;
  padding: 12px 18px;
}

.rows-head {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding-top: 10px;
  padding-bottom: 10px;
}

.row {
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.row:last-child {
  border-bottom: none;
}

.row:hover {
  background: var(--surface-quiet);
  text-decoration: none;
}

/* Marca lateral para lo que exige accion: ambar por confirmar, rojo si fallo. */
.rows .row.row-attention {
  box-shadow: inset 3px 0 0 var(--warn-solid);
}

.rows .row.row-attn-shopify_failed {
  box-shadow: inset 3px 0 0 var(--danger);
}

.rows-orders .rows-head,
.rows-orders .row {
  grid-template-columns: 84px minmax(0, 1.6fr) minmax(0, 1fr) 128px 168px 12px;
  grid-template-areas: 'ref customer place amount status go';
}

.rows-links .rows-head,
.rows-links .row {
  grid-template-columns: 84px minmax(0, 1fr) 150px 168px 12px;
  grid-template-areas: 'ref customer amount status go';
}

.cell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cell-ref {
  grid-area: ref;
  align-items: flex-start;
}

.cell-customer {
  grid-area: customer;
}

.cell-place {
  grid-area: place;
}

.cell-amount {
  grid-area: amount;
  align-items: flex-end;
  text-align: right;
}

.cell-status {
  grid-area: status;
  align-items: flex-start;
}

.cell-go {
  grid-area: go;
  align-items: center;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
}

.cell-strong {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-sub {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 40px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-title {
  font-weight: 650;
  font-size: 15px;
}

.empty-hint {
  margin-top: 4px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Items y totales
   ========================================================================== */

.line-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.line-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: 'title detail total';
  gap: 6px 16px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.line-item:first-child {
  padding-top: 0;
}

.line-title {
  grid-area: title;
  font-weight: 550;
  overflow-wrap: anywhere;
}

.line-detail {
  grid-area: detail;
  color: var(--text-secondary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.line-total {
  grid-area: total;
  font-weight: 600;
  white-space: nowrap;
  min-width: 84px;
  text-align: right;
}

.totals {
  padding-top: 4px;
}

.totals-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  color: var(--text-secondary);
}

.totals-row-final {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
}

.totals-row-final strong {
  font-size: 19px;
  font-weight: 700;
}

/* ==========================================================================
   Formularios
   ========================================================================== */

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

input[type='text'],
input[type='password'],
input[type='number'],
textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* 16px evita el zoom automatico de iOS */
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea {
  min-height: 62px;
  resize: vertical;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input[readonly] {
  background: var(--surface-alt);
}

/* Filas de items del formulario de nuevo link. */
.items-head,
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 152px 104px 40px;
  grid-template-areas: 'title price qty remove';
  gap: 10px;
  align-items: center;
}

.items-head {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.items {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.item-field {
  display: block;
  min-width: 0;
}

.item-label {
  display: none;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.item-field-title {
  grid-area: title;
}

.item-field-price {
  grid-area: price;
}

.item-field-qty {
  grid-area: qty;
}

.remove-item {
  grid-area: remove;
  display: grid;
  place-items: center;
  width: 40px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}

.remove-item:hover {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.input-money {
  position: relative;
  display: block;
}

.input-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.input-money input {
  padding-left: 26px;
  font-variant-numeric: tabular-nums;
}

/* Resumen en vivo del formulario. */
.summary-card {
  display: grid;
  gap: 2px;
}

.summary-card h2 {
  margin-bottom: 8px;
}

.summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-variant-numeric: tabular-nums;
}

.summary-row strong {
  font-size: 16px;
}

.summary-row-quiet {
  color: var(--text-secondary);
  font-size: 13px;
}

.summary-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-weight: 650;
}

.summary-total strong {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.summary-note {
  margin: 10px 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-quiet);
  color: var(--text-secondary);
  font-size: 12px;
}

.summary-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Numero de pedido destacado en el formulario. */
.ref-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.ref-preview-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.ref-preview-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   Bloque para copiar el link publico
   ========================================================================== */

.share-card {
  padding: 20px;
  margin-bottom: 22px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
}

.share-card h2 {
  color: var(--accent-deep);
  font-size: 17px;
}

.share-sub {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 13px;
}

.share-head {
  margin-bottom: 14px;
}

.share-card-off {
  background: var(--surface-quiet);
  border-color: var(--border);
}

.share-card-off h2 {
  color: var(--text-secondary);
}

.copy-row {
  display: flex;
  gap: 10px;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--surface);
}

.copy-row .btn {
  flex: none;
  min-height: 44px;
  padding: 0 22px;
}

/* ==========================================================================
   Bloques de accion del detalle de pedido
   ========================================================================== */

.action-card {
  padding: 18px 20px;
  border: 1px solid;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.action-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.action-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.action-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.action-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
}

.action-warn .action-icon {
  background: var(--warn-solid);
}

.action-danger .action-icon {
  background: var(--danger);
}

.action-text h2 {
  font-size: 17px;
}

.action-warn .action-text h2 {
  color: var(--warn);
}

.action-danger .action-text h2 {
  color: var(--danger);
}

.action-text p {
  margin-top: 5px;
  color: var(--text-secondary);
}

.action-meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.error-detail {
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--danger);
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Listas de datos
   ========================================================================== */

.details {
  margin: 0;
}

.details-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 4px 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.details-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.details dt {
  color: var(--text-secondary);
  font-size: 13px;
}

.details dd {
  margin: 0;
  font-weight: 550;
  overflow-wrap: anywhere;
}

.meta-list {
  margin: 0;
  display: grid;
  gap: 11px;
}

.meta-row dt {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.meta-row dd {
  margin: 2px 0 0;
  font-weight: 550;
  overflow-wrap: anywhere;
}

.state-badge-row {
  margin: 12px 0 16px;
}

.shopify-block {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.shopify-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
}

/* ==========================================================================
   Login
   ========================================================================== */

.view-login {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 18px;
  min-height: calc(100vh - 100px);
}

.login-card {
  width: min(384px, 100%);
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-card .brand-mark-lg {
  margin: 0 auto 16px;
}

.login-card h1 {
  font-size: 23px;
}

.login-sub {
  margin-top: 5px;
  margin-bottom: 24px;
  color: var(--text-secondary);
}

.login-form {
  text-align: left;
  display: grid;
  gap: 18px;
}

.login-foot {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   Mobile — el equipo usa esto desde el telefono mientras responde Instagram
   ========================================================================== */

@media (max-width: 1080px) {
  .rows-orders .rows-head,
  .rows-orders .row {
    grid-template-columns: 80px minmax(0, 1.4fr) 124px 158px 12px;
    grid-template-areas: 'ref customer amount status go';
  }

  .rows-orders .cell-place {
    display: none;
  }
}

@media (max-width: 900px) {
  .layout-split {
    grid-template-columns: minmax(0, 1fr);
  }

  .layout-side {
    position: static;
  }

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

@media (max-width: 768px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 0 12px;
    padding: 0 14px;
  }

  .brand {
    min-height: 52px;
  }

  .topnav {
    order: 3;
    flex-basis: 100%;
    gap: 0;
    border-top: 1px solid var(--border);
  }

  .topnav a {
    flex: 1;
    justify-content: center;
    height: 44px;
    border-radius: 0;
    font-size: 13px;
  }

  body:has(.view-dashboard) .topnav a[data-nav='dashboard'],
  body:has(.view-link-detail) .topnav a[data-nav='dashboard'],
  body:has(.view-order-detail) .topnav a[data-nav='dashboard'],
  body:has(.view-new-link) .topnav a[data-nav='new-link'] {
    background: none;
    box-shadow: inset 0 -2px 0 var(--accent);
  }

  .admin-main {
    padding: 18px 14px 56px;
  }

  h1 {
    font-size: 21px;
  }

  .page-head {
    gap: 14px;
    margin-bottom: 18px;
  }

  .page-head > .btn {
    width: 100%;
  }

  .page-title-name {
    display: block;
    margin: 8px 0 0;
    font-size: 18px;
  }

  .card,
  .action-card,
  .share-card {
    padding: 16px;
    border-radius: var(--radius);
  }

  .stat {
    padding: 13px 14px;
    border-radius: var(--radius);
  }

  .stat-value {
    font-size: 21px;
  }

  .stat-label {
    font-size: 11px;
    letter-spacing: 0.04em;
  }

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

  /* Las tablas se convierten en tarjetas apiladas: nada de scroll horizontal. */
  .rows {
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    display: grid;
    gap: 10px;
    overflow: visible;
  }

  .rows-head {
    display: none;
  }

  .row,
  .rows-orders .row,
  .rows-links .row {
    padding: 13px 14px;
    gap: 4px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'ref amount'
      'customer customer'
      'place place'
      'status status';
  }

  .rows-links .row {
    grid-template-areas:
      'ref amount'
      'customer customer'
      'status status';
  }

  .rows-orders .cell-place {
    display: flex;
  }

  .cell-go {
    display: none;
  }

  .cell-ref,
  .cell-amount {
    justify-content: center;
  }

  .cell-customer {
    margin-top: 6px;
  }

  .cell-customer .cell-strong {
    font-size: 15px;
  }

  .cell-status {
    margin-top: 8px;
  }

  .cell-amount .cell-strong {
    font-size: 16px;
  }

  .rows .row.row-attention {
    box-shadow: inset 3px 0 0 var(--warn-solid), var(--shadow-sm);
  }

  .rows .row.row-attn-shopify_failed {
    box-shadow: inset 3px 0 0 var(--danger), var(--shadow-sm);
  }

  /* Filas de items: una tarjeta por item, con labels visibles. */
  .items-head {
    display: none;
  }

  .item-row {
    grid-template-columns: minmax(0, 1fr) 96px 44px;
    grid-template-areas:
      'title title title'
      'price qty remove';
    gap: 10px;
    padding: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    align-items: end;
  }

  .item-label {
    display: block;
  }

  .remove-item {
    width: 44px;
  }

  .details-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .line-item {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'title title'
      'detail total';
  }

  .copy-row {
    flex-direction: column;
  }

  .copy-row .btn {
    min-height: 48px;
  }

  .ref-preview {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
  }

  .ref-preview-hint {
    display: none;
  }

  .btn-block-mobile {
    width: 100%;
  }

  .action-card form .btn {
    width: 100%;
  }

  .card-head-row {
    flex-wrap: nowrap;
  }

  /* Objetivos tactiles comodos con el pulgar. */
  .btn-sm {
    min-height: 38px;
    padding: 0 14px;
  }

  .view-login {
    min-height: calc(100vh - 70px);
    align-content: start;
    padding-top: 24px;
  }
}

@media (max-width: 380px) {
  .item-row {
    grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-areas:
      'title title'
      'price price'
      'qty remove';
  }

  .stat-value {
    font-size: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Seccion Productos (carga con IA)
   ========================================================================== */

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

.stat-warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.stat-danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.dropzone {
  border: 2px dashed var(--accent-border);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft-strong);
}

.dropzone-title {
  font-weight: 650;
  color: var(--accent-strong);
}

.dropzone-hint {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-rows {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.upload-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto 32px;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.upload-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.upload-fields {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.upload-fields input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.upload-fields input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.upload-price {
  max-width: 160px;
}

.upload-price.is-invalid {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.upload-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 13px;
  min-width: 110px;
  text-align: right;
}

.upload-link {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-error {
  color: var(--danger);
  font-size: 12px;
  max-width: 220px;
}

.upload-remove {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  cursor: pointer;
  line-height: 1;
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.upload-history {
  display: grid;
  gap: 0;
  padding: 6px 0;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.history-row:last-child {
  border-bottom: none;
}

.history-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.history-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.history-error {
  font-size: 12px;
  color: var(--danger);
}

.history-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .stat-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .upload-row {
    grid-template-columns: 48px minmax(0, 1fr) 32px;
  }

  .upload-status {
    grid-column: 1 / -1;
    align-items: flex-start;
    text-align: left;
  }

  .history-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
