/* =================================================================
 |  WhatsApp CRM SaaS — Master Stylesheet
 |  ---------------------------------------------------------------
 |  Design language: clean modern SaaS (Interakt / WATI / AiSensy
 |  inspired) with a refined WhatsApp-green + slate palette.
 |  - Dark sidebar, light content area
 |  - Emerald/teal primary accent (NO blue/indigo)
 |  - Mobile-first responsive
 |  - Self-contained — no external framework imports
 |  - Production-quality, well-organised, commented
 |
 |  Sections:
 |    1.  Design tokens (CSS custom properties)
 |    2.  Base reset & typography
 |    3.  Scrollbar styling
 |    4.  Layout (app / sidebar / topbar / content)
 |    5.  Buttons
 |    6.  Cards
 |    7.  Tables
 |    8.  Forms
 |    9.  Badges & pills
 |    10. Alerts
 |    11. Modals
 |    12. Dropdowns
 |    13. Avatars & status indicators
 |    14. Empty state
 |    15. Spinners
 |    16. Tabs
 |    17. Pagination
 |    18. Chat window (inbox)
 |    19. Stat cards & grids
 |    20. Progress bars
 |    21. Breadcrumbs
 |    22. Tooltips
 |    23. Skeletons (loading shimmer)
 |    24. Utilities
 |    25. Animations
 |    26. Responsive breakpoints
 | ================================================================= */


/* =================================================================
 |  1. Design tokens
 | ================================================================= */
:root {
    /* Brand / accent — emerald + teal (WhatsApp-green inspired) */
    --color-primary:        #10b981;   /* emerald-500 */
    --color-primary-dark:   #059669;   /* emerald-600 */
    --color-primary-darker: #047857;   /* emerald-700 */
    --color-primary-light:  #d1fae5;   /* emerald-100 */
    --color-primary-lighter:#ecfdf5;   /* emerald-50  */

    /* Neutrals — slate */
    --color-bg:             #f8fafc;   /* slate-50  */
    --color-surface:        #ffffff;   /* white     */
    --color-sidebar:        #0f172a;   /* slate-900 */
    --color-sidebar-soft:   #1e293b;   /* slate-800 */
    --color-sidebar-hover:  #1e293b;   /* slate-800 */
    --color-sidebar-active: #0b1220;   /* near-black */

    /* Text */
    --color-text:           #1e293b;   /* slate-800 */
    --color-text-muted:     #64748b;   /* slate-500 */
    --color-text-soft:      #94a3b8;   /* slate-400 */
    --color-text-inverse:   #f1f5f9;   /* slate-100 */
    --color-text-inverse-muted: #94a3b8;

    /* Borders & dividers */
    --color-border:         #e2e8f0;   /* slate-200 */
    --color-border-soft:    #f1f5f9;   /* slate-100 */
    --color-border-sidebar: rgba(255, 255, 255, 0.08);

    /* Semantic */
    --color-success:        #22c55e;
    --color-success-light:  #dcfce7;
    --color-warning:        #f59e0b;
    --color-warning-light:  #fef3c7;
    --color-danger:         #ef4444;
    --color-danger-light:   #fee2e2;
    --color-info:           #0ea5e9;
    --color-info-light:     #e0f2fe;

    /* Typography */
    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    --fs-xs:   0.75rem;   /* 12px */
    --fs-sm:   0.875rem;  /* 14px */
    --fs-base: 0.9375rem; /* 15px */
    --fs-md:   1rem;      /* 16px */
    --fs-lg:   1.125rem;  /* 18px */
    --fs-xl:   1.25rem;   /* 20px */
    --fs-2xl:  1.5rem;    /* 24px */
    --fs-3xl:  1.875rem;  /* 30px */
    --fs-4xl:  2.25rem;   /* 36px */
    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
    --lh-tight: 1.25;
    --lh-base: 1.5;

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

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

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

    /* Motion */
    --transition-fast: 120ms ease;
    --transition:      180ms ease;
    --transition-slow: 280ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index scale */
    --z-sidebar:  40;
    --z-topbar:   50;
    --z-backdrop: 60;
    --z-dropdown: 70;
    --z-modal:    80;
    --z-toast:    90;
}


