/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:       #0f1117;
  --bg-surface:    #1a1d27;
  --bg-elevated:   #22263a;
  --bg-hover:      #2a2f45;
  --border:        #2e3350;
  --border-light:  #3a4060;

  --text-primary:  #e8eaf6;
  --text-secondary:#9ba3c2;
  --text-muted:    #5c637a;

  --blue:          #1877F2;
  --blue-hover:    #1565d8;
  --blue-dim:      rgba(24,119,242,0.15);

  --green:         #22c55e;
  --green-dim:     rgba(34,197,94,0.15);
  --yellow:        #f59e0b;
  --yellow-dim:    rgba(245,158,11,0.15);
  --red:           #ef4444;
  --red-dim:       rgba(239,68,68,0.15);
  --purple:        #8b5cf6;

  --sidebar-w:     240px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --transition:    0.18s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}


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

.sidebar-nav li { padding: 2px 10px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: var(--blue-dim); color: var(--blue); }
.nav-link-danger { color: var(--red) !important; }
.nav-link-danger:hover { background: var(--red-dim) !important; }

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 10px 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 200;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
}

/* ─── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 32px;
}

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

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 4px 10px;
  border-radius: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 16px;
}

.section-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Metric Cards ───────────────────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 8px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition);
}
.metric-card:hover { border-color: var(--border-light); }

.metric-icon { font-size: 28px; line-height: 1; }

.metric-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* ─── Contas Grid ────────────────────────────────────────────────────────────── */
.contas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.conta-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.conta-card:hover { border-color: var(--border-light); box-shadow: var(--shadow); }

.conta-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.conta-nome {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.conta-metricas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.conta-metrica {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.metrica-valor {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

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

/* ─── Status Badges ──────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.status-badge::before { content: '●'; font-size: 8px; }

.status-ok         { background: var(--green-dim);  color: var(--green);  }
.status-atencao    { background: var(--yellow-dim); color: var(--yellow); }
.status-critico    { background: var(--red-dim);    color: var(--red);    }
.status-desconhecido { background: var(--bg-elevated); color: var(--text-muted); }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary  { background: var(--blue);       color: #fff;                border-color: var(--blue); }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); border-color: var(--blue-hover); }

.btn-outline  { background: transparent;       color: var(--text-secondary); border-color: var(--border-light); }
.btn-outline:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger   { background: var(--red-dim);    color: var(--red);          border-color: var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; }

.btn-full { width: 100%; }
.btn-sm   { padding: 6px 12px; font-size: 12px; }
.btn-xs   { padding: 4px 8px;  font-size: 11px; }

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th {
  background: var(--bg-elevated);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  vertical-align: middle;
}

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

.table tr:hover td { background: var(--bg-hover); }

.table code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  font-family: monospace;
}

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

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 13px;
  width: 100%;
  transition: border-color var(--transition);
  outline: none;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.form-group-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.form-group-inline label { white-space: nowrap; margin: 0; }
.form-group-inline input,
.form-group-inline select { width: auto; }

/* ─── Modals ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: modalIn 0.18s ease;
}

.modal-lg { max-width: 680px; }
.modal-sm { max-width: 400px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1);    }
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.alert-error   { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(239,68,68,0.3); }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.alert-warning { background: var(--yellow-dim);color: var(--yellow);border: 1px solid rgba(245,158,11,0.3); }

/* ─── Saldo Modal ────────────────────────────────────────────────────────────── */
.saldo-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.saldo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.saldo-row:last-child { border-bottom: none; }

.saldo-row span:first-child { color: var(--text-secondary); }

.saldo-destaque {
  background: var(--blue-dim);
  border-color: rgba(24,119,242,0.2);
}

.saldo-destaque strong {
  font-size: 18px;
  color: var(--blue);
}

/* ─── Progresso de Relatório ─────────────────────────────────────────────────── */
.progresso-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: monospace;
  font-size: 12px;
  min-height: 80px;
}

.progresso-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-secondary);
  animation: fadeSlide 0.2s ease;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.progresso-dot {
  color: var(--blue);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ─── Loading & Empty States ─────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 64px 32px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ─── Filtros ────────────────────────────────────────────────────────────────── */
.filtros-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

/* ─── Skeleton ───────────────────────────────────────────────────────────────── */
.skeleton .metric-value {
  background: var(--bg-elevated);
  color: transparent;
  border-radius: 4px;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0%,100% { opacity: 0.4; }
  50%      { opacity: 0.8; }
}

/* ─── Login Page ─────────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 60% 40%, rgba(24,119,242,0.08) 0%, transparent 60%), var(--bg-base);
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 20px;
}

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

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.login-form {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
}

/* ─── Settings Page ──────────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 480px);
  gap: 20px;
}

.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.settings-card-header p {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Platform Badges ────────────────────────────────────────────────────────── */
.badge-plataforma {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-meta {
  background: rgba(24,119,242,0.15);
  color: #1877F2;
  border: 1px solid rgba(24,119,242,0.25);
}

.badge-google {
  background: rgba(234,67,53,0.12);
  color: #ea4335;
  border: 1px solid rgba(234,67,53,0.25);
}

/* ─── Platform Toggle (conta form) ──────────────────────────────────────────── */
.platform-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.platform-btn {
  flex: 1;
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.platform-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.platform-btn.active {
  background: var(--blue);
  color: #fff;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .main-content { margin-left: 0; padding: 16px; padding-top: 64px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .filtros-bar { flex-direction: column; align-items: stretch; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .contas-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius) var(--radius) 0 0; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}
