/* =================================
   CSS Variables & Reset
   ================================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Brand Color */
  --brand: #39e5a6;
  --brand-dark: #2dd194;
  --brand-darker: #24b880;
  --brand-light: rgba(57, 229, 166, 0.1);

  /* State Colors */
  --state-success: #22c55e;
  --state-success-dark: #16a34a;
  --state-success-light: rgba(34, 197, 94, 0.1);
  --state-warning: #f59e0b;
  --state-warning-dark: #d97706;
  --state-warning-light: rgba(251, 191, 36, 0.1);
  --state-danger: #ef4444;
  --state-danger-dark: #dc2626;
  --state-danger-light: rgba(239, 68, 68, 0.1);
  --state-info: #3b82f6;
  --state-info-dark: #2563eb;
  --state-info-light: rgba(59, 130, 246, 0.1);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
}

/* Dark Theme */
[data-theme="dark"] {
  color-scheme: dark;
  /* Zinc/Gray Palette - Dark Mode */
  --bg-primary: #09090b;
  --bg-secondary: #18181b;
  --bg-tertiary: #27272a;
  --bg-elevated: #1e1e22;

  --border-subtle: #27272a;
  --border-default: #3f3f46;
  --border-emphasis: #52525b;

  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

/* Light Theme */
[data-theme="light"] {
  color-scheme: light;
  /* Zinc/Gray Palette - Light Mode */
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f4f4f5;
  --bg-elevated: #ffffff;

  --border-subtle: #e4e4e7;
  --border-default: #d4d4d8;
  --border-emphasis: #a1a1aa;

  --text-primary: #09090b;
  --text-secondary: #3f3f46;
  --text-tertiary: #52525b;

  /* Shadows */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Adjust brand colors for light mode */
  --brand: #0ea772;
  --brand-dark: #0d9568;
  --brand-darker: #0c835e;
  --brand-light: rgba(14, 167, 114, 0.15);
}

/* Auto theme based on system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --bg-elevated: #1e1e22;

    --border-subtle: #27272a;
    --border-default: #3f3f46;
    --border-emphasis: #52525b;

    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  }
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f4f4f5;
    --bg-elevated: #ffffff;

    --border-subtle: #e4e4e7;
    --border-default: #d4d4d8;
    --border-emphasis: #a1a1aa;

    --text-primary: #09090b;
    --text-secondary: #3f3f46;
    --text-tertiary: #52525b;

    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --brand: #0ea772;
    --brand-dark: #0d9568;
    --brand-darker: #0c835e;
    --brand-light: rgba(14, 167, 114, 0.15);
  }
}

html {
  scroll-behavior: smooth;
}

/* Smooth theme transitions */
html,
html * {
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease;
}

/* Disable transitions for elements that shouldn't animate */
.sidebar,
.main-content,
.nav-item,
.stat-card,
.chart-card,
.period-button,
.icon-button,
.sidebar-toggle,
.user-profile {
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease,
    transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    width 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* =================================
   UTILITY CLASSES
   ================================= */

/* Grid utilities */
.col-span-full {
  grid-column: 1 / -1;
}

/* Visibility utilities */
.hidden {
  display: none;
}

/* Padding utilities */
.p-4 {
  padding: 1rem;
}

/* =================================
   Typography
   ================================= */

.font-display,
.page-title,
.stat-value,
.chart-title,
.card-title {
  font-family: "Manrope", sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* =================================
   Scrollbar
   ================================= */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-emphasis);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* =================================
   Layout
   ================================= */

.app {
  display: flex;
  min-height: 100vh;
}

/* =================================
   Sidebar
   ================================= */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition:
    width 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar.collapsed-desktop {
  width: var(--sidebar-collapsed-width);
  overflow-x: hidden;
}

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

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar.collapsed-desktop .sidebar-header {
  padding: 1rem 0.5rem;
  flex-direction: column;
  gap: 0.75rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
  text-decoration: none;
  color: var(--brand);
}

.sidebar-toggle {
  width: 2rem;
  height: 2rem;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

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

.sidebar-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar.collapsed-desktop .sidebar-toggle svg {
  transform: rotate(180deg);
}

.logo-full {
  display: block;
  max-width: 100%;
}

.logo-collapsed {
  display: none;
}

.sidebar.collapsed-desktop .logo-full {
  display: none;
}

.sidebar.collapsed-desktop .logo-collapsed {
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed-desktop .sidebar-nav {
  padding: 1rem 0.5rem;
}

.nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.75rem 0;
}

.nav-section-title {
  display: block;
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.sidebar.collapsed-desktop .nav-divider {
  margin: 0.75rem 0.5rem;
}

.sidebar.collapsed-desktop .nav-section-title {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.25rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  white-space: nowrap;
}

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

.nav-item.active {
  background: var(--brand-light);
  color: var(--brand);
}

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

.sidebar.collapsed-desktop .nav-item {
  justify-content: center;
  padding: 0.75rem;
  width: auto;
  margin-left: 0;
  margin-right: 0;
  gap: 0;
}

.sidebar.collapsed-desktop .nav-item span {
  display: none;
}

.sidebar.collapsed-desktop .nav-item.active::before {
  display: none;
}

.sidebar.collapsed-desktop .nav-item.active {
  background: var(--brand-light);
  color: var(--brand);
}

.nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

/* Tooltip for collapsed sidebar */
.sidebar.collapsed-desktop .nav-item::after {
  content: attr(data-tooltip);
  position: fixed;
  left: calc(var(--sidebar-collapsed-width) + 1rem);
  top: var(--tooltip-top, 50%);
  transform: translateY(-50%) translateX(-0.5rem);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease-out,
    transform 0.2s ease-out,
    visibility 0.2s;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
}

.sidebar.collapsed-desktop .nav-item:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-subtle);
  position: relative;
}

.sidebar.collapsed-desktop .sidebar-footer {
  padding: 1rem 0.5rem;
  display: flex;
  justify-content: center;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  transition: all 0.3s;
  cursor: pointer;
  position: relative;
}

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

.sidebar.collapsed-desktop .user-profile {
  justify-content: center;
  padding: 0.5rem;
  gap: 0;
}

.user-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-darker) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
  transition:
    opacity 0.2s,
    width 0.3s;
}

