/* ============================================
   ADMIN PANEL STYLES — AfiliadosML
   ============================================ */

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

/* ---- CSS Variables (shared with public site) ---- */
:root {
  --color-bg: #07070f;
  --color-bg-2: #0d0d1a;
  --color-surface: rgba(255, 255, 255, 0.04);
  --color-surface-hover: rgba(255, 255, 255, 0.07);
  --color-surface-2: rgba(255, 255, 255, 0.06);
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-hover: rgba(255, 255, 255, 0.16);

  --color-primary: #ffe600;
  --color-primary-dark: #e6cf00;
  --color-primary-glow: rgba(255, 230, 0, 0.2);

  --color-accent-blue: #3483fa;
  --color-accent-purple: #7c3aed;
  --color-accent-green: #10b981;
  --color-accent-orange: #f59e0b;
  --color-accent-red: #ef4444;

  --color-text: #f0f0f5;
  --color-text-muted: #8b8ba7;
  --color-text-faint: #4a4a6a;

  --sidebar-w: 260px;
  --topbar-h: 64px;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow-y: 0 0 30px rgba(255, 230, 0, 0.15);

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  background: radial-gradient(ellipse 80% 60% at 30% 0%, rgba(52,131,250,.12) 0%, transparent 60%),
              radial-gradient(ellipse 60% 50% at 80% 100%, rgba(255,230,0,.08) 0%, transparent 60%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: 0 32px 80px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06);
  animation: slide-up .4s cubic-bezier(.34,1.56,.64,1);
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(30px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo-img {
  height: 56px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(255, 215, 60, 0.25));
}

.login-logo-text { font-size: 1.2rem; font-weight: 800; color: var(--color-text); }

.login-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.login-subtitle { font-size: .9rem; color: var(--color-text-muted); margin-bottom: 28px; }

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 13px 16px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  outline: none;
  transition: var(--transition);
}
.form-input::placeholder { color: var(--color-text-faint); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  background: rgba(255,255,255,.07);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select option { background: #1a1a2e; }
.form-hint { font-size: .76rem; color: var(--color-text-faint); margin-top: 5px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: var(--radius-full);
  font-family: 'Inter', sans-serif;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--color-primary);
  color: #07070f;
  box-shadow: 0 0 24px var(--color-primary-glow);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 32px var(--color-primary-glow);
}
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}
.btn-danger {
  background: rgba(239,68,68,.15);
  color: var(--color-accent-red);
  border: 1px solid rgba(239,68,68,.25);
}
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  padding: 8px 14px;
  font-size: .83rem;
}
.btn-ghost:hover { background: var(--color-surface); color: var(--color-text); }
.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: .85rem;
}
.btn-icon:hover { background: var(--color-surface-hover); color: var(--color-text); }
.btn-icon.danger:hover { color: var(--color-accent-red); border-color: rgba(239,68,68,.3); }

.login-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: .85rem;
  color: var(--color-accent-red);
  margin-bottom: 16px;
  display: none;
}
.login-error.visible { display: block; }

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.admin-sidebar {
  width: var(--sidebar-w);
  background: rgba(255,255,255,.03);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo-img {
  height: 48px;
  width: auto;
  max-width: 88px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(255, 215, 60, 0.22));
}

.sidebar-brand-text {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-subtitle { font-size: .7rem; color: var(--color-text-faint); margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--color-text-faint);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}

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

.nav-item.active {
  background: rgba(255,230,0,.1);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--color-primary);
}

