/* ===========================================================
   M3 Fanpage Monitor — Clay Design System
   Soft 3D, Puffy Elements, Pastel Gradients, Organic Shapes
   =========================================================== */

/* --- CSS Variables / Design Tokens (Clay Light Theme) --- */
:root {
    /* Primary Clay Indigo */
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --primary-light: #EDE9FF;
    --primary-bg: rgba(108, 92, 231, 0.10);

    /* Clay Soft Semantic Palette */
    --success: #00B894;
    --success-bg: #E6FAF3;
    --danger: #E17055;
    --danger-bg: #FDEDEA;
    --warning: #FDCB6E;
    --warning-bg: #FFF8E7;
    --info: #74B9FF;
    --info-bg: #EBF5FF;
    --purple: #A29BFE;
    --purple-bg: #F0EEFF;
    --pink: #FD79A8;
    --pink-bg: #FFF0F5;

    /* Clay Warm Surfaces */
    --bg-body: #F0EDE8;
    --bg-sidebar: #E8E4DE;
    --bg-card: #FDFCFA;
    --bg-header: rgba(253, 252, 250, 0.88);
    --bg-input: #FFFFFF;
    --bg-hover: rgba(108, 92, 231, 0.06);
    --bg-selected: rgba(108, 92, 231, 0.10);
    --bg-subtle: #F5F3EF;
    --bg-secondary: #F0EDE8;

    /* Clay Text Palette */
    --text-primary: #2D3436;
    --text-secondary: #636E72;
    --text-muted: #B2BEC3;

    /* Clay Whisper Borders */
    --border: rgba(45, 52, 54, 0.08);
    --border-color: rgba(45, 52, 54, 0.08);
    --border-subtle: rgba(45, 52, 54, 0.04);
    --border-focus: #6C5CE7;

    /* Clay Radius Scale — Large & Organic */
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Clay Multi-layer Soft 3D Elevation */
    --shadow-xs: 0 2px 4px rgba(45, 52, 54, 0.06), inset 0 1px 1px rgba(255, 255, 255, 0.7);
    --shadow-sm: 0 4px 8px rgba(45, 52, 54, 0.08), 0 1px 2px rgba(45, 52, 54, 0.04), inset 0 1px 2px rgba(255, 255, 255, 0.6);
    --shadow-md: 0 8px 20px rgba(45, 52, 54, 0.10), 0 2px 6px rgba(45, 52, 54, 0.05), inset 0 2px 3px rgba(255, 255, 255, 0.5);
    --shadow-lg: 0 16px 40px rgba(45, 52, 54, 0.12), 0 4px 10px rgba(45, 52, 54, 0.06), inset 0 2px 4px rgba(255, 255, 255, 0.4);

    /* Clay inner shadow for pressed / concave effect */
    --shadow-inset: inset 0 2px 6px rgba(45, 52, 54, 0.08), inset 0 1px 2px rgba(45, 52, 54, 0.04);

    --transition-fast: 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-base: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

    --sidebar-width: 260px;
    --header-height: 64px;
}

/* --- Clay Dark Theme --- */
[data-theme="dark"] {
    --primary: #A29BFE;
    --primary-dark: #6C5CE7;
    --primary-light: rgba(162, 155, 254, 0.18);
    --primary-bg: rgba(162, 155, 254, 0.12);

    --success: #55EFC4;
    --success-bg: rgba(85, 239, 196, 0.12);
    --danger: #FF7675;
    --danger-bg: rgba(255, 118, 117, 0.12);
    --warning: #FFEAA7;
    --warning-bg: rgba(255, 234, 167, 0.12);
    --info: #74B9FF;
    --info-bg: rgba(116, 185, 255, 0.12);
    --purple: #A29BFE;
    --purple-bg: rgba(162, 155, 254, 0.12);
    --pink: #FD79A8;
    --pink-bg: rgba(253, 121, 168, 0.12);

    --bg-body: #1E1E2E;
    --bg-sidebar: #252536;
    --bg-card: #2A2A3C;
    --bg-header: rgba(30, 30, 46, 0.90);
    --bg-input: #2A2A3C;
    --bg-hover: rgba(162, 155, 254, 0.08);
    --bg-selected: rgba(162, 155, 254, 0.12);
    --bg-subtle: #252536;
    --bg-secondary: #252536;

    --text-primary: rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(255, 255, 255, 0.58);
    --text-muted: rgba(255, 255, 255, 0.32);

    --border: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-subtle: rgba(255, 255, 255, 0.03);
    --border-focus: #A29BFE;

    --shadow-xs: 0 2px 4px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.05);
    --shadow-sm: 0 4px 8px rgba(0, 0, 0, 0.30), inset 0 1px 2px rgba(255, 255, 255, 0.04);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.35), inset 0 2px 3px rgba(255, 255, 255, 0.03);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.40), inset 0 2px 4px rgba(255, 255, 255, 0.02);
    --shadow-inset: inset 0 2px 6px rgba(0, 0, 0, 0.25), inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.55;
    transition: background-color 0.3s ease, color 0.3s ease;
}

