/* =============================================
   JudFácil - SaaS Multi-tenancy Platform
   Main Stylesheet with Light/Dark Theme
   ============================================= */

/* --- CSS Variables / Themes --- */
:root {
  /* Brand Colors */
  --brand-gradient: linear-gradient(135deg, #FF4E50 0%, #FC913A 50%, #F9D423 100%);
  --brand-gradient-btn: linear-gradient(135deg, #FF4E50 0%, #FC913A 100%);
  --brand-red: #FF4E50;
  --brand-orange: #FC913A;
  --brand-yellow: #F9D423;
  --brand-navy: #1A1F3C;
  --brand-pink: #FF2D6B;

  /* Light Theme */
  --bg-primary: #F4F6FB;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #EEF1F8;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --bg-header: #FFFFFF;
  --bg-input: #F0F2F8;
  --bg-hover: #F0F2F8;
  --bg-overlay: rgba(26, 31, 60, 0.5);

  --text-primary: #1A1F3C;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --text-inverse: #FFFFFF;
  --text-link: #FC913A;

  --border-color: #E5E7EB;
  --border-input: #D1D5DB;
  --border-focus: #FC913A;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-brand: 0 4px 20px rgba(252, 145, 58, 0.35);

  --sidebar-width: 260px;
  --header-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-primary: #0F1117;
  --bg-secondary: #1A1D27;
  --bg-tertiary: #1E2130;
  --bg-card: #1E2130;
  --bg-sidebar: #151821;
  --bg-header: #151821;
  --bg-input: #252A3D;
  --bg-hover: #252A3D;
  --bg-overlay: rgba(0, 0, 0, 0.7);

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-inverse: #1A1F3C;
  --text-link: #FC913A;

  --border-color: #2A3050;
  --border-input: #2A3050;
  --border-focus: #FC913A;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-brand: 0 4px 20px rgba(252, 145, 58, 0.25);
}

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

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-tertiary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-orange); }

/* --- Page Sections (Auth screens) --- */
.auth-page {
  display: none;
  min-height: 100vh;
  width: 100%;
}
.auth-page.active { display: flex; }

/* --- Auth Layout --- */
.auth-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  width: 100%;
}

.auth-left {
  background: var(--brand-gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

.auth-left::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  top: -100px; left: -100px;
}
.auth-left::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  bottom: -80px; right: -80px;
}

.auth-left-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 1;
  margin-bottom: 40px;
}

.auth-left-logo img {
  width: 90px;
  height: 90px;
  filter: brightness(0) invert(1) drop-shadow(0 4px 20px rgba(0,0,0,0.25));
}

.auth-left-logo .brand-text {
  display: flex;
  align-items: center;
  gap: 0;
}

.auth-left-logo .brand-text span,
.auth-left-logo .brand-text span:first-child,
.auth-left-logo .brand-text span:last-child {
  font-size: 2.4rem;
  font-weight: 800;
  color: #ffffff !important;
  text-shadow: 0 2px 8px rgba(0,0,0,0.18);
  -webkit-text-fill-color: #ffffff !important;
}

.auth-left-tagline {
  color: #ffffff !important;
  font-size: 1.1rem;
  text-align: center;
  max-width: 360px;
  z-index: 1;
  font-weight: 500;
  line-height: 1.7;
  text-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.auth-left-features {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 40px;
  z-index: 1;
  width: 100%;
  max-width: 360px;
}

.auth-feature-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255,255,255,0.18);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.30);
}

.auth-feature-item .feature-icon {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.30);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.auth-feature-item .feature-text strong {
  display: block;
  color: #ffffff !important;
  font-size: 0.9rem;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.auth-feature-item .feature-text span {
  color: #ffffff !important;
  opacity: 0.88;
  font-size: 0.8rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.10);
}

/* Garantia: todos os textos dentro do painel esquerdo são brancos */
.auth-left * {
  color: #ffffff;
}

.auth-left .brand-text span {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

.auth-left p,
.auth-left span,
.auth-left strong,
.auth-left .auth-left-tagline {
  color: #ffffff !important;
}

.auth-right {
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  transition: background 0.3s ease;
  position: relative;
}

.auth-form-wrapper {
  width: 100%;
  max-width: 420px;
}

.auth-form-header {
  margin-bottom: 32px;
}

.auth-form-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.auth-form-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Theme Toggle (Auth) */
.auth-theme-toggle {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-input-wrapper {
  position: relative;
}

.form-input-wrapper .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}

.form-input-wrapper .input-icon-right {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.form-input-wrapper .input-icon-right:hover { color: var(--brand-orange); }

.form-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 3px rgba(252, 145, 58, 0.15);
}

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

.form-input.no-icon { padding-left: 14px; }

.form-input.has-right-icon { padding-right: 42px; }

.form-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
  cursor: pointer;
  appearance: none;
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(252, 145, 58, 0.15);
}

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

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.form-check label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-check label a { color: var(--brand-orange); font-weight: 600; }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.form-link {
  font-size: 0.85rem;
  color: var(--brand-orange);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.form-link:hover { color: var(--brand-red); text-decoration: underline; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand-gradient-btn);
  color: #fff;
  width: 100%;
  padding: 13px;
  font-size: 0.95rem;
  box-shadow: var(--shadow-brand);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(252, 145, 58, 0.45);
  filter: brightness(1.05);
}

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

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