.nav-item .nav-icon { width: 18px; text-align: center; font-size: .95rem; }
.nav-item .nav-badge {
  margin-left: auto;
  padding: 2px 8px;
  background: rgba(255,230,0,.15);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: .7rem;
  font-weight: 700;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-toggle .nav-chevron {
  margin-left: auto;
  font-size: .7rem;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.nav-group-toggle.open .nav-chevron,
.nav-group.open .nav-group-toggle .nav-chevron {
  transform: rotate(180deg);
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 6px 12px;
  margin-left: 10px;
  border-left: 1px solid var(--color-border);
}

.nav-submenu[hidden] {
  display: none !important;
}

.nav-subitem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-muted);
  font-size: .82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.nav-subitem i {
  width: 14px;
  text-align: center;
  font-size: .78rem;
  opacity: 0.85;
}

.nav-subitem:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.nav-subitem.active {
  background: rgba(255, 230, 0, 0.12);
  color: var(--color-primary);
  font-weight: 700;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--color-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  margin-bottom: 8px;
}

.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent-purple), var(--color-accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-name { font-size: .85rem; font-weight: 600; }
.sidebar-user-role { font-size: .72rem; color: var(--color-text-muted); }

.btn-logout {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-family: 'Inter', sans-serif;
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-logout:hover {
  background: rgba(239,68,68,.1);
  border-color: rgba(239,68,68,.3);
  color: var(--color-accent-red);
}

/* ---- MAIN CONTENT ---- */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- TOP BAR ---- */
.admin-topbar {
  height: var(--topbar-h);
  background: rgba(7,7,15,.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}
.topbar-subtitle {
  font-size: .75rem;
  color: var(--color-text-muted);
}

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

.topbar-live-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--color-text-muted);
}

.topbar-live-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-accent-green);
  animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
  50% { opacity: .8; box-shadow: 0 0 0 4px rgba(16,185,129,0); }
}

/* ---- CONTENT AREA ---- */
.admin-content { padding: 28px; flex: 1; }

.section-panel { display: none; }
.section-panel.active { display: block; animation: fade-in .2s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 4px; }
.page-subtitle { font-size: .85rem; color: var(--color-text-muted); }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--color-border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: .12;
  transform: translate(20px, -20px);
}
.stat-card.blue::before { background: var(--color-accent-blue); }
.stat-card.green::before { background: var(--color-accent-green); }
.stat-card.yellow::before { background: var(--color-primary); }
.stat-card.purple::before { background: var(--color-accent-purple); }
.stat-card.orange::before { background: var(--color-accent-orange); }

.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 14px;
}
.stat-card.blue .stat-card-icon { background: rgba(52,131,250,.15); color: var(--color-accent-blue); }
.stat-card.green .stat-card-icon { background: rgba(16,185,129,.15); color: var(--color-accent-green); }
.stat-card.yellow .stat-card-icon { background: rgba(255,230,0,.15); color: var(--color-primary); }
.stat-card.purple .stat-card-icon { background: rgba(124,58,237,.15); color: var(--color-accent-purple); }
.stat-card.orange .stat-card-icon { background: rgba(245,158,11,.15); color: var(--color-accent-orange); }

.stat-card-value {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 4px;
  letter-spacing: -.02em;
}
.stat-card-label { font-size: .8rem; color: var(--color-text-muted); font-weight: 500; }
.stat-card-change {
  font-size: .75rem;
  margin-top: 8px;
  font-weight: 600;
}
.stat-card-change.positive { color: var(--color-accent-green); }
.stat-card-change.negative { color: var(--color-accent-red); }

/* ============================================================
   CHART + DASHBOARD
   ============================================================ */
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 0;
}

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

.chart-title { font-size: 1rem; font-weight: 700; }
.chart-subtitle { font-size: .78rem; color: var(--color-text-muted); }

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--color-text-muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.clicks { background: var(--color-primary); }
.legend-dot.views { background: var(--color-accent-blue); }

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  min-height: 220px;
}

.chart-canvas-sm {
  min-height: 210px;
  max-height: 260px;
}

.dash-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0 20px;
}

.insight-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.insight-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(124, 58, 237, 0.15);
  color: #a78bfa;
  flex-shrink: 0;
}

