/* ═══════════════════════════════════════════════════════════
   CommerceFlow — Design System
   Dark / Light mode + Mobile-first
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
a { text-decoration: none; }

/* ══════════════════════════════════════════════════════════
   TOKENS — Light Mode (default)
   B2BFlow palette — extraída del logo
   ══════════════════════════════════════════════════════════ */
:root {
  /* Brand — del gradiente del icono */
  --brand:         #0f1b3d;
  --brand-mid:     #1e3a8a;
  --accent:        #3d7bff;   /* "nube" azul brillante */
  --accent-hover:  #2563eb;
  --accent-soft:   rgba(61,123,255,.12);
  --accent-light:  #6fa3ff;   /* "2" superscript — azul suave */

  /* Surfaces */
  --bg:            #f0f4ff;   /* blanco con tinte azul muy leve */
  --surface:       #ffffff;
  --surface-2:     #f5f8ff;
  --border:        #dde5f5;
  --border-strong: #b8c9e8;

  /* Text */
  --text:          #12224e;   /* "b2b" color del logo */
  --text-2:        #1e3a8a;
  --text-muted:    #5b7ab0;
  --text-subtle:   #94afd4;

  /* Status */
  --success:       #22c55e;
  --success-soft:  #dcfce7;
  --success-text:  #15803d;
  --warning:       #f59e0b;
  --warning-soft:  #fef9c3;
  --warning-text:  #b45309;
  --danger:        #ef4444;
  --danger-soft:   #fee2e2;
  --danger-text:   #b91c1c;
  --info:          #6fa3ff;
  --info-soft:     #dbeafe;
  --info-text:     #1e3a8a;

  /* Layout */
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-full:   9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15,27,61,.06);
  --shadow-sm: 0 1px 3px rgba(15,27,61,.10), 0 1px 2px rgba(15,27,61,.06);
  --shadow:    0 4px 6px rgba(15,27,61,.07), 0 2px 4px rgba(15,27,61,.05);
  --shadow-md: 0 10px 15px rgba(15,27,61,.09), 0 4px 6px rgba(15,27,61,.05);
  --shadow-lg: 0 20px 25px rgba(15,27,61,.10), 0 8px 10px rgba(15,27,61,.06);

  /* Sidebar — siempre dark, usa los colores del icono */
  --sidebar-bg:       #0f1b3d;
  --sidebar-text:     rgba(255,255,255,.65);
  --sidebar-text-act: #ffffff;
  --sidebar-border:   rgba(255,255,255,.08);
  --sidebar-hover:    rgba(111,163,255,.10);
  --sidebar-active:   var(--accent);

  /* Transitions */
  --transition: .2s ease;
}

/* ══════════════════════════════════════════════════════════
   TOKENS — Dark Mode
   ══════════════════════════════════════════════════════════ */
[data-theme="dark"] {
  /* Superficies — del fondo oscuro del icono */
  --bg:            #080d1a;
  --surface:       #0f1b3d;   /* = --brand, el azul más oscuro del logo */
  --surface-2:     #152248;
  --border:        #1e3060;
  --border-strong: #2a4480;

  /* Texto */
  --text:          #e8f0ff;
  --text-2:        #a8c0f0;
  --text-muted:    #6fa3ff;   /* = --accent-light */
  --text-subtle:   #3d5a99;

  /* Accent más brillante en dark */
  --accent:        #6fa3ff;
  --accent-hover:  #4d87ff;
  --accent-soft:   rgba(111,163,255,.15);

  /* Status */
  --success-soft:  rgba(34,197,94,.15);
  --success-text:  #4ade80;
  --warning-soft:  rgba(245,158,11,.15);
  --warning-text:  #fbbf24;
  --danger-soft:   rgba(239,68,68,.15);
  --danger-text:   #f87171;
  --info-soft:     rgba(111,163,255,.15);
  --info-text:     #93c5fd;

  /* Sombras más pronunciadas sobre dark */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.5);
  --shadow:    0 4px 6px rgba(0,0,0,.4);
  --shadow-md: 0 10px 15px rgba(0,0,0,.5);

  /* Sidebar en dark — tono más profundo que el fondo */
  --sidebar-bg:     #060b14;
  --sidebar-border: rgba(111,163,255,.08);
  --sidebar-hover:  rgba(111,163,255,.08);
}

