*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #4F46E5; --primary-dark: #3730A3; --primary-light: #818CF8;
  --accent: #7C3AED; --success: #10B981; --warning: #F59E0B; --danger: #EF4444;
  --bg: #0F0E17; --bg-card: #1A1929; --bg-card2: #211F35;
  --text: #F8F8FC; --muted: #9CA3AF;
  --border: rgba(255,255,255,0.08);
  --gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
}
html { scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }

/* ── NAV ── */
.app-nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(15,14,23,0.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo-link { font-size: 1.25rem; font-weight: 800; text-decoration: none;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.logo-link span { font-weight: 400; }
.nav-right { display: flex; align-items: center; gap: 1rem; }
.nav-user { color: var(--muted); font-size: 0.9rem; }
.nav-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color 0.2s; }
.nav-link:hover { color: var(--text); }
.nav-logout { color: var(--danger); }
.nav-btn {
  background: var(--gradient); color: #fff; text-decoration: none;
  padding: 0.45rem 1.1rem; border-radius: 8px; font-weight: 600; font-size: 0.88rem;
  transition: opacity 0.2s;
}
.nav-btn:hover { opacity: 0.85; }

/* ── FOOTER ── */
.app-footer {
  text-align: center; padding: 2rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.82rem;
}
.app-footer a { color: var(--muted); text-decoration: none; }
.app-footer a:hover { color: var(--primary-light); }

/* ── FLASH ── */
.flash {
  padding: 0.85rem 1.25rem; border-radius: 10px; margin-bottom: 1.25rem;
  font-size: 0.92rem; font-weight: 500;
}
.flash-error   { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #FCA5A5; }
.flash-success { background: rgba(16,185,129,0.12); border: 1px solid rgba(16,185,129,0.3); color: #6EE7B7; }

/* ── AUTH ── */
.auth-wrap { min-height: calc(100vh - 140px); display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 2.5rem 2rem;
}
.auth-logo {
  font-size: 1.5rem; font-weight: 800; margin-bottom: 1.25rem;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-logo span { font-weight: 400; }
.auth-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.25rem; letter-spacing: -0.3px; }
.auth-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.75rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-bottom: 0.4rem; letter-spacing: 0.3px; }
.field input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.7rem 1rem; color: var(--text);
  font-size: 0.95rem; font-family: inherit;
  transition: border-color 0.2s;
}
.field input:focus { outline: none; border-color: var(--primary); }
.btn-submit {
  width: 100%; background: var(--gradient); color: #fff; border: none;
  padding: 0.85rem; border-radius: 10px; font-weight: 700; font-size: 1rem;
  cursor: pointer; margin-top: 0.5rem; transition: opacity 0.2s;
  font-family: inherit;
}
.btn-submit:hover { opacity: 0.88; }
.auth-switch { margin-top: 1.25rem; text-align: center; color: var(--muted); font-size: 0.88rem; }
.auth-switch a { color: var(--primary-light); text-decoration: none; font-weight: 600; }
.auth-terms { margin-top: 0.75rem; text-align: center; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }

/* ── DASHBOARD ── */
.dash-wrap { display: flex; min-height: calc(100vh - 130px); }

.dash-sidebar {
  width: 230px; flex-shrink: 0;
  background: var(--bg-card); border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex; flex-direction: column; gap: 2rem;
}
.sidebar-brand {
  font-size: 1.15rem; font-weight: 800; padding: 0 0.5rem;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.sidebar-brand span { font-weight: 400; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar-link {
  display: block; padding: 0.65rem 0.75rem; border-radius: 8px;
  text-decoration: none; color: var(--muted); font-size: 0.9rem; font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.sidebar-link:hover, .sidebar-link.active { background: rgba(79,70,229,0.15); color: var(--text); }
.sidebar-logout { margin-top: auto; color: var(--danger); }
.sidebar-logout:hover { background: rgba(239,68,68,0.1); color: var(--danger); }

.dash-content { flex: 1; padding: 2rem; overflow-x: hidden; }
.dash-header { margin-bottom: 2rem; }
.dash-title { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.5px; }
.dash-sub { color: var(--muted); font-size: 0.95rem; }

.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 2.5rem; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
}
.stat-icon { font-size: 1.75rem; }
.stat-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); letter-spacing: 0.5px; text-transform: uppercase; }
.stat-val { font-size: 1.05rem; font-weight: 700; margin-top: 0.15rem; }
.status-active { color: var(--success); }
.status-past_due { color: var(--warning); }
.status-canceled { color: var(--danger); }
.site-link { color: var(--primary-light); text-decoration: none; font-size: 0.9rem; }

.dash-section { margin-bottom: 2.5rem; }
.section-heading { font-size: 1.15rem; font-weight: 700; margin-bottom: 1.25rem; letter-spacing: -0.3px; }
.section-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.btn-sm { color: var(--primary-light); text-decoration: none; font-size: 0.85rem; font-weight: 600; }

/* Plan cards inside dash */
.plan-cards { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); max-width: 620px; }
.plan-card {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.75rem; position: relative;
}
.plan-card.featured { border-color: var(--primary); box-shadow: 0 0 30px rgba(79,70,229,0.2); }
.featured-badge {
  position: absolute; top: -12px; left: 1.5rem;
  background: var(--gradient); color: #fff;
  font-size: 0.72rem; font-weight: 700; padding: 0.25rem 0.75rem; border-radius: 100px;
}
.plan-name { font-size: 0.85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; }
.plan-price { font-size: 2.5rem; font-weight: 900; letter-spacing: -1px; line-height: 1; margin-bottom: 1rem; }
.plan-price span { font-size: 1rem; color: var(--muted); font-weight: 500; }
.plan-features { list-style: none; margin-bottom: 1.5rem; }
.plan-features li { font-size: 0.88rem; color: var(--muted); padding: 0.3rem 0; }
.plan-features li strong { color: var(--text); }
.btn-plan {
  display: block; text-align: center; padding: 0.75rem; border-radius: 9px;
  font-weight: 700; text-decoration: none; font-size: 0.95rem; transition: all 0.2s;
}
.btn-plan.primary { background: var(--gradient); color: #fff; }
.btn-plan.primary:hover { opacity: 0.88; }
.btn-plan.ghost { border: 1px solid var(--border); color: var(--text); }
.btn-plan.ghost:hover { border-color: var(--primary-light); background: rgba(79,70,229,0.1); }

/* Invoices table */
.table-wrap { overflow-x: auto; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.inv-table th { text-align: left; padding: 0.75rem 1rem; color: var(--muted); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.inv-table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); }
.inv-table tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 0.25rem 0.6rem; border-radius: 6px; font-size: 0.78rem; font-weight: 700; }
.badge-paid   { background: rgba(16,185,129,0.15); color: #6EE7B7; }
.badge-open   { background: rgba(245,158,11,0.15); color: #FCD34D; }
.badge-void   { background: rgba(156,163,175,0.15); color: #9CA3AF; }
.inv-link { color: var(--primary-light); text-decoration: none; font-size: 0.85rem; }

/* Portal CTA */
.portal-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.5rem 1.75rem;
}
.portal-cta h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.25rem; }
.portal-cta p { color: var(--muted); font-size: 0.88rem; }
.btn-portal {
  white-space: nowrap; background: var(--gradient); color: #fff;
  padding: 0.7rem 1.25rem; border-radius: 9px; font-weight: 700; font-size: 0.9rem;
  text-decoration: none; transition: opacity 0.2s;
}
.btn-portal:hover { opacity: 0.88; }

/* Center page (obrigado, error) */
.center-page { min-height: calc(100vh - 130px); display: flex; align-items: center; justify-content: center; padding: 2rem; }
.ty-box { max-width: 480px; text-align: center; }
.ty-icon { font-size: 4rem; margin-bottom: 1rem; }
.ty-box h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.75rem; }
.ty-box p { color: var(--muted); margin-bottom: 2rem; line-height: 1.7; }
.btn-primary-full {
  display: inline-block; background: var(--gradient); color: #fff;
  padding: 0.85rem 2rem; border-radius: 10px; font-weight: 700; text-decoration: none;
  transition: opacity 0.2s;
}
.btn-primary-full:hover { opacity: 0.88; }

/* ── MOBILE ── */
@media (max-width: 768px) {
  .dash-sidebar { display: none; }
  .dash-content { padding: 1.25rem; }
  .app-nav { padding: 0.75rem 1rem; }
  .portal-cta { flex-direction: column; }
}
