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

:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255,255,255,0.85);
  --bg-input: #ffffff;
  --glass-border: rgba(0,0,0,0.06);
  --glass-border-hover: rgba(0,0,0,0.12);

  --accent-primary: #3b82f6;
  --accent-primary-dim: rgba(59,130,246,0.1);
  --accent-success: #0891b2;
  --accent-success-dim: rgba(8,145,178,0.1);
  --accent-error: #dc2626;
  --accent-error-dim: rgba(220,38,38,0.1);
  --accent-warning: #d97706;
  --accent-warning-dim: rgba(217,119,6,0.1);
  --accent-emerald: #059669;
  --accent-emerald-dim: rgba(5,150,105,0.1);
  --accent-purple: #9333ea;
  --accent-purple-dim: rgba(147,51,234,0.1);
  --accent-orange: #ea580c;
  --accent-orange-dim: rgba(234,88,12,0.1);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --sidebar-width: 250px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 20px;
  --transition: 300ms cubic-bezier(0.4,0,0.2,1);
  --glass-bg: rgba(255,255,255,0.7);
  --glass-blur: blur(12px);
  --card-shadow: 0 4px 20px rgba(0,0,0,0.05);
  --card-shadow-hover: 0 12px 30px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --bg-primary: #0a0a16;
  --bg-secondary: #0d0d1a;
  --bg-card: rgba(30,30,60,0.4);
  --bg-input: rgba(255,255,255,0.03);
  --glass-border: rgba(255,255,255,0.06);
  --glass-border-hover: rgba(255,255,255,0.12);

  --accent-primary: #3b82f6;
  --accent-primary-dim: rgba(59,130,246,0.12);
  --accent-success: #06b6d4;
  --accent-success-dim: rgba(6,182,212,0.12);
  --accent-error: #ef4444;
  --accent-error-dim: rgba(239,68,68,0.12);
  --accent-warning: #f59e0b;
  --accent-warning-dim: rgba(245,158,11,0.12);
  --accent-emerald: #34d399;
  --accent-emerald-dim: rgba(52,211,153,0.12);
  --accent-purple: #a855f7;
  --accent-purple-dim: rgba(168,85,247,0.12);
  --accent-orange: #fb923c;
  --accent-orange-dim: rgba(251,146,60,0.12);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --glass-bg: rgba(255,255,255,0.03);
  --card-shadow: 0 4px 20px rgba(0,0,0,0.3);
  --card-shadow-hover: 0 12px 30px rgba(0,0,0,0.5);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: none;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
body.logged-in .sidebar { display: flex; }

.sidebar-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px 0 24px 0;
  width: 100%;
}
.sidebar-logo-wrap {
  width: 210px;
  height: 105px;
  overflow: hidden;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-icon-default-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--accent-primary);
}
.brand-name-fallback {
  font-size: 20px;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: -0.5px;
}
.brand-name-fallback strong { font-weight: 700; color: var(--text-primary); }

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}
.nav-link:hover { background: var(--accent-primary-dim); color: var(--text-primary); }
.nav-link.active { background: var(--accent-primary-dim); color: var(--accent-primary); }
[data-theme="dark"] .nav-link.active { background: rgba(59,130,246,0.18); color: #fff; }

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

.sidebar-bottom {
  padding: 12px 14px 20px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wa-status-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.wa-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition);
}
.wa-dot.connected { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.wa-dot.disconnected { background: var(--accent-error); }

.theme-row { display: flex; align-items: center; gap: 8px; }
.theme-icon { display: flex; align-items: center; color: var(--text-muted); }
.theme-switch {
  position: relative;
  display: inline-block;
  width: 36px; height: 20px;
}
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--text-muted);
  border-radius: 34px;
  transition: .3s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px; width: 14px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .3s;
}
input:checked + .slider { background: var(--accent-primary); }
input:checked + .slider:before { transform: translateX(16px); }

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.08);
  color: #ef4444;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
}
.btn-logout:hover { background: rgba(239,68,68,0.16); }

