*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-tertiary: #f5f5f5;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa;
  --bg-elevated: #ffffff;

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --accent-subtle: rgba(99, 102, 241, 0.07);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.08);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.08);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.08);

  --border: #e5e7eb;
  --border-light: #d1d5db;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-xl: 0 8px 30px rgba(0,0,0,0.08);

  --sidebar-width: 250px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 64px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

.app-container {
  display: flex;
  min-height: 100vh;
}

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  display: flex;
  transition: all 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.sidebar-toggle svg { width: 16px; height: 16px; transition: transform 0.3s; }

/* ===== Estado recolhido: só ícones ===== */
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-arrow,
.sidebar.collapsed .sidebar-status span,
.sidebar.collapsed .sidebar-version { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 18px 0; gap: 0; }
.sidebar.collapsed .sidebar-toggle { margin-left: 0; position: absolute; right: -12px; top: 22px; background: var(--bg-primary); z-index: 5; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; gap: 0; }
.sidebar.collapsed .nav-submenu { display: none !important; }
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed-width); }
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item:hover::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  background: var(--text-primary); color: #fff; font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: var(--radius-sm); white-space: nowrap; z-index: 100;
  box-shadow: var(--shadow-lg);
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-text .brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-text .brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.sidebar-nav ul { list-style: none; }

.sidebar-nav li { margin-bottom: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--text-secondary);
  text-decoration: none !important;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color 0.15s;
}

.nav-item:hover {
  background: rgba(99, 102, 241, 0.06);
  color: #6366f1;
}