/* =================================================================
 |  2. Base reset & typography
 | ================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5em;
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    color: var(--color-text);
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
h5 { font-size: var(--fs-base); }
h6 { font-size: var(--fs-sm); }
p { margin: 0 0 1rem; }
a {
    color: var(--color-primary-dark);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary-darker); text-decoration: underline; }
img, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    max-width: 100%;
}
img { height: auto; }
button, input, optgroup, select, textarea {
    font-family: inherit;
    font-size: 100%;
    line-height: var(--lh-base);
    color: inherit;
    margin: 0;
}
button { cursor: pointer; background: none; border: none; padding: 0; }
ul, ol { margin: 0 0 1rem 1.25rem; padding: 0; }
small { font-size: var(--fs-sm); color: var(--color-text-muted); }
code, pre, kbd, samp { font-family: var(--font-mono); font-size: 0.9em; }
hr {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: 1.5rem 0;
}

/* Visible focus ring for keyboard users (accessibility) */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
/* Remove default outline on mouse clicks (only show for keyboard nav) */
:focus:not(:focus-visible) { outline: none; }

/* Screen-reader-only utility */
.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;
}


/* =================================================================
 |  3. Scrollbar styling (webkit + Firefox)
 | ================================================================= */
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-text-soft) transparent;
}
/* Webkit / Blink (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: var(--color-text-soft);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-text-muted);
    background-clip: content-box;
}
/* Sidebar (dark) scrollbar variant */
.sidebar ::-webkit-scrollbar-thumb,
.sidebar {
    scrollbar-color: #334155 transparent;
}
.sidebar ::-webkit-scrollbar-thumb {
    background-color: #334155;
}


/* =================================================================
 |  4. Layout
 | ================================================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--color-bg);
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-text-inverse);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: transform var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0 1.25rem;
    height: var(--header-height);
    min-height: var(--header-height);
    border-bottom: 1px solid var(--color-border-sidebar);
    flex-shrink: 0;
}
.sidebar-brand-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: var(--fw-bold);
    font-size: var(--fs-md);
    flex-shrink: 0;
}
.sidebar-brand-name {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: #fff;
    letter-spacing: -0.01em;
}
.sidebar-brand-name small {
    display: block;
    font-size: 0.6875rem;
    font-weight: var(--fw-normal);
    color: var(--color-text-inverse-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1 1 auto;
    padding: 0.75rem 0 1.5rem;
    overflow-y: auto;
}

.sidebar-section {
    margin-top: 1.25rem;
    padding: 0 1.25rem;
}
.sidebar-section-label {
    padding: 0.375rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-inverse-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    margin: 1px 0;
    color: var(--color-text-inverse-muted);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    border-left: 3px solid transparent;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    text-decoration: none;
    position: relative;
}
.sidebar-link:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-text-inverse);
    text-decoration: none;
}
.sidebar-link.active {
    background: var(--color-sidebar-active);
    color: #fff;
    border-left-color: var(--color-primary);
}
.sidebar-link-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 1.75;
    fill: none;
}
.sidebar-link-badge {
    margin-left: auto;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: var(--fw-semibold);
    padding: 0.125rem 0.4375rem;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid var(--color-border-sidebar);
    padding: 0.75rem;
    flex-shrink: 0;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    color: var(--color-text-inverse);
    text-decoration: none;
    transition: background var(--transition-fast);
}
.sidebar-user:hover {
    background: var(--color-sidebar-hover);
    text-decoration: none;
}
.sidebar-user-info {
    flex: 1;
    min-width: 0;
}
.sidebar-user-name {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-email {
    font-size: 0.75rem;
    color: var(--color-text-inverse-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Mobile sidebar backdrop ---- */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: var(--z-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}
body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
}

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

