:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', 'Sarabun', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.card {
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

h1,
h2,
h3 {
    margin-bottom: 1rem;
    color: var(--text-main);
}

/* Headings inside colored containers inherit parent color */
.summary-hero h1,
.summary-hero h2,
.summary-hero h3,
.summary-hero p {
    color: white;
}


.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background-color: #fff;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background-color: #f1f5f9;
    font-weight: 600;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-warning {
    background-color: #fef9c3;
    color: #854d0e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Dashboard layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    border-left: 4px solid var(--primary);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* ─── Badge Info ─────────────────────────────────────────── */
.badge-info {
    background-color: #e0f2fe;
    color: #075985;
}

/* ─── Button Outline ────────────────────────────────────── */
.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

/* ─── text-muted ─────────────────────────────────────────── */
.text-muted {
    color: var(--text-muted);
}

.text-success {
    color: var(--success);
}

/* ─── Mobile-first responsive ────────────────────────────── */

/* Tables: allow horizontal scroll on small screens */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Responsive grid: collapse to single column on mobiles */
@media (max-width: 640px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .card {
        padding: 1.25rem;
        border-radius: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* Compact table cells */
    th,
    td {
        padding: 0.6rem 0.75rem;
        font-size: 0.82rem;
    }

    /* Stack header flex rows */
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    /* Progress bar header info */
    .progress-header-bar {
        width: 100%;
        flex-wrap: wrap;
    }

    h1 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 1rem;
    }

    /* Hide less important columns on mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* ─── Table Toolbar (search + filter + per-page) ─────────── */
.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.table-toolbar input[type="text"] {
    flex: 1;
    min-width: 160px;
    max-width: 320px;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 0.6rem center;
    padding-left: 2rem;
}

.table-toolbar select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
    width: auto;
    min-width: 130px;
}

.table-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}

/* ─── Pagination ─────────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    justify-content: center;
}

.page-btn {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    background: white;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.15s;
    color: var(--text-main);
}

.page-btn:hover:not(.disabled):not(.active) {
    background: #f1f5f9;
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
}

.page-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}