/* ══════════════════════════════════════════════════════════
   BASE
   ══════════════════════════════════════════════════════════ */
html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

/* ══════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition), box-shadow var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo h1 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.4px;
  line-height: 1.2;
}

.sidebar-logo h1 span { color: var(--accent); }

.sidebar-logo p {
  font-size: 10px;
  color: rgba(255,255,255,.35);
  margin-top: 2px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.25);
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 10px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  position: relative;
}

.nav-item:hover {
  color: var(--sidebar-text-act);
  background: var(--sidebar-hover);
}

.nav-item.active {
  color: var(--sidebar-text-act);
  background: var(--accent);
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item.active .nav-icon { opacity: 1; }

/* Sidebar bottom */
.sidebar-bottom {
  padding: 12px 10px 16px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.store-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.store-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.store-details { overflow: hidden; }

.store-details .store-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.store-details .store-plan {
  font-size: 10px;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: none;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.4);
  font-size: 12px;
  font-weight: 500;
  transition: all .15s;
}

.btn-logout:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.7);
  border-color: rgba(255,255,255,.2);
}

/* ── Main content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background var(--transition), border-color var(--transition);
  box-shadow: var(--shadow-xs);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-hamburger {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all .15s;
}

.btn-hamburger:hover { background: var(--surface-2); color: var(--text); }

.btn-hamburger svg { display: block; }

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.store-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.store-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-soft);
}

/* Theme toggle */
.btn-theme {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  font-size: 16px;
}

.btn-theme:hover { background: var(--border); color: var(--text); }

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}

/* ══════════════════════════════════════════════════════════
   PAGE BODY
   ══════════════════════════════════════════════════════════ */
.page-body {
  padding: 24px;
  flex: 1;
  max-width: 1200px;
  width: 100%;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ══════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  transition: background var(--transition), border-color var(--transition);
  overflow: visible;
}

/* Clip only the header so it respects the card's top border-radius */
.card-header {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.card-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.card-body { padding: 20px; }

/* ══════════════════════════════════════════════════════════
   FORM
   ══════════════════════════════════════════════════════════ */
.rule-form {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

/* Right panel: inputs + button stacked */
.rule-form-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-form-controls .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rule-form-controls .btn {
  width: 100%;
  justify-content: center;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.form-control {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s, background var(--transition);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-control::placeholder { color: var(--text-subtle); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ══════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: 1.5px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  cursor: pointer;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(233,69,96,.3);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 4px 10px rgba(233,69,96,.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger-text);
  border-color: transparent;
  padding: 6px 10px;
  font-size: 12px;
}
.btn-danger-soft:hover {
  background: var(--danger);
  color: #fff;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ══════════════════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background .1s;
}

tbody tr:hover td { background: var(--surface-2); }

.product-name {
  font-weight: 500;
  color: var(--text);
}

.product-id {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── Rule cards (mobile) ── */
.rule-cards { display: none; }

.rule-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.rule-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.rule-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.rule-card-id {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.rule-card-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: var(--success-soft); color: var(--success-text); }
.badge-yellow { background: var(--warning-soft); color: var(--warning-text); }
.badge-red    { background: var(--danger-soft);  color: var(--danger-text);  }
.badge-blue   { background: var(--info-soft);    color: var(--info-text);    }

/* ══════════════════════════════════════════════════════════
   CODE BLOCK
   ══════════════════════════════════════════════════════════ */
.code-block {
  position: relative;
  background: #0f172a;
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
}

.code-block pre {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  color: #e2e8f0;
  line-height: 1.7;
  white-space: pre;
}

.code-block .copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.6);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.code-block .copy-btn:hover {
  background: rgba(255,255,255,.2);
  color: #fff;
}

/* ══════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 14px;
}

.empty-state h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════
   AUTH SCREENS
   ══════════════════════════════════════════════════════════ */
.screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.screen.active { display: flex; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 28px;
  letter-spacing: -.4px;
}

.auth-logo span { color: var(--accent); }

.auth-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--danger-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 16px;
}

.auth-icon.loading-icon {
  background: var(--accent-soft);
}

.auth-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.auth-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.7;
}

/* ══════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .25s cubic-bezier(.34,1.56,.64,1);
  pointer-events: all;
  max-width: 320px;
}

.toast-success {
  background: var(--surface);
  border: 1px solid var(--success);
  color: var(--success-text);
}

.toast-error {
  background: var(--surface);
  border: 1px solid var(--danger);
  color: var(--danger-text);
}

.toast-icon { font-size: 16px; flex-shrink: 0; }

@keyframes toastIn {
  from { transform: translateX(16px) scale(.96); opacity: 0; }
  to   { transform: translateX(0)    scale(1);   opacity: 1; }
}

/* ══════════════════════════════════════════════════════════
   SPINNER
   ══════════════════════════════════════════════════════════ */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════
   DIVIDER
   ══════════════════════════════════════════════════════════ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ══════════════════════════════════════════════════════════
   PRODUCT PICKER
   ══════════════════════════════════════════════════════════ */

.product-picker { position: relative; }

.product-picker-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
  min-height: 40px;
}

.product-picker-trigger:focus,
.product-picker-trigger.open {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.product-picker-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.product-picker-thumb-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-subtle);
}

