:root {
  --bg: #0b0f14;
  --surface: #111827;
  --surface-2: #161f2e;
  --card: #1b2433;
  --card-hover: #202c3e;
  --border: #283449;
  --border-soft: #1f2a3a;
  --text: #f4f6fb;
  --muted: #93a0b4;
  --muted-2: #6b7890;
  --green: #22c55e;
  --green-2: #16a34a;
  --green-ghost: rgba(34, 197, 94, 0.12);
  --orange: #f97316;
  --orange-2: #ea6a0c;
  --orange-ghost: rgba(249, 115, 22, 0.14);
  --danger: #f87171;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --radius: 14px;
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== LOGIN / REGISTRO ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #0c111b 0%, var(--bg) 100%);
}

.auth-box {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, #0e1420, #0a0f1a);
  border: 1px solid var(--border);
  border-top: 3px solid var(--green);
  border-radius: 22px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.auth-brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.auth-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.auth-field input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 13px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-ghost);
}

.auth-btn {
  width: 100%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-2) 100%);
  color: #04130a;
  box-shadow: 0 8px 22px rgba(34, 197, 94, 0.3);
  transition: filter 0.15s;
  margin-top: 8px;
}

.auth-btn:hover { filter: brightness(1.08); }
.auth-btn:disabled { opacity: 0.5; cursor: default; }

.auth-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

.auth-toggle a {
  color: var(--green);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.auth-toggle a:hover { text-decoration: underline; }

.auth-error {
  color: var(--danger);
  font-size: 13px;
  margin: -8px 0 12px;
  min-height: 18px;
}

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

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0e1420, var(--surface));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 16px;
}

.sidebar-brand strong {
  font-size: 18px;
  font-weight: 800;
}

.sidebar-brand span {
  font-size: 11px;
  color: var(--muted);
  background: var(--green-ghost);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  margin-bottom: 4px;
  text-decoration: none;
}

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

.nav-item.active { background: var(--green-ghost); color: var(--green); }

.nav-ic { width: 18px; height: 18px; flex: 0 0 auto; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-user-email {
  font-size: 11px;
  color: var(--muted-2);
}

.logout-btn {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  margin-top: 8px;
  transition: background 0.13s;
}

.logout-btn:hover { background: rgba(248, 113, 113, 0.1); }

.main {
  flex: 1;
  margin-left: 260px;
  padding: 28px 32px;
  max-width: calc(100vw - 260px);
}

/* ===== HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 800;
}

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

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

.stat-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  transition: background 0.15s;
}

.stat-card:hover { background: var(--card-hover); }

.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-value.green { color: var(--green); }
.stat-value.orange { color: var(--orange); }

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

.filter-input {
  flex: 1 1 240px;
  min-width: 200px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 11px 14px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
}

.filter-input:focus { border-color: var(--green); }

.filter-select {
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 11px 14px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  min-width: 160px;
}

.btn {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  transition: filter 0.13s, background 0.13s;
  white-space: nowrap;
}

.btn-green {
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #04130a;
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.3);
}

.btn-green:hover { filter: brightness(1.08); }

.btn-orange {
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  color: #160a02;
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.3);
}

.btn-orange:hover { filter: brightness(1.08); }

.btn-ghost {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

/* ===== OFERTAS ===== */
.offers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.offer-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-top: 3px solid var(--orange);
  border-radius: var(--radius);
  padding: 16px;
  transition: background 0.15s, transform 0.15s;
  animation: fadeIn 0.25s ease;
}

.offer-card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
}

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

.offer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.offer-rank {
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--orange-ghost);
  color: var(--orange);
  border: 1px solid rgba(249, 115, 22, 0.4);
  border-radius: 11px;
  font-size: 14px;
  font-weight: 800;
  flex: 0 0 auto;
}

.offer-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.offer-stat {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.offer-stat strong {
  color: var(--orange);
  font-size: 20px;
  font-weight: 800;
}

.offer-keyword {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--green-ghost);
  color: var(--green);
  margin-bottom: 10px;
}

.offer-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #0d1320;
  border: 1px solid var(--border-soft);
  margin-bottom: 12px;
  position: relative;
}

.offer-media img, .offer-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.offer-media-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 7px;
}

.offer-page {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.offer-copy {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.offer-domain {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
  margin-bottom: 12px;
}

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

.offer-actions .btn {
  flex: 1;
  padding: 9px 8px;
  font-size: 12px;
}

/* ===== TABELA ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}

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

th {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(40, 52, 73, 0.5);
  color: var(--text);
  vertical-align: middle;
}

tr:hover td { background: rgba(255, 255, 255, 0.02); }

.td-thumb {
  width: 64px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  background: #0d1320;
  border: 1px solid var(--border);
}

.td-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.td-name {
  font-weight: 700;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-ads {
  color: var(--orange);
  font-weight: 800;
  font-size: 15px;
}

.td-domain {
  color: var(--green);
}

.td-actions {
  display: flex;
  gap: 6px;
}

.td-actions .btn {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

/* ===== KEYWORDS VIEW ===== */
.keyword-group {
  margin-bottom: 24px;
}

.keyword-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 11px;
  border: 1px solid var(--border);
}

.keyword-header h3 {
  font-size: 14px;
  font-weight: 800;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.keyword-count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-left: auto;
}

/* ===== CONFIGURAÇÕES ===== */
.settings-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 640px;
  margin-bottom: 20px;
}

.settings-card h3 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
}

.settings-card p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.api-key-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.api-key-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 13px;
  outline: none;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 12px;
  color: var(--muted);
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.empty-state p {
  font-size: 13px;
  max-width: 400px;
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--muted);
  font-size: 14px;
  gap: 10px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--green-2);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #dc2626; }

/* ===== RESPONSIVO ===== */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; height: auto; }
  .main { margin-left: 0; max-width: 100%; padding: 16px; }
  .layout { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