/* ---- Topbar ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
    height: var(--header-height);
    min-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 1.5rem;
    gap: 1rem;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
}
.topbar-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--color-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-subtitle {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    margin: 0;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}
.topbar-search {
    position: relative;
    width: 280px;
    max-width: 32vw;
}
.topbar-search input {
    width: 100%;
    padding: 0.5rem 0.875rem 0.5rem 2.25rem;
    font-size: var(--fs-sm);
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.topbar-search input::placeholder { color: var(--color-text-soft); }
.topbar-search input:focus {
    background: var(--color-surface);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
    outline: none;
}
.topbar-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--color-text-soft);
    pointer-events: none;
}

.hamburger {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    transition: background var(--transition-fast);
}
.hamburger:hover { background: var(--color-border-soft); }
.hamburger svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; fill: none; }

/* ---- Content area ---- */
.content {
    flex: 1 1 auto;
    padding: 1.5rem;
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
}
.content-narrow { max-width: 960px; }
.content-full { max-width: 100%; }

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.page-header-title {
    margin: 0 0 0.25rem;
    font-size: var(--fs-2xl);
    font-weight: var(--fw-semibold);
}
.page-header-subtitle {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}


/* =================================================================
 |  5. Buttons
 | ================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: 1.4;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
}
.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #fff;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}
.btn-secondary {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text);
}
.btn-secondary:hover {
    background: var(--color-bg);
    border-color: var(--color-text-soft);
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-text-muted);
}
.btn-ghost:hover {
    background: var(--color-border-soft);
    color: var(--color-text);
}
.btn-success {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
}
.btn-success:hover { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-warning {
    background: var(--color-warning);
    border-color: var(--color-warning);
    color: #fff;
}
.btn-warning:hover { background: #d97706; border-color: #d97706; color: #fff; }

.btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: var(--fs-xs);
    border-radius: var(--radius-sm);
}
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg {
    padding: 0.75rem 1.25rem;
    font-size: var(--fs-md);
    border-radius: var(--radius-lg);
}
.btn-lg svg { width: 18px; height: 18px; }
.btn-block { display: flex; width: 100%; }
.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: var(--radius);
}
.btn-icon.btn-sm { width: 30px; height: 30px; }
.btn-icon.btn-lg { width: 44px; height: 44px; }

/* Loading state on buttons */
.btn[aria-busy="true"] {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    color: currentColor;
    opacity: 0.9;
}
.btn-primary[aria-busy="true"]::after,
.btn-success[aria-busy="true"]::after,
.btn-danger[aria-busy="true"]::after { border-color: #fff; border-top-color: transparent; }
@keyframes btn-spin { to { transform: rotate(360deg); } }


/* =================================================================
 |  6. Cards
 | ================================================================= */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-flush { box-shadow: none; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}
.card-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    margin: 0;
    color: var(--color-text);
}
.card-subtitle {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    margin: 0.125rem 0 0;
}
.card-body {
    padding: 1.25rem;
}
.card-body-flush { padding: 0; }
.card-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}