.product-picker-info { flex: 1; overflow: hidden; }

.product-picker-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-picker-placeholder {
  font-size: 13px;
  color: var(--text-subtle);
}

.product-picker-sku {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.product-picker-chevron {
  color: var(--text-subtle);
  flex-shrink: 0;
  transition: transform .15s;
}

.product-picker-trigger.open .product-picker-chevron {
  transform: rotate(180deg);
}

/* Dropdown */
.product-picker-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 500;
  overflow: hidden;
}

.product-picker-dropdown.open { display: block; }

.product-picker-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.product-picker-search input {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color .15s;
}

.product-picker-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.product-picker-list {
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.product-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--border);
}

.product-picker-item:last-child { border-bottom: none; }

.product-picker-item:hover { background: var(--surface-2); }

.product-picker-item.selected { background: var(--accent-soft); }

.product-picker-item img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.product-picker-item-no-img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.product-picker-item-info { flex: 1; overflow: hidden; }

.product-picker-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-picker-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  gap: 8px;
}

.product-picker-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Table product cell ── */
.product-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-cell-img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface-2);
}

.product-cell-img-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.product-cell-info { overflow: hidden; }

.product-cell-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-cell-sku {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (max 1024px)
   ══════════════════════════════════════════════════════════ */
/* ══════════════════════════════════════════════════════════
   PAGE LOADER
   ══════════════════════════════════════════════════════════ */
.page-loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  transition: opacity .45s ease, visibility .45s ease;
}
.page-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-icon {
  width: 72px; height: 72px;
  animation: loaderIconIn .55s cubic-bezier(.34,1.56,.64,1) both, loaderPulse 2.4s ease-in-out .55s infinite;
  filter: drop-shadow(0 8px 24px rgba(61,123,255,.35));
}
@keyframes loaderIconIn {
  from { opacity: 0; transform: scale(.55) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes loaderPulse {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 8px 24px rgba(61,123,255,.3)); }
  50%       { transform: scale(1.06); filter: drop-shadow(0 12px 32px rgba(61,123,255,.55)); }
}
.loader-track {
  width: 100px; height: 3px; border-radius: 99px;
  background: var(--border); overflow: hidden;
}
.loader-track::after {
  content: ''; display: block; height: 100%; width: 38%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 99px;
  animation: loaderSlide 1.3s ease-in-out infinite;
}
@keyframes loaderSlide {
  from { transform: translateX(-260%); }
  to   { transform: translateX(390%); }
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR LOGO (SVG icon version)
   ══════════════════════════════════════════════════════════ */
.sidebar-logo-img { width: 36px; height: 36px; flex-shrink: 0; }
.sidebar-logo-text { display: flex; flex-direction: column; }
.sidebar-logo-text strong { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: -.4px; line-height: 1; }
.sidebar-logo-text strong span { color: var(--accent-light); }
.sidebar-logo-text small { font-size: 10px; color: rgba(255,255,255,.35); letter-spacing: .04em; margin-top: 2px; }
.sidebar-logo { gap: 10px; align-items: center; }

/* ══════════════════════════════════════════════════════════
   STAT ROW  (dashboard mini-stats)
   ══════════════════════════════════════════════════════════ */
.stat-row {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 20px;
}
.stat-mini {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.stat-mini:hover { border-color: var(--border-strong); box-shadow: 0 2px 12px rgba(0,0,0,.07); }
.stat-mini-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--accent-soft);
}
.stat-mini-val { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-mini-lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET + MOBILE (≤ 1024px) sidebar off-canvas
   ══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }

  /* Sidebar off-canvas */
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.open { display: block; }

  /* Content full width */
  .main-content { margin-left: 0 !important; }

  /* Show hamburger */
  .btn-hamburger { display: flex; }

  .page-body { padding: 20px; }
  .stat-row { grid-template-columns: repeat(3,1fr); }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .topbar-title { font-size: 14px; }
  .store-badge .store-label { display: none; }

  .page-body { padding: 14px; }

  .rule-form { grid-template-columns: 1fr; gap: 14px; }
  .rule-form-controls .form-row { grid-template-columns: 1fr 1fr; }

  /* Table → hidden, show cards */
  .table-wrap table { display: none; }
  .rule-cards { display: block; }

  .auth-card { padding: 32px 24px; }

  .toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { max-width: 100%; }

  .card-header { padding: 14px 16px; }
  .card-body   { padding: 16px; }

  .stat-row { grid-template-columns: 1fr 1fr; }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (≤ 480px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .rule-form { grid-template-columns: 1fr; }
  .rule-form-controls .form-row { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  .topbar-right { gap: 8px; }
}

/* ══════════════════════════════════════════════════════════
   PAGE CONTENT — contenedor principal con padding
   ══════════════════════════════════════════════════════════ */
.page-content {
  padding: 28px 28px 40px;
  max-width: 1100px;
  width: 100%;
}

@media (max-width: 1024px) { .page-content { padding: 20px; } }
@media (max-width: 768px)  { .page-content { padding: 16px; } }

/* ══════════════════════════════════════════════════════════
   INPUT — alias de form-control para el panel nuevo
   ══════════════════════════════════════════════════════════ */
.input {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s, background var(--transition);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-subtle); }
.input-sm { padding: 7px 10px; font-size: 12px; }

