/* ==========================================================================
   Lead Management System - Apple Premium Design System
   Using Inter font (loaded via Google Fonts in layout templates)
   ========================================================================== */

/* ==========================================================================
   1. CSS Custom Properties / Theming
   ========================================================================== */

:root {
    /* Primary palette - overridable per tenant */
    --primary: #0071E3;
    --primary-hover: #0077ED;
    --primary-light: rgba(0, 113, 227, 0.10);
    --primary-ring: rgba(0, 113, 227, 0.30);

    --secondary: #86868B;
    --secondary-hover: #6E6E73;

    --accent: #FF375F;
    --accent-light: rgba(255, 55, 95, 0.10);

    /* Neutrals */
    --white: #FFFFFF;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F7;
    --bg-tertiary: #FBFBFD;
    --border: #E5E5EA;
    --border-light: #F0F0F2;
    --text-primary: #1D1D1F;
    --text-secondary: #6E6E73;
    --text-tertiary: #86868B;
    --text-placeholder: #AEAEB2;

    /* Semantic colors */
    --success: #30D158;
    --success-bg: rgba(48, 209, 88, 0.10);
    --warning: #FF9F0A;
    --warning-bg: rgba(255, 159, 10, 0.10);
    --danger: #FF3B30;
    --danger-bg: rgba(255, 59, 48, 0.10);
    --info: #0071E3;
    --info-bg: rgba(0, 113, 227, 0.10);

    /* Shadows */
    --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.10);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --content-max-width: 1200px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Z-index scale */
    --z-sidebar: 100;
    --z-header: 200;
    --z-modal-backdrop: 300;
    --z-modal: 400;
    --z-toast: 500;
    --z-tooltip: 600;
}

/* ==========================================================================
   2. Reset & Base
   ========================================================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   3. Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.5rem;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.0625rem;
}

h5 {
    font-size: 0.9375rem;
}

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

.text-sm {
    font-size: 0.8125rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-lg {
    font-size: 1.0625rem;
}

.text-muted {
    color: var(--text-secondary);
}

.text-caption {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    letter-spacing: 0.01em;
}

/* ==========================================================================
   4. Layout - Sidebar + Main
   ========================================================================== */

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

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: transform var(--transition-slow);
    overflow-y: auto;
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding-top: var(--space-xl);
    padding-bottom: var(--space-xl);
}

.sidebar-header img {
    max-height: 72px;
    max-width: 200px;
    width: auto;
    object-fit: contain;
}

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

.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
}

.sidebar-nav .nav-section {
    margin-bottom: var(--space-lg);
}

.sidebar-nav .nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-base);
    cursor: pointer;
}

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

.sidebar-nav .nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

.sidebar-nav .nav-link .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav .nav-link.active .nav-icon {
    opacity: 1;
}

.sidebar-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-light);
}

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

/* Top header bar */
.top-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    z-index: var(--z-header);
}

.page-content {
    flex: 1;
    padding: var(--space-xl);
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.page-header h1 {
    margin: 0;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    padding: var(--space-sm);
    cursor: pointer;
    color: var(--text-primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: calc(var(--z-sidebar) - 1);
    backdrop-filter: blur(4px);
}

/* ==========================================================================
   5. Cards
   ========================================================================== */

.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

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

.card-glass {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

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

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-light);
    background: var(--bg-tertiary);
}

/* ==========================================================================
   6. Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}

.btn:focus-visible {
    outline: 3px solid var(--primary-ring);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    color: var(--white);
}

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

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

.btn-secondary:hover {
    background: var(--border-light);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #E0342B;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    color: var(--white);
}

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

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

.btn-icon {
    padding: 10px;
    border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
    padding: 6px;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-group {
    display: inline-flex;
    gap: var(--space-sm);
}

/* ==========================================================================
   7. Form Inputs
   ========================================================================== */

.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    appearance: none;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--secondary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

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

.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-bg);
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: var(--space-xs);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868B' d='M6 8.825a.7.7 0 0 1-.5-.2L1.675 4.8a.7.7 0 0 1 1-1L6 7.125 9.325 3.8a.7.7 0 0 1 1 1L6.5 8.625a.7.7 0 0 1-.5.2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}