/* =================================================================
 |  7. Tables
 | ================================================================= */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
    color: var(--color-text);
}
.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: middle;
}
.table thead th {
    font-size: 0.6875rem;
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.table tbody td {
    border-bottom: 1px solid var(--color-border-soft);
}
.table tbody tr:last-child td { border-bottom: none; }
.table-striped tbody tr:nth-child(even) { background: var(--color-bg); }
.table-hover tbody tr {
    transition: background var(--transition-fast);
}
.table-hover tbody tr:hover { background: var(--color-primary-lighter); }
.table-compact th,
.table-compact td { padding: 0.5rem 0.75rem; }
.table td .row-actions {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
}


/* =================================================================
 |  8. Forms
 | ================================================================= */
.form-group {
    margin-bottom: 1rem;
}
.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-text);
}
.form-label .req { color: var(--color-danger); margin-left: 2px; }
.form-control,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: var(--fs-sm);
    line-height: var(--lh-base);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
}
.form-control::placeholder,
.form-textarea::placeholder { color: var(--color-text-soft); }
.form-control:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
    outline: none;
}
.form-control:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: not-allowed;
}
.form-textarea { min-height: 96px; resize: vertical; font-family: inherit; }
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 2rem;
}
.form-text {
    display: block;
    margin-top: 0.375rem;
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}
.form-error {
    display: block;
    margin-top: 0.375rem;
    font-size: var(--fs-xs);
    color: var(--color-danger);
    font-weight: var(--fw-medium);
}
.form-control.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    border-color: var(--color-danger);
}
.form-control.is-invalid:focus,
.form-select.is-invalid:focus,
.form-textarea.is-invalid:focus {
    box-shadow: 0 0 0 3px var(--color-danger-light);
}
.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--fs-sm);
    color: var(--color-text);
    cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    cursor: pointer;
}
.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}
.input-group .form-control {
    border-radius: 0;
    flex: 1 1 auto;
}
.input-group .input-group-text {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
}
.input-group > *:first-child { border-top-left-radius: var(--radius); border-bottom-left-radius: var(--radius); }
.input-group > *:last-child  { border-top-right-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.input-group .form-control + .input-group-text { border-left: none; }
.input-group .input-group-text + .form-control { border-left: none; }


/* =================================================================
 |  9. Badges & pills
 | ================================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: var(--fw-semibold);
    line-height: 1.4;
    color: var(--color-text-muted);
    background: var(--color-border-soft);
    border-radius: var(--radius-full);
    white-space: nowrap;
}
.badge-success { background: var(--color-success-light); color: #15803d; }
.badge-warning { background: var(--color-warning-light); color: #b45309; }
.badge-danger  { background: var(--color-danger-light);  color: #b91c1c; }
.badge-info    { background: var(--color-info-light);    color: #0369a1; }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary-darker); }
.badge-muted   { background: var(--color-border-soft);   color: var(--color-text-muted); }


/* =================================================================
 |  10. Alerts
 | ================================================================= */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-text-soft);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--fs-sm);
    margin-bottom: 1rem;
}
.alert-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
}
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: var(--fw-semibold); margin-bottom: 0.125rem; }
.alert-dismiss {
    flex-shrink: 0;
    width: 24px; height: 24px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: inherit; opacity: 0.6;
    transition: opacity var(--transition-fast), background var(--transition-fast);
}
.alert-dismiss:hover { opacity: 1; background: rgba(0,0,0,0.05); }

.alert-success { background: var(--color-success-light); border-color: #bbf7d0; border-left-color: var(--color-success); color: #14532d; }
.alert-danger  { background: var(--color-danger-light);  border-color: #fecaca; border-left-color: var(--color-danger);  color: #7f1d1d; }
.alert-warning { background: var(--color-warning-light); border-color: #fde68a; border-left-color: var(--color-warning); color: #78350f; }
.alert-info    { background: var(--color-info-light);    border-color: #bae6fd; border-left-color: var(--color-info);    color: #075985; }


/* =================================================================
 |  11. Modals
 | ================================================================= */
.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity var(--transition);
}
.modal.is-open {
    display: flex;
    opacity: 1;
}
.modal-dialog {
    width: 100%;
    max-width: 480px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    transform: translateY(8px) scale(0.98);
    transition: transform var(--transition-slow);
}
.modal.is-open .modal-dialog { transform: translateY(0) scale(1); }
.modal-modal-lg .modal-dialog { max-width: 720px; }
.modal-modal-sm .modal-dialog { max-width: 360px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.modal-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    margin: 0;
}
.modal-close {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--color-text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
}
.modal-close:hover { background: var(--color-border-soft); color: var(--color-text); }
.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1 1 auto;
}
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}


/* =================================================================
 |  12. Dropdowns
 | ================================================================= */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
}
.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.375rem;
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
}
.dropdown.is-open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.dropdown-menu-left { left: 0; right: auto; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    font-size: var(--fs-sm);
    color: var(--color-text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.dropdown-item:hover {
    background: var(--color-border-soft);
    text-decoration: none;
    color: var(--color-text);
}
.dropdown-item svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger:hover { background: var(--color-danger-light); color: var(--color-danger); }
.dropdown-divider {
    height: 1px;
    background: var(--color-border);
    margin: 0.375rem 0;
}
.dropdown-header {
    padding: 0.5rem 0.625rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}


/* =================================================================
 |  13. Avatars & status indicators
 | ================================================================= */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: #fff;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.avatar-md { width: 36px; height: 36px; font-size: var(--fs-sm); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--fs-md); }
.avatar-xl { width: 72px; height: 72px; font-size: var(--fs-xl); }
.avatar-group { display: inline-flex; }
.avatar-group .avatar { margin-left: -8px; border: 2px solid var(--color-surface); }
.avatar-group .avatar:first-child { margin-left: 0; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-soft);
    flex-shrink: 0;
}
.status-dot-online  { background: var(--color-success); box-shadow: 0 0 0 2px var(--color-success-light); }
.status-dot-offline { background: var(--color-text-soft); }
.status-dot-away    { background: var(--color-warning); }
.status-dot-busy    { background: var(--color-danger); }

.avatar-status {
    position: absolute;
    bottom: 0; right: 0;
    width: 10px; height: 10px;
    border-radius: 50%;
    border: 2px solid var(--color-surface);
}


/* =================================================================
 |  14. Empty state
 | ================================================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-muted);
}
.empty-state-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    color: var(--color-text-soft);
    stroke: currentColor;
    stroke-width: 1.25;
    fill: none;
}
.empty-state-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--color-text);
    margin: 0 0 0.375rem;
}
.empty-state-desc {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    max-width: 380px;
    margin: 0 0 1.25rem;
}


/* =================================================================
 |  15. Spinners
 | ================================================================= */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--color-primary-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
.spinner-on-primary {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* =================================================================
 |  16. Tabs
 | ================================================================= */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    gap: 0.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab {
    padding: 0.625rem 1rem;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    margin-bottom: -1px;
}
.tab:hover { color: var(--color-text); }
.tab.active {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary);
}
.tab:disabled, .tab[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}
.tab-content {
    padding: 1.25rem 0;
    display: none;
}
.tab-content.is-active { display: block; animation: fadeIn var(--transition-slow); }


/* =================================================================
 |  17. Pagination
 | ================================================================= */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    list-style: none;
    margin: 1.25rem 0 0;
    padding: 0;
}
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.5rem;
    font-size: var(--fs-sm);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.page-link:hover {
    background: var(--color-bg);
    border-color: var(--color-text-soft);
    text-decoration: none;
}
.page-link.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    cursor: default;
}
.page-link:disabled,
.page-link.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    color: var(--color-text-muted);
}