input, textarea, select, button, a, th, td, label, span, div, p, h1, h2, h3, h4, h5, h6, li {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.sidebar, .header, .card, .stat-card, .dropdown-menu, .form-control {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--primary-dark);
}

/* --- Clay Typography Scale --- */
h1, h2, h3, h4, h5, h6, .page-title {
    letter-spacing: -0.025em;
    color: var(--text-primary);
    font-weight: 700;
}
.page-title {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.3;
}

/* --- Layout --- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}
.app-content {
    flex: 1;
    padding: 28px 36px;
}

/* --- Clay Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: none;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.3s ease, transform 0.3s ease;
    overflow-x: hidden;
    box-shadow: 4px 0 20px rgba(45, 52, 54, 0.06);
}
[data-theme="dark"] .sidebar {
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
}
.sidebar-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.sidebar-logo svg {
    color: var(--primary);
    filter: drop-shadow(0 2px 4px rgba(108, 92, 231, 0.3));
}
.sidebar-toggle {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: scale(1.1);
}
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}
.sidebar-menu {
    list-style: none;
}
.menu-heading {
    padding: 16px 14px 8px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.menu-item {
    margin-bottom: 4px;
}
.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 12px;
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}
.menu-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateX(3px);
}
.menu-link.active {
    color: var(--primary);
    background: var(--primary-bg);
    font-weight: 600;
    border-color: rgba(108, 92, 231, 0.12);
    box-shadow: var(--shadow-xs);
}
[data-theme="dark"] .menu-link.active {
    background: var(--primary-bg);
    border-color: rgba(162, 155, 254, 0.15);
}
.menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: rgba(45, 52, 54, 0.04);
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition-fast);
}
[data-theme="dark"] .menu-icon {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}
.menu-link:hover .menu-icon {
    color: var(--primary);
    background: rgba(108, 92, 231, 0.12);
    transform: scale(1.06);
}
.menu-link.active .menu-icon {
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary) 0%, #A29BFE 100%);
    box-shadow: 0 3px 10px rgba(108, 92, 231, 0.35);
}

/* --- Clay Header --- */
.header {
    height: var(--header-height);
    background: var(--bg-header);
    backdrop-filter: blur(16px) saturate(180%);
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 36px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(45, 52, 54, 0.04);
}
[data-theme="dark"] .header {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
}
.breadcrumb a {
    color: var(--text-muted);
    transition: color 0.2s ease;
}
.breadcrumb a:hover {
    color: var(--primary);
}
.breadcrumb .separator {
    color: var(--text-muted);
    font-size: 0.75rem;
}
.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 600;
}

/* User Dropdown */
.user-dropdown { position: relative; }
.user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px 14px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
.user-btn:hover {
    background: var(--bg-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary) 0%, #A29BFE 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}
.user-info { text-align: left; }
.user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
}
.user-role {
    font-size: 0.6875rem;
    color: var(--text-muted);
}
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 200;
    padding: 6px;
    animation: clayPopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}
.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateX(3px);
}

/* Quota Badge */
.quota-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    padding: 5px 14px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--primary-bg);
    box-shadow: var(--shadow-xs);
}