/* ══════════════════════════════════════════════════════════
   CARD TITLE / SUBTITLE
   ══════════════════════════════════════════════════════════ */
.card-title    { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════
   STAT MINI — aliases para las clases usadas en el HTML
   ══════════════════════════════════════════════════════════ */
.stat-mini-value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-mini-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ══════════════════════════════════════════════════════════
   BUTTONS — secundario + iconos
   ══════════════════════════════════════════════════════════ */
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--border);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-icon {
  width: 30px; height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
}

/* ══════════════════════════════════════════════════════════
   TOPBAR — secciones internas
   ══════════════════════════════════════════════════════════ */
.topbar-store {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
  cursor: default;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR — secciones internas
   ══════════════════════════════════════════════════════════ */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-footer {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-brand {
  font-size: 15px; font-weight: 700; color: #fff;
  letter-spacing: -.3px; line-height: 1.2;
  display: block;
}
.sidebar-sub {
  font-size: 10px; color: rgba(255,255,255,.32);
  letter-spacing: .03em;
  display: block; margin-top: 1px;
}

/* ══════════════════════════════════════════════════════════
   STORE CHIP — topbar y sidebar footer
   ══════════════════════════════════════════════════════════ */
.store-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  padding: 4px 0;
}
.store-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.15);
}
.store-chip .store-name {
  font-size: 13px; font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.store-chip .store-plan {
  font-size: 10px; color: var(--text-muted);
  white-space: nowrap;
}

/* Sidebar footer store chip */
.sidebar-footer .store-chip {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
}
.sidebar-footer .store-chip .store-name {
  font-size: 12px; color: rgba(255,255,255,.85);
}
.sidebar-footer .store-chip .store-plan {
  font-size: 10px; color: rgba(255,255,255,.35);
}
.sidebar-footer .store-chip .store-avatar {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

/* Nav badge */
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px; text-align: center;
}

/* ══════════════════════════════════════════════════════════
   RULE CONTROLS — formulario inline de nueva regla
   ══════════════════════════════════════════════════════════ */
.rule-controls-inline {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.rule-inline-fields {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.rule-inline-fields .form-group { margin: 0; min-width: 110px; }
.rule-inline-fields .form-group label {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: 5px;
}
.rule-inline-fields .btn { white-space: nowrap; flex-shrink: 0; }

@media (max-width: 768px) {
  .rule-controls-inline { flex-direction: column; align-items: stretch; }
  .rule-inline-fields { flex-wrap: wrap; }
  .rule-inline-fields .form-group { min-width: calc(50% - 5px); flex: 1; }
}

/* ══════════════════════════════════════════════════════════
   PRODUCT PICKER — search wrap
   ══════════════════════════════════════════════════════════ */
.product-picker-search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.product-picker-search-wrap .product-picker-search,
.product-picker-search {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color .15s;
}
.product-picker-search:focus { outline: none; border-color: var(--accent); }

/* ══════════════════════════════════════════════════════════
   CODE BLOCK WRAP — snippet de integración
   ══════════════════════════════════════════════════════════ */
.code-block-wrap {
  position: relative;
  background: #0c1222;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #1e2d4a;
}
.code-block-wrap pre.code-block,
.code-block-wrap .code-block {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px; line-height: 1.75;
  color: #a8c0f0;
  padding: 16px;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.code-copy-btn {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(111,163,255,.15);
  border: 1px solid rgba(111,163,255,.25);
  color: rgba(111,163,255,.8);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.code-copy-btn:hover {
  background: rgba(111,163,255,.3);
  color: #fff;
}

/* ══════════════════════════════════════════════════════════
   DESKTOP-ONLY / MOBILE-ONLY
   ══════════════════════════════════════════════════════════ */
.desktop-only { display: block; }
.mobile-only  { display: none; }
@media (max-width: 768px) {
  .desktop-only { display: none; }
  .mobile-only  { display: block; }
}

/* ══════════════════════════════════════════════════════════
   INLINE EDIT ROW — edición de reglas en tabla
   ══════════════════════════════════════════════════════════ */
tr.editing td { background: var(--accent-soft) !important; }

.edit-input {
  padding: 5px 8px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  width: 80px;
  appearance: none;
}
.edit-input:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.btn-edit {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  padding: 5px 10px;
  font-size: 12px;
}
.btn-edit:hover { background: var(--accent); color: #fff; }

.btn-save-inline {
  background: var(--success-soft);
  color: var(--success-text);
  border-color: transparent;
  padding: 5px 10px;
  font-size: 12px;
}
.btn-save-inline:hover { background: var(--success); color: #fff; }

.btn-cancel-inline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  padding: 5px 10px;
  font-size: 12px;
}
.btn-cancel-inline:hover { background: var(--surface-2); color: var(--text); }

/* Acciones en tabla — grupo de botones */
.rule-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

/* ══════════════════════════════════════════════════════════
   FORM LABEL — alias genérico
   ══════════════════════════════════════════════════════════ */
.form-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
  display: block; margin-bottom: 5px;
}

/* ══════════════════════════════════════════════════════════
   DRAWER — panel lateral deslizable
   ══════════════════════════════════════════════════════════ */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45);
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}
.drawer-overlay.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 201;
  width: 440px; max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.drawer-title { font-size: 15px; font-weight: 700; color: var(--text); }

.drawer-body {
  flex: 1; overflow-y: auto;
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 16px;
}

/* aviso de trial vencido */
.trial-warning {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--warning-soft); border: 1px solid var(--warning);
  font-size: 12px; font-weight: 600; color: var(--warning-text);
}

/* select nativo dentro del drawer */
.drawer select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b7ab0' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* helpers del drawer */
.drawer-field-value { font-size: 14px; color: var(--text); padding: 2px 0; }
.fw-600  { font-weight: 600; }
.font-mono { font-family: monospace; color: var(--text-subtle); font-size: 13px; }
.text-subtle { color: var(--text-subtle); font-size: 13px; }
.drawer-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* grid de 2 columnas para forms */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 360px) { .form-row-2 { grid-template-columns: 1fr; } }

/* Drawer — card-body: flex column con gap para espaciado consistente */
.drawer .card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
}

/* Input de fecha: ancho acotado */
.drawer input[type="date"] { max-width: 200px; }

/* Botón de guardar — alineado al inicio */
.drawer #btn-save-plan,
.drawer #btn-save-credentials { align-self: flex-start; }

@media (max-width: 520px) {
  .drawer { width: 100vw; }
}
ials { align-self: flex-start; }