/* =================================================================
 |  18. Chat window (inbox)
 | ================================================================= */
.chat-window {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--color-bg);
}
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    margin: 0;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header-meta {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    scroll-behavior: smooth;
    background:
        linear-gradient(to bottom, var(--color-bg), var(--color-bg)),
        var(--color-surface);
}
.chat-message {
    max-width: 70%;
    padding: 0.5rem 0.875rem;
    font-size: var(--fs-sm);
    line-height: 1.45;
    border-radius: var(--radius-lg);
    word-wrap: break-word;
    overflow-wrap: anywhere;
    position: relative;
    animation: fadeInUp var(--transition);
}
.chat-message-in {
    align-self: flex-start;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 4px;
}
.chat-message-out {
    align-self: flex-end;
    margin-left: auto;
    background: var(--color-primary-light);
    color: var(--color-primary-darker);
    border-bottom-right-radius: 4px;
}
.chat-message-meta {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.625rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
    justify-content: flex-end;
}
.chat-message-in .chat-message-meta { justify-content: flex-start; }
.chat-message-status {
    display: inline-flex;
    align-items: center;
}
.chat-message-status svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; }
.chat-message-status.sent     { color: var(--color-text-soft); }
.chat-message-status.delivered{ color: var(--color-text-soft); }
.chat-message-status.read     { color: var(--color-info); }
.chat-message-status.failed   { color: var(--color-danger); }

.chat-message-image,
.chat-message-video,
.chat-message-document {
    display: block;
    margin-bottom: 0.375rem;
    border-radius: var(--radius-sm);
    max-width: 100%;
    background: var(--color-border-soft);
}
.chat-message-image img,
.chat-message-video video { max-width: 100%; border-radius: var(--radius-sm); display: block; }
.chat-message-document {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    font-size: var(--fs-sm);
    color: var(--color-text);
    text-decoration: none;
}
.chat-message-document:hover { text-decoration: none; background: rgba(0,0,0,0.03); }

