/* ============================================================
   GestImmo — Global Stylesheet (Phase 3A)
   Design: Professional property-management aesthetic
   Palette: Deep slate + warm amber accents
   ============================================================ */

/* --- Google Fonts (self-hosted fallback via system stack) --- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================================
   1. CSS Custom Properties (Design Tokens)
   ============================================================ */
:root {
    /* --- Typography --- */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;

    --text-xs:   0.75rem;    /* 12px */
    --text-sm:   0.8125rem;  /* 13px */
    --text-base: 0.9375rem;  /* 15px */
    --text-lg:   1.125rem;   /* 18px */
    --text-xl:   1.375rem;   /* 22px */
    --text-2xl:  1.75rem;    /* 28px */
    --text-3xl:  2.25rem;    /* 36px */

    --leading-tight:  1.25;
    --leading-normal: 1.55;
    --leading-loose:  1.75;

    --weight-light:    300;
    --weight-normal:   400;
    --weight-medium:   500;
    --weight-semibold: 600;
    --weight-bold:     700;

    /* --- Spacing Scale --- */
    --space-1:  0.25rem;    /* 4px */
    --space-2:  0.5rem;     /* 8px */
    --space-3:  0.75rem;    /* 12px */
    --space-4:  1rem;       /* 16px */
    --space-5:  1.25rem;    /* 20px */
    --space-6:  1.5rem;     /* 24px */
    --space-8:  2rem;       /* 32px */
    --space-10: 2.5rem;     /* 40px */
    --space-12: 3rem;       /* 48px */
    --space-16: 4rem;       /* 64px */

    /* --- Border Radius --- */
    --radius-sm:   0.375rem;
    --radius-md:   0.5rem;
    --radius-lg:   0.75rem;
    --radius-xl:   1rem;
    --radius-2xl:  1.25rem;
    --radius-full: 9999px;

    /* --- Shadows --- */
    --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:    0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg:    0 10px 15px rgba(0, 0, 0, 0.06), 0 4px 6px rgba(0, 0, 0, 0.04);
    --shadow-xl:    0 20px 25px rgba(0, 0, 0, 0.08), 0 10px 10px rgba(0, 0, 0, 0.03);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.04);

    /* --- Transitions --- */
    --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base:   250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow:   350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* --- Layout --- */
    --sidebar-width:     260px;
    --sidebar-collapsed: 72px;
    --header-height:     64px;
    --content-max-width: 1320px;
    --z-sidebar:    100;
    --z-header:     110;
    --z-overlay:    200;
    --z-modal:      300;
    --z-toast:      400;

    /* --- Light Theme (default) --- */
    --color-primary-50:  #eff8ff;
    --color-primary-100: #dbeefe;
    --color-primary-200: #bee0fd;
    --color-primary-300: #90cdfc;
    --color-primary-400: #5bb2f8;
    --color-primary-500: #3694f3;
    --color-primary-600: #2077e8;
    --color-primary-700: #1862d5;
    --color-primary-800: #1950ad;
    --color-primary-900: #1a4588;

    --color-accent-50:   #fffbeb;
    --color-accent-100:  #fff3c6;
    --color-accent-200:  #ffe588;
    --color-accent-300:  #ffd24a;
    --color-accent-400:  #ffc020;
    --color-accent-500:  #f5a307;
    --color-accent-600:  #d97b02;
    --color-accent-700:  #b55706;
    --color-accent-800:  #93430c;
    --color-accent-900:  #79370d;

    --color-success-50:  #ecfdf5;
    --color-success-100: #d1fae5;
    --color-success-500: #10b981;
    --color-success-600: #059669;
    --color-success-700: #047857;

    --color-danger-50:   #fef2f2;
    --color-danger-100:  #fee2e2;
    --color-danger-500:  #ef4444;
    --color-danger-600:  #dc2626;
    --color-danger-700:  #b91c1c;

    --color-warning-50:  #fffbeb;
    --color-warning-100: #fef3c7;
    --color-warning-500: #f59e0b;
    --color-warning-600: #d97706;

    /* --- Surfaces (Light) --- */
    --bg-body:          #f5f6fa;
    --bg-surface:       #ffffff;
    --bg-surface-hover: #f8f9fc;
    --bg-surface-alt:   #f0f2f7;
    --bg-sidebar:       #111827;
    --bg-sidebar-hover: #1f2937;
    --bg-sidebar-active:#263348;
    --bg-header:        #ffffff;
    --bg-input:         #ffffff;
    --bg-input-focus:   #ffffff;
    --bg-card:          #ffffff;
    --bg-modal:         #ffffff;
    --bg-tooltip:       #1e293b;
    --bg-badge:         #e8eaf0;

    /* --- Borders (Light) --- */
    --border-color:     #e2e5ed;
    --border-color-strong: #cbd0dc;
    --border-input:     #d1d5e0;
    --border-focus:     var(--color-primary-500);

    /* --- Text (Light) --- */
    --text-primary:     #111827;
    --text-secondary:   #4b5563;
    --text-tertiary:    #9ca3af;
    --text-inverse:     #ffffff;
    --text-link:        var(--color-primary-600);
    --text-link-hover:  var(--color-primary-700);
    --text-sidebar:     #94a3b8;
    --text-sidebar-active: #ffffff;
    --text-on-primary:  #ffffff;
    --text-placeholder: #9ca3af;

    /* --- Misc --- */
    --overlay-bg:      rgba(0, 0, 0, 0.45);
    --scrollbar-bg:    #e5e7eb;
    --scrollbar-thumb: #9ca3af;
    --focus-ring:      0 0 0 3px rgba(54, 148, 243, 0.25);
}

