/**
 * Viraloka Portal Design System
 * 
 * Unified styling system for consistent SaaS experience.
 * Token-based, themeable, white-label ready.
 * 
 * Version: 1.0.0
 */

/* ============================================
   1. DESIGN TOKENS (Foundation Layer)
   ============================================ */

:root {
  /* Colors */
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-hover: #334155;
  --color-border: #334155;
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-primary-rgb: 99,102,241;
  --color-accent: #a855f7;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-text: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-text-inverse: #ffffff;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Typography */
  --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-serif: 'Georgia', 'Times New Roman', serif;
  --font-base: 14px;
  --font-sm: 12px;
  --font-md: 16px;
  --font-lg: 18px;
  --font-xl: 24px;
  --font-2xl: 32px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --sidebar-width: 180px;
  --header-height: 65px;
}

/* ============================================
   2. THEMING & WHITE-LABEL
   ============================================ */

/* Brand Override Example */
[data-brand="brandA"] {
  --color-primary: #ff5722;
  --color-primary-hover: #e64a19;
}

[data-brand="brandB"] {
  --color-primary: #9c27b0;
  --color-primary-hover: #7b1fa2;
}

/* Context Override */
[data-context="marketing"] {
  --color-primary: #7c3aed;
  --color-primary-hover: #6d28d9;
}

[data-context="hr"] {
  --color-primary: #0ea5e9;
  --color-primary-hover: #0284c7;
}

[data-context="sales"] {
  --color-primary: #10b981;
  --color-primary-hover: #059669;
}

/* Dark/Light Mode */
[data-theme="light"] {
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-border: #e2e8f0;
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-inverse: #ffffff;
}

/* ============================================
   3. RESET & BASE
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body.viraloka-portal {
  font-family: var(--font-family-sans);
  font-size: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

/* ============================================
   4. LAYOUT SYSTEM
   ============================================ */

.layout {
  display: flex;
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 90;
  overflow: visible;
  transition: left var(--transition-base);
}

.topbar.sidebar-collapsed {
  left: 50px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.topbar-toggle {
  background: transparent;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.topbar-toggle:hover {
  background: var(--color-surface-hover);
}

.topbar-toggle .dashicons {
  font-size: 20px;
  width: 20px;
  height: 20px;
}

.topbar-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--color-text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.topbar-user-name {
  font-size: var(--font-sm);
  font-weight: 500;
}

.topbar-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.topbar-theme-toggle:hover {
  background: var(--color-surface-hover);
}

.topbar-theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.topbar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.topbar-logout:hover {
  background: var(--color-surface-hover);
  color: var(--color-danger);
}

.topbar-logout .dashicons {
  font-size: 20px;
  width: 20px;
  height: 20px;
}

/* User Dropdown */
.topbar-user-dropdown {
  position: relative;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.topbar-user:hover {
  background: var(--color-surface-hover);
}

.user-dropdown-caret {
  font-size: 14px !important;
  width: 14px !important;
  height: 14px !important;
  opacity: 0.6;
  transition: transform var(--transition-fast);
}

.topbar-user[aria-expanded="true"] .user-dropdown-caret {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  overflow: hidden;
}

.user-dropdown-menu.open {
  display: block;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--font-sm);
  transition: background var(--transition-fast);
}

.user-dropdown-item:hover {
  background: var(--color-surface-hover);
}

.user-dropdown-item .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.user-dropdown-item--danger {
  color: var(--color-danger, #e53e3e);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-xs) 0;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 100;
  transition: width var(--transition-base), transform var(--transition-base);
}

.sidebar.collapsed {
  width: 50px;
}

.sidebar.collapsed .sidebar-brand h2,
.sidebar.collapsed .menu-label,
.sidebar.collapsed .submenu-toggle {
  display: none;
}

/* Show labels in submenu when collapsed */
.sidebar.collapsed .submenu .menu-label {
  display: block;
}

.sidebar.collapsed .sidebar-menu-item a {
  justify-content: center;
  padding: var(--space-sm);
}

.sidebar.collapsed .sidebar-menu .dashicons {
  margin-right: 0;
}

/* Show submenu on hover when sidebar is collapsed */
.sidebar.collapsed .sidebar-menu-item.has-children {
  position: relative;
}

/* Tooltip for collapsed menu items without children */
.sidebar.collapsed .sidebar-menu-item:not(.has-children) {
  position: relative;
}

.sidebar.collapsed .sidebar-menu-item:not(.has-children):hover::after {
  content: attr(data-label);
  position: fixed;
  left: 50px;
  top: var(--tooltip-top, 0);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs) var(--space-sm);
  white-space: nowrap;
  z-index: 1000;
  color: var(--color-text);
  font-size: var(--font-sm);
  pointer-events: none;
}

.sidebar.collapsed .sidebar-menu-item.has-children .submenu {
  display: none;
  position: fixed;
  left: 50px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 1000;
  max-height: none;
  overflow: visible;
  padding: var(--space-xs) 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.sidebar.collapsed .sidebar-menu-item.has-children:hover .submenu {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.sidebar.collapsed .sidebar-menu .submenu-item {
  margin: 0;
}

.sidebar.collapsed .sidebar-menu .submenu-item a {
  padding: var(--space-sm) var(--space-md);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.sidebar-brand {
  padding: var(--space-md);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-brand h2 {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand img {
  max-width: 120px;
  max-height: 48px;
  width: auto;
  height: auto;
  display: block;
}

.sidebar-brand-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-top: var(--space-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-md) 0;
}

.sidebar-menu ul {
  list-style: none;
}

.sidebar-menu-item {
  margin: var(--space-xs) var(--space-xs);
}

.sidebar-menu-item a {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.sidebar-menu-item a:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.sidebar-menu-item.active>a {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-weight: 600;
}

/* When parent has active child, show subtle highlight */
.sidebar-menu-item.has-children.active>a {
  background: rgba(99, 102, 241, 0.2);
  color: var(--color-primary);
  font-weight: 600;
}

/* Dashicons support */
.sidebar-menu .dashicons {
  width: 20px;
  height: 20px;
  font-size: 20px;
  margin-right: var(--space-sm);
  flex-shrink: 0;
}

.menu-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Submenu styles */
.sidebar-menu-item.has-children>.menu-item-link {
  font-weight: 600;
}

.sidebar-menu .submenu {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-base);
}

.sidebar-menu-item.has-children.expanded>.submenu {
  max-height: 500px;
}

.sidebar-menu .submenu-item {
  margin: 0;
}

.sidebar-menu .submenu-item a {
  padding: var(--space-xs) var(--space-sm) var(--space-xs) calc(var(--space-sm) + 28px);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

.sidebar-menu .submenu-item a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
}

.sidebar-menu .submenu-item.active a {
  background: rgba(99, 102, 241, 0.15);
  color: var(--color-primary);
  font-weight: 500;
}

.sidebar-menu-icon {
  margin-right: var(--space-sm);
  font-size: var(--font-lg);
}

/* Submenu toggle arrow */
.submenu-toggle {
  margin-left: auto;
  transition: transform var(--transition-fast);
  font-size: 12px;
  cursor: pointer;
  padding: var(--space-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.submenu-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-menu-item.has-children.expanded>a .submenu-toggle {
  transform: rotate(90deg);
}

.sidebar-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: var(--space-lg);
  background: var(--color-bg);
  transition: margin-left var(--transition-base);
  min-height: calc(100vh - var(--header-height));
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  overflow-x: hidden;
}

.content.sidebar-collapsed {
  margin-left: 50px;
}

.content-header {
  display: none;
}

/* ============================================
   5. GRID SYSTEM
   ============================================ */

.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-1 {
  grid-template-columns: repeat(1, 1fr);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* ============================================
   6. COMPONENT SYSTEM
   ============================================ */

/* 6.1 Card */
.p-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.p-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-md);
}

.p-card-header h3 {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.p-card-body {
  color: var(--color-text);
}

.p-card-footer {
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-md);
}

.ga4-behavior-card {
  border-top: 3px solid #F9AB00;
}

.ga4-sync-meta {
  margin-left: auto;
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}

.ga4-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.ga4-kpi-chip {
  background: rgba(249, 171, 0, 0.08);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 100px;
  justify-content: center;
  transition: transform var(--transition-fast) ease;
}

.ga4-kpi-chip:hover {
  transform: translateY(-2px);
}

.ga4-kpi-value {
  font-size: var(--font-xl);
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-text);
}

.ga4-kpi-label {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ga4-kpi-orange {
  background: rgba(249, 171, 0, 0.12);
  border-color: rgba(249, 171, 0, 0.24);
}

.ga4-kpi-green {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.24);
}

.ga4-kpi-blue {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.24);
}

.ga4-kpi-purple {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.24);
}

.ga4-kpi-teal {
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.24);
}

.ga4-section-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-sm) 0;
}