.chat-typing {
    align-self: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    padding: 0.625rem 0.875rem;
    display: none;
    align-items: center;
    gap: 0.25rem;
}
.chat-typing.is-visible { display: inline-flex; }
.chat-typing-dot {
    width: 6px; height: 6px;
    background: var(--color-text-soft);
    border-radius: 50%;
    animation: typing-bounce 1.2s infinite;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

.chat-day-divider {
    align-self: center;
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    margin: 0.5rem 0;
}

.chat-input {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}
.chat-input textarea {
    flex: 1 1 auto;
    min-height: 40px;
    max-height: 140px;
    padding: 0.5rem 0.75rem;
    font-size: var(--fs-sm);
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.chat-input textarea:focus {
    background: var(--color-surface);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
    outline: none;
}
.chat-input-actions {
    display: flex;
    gap: 0.25rem;
}


/* =================================================================
 |  19. Stat cards & grids
 | ================================================================= */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}
.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.stat-card-label {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-text-muted);
    margin: 0;
}
.stat-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-light);
    color: var(--color-primary-darker);
    flex-shrink: 0;
}
.stat-card-icon svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; }
.stat-card-icon.icon-success { background: var(--color-success-light); color: #15803d; }
.stat-card-icon.icon-warning { background: var(--color-warning-light); color: #b45309; }
.stat-card-icon.icon-danger  { background: var(--color-danger-light);  color: #b91c1c; }
.stat-card-icon.icon-info    { background: var(--color-info-light);    color: #0369a1; }
.stat-card-value {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-bold);
    line-height: 1.1;
    color: var(--color-text);
    margin: 0;
    letter-spacing: -0.02em;
}
.stat-card-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}
.stat-card-trend.up   { color: var(--color-success); }
.stat-card-trend.down { color: var(--color-danger); }
.stat-card-trend svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2.5; fill: none; }

.grid {
    display: grid;
    gap: 1rem;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }


/* =================================================================
 |  20. Progress bars
 | ================================================================= */
.progress {
    height: 8px;
    background: var(--color-border-soft);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}
.progress-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}
.progress-bar.success { background: var(--color-success); }
.progress-bar.warning { background: var(--color-warning); }
.progress-bar.danger  { background: var(--color-danger); }
.progress-sm { height: 4px; }
.progress-lg { height: 14px; }


/* =================================================================
 |  21. Breadcrumbs
 | ================================================================= */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.375rem;
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
}
.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}
.breadcrumb-item a { color: var(--color-text-muted); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--color-text); text-decoration: none; }
.breadcrumb-item.active { color: var(--color-text); font-weight: var(--fw-medium); }
.breadcrumb-separator { color: var(--color-text-soft); user-select: none; }


/* =================================================================
 |  22. Tooltips
 | ================================================================= */
.tooltip {
    position: relative;
    display: inline-flex;
}
.tooltip[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--color-sidebar);
    color: var(--color-text-inverse);
    font-size: 0.6875rem;
    line-height: 1.3;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    z-index: var(--z-dropdown);
}
.tooltip[data-tooltip]:hover::after,
.tooltip[data-tooltip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
.tooltip[data-tooltip]::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--color-sidebar);
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.tooltip[data-tooltip]:hover::before,
.tooltip[data-tooltip]:focus-visible::before { opacity: 1; }


/* =================================================================
 |  23. Skeletons (loading shimmer)
 | ================================================================= */
