/* ============================================
   ProIA Delivery — SuperAdmin Dashboard
   Design System & Styles
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Brand */
  --brand: #E97316;
  --brand-light: #FB923C;
  --brand-dark: #C2410C;
  --brand-glow: rgba(233, 115, 22, 0.25);

  /* Sizing */
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
  --speed-fast: 150ms;
  --speed: 250ms;
  --speed-slow: 400ms;
}

/* Dark theme (default) */
[data-theme="dark"] {
  --bg-body: #0B0F19;
  --bg-surface: #131825;
  --bg-surface-hover: #1A2035;
  --bg-card: #161C2E;
  --bg-card-hover: #1E2540;
  --bg-input: #1A2035;
  --bg-modal: #161C2E;
  --border-color: rgba(255,255,255,0.07);
  --border-subtle: rgba(255,255,255,0.04);
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-popup: 0 20px 60px rgba(0,0,0,0.5);
  --chart-grid: rgba(255,255,255,0.06);
  --scrollbar-track: #131825;
  --scrollbar-thumb: #2A3350;
  --sidebar-bg: #0E1220;
  --stat-card-gradient: linear-gradient(135deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
}

/* Light theme */
[data-theme="light"] {
  --bg-body: #F1F5F9;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-input: #F1F5F9;
  --bg-modal: #FFFFFF;
  --border-color: rgba(0,0,0,0.08);
  --border-subtle: rgba(0,0,0,0.04);
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --shadow-card: 0 1px 8px rgba(0,0,0,0.06), 0 4px 24px rgba(0,0,0,0.04);
  --shadow-popup: 0 20px 60px rgba(0,0,0,0.12);
  --chart-grid: rgba(0,0,0,0.06);
  --scrollbar-track: #F1F5F9;
  --scrollbar-thumb: #CBD5E1;
  --sidebar-bg: #FFFFFF;
  --stat-card-gradient: linear-gradient(135deg, rgba(0,0,0,0.01), rgba(0,0,0,0.02));
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

/* ========================================
   LOGIN SCREEN
   ======================================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  padding: 20px;
  animation: loginFadeIn 0.6s var(--ease);
}

.login-screen.hidden {
  display: none;
}

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

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px 40px 40px;
  box-shadow: var(--shadow-popup);
  position: relative;
  overflow: hidden;
  animation: loginSlideUp 0.5s var(--ease) 0.15s both;
}

@keyframes loginSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-light), var(--brand));
  background-size: 200% 100%;
  animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.login-logo-wrap {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(233, 115, 22, 0.3);
  animation: logoPulse 2s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(233, 115, 22, 0.3); }
  50% { box-shadow: 0 8px 48px rgba(233, 115, 22, 0.5); }
}

.login-brand {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  position: relative;
  display: flex;
  align-items: center;
}

.login-field-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-size: 1.2rem;
  pointer-events: none;
  transition: color var(--speed-fast) var(--ease);
}

.login-field input {
  width: 100%;
  padding: 14px 16px 14px 50px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--speed-fast) var(--ease), box-shadow var(--speed-fast) var(--ease);
}

.login-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.login-field input:focus + .login-field-icon,
.login-field:focus-within .login-field-icon {
  color: var(--brand);
}

.login-error {
  color: #EF4444;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  min-height: 20px;
  transition: opacity var(--speed-fast) var(--ease);
}

.login-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--brand-glow);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn.loading .login-btn-text {
  opacity: 0;
}

.login-btn.loading .login-btn-loader {
  display: inline-block;
}

.login-btn-loader {
  display: none;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  position: absolute;
}

.login-footer-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 24px;
  letter-spacing: 0.03em;
}

/* ========================================
   LOGOUT BUTTON
   ======================================== */
.btn-logout {
  color: var(--text-muted) !important;
  transition: all var(--speed-fast) var(--ease) !important;
}

.btn-logout:hover {
  color: #EF4444 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  background: rgba(239, 68, 68, 0.1) !important;
}

/* ========================================
   DASHBOARD FOOTER
   ======================================== */
.dashboard-footer {
  padding: 24px 32px;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.dashboard-footer p {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.dashboard-footer a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--speed-fast) var(--ease);
}

.dashboard-footer a:hover {
  color: var(--brand-light);
  text-decoration: underline;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--speed) var(--ease);
}

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

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
}

.sidebar-brand {
  font-weight: 800;
  font-size: 1.25rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--speed-fast) var(--ease);
  position: relative;
}

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

.nav-item.active {
  background: var(--brand-glow);
  color: var(--brand);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--brand);
  border-radius: 0 4px 4px 0;
}

.nav-item .material-icons-round {
  font-size: 1.3rem;
}

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

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--speed-fast) var(--ease);
}

.theme-toggle:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 99;
}

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

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-body);
  z-index: 50;
  backdrop-filter: blur(12px);
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.5rem;
}

.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 1.2rem; font-weight: 700; }
.topbar-title p { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--speed-fast) var(--ease);
}

.btn-icon:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--brand);
}

.avatar-badge {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  font-size: 1.25rem;
}

/* ---------- Pages ---------- */
.page {
  display: none;
  padding: 28px 32px 40px;
  animation: fadeIn var(--speed) var(--ease);
}

.page.active { display: block; }

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

.page-header-row {
  margin-bottom: 24px;
}