.sidebar.collapsed-desktop .user-info {
  display: none;
}

/* Tooltip for user profile in collapsed state */
.sidebar.collapsed-desktop .user-profile {
  position: relative;
}

.sidebar.collapsed-desktop .user-profile::after {
  content: attr(data-user-name);
  position: fixed;
  left: calc(var(--sidebar-collapsed-width) + 1rem);
  top: var(--user-tooltip-top, 50%);
  transform: translateY(-50%) translateX(-0.5rem);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease-out,
    transform 0.2s ease-out,
    visibility 0.2s;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
}

.sidebar.collapsed-desktop .user-profile:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

/* Hide tooltip when dropdown is open */
.sidebar.collapsed-desktop .user-profile.dropdown-open::after {
  display: none;
}

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

.user-email {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* User Dropdown Icon */
.user-dropdown-icon {
  width: 1rem;
  height: 1rem;
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.user-profile:hover .user-dropdown-icon {
  color: var(--text-secondary);
}

.user-profile.dropdown-open .user-dropdown-icon {
  transform: rotate(180deg);
}

.sidebar.collapsed-desktop .user-dropdown-icon {
  display: none;
}

/* User Dropdown Menu */
.user-dropdown {
  position: absolute;
  bottom: 100%;
  left: 1rem;
  right: 1rem;
  margin-bottom: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  overflow: hidden;
}

.user-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown.collapsed {
  position: fixed;
  left: calc(var(--sidebar-collapsed-width) + 1rem);
  right: auto;
  width: 240px;
  bottom: 1rem;
  margin-bottom: 0;
}

/* Dropdown Header */
.dropdown-header {
  padding: 0.875rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
}

.dropdown-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.dropdown-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dropdown-user-email {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* Dropdown Divider */
.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.25rem 0;
}

/* Dropdown Items */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
}

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

.dropdown-item svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

#logoutForm {
  margin: 0;
}

button.dropdown-item {
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.dropdown-item.logout-item {
  color: #ef4444;
}

.dropdown-item.logout-item:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

[data-theme="light"] .dropdown-item.logout-item:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* =================================
   Main Content
   ================================= */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-primary);
  transition: margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar.collapsed-desktop ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

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

/* =================================
   Header
   ================================= */

