:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #22263a;
  --bg-input: #141720;
  --border: #2a2f42;
  --text: #e8eaf0;
  --text-muted: #8b92a8;
  --primary: #6c5ce7;
  --primary-hover: #7d6ff0;
  --primary-glow: rgba(108, 92, 231, 0.25);
  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #e17055;
  --ml: #ffe600;
  --shopee: #ee4d2d;
  --tiktok: #fe2c55;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --sidebar-w: 240px;
  --font: 'DM Sans', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

.app {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.logo-icon { font-size: 1.5rem; }
.logo-text { font-weight: 700; font-size: 1.15rem; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

.sidebar-bottom {
  flex-shrink: 0;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 42%;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--primary-glow); color: var(--primary); font-weight: 600; }

.platform-status {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--danger); }
.status-dot.simulation { background: var(--warning); }

/* Main */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  width: calc(100% - var(--sidebar-w));
  min-width: 0;
  padding: 2rem;
  max-width: calc(1400px + var(--sidebar-w));
  box-sizing: border-box;
}

.view { display: none; }
.view.active { display: block; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.75rem; font-weight: 700; }
.subtitle { color: var(--text-muted); margin-top: 0.25rem; font-size: 0.9rem; }

.header-actions { display: flex; gap: 0.75rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 0 20px var(--primary-glow); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.card-header-row .card-title { margin-bottom: 0; }

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.25rem;
}