/* --- Clay Cards & Containers --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.card-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
}
.card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}
.card-body {
    padding: 24px;
}
.card-body.p-0 { padding: 0; }
.card-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
    background: transparent;
}

/* Clay Stat Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #A29BFE, #FD79A8);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px) scale(1.01);
}
.stat-card:hover::before {
    opacity: 1;
}
[data-theme="dark"] .stat-card:hover {
    border-color: rgba(162, 155, 254, 0.15);
}
.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xs);
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    margin-top: 12px;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}
.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* Compact Professional Metric Cards */
.metrics-grid-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
@media (max-width: 1240px) {
    .metrics-grid-6 {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}
@media (max-width: 640px) {
    .metrics-grid-6 {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* 8 Metric Cards Grid (Balanced 4x2 on standard desktop, 8x1 on wide) */
.metrics-grid-8 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
@media (min-width: 1440px) {
    .metrics-grid-8 {
        grid-template-columns: repeat(8, 1fr);
    }
}
@media (max-width: 960px) {
    .metrics-grid-8 {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}
@media (max-width: 480px) {
    .metrics-grid-8 {
        grid-template-columns: 1fr;
    }
}

.metric-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 13px 15px;
    box-shadow: var(--shadow-xs);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 102px;
}
.metric-box:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
    border-color: rgba(108, 92, 231, 0.25);
}
.metric-box-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.metric-box-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.metric-box-icon {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.metric-box-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.15;
    margin: 4px 0 2px;
    letter-spacing: -0.02em;
}
.metric-box-sub {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Clay Database Tables --- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
thead th {
    padding: 12px 16px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    text-align: left;
    background: var(--bg-subtle);
}
thead th:first-child {
    border-top-left-radius: var(--radius-md);
}
thead th:last-child {
    border-top-right-radius: var(--radius-md);
}
tbody td {
    padding: 13px 16px;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-primary);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr {
    transition: all 0.15s ease;
}
tbody tr:hover {
    background: var(--bg-hover);
}
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell-name { font-weight: 600; font-size: 0.8125rem; }
.user-cell-email { font-size: 0.75rem; color: var(--text-muted); }

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
}
.table-responsive::-webkit-scrollbar {
    height: 8px;
}
.table-responsive::-webkit-scrollbar-track {
    background: var(--bg-subtle);
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #B2BEC3, #DFE6E9);
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #636E72, #B2BEC3);
}

/* --- Clay Forms --- */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.form-label .required { color: var(--danger); }
.form-control {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    transition: all 0.25s ease;
    outline: none;
    box-shadow: var(--shadow-inset);
}
.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-bg), var(--shadow-inset);
}
.form-control::placeholder {
    color: var(--text-muted);
}
textarea.form-control {
    resize: vertical;
    min-height: 80px;
}
select.form-control {
    cursor: pointer;
    appearance: none;
    padding-right: 36px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23636E72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px 12px !important;
}

/* Checkbox */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"], input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
    border-radius: var(--radius-xs);
}

/* Password Toggle Wrapper */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}
.password-wrapper .form-control {
    padding-right: 42px;
}
.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: color 0.2s ease, background-color 0.2s ease;
    z-index: 2;
}
.password-toggle:hover {
    color: var(--primary);
    background: var(--bg-hover);
}
.password-toggle:focus {
    outline: none;
    color: var(--primary);
}

/* --- Clay Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-decoration: none;
    line-height: 1.4;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
}
.btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-sm);
}
.btn:active {
    transform: scale(0.97);
    box-shadow: var(--shadow-inset);
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #A29BFE 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.30), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.40), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}
.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #55EFC4 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 184, 148, 0.30), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}
.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #FF7675 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(225, 112, 85, 0.30), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}
.btn-danger:hover {
    background: linear-gradient(135deg, #c53030 0%, var(--danger) 100%);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(225, 112, 85, 0.40);
}
.btn-outline {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .btn-outline:hover {
    border-color: var(--primary);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    box-shadow: none;
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 0.75rem;
    border-radius: var(--radius-xs);
}
.btn-xs {
    padding: 4px 10px;
    font-size: 0.6875rem;
    border-radius: var(--radius-xs);
}
.btn-lg {
    padding: 12px 24px;
    font-size: 0.9375rem;
    border-radius: var(--radius-md);
}
.w-100 { width: 100%; justify-content: center; }
.btn:disabled, .btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
}

/* --- Clay Soft Pastel Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
}
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--bg-hover); color: var(--text-secondary); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }

/* --- Clay Alerts --- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    line-height: 1.5;
    border: none;
    box-shadow: var(--shadow-xs);
}
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-info { background: var(--info-bg); color: var(--info); }

/* --- Clay Avatars --- */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: var(--shadow-xs);
}
.avatar-xs { width: 26px; height: 26px; font-size: 0.625rem; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.6875rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 0.9375rem; }
.avatar-xl { width: 56px; height: 56px; font-size: 1.125rem; }

/* --- Grid System --- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* --- Utilities --- */
.d-flex { display: flex; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary) !important; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.p-0 { padding: 0; }

/* Sidebar Overlay */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); backdrop-filter: blur(4px); z-index: 99; }

/* --- Clay Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 15, 15, 0.40);
    backdrop-filter: blur(8px) saturate(150%);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: clayPopIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
    transform: rotate(90deg);
}
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border-color);
}

/* --- Clay Tabs Component --- */
.tab-navigation {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    border-bottom: none;
    padding: 4px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
}
.tab-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    border: none;
    background: transparent;
    border-bottom: none;
    margin-bottom: 0;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: var(--radius-sm);
}
.tab-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.5);
}
[data-theme="dark"] .tab-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.tab-item.active {
    color: var(--primary);
    background: var(--bg-card);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: clayFadeIn 0.3s ease;
}