/* ===== MAIN ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  transition: margin var(--transition);
}
body.auth-mode .main-content { margin-left: 0; padding: 0; }
body.auth-mode .sidebar { display: none !important; }

.page-container {
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeIn 300ms ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== LOGIN ===== */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  backdrop-filter: var(--glass-blur);
}
.login-brand-icon {
  width: 56px; height: 56px;
  background: var(--accent-primary-dim);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  margin: 0 auto 16px;
}
.login-title { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.login-sub { font-size: 13px; color: var(--text-secondary); margin-top: 6px; margin-bottom: 28px; }
.login-error { color: var(--accent-error); font-size: 12px; margin-top: 8px; display: none; }
/* Logo no login */
.login-logo-wrap {
  width: 220px;
  height: 110px;
  background: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0 auto 20px;
}
[data-theme="dark"] .login-logo-wrap { background: rgba(255,255,255,0.08); }
.login-logo-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.page-header .subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ===== KPI GRID ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  backdrop-filter: var(--glass-blur);
  transition: var(--transition);
}
.kpi-card:hover { border-color: var(--accent-primary); transform: translateY(-3px) scale(1.02); box-shadow: var(--card-shadow-hover); }
.kpi-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.kpi-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  margin-bottom: 4px;
}
.kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -1px; }

.kpi-blue   { color: var(--accent-primary); }
.kpi-blue   .kpi-icon { background: var(--accent-primary-dim); }
.kpi-green  { color: var(--accent-emerald); }
.kpi-green  .kpi-icon { background: var(--accent-emerald-dim); }
.kpi-amber  { color: var(--accent-warning); }
.kpi-amber  .kpi-icon { background: var(--accent-warning-dim); }
.kpi-purple { color: var(--accent-purple); }
.kpi-purple .kpi-icon { background: var(--accent-purple-dim); }
.kpi-red    { color: var(--accent-error); }
.kpi-red    .kpi-icon { background: var(--accent-error-dim); }

/* ===== TABLE CARD ===== */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: visible;
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--card-shadow);
}
.table-card .table-wrap { overflow-x: auto; }
.table-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.table-card-header h3 { font-size: 14px; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}
tbody td { padding: 11px 16px; font-size: 13px; border-bottom: 1px solid var(--glass-border); }
tbody tr { transition: var(--transition); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }

/* ===== 2 COL GRID ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.badge-blue   { background: var(--accent-primary-dim); color: var(--accent-primary); }
.badge-green  { background: var(--accent-emerald-dim); color: var(--accent-emerald); }
.badge-amber  { background: var(--accent-warning-dim); color: var(--accent-warning); }
.badge-red    { background: var(--accent-error-dim);   color: var(--accent-error); }
.badge-muted  { background: var(--glass-border); color: var(--text-secondary); }
.badge-purple { background: var(--accent-purple-dim);  color: var(--accent-purple); }
.badge-orange { background: var(--accent-orange-dim);  color: var(--accent-orange); }

/* Platform tags */
.platform-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.platform-amazon       { background: rgba(255,153,0,0.12);   color: #ff9900; }
.platform-shopee       { background: rgba(238,77,45,0.12);   color: #ee4d2d; }
.platform-mercadolivre { background: rgba(245,197,24,0.15);  color: #c9a000; }
[data-theme="dark"] .platform-mercadolivre { color: #f5c518; }
.platform-aliexpress   { background: rgba(232,32,42,0.12);   color: #e8202a; }
.platform-magalu       { background: rgba(0,102,204,0.12);   color: #0066cc; }
[data-theme="dark"] .platform-magalu { color: #60a5fa; }
.platform-lomadee        { background: rgba(224,92,10,0.12);   color: #e05c0a; }
[data-theme="dark"] .platform-lomadee { color: #fb923c; }
.platform-electrolux     { background: rgba(0,83,159,0.12);    color: #00539f; }
[data-theme="dark"] .platform-electrolux { color: #60a5fa; }
.platform-drogasmil      { background: rgba(0,150,64,0.12);    color: #009640; }
[data-theme="dark"] .platform-drogasmil { color: #4ade80; }
.platform-drogariarosario{ background: rgba(220,38,38,0.12);   color: #dc2626; }
[data-theme="dark"] .platform-drogariarosario { color: #f87171; }
.platform-malwee         { background: rgba(139,0,139,0.12);   color: #8b008b; }
[data-theme="dark"] .platform-malwee { color: #d946ef; }
.platform-gazin          { background: rgba(0,112,185,0.12);   color: #0070b9; }
[data-theme="dark"] .platform-gazin { color: #60a5fa; }
.platform-shopclub       { background: rgba(30,136,229,0.12);  color: #1e88e5; }
[data-theme="dark"] .platform-shopclub { color: #60a5fa; }
.platform-rovitex        { background: rgba(211,47,47,0.12);   color: #d32f2f; }
[data-theme="dark"] .platform-rovitex { color: #f87171; }
.platform-brinox         { background: rgba(255,111,0,0.12);   color: #ff6f00; }
[data-theme="dark"] .platform-brinox { color: #fb923c; }
.platform-lojasrede      { background: rgba(196,0,0,0.12);     color: #c40000; }
[data-theme="dark"] .platform-lojasrede { color: #f87171; }
.platform-casadofitness     { background: rgba(0,137,123,0.12);   color: #00897b; }
[data-theme="dark"] .platform-casadofitness { color: #4db6ac; }
.platform-camisariacolombo  { background: rgba(121,85,72,0.12);   color: #795548; }
[data-theme="dark"] .platform-camisariacolombo { color: #a1887f; }
.platform-promofarma        { background: rgba(56,142,60,0.12);   color: #388e3c; }
[data-theme="dark"] .platform-promofarma { color: #66bb6a; }
.platform-coza              { background: rgba(123,31,162,0.12);  color: #7b1fa2; }
[data-theme="dark"] .platform-coza { color: #ba68c8; }
.platform-other          { background: var(--glass-border); color: var(--text-secondary); }

/* Status tags */
.status-sent          { background: var(--accent-emerald-dim);  color: var(--accent-emerald); }
.status-auto-approved { background: var(--accent-primary-dim);  color: var(--accent-primary); }
.status-pending       { background: var(--accent-warning-dim);  color: var(--accent-warning); }
.status-rejected      { background: var(--accent-error-dim);    color: var(--accent-error); }
.status-auto-rejected { background: var(--accent-orange-dim);   color: var(--accent-orange); }
.status-discarded     { background: var(--glass-border);        color: var(--text-muted); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-decoration: none;
}
.btn-primary   { background: rgba(59,130,246,0.12); color: var(--accent-primary); border: 1px solid rgba(59,130,246,0.28); }
.btn-primary:hover { background: rgba(59,130,246,0.2); }
.btn-success   { background: var(--accent-emerald-dim); color: var(--accent-emerald); border: 1px solid var(--accent-emerald-dim); }
.btn-success:hover { opacity: 0.8; }
.btn-danger    { background: var(--accent-error-dim); color: var(--accent-error); border: 1px solid var(--accent-error-dim); }
.btn-danger:hover { opacity: 0.8; }
.btn-secondary { background: rgba(255,255,255,0.05); color: var(--text-secondary); border: 1px solid var(--glass-border); }
.btn-secondary:hover { background: rgba(255,255,255,0.09); color: var(--text-primary); }
[data-theme="light"] .btn-secondary { background: var(--bg-secondary); border-color: rgba(0,0,0,0.15); }
[data-theme="light"] .btn-secondary:hover { background: var(--bg-primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { width:32px; height:32px; padding:0; display:flex; align-items:center; justify-content:center; border-radius:var(--radius-sm); background:var(--glass-bg); border:1px solid var(--glass-border); color:var(--text-secondary); cursor:pointer; transition:var(--transition); }
.btn-icon:hover { background:rgba(255,255,255,0.1); color:var(--text-primary); }
.btn-group { display:flex; gap:6px; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select {
  padding: 9px 13px;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  transition: var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-secondary); }

/* ===== SETTINGS CARD ===== */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--card-shadow);
}
.settings-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Toggle row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--glass-border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 13px; font-weight: 500; }
.toggle-sub { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px; height: 22px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--text-muted);
  border-radius: 34px;
  transition: .3s;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .3s;
}
input:checked + .toggle-slider { background: var(--accent-primary); }
input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ===== APPROVAL CARDS ===== */
.offer-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  transition: var(--transition);
  backdrop-filter: var(--glass-blur);
}
.offer-card:hover { border-color: var(--glass-border-hover); box-shadow: var(--card-shadow); }
.offer-card-header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 12px; }
.offer-img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--glass-border);
  flex-shrink: 0;
}
.offer-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; line-height: 1.4; }
.offer-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.offer-prices { display: flex; align-items: baseline; gap: 8px; margin: 8px 0; }
.offer-price-current { font-size: 20px; font-weight: 800; color: var(--accent-emerald); }
.offer-price-original { font-size: 13px; color: var(--text-muted); text-decoration: line-through; }
.offer-discount { background: var(--accent-error-dim); color: var(--accent-error); font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 100px; }
.offer-copy { font-size: 12px; color: var(--text-secondary); background: var(--glass-border); padding: 8px 12px; border-radius: var(--radius-sm); margin: 10px 0; font-style: italic; }
.offer-actions { display: flex; gap: 10px; margin-top: 14px; }
.offer-actions a { font-size: 12px; color: var(--accent-primary); }
.offer-ai-rec { font-size: 12px; padding: 8px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; }
.offer-ai-rec.rec-approve { background: var(--accent-emerald-dim); color: var(--accent-emerald); }
.offer-ai-rec.rec-reject  { background: var(--accent-error-dim); color: var(--accent-error); }
.offer-ai-rec.rec-info    { background: var(--accent-warning-dim); color: var(--accent-warning); }

/* ===== VALIDATION PANEL ===== */
.val-panel { border: 1px solid var(--glass-border); border-radius: var(--radius-sm); overflow: hidden; margin: 10px 0; font-size: 12px; }
.val-row { display: flex; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--glass-border); }
.val-row:last-child { border-bottom: none; }
.val-row-warn { background: rgba(239,68,68,0.06); }
.val-label { color: var(--text-secondary); min-width: 100px; flex-shrink: 0; font-weight: 500; }
.val-value { color: var(--text-primary); flex: 1; line-height: 1.4; }
.val-value.val-green { color: var(--accent-emerald); font-weight: 600; }
.val-value.val-warn  { color: var(--accent-error); }
.val-value.val-muted { color: var(--text-secondary); font-style: italic; }
.val-source { color: var(--text-secondary); font-weight: 400; font-style: normal; font-size: 11px; }
.offer-tech-note { font-size: 11px; color: var(--text-secondary); background: var(--glass-border); padding: 6px 10px; border-radius: var(--radius-sm); margin: 8px 0; white-space: pre-wrap; word-break: break-word; }
.dup-highlight td { animation: dup-flash 2s ease; }
@keyframes dup-flash { 0%,100% { background: transparent; } 20%,80% { background: var(--accent-primary-dim); } }

/* ===== LOGS CONSOLE ===== */
.log-console {
  background: #0a0a10;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  height: 580px;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
}
[data-theme="light"] .log-console { background: #1a1a2e; }
.log-line { padding: 1px 0; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.log-line.info    { color: #a3e4a3; }
.log-line.warn    { color: #ffd27a; }
.log-line.error   { color: #ff7070; }
.log-line.default { color: #8a8aaa; }
.log-ts    { color: #5a5a7a; margin-right: 6px; }
.log-level { font-weight: 700; margin-right: 6px; min-width: 40px; display: inline-block; }

/* ===== FILTERS BAR ===== */
.filters-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.filters-bar .form-input,
.filters-bar .form-select { min-width: 140px; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--glass-border);
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== TOAST ===== */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: slideInRight 250ms ease;
  min-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-success { background: #0c4a6e; border: 1px solid rgba(6,182,212,0.3); color: #06b6d4; }
.toast-error   { background: #3d1414; border: 1px solid rgba(239,68,68,0.3); color: #ef4444; }
.toast-info    { background: #0d1e3d; border: 1px solid rgba(59,130,246,0.3); color: #3b82f6; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state svg { margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 13px; margin-top: 6px; }

/* ===== UTILITY ===== */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-success   { color: var(--accent-emerald); }
.text-warn      { color: var(--accent-warning); }
.text-danger    { color: var(--accent-error); }
.text-blue      { color: var(--accent-primary); }
.text-sm        { font-size: 12px; }
.bold           { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* Recent list */
.recent-list { padding: 4px 16px; }
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--glass-border);
}
.recent-item:last-child { border-bottom: none; }
.recent-name { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.recent-meta { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.recent-price { font-weight: 700; font-size: 13px; color: var(--accent-emerald); white-space: nowrap; margin-left: 12px; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== FIN-KPI (Dashboard cards secundários) ===== */
.fin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.fin-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.fin-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.fin-kpi-card:hover { border-color: var(--glass-border-hover); transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
.fin-kpi-card.fin-green::before { background: linear-gradient(90deg, #10b981, #34d399); }
.fin-kpi-card.fin-red::before   { background: linear-gradient(90deg, #ef4444, #f87171); }
.fin-kpi-card.fin-blue::before  { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.fin-kpi-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; font-weight: 600; }
.fin-kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -1px; }
.fin-kpi-value.fin-val-green { color: #10b981; }
.fin-kpi-value.fin-val-red   { color: #ef4444; }

/* ===== CHARTS GRID ===== */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .charts-grid  { grid-template-columns: 1fr; }
  .fin-kpi-grid { grid-template-columns: 1fr; }
}

/* ===== FILTERS BAR ===== */
.filters-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }

/* ===== INFO ICON + TOOLTIP ===== */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  cursor: help;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.info-icon:hover {
  background: var(--accent-primary);
  color: #fff;
  transform: scale(1.1);
}
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #ffffff;
  color: #0f172a;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: normal;
  width: 200px;
  text-align: center;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.3), 0 0 1px 1px rgba(0,0,0,0.1);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2000;
  line-height: 1.4;
  border: 1px solid rgba(0,0,0,0.1);
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: rgba(0,0,0,0.1) transparent transparent transparent;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 2000;
}
[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== MOBILE RESPONSIVE (≤ 767px) ===== */
@media (max-width: 767px) {
  :root { --sidebar-width: 0px; }

  body.logged-in { padding-bottom: 64px; }

  /* Sidebar vira bottom-nav */
  .sidebar {
    width: 100% !important;
    min-height: unset;
    height: 64px;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--glass-border);
    z-index: 200;
    background: var(--bg-secondary);
    padding: 0;
    backdrop-filter: blur(16px);
  }

  /* Esconde cabeçalho do sidebar (logo) e rodapé (logout/status) em mobile */
  .sidebar-header,
  .sidebar-bottom { display: none !important; }

  /* Nav horizontal */
  .sidebar-nav {
    flex-direction: row;
    flex: 1;
    padding: 0;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    align-items: stretch;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }

  .nav-link {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 6px 6px;
    flex: 1;
    min-width: 54px;
    font-size: 10px;
    border-radius: 0;
    text-align: center;
  }
  .nav-link svg { width: 20px; height: 20px; }
  .nav-link span { font-size: 10px; line-height: 1.2; }
  .nav-link.active {
    background: var(--accent-primary-dim);
    border-top: 2px solid var(--accent-primary);
  }

  .badge-pill {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 9px;
    min-width: 14px;
    padding: 0 4px;
  }
  .nav-link { position: relative; }

  /* Main content sem margem lateral */
  .main-content {
    margin-left: 0 !important;
    padding: 16px 12px;
    min-height: unset;
  }

  /* KPI grid 2 colunas em mobile */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 22px; }

  /* Page header menor */
  .page-header { margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
  .page-header h2 { font-size: 18px; }

  /* Cards full-width */
  .settings-card, .card { border-radius: var(--radius-md); padding: 16px; }

  /* Tabelas scrolláveis horizontalmente */
  .table-wrap, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }

  /* Formulários full-width */
  .form-input, .form-select, .btn { width: 100%; box-sizing: border-box; }
  .btn { min-height: 44px; font-size: 14px; }

  /* Modais full-screen */
  .modal-content, [class*="modal"] > div {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-md) !important;
  }

  /* Filtros quebram em coluna */
  .filters-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filters-bar .form-select,
  .filters-bar .form-input,
  .filters-bar .btn { width: 100%; }

  /* Charts aspect ratio responsivo */
  .chart-wrap canvas { max-height: 220px !important; }
  .charts-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Login card */
  .login-card { padding: 24px 18px; }

  /* Crop modal */
  #crop-modal > div { width: 96vw !important; padding: 16px !important; }
}

/* ===== TABLET (768px–1024px) ===== */
@media (min-width: 768px) and (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
  .main-content { padding: 20px 18px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* ===== PWA — safe-area para notch ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body.logged-in { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  @media (max-width: 767px) {
    .sidebar { padding-bottom: env(safe-area-inset-bottom); height: calc(64px + env(safe-area-inset-bottom)); }
  }
}
