:root {
    /* Color Palette - Tailwind-inspired */
    --primary-color: #3b82f6;
    /* Blue 500 */
    --primary-hover: #2563eb;
    /* Blue 600 */
    --primary-light: #eff6ff;
    /* Blue 50 */
    --secondary-color: #64748b;
    /* Slate 500 */
    --background-color: #f8fafc;
    /* Slate 50 */
    --surface-color: #ffffff;
    --text-color: #1e293b;
    /* Slate 800 */
    --text-muted: #64748b;
    /* Slate 500 */
    --border-color: #e2e8f0;
    /* Slate 200 */

    /* Semantic Colors */
    --success-color: #10b981;
    /* Emerald 500 */
    --success-light: #d1fae5;
    /* Emerald 100 */
    --warning-color: #f59e0b;
    /* Amber 500 */
    --warning-light: #fef3c7;
    /* Amber 100 */
    --danger-color: #ef4444;
    /* Red 500 */
    --danger-light: #fee2e2;
    /* Red 100 */
    --info-color: #0ea5e9;
    /* Sky 500 */
    --info-light: #e0f2fe;
    /* Sky 100 */

    /* Layout & Metics */
    --sidebar-width: 260px;
    --header-height: 64px;

    /* Shadows - Soft and modern */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-floating: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================= Reset & Typography ================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-color);
    font-weight: 600;
    line-height: 1.2;
    margin-top: 0;
}

p {
    margin-top: 0;
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
}

/* ================= Layout Structure ================= */
.wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100%;
    overflow-y: auto;
    z-index: 50;
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--surface-color);
    letter-spacing: -0.025em;
}

.sidebar-menu {
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-link i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 0.75rem;
    text-align: center;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.nav-link:hover {
    background-color: var(--background-color);
    color: var(--text-color);
}

.nav-link:hover i {
    opacity: 1;
}

.nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary-hover);
    font-weight: 600;
}

.nav-link.active i {
    color: var(--primary-color);
    opacity: 1;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    max-width: 100%;
    transition: margin-left var(--transition-normal);
}

/* ================= Mobile Header & Overlay ================= */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    z-index: 40;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.mobile-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.mobile-toggle-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.mobile-toggle-btn:active {
    background-color: var(--background-color);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    /* Slate 900 with opacity */
    backdrop-filter: blur(2px);
    z-index: 45;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ================= Components ================= */

/* --- Cards --- */
.card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    letter-spacing: -0.025em;
}

/* --- Buttons --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    background-color: var(--primary-color);
    color: white;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    color: white;
    /* Ensure text stays white on hover */
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success-color);
}

.btn-success:hover {
    background-color: #059669;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: #d97706;
}

/* --- Form Controls --- */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    background-color: var(--surface-color);
    color: var(--text-color);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    /* Soft blue glow */
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Input Groups */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    flex: 1 1 auto;
    width: 1%;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--secondary-color);
    text-align: center;
    white-space: nowrap;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-right: none;
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
}

/* --- Tables --- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    /* For rounded corners on the table container */
    background: var(--surface-color);
}

table.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    text-align: left;
}

.table th {
    background-color: var(--background-color);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 0.95rem;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-hover tbody tr:hover {
    background-color: var(--background-color);
}

/* --- Badges --- */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    white-space: nowrap;
}

/* --- Alerts --- */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.alert-success {
    background-color: var(--success-light);
    color: #065f46;
    border-color: #a7f3d0;
}

.alert-danger {
    background-color: var(--danger-light);
    color: #991b1b;
    border-color: #fecaca;
}

.alert-info {
    background-color: var(--info-light);
    color: #075985;
    border-color: #bae6fd;
}

.alert-warning {
    background-color: var(--warning-light);
    color: #92400e;
    border-color: #fde68a;
}

/* ================= Utilities ================= */
.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.align-center {
    align-items: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

.w-100 {
    width: 100%;
}

.text-center {
    text-align: center;
}

.text-end {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.font-bold {
    font-weight: 700;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.p-2 {
    padding: 0.5rem;
}

.p-3 {
    padding: 1rem;
}

.p-4 {
    padding: 1.5rem;
}

/* ================= Mobile Responsiveness ================= */
@media (max-width: 992px) {
    .main-content {
        padding: 1.5rem;
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-floating);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: calc(var(--header-height) + 1rem);
        /* Space for mobile header */
    }

    .mobile-header {
        display: flex;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    /* Make buttons full width on small screens if they are stacked */
    .mobile-full-btn {
        width: 100%;
        justify-content: center;
    }

    /* Larger touch targets for mobile inputs */
    .form-control {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .btn-primary {
        padding: 0.75rem 1.25rem;
    }

    /* Fix table responsiveness visual */
    .table-responsive {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-left: -1.25rem;
        margin-right: -1.25rem;
        width: calc(100% + 2.5rem);
    }

    .table th:first-child,
    .table td:first-child {
        padding-left: 1.25rem;
    }

    .table th:last-child,
    .table td:last-child {
        padding-right: 1.25rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    /* Slightly smaller base font on very small generic devices */
}