.ga4-section-heading {
  display: block;
  margin-bottom: 12px;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text);
}

.ga4-table {
  width: 100%;
  font-size: var(--font-sm);
  border-collapse: collapse;
}

.ga4-table th,
.ga4-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}

.ga4-table th {
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: left;
}

.ga4-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.06);
}

.ga4-page-link {
  color: var(--color-primary);
  text-decoration: none;
}

.ga4-channel-row {
  margin-bottom: 14px;
}

.ga4-channel-row:last-child {
  margin-bottom: 0;
}

.ga4-channel-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}

.ga4-chart-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.ga4-bar-blue {
  background: #3b82f6;
}

.ga4-bar-green {
  background: #16a34a;
}

.ga4-bar-orange {
  background: #f59e0b;
}

.ga4-bar-purple {
  background: #8b5cf6;
}

.ga4-bar-red {
  background: #ef4444;
}

.ga4-bar-teal {
  background: #14b8a6;
}

.ga4-bar-gray {
  background: #64748b;
}

.ga4-metric-note {
  margin: 0;
  color: var(--color-text-muted);
}

/* 6.2 Button */
.p-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.p-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.p-btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.p-btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.p-btn-success {
  background: var(--color-success);
  color: var(--color-text-inverse);
}

.p-btn-warning {
  background: var(--color-warning);
  color: var(--color-text-inverse);
}

.p-btn-danger {
  background: var(--color-danger);
  color: var(--color-text-inverse);
}

.p-btn-danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
}

.p-btn-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.p-btn-outline:hover:not(:disabled) {
  background: var(--color-surface-hover);
}

.p-btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-sm);
}

.p-btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-md);
}

/* 6.3 Form Input */
.p-input,
.p-select,
.p-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  font-size: var(--font-base);
  transition: border-color var(--transition-fast);
}

.p-input:focus,
.p-select:focus,
.p-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.p-input::placeholder,
.p-textarea::placeholder {
  color: var(--color-text-muted);
}

.p-textarea {
  resize: vertical;
  min-height: 100px;
}

.p-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text);
}

.p-form-group {
  margin-bottom: var(--space-md);
}

.p-form-help {
  display: block;
  margin-top: var(--space-xs);
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}

.p-form-error {
  display: block;
  margin-top: var(--space-xs);
  font-size: var(--font-sm);
  color: var(--color-danger);
}

/* 6.4 Table */
.p-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.p-table thead {
  background: var(--color-surface-hover);
}