.page-header-row h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ---------- Stats Grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--stat-card-gradient), var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--speed) var(--ease);
  cursor: default;
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: rgba(59,130,246,0.15); color: #3B82F6; }
.stat-icon.green { background: rgba(34,197,94,0.15); color: #22C55E; }
.stat-icon.orange { background: rgba(233,115,22,0.15); color: #E97316; }
.stat-icon.purple { background: rgba(139,92,246,0.15); color: #8B5CF6; }
.stat-icon.teal { background: rgba(20,184,166,0.15); color: #14B8A6; }
.stat-icon.red { background: rgba(239,68,68,0.15); color: #EF4444; }

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ---------- Charts Grid ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: box-shadow var(--speed) var(--ease);
}

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

.chart-card.wide {
  grid-column: 1 / -1;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.chart-icon {
  color: var(--text-muted);
  font-size: 1.3rem;
}

.chart-container {
  position: relative;
  height: 260px;
}

.chart-container.chart-wide {
  height: 220px;
}

/* ---------- Table Card ---------- */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.table-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.badge {
  background: var(--brand);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.table-responsive {
  overflow-x: auto;
}

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

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

tbody tr:hover {
  background: var(--bg-surface-hover);
}

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

.loading-cell {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted) !important;
}

/* Status pills */
.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.pill-active { background: rgba(34,197,94,0.15); color: #22C55E; }
.pill-overdue { background: rgba(239,68,68,0.15); color: #EF4444; }
.pill-trial { background: rgba(59,130,246,0.15); color: #3B82F6; }
.pill-cancelled { background: rgba(107,114,128,0.15); color: #6B7280; }
.pill-lite { background: rgba(107,114,128,0.15); color: #6B7280; }
.pill-starter { background: rgba(59,130,246,0.15); color: #3B82F6; }
.pill-pro { background: rgba(245,158,11,0.15); color: #F59E0B; }
.pill-premium { background: rgba(139,92,246,0.15); color: #8B5CF6; }

.pill-sim { background: rgba(34,197,94,0.15); color: #22C55E; }
.pill-nao { background: rgba(239,68,68,0.15); color: #EF4444; }

/* ---------- Planos Grid ---------- */
.planos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.plano-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
  transition: all var(--speed) var(--ease);
  overflow: hidden;
}

.plano-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

.plano-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--plano-color, var(--brand));
}

.plano-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.plano-card-header .plano-icon {
  font-size: 2rem;
}

.plano-card-header .plano-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--brand-glow);
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.plano-name {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.plano-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.plano-prices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.plano-price-item {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.plano-price-item .price-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.plano-price-item .price-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.plano-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.plano-meta .meta-tag {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 500;
}

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

/* ---------- Config Sections ---------- */
.config-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.config-category {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.config-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.config-category-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: capitalize;
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-category-header .material-icons-round {
  font-size: 1.2rem;
  color: var(--brand);
}

.config-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--speed-fast) var(--ease);
}

.config-item:last-child { border-bottom: none; }
.config-item:hover { background: var(--bg-surface-hover); }

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

.config-item-key {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand);
  font-family: 'Courier New', monospace;
}

.config-item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.config-item-value {
  flex: 1;
  min-width: 0;
}

.config-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color var(--speed-fast) var(--ease);
  outline: none;
}

.config-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

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

.btn-save {
  padding: 8px 16px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--speed-fast) var(--ease);
  opacity: 0;
  pointer-events: none;
}

.btn-save.visible {
  opacity: 1;
  pointer-events: all;
}

.btn-save:hover {
  background: var(--brand-dark);
}

.btn-delete {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--speed-fast) var(--ease);
}

.btn-delete:hover {
  background: rgba(239,68,68,0.15);
  color: #EF4444;
}

.config-add-row {
  padding: 16px 24px;
  display: flex;
  justify-content: flex-start;
}

/* ---------- Buttons ---------- */
.btn {
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--speed-fast) var(--ease);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--brand);
  color: white;
}

.btn-primary:hover {
  background: var(--brand-dark);
  box-shadow: 0 4px 16px var(--brand-glow);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

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

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-glow);
}

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
  animation: fadeIn var(--speed-fast) var(--ease);
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-popup);
}

.modal.modal-sm {
  max-width: 480px;
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 20px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--speed-fast) var(--ease);
}

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

.form-group textarea { resize: vertical; }

.color-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-input-row input[type="color"] {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
  cursor: pointer;
  background: var(--bg-input);
}

.color-input-row input[type="text"] {
  flex: 1;
}

.form-row-checks {
  grid-column: 1 / -1;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-card);
  animation: slideInRight var(--speed) var(--ease);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
}

.toast-success { background: #059669; }
.toast-error { background: #DC2626; }
.toast-info { background: #2563EB; }

.toast .material-icons-round { font-size: 1.2rem; }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: block;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .menu-btn {
    display: flex;
  }

  .topbar {
    padding: 0 16px;
  }

  .page {
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .planos-grid {
    grid-template-columns: 1fr;
  }

  .config-item {
    flex-direction: column;
    align-items: stretch;
  }

  .config-item-actions {
    justify-content: flex-end;
  }

  .login-card {
    padding: 36px 24px 32px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .plano-prices {
    grid-template-columns: 1fr;
  }
}