/* ============================================================
   1b. Dark Theme
   ============================================================ */
[data-theme="dark"] {
    --bg-body:          #0b0f19;
    --bg-surface:       #111827;
    --bg-surface-hover: #1a2234;
    --bg-surface-alt:   #151d2e;
    --bg-sidebar:       #080c14;
    --bg-sidebar-hover: #111827;
    --bg-sidebar-active:#192038;
    --bg-header:        #111827;
    --bg-input:         #1a2234;
    --bg-input-focus:   #1e2a3f;
    --bg-card:          #111827;
    --bg-modal:         #151d2e;
    --bg-tooltip:       #1e293b;
    --bg-badge:         #1e293b;

    --border-color:        #1e293b;
    --border-color-strong: #334155;
    --border-input:        #2a3650;
    --border-focus:        var(--color-primary-400);

    --text-primary:     #f1f5f9;
    --text-secondary:   #94a3b8;
    --text-tertiary:    #64748b;
    --text-link:        var(--color-primary-400);
    --text-link-hover:  var(--color-primary-300);
    --text-placeholder: #4b5563;

    --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md:    0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg:    0 10px 15px rgba(0, 0, 0, 0.3), 0 4px 6px rgba(0, 0, 0, 0.15);
    --shadow-xl:    0 20px 25px rgba(0, 0, 0, 0.35), 0 10px 10px rgba(0, 0, 0, 0.15);

    --overlay-bg:      rgba(0, 0, 0, 0.65);
    --scrollbar-bg:    #1e293b;
    --scrollbar-thumb: #475569;
    --focus-ring:      0 0 0 3px rgba(91, 178, 248, 0.2);
}

/* ============================================================
   2. CSS Reset & Base Styles
   ============================================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--weight-normal);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--bg-body);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Selection */
::selection {
    background-color: var(--color-primary-200);
    color: var(--color-primary-900);
}
[data-theme="dark"] ::selection {
    background-color: var(--color-primary-800);
    color: var(--color-primary-100);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Focus visible */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

/* Base elements */
a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--text-link-hover);
}

img, svg, video {
    display: block;
    max-width: 100%;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

small { font-size: var(--text-sm); }
strong { font-weight: var(--weight-semibold); }
code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 0.15em 0.4em;
    background: var(--bg-surface-alt);
    border-radius: var(--radius-sm);
}

/* Skip link (a11y) */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    padding: var(--space-2) var(--space-4);
    background: var(--color-primary-600);
    color: #fff;
    border-radius: var(--radius-md);
    z-index: 999;
    font-weight: var(--weight-medium);
}
.skip-link:focus {
    top: var(--space-4);
}

/* ============================================================
   3. Layout — App Shell
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: width var(--transition-base), transform var(--transition-base);
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-5);
    height: var(--header-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}
.sidebar__brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-700));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(54, 148, 243, 0.3);
}
.sidebar__brand-icon svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}
.sidebar__brand-name {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: #fff;
    letter-spacing: -0.02em;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

/* Sidebar Navigation */
.sidebar__nav {
    flex: 1;
    padding: var(--space-4) var(--space-3);
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar__nav::-webkit-scrollbar { width: 3px; }
.sidebar__nav::-webkit-scrollbar-track { background: transparent; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.sidebar__section {
    margin-bottom: var(--space-6);
}
.sidebar__section-title {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(148, 163, 184, 0.5);
    padding: 0 var(--space-3) var(--space-2);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-fast);
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-sidebar);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    transition: all var(--transition-fast);
    position: relative;
    text-decoration: none;
    margin-bottom: 2px;
}
.sidebar__link:hover {
    background: var(--bg-sidebar-hover);
    color: #e2e8f0;
}
.sidebar__link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
}
.sidebar__link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--color-primary-400);
    border-radius: 0 3px 3px 0;
}