.nav-item:hover svg { color: #6366f1; }

.nav-item.active {
  background: rgba(99, 102, 241, 0.08);
  color: #4f46e5;
  font-weight: 600;
}

.nav-item.active svg { color: #4f46e5; }

.nav-parent { justify-content: flex-start; }
.nav-arrow { width: 14px; height: 14px; margin-left: auto; transition: transform 0.2s; }
.nav-submenu { padding-left: 20px; }
.nav-sub { font-size: 13px !important; padding: 7px 14px !important; }

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

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

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

.sidebar-version { font-size: 11px; color: var(--text-muted); opacity: 0.6; }

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

/* ═══ TOPBAR ═══ */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

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

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.mobile-menu-btn svg { width: 22px; height: 22px; }

.page-title-area h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.search-box {
  position: relative;
  width: 260px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.search-box input::placeholder { color: var(--text-muted); }

/* ═══ CONTENT ═══ */
.content-wrapper {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══ DASHBOARD ═══ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: all 0.25s ease;
}

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

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  flex-shrink: 0;
}

.stat-card-icon svg { width: 100%; height: 100%; }

.stat-card-primary .stat-card-icon { background: var(--accent-subtle); color: var(--accent); }
.stat-card-success .stat-card-icon { background: var(--success-bg); color: var(--success); }
.stat-card-warning .stat-card-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card-info .stat-card-icon { background: var(--info-bg); color: var(--info); }

.stat-card-body { display: flex; flex-direction: column; }

.stat-card-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.stat-card-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.stat-card-primary .stat-card-value { color: var(--accent); }
.stat-card-success .stat-card-value { color: var(--success); }
.stat-card-warning .stat-card-value { color: var(--warning); }
.stat-card-info .stat-card-value { color: var(--info); }

/* ═══ CHARTS ═══ */
.dashboard-charts {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all 0.25s ease;
}

.chart-card:hover {
  box-shadow: var(--shadow-lg);
}

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

.chart-card-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.chart-card-badge {
  font-size: 11px;
  padding: 3px 10px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  color: var(--text-muted);
  font-weight: 500;
}

.chart-card-body { padding: 20px; }

.status-chart { margin-top: 4px; }

.chart-bar-group { display: flex; flex-direction: column; gap: 10px; }

.chart-bar-labels {
  display: flex;
  justify-content: space-between;
  padding-right: 40px;
}

.chart-bar-labels span {
  font-size: 12px;
  color: var(--text-muted);
  width: 25%;
  text-align: center;
}

.chart-bars {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  height: 140px;
}

.chart-bar {
  flex: 1;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  position: relative;
  height: calc(var(--pct) * 1.4px);
  min-height: 6px;
  transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
}

.chart-bar:nth-child(1) { background: linear-gradient(180deg, var(--warning), #fde68a); }
.chart-bar:nth-child(2) { background: linear-gradient(180deg, var(--success), #bbf7d0); }
.chart-bar:nth-child(3) { background: linear-gradient(180deg, var(--danger), #fecaca); }
.chart-bar:nth-child(4) { background: linear-gradient(180deg, var(--text-muted), #e2e8f0); }

.chart-bar span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  opacity: 0;
  animation: fadeIn 0.3s 0.5s forwards;
}

.recent-activity { min-height: 100px; }

.activity-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px;
  color: var(--text-muted);
}

.activity-placeholder svg { width: 36px; height: 36px; opacity: 0.25; }
.activity-placeholder p { font-size: 13px; }

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-dot.created { background: var(--success); }
.activity-dot.updated { background: var(--info); }
.activity-dot.imported { background: var(--accent); }

.activity-text { color: var(--text-primary); flex: 1; }
.activity-text strong { color: var(--accent); }

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ═══ PAGE TOOLBAR ═══ */
.page-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
}

.toolbar-filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.filter-group .form-input,
.filter-group .form-select {
  min-width: 150px;
}

.search-filter .form-input { min-width: 190px; }

.toolbar-actions {
  display: flex;
  gap: 8px;
}

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none !important;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s;
}

.btn:hover::after { background: rgba(255,255,255,0.1); }
.btn:active::after { background: rgba(0,0,0,0.08); }

.btn svg { width: 16px; height: 16px; position: relative; z-index: 1; }
.btn span { position: relative; z-index: 1; }

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.3);
}

.btn-ghost {
  background: #ffffff;
  color: #374151;
  border: 1.5px solid #e5e7eb;
}

.btn-ghost:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  color: #111827;
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.btn-danger:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(239, 68, 68, 0.3);
}

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

.btn-sm svg { width: 14px; height: 14px; }

/* ═══ FORMS ═══ */
.form-input, .form-select {
  padding: 9px 13px;
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: all 0.2s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-input:hover, .form-select:hover {
  border-color: var(--border-light);
}

.form-input::placeholder { color: var(--text-muted); }

.form-select {
  cursor: pointer;
  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='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* ═══ FORNECEDORES LIST ═══ */
.fornecedores-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.forn-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.forn-row:last-child { border-bottom: none; }
.forn-row:hover { background: var(--accent-subtle); }

.forn-logo {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.forn-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.forn-avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.forn-info { flex: 1; min-width: 0; }

.forn-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

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

.forn-meta a { color: var(--accent); }

.forn-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.forn-row { cursor: pointer; }
.forn-row .forn-actions { pointer-events: auto; }
.forn-row .forn-actions .btn { pointer-events: auto; position: relative; z-index: 2; }
.forn-row.forn-expanded { background: var(--accent-subtle); }

.forn-dropdown {
  display: none;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 12px 20px 12px 84px;
}

.forn-dropdown.open { display: block; }

.forn-dropdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.forn-dropdown th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.forn-dropdown td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.forn-dropdown tr:last-child td { border-bottom: none; }
.forn-dropdown .text-right { text-align: right; }

.forn-dropdown-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.forn-expand-icon {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
  transition: transform 0.2s;
  display: inline-block;
}

.forn-expanded .forn-expand-icon { transform: rotate(90deg); }

/* ===== Nimbi steps ===== */
.nimbi-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 16px 0 24px;
}
@media (max-width: 1100px) { .nimbi-steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .nimbi-steps { grid-template-columns: 1fr; } }
.nimbi-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.nimbi-step:hover { box-shadow: var(--shadow); border-color: var(--border-light); }
.nimbi-step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nimbi-step-num {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: 13px;
}
.nimbi-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 999px;
}
.nimbi-badge-nimbi { background: rgba(99,102,241,0.12); color: var(--accent-dark); }
.nimbi-badge-stelc { background: var(--bg-tertiary); color: var(--text-secondary); }
.nimbi-step-title { font-size: 15px; font-weight: 600; margin: 2px 0 0; }
.nimbi-step-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; margin: 0; flex: 1; }
.nimbi-step-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); }

/* Dropdown de exportação (Itens / Preço / Imagens) */
.export-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 200px; z-index: 100; overflow: hidden; padding: 4px;
}
.export-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--text-primary); text-align: left;
  border-radius: var(--radius-sm); transition: background 0.12s;
}
.export-menu-item:hover { background: var(--accent-subtle); }
.export-menu-item svg { color: var(--accent); flex-shrink: 0; }

