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

:root {
    --primary: #1a56db;
    --primary-dark: #1e429f;
    --primary-light: #e8f0fe;
    --success: #0e9f6e;
    --warning: #c27803;
    --danger: #e02424;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

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

body {
    font-family: 'Sarabun', sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    font-size: 15px;
    line-height: 1.6;
}

/* ===== LOGIN ===== */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a56db 0%, #1e429f 50%, #0f2980 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo img {
    height: 80px;
    object-fit: contain;
}

.login-logo h2 {
    margin-top: 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-dark);
}

.login-logo p {
    font-size: 13px;
    color: var(--gray-500);
}

/* ===== LAYOUT ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, #1a56db 0%, #1e429f 100%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform .3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(255,255,255,.2);
    padding: 4px;
}

.sidebar-header h1 {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.sidebar-header p {
    font-size: 11px;
    color: rgba(255,255,255,.7);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-section {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,.5);
    text-transform: uppercase;
    letter-spacing: .1em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: 14px;
    transition: all .2s;
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.nav-item:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,.2);
    color: #fff;
    border-left-color: #fff;
    font-weight: 600;
}

.nav-item .icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.15);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    background: rgba(255,255,255,.1);
}

.user-avatar {
    width: 36px; height: 36px;
    background: rgba(255,255,255,.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.user-info-text .name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.user-info-text .role {
    font-size: 11px;
    color: rgba(255,255,255,.65);
}

/* ===== MAIN CONTENT ===== */
.main-wrap {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--gray-700);
}

.content {
    flex: 1;
    padding: 24px;
}

/* ===== CARDS ===== */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.card-body { padding: 20px; }

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.blue { background: #e8f0fe; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.yellow { background: #fef3c7; }
.stat-icon.red { background: #fee2e2; }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Sarabun', sans-serif;
    color: var(--gray-900);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}

.form-control.is-invalid { border-color: var(--danger); }

select.form-control { cursor: pointer; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Sarabun', sans-serif;
    cursor: pointer;
    border: none;
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #057a55; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c81e1e; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: var(--warning); }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 13px 28px; font-size: 16px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: var(--gray-50);
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-warning { background: #fef3c7; color: #92400e; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { 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; }

/* ===== OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 20px;
    border-top: 1px solid var(--gray-100);
    justify-content: flex-end;
    flex-wrap: wrap;
}

.page-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1.5px solid var(--gray-200);
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    color: var(--gray-700);
    font-family: 'Sarabun', sans-serif;
    transition: all .2s;
}

.page-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== PRINT ===== */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-wrap { margin-left: 0; }
    .content { padding: 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .main-wrap {
        margin-left: 0;
    }
    .hamburger {
        display: block;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .content {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .login-box {
        padding: 28px 20px;
    }
    .topbar { padding: 0 16px; }
}