.sidebar__link-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}
.sidebar__link:hover .sidebar__link-icon,
.sidebar__link.active .sidebar__link-icon {
    opacity: 1;
}
.sidebar__link-text {
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar__link-badge {
    margin-left: auto;
    padding: 1px 8px;
    font-size: 0.6875rem;
    font-weight: var(--weight-semibold);
    background: var(--color-primary-600);
    color: #fff;
    border-radius: var(--radius-full);
    line-height: 1.5;
    flex-shrink: 0;
}

/* Sidebar footer */
.sidebar__footer {
    padding: var(--space-3);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

/* Sidebar collapsed state */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed .sidebar__brand-name,
.sidebar.collapsed .sidebar__section-title,
.sidebar.collapsed .sidebar__link-text,
.sidebar.collapsed .sidebar__link-badge {
    opacity: 0;
    pointer-events: none;
}
.sidebar.collapsed .sidebar__link {
    justify-content: center;
    padding: var(--space-2);
}
.sidebar.collapsed .sidebar__link.active::before {
    left: 0;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: calc(var(--z-sidebar) - 1);
    opacity: 0;
    transition: opacity var(--transition-base);
}
.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* --- Main Content Area --- */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-base);
}
.sidebar.collapsed ~ .main-wrapper {
    margin-left: var(--sidebar-collapsed);
}

/* --- Header --- */
.header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    gap: var(--space-4);
    z-index: var(--z-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

.header__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.header__toggle:hover {
    background: var(--bg-surface-alt);
    color: var(--text-primary);
}
.header__toggle svg {
    width: 20px;
    height: 20px;
}

.header__breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    flex: 1;
    min-width: 0;
}
.header__breadcrumb a {
    color: var(--text-secondary);
    white-space: nowrap;
}
.header__breadcrumb a:hover {
    color: var(--text-primary);
}
.header__breadcrumb-sep {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
}
.header__breadcrumb-current {
    color: var(--text-primary);
    font-weight: var(--weight-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Search bar in header */
.header__search {
    position: relative;
    display: flex;
    align-items: center;
}
.header__search-input {
    width: 220px;
    height: 36px;
    padding: 0 var(--space-4) 0 36px;
    background: var(--bg-surface-alt);
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}
.header__search-input::placeholder { color: var(--text-placeholder); }
.header__search-input:focus {
    width: 280px;
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: var(--focus-ring);
    outline: none;
}
.header__search-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* Header icon button */
.header__icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.header__icon-btn:hover {
    background: var(--bg-surface-alt);
    color: var(--text-primary);
}
.header__icon-btn svg {
    width: 20px;
    height: 20px;
}
.header__icon-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--color-danger-500);
    border: 2px solid var(--bg-header);
    border-radius: 50%;
}

/* Header user menu */
.header__user {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.header__user:hover {
    background: var(--bg-surface-alt);
}
.header__avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary-500), var(--color-accent-500));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: #fff;
    flex-shrink: 0;
}
.header__avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}
.header__user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.header__user-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.header__user-role {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    padding: var(--space-6);
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
}

/* ============================================================
   4. Auth Layout (No sidebar)
   ============================================================ */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
}

.auth-layout__left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
}

.auth-layout__right {
    flex: 1;
    display: none;
    background: linear-gradient(135deg, #111827 0%, #1e3a5f 50%, #1a4588 100%);
    position: relative;
    overflow: hidden;
}
.auth-layout__right::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(54, 148, 243, 0.15), transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(245, 163, 7, 0.08), transparent 50%);
}
.auth-layout__right-content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-16);
    color: #fff;
}
.auth-layout__tagline {
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-4);
}
.auth-layout__subtitle {
    font-size: var(--text-lg);
    color: rgba(255, 255, 255, 0.65);
    max-width: 420px;
    line-height: var(--leading-loose);
}