.p-table th {
  padding: var(--space-md);
  text-align: left;
  font-weight: 600;
  font-size: var(--font-sm);
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.p-table td {
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
}

.p-table tbody tr:hover {
  background: var(--color-surface-hover);
}

/* 6.5 Badge */
.p-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  font-weight: 500;
}

.p-badge-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.p-badge-success {
  background: var(--color-success);
  color: var(--color-text-inverse);
}

.p-badge-warning {
  background: var(--color-warning);
  color: var(--color-text-inverse);
}

.p-badge-danger {
  background: var(--color-danger);
  color: var(--color-text-inverse);
}

/* 6.6 Alert */
.p-alert {
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: var(--space-md);
}

.p-alert-info {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--color-primary);
  color: var(--color-text);
}

.p-alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--color-success);
  color: var(--color-text);
}

.p-alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--color-warning);
  color: var(--color-text);
}

.p-alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--color-danger);
  color: var(--color-text);
}

/* ============================================
   7. MODAL SYSTEM
   ============================================ */

.p-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.p-modal.active {
  display: flex;
}

.p-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.p-modal-container {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 2;
  animation: modalSlideIn var(--transition-base);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.p-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.p-modal-header h3 {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--color-text);
}

.p-modal-close {
  background: transparent;
  border: none;
  font-size: var(--font-xl);
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.p-modal-close:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.p-modal-body {
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.p-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

/* ============================================
   8. TOAST/NOTIFICATION SYSTEM
   ============================================ */

#portal-toast {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 400px;
}

.p-toast {
  background: var(--color-surface);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  animation: toastSlideIn var(--transition-base);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.p-toast.removing {
  animation: toastSlideOut var(--transition-base);
}

@keyframes toastSlideOut {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.p-toast-info {
  border-color: var(--color-primary);
}

.p-toast-success {
  border-color: var(--color-success);
}

.p-toast-warning {
  border-color: var(--color-warning);
}

.p-toast-danger {
  border-color: var(--color-danger);
}

.p-toast-content {
  flex: 1;
  color: var(--color-text);
}

.p-toast-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  font-size: var(--font-lg);
  line-height: 1;
}

.p-toast-close:hover {
  color: var(--color-text);
}

/* ============================================
   9. UTILITY CLASSES
   ============================================ */

/* Spacing */
.mt-xs {
  margin-top: var(--space-xs);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mb-xs {
  margin-bottom: var(--space-xs);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.ml-xs {
  margin-left: var(--space-xs);
}

.ml-sm {
  margin-left: var(--space-sm);
}

.ml-md {
  margin-left: var(--space-md);
}

.ml-lg {
  margin-left: var(--space-lg);
}

.mr-xs {
  margin-right: var(--space-xs);
}

.mr-sm {
  margin-right: var(--space-sm);
}

.mr-md {
  margin-right: var(--space-md);
}

.mr-lg {
  margin-right: var(--space-lg);
}

.pt-xs {
  padding-top: var(--space-xs);
}

.pt-sm {
  padding-top: var(--space-sm);
}

.pt-md {
  padding-top: var(--space-md);
}

.pt-lg {
  padding-top: var(--space-lg);
}

.pb-xs {
  padding-bottom: var(--space-xs);
}

.pb-sm {
  padding-bottom: var(--space-sm);
}

.pb-md {
  padding-bottom: var(--space-md);
}

.pb-lg {
  padding-bottom: var(--space-lg);
}

/* Text */
.text-left {
  text-align: left;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-primary {
  color: var(--color-primary);
}

.text-success {
  color: var(--color-success);
}

.text-warning {
  color: var(--color-warning);
}

.text-danger {
  color: var(--color-danger);
}

.text-sm {
  font-size: var(--font-sm);
}

.text-base {
  font-size: var(--font-base);
}

.text-md {
  font-size: var(--font-md);
}

.text-lg {
  font-size: var(--font-lg);
}

.text-xl {
  font-size: var(--font-xl);
}

.font-bold {
  font-weight: 600;
}

.font-normal {
  font-weight: 400;
}

/* Display */
.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

.flex {
  display: flex;
}

.inline-flex {
  display: inline-flex;
}

.hidden {
  display: none;
}

/* Flex */
.flex-row {
  flex-direction: row;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.gap-xs {
  gap: var(--space-xs);
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

/* Width */
.w-full {
  width: 100%;
}

.w-auto {
  width: auto;
}

/* ============================================
   10. RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .topbar {
    left: 0;
  }

  .topbar.sidebar-collapsed {
    left: 0;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-base);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
  }

  .content.sidebar-collapsed {
    margin-left: 0;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }
}

/* ============================================
   11. EMPTY STATE
   ============================================ */

.p-empty-state {
  text-align: center;
  padding: var(--space-xl);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.p-empty-state h3 {
  font-size: var(--font-xl);
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.p-empty-state p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

/* ============================================
   11.5 DASHBOARD LAYOUT (ViraSaaS)
   ============================================ */

.virasaas-dashboard {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  width: 100%;
}

.virasaas-dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.virasaas-dashboard-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
  letter-spacing: -0.02em;
}

.virasaas-dashboard-filters {
  display: flex;
  gap: var(--space-md);
}

.virasaas-date-range-filter {
  display: inline-flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 4px;
}

.virasaas-filter-btn {
  padding: 6px 16px;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.virasaas-filter-btn:hover {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.03);
}

.virasaas-filter-btn--active {
  background: var(--color-primary);
  color: #fff !important;
  box-shadow: var(--shadow-sm);
}

.virasaas-dashboard-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: var(--space-lg);
  align-items: stretch;
}

.virasaas-dashboard-widget-cell {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.virasaas-dashboard-widget-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.virasaas-dashboard-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--color-border);
}

/* ============================================
   11.6 WIDGETS (ViraSaaS)
   ============================================ */

.virasaas-widget {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.virasaas-widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.virasaas-widget-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.virasaas-widget-period {
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  background: rgba(0, 0, 0, 0.05);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  text-transform: capitalize;
}

.virasaas-widget-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  flex: 1;
}

.virasaas-widget-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.virasaas-widget-metric:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.virasaas-widget-metric--primary {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
  border-bottom: none;
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-sm);
}

.virasaas-widget-metric--primary .virasaas-widget-metric-label {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.virasaas-widget-metric--primary .virasaas-widget-metric-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.virasaas-widget-metric:not(.virasaas-widget-metric--primary) .virasaas-widget-metric-label {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}

.virasaas-widget-metric:not(.virasaas-widget-metric--primary) .virasaas-widget-metric-value {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--color-text);
}

.virasaas-widget-empty {
  color: var(--color-text-muted);
  font-style: italic;
  font-size: var(--font-sm);
  margin: auto 0;
}

.virasaas-widget-error {
  color: var(--color-danger);
  font-size: var(--font-sm);
  padding: var(--space-md);
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-md);
  text-align: center;
}

.virasaas-upgrade-prompt {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  background: linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.05), rgba(var(--color-primary-rgb), 0.1));
  border-radius: var(--radius-md);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.virasaas-upgrade-prompt strong {
  font-size: var(--font-lg);
  color: var(--color-text);
  margin-bottom: var(--space-sm);
  display: block;
}

.virasaas-upgrade-prompt p {
  color: var(--color-text-muted);
  font-size: var(--font-sm);
  margin-bottom: var(--space-md);
}

.virasaas-upgrade-prompt small {
  font-size: var(--font-xs);
  color: var(--color-text-light);
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ============================================
   12. LOADING STATE
   ============================================ */

.p-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.p-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  color: var(--color-text-muted);
}

/* ============================================
   13. DASHBOARD WIDGETS (Generic & Reusable)
   ============================================ */

/* Base widget wrapper - works for any widget */
.p-card-body>div[class*="widget-"] {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-height: 200px;
}

/* Widget stats grid - auto-adapts to number of stats */
.widget-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-lg);
  flex: 1;
}

/* Individual stat box */
.widget-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
  min-height: 140px;
}