/* Search input with icon */
.search-input-wrapper {
    position: relative;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input-wrapper .form-input {
    padding-left: 40px;
}

/* Color picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.color-picker-input {
    width: 48px;
    height: 48px;
    padding: 4px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: none;
    transition: border-color var(--transition-base);
}

.color-picker-input:hover {
    border-color: var(--secondary);
}

.color-picker-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.color-preview {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ==========================================================================
   8. Tables
   ========================================================================== */

.table-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    gap: var(--space-md);
    flex-wrap: wrap;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

tbody td {
    padding: var(--space-md) var(--space-lg);
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--bg-secondary);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr[data-href] {
    cursor: pointer;
}

.table-empty {
    padding: var(--space-3xl) var(--space-lg);
    text-align: center;
    color: var(--text-tertiary);
}

/* ==========================================================================
   9. Badges / Status Pills
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
    line-height: 1.4;
}

.badge-new,
.badge-blue {
    background: var(--info-bg);
    color: var(--info);
}

.badge-contacted,
.badge-orange {
    background: var(--warning-bg);
    color: #CC7F08;
}

.badge-qualified,
.badge-purple {
    background: rgba(175, 82, 222, 0.10);
    color: #AF52DE;
}

.badge-converted,
.badge-green {
    background: var(--success-bg);
    color: #248A3D;
}

.badge-lost,
.badge-red {
    background: var(--danger-bg);
    color: var(--danger);
}

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

/* ==========================================================================
   10. Dashboard Stat Cards
   ========================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    padding: var(--space-lg);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
    font-weight: 500;
}

.stat-change {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: var(--space-sm);
}

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

.stat-change.negative {
    color: var(--danger);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

/* ==========================================================================
   10b. Impersonation Banner
   ========================================================================== */

.impersonate-banner {
    background: linear-gradient(135deg, #FF9500, #FF6B00);
    color: #fff;
    padding: 8px 16px;
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.impersonate-banner + .app-layout {
    margin-top: 40px;
}

.impersonate-banner + .app-layout .sidebar {
    top: 40px;
    height: calc(100vh - 40px);
}

.impersonate-banner + .app-layout .top-header {
    top: 40px;
}

/* ==========================================================================
   11. Login Page
   ========================================================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #E8E8ED 50%, var(--bg-secondary) 100%);
    padding: var(--space-lg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--space-2xl);
    animation: slideUp 0.4s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-logo img {
    height: 40px;
    margin: 0 auto;
}

.login-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: var(--space-xl);
}

.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    margin-top: var(--space-sm);
}

.login-footer {
    text-align: center;
    margin-top: var(--space-lg);
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

/* ==========================================================================
   12. Modals
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    animation: fadeIn 0.2s ease;
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-lg) 0;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-base);
    font-size: 1.125rem;
    line-height: 1;
}

.modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: 0 var(--space-lg) var(--space-lg);
}

/* ==========================================================================
   13. Toast / Flash Notifications
   ========================================================================== */

.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 300px;
    max-width: 420px;
    pointer-events: auto;
    animation: slideIn 0.3s ease;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-message {
    flex: 1;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
    transition: color var(--transition-base);
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast.dismissing {
    animation: slideOut 0.3s ease forwards;
}

/* Flash messages (inline, page-level) */
.flash-message {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-size: 0.875rem;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.flash-success {
    background: var(--success-bg);
    color: #248A3D;
    border: 1px solid rgba(48, 209, 88, 0.2);
}

.flash-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.flash-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(0, 113, 227, 0.2);
}

.flash-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    font-size: 1.125rem;
    transition: opacity var(--transition-base);
}

.flash-dismiss:hover {
    opacity: 1;
}

/* ==========================================================================
   14. Pagination
   ========================================================================== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-lg) 0;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 var(--space-sm);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

.pagination a:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--primary);
    color: var(--white);
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pagination .dots {
    color: var(--text-tertiary);
    pointer-events: none;
}

/* ==========================================================================
   15. File Upload Dropzone
   ========================================================================== */

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-tertiary);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-md);
    color: var(--text-tertiary);
}

.dropzone-text {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.dropzone-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

.dropzone-preview {
    margin-top: var(--space-md);
}

.dropzone-preview img {
    max-height: 120px;
    margin: 0 auto;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   16. Avatar / Initials Circle
   ========================================================================== */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--primary-light);
    color: var(--primary);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.avatar-md {
    width: 40px;
    height: 40px;
    font-size: 0.8125rem;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1rem;
}

/* ==========================================================================
   17. Empty State
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-xl);
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-lg);
    color: var(--text-tertiary);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.empty-state-text {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    max-width: 360px;
    margin: 0 auto var(--space-lg);
}

/* ==========================================================================
   18. Dropdown
   ========================================================================== */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    padding: var(--space-xs);
    z-index: 50;
    display: none;
    animation: fadeIn 0.15s ease;
}

.dropdown-menu.active {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    cursor: pointer;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    font-family: inherit;
}

.dropdown-item:hover {
    background: var(--bg-secondary);
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background: var(--danger-bg);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-xs) 0;
}

/* ==========================================================================
   19. Utility Classes
   ========================================================================== */

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.gap-lg {
    gap: var(--space-lg);
}

.mt-sm {
    margin-top: var(--space-sm);
}

.mt-md {
    margin-top: var(--space-md);
}

.mt-lg {
    margin-top: var(--space-lg);
}

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

.w-full {
    width: 100%;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ==========================================================================
   20. Scrollbar Styling
   ========================================================================== */

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* ==========================================================================
   21. Animations
   ========================================================================== */

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

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

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

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

/* ==========================================================================
   22. Responsive
   ========================================================================== */

@media (max-width: 1024px) {
    .page-content {
        padding: var(--space-lg);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

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

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

    .sidebar-toggle {
        display: flex;
    }

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

    .page-content {
        padding: var(--space-md);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header-actions {
        width: 100%;
    }

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

    .table-container {
        border-radius: var(--radius-md);
    }

    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    thead th,
    tbody td {
        padding: var(--space-sm) var(--space-md);
    }

    .toast-container {
        top: var(--space-md);
        right: var(--space-md);
        left: var(--space-md);
    }

    .toast {
        min-width: unset;
        width: 100%;
    }

    .modal {
        margin: var(--space-md);
        max-width: calc(100% - var(--space-xl));
    }

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

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .login-card {
        padding: var(--space-xl);
    }

    .stat-value {
        font-size: 1.5rem;
    }
}