.header {
  background: var(--bg-secondary);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .header {
  background-color: rgba(24, 24, 27, 0.8);
}

[data-theme="light"] .header {
  background-color: rgba(255, 255, 255, 0.95);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .header {
    background-color: rgba(24, 24, 27, 0.8);
  }
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .header {
    background-color: rgba(255, 255, 255, 0.95);
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.menu-toggle {
  display: none;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.menu-toggle:hover {
  background: var(--border-default);
  color: var(--text-primary);
}

.menu-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
}

.page-title {
  font-size: 1.875rem;
  margin-bottom: 0.125rem;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.icon-button {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-button:hover {
  background: var(--border-default);
  color: var(--text-primary);
}

.icon-button svg {
  width: 1.125rem;
  height: 1.125rem;
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--brand);
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  min-width: 1.125rem;
  text-align: center;
}

/* Theme Toggle Icons */
.theme-icon-light,
.theme-icon-dark {
  transition: all 0.3s ease;
}

[data-theme="dark"] .theme-icon-light {
  display: none;
}

[data-theme="dark"] .theme-icon-dark {
  display: block;
}

[data-theme="light"] .theme-icon-light {
  display: block;
}

[data-theme="light"] .theme-icon-dark {
  display: none;
}

/* Default to dark icon if no theme set (follows system) */
:root:not([data-theme]) .theme-icon-dark {
  display: block;
}

:root:not([data-theme]) .theme-icon-light {
  display: none;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-icon-dark {
    display: none;
  }

  :root:not([data-theme]) .theme-icon-light {
    display: block;
  }
}

/* =================================
   Period Selector
   ================================= */

.period-selector {
  padding: 2rem 2rem 0;
  display: flex;
  gap: 0.5rem;
  animation: fadeIn 0.4s ease-out;
}

.period-button {
  padding: 0.625rem 1rem;
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.period-button:hover {
  color: var(--text-primary);
  border-color: var(--border-default);
}

.period-button.active {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-darker) 100%);
  border-color: var(--brand);
  color: white;
}

[data-theme="dark"] .period-button.active {
  box-shadow:
    var(--shadow-lg),
    0 0 20px rgba(57, 229, 166, 0.3);
}

[data-theme="light"] .period-button.active {
  box-shadow: var(--shadow-md);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .period-button.active {
    box-shadow:
      var(--shadow-lg),
      0 0 20px rgba(57, 229, 166, 0.3);
  }
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .period-button.active {
    box-shadow: var(--shadow-md);
  }
}

/* =================================
   Stats Grid
   ================================= */

.stats-grid {
  padding: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.stat-card.card-1 {
  animation-delay: 0.1s;
}
.stat-card.card-2 {
  animation-delay: 0.2s;
}
.stat-card.card-3 {
  animation-delay: 0.3s;
}
.stat-card.card-4 {
  animation-delay: 0.4s;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--border-default);
}

.stat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.stat-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.stat-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-value {
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.stat-change {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.change-value {
  font-size: 0.875rem;
  font-weight: 700;
}

.stat-change.positive .change-value {
  color: var(--brand);
}

.stat-change.negative .change-value {
  color: #f87171;
}

.change-label {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

/* =================================
   Charts Row
   ================================= */

.charts-row {
  padding: 0 2rem 2rem;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

.chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.chart-large {
  animation-delay: 0.5s;
}

.chart-card:not(.chart-large) {
  animation-delay: 0.6s;
}

.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.chart-title {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.chart-subtitle {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.chart-legend {
  display: flex;
  gap: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-dot {
  width: 0.75rem;
  height: 0.75rem;
  background: var(--brand);
  border-radius: 50%;
}

.legend-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
}

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

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* =================================
   Bottom Grid
   ================================= */

.bottom-grid {
  padding: 0 2rem 2rem;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

.activity-card,
.products-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: 0.5s;
}

.card-header {
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

/* Activity List */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  transition: background 0.2s;
  animation: fadeIn 0.4s ease-out backwards;
}

.activity-item.item-1 {
  animation-delay: 0.6s;
}
.activity-item.item-2 {
  animation-delay: 0.7s;
}
.activity-item.item-3 {
  animation-delay: 0.8s;
}
.activity-item.item-4 {
  animation-delay: 0.9s;
}

.activity-item:hover {
  background: var(--bg-tertiary);
}

.activity-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-darker) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.activity-description {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Products List */
.products-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.product-item {
  animation: fadeIn 0.4s ease-out backwards;
}

.product-item.item-1 {
  animation-delay: 0.6s;
}
.product-item.item-2 {
  animation-delay: 0.7s;
}
.product-item.item-3 {
  animation-delay: 0.8s;
}
.product-item.item-4 {
  animation-delay: 0.9s;
}

.product-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.product-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.product-sales {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--brand);
}

.progress-bar {
  width: 100%;
  height: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-darker) 100%);
  border-radius: 9999px;
  transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
  width: var(--progress, 0%);
}

/* =================================
   Animations
   ================================= */

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

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

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

/* =================================
   Responsive
   ================================= */

@media (max-width: 1024px) {
  .charts-row,
  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

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

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

  .sidebar.collapsed-desktop {
    width: var(--sidebar-width);
  }

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

  .sidebar.collapsed-desktop ~ .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-toggle {
    display: none;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 1rem 1.5rem;
  }

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

  .period-selector,
  .stats-grid,
  .charts-row,
  .bottom-grid {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .page-subtitle {
    display: none;
  }
}

/* =================================
   Password Requirements
   ================================= */

.password-requirements {
  margin-top: 0.5rem;
  padding-left: 1.25rem;
  list-style: disc;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* =================================
   Utilities
   ================================= */

.hidden {
  display: none;
}

.mt-1 {
  margin-top: 1rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background: rgba(57, 229, 166, 0.15);
  color: var(--brand);
}

.badge-warning {
  background: rgba(251, 191, 36, 0.15);
  color: #d97706;
}

.badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.badge-error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.badge-gray {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Preview */

.empty-state-text {
  margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-darker) 100%);
  color: white;
}

.btn-primary:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: var(--border-default);
}

.btn-secondary[data-variant="danger"] {
  color: var(--state-danger);
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

/* Form Fields */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}

/* Input styles are now in blocks/_inputs.css */

.form-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

/* Checkbox styles are now in blocks/_inputs.css */

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

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

/* =================================
   Modal (base styles)
   ================================= */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.modal-close svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* References Panel (Material de consulta) */
.references-panel {
  margin-bottom: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.references-panel__toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 1rem;
  background: var(--bg-tertiary);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  list-style: none;
}

.references-panel__toggle::-webkit-details-marker {
  display: none;
}

.references-panel__toggle > svg:first-child {
  color: var(--state-info);
}

.references-panel__chevron {
  margin-left: auto;
  transition: transform 0.2s;
  color: var(--text-tertiary);
}

.references-panel[open] .references-panel__chevron {
  transform: rotate(180deg);
}

.references-panel__content {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.reference-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.reference-card__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  list-style: none;
}

.reference-card__header::-webkit-details-marker {
  display: none;
}

.reference-card__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.reference-card__source {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.reference-card__chevron {
  display: flex;
  margin-left: auto;
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
}

.reference-card[open] > .reference-card__header .reference-card__chevron {
  transform: rotate(180deg);
}

.reference-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0 0.75rem 0.75rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.625rem;
}

.reference-card__description {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.reference-card__relevance {
  display: flex;
  align-items: flex-start;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-style: italic;
}

.reference-card__relevance svg {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.reference-card__link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--brand);
  text-decoration: none;
}

.reference-card__link:hover {
  text-decoration: underline;
}

/* =================================
   Dashboard Single Form
   ================================= */

.dashboard-single {
  display: flex;
  justify-content: center;
  padding: 2rem;
  min-height: 60vh;
}

/* Empty State */
.dashboard-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
}

.dashboard-empty .empty-icon {
  color: var(--text-tertiary);
  margin-bottom: 1.5rem;
  opacity: 0.5;
}

.dashboard-empty .empty-title {
  font-family: "Manrope", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.dashboard-empty .empty-desc {
  color: var(--text-secondary);
  max-width: 400px;
  font-size: 0.9375rem;
}

/* Pending & Progress Cards */
.pending-card,
.progress-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 3rem 2rem;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.pending-icon,
.progress-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  background: var(--brand-light);
  color: var(--brand);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.pending-title,
.progress-title {
  font-family: "Manrope", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.pending-desc,
.progress-desc {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 1rem;
}

.pending-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-bottom: 1.5rem;
}

.pending-actions,
.progress-actions {
  margin-top: 0.5rem;
}

.btn-lg {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
}

/* Result Card */
.result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.result-score-circle {
  position: relative;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.result-score-circle::before {
  content: "";
  position: absolute;
  width: 3.5rem;
  height: 3.5rem;
  background: var(--bg-secondary);
  border-radius: 50%;
}

.result-score-value {
  position: relative;
  font-family: "Manrope", sans-serif;
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text-primary);
}

.result-info {
  flex: 1;
}

.result-title {
  font-family: "Manrope", sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.result-meta svg {
  color: var(--brand);
}

.result-summary {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
}

.result-stat {
  display: flex;
  flex-direction: column;
}

.result-stat-value {
  font-family: "Manrope", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.result-stat-label {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.result-topics {
  margin-bottom: 2rem;
}

.result-topics-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.result-topics-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-topic-item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.result-topic-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-topic-name {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.result-topic-score {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.result-topic-bar {
  height: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.result-topic-fill {
  height: 100%;
  background: var(--brand);
  border-radius: var(--radius-sm);
  transition: width 0.5s ease;
}

.result-actions {
  display: flex;
  justify-content: center;
}

/* Dashboard Responsive */
@media (max-width: 768px) {
  .dashboard-single {
    padding: 1rem;
  }

  .pending-card,
  .progress-card,
  .result-card {
    padding: 2rem 1.5rem;
  }

  .result-header {
    flex-direction: column;
    text-align: center;
  }

  .result-summary {
    justify-content: center;
  }
}