.btn-secondary:hover { background: var(--bg-hover); border-color: var(--brand-orange); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--brand-orange);
  color: var(--brand-orange);
}

.btn-outline:hover { background: var(--brand-orange); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

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

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-lg { padding: 15px 32px; font-size: 1rem; }

/* --- Divider --- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
}

.auth-divider span {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* --- Social Buttons --- */
.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.social-btn:hover { border-color: var(--brand-orange); background: var(--bg-hover); }

.social-btn img { width: 20px; height: 20px; }

.social-btns { display: flex; flex-direction: column; gap: 10px; }

/* --- Auth Footer --- */
.auth-footer-text {
  text-align: center;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-footer-text a, .auth-footer-text button {
  color: var(--brand-orange);
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  transition: var(--transition);
}

.auth-footer-text a:hover,
.auth-footer-text button:hover { color: var(--brand-red); text-decoration: underline; }

/* --- Password Strength --- */
.password-strength {
  margin-top: 8px;
}

.strength-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.strength-bar span {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border-color);
  transition: var(--transition);
}

.strength-bar span.active-weak { background: #ef4444; }
.strength-bar span.active-fair { background: #f59e0b; }
.strength-bar span.active-good { background: #3b82f6; }
.strength-bar span.active-strong { background: #10b981; }

.strength-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- OTP Input --- */
.otp-wrapper {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 24px 0;
}

.otp-input {
  width: 52px;
  height: 56px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--bg-input);
  border: 2px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.otp-input:focus {
  border-color: var(--brand-orange);
  box-shadow: 0 0 0 3px rgba(252,145,58,0.15);
  background: var(--bg-secondary);
}

/* --- Theme Toggle Button --- */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle-btn:hover { border-color: var(--brand-orange); color: var(--brand-orange); }

.theme-toggle-btn .toggle-icon { font-size: 1rem; }

/* =============================================
   DASHBOARD
   ============================================= */
.dashboard-page {
  display: none;
}

.dashboard-page.active {
  display: flex;
  min-height: 100vh;
}

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

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

.sidebar-logo {
  width: 36px; height: 36px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
}

.sidebar-brand span:first-child {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--brand-navy);
}

.sidebar-brand span:last-child {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--brand-pink);
}

[data-theme="dark"] .sidebar-brand span:first-child {
  color: #F1F5F9;
}

.sidebar-toggle-btn {
  margin-left: auto;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover { color: var(--brand-orange); border-color: var(--brand-orange); }

/* Tenant Badge */
.tenant-badge {
  margin: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.tenant-badge:hover { border-color: var(--brand-orange); }

.tenant-avatar {
  width: 32px; height: 32px;
  background: var(--brand-gradient-btn);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

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

.tenant-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tenant-plan {
  font-size: 0.7rem;
  color: var(--brand-orange);
  font-weight: 500;
}

.tenant-chevron {
  color: var(--text-muted);
  font-size: 0.7rem;
  flex-shrink: 0;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-radius: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  position: relative;
}

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

.nav-item.active {
  background: linear-gradient(135deg, rgba(255,78,80,0.12), rgba(252,145,58,0.12));
  color: var(--brand-orange);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--brand-gradient-btn);
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.nav-item .nav-label { flex: 1; }

.nav-badge {
  background: var(--brand-gradient-btn);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.nav-badge.new {
  background: #10b981;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border-color);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-user:hover { background: var(--bg-hover); }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient-btn);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

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

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.user-menu-btn {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.user-menu-btn:hover { color: var(--brand-orange); }

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

/* --- Top Header --- */
.top-header {
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  transition: background 0.3s ease;
}

.header-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
}

.header-breadcrumb .bc-item { color: var(--text-muted); }
.header-breadcrumb .bc-sep { color: var(--text-muted); font-size: 0.75rem; }
.header-breadcrumb .bc-current { color: var(--text-primary); font-weight: 600; }

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  min-width: 260px;
  cursor: text;
  transition: var(--transition);
}

.header-search:focus-within {
  border-color: var(--brand-orange);
  box-shadow: 0 0 0 3px rgba(252,145,58,0.1);
}

.header-search i { color: var(--text-muted); font-size: 0.85rem; }

.header-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  width: 100%;
}

.header-search input::placeholder { color: var(--text-muted); }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.header-icon-btn:hover {
  border-color: var(--brand-orange);
  color: var(--brand-orange);
  background: var(--bg-hover);
}

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--brand-red);
  border-radius: 50%;
  border: 2px solid var(--bg-header);
}

/* --- Page Body --- */
.page-body {
  flex: 1;
  padding: 28px 28px;
  overflow-x: hidden;
}

.page-title-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-title p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

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

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}

.stat-icon.orange { background: rgba(252,145,58,0.15); color: var(--brand-orange); }
.stat-icon.red { background: rgba(255,78,80,0.15); color: var(--brand-red); }
.stat-icon.green { background: rgba(16,185,129,0.15); color: #10b981; }
.stat-icon.blue { background: rgba(59,130,246,0.15); color: #3b82f6; }
.stat-icon.purple { background: rgba(139,92,246,0.15); color: #8b5cf6; }

.stat-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.stat-badge.up { background: rgba(16,185,129,0.12); color: #10b981; }
.stat-badge.down { background: rgba(239,68,68,0.12); color: #ef4444; }

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

.stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Grid Layout --- */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.content-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.span-2 { grid-column: span 2; }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

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

.card-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body { padding: 20px; }

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Chart Area --- */
.chart-wrapper {
  position: relative;
  height: 220px;
}

/* --- Activity Feed --- */
.activity-list { display: flex; flex-direction: column; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-dot.orange { background: var(--brand-orange); }
.activity-dot.green { background: #10b981; }
.activity-dot.blue { background: #3b82f6; }
.activity-dot.red { background: var(--brand-red); }
.activity-dot.purple { background: #8b5cf6; }

.activity-content { flex: 1; }

.activity-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.activity-text strong { color: var(--text-primary); font-weight: 600; }

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* --- Table --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.data-table th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.data-table th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

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

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

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

.table-avatar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-avatar .avatar-circle {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient-btn);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.table-avatar .avatar-name { font-weight: 500; }
.table-avatar .avatar-email { font-size: 0.75rem; color: var(--text-muted); }

/* --- Badges / Status --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.73rem;
  font-weight: 600;
}

.badge-success { background: rgba(16,185,129,0.12); color: #10b981; }
.badge-warning { background: rgba(245,158,11,0.12); color: #f59e0b; }
.badge-danger { background: rgba(239,68,68,0.12); color: #ef4444; }
.badge-info { background: rgba(59,130,246,0.12); color: #3b82f6; }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-purple { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.badge-orange { background: rgba(252,145,58,0.12); color: var(--brand-orange); }

/* --- Progress Bar --- */
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--brand-gradient-btn);
  transition: width 1s ease;
}

.progress-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}

/* --- Quick Actions --- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.quick-action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.quick-action-item:hover {
  border-color: var(--brand-orange);
  background: var(--bg-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

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

.qa-text .qa-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.qa-text .qa-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* --- Mini Stat --- */
.mini-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.mini-stat:last-child { border-bottom: none; padding-bottom: 0; }
.mini-stat:first-child { padding-top: 0; }

.mini-stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-stat-label .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mini-stat-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* --- Notification Panel --- */
.notif-panel {
  position: fixed;
  top: 64px;
  right: 24px;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: none;
  overflow: hidden;
}

.notif-panel.open { display: block; }

.notif-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notif-panel-header h4 { font-size: 0.9rem; font-weight: 700; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: rgba(252,145,58,0.04); }

.notif-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.notif-info .notif-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.notif-info .notif-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.notif-info .notif-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Collapsed Sidebar --- */
.sidebar.collapsed {
  width: 68px;
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .tenant-info,
.sidebar.collapsed .tenant-chevron,
.sidebar.collapsed .user-info,
.sidebar.collapsed .user-menu-btn {
  display: none;
}

.sidebar.collapsed .tenant-badge {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
  margin: 1px 8px;
}

.sidebar.collapsed .sidebar-user {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed + .main-content {
  margin-left: 68px;
}

/* --- Mobile Overlay --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 99;
  backdrop-filter: blur(2px);
}

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

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 400px;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-left: 4px solid var(--brand-orange);
}

.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #ef4444; }
.toast.info { border-left-color: #3b82f6; }

@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(110%); opacity: 0; }
}

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); }
.toast-msg { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.toast-close { color: var(--text-muted); padding: 2px; cursor: pointer; font-size: 0.85rem; }
.toast-close:hover { color: var(--text-primary); }

/* --- Responsive --- */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1024px) {
  .auth-container { grid-template-columns: 1fr; }
  .auth-left { display: none; }
  .auth-right { min-height: 100vh; }
}

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .content-grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }

  .sidebar {
    transform: translateX(-100%);
  }

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

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

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

  .page-body { padding: 16px; }
  .top-header { padding: 0 16px; }
  .header-search { display: none; }

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

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-title-bar { flex-direction: column; align-items: flex-start; }
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.fade-in { animation: fadeIn 0.4s ease forwards; }
.scale-in { animation: scaleIn 0.3s ease forwards; }

/* --- Gradient Text --- */
.gradient-text {
  background: var(--brand-gradient-btn);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Spinner --- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* --- Plan Cards --- */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.plan-card {
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.plan-card:hover {
  border-color: var(--brand-orange);
  transform: translateY(-2px);
}

.plan-card.selected {
  border-color: var(--brand-orange);
  background: rgba(252,145,58,0.06);
}

.plan-card.popular::before {
  content: 'Popular';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-gradient-btn);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: var(--radius-full);
}

.plan-name { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.plan-price { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); }
.plan-price span { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); }
.plan-features { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.plan-feature { font-size: 0.78rem; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.plan-feature i { color: #10b981; font-size: 0.7rem; }