.th-check, .td-check { width: 40px; text-align: center; }
.th-check input, .td-check input { cursor: pointer; width: 16px; height: 16px; }

/* Linha expansível de detalhes (tira colunas secundárias da rolagem horizontal) */
.th-expand, .td-expand { width: 32px; text-align: center; padding-left: 0; padding-right: 0; }
.nl-expand-btn {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  display: inline-flex; padding: 4px; border-radius: var(--radius-sm); transition: all 0.15s;
}
.nl-expand-btn:hover { background: var(--bg-tertiary); color: var(--accent); }
.nl-expand-btn svg { transition: transform 0.2s; }
.nl-expand-btn.open svg { transform: rotate(90deg); color: var(--accent); }
.nl-expand-btn.open { color: var(--accent); }
.nl-detail > td { background: var(--bg-secondary); padding: 16px 20px !important; }
.nl-det-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 24px; }
.nl-det-full { grid-column: 1 / -1; }
.nl-det-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nl-det-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.nl-det-val { font-size: 13px; color: var(--text-primary); word-break: break-word; }
@media (max-width: 900px) { .nl-det-grid { grid-template-columns: 1fr 1fr; } }
.nimbi-bulk-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--accent-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 13px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .form-group { margin-bottom: 0; }
.form-group-full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px;
  transition: all 0.25s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-light);
}

.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-actions {
  margin-top: 14px;
  display: flex;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ═══ STATS ROW ═══ */
.stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  flex: 1;
  transition: all 0.2s;
}

.stat-mini:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-light);
}

.stat-mini .stat-mini-num {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

/* ═══ TABLE ═══ */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

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

.data-table thead {
  background: var(--bg-tertiary);
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.1s; }
.td-truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table tbody tr:hover td { background: var(--accent-subtle); }

.data-table .text-right { text-align: right; }
.data-table td.text-right { font-variant-numeric: tabular-nums; }
.data-table .text-center { text-align: center; }

.th-check, .td-check { width: 36px; text-align: center; padding: 0 6px !important; }
.th-check input[type="checkbox"], .td-check input[type="checkbox"] {
  width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent);
}

.td-actions { width: 80px; text-align: center; white-space: nowrap; }
.data-table th.td-actions { text-align: center; }

.th-num, .td-num { width: 40px; text-align: center; padding: 0 6px !important; color: var(--text-muted); font-size: 12px; font-weight: 600; }

.hist-row { cursor: pointer; }
.hist-row.hist-expanded { background: var(--accent-subtle); }

.hist-dropdown { display: none; }
.hist-dropdown.open { display: table-row; }
.hist-dropdown td { background: var(--bg-secondary); padding: 8px 20px !important; }

.th-img, .td-img { width: 56px; text-align: center; padding: 4px 6px !important; vertical-align: middle; }

.prod-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 4px;
  background: var(--bg-tertiary);
  display: block;
  margin: 0 auto;
}

.prod-img-placeholder {
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: 4px;
  background: var(--bg-tertiary);
}

.edit-input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font);
  outline: none;
  min-width: 60px;
}

.edit-input-moeda { min-width: 80px; }

.tr-editing td { padding-top: 6px; padding-bottom: 6px; vertical-align: middle; }
.tr-editing .td-actions { white-space: nowrap; }

/* ═══ BADGES ═══ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.badge-pendente { background: var(--warning-bg); color: var(--warning); }
.badge-pendente::before { background: var(--warning); }

.badge-atualizado { background: var(--success-bg); color: var(--success); }
.badge-atualizado::before { background: var(--success); }

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

.badge-nao_encontrado { background: rgba(148, 163, 184, 0.1); color: var(--text-muted); }
.badge-nao_encontrado::before { background: var(--text-muted); }

/* ═══ PAGINATION ═══ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
}

.pagination button {
  padding: 7px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  transition: all 0.15s;
  min-width: 36px;
}

.pagination button:hover:not(.active) {
  background: #f9fafb;
  border-color: var(--border-light);
  color: var(--text-primary);
}

.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ═══ MODALS ═══ */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
}