.form-group {
  margin-bottom: 1rem;
  position: relative;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.char-count {
  position: absolute;
  right: 0.5rem;
  bottom: -1.2rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

/* Toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.toggle input { display: none; }
.toggle-slider {
  width: 36px; height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::after { transform: translateX(16px); }

/* Category mapping */
.category-mapping { margin-top: 0.75rem; }
.mapping-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.mapping-items { display: flex; flex-direction: column; gap: 0.4rem; }

.mapping-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.mapping-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.mapping-badge.ml { background: var(--ml); color: #333; }
.mapping-badge.shopee { background: var(--shopee); color: #fff; }
.mapping-badge.tiktok { background: var(--tiktok); color: #fff; }

/* Variations */
.variation-types { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }

.variation-axis {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.axis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.axis-header input {
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  font-family: var(--font);
  width: 120px;
}

.axis-options { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.option-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: var(--bg-hover);
  border-radius: 20px;
  font-size: 0.8rem;
}

.option-chip input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.8rem;
  width: 60px;
  font-family: var(--font);
}

.option-chip button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
}

.add-option-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: var(--font);
}
.add-option-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Variation table */
#variationTable {
  overflow-x: auto;
  margin-top: 0.75rem;
  -webkit-overflow-scrolling: touch;
}
.var-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.var-table th, .var-table td {
  padding: 0.5rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.var-table th { background: var(--bg-input); font-weight: 600; color: var(--text-muted); }
.var-table input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 0.2rem;
}
.var-image-cell {
  min-width: 15rem;
  width: 15rem;
}
.var-image-cell .var-primary-image {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  line-height: 1.35;
  appearance: auto;
  -webkit-appearance: menulist;
}
.var-image-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.var-upload-btn {
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 0.35rem 0.45rem;
  border-radius: var(--radius-sm); background: var(--bg-input); border: 1px solid var(--border);
  flex-shrink: 0;
}
.var-image-preview { flex-shrink: 0; }
.var-image-thumb {
  width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.img-badge--catalog { background: #2d4a6e; right: auto; left: 0.35rem; top: 1.6rem; }
.img-badge--var { background: #6e4a2d; right: auto; left: 0.35rem; top: 1.6rem; }

/* Images */
.image-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 1rem;
}
.image-upload-zone:hover,
.image-upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-glow);
}
.upload-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.upload-hint { font-size: 0.75rem; color: var(--text-muted); }

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.image-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-item .img-badge {
  position: absolute;
  top: 4px; left: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-weight: 700;
}

.image-preview-item .img-remove {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-item .img-status {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.75);
  font-size: 0.65rem;
  padding: 0.2rem;
  text-align: center;
}

.platform-image-info {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.img-info-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.img-info-row .ok { color: var(--success); }
.img-info-row .warn { color: var(--warning); }

/* Platform toggles */
.platform-toggles { display: flex; flex-direction: column; gap: 0.75rem; }

.platform-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
}
.platform-toggle:has(input:checked) { border-color: var(--primary); }
.platform-toggle input { accent-color: var(--primary); width: 18px; height: 18px; }

.platform-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.7rem;
  flex-shrink: 0;
}
.platform-icon.ml { background: var(--ml); color: #333; }
.platform-icon.shopee { background: var(--shopee); color: #fff; }
.platform-icon.tiktok { background: var(--tiktok); color: #fff; }

.platform-info { flex: 1; }
.platform-info .name { font-weight: 600; font-size: 0.9rem; }
.platform-info .desc { font-size: 0.75rem; color: var(--text-muted); }

/* Summary */
.summary-content { font-size: 0.85rem; }
.summary-empty { color: var(--text-muted); font-style: italic; }
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.summary-row:last-child { border-bottom: none; }
.summary-label { color: var(--text-muted); }

/* History */
.history-list { display: flex; flex-direction: column; gap: 0.75rem; }

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.history-title { font-weight: 600; }
.history-date { font-size: 0.8rem; color: var(--text-muted); }

.history-platforms { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.history-platform {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.history-platform.success { border-left: 3px solid var(--success); }
.history-platform.error { border-left: 3px solid var(--danger); }
.history-platform.pending { border-left: 3px solid var(--warning); }

/* Settings page */
.settings-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.settings-banner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.12), rgba(108, 92, 231, 0.04));
  border: 1px solid rgba(108, 92, 231, 0.35);
  border-radius: var(--radius);
}

.settings-banner-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.settings-banner-text {
  flex: 1 1 16rem;
  min-width: 0;
}

.settings-banner-text strong { display: block; font-size: 0.95rem; margin-bottom: 0.2rem; }
.settings-banner-text p { font-size: 0.82rem; color: var(--text-muted); margin: 0; line-height: 1.45; }

.settings-banner .toggle {
  flex-shrink: 0;
  align-self: flex-start;
}

.settings-sync {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(108, 92, 231, 0.25);
  width: 100%;
}

.settings-sync label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.field-hint-inline { font-weight: 400; color: var(--text-muted); }

.settings-sync-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.settings-sync-row .settings-input {
  flex: 1;
  min-width: 12rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
}

.settings-sync-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  line-height: 1.45;
}

.settings-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.settings-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.settings-status-chip.connected { border-color: rgba(0, 184, 148, 0.45); color: var(--success); }
.settings-status-chip.simulation { border-color: rgba(253, 203, 110, 0.45); color: var(--warning); }
.settings-status-chip.disconnected { border-color: rgba(225, 112, 85, 0.35); color: var(--danger); }

.settings-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.settings-tab {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.settings-tab:hover { background: var(--bg-hover); color: var(--text); }

.settings-tab.active {
  background: var(--bg-input);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--border);
}

.settings-tab[data-platform="mercadolivre"].active { box-shadow: inset 0 -2px 0 var(--ml); }
.settings-tab[data-platform="shopee"].active { box-shadow: inset 0 -2px 0 var(--shopee); }
.settings-tab[data-platform="tiktok"].active { box-shadow: inset 0 -2px 0 var(--tiktok); }

.settings-tab-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.settings-tab-icon.ml { background: var(--ml); color: #1a1a1a; }
.settings-tab-icon.shopee { background: var(--shopee); color: #fff; }
.settings-tab-icon.tiktok { background: var(--tiktok); color: #fff; }

.settings-panels { min-height: 12rem; }

.settings-panel {
  display: none;
  animation: settingsFadeIn 0.2s ease;
}

.settings-panel.active { display: block; }

@keyframes settingsFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-panel-card--ml { border-top: 3px solid var(--ml); }
.settings-panel-card--shopee { border-top: 3px solid var(--shopee); }
.settings-panel-card--tiktok { border-top: 3px solid var(--tiktok); }

.connect-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 520px;
}

.connect-card--mercadolivre { border-top: 3px solid var(--ml); }
.connect-card--shopee { border-top: 3px solid var(--shopee); }
.connect-card--tiktok { border-top: 3px solid var(--tiktok); }

.connect-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.connect-card-title {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.connect-card-title h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.connect-card-title p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.connect-account {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: var(--accent);
}

.connect-warn {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: #ffb4b4;
}

.connect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.settings-panel-header {
  flex-wrap: wrap;
  gap: 0.75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.settings-panel-title { display: flex; align-items: center; gap: 0.75rem; }
.settings-panel-title h3 { font-size: 1.05rem; margin: 0; }
.settings-panel-title p { font-size: 0.8rem; color: var(--text-muted); margin: 0.2rem 0 0; }

.settings-panel-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
}

.settings-panel-badge.connected { background: rgba(0, 184, 148, 0.15); color: var(--success); }
.settings-panel-badge.simulation { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.settings-panel-badge.disconnected { background: rgba(225, 112, 85, 0.12); color: var(--danger); }

.settings-panel-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.settings-panel-body--single { grid-template-columns: 1fr; }

.settings-section {
  padding: 1.25rem 1.5rem;
  border-right: 1px solid var(--border);
}

.settings-section:last-child { border-right: none; }

.settings-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.settings-section-title .step-num {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--primary-glow);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
}

.settings-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.settings-fields-grid .form-group--full { grid-column: 1 / -1; }

.settings-input--mono {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.8rem;
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  line-height: 1.4;
}

.settings-note-card {
  padding: 1rem;
  background: var(--bg-input);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.settings-note-card strong { color: var(--text); }

.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  bottom: 1rem;
  z-index: 10;
  box-shadow: var(--shadow);
}

.settings-footer-hint { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

.settings-info { margin-top: 0.5rem; }
.settings-info summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
}
.settings-info[open] summary { margin-bottom: 0.75rem; color: var(--text); }

.info-card ul { margin: 0.75rem 0 0.75rem 1.25rem; font-size: 0.85rem; color: var(--text-muted); }
.info-card li { margin-bottom: 0.3rem; }
.info-card .note { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.75rem; }

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  padding: 0;
  max-width: 800px;
  width: 90vw;
  max-height: 85vh;
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0,0,0,0.6); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-body { padding: 1.5rem; overflow-y: auto; max-height: 60vh; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* Preview */
.preview-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.preview-tab {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
}
.preview-tab.active { background: var(--primary-glow); border-color: var(--primary); color: var(--primary); font-weight: 600; }

.preview-panel { display: none; }
.preview-panel.active { display: block; }

.preview-json {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
}

.preview-warnings {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(253, 203, 110, 0.1);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}
.preview-warnings li { margin-left: 1rem; margin-top: 0.25rem; }

.preview-desc-block {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.preview-desc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.preview-desc-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.preview-desc-count.over-limit { color: var(--danger); font-weight: 600; }

.preview-desc-text {
  margin: 0;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}

.preview-desc-changes {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--warning);
}

.description-preview {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.desc-preview-card {
  padding: 0.65rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.desc-preview-card.has-warnings { border-color: var(--warning); }

.desc-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.desc-preview-count { font-weight: 400; color: var(--text-muted); font-size: 0.75rem; }
.desc-preview-count.over { color: var(--danger); }

.desc-preview-snippet {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  max-height: 4.5em;
  overflow: hidden;
}

.desc-preview-warnings {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--warning);
}

/* Publish progress */
.publish-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.publish-step:last-child { border-bottom: none; }

.step-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.step-icon.pending { background: var(--bg-hover); }
.step-icon.running { background: var(--primary-glow); animation: pulse 1s infinite; }
.step-icon.success { background: rgba(0,184,148,0.2); }
.step-icon.error { background: rgba(225,112,85,0.2); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.step-info { flex: 1; }
.step-name { font-weight: 600; font-size: 0.9rem; }
.step-detail { font-size: 0.78rem; color: var(--text-muted); }
.step-error { color: var(--danger); display: block; line-height: 1.4; word-break: break-word; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.success { background: #0d3d32; border: 1px solid var(--success); }
.toast.error { background: #3d1a12; border: 1px solid var(--danger); }
.toast.info { background: #1a1540; border: 1px solid var(--primary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Avisos */
.protocol-warning {
  background: #c0392b;
  color: #fff;
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  position: sticky;
  top: 0;
  z-index: 200;
}

.simulation-banner {
  background: rgba(253, 203, 110, 0.15);
  border: 1px solid var(--warning);
  color: var(--warning);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}

.simulation-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.validation-errors {
  background: rgba(225, 112, 85, 0.12);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: var(--danger);
}
.validation-errors ul { margin: 0.4rem 0 0 1.2rem; }
.validation-errors li { margin-bottom: 0.2rem; }

/* Mercado Livre form */
.ml-card { border-color: #ffe60044; }
.ml-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.75rem; }

.ml-oauth-box {
  padding: 0;
  margin-bottom: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}
.ml-oauth-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; }
.ml-oauth-steps {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 1rem 1.1rem;
  line-height: 1.55;
}
.ml-oauth-steps li { margin-bottom: 0.35rem; }
.ml-oauth-steps a { color: var(--primary); }
.ml-oauth-actions, .ml-creds-actions, .settings-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.ml-creds-actions { margin-top: 0.75rem; padding-top: 0; border-top: none; }
.ml-pkce-toggle { margin: 0.5rem 0 0.75rem; font-size: 0.78rem; }
.ml-auth-url {
  width: 100%; box-sizing: border-box; resize: vertical;
  padding: 0.55rem 0.65rem; font-size: 0.72rem; line-height: 1.35;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted); font-family: Consolas, monospace;
}
.ml-oauth-help { margin-top: 0.75rem; font-size: 0.78rem; color: var(--text-muted); }
.ml-oauth-help summary { cursor: pointer; }
.ml-oauth-help ul { margin: 0.5rem 0 0 1.1rem; line-height: 1.45; }
#creds-mercadolivre-redirectUri.is-readonly {
  opacity: 0.85;
  cursor: default;
}
#creds-mercadolivre-redirectUri:not(.is-readonly) {
  border-color: var(--primary);
}
.ml-status { font-size: 0.78rem; color: var(--warning); display: block; margin-top: 0.35rem; }
.ml-search-row { display: flex; gap: 0.5rem; }
.ml-search-row input { flex: 1; }
.ml-section-label { font-size: 0.85rem; font-weight: 600; margin: 0.75rem 0 0.5rem; }
.ml-attrs-section { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.ml-attrs-section .ml-section-toggle {
  display: flex; align-items: center; gap: 0.35rem; width: 100%;
  background: none; border: none; padding: 0; cursor: pointer; text-align: left;
  color: var(--text); font: inherit;
}
.ml-attrs-collapsible .ml-section-toggle::after {
  content: '▸'; font-size: 0.75rem; color: var(--text-muted); margin-left: auto;
}
.ml-attrs-collapsible.is-open .ml-section-toggle::after { content: '▾'; }
.ml-attrs-collapsible:not(.is-open) .ml-attrs-grid { display: none; }
.ml-attr-count { font-weight: 400; color: var(--text-muted); font-size: 0.78rem; }
.ml-attrs-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem 1rem;
  margin-top: 0.75rem;
}
.ml-attr-group--unit { grid-column: 1 / -1; }
.ml-attr-hint { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 0.25rem; }
.ml-combo-field { width: 100%; }
.ml-combo-field .ml-attr-combo { width: 100%; }
.ml-number-unit {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(7rem, 11rem);
  gap: 0.65rem;
  width: 100%;
}
.ml-number-unit .ml-attr-number,
.ml-number-unit .ml-attr-unit {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.ml-attr-optional label::after { content: ' (opcional)'; font-weight: 400; color: var(--text-muted); font-size: 0.78rem; }
.ml-fee-breakdown {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ml-fee-title { font-size: 0.82rem; font-weight: 600; margin: 0 0 0.65rem; }
.ml-fee-category { font-size: 0.78rem; color: var(--text-muted); margin: 0 0 0.65rem; line-height: 1.4; }
.ml-fee-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  font-size: 0.82rem; padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
.ml-fee-row:last-of-type { border-bottom: none; }
.ml-fee-row--cost span:last-child { color: var(--danger, #e74c3c); }
.ml-fee-row--total { font-weight: 600; margin-top: 0.25rem; }
.ml-fee-row--total span:last-child { color: var(--danger, #e74c3c); }
.ml-fee-row--net {
  margin-top: 0.5rem; padding-top: 0.6rem;
  border-top: 2px solid var(--border); border-bottom: none;
  font-weight: 700; font-size: 0.9rem;
}
.ml-fee-row--net span:last-child { color: var(--success, #2ecc71); text-align: right; }
.ml-fee-row--net small { font-weight: 500; color: var(--text-muted); font-size: 0.75rem; }
.ml-fee-note { font-size: 0.7rem; color: var(--text-muted); margin: 0.6rem 0 0; line-height: 1.4; }
@media (max-width: 768px) {
  .ml-attrs-grid { grid-template-columns: 1fr; }
  .ml-number-unit { grid-template-columns: 1fr 1fr; }
}

/* Auth / SaaS login */
.auth-screen {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.auth-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  width: 100%;
  min-height: 100vh;
}

.auth-brand {
  background: linear-gradient(145deg, #1a1033 0%, #0f1117 50%, #0d1f2d 100%);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 3rem;
}

.auth-brand-inner { max-width: 520px; }

.auth-logo {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.auth-brand h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.2;
  margin-bottom: 1rem;
}

.auth-brand p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 1rem;
}

.auth-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: var(--bg-input);
  padding: 0.35rem;
  border-radius: var(--radius-sm);
}

.auth-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.auth-tab.active {
  background: var(--primary-glow);
  color: var(--primary);
  font-weight: 600;
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form[hidden] { display: none !important; }

.btn-block { width: 100%; justify-content: center; }

.auth-legal {
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
  text-align: center;
}

.sidebar-user {
  flex-shrink: 0;
}

.sidebar-user-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.65rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-plan {
  font-size: 0.68rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.settings-saas-note {
  padding: 0.85rem 1rem;
  background: rgba(108, 92, 231, 0.12);
  border: 1px solid rgba(108, 92, 231, 0.35);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.settings-saas-note strong { color: var(--text); }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

/* Responsive */
@media (max-width: 1024px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .settings-panel-body { grid-template-columns: 1fr; }
  .settings-section { border-right: none; border-bottom: 1px solid var(--border); }
  .settings-section:last-child { border-bottom: none; }
  .settings-fields-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { width: 60px; padding: 1rem 0.5rem; }
  .logo-text, .nav-item span:not(.nav-icon) { display: none; }
  .main {
    margin-left: 60px;
    width: calc(100% - 60px);
    padding: 1rem;
  }
  .form-row { grid-template-columns: 1fr; }
  .image-preview-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-banner-top { flex-direction: column; align-items: stretch; }
  .settings-banner .toggle { align-self: stretch; justify-content: space-between; }
  .settings-footer { flex-direction: column; align-items: stretch; }
  .settings-footer .btn { width: 100%; }
  .sidebar-bottom { max-height: none; }
  .platform-status { display: none; }
  .sidebar-user-name,
  .sidebar-user-email,
  .sidebar-user-plan { display: none; }
  .sidebar-user-card { padding: 0.35rem; align-items: center; }
  .sidebar-user-card .btn { padding: 0.4rem; font-size: 0.7rem; }
  .page-header { flex-direction: column; align-items: stretch; }
  .header-actions { width: 100%; }
  .header-actions .btn { flex: 1; justify-content: center; }
  .auth-panel { padding: 1rem; }
  .auth-card { padding: 1.25rem; }
}

/* ── Painel administrativo ── */
.admin-panel { display: flex; flex-direction: column; gap: 1.25rem; max-width: 1100px; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.admin-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
}

.admin-stat-card strong {
  display: block;
  font-size: 1.75rem;
  color: var(--primary);
}

.admin-stat-card span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.admin-section { margin-bottom: 0; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th,
.admin-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-muted {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.admin-empty {
  color: var(--text-muted);
  padding: 1rem 0;
}

.admin-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.admin-badge--pending { background: rgba(255, 193, 7, 0.15); color: #ffc107; }
.admin-badge--active { background: rgba(0, 186, 136, 0.15); color: #00ba88; }
.admin-badge--suspended { background: rgba(255, 107, 107, 0.15); color: #ff6b6b; }

.admin-actions { white-space: nowrap; }

.admin-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.admin-app-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.admin-app-card h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.admin-app-card--ml { border-top: 3px solid var(--ml); }
.admin-app-card--shopee { border-top: 3px solid var(--shopee); }
.admin-app-card--tiktok { border-top: 3px solid var(--tiktok); }

.admin-actions-bar {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 700px) {
  .admin-stats { grid-template-columns: 1fr; }
}