.widget-stat:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

/* Stat value (numbers/metrics) */
.widget-stat .stat-value {
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
  line-height: 1.1;
  word-break: keep-all;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact display for large numbers */
.widget-stat .stat-value[data-large="true"] {
  font-size: clamp(1.25rem, 3.5vw, 2rem);
  letter-spacing: -0.02em;
}

/* Stat label (description) */
.widget-stat .stat-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-top: var(--space-xs);
}

/* Widget action link/button */
.widget-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--font-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  transition: all 0.2s ease;
  margin-top: auto;
}

.widget-link:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--color-primary);
  text-decoration: none;
  transform: translateX(2px);
}

/* Widget content wrapper (for custom layouts) */
.widget-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Widget grid layouts - use these classes for different stat counts */
.widget-stats-2 {
  grid-template-columns: repeat(2, 1fr);
}

.widget-stats-3 {
  grid-template-columns: repeat(3, 1fr);
}

.widget-stats-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .widget-stat .stat-value {
    font-size: clamp(1.25rem, 3.5vw, 2rem);
  }

  .widget-stats-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {

  .widget-stats,
  .widget-stats-3,
  .widget-stats-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .widget-stat {
    min-height: 120px;
  }
}

@media (max-width: 768px) {

  .widget-stats,
  .widget-stats-2,
  .widget-stats-3,
  .widget-stats-4 {
    grid-template-columns: 1fr;
  }

  .widget-stat {
    min-height: 110px;
    padding: var(--space-lg) var(--space-md);
  }

  .widget-stat .stat-value {
    font-size: clamp(1.5rem, 5vw, 2rem);
  }
}


/* ============================================
   14. LOGIN PAGE
   ============================================ */

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: var(--space-lg);
}

.login-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-logo img {
  max-width: 200px;
  height: auto;
  max-height: 60px;
}

.login-logo h1 {
  font-size: var(--font-xl);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-label {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text);
}

.form-input {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--font-base);
  transition: all var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.form-checkbox input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.form-checkbox label {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}

.login-button {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.login-button:hover {
  background: var(--color-primary-hover);
}

.login-error {
  padding: var(--space-sm) var(--space-md);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-sm);
  color: var(--color-danger);
  font-size: var(--font-sm);
}

.login-footer {
  margin-top: var(--space-lg);
  text-align: center;
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}

