:root {
  --font-family-base: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 64px;
  
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --info-color: #06b6d4;

  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #4f46e5;
  --sidebar-text: #94a3b8;
  --sidebar-text-bright: #f8fafc;
  --sidebar-border: #1e293b;

  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] {
  --bg-body: #090d16;
  --bg-surface: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family-base);
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT PRINCIPAL (APP WRAPPER)
   ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: all 0.25s ease-in-out;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--sidebar-text-bright);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.025em;
  color: #ffffff;
}

.brand-subtitle {
  font-size: 0.65rem;
  color: #94a3b8;
  display: block;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.sidebar-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  padding: 0.75rem 0.75rem 0.35rem;
}

.nav-item-custom {
  margin-bottom: 0.2rem;
}

.nav-link-custom {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--sidebar-text);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-link-custom i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.nav-link-custom:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-text-bright);
}

.nav-link-custom.active {
  background-color: var(--sidebar-active);
  color: #ffffff;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  font-size: 0.8rem;
}

/* MAIN CONTENT */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease-in-out;
}

/* TOPBAR */
.app-topbar {
  height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 900;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}

.btn-sidebar-toggle:hover {
  background-color: var(--border-color);
  color: var(--text-main);
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.user-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.user-avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #4f46e5;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}

/* APP CONTENT CONTAINER */
.app-content {
  flex: 1;
  padding: 1.5rem;
}

/* ============================================================
   UI COMPONENTS (CARDS, BADGES, BUTTONS)
   ============================================================ */
.card-modern {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-modern:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

.card-header-modern {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card {
  padding: 1.25rem;
  border-radius: 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.stat-icon.primary { background: rgba(79, 70, 229, 0.12); color: #4f46e5; }
.stat-icon.success { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.stat-icon.warning { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.stat-icon.info { background: rgba(6, 182, 212, 0.12); color: #06b6d4; }

.table-modern {
  width: 100%;
  margin-bottom: 0;
}

.table-modern th {
  background-color: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.table-modern td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

/* ============================================================
   TELA DE LOGIN
   ============================================================ */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 10% 20%, #1e1b4b 0%, #0f172a 90%);
}

.login-wrapper {
  width: 100%;
  max-width: 440px;
  padding: 1.5rem;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .login-card {
  background: #0f172a;
}

.brand-logo-icon {
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  color: #fff;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
}

.text-gradient {
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-glow {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  border: none;
  box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
  transition: all 0.2s ease;
}

.btn-glow:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px 0 rgba(79, 70, 229, 0.45);
}

/* RESPONSIVIDADE */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
}