/* =================================================================
   PA SaaS System - Modern Card-Based Design System v2.0
   Clean, Adaptive, Premium
   ================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* --- CSS Variables --- */
:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #DBEAFE;
    --primary-50: #EFF6FF;
    --secondary: #7C3AED;
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --info: #06B6D4;
    --info-light: #CFFAFE;

    --bg-body: #F0F4F8;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0F172A;
    --bg-sidebar-hover: #1E293B;
    --bg-sidebar-active: rgba(37,99,235,0.15);

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-light: #CBD5E1;

    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --border-focus: rgba(37,99,235,0.4);

    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 28px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);
    --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.15);
    --shadow-colored: 0 8px 25px -5px rgba(37,99,235,0.25);

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

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }

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

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #E2E8F0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sidebar-brand-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3B82F6, #7C3AED);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}
.sidebar-brand-text { font-size: 15px; font-weight: 700; color: white; line-height: 1.3; }
.sidebar-brand-text small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #64748B;
    opacity: 1;
}

.sidebar-nav { padding: 12px 10px; flex: 1; }
.sidebar-section { margin-bottom: 24px; }
.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #475569;
    padding: 0 12px;
    margin-bottom: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: #94A3B8;
    font-weight: 500;
    font-size: 14px;
    transition: all var(--transition);
    cursor: pointer;
    margin-bottom: 1px;
    position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #E2E8F0; }
.nav-item.active {
    background: rgba(37,99,235,0.18);
    color: #93C5FD;
    font-weight: 600;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 3px;
    background: #3B82F6;
    border-radius: 0 3px 3px 0;
}
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; font-style: normal; }
.nav-badge {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    background: rgba(59,130,246,0.2);
    color: #93C5FD;
    font-weight: 600;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.sidebar-user:hover { background: rgba(255,255,255,0.06); }
.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #3B82F6, #7C3AED);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.1);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #E2E8F0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: #475569; }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; min-width: 0; }

/* Header */
.main-header {
    height: var(--header-height);
    background: rgba(255,255,255,0.92);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.btn-sidebar-toggle {
    display: none;
    width: 38px; height: 38px;
    border: none;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
}

.page-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* Content area */
.content-area { padding: 28px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 24px; }
.card-footer { padding: 14px 24px; border-top: 1px solid var(--border-light); }

/* Modern section card */
.section-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
}
.section-card-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--bg-card);
}
.section-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-card-body { padding: 28px; }

/* Glass card */
.glass-card {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

/* ============================================================
   STAT / KPI CARDS
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card:hover::after { opacity: 1; }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon.blue   { background: #DBEAFE; color: #2563EB; }
.stat-icon.green  { background: #D1FAE5; color: #059669; }
.stat-icon.purple { background: #EDE9FE; color: #7C3AED; }
.stat-icon.amber  { background: #FEF3C7; color: #D97706; }
.stat-icon.red    { background: #FEE2E2; color: #DC2626; }
.stat-icon.cyan   { background: #CFFAFE; color: #0891B2; }
.stat-icon.pink   { background: #FCE7F3; color: #BE185D; }
.stat-icon.teal   { background: #CCFBF1; color: #0F766E; }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--text-primary); line-height: 1; letter-spacing: -0.5px; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-change {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.stat-change.up   { background: #D1FAE5; color: #059669; }
.stat-change.down { background: #FEE2E2; color: #DC2626; }

/* ============================================================
   CONTROLS BAR
   ============================================================ */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.controls-bar .spacer { flex: 1; }
.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.search-input-wrap .search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}
.search-input-wrap input {
    padding-left: 36px;
    height: 38px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    width: 220px;
    background: var(--bg-card);
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
    transition: all var(--transition);
}
.search-input-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    width: 260px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: var(--radius); }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; box-shadow: var(--shadow-colored); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; box-shadow: 0 8px 25px -5px rgba(16,185,129,0.35); }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; color: white; }
.btn-secondary { background: var(--bg-card); color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg-body); color: var(--text-primary); border-color: #CBD5E1; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-body); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-soft-primary { background: var(--primary-50); color: var(--primary); border: none; }
.btn-soft-primary:hover { background: var(--primary-light); color: var(--primary-dark); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-card);
    transition: all var(--transition);
    outline: none;
    line-height: 1.5;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.form-help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* Form grid layouts */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* Form section card */
.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 20px;
}
.form-section-header {
    padding: 14px 20px;
    background: var(--bg-body);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.form-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}
.form-section-number {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.form-section-body { padding: 20px; }

/* File upload */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-body);
}
.file-upload:hover { border-color: var(--primary); background: var(--primary-50); }
.file-upload-icon { font-size: 36px; color: var(--text-muted); margin-bottom: 8px; }
.file-upload-text { font-size: 14px; color: var(--text-secondary); }

/* ============================================================
   TABLES
   ============================================================ */
.table-container { overflow-x: auto; border-radius: var(--radius-lg); }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.data-table thead th {
    padding: 11px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-body);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