.login-footer a {
  color: var(--color-primary);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

.login-footer .footer-separator {
  margin: 0 var(--space-sm);
  color: var(--color-text-muted);
}

.login-success {
  padding: var(--space-sm) var(--space-md);
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid var(--color-success);
  border-radius: var(--radius-sm);
  color: var(--color-success);
  font-size: var(--font-sm);
  margin-bottom: var(--space-md);
}

/* ============================================
   15. ADDITIONAL BADGE VARIANTS
   ============================================ */

.p-badge-secondary {
  background: var(--color-surface-hover);
  color: var(--color-text-muted);
}

.p-badge-info {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

/* ============================================
   16. CARD ACTION LINKS
   ============================================ */

.p-card-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.p-card-action:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.p-card-action h4 {
  font-size: var(--font-md);
  font-weight: 600;
  margin: var(--space-sm) 0;
  color: var(--color-text);
}

.p-card-action p {
  margin: 0;
}

/* ============================================
   18. INVOICE BUILDER MODULE
   ============================================
   vir-* utility layer (used by IB templates)
   + ib-* component classes.
   All values use portal design tokens.
   ============================================ */

/* ── 18.1  vir-* Layout utilities ── */
.vir-flex {
  display: flex;
}

.vir-inline-flex {
  display: inline-flex;
}

.vir-grid {
  display: grid;
}

.vir-block {
  display: block;
}

.vir-hidden {
  display: none;
}

.vir-flex-col {
  flex-direction: column;
}

.vir-flex-row {
  flex-direction: row;
}

.vir-flex-wrap {
  flex-wrap: wrap;
}

.vir-items-center {
  align-items: center;
}

.vir-items-start {
  align-items: flex-start;
}

.vir-items-end {
  align-items: flex-end;
}

.vir-justify-between {
  justify-content: space-between;
}

.vir-justify-end {
  justify-content: flex-end;
}

.vir-justify-center {
  justify-content: center;
}

.vir-gap-1 {
  gap: 4px;
}

.vir-gap-2 {
  gap: var(--space-sm);
}

.vir-gap-3 {
  gap: 12px;
}

.vir-gap-4 {
  gap: var(--space-md);
}

.vir-gap-6 {
  gap: var(--space-lg);
}

.vir-gap-8 {
  gap: var(--space-xl);
}

.vir-w-full {
  width: 100%;
}

.vir-min-w-full {
  min-width: 100%;
}

.vir-overflow-x-auto {
  overflow-x: auto;
}

.vir-overflow-hidden {
  overflow: hidden;
}

.vir-whitespace-nowrap {
  white-space: nowrap;
}

/* ── 18.2  vir-* Spacing ── */
.vir-p-1 {
  padding: 4px;
}

.vir-p-2 {
  padding: var(--space-sm);
}

.vir-p-3 {
  padding: 12px;
}

.vir-p-4 {
  padding: var(--space-md);
}

.vir-p-5 {
  padding: 20px;
}

.vir-p-6 {
  padding: var(--space-lg);
}

.vir-p-8 {
  padding: var(--space-xl);
}

.vir-px-2 {
  padding-left: var(--space-sm);
  padding-right: var(--space-sm);
}

.vir-px-3 {
  padding-left: 12px;
  padding-right: 12px;
}

.vir-px-4 {
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

.vir-px-6 {
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

.vir-py-1 {
  padding-top: 4px;
  padding-bottom: 4px;
}

.vir-py-2 {
  padding-top: var(--space-sm);
  padding-bottom: var(--space-sm);
}

.vir-py-3 {
  padding-top: 12px;
  padding-bottom: 12px;
}

.vir-py-4 {
  padding-top: var(--space-md);
  padding-bottom: var(--space-md);
}

.vir-mt-1 {
  margin-top: 4px;
}

.vir-mt-2 {
  margin-top: var(--space-sm);
}

.vir-mt-4 {
  margin-top: var(--space-md);
}

.vir-mt-6 {
  margin-top: var(--space-lg);
}

.vir-mb-1 {
  margin-bottom: 4px;
}

.vir-mb-2 {
  margin-bottom: var(--space-sm);
}

.vir-mb-3 {
  margin-bottom: 12px;
}

.vir-mb-4 {
  margin-bottom: var(--space-md);
}

.vir-mb-6 {
  margin-bottom: var(--space-lg);
}

.vir-mb-8 {
  margin-bottom: var(--space-xl);
}

.vir-mr-1 {
  margin-right: 4px;
}

.vir-mr-2 {
  margin-right: var(--space-sm);
}

.vir-ml-auto {
  margin-left: auto;
}

/* ── 18.3  vir-* Grid ── */
.vir-grid-cols-1 {
  grid-template-columns: repeat(1, 1fr);
}

.vir-grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.vir-grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.vir-grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* ── 18.4  vir-* Typography ── */
.vir-text-xs {
  font-size: var(--font-sm);
}

.vir-text-sm {
  font-size: var(--font-sm);
}

.vir-text-base {
  font-size: var(--font-base);
}

.vir-text-lg {
  font-size: var(--font-lg);
}

.vir-text-xl {
  font-size: var(--font-xl);
}

.vir-text-2xl {
  font-size: var(--font-2xl);
}

.vir-text-3xl {
  font-size: 2rem;
}

.vir-font-medium {
  font-weight: 500;
}

.vir-font-semibold {
  font-weight: 600;
}

.vir-font-bold {
  font-weight: 700;
}

.vir-font-extrabold {
  font-weight: 800;
}

.vir-leading-5 {
  line-height: 1.25rem;
}

.vir-tracking-wider {
  letter-spacing: 0.05em;
}

.vir-uppercase {
  text-transform: uppercase;
}

.vir-text-left {
  text-align: left;
}

.vir-text-right {
  text-align: right;
}

.vir-text-center {
  text-align: center;
}

/* Colour aliases -> portal tokens */
.vir-text-gray-400 {
  color: var(--color-text-muted);
}

.vir-text-gray-500 {
  color: var(--color-text-muted);
}

.vir-text-gray-700 {
  color: var(--color-text);
}

.vir-text-gray-800 {
  color: var(--color-text);
}

.vir-text-gray-900 {
  color: var(--color-text);
}

.vir-text-blue-600 {
  color: #60a5fa;
}

.vir-text-blue-800 {
  color: #3b82f6;
}

.vir-text-blue-900 {
  color: #2563eb;
}

.vir-text-green-600 {
  color: var(--color-success);
}

.vir-text-green-800 {
  color: #16a34a;
}

.vir-text-yellow-600 {
  color: var(--color-warning);
}

.vir-text-yellow-800 {
  color: #d97706;
}

.vir-text-red-600 {
  color: var(--color-danger);
}

.vir-text-red-800 {
  color: #dc2626;
}

.vir-text-purple-600 {
  color: #a855f7;
}

.vir-text-purple-800 {
  color: #9333ea;
}

.vir-text-indigo-600 {
  color: var(--color-primary);
}

.vir-text-white {
  color: #fff;
}

/* Background aliases */
.vir-bg-white {
  background: var(--color-surface);
}

.vir-bg-gray-50 {
  background: var(--color-surface-hover);
}

.vir-bg-gray-100 {
  background: rgba(148, 163, 184, .15);
}

.vir-bg-blue-100 {
  background: rgba(96, 165, 250, .15);
}

.vir-bg-green-100 {
  background: rgba(34, 197, 94, .15);
}

.vir-bg-yellow-100 {
  background: rgba(245, 158, 11, .15);
}

.vir-bg-red-100 {
  background: rgba(239, 68, 68, .15);
}

.vir-bg-purple-100 {
  background: rgba(168, 85, 247, .15);
}

.vir-bg-indigo-600 {
  background: var(--color-primary);
}

/* Border aliases */
.vir-border {
  border: 1px solid var(--color-border);
}

.vir-border-b {
  border-bottom: 1px solid var(--color-border);
}

.vir-border-t {
  border-top: 1px solid var(--color-border);
}

.vir-border-gray-200 {
  border-color: var(--color-border);
}

.vir-border-red-200 {
  border-color: rgba(239, 68, 68, .35);
}

.vir-divide-y>*+* {
  border-top: 1px solid var(--color-border);
}

.vir-divide-gray-200>*+* {
  border-top-color: var(--color-border);
}

/* Radius */
.vir-rounded {
  border-radius: var(--radius-sm);
}

.vir-rounded-lg {
  border-radius: var(--radius-md);
}

.vir-rounded-xl {
  border-radius: var(--radius-lg);
}

.vir-rounded-full {
  border-radius: 9999px;
}

/* Shadow */
.vir-shadow-sm {
  box-shadow: var(--shadow-sm);
}

.vir-shadow {
  box-shadow: var(--shadow-md);
}

.vir-shadow-lg {
  box-shadow: var(--shadow-lg);
}

/* ── 18.5  vir-* Button & Form ── */
.vir-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
}

.vir-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.vir-btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.vir-btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: #fff;
}

.vir-btn-success {
  background: var(--color-success);
  color: #fff;
}

.vir-btn-success:hover:not(:disabled) {
  filter: brightness(1.1);
}

.vir-btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}

.vir-btn-danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
  color: #fff;
}