.modal.show { display: flex; animation: modalIn 0.2s ease; }

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.35);
}

@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  position: relative;
  background: #ffffff;
  border: none;
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  margin-top: 60px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: modalSlide 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

@keyframes modalSlide {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

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

.modal-panel-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  display: flex;
}

.modal-close-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-close-btn svg { width: 18px; height: 18px; }

.modal-panel-body { padding: 20px; }
.modal-panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* Modal com formulário: header fixo, corpo rolável, footer (Salvar) sempre visível */
.modal-panel > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(90vh - 60px);
}
.modal-panel > form .modal-panel-body { flex: 1; overflow-y: auto; min-height: 0; }
.modal-panel > form .modal-panel-footer { flex-shrink: 0; }

/* ===== Editar produto — layout premium por seções ===== */
.modal-panel-edit { max-width: 760px; margin-top: 40px; }
.ne-body { padding: 0; }
.ne-imgrow {
  display: flex; gap: 18px; align-items: center;
  padding: 22px 28px;
  background: linear-gradient(135deg, var(--accent-subtle), transparent 75%);
  border-bottom: 1px solid var(--border);
}
.ne-thumb {
  width: 88px; height: 88px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: #fff; display: flex; align-items: center; justify-content: center;
  overflow: hidden; box-shadow: var(--shadow-sm); position: relative;
}
.ne-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.ne-thumb .ne-thumb-empty { position: absolute; font-size: 10px; color: var(--text-muted); }
.ne-thumb img[src]:not([src=""]) + .ne-thumb-empty { display: none; }
.ne-imgrow-field { flex: 1; min-width: 0; }
.ne-imgrow-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.ne-hint { font-size: 11.5px; color: var(--text-muted); margin: 6px 0 0; }
.ne-img-inputs { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ne-img-inputs .form-input { flex: 1; min-width: 180px; }
.ne-img-or { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.ne-img-inputs .btn { flex-shrink: 0; }

.ne-section { border: none; padding: 18px 28px; margin: 0; border-bottom: 1px solid var(--border); }
.ne-section:last-of-type { border-bottom: none; }
.ne-section legend {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent-dark); padding: 0; margin-bottom: 14px;
}
.ne-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.ne-grid-4 { grid-template-columns: repeat(4, 1fr); }
.ne-full { grid-column: 1 / -1; }
.ne-grid .form-group { margin-bottom: 0; }
@media (max-width: 700px) {
  .ne-grid, .ne-grid-4 { grid-template-columns: 1fr 1fr; }
  .ne-imgrow { flex-direction: column; align-items: flex-start; }
}

/* ===== Modal grande + detalhes premium ===== */
.modal-panel-lg { max-width: 920px; }
.modal-panel-lg .modal-panel-body { padding: 0; max-height: 78vh; overflow-y: auto; }

.nd-hero {
  display: flex; gap: 24px; align-items: center;
  padding: 28px 32px;
  background: linear-gradient(135deg, var(--accent-subtle), transparent 70%);
  border-bottom: 1px solid var(--border);
}
.nd-thumb {
  width: 132px; height: 132px; flex-shrink: 0;
  border-radius: var(--radius-lg);
  background: #fff; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; box-shadow: var(--shadow);
}
.nd-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.nd-thumb.nd-noimg::after { content: 'Sem imagem'; font-size: 11px; color: var(--text-muted); }
.nd-hero-info { min-width: 0; flex: 1; }
.nd-forn { font-size: 12px; font-weight: 600; color: var(--accent-dark); text-transform: uppercase; letter-spacing: 0.04em; }
.nd-title { font-size: 20px; font-weight: 700; line-height: 1.3; margin: 6px 0; color: var(--text-primary); }
.nd-sku { font-size: 13px; color: var(--text-secondary); }
.nd-sku strong { color: var(--text-primary); }
.nd-badges { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.nd-badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.nd-badge-status { background: var(--warning-bg); color: var(--warning); }
.nd-badge-ia { background: var(--success-bg); color: var(--success); }
.nd-badge-pend { background: var(--bg-tertiary); color: var(--text-secondary); }
.nd-price { font-size: 26px; font-weight: 800; color: var(--text-primary); margin-top: 4px; }

.nd-section { padding: 20px 32px; border-bottom: 1px solid var(--border); }
.nd-section:last-child { border-bottom: none; }
.nd-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent-dark); margin-bottom: 14px;
}
.nd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
.nd-field-full { grid-column: 1 / -1; }
.nd-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 3px; }
.nd-value { font-size: 14px; color: var(--text-primary); word-break: break-word; line-height: 1.5; }
.nd-empty { color: var(--text-muted); }
@media (max-width: 720px) {
  .nd-hero { flex-direction: column; text-align: center; }
  .nd-grid { grid-template-columns: 1fr; }
}

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

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