.auth-card {
    width: 100%;
    max-width: 420px;
}
.auth-card__logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
}
.auth-card__logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-700));
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(54, 148, 243, 0.25);
}
.auth-card__logo-icon svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}
.auth-card__logo-name {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.auth-card__title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    margin-bottom: var(--space-2);
}
.auth-card__subtitle {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
}

/* ============================================================
   5. Form Components
   ============================================================ */
.form-group {
    margin-bottom: var(--space-5);
}
.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}
.form-label--required::after {
    content: ' *';
    color: var(--color-danger-500);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    appearance: none;
}
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-placeholder);
}
.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--border-color-strong);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
    box-shadow: var(--focus-ring);
}

.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    border-color: var(--color-danger-500);
}
.form-input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.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' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 5.646a.5.5 0 01.708 0L8 8.293l2.646-2.647a.5.5 0 01.708.708l-3 3a.5.5 0 01-.708 0l-3-3a.5.5 0 010-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
}
.form-error {
    font-size: var(--text-xs);
    color: var(--color-danger-500);
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

/* Input group (icon prefix/suffix) */
.input-group {
    position: relative;
}
.input-group .form-input {
    padding-left: 40px;
}
.input-group__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    pointer-events: none;
}
.input-group__action {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}
.input-group__action:hover {
    color: var(--text-secondary);
}

/* Checkbox / Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-sm);
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary-600);
    cursor: pointer;
}

/* ============================================================
   6. Button Components
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Sizes */
.btn--sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
}
.btn--lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
}
.btn--full {
    width: 100%;
}
.btn--icon {
    padding: var(--space-2);
    width: 36px;
    height: 36px;
}

/* Variants */
.btn--primary {
    background: var(--color-primary-600);
    color: var(--text-on-primary);
    border-color: var(--color-primary-600);
}
.btn--primary:hover {
    background: var(--color-primary-700);
    border-color: var(--color-primary-700);
    box-shadow: 0 2px 8px rgba(32, 119, 232, 0.3);
}
.btn--primary:active {
    background: var(--color-primary-800);
}

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

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

.btn--danger {
    background: var(--color-danger-600);
    color: #fff;
    border-color: var(--color-danger-600);
}
.btn--danger:hover {
    background: var(--color-danger-700);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.btn--success {
    background: var(--color-success-600);
    color: #fff;
    border-color: var(--color-success-600);
}
.btn--success:hover {
    background: var(--color-success-700);
}

.btn--accent {
    background: var(--color-accent-500);
    color: #fff;
    border-color: var(--color-accent-500);
}
.btn--accent:hover {
    background: var(--color-accent-600);
}

/* Loading spinner on buttons */
.btn--loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn--loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================================
   7. Card Component
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.card:hover {
    border-color: var(--border-color-strong);
}
.card--shadow {
    box-shadow: var(--shadow-sm);
}
.card--interactive:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.card__header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}
.card__title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
}
.card__body {
    padding: var(--space-6);
}
.card__footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface-alt);
}