table.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
table.data-table tbody tr { transition: background var(--transition); }
table.data-table tbody tr:hover { background: var(--primary-50); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES / STATUS PILLS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}
.badge-blue    { background: #DBEAFE; color: #1D4ED8; }
.badge-green   { background: #D1FAE5; color: #047857; }
.badge-purple  { background: #EDE9FE; color: #6D28D9; }
.badge-amber   { background: #FEF3C7; color: #B45309; }
.badge-red     { background: #FEE2E2; color: #B91C1C; }
.badge-gray    { background: #F1F5F9; color: #475569; }
.badge-cyan    { background: #CFFAFE; color: #0E7490; }
.badge-pink    { background: #FCE7F3; color: #BE185D; }
.badge-teal    { background: #CCFBF1; color: #0F766E; }
.badge-indigo  { background: #E0E7FF; color: #4338CA; }
.badge-dot::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.8;
}

/* ============================================================
   ALERTS / FLASH MESSAGES
   ============================================================ */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }
.alert-close {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition);
    background: none;
    border: none;
    font-size: 18px;
    color: inherit;
    padding: 0;
    line-height: 1;
}
.alert-close:hover { opacity: 1; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}
.empty-state-art {
    width: 120px; height: 120px;
    margin: 0 auto 24px;
    background: var(--bg-body);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    position: relative;
}
.empty-state-art::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: calc(var(--radius-xl) + 2px);
    background: linear-gradient(135deg, #DBEAFE, #EDE9FE);
    z-index: -1;
}
.empty-state-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.empty-state-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container { position: relative; width: 100%; height: 280px; }
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* ============================================================
   MASONRY / IMAGE GRID
   ============================================================ */
.masonry-grid { columns: 3; column-gap: 16px; }
.masonry-item {
    break-inside: avoid;
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.masonry-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-xl); }
.masonry-item img { width: 100%; display: block; cursor: pointer; }
.masonry-caption { padding: 12px 14px; font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.masonry-date { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
    animation: fadeIn 0.2s;
}
.lightbox-overlay.active { display: flex; }
.lightbox-img { max-width: 90vw; max-height: 85vh; border-radius: var(--radius); box-shadow: var(--shadow-xl); }
.lightbox-close {
    position: absolute;
    top: 20px; right: 24px;
    width: 44px; height: 44px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* ============================================================
   MODAL
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1E3A8A 0%, #312E81 50%, #4C1D95 100%);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-2xl);
    padding: 40px;
    box-shadow: var(--shadow-xl);
}
.auth-logo {
    width: 64px; height: 64px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #3B82F6, #7C3AED);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    margin: 0 auto 20px;
    box-shadow: 0 8px 20px rgba(37,99,235,0.35);
}
.auth-title { font-size: 24px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.auth-subtitle { font-size: 14px; color: var(--text-muted); text-align: center; margin-bottom: 32px; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    margin-top: 24px;
}
.pagination a, .pagination span {
    padding: 7px 13px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
}
.pagination a { color: var(--text-secondary); background: var(--bg-card); border: 1px solid var(--border); }
.pagination a:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary); }
.pagination .active { background: var(--primary); color: white; border: 1px solid var(--primary); }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* ============================================================
   SPINNER / LOADING
   ============================================================ */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(4px);
}
.loading-overlay.active { display: flex; }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar-wrap {
    background: var(--bg-body);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.6s ease;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Hover lift */
.hover-lift { transition: all var(--transition); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 13px 18px;
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
    border-left: 4px solid var(--primary);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .btn-sidebar-toggle { display: flex; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .masonry-grid { columns: 2; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .content-area { padding: 16px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .masonry-grid { columns: 1; }
    .form-row { grid-template-columns: 1fr; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr; }
    .card-body { padding: 16px; }
    .section-card-body { padding: 16px; }
    .main-header { padding: 0 16px; }
    .auth-card { padding: 24px; }
    .controls-bar { gap: 8px; }
    .search-input-wrap input { width: 100%; }
    .search-input-wrap input:focus { width: 100%; }
    table.data-table { font-size: 13px; border: 0; }
    table.data-table thead { display: none; }
    table.data-table tr {
        display: block;
        margin-bottom: 14px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: white;
        padding: 8px 0;
        box-shadow: var(--shadow-sm);
    }
    table.data-table td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        border-bottom: 1px solid var(--border-light);
        padding: 10px 16px;
    }
    table.data-table td:last-child { border-bottom: 0; align-items: stretch; }
    table.data-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        text-transform: uppercase;
        color: var(--text-muted);
        font-size: 10px;
        margin-bottom: 5px;
        letter-spacing: 0.5px;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 22px; }
.text-2xl { font-size: 28px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-extrabold { font-weight: 800; }
.leading-tight { line-height: 1.25; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.p-0 { padding: 0; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.rounded-full { border-radius: var(--radius-full); }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.opacity-50 { opacity: 0.5; }
.opacity-70 { opacity: 0.7; }
.border-0 { border: none !important; }
.shadow-none { box-shadow: none !important; }
.bg-white { background: white; }
.bg-body { background: var(--bg-body); }