.form-group .form-input,
.form-group .form-select { width: 100%; }

.form-group small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

/* ═══ FILE UPLOAD ═══ */
.file-upload-zone {
  position: relative;
  border: 2px dashed #d1d5db;
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}

.file-upload-zone:hover {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.04);
}

.file-upload-zone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.file-upload-content svg { width: 36px; height: 36px; opacity: 0.4; }
.file-upload-content span { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.file-upload-content small { font-size: 11px; }

.file-upload-zone.has-file {
  border-color: var(--success);
  border-style: solid;
  background: var(--success-bg);
}

.file-upload-zone.has-file .file-upload-content svg { opacity: 1; color: var(--success); }
.file-upload-zone.has-file .file-upload-content span { color: var(--success); }

/* ═══ LOADING & EMPTY ═══ */
.loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.loading::before {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 12px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon { width: 48px; height: 48px; opacity: 0.15; margin-bottom: 12px; }

.empty h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty p { font-size: 13px; }

/* ═══ TOAST ═══ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 260px;
  max-width: 380px;
}

.toast.toast-out {
  animation: toastOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--accent); }

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast .toast-close { margin-left: auto; cursor: pointer; opacity: 0.7; }
.toast .toast-close:hover { opacity: 1; }

/* ═══ LOGIN ═══ */
.login-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: #ffffff;
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.login-overlay.show { display: flex; }

.login-card {
  background: #ffffff;
  border: none;
  border-radius: 20px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
  overflow: hidden;
}

.login-header {
  text-align: center;
  padding: 40px 28px 24px;
}
.login-header .login-logo {
  width: 80px; height: 80px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.login-header .login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.login-header h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; color: #111827; }
.login-header p { font-size: 14px; color: #6b7280; margin: 0; }

.login-body { padding: 0 28px 20px; }
.login-body .form-group { margin-bottom: 16px; }

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-top: 4px;
}

.login-footer { padding: 0 28px 32px; }
.login-btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}
.login-btn:hover {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
}

/* ═══ USER BADGE ═══ */
.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 14px;
  padding: 6px 10px 6px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 30px;
  flex-shrink: 0;
}

.user-badge-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.user-badge-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-badge-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.user-badge-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

.user-badge-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  transition: all 0.15s;
}
.user-badge-logout:hover { color: var(--danger); background: var(--danger-bg); }
.user-badge-logout svg { width: 16px; height: 16px; }

@media (max-width: 768px) {
  .user-badge { margin-left: 8px; padding: 4px 6px 4px 4px; }
  .user-badge-avatar { width: 26px; height: 26px; font-size: 11px; }
  .user-badge-info { display: none; }
}

/* ═══ PERMISSÕES TABLE ═══ */
#permissoes-container .data-table td { vertical-align: middle; }
#permissoes-container .data-table select { min-width: 120px; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-charts { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,0.15); }
  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: flex; }
  .topbar { padding: 0 16px; }
  .content-wrapper { padding: 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .page-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-filters { flex-direction: column; }
  .filter-group .form-input,
  .filter-group .form-select,
  .search-filter .form-input { min-width: 0; width: 100%; }
  .search-box { width: 180px; }
  .stats-row { flex-wrap: wrap; }
  .stat-mini { min-width: calc(50% - 5px); }
}

/* Edição inline de células */
.td-inline-edit { cursor: pointer; position: relative; }
.td-inline-edit:hover { background: rgba(99,102,241,0.06); }
.td-inline-edit:hover span { text-decoration: underline dotted var(--accent); }