.vir-btn-outline {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}

.vir-btn-outline:hover:not(:disabled) {
  background: var(--color-surface-hover);
  border-color: var(--color-primary);
}

.vir-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-muted);
}

.vir-btn-ghost:hover:not(:disabled) {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.vir-btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-sm);
}

.vir-btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-md);
}

/* Form elements */
.vir-form-input,
.vir-form-select,
.vir-form-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--font-base);
  font-family: var(--font-family-sans);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.vir-form-input:focus,
.vir-form-select:focus,
.vir-form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

.vir-form-input::placeholder,
.vir-form-textarea::placeholder {
  color: var(--color-text-muted);
}

.vir-form-textarea {
  resize: vertical;
  min-height: 90px;
}

.vir-form-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text);
}

.vir-form-group {
  margin-bottom: var(--space-md);
}

/* ── 18.6  ib-* Page layout ── */
.ib-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.ib-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.ib-page-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
  letter-spacing: -.02em;
}

.ib-page-subtitle {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  margin: 2px 0 0;
}

.ib-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ── 18.7  ib-* Stat cards ── */
.ib-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
}

.ib-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.ib-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.ib-stat-label {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: var(--space-xs);
}

.ib-stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
  letter-spacing: -.03em;
}

.ib-stat-value--success {
  color: var(--color-success);
}

.ib-stat-value--warning {
  color: var(--color-warning);
}

.ib-stat-value--danger {
  color: var(--color-danger);
}

.ib-stat-meta {
  margin-top: var(--space-xs);
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}

/* ── 18.8  ib-* Status badges ── */
.ib-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: var(--font-sm);
  font-weight: 600;
  white-space: nowrap;
}

.ib-badge--draft {
  background: rgba(148, 163, 184, .2);
  color: var(--color-text-muted);
}

.ib-badge--sent {
  background: rgba(96, 165, 250, .15);
  color: #60a5fa;
}

.ib-badge--viewed {
  background: rgba(168, 85, 247, .15);
  color: #c084fc;
}

.ib-badge--paid {
  background: rgba(34, 197, 94, .15);
  color: var(--color-success);
}

.ib-badge--overdue {
  background: rgba(239, 68, 68, .15);
  color: var(--color-danger);
}

.ib-badge--cancelled {
  background: rgba(239, 68, 68, .1);
  color: var(--color-danger);
  opacity: .75;
}

.ib-badge--partially-paid {
  background: rgba(245, 158, 11, .15);
  color: var(--color-warning);
}

/* ── 18.9  ib-* Filter bar ── */
.ib-filter-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-md);
}

.ib-filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 140px;
}

.ib-filter-label {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text-muted);
}

/* ── 18.10  ib-* Data table ── */
.ib-table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ib-table {
  width: 100%;
  border-collapse: collapse;
}

.ib-table thead {
  background: var(--color-surface-hover);
}