/* ============================================================
   8. Table Component
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    background: var(--bg-card);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: var(--weight-semibold);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    background: var(--bg-surface-alt);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}
.table tr:last-child td {
    border-bottom: none;
}
.table tbody tr {
    transition: background var(--transition-fast);
}
.table tbody tr:hover {
    background: var(--bg-surface-hover);
}

/* ============================================================
   9. Badge / Status
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 10px;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    border-radius: var(--radius-full);
    line-height: 1.6;
    white-space: nowrap;
}
.badge--primary  { background: var(--color-primary-100); color: var(--color-primary-700); }
.badge--success  { background: var(--color-success-100); color: var(--color-success-700); }
.badge--danger   { background: var(--color-danger-100);  color: var(--color-danger-700);  }
.badge--warning  { background: var(--color-warning-100); color: var(--color-warning-600); }
.badge--neutral  { background: var(--bg-badge);          color: var(--text-secondary);    }

[data-theme="dark"] .badge--primary { background: rgba(54, 148, 243, 0.15); color: var(--color-primary-300); }
[data-theme="dark"] .badge--success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
[data-theme="dark"] .badge--danger  { background: rgba(239, 68, 68, 0.15);  color: #fca5a5; }
[data-theme="dark"] .badge--warning { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }

/* Status dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot--success { background: var(--color-success-500); }
.status-dot--danger  { background: var(--color-danger-500);  }
.status-dot--warning { background: var(--color-warning-500); }
.status-dot--primary { background: var(--color-primary-500); }
.status-dot--neutral { background: var(--text-tertiary);     }

/* ============================================================
  10. Flash / Alert Messages
   ============================================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
    border: 1px solid transparent;
    animation: alertSlideIn 0.3s ease-out;
}
@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.alert__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}
.alert__content { flex: 1; }
.alert__close {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}
.alert__close:hover { opacity: 0.8; }

.alert--success {
    background: var(--color-success-50);
    border-color: var(--color-success-500);
    color: var(--color-success-700);
}
.alert--danger {
    background: var(--color-danger-50);
    border-color: var(--color-danger-500);
    color: var(--color-danger-700);
}
.alert--warning {
    background: var(--color-warning-50);
    border-color: var(--color-warning-500);
    color: var(--color-warning-600);
}
.alert--info {
    background: var(--color-primary-50);
    border-color: var(--color-primary-400);
    color: var(--color-primary-700);
}

[data-theme="dark"] .alert--success { background: rgba(16, 185, 129, 0.1);  color: #6ee7b7; }
[data-theme="dark"] .alert--danger  { background: rgba(239, 68, 68, 0.1);   color: #fca5a5; }
[data-theme="dark"] .alert--warning { background: rgba(245, 158, 11, 0.1);  color: #fcd34d; }
[data-theme="dark"] .alert--info    { background: rgba(54, 148, 243, 0.1);  color: #90cdfc; }

/* Toast (floating) */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: 400px;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    font-size: var(--text-sm);
    animation: toastIn 0.35s var(--transition-base);
}
.toast--exit {
    animation: toastOut 0.25s ease-in forwards;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ============================================================
  11. Modal / Dialog
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    animation: fadeIn 0.2s ease-out;
}
.modal-overlay.open {
    display: flex;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--bg-modal);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal__title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
}
.modal__close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.modal__close:hover {
    background: var(--bg-surface-alt);
    color: var(--text-primary);
}
.modal__body {
    padding: var(--space-6);
    overflow-y: auto;
}
.modal__footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* ============================================================
  12. Pagination
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-sm);
}
.pagination__item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: var(--weight-medium);
    transition: all var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    border: none;
    background: transparent;
}
.pagination__item:hover {
    background: var(--bg-surface-alt);
    color: var(--text-primary);
}
.pagination__item.active {
    background: var(--color-primary-600);
    color: #fff;
}

/* ============================================================
  13. Dropdown
   ============================================================ */
.dropdown {
    position: relative;
    display: inline-flex;
}
.dropdown__menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: var(--space-1);
    display: none;
    animation: dropdownIn 0.15s ease-out;
}
.dropdown__menu.open {
    display: block;
}
@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}
.dropdown__item:hover {
    background: var(--bg-surface-alt);
}
.dropdown__item svg {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}
.dropdown__divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-1) 0;
}

/* ============================================================
  14. Stat cards (Dashboard)
   ============================================================ */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-5) var(--space-6);
    transition: all var(--transition-fast);
}
.stat-card:hover {
    border-color: var(--border-color-strong);
    box-shadow: var(--shadow-sm);
}
.stat-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}
.stat-card__label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: var(--weight-medium);
}
.stat-card__icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-card__icon svg {
    width: 20px;
    height: 20px;
}
.stat-card__icon--primary { background: var(--color-primary-100); color: var(--color-primary-600); }
.stat-card__icon--success { background: var(--color-success-100); color: var(--color-success-600); }
.stat-card__icon--warning { background: var(--color-warning-100); color: var(--color-warning-600); }
.stat-card__icon--danger  { background: var(--color-danger-100);  color: var(--color-danger-600);  }
.stat-card__icon--accent  { background: var(--color-accent-100);  color: var(--color-accent-600);  }

[data-theme="dark"] .stat-card__icon--primary { background: rgba(54, 148, 243, 0.15); }
[data-theme="dark"] .stat-card__icon--success { background: rgba(16, 185, 129, 0.15); }
[data-theme="dark"] .stat-card__icon--warning { background: rgba(245, 158, 11, 0.15); }
[data-theme="dark"] .stat-card__icon--danger  { background: rgba(239, 68, 68, 0.15);  }
[data-theme="dark"] .stat-card__icon--accent  { background: rgba(245, 163, 7, 0.15);  }