/* --- Clay Pagination --- */
nav:has(.pagination),
.pagination,
ul.pagination {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    margin: 0;
    list-style: none;
}
ul.pagination li {
    list-style: none;
    margin: 0;
    padding: 0;
    display: inline-block;
}
.pagination a,
.pagination span,
ul.pagination li a,
ul.pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    box-shadow: var(--shadow-xs);
}
.pagination a:hover,
ul.pagination li a:hover {
    background: var(--primary-bg);
    color: var(--primary);
    border-color: rgba(108, 92, 231, 0.2);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.pagination .active a,
.pagination .active span,
ul.pagination li.active a,
ul.pagination li.active span {
    background: linear-gradient(135deg, var(--primary), #A29BFE) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.35);
}
.pagination .disabled a,
.pagination .disabled span,
ul.pagination li.disabled a,
ul.pagination li.disabled span {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- Clay Animations --- */
@keyframes clayFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes clayPopIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --- Theme Toggle --- */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--primary);
    transform: rotate(15deg) scale(1.05);
    box-shadow: var(--shadow-sm);
}
.theme-toggle .icon-sun, .theme-toggle .icon-moon {
    position: absolute;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.theme-toggle .icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.5); }
[data-theme="dark"] .theme-toggle .icon-sun { opacity: 0; transform: rotate(90deg) scale(0.5); }
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }

/* --- Responsive --- */
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .app-main { margin-left: 0; }
    .mobile-menu-toggle { display: flex; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .header { padding: 0 16px; }
    .app-content { padding: 16px; }
    table { font-size: 0.75rem; }
    thead th, tbody td { padding: 10px 12px; }
    .tab-navigation { overflow-x: auto; flex-wrap: nowrap; }
    .tab-item { white-space: nowrap; flex-shrink: 0; }
}

/* --- Clay Auth Layout --- */
.auth-page {
    background: linear-gradient(135deg, #F0EDE8 0%, #E8E4DE 30%, #DFE6E9 60%, #EDE9FF 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    position: relative;
}
.auth-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, rgba(108, 92, 231, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(253, 121, 168, 0.06) 0%, transparent 50%);
    pointer-events: none;
}
[data-theme="dark"] .auth-page {
    background: linear-gradient(135deg, #1E1E2E 0%, #252536 50%, #2A2A3C 100%);
}
[data-theme="dark"] .auth-page::before {
    background: radial-gradient(circle at 30% 30%, rgba(162, 155, 254, 0.06) 0%, transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(253, 121, 168, 0.04) 0%, transparent 50%);
}
.auth-theme-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100;
}
.auth-container {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}
.auth-logo-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary) 0%, #A29BFE 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.3);
}
.auth-logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}
.auth-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: -0.03em;
}
.auth-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
    text-align: center;
    line-height: 1.5;
}
.auth-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.auth-footer a {
    color: var(--primary);
    font-weight: 600;
}
.auth-footer a:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

/* --- Clay Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(108, 92, 231, 0.2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(108, 92, 231, 0.35); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(162, 155, 254, 0.2); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(162, 155, 254, 0.35); }

/* --- Modern Custom Popup Modal & Toast --- */
.custom-alert-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 15, 15, 0.40);
    backdrop-filter: blur(8px) saturate(150%);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.custom-alert-overlay.show {
    display: flex;
    opacity: 1;
}
.custom-alert-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 440px;
    padding: 32px 28px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    transform: scale(0.92);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.custom-alert-overlay.show .custom-alert-box {
    transform: scale(1);
}
.custom-alert-icon {
    width: 62px;
    height: 62px;
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-xs);
}
.custom-alert-icon.success {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.15), rgba(85, 239, 196, 0.15));
    color: var(--success);
}
.custom-alert-icon.error {
    background: linear-gradient(135deg, rgba(225, 112, 85, 0.15), rgba(255, 118, 117, 0.15));
    color: var(--danger);
}
.custom-alert-icon.warning {
    background: linear-gradient(135deg, rgba(253, 203, 110, 0.2), rgba(255, 234, 167, 0.2));
    color: var(--warning);
}
.custom-alert-icon.info {
    background: linear-gradient(135deg, rgba(116, 185, 255, 0.15), rgba(108, 92, 231, 0.12));
    color: var(--info);
}
.custom-alert-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.custom-alert-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 24px;
    word-break: break-word;
}
.custom-alert-btn {
    width: 100%;
    padding: 13px 20px;
    font-size: 0.9375rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary), #A29BFE);
    color: #fff;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 6px 16px rgba(108, 92, 231, 0.30), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}
.custom-alert-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(108, 92, 231, 0.40), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

/* Toast Container */
#toastContainer {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}
.custom-toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 440px;
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.875rem;
    color: var(--text-primary);
    animation: toastSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: all 0.25s ease;
}
@keyframes toastSlideIn {
    from { transform: translateX(100%) scale(0.9); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}
.custom-toast.hide {
    transform: translateX(100%) scale(0.9);
    opacity: 0;
}