.ib-table th {
  padding: var(--space-md);
  text-align: left;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

.ib-table td {
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

.ib-table tbody tr {
  transition: background var(--transition-fast);
}

.ib-table tbody tr:hover {
  background: var(--color-surface-hover);
}

.ib-table-link {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.ib-table-link:hover {
  color: var(--color-primary);
}

.ib-table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.ib-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.ib-icon-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.ib-icon-btn--danger:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* ── 18.11  ib-* Invoice detail ── */
.ib-invoice-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.ib-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ib-meta-label {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.ib-meta-value {
  font-size: var(--font-base);
  color: var(--color-text);
  font-weight: 500;
}

.ib-meta-value--large {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--color-text);
}

.ib-totals {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  border-top: 2px solid var(--color-border);
  padding-top: var(--space-md);
  margin-top: var(--space-md);
}

.ib-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-base);
  color: var(--color-text-muted);
}

.ib-totals-row--total {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--color-text);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-sm);
  margin-top: var(--space-xs);
}

.ib-totals-row--balance {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--color-warning);
}

.ib-totals-row--paid {
  color: var(--color-success);
}

/* ── 18.12  ib-* Invoice form ── */
.ib-form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.ib-form-section-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.ib-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-sm);
}

.ib-items-table th {
  padding: var(--space-sm);
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.ib-items-table td {
  padding: var(--space-sm);
  vertical-align: middle;
}

.ib-items-table tr.ib-item-row:hover {
  background: var(--color-surface-hover);
}

.ib-item-subtotal {
  font-weight: 600;
  color: var(--color-text);
  text-align: right;
}

.ib-add-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-primary);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: var(--space-xs) 0;
  transition: opacity var(--transition-fast);
}

.ib-add-item:hover {
  opacity: .75;
}

/* ── 18.13  ib-* Toolbar ── */
.ib-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.ib-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 var(--space-xs);
}

/* ── 18.14  ib-* Empty state ── */
.ib-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-xl);
  gap: var(--space-md);
  color: var(--color-text-muted);
}

.ib-empty-icon {
  font-size: 48px;
  width: 48px;
  height: 48px;
  display: block;
  opacity: .4;
}

.ib-empty h3 {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.ib-empty p {
  margin: 0;
  font-size: var(--font-sm);
}

/* ── 18.15  ib-* Flash messages ── */
.ib-flash {
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  font-size: var(--font-base);
  animation: ib-flash-in .25s ease;
}

@keyframes ib-flash-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ib-flash--success {
  background: rgba(34, 197, 94, .1);
  border-color: var(--color-success);
  color: var(--color-success);
}

.ib-flash--error {
  background: rgba(239, 68, 68, .1);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.ib-flash--info {
  background: rgba(99, 102, 241, .1);
  border-color: var(--color-primary);
  color: var(--color-text);
}

/* ── 18.16  Responsive ── */
@media (max-width: 768px) {
  .ib-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .ib-invoice-meta {
    grid-template-columns: 1fr;
  }

  .ib-page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .ib-filter-bar {
    flex-direction: column;
  }

  .vir-grid-cols-2,
  .vir-grid-cols-3,
  .vir-grid-cols-4 {
    grid-template-columns: 1fr;
  }

  .ib-table th:nth-child(n+4),
  .ib-table td:nth-child(n+4) {
    display: none;
  }
}

@media (max-width: 480px) {
  .ib-stats-grid {
    grid-template-columns: 1fr;
  }

  .ib-actions {
    width: 100%;
  }

  .ib-actions .vir-btn {
    flex: 1;
    justify-content: center;
  }
}

/* hover: aliases used in templates */
.hover\:vir-text-blue-900:hover {
  color: #2563eb;
}

.hover\:vir-text-blue-600:hover {
  color: #60a5fa;
}

.hover\:vir-underline:hover {
  text-decoration: underline;
}

/* ============================================
   17. SOCIAL LOGIN BUTTONS
   ============================================ */

.social-login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--color-text-muted);
  font-size: var(--font-sm);
}

.social-login-divider::before,
.social-login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.social-login-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}

.social-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

.social-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}



/* ============================================
   17. Billing Tabs
   ============================================ */

.virasaas-billing-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-lg);
}

.virasaas-billing-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--font-sm);
  font-weight: 500;
  border: 2px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
}

.virasaas-billing-tab:hover {
  color: var(--color-primary);
  background: var(--color-surface-hover);
}

.virasaas-billing-tab.active {
  color: var(--color-primary);
  border-color: var(--color-border);
  border-bottom-color: var(--color-bg);
  background: var(--color-bg);
}

.virasaas-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.virasaas-plan-card {
  display: flex;
  flex-direction: column;
}

.virasaas-plan-card .p-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ============================================
   19. NULIS MODULE
   ============================================ */

.nulis-templates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding-top: 4px;
}

@media (max-width: 1024px) {
  .nulis-templates-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .nulis-templates-grid {
    grid-template-columns: 1fr;
  }
}

/* Credit Balance Circle */
.topbar-credits {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: var(--space-sm);
  cursor: pointer;
  z-index: 1001;
}

.credits-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  transition: all var(--transition-base);
  border: 2px solid var(--color-primary);
}

.topbar-credits:hover .credits-circle,
.topbar-credits.active .credits-circle {
  transform: scale(1.05);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-md);
}

.credits-hover-detail {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 12px;
  width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 1000;
  flex-direction: column;
  gap: var(--space-xs);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.topbar-credits.active .credits-hover-detail,
.topbar-credits:hover .credits-hover-detail {
  display: flex;
}

.hover-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-sm);
  padding: 4px 0;
}

.hover-label {
  color: var(--color-text-muted);
  font-weight: 500;
}

.hover-value {
  color: var(--color-text);
  font-weight: 600;
}

.refill-btn {
  margin-top: var(--space-sm);
  width: 100%;
  text-align: center;
}