.stat-card__value {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    line-height: 1;
    margin-bottom: var(--space-1);
}
.stat-card__trend {
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.stat-card__trend--up   { color: var(--color-success-600); }
.stat-card__trend--down { color: var(--color-danger-600);  }

/* ============================================================
  15. Page Title
   ============================================================ */
.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}
.page-title__left {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.page-title__heading {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
}
.page-title__sub {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}
.page-title__actions {
    display: flex;
    gap: var(--space-3);
}

/* ============================================================
  16. Empty State
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-16) var(--space-8);
    text-align: center;
}
.empty-state__icon {
    width: 64px;
    height: 64px;
    color: var(--text-tertiary);
    margin-bottom: var(--space-4);
    opacity: 0.5;
}
.empty-state__title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-2);
}
.empty-state__text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    max-width: 400px;
    margin-bottom: var(--space-6);
}

/* ============================================================
  17. Utility Classes
   ============================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm     { font-size: var(--text-sm); }
.text-xs     { font-size: var(--text-xs); }
.text-muted  { color: var(--text-secondary); }
.text-danger { color: var(--color-danger-500); }
.text-success{ color: var(--color-success-500); }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.w-full { width: 100%; }
.hidden { display: none !important; }

/* Grid helpers */
.grid {
    display: grid;
    gap: var(--space-6);
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Impersonation bar */
.impersonation-bar {
    background: var(--color-accent-500);
    color: #fff;
    text-align: center;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
}
.impersonation-bar a {
    color: #fff;
    text-decoration: underline;
    font-weight: var(--weight-semibold);
}

/* ============================================================
  18. Theme Toggle Switch
   ============================================================ */
.theme-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    border: none;
    background: var(--bg-surface-alt);
    border-radius: var(--radius-full);
    cursor: pointer;
    padding: 2px;
    transition: background var(--transition-fast);
}
.theme-toggle:hover {
    background: var(--border-color);
}
.theme-toggle__thumb {
    display: block;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base);
    position: relative;
}
[data-theme="dark"] .theme-toggle {
    background: var(--color-primary-800);
}
[data-theme="dark"] .theme-toggle__thumb {
    transform: translateX(20px);
}
.theme-toggle__icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
}
.theme-toggle__icon--sun  { left: 6px;  color: var(--color-accent-500); }
.theme-toggle__icon--moon { right: 6px; color: var(--color-primary-300); }

/* ============================================================
  19. Responsive Design
   ============================================================ */

/* Large tablets and small desktops */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Desktop: show auth right panel */
@media (min-width: 1025px) {
    .auth-layout__right {
        display: flex;
    }
}

/* Tablets */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar.collapsed {
        width: var(--sidebar-width);
    }

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

    .header__search-input {
        width: 180px;
    }
    .header__search-input:focus {
        width: 220px;
    }
    .header__user-info {
        display: none;
    }
}

/* Phones */
@media (max-width: 768px) {
    :root {
        --space-6: 1.25rem;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: var(--space-4);
    }

    .header {
        padding: 0 var(--space-4);
    }
    .header__search {
        display: none;
    }

    .page-title {
        flex-direction: column;
        align-items: flex-start;
    }
    .page-title__actions {
        width: 100%;
    }
    .page-title__actions .btn {
        flex: 1;
    }

    .card__body {
        padding: var(--space-4);
    }

    .modal {
        max-width: 100%;
        max-height: 90vh;
        margin: var(--space-4);
        border-radius: var(--radius-xl);
    }

    .table-wrapper {
        border-radius: var(--radius-lg);
    }

    .auth-card {
        max-width: 100%;
    }
    .auth-layout__left {
        padding: var(--space-6) var(--space-4);
    }
}

/* Small phones */
@media (max-width: 480px) {
    .stat-card {
        padding: var(--space-4);
    }
    .stat-card__value {
        font-size: var(--text-xl);
    }
    .header__actions {
        gap: var(--space-1);
    }
}

/* ============================================================
  20. Loading / Skeleton
   ============================================================ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-surface-alt) 25%, var(--bg-surface-hover) 50%, var(--bg-surface-alt) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton--text {
    height: 14px;
    margin-bottom: var(--space-2);
}
.skeleton--title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-3);
}
.skeleton--avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
}

/* Full page loader */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}
.page-loader.hidden {
    opacity: 0;
    pointer-events: none;
}
.page-loader__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary-500);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ============================================================
  21. Print Styles
   ============================================================ */
@media print {
    .sidebar,
    .header,
    .sidebar-overlay,
    .toast-container {
        display: none !important;
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
    body {
        background: #fff;
        color: #000;
    }
    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}