.insight-icon.green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.insight-icon.blue { background: rgba(52, 131, 250, 0.15); color: #60a5fa; }
.insight-icon.yellow { background: rgba(255, 230, 0, 0.15); color: var(--color-primary); }
.insight-icon.purple { background: rgba(124, 58, 237, 0.15); color: #a78bfa; }
.insight-icon.orange { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.insight-value {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--color-text);
}

.insight-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.dash-charts-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

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

.funnel-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.funnel-pill {
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-border);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.funnel-pill strong {
  color: var(--color-text);
  font-weight: 700;
}

.dash-ranking {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ranking-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--color-border);
}

.ranking-pos {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  background: rgba(255, 230, 0, 0.12);
  color: var(--color-primary);
}

.ranking-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.ranking-clicks {
  font-weight: 800;
  color: var(--color-primary);
  white-space: nowrap;
}

.ranking-empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

@media (max-width: 980px) {
  .dash-charts-grid {
    grid-template-columns: 1fr;
  }
  .chart-card-wide {
    grid-column: auto;
  }
}

/* ============================================================
   TABLES
   ============================================================ */
.table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.table-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.table-title { font-size: .95rem; font-weight: 700; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  padding: 10px 18px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-faint);
  border-bottom: 1px solid var(--color-border);
  background: rgba(0,0,0,.2);
}

.admin-table td {
  padding: 13px 18px;
  font-size: .87rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table tr:hover td { background: rgba(255,255,255,.02); }

.table-product-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-thumb {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: rgba(255,255,255,.05);
  flex-shrink: 0;
}

.table-product-title {
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 240px;
}

.table-product-cat {
  font-size: .72rem;
  color: var(--color-text-faint);
  margin-top: 2px;
}

.badge-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 700;
}
.badge-pill.green { background: rgba(16,185,129,.15); color: var(--color-accent-green); }
.badge-pill.blue { background: rgba(52,131,250,.15); color: var(--color-accent-blue); }
.badge-pill.yellow { background: rgba(255,230,0,.15); color: var(--color-primary); }
.badge-pill.red { background: rgba(239,68,68,.15); color: var(--color-accent-red); }

.ctr-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctr-bar-track {
  width: 60px; height: 5px;
  background: rgba(255,255,255,.08);
  border-radius: 3px;
  overflow: hidden;
}
.ctr-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width .5s ease;
}

.actions-cell { display: flex; gap: 6px; justify-content: flex-end; }

.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-muted);
}
.table-empty-icon { font-size: 2.5rem; opacity: .3; margin-bottom: 12px; }
.table-empty-text { font-size: .9rem; }

/* ============================================================
   PRODUCT ADD/EDIT PANEL
   ============================================================ */
.add-product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.fetch-preview-box {
  display: none;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,230,0,.2);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 14px;
  gap: 14px;
  align-items: flex-start;
}
.fetch-preview-box.visible { display: flex; }
.fetch-preview-img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }
.fetch-preview-info {}
.fetch-preview-title { font-size: .88rem; font-weight: 600; line-height: 1.4; margin-bottom: 4px; }
.fetch-preview-price { font-size: 1.1rem; font-weight: 800; color: var(--color-primary); }
.fetch-preview-ok { font-size: .75rem; color: var(--color-accent-green); margin-top: 6px; }

.input-row { display: flex; gap: 12px; }
.input-row .form-group { flex: 1; }

/* ============================================================
   IMPORT SECTION
   ============================================================ */
.import-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.import-steps {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.import-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 160px;
  padding: 14px 18px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,230,0,.15);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 800;
  flex-shrink: 0;
}

.step-label { font-size: .8rem; font-weight: 600; }
.step-desc { font-size: .72rem; color: var(--color-text-muted); }

.import-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 4px;
}

.import-item {
  background: rgba(255,255,255,.03);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.import-item:hover { border-color: rgba(255,230,0,.3); background: rgba(255,230,0,.04); }
.import-item.selected { border-color: var(--color-primary); background: rgba(255,230,0,.06); }
.import-item.selected::after {
  content: '✓';
  position: absolute;
  top: 8px; right: 8px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #07070f;
  font-size: .7rem;
  font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}

.import-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: rgba(255,255,255,.03);
}