.skeleton {
    display: inline-block;
    background: linear-gradient(
        90deg,
        var(--color-border-soft) 0%,
        var(--color-border) 50%,
        var(--color-border-soft) 100%
    );
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    width: 100%;
    height: 14px;
}
.skeleton-text { height: 12px; margin-bottom: 6px; }
.skeleton-text:last-child { width: 60%; }
.skeleton-title { height: 18px; width: 50%; margin-bottom: 12px; }
.skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; }
.skeleton-block { height: 80px; }
.skeleton-card .skeleton { margin-bottom: 8px; }
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* =================================================================
 |  24. Utilities
 | ================================================================= */
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }
.text-muted  { color: var(--color-text-muted) !important; }
.text-soft   { color: var(--color-text-soft) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-success{ color: var(--color-success) !important; }
.text-warning{ color: var(--color-warning) !important; }
.text-info   { color: var(--color-info) !important; }
.text-primary{ color: var(--color-primary-dark) !important; }
.text-sm     { font-size: var(--fs-sm); }
.text-xs     { font-size: var(--fs-xs); }
.text-lg     { font-size: var(--fs-lg); }
.text-xl     { font-size: var(--fs-xl); }
.font-medium { font-weight: var(--fw-medium); }
.font-semibold { font-weight: var(--fw-semibold); }
.font-bold   { font-weight: var(--fw-bold); }
.uppercase   { text-transform: uppercase; letter-spacing: 0.04em; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 0.75rem; } .mt-4 { margin-top: 1rem; } .mt-5 { margin-top: 1.5rem; } .mt-6 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; } .mb-4 { margin-bottom: 1rem; } .mb-5 { margin-bottom: 1.5rem; } .mb-6 { margin-bottom: 2rem; }
.ml-1 { margin-left: 0.25rem; } .ml-2 { margin-left: 0.5rem; } .ml-3 { margin-left: 0.75rem; } .ml-auto { margin-left: auto; }
.mr-1 { margin-right: 0.25rem; } .mr-2 { margin-right: 0.5rem; } .mr-3 { margin-right: 0.75rem; } .mr-auto { margin-right: auto; }
.p-0 { padding: 0; } .p-2 { padding: 0.5rem; } .p-3 { padding: 0.75rem; } .p-4 { padding: 1rem; } .p-5 { padding: 1.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.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-1 { gap: 0.25rem; } .gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; } .gap-4 { gap: 1rem; }
.grid-cols { display: grid; }
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.w-full { width: 100%; }
.w-auto { width: auto; }
.h-full { height: 100%; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.rounded { border-radius: var(--radius); }
.rounded-full { border-radius: var(--radius-full); }
.shadow { box-shadow: var(--shadow); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.border { border: 1px solid var(--color-border); }
.border-t { border-top: 1px solid var(--color-border); }
.border-b { border-bottom: 1px solid var(--color-border); }
.bg-surface { background: var(--color-surface); }
.bg-muted { background: var(--color-bg); }
.bg-primary { background: var(--color-primary); color: #fff; }
.no-underline { text-decoration: none !important; }
.list-none { list-style: none; }
.pointer-events-none { pointer-events: none; }


/* =================================================================
 |  25. Animations
 | ================================================================= */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
.animate-fade-in { animation: fadeIn var(--transition-slow); }
.animate-fade-in-up { animation: fadeInUp var(--transition-slow); }
.animate-slide-in-left { animation: slideInLeft var(--transition-slow); }
.animate-slide-in-right { animation: slideInRight var(--transition-slow); }

/* Reduced-motion: respect user preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* =================================================================
 |  26. Responsive breakpoints
 | ================================================================= */

/* Large desktops and up (>= 1024px) — nothing to do, defaults apply */

/* Tablet and below (<= 1024px) — collapse 4-col grid to 2-col */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar-search { width: 220px; }
    .content { padding: 1.25rem; }
}

/* Mobile and below (<= 768px) — sidebar hides, hamburger appears */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .main-area {
        margin-left: 0;
    }
    .hamburger {
        display: inline-flex;
    }
    .topbar {
        padding: 0 1rem;
    }
    .topbar-search {
        display: none;
    }
    .topbar-title {
        font-size: var(--fs-md);
    }
    .content {
        padding: 1rem;
    }
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    .grid-auto {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header-actions {
        justify-content: stretch;
    }
    .page-header-actions .btn { flex: 1; }
    .modal {
        padding: 0.5rem;
    }
    .modal-dialog {
        max-width: 100%;
        max-height: calc(100vh - 1rem);
    }
    .card-body { padding: 1rem; }
    .stat-card-value { font-size: var(--fs-2xl); }
    .chat-message { max-width: 85%; }
}

/* Small phones (<= 480px) — even tighter */
@media (max-width: 480px) {
    .topbar-actions .btn-text { display: none; }
    .topbar-actions .btn { padding: 0.5rem; }
    .chat-message { max-width: 92%; }
    .content { padding: 0.75rem; }
}

/* Print styles — useful for contact export / report printing */
@media print {
    .sidebar, .topbar, .sidebar-backdrop, .page-header-actions, .btn { display: none !important; }
    .main-area { margin-left: 0 !important; }
    .card { box-shadow: none; border-color: #ccc; }
    body { background: #fff; }
}