/* ============================================
   20. DASHBOARD — Chart Card & Widget Grid
   ============================================ */

/* Chart card — frameless, full-bleed feel */
.vp-chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  margin-bottom: var(--space-xl);
  /* gap between chart and first widget row */
}

.vp-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-md);
}

.vp-chart-title {
  display: block;
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -.02em;
}

.vp-chart-subtitle {
  display: block;
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.vp-chart-workspace {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  background: var(--color-surface-hover);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
}

.vp-chart-body {
  position: relative;
  height: 240px;
}

.vp-line-chart {
  width: 100%;
  height: 100%;
}

.vp-line-chart svg {
  width: 100%;
  height: 100%;
}

/* Widget section — gap between chart and rows, and between rows */
.vp-widgets-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  /* gap between widget rows */
}

.vp-widget-row {
  display: grid;
  gap: var(--space-lg);
  /* gap between cards within a row */
}

.vp-widget-cell {
  min-height: 0;
}

@media (max-width: 900px) {
  .vp-widget-row {
    grid-template-columns: 1fr !important;
  }
}

/* KPI pills in chart header */
.vp-kpi-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  background: var(--color-surface-hover);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.vp-kpi-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--kpi-color, var(--color-primary));
  flex-shrink: 0;
}

.vp-kpi-pill strong {
  color: var(--color-text);
  font-weight: 700;
}

/* ============================================
   21. ANALYTICS KPI CARDS
   ============================================ */

.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.analytics-kpi-card {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.analytics-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.analytics-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .analytics-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .analytics-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.sh-scan-wrap {
  max-width: 580px;
  margin: 0 auto;
  padding: 48px 20px 64px;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #111827;
  background: #ffffff;
}

/* Typography */
.sh-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6b7280;
  margin: 0 0 12px;
}

.sh-headline {
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  color: #0f172a;
}

.sh-headline--result {
  font-size: clamp(22px, 4vw, 32px);
}

.sh-sub {
  font-size: 16px;
  color: #6b7280;
  margin: 0 0 32px;
  line-height: 1.6;
}

.sh-hint {
  font-size: 12px;
  color: #9ca3af;
  margin: 12px 0 0;
}

/* Search Box */
.sh-search-box {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  padding: 6px 6px 6px 16px;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sh-search-box:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sh-search-icon {
  color: #9ca3af;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.sh-search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  color: #111827;
  background: transparent;
  min-width: 0;
  padding: 8px 0;
}

.sh-search-input::placeholder {
  color: #9ca3af;
}

.sh-start-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.sh-start-btn:hover {
  background: #1d4ed8;
}

.sh-start-btn:active {
  transform: scale(0.97);
}

.sh-error {
  color: #dc2626;
  font-size: 13px;
  margin: 10px 0 0;
}

/* Progress */
.sh-progress-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sh-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #2563eb;
  opacity: 0.3;
  animation: sh-pulse 1.4s ease-out infinite;
}

@keyframes sh-pulse {
  0% {
    transform: scale(0.85);
    opacity: 0.4;
  }

  70% {
    transform: scale(1.2);
    opacity: 0;
  }

  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

.sh-progress-icon {
  flex-shrink: 0;
}

.sh-progress-msg {
  font-size: 17px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 20px;
}

.sh-bar-track {
  background: #e5e7eb;
  border-radius: 99px;
  height: 4px;
  overflow: hidden;
  max-width: 280px;
  margin: 0 auto 12px;
}

.sh-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 99px;
  width: 0;
  transition: width 0.35s ease;
}

.sh-progress-domain {
  font-size: 13px;
  color: #9ca3af;
  margin: 0;
}

/* Result */
.sh-result-domain {
  font-size: 15px;
  color: #6b7280;
  margin: 0 0 32px;
  font-weight: 500;
}

/* Score Cards */
.sh-scores {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.sh-score-card {
  flex: 1;
  min-width: 120px;
  max-width: 160px;
  background: #ffffff;
  border: 1.5px solid #f1f5f9;
  border-radius: 16px;
  padding: 20px 12px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.sh-ring-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sh-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.sh-ring-bg {
  fill: none;
  stroke: #f1f5f9;
  stroke-width: 7;
}

.sh-ring-fg {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 201;
  stroke-dashoffset: 201;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s;
}

.sh-ring-val {
  position: relative;
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  z-index: 1;
}

.sh-score-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Issues Card */
.sh-issues-card {
  background: #ffffff;
  border: 1.5px solid #fde68a;
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 24px;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sh-issues-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 14px;
}

.sh-issues-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sh-issues-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: #374151;
  line-height: 1.5;
}

.sh-issue-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  margin-top: 6px;
}

/* CTA Card */
.sh-cta-card {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #4f46e5 100%);
  border-radius: 20px;
  padding: 32px 28px;
  margin-bottom: 24px;
  color: #ffffff;
}

.sh-cta-headline {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.sh-cta-body {
  font-size: 14px;
  opacity: 0.85;
  margin: 0 0 24px;
  line-height: 1.6;
  color: #ffffff;
}

.sh-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 28px;
  background: #ffffff;
  color: #1e40af;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.sh-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  color: #1e40af;
  text-decoration: none;
}

.sh-cta-note {
  font-size: 12px;
  opacity: 0.65;
  margin: 14px 0 0;
  color: #ffffff;
}

/* Rescan Button */
.sh-rescan {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
}

.sh-rescan:hover {
  color: #111827;
}

/* Steps visibility - using higher specificity to override inline styles */
.sh-step {
  display: none !important;
}

#sitehub-scan-app .sh-step.sh-active,
#sitehub-scan-app .sh-step[style*="display: block"] {
  display: block !important;
}