.import-item-title {
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.import-item-price { font-size: .95rem; font-weight: 800; color: var(--color-primary); }

.import-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: 10px;
}

.import-selected-count { font-size: .85rem; color: var(--color-text-muted); }
.import-selected-count strong { color: var(--color-primary); }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 560px);
  gap: 20px;
  max-width: 640px;
}

.settings-card[hidden] {
  display: none !important;
}

.settings-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.settings-card-title {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.settings-card-desc { font-size: .8rem; color: var(--color-text-muted); margin-bottom: 20px; }
.settings-divider { height: 1px; background: var(--color-border); margin: 16px 0; }

.header-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-color-row input[type="color"] {
  width: 48px;
  height: 44px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  flex-shrink: 0;
}

.header-color-row #settings-header-color-hex {
  max-width: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.header-color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.header-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 1px var(--color-border);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.header-swatch:hover {
  transform: scale(1.1);
}

.header-swatch.active {
  box-shadow: 0 0 0 2px var(--color-primary), 0 0 0 1px var(--color-border);
}

.header-color-preview {
  margin-top: 14px;
  height: 56px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: #dff4ff;
  color: #0a2540;
  font-size: 0.85rem;
  font-weight: 700;
}

.header-color-preview-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
  display: block;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: #1a1a2e;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: .86rem;
  font-weight: 500;
  color: var(--color-text);
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  animation: toast-in .3s cubic-bezier(.34,1.56,.64,1);
  min-width: 260px;
  max-width: 340px;
}

@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.toast.fade-out { animation: toast-out .25s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px) scale(.95); } }
.toast.success { border-left: 3px solid var(--color-accent-green); }
.toast.error { border-left: 3px solid var(--color-accent-red); }
.toast.info { border-left: 3px solid var(--color-accent-blue); }
.toast.warn { border-left: 3px solid var(--color-accent-orange); }

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.loading-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.15);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.divider { height: 1px; background: var(--color-border); margin: 20px 0; }

.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-green { color: var(--color-accent-green); }
.text-red { color: var(--color-accent-red); }

.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: .85rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert.info { background: rgba(52,131,250,.08); border: 1px solid rgba(52,131,250,.2); color: #93c5fd; }
.alert.success { background: rgba(16,185,129,.08); border: 1px solid rgba(16,185,129,.2); color: #6ee7b7; }
.alert.warn { background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.2); color: #fcd34d; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .admin-sidebar {
    transform: translateX(-260px);
    width: 260px;
  }
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,.5);
  }
  .admin-main { margin-left: 0; }
  .admin-content { padding: 16px; }
  .input-row { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Backdrop atrás do menu aberto */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .admin-topbar { padding: 0 14px; }
  .topbar-title { font-size: 0.95rem; }
  .topbar-subtitle { display: none; }
  .topbar-live-dot { display: none; }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-header .flex { justify-content: stretch; }
  .page-header .flex > * { flex: 1; }

  .dash-insights { grid-template-columns: 1fr 1fr; }
  .chart-canvas-wrap { min-height: 200px; }
  .chart-canvas-sm { min-height: 190px; max-height: 230px; }

  .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table { min-width: 640px; }
}

@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card-value { font-size: 1.3rem; }
  .login-card { padding: 28px 20px; }
  .dash-insights { grid-template-columns: 1fr 1fr; gap: 8px; }
  .insight-card { padding: 10px 12px; gap: 8px; }
  .insight-icon { width: 32px; height: 32px; font-size: 0.85rem; }
  .insight-value { font-size: 0.98rem; }
  .insight-label { font-size: 0.68rem; }
  .chart-card { padding: 14px; }
  .dash-ranking { padding: 14px; }
  .ranking-item { grid-template-columns: 28px 1fr auto; gap: 8px; padding: 8px 10px; }
  .ranking-pos { width: 26px; height: 26px; font-size: 0.75rem; }
  .form-actions-row, .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; justify-content: center; }
}
