:root {
    --sidebar-bg: #10223f;
    --sidebar-bg-2: #142b4f;
    --accent: #1f6feb;
    --accent-2: #5aa8ff;
    --accent-soft: #e9f2ff;
    --surface: #ffffff;
    --surface-2: #f7faff;
    --surface-3: #f1f5fb;
    --app-bg: #edf2f8;
    --text: #132238;
    --muted: #65748b;
    --border: #dbe4f0;
    --success-soft: #e9f9f0;
    --warning-soft: #fff5df;
    --danger-soft: #fdeceb;
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 18px;
    --shadow-sm: 0 4px 12px rgba(17, 40, 78, 0.08);
    --shadow: 0 12px 30px rgba(17, 40, 78, 0.12);
    --shadow-lg: 0 20px 45px rgba(17, 40, 78, 0.18);
}

html[data-theme='dark'] {
    --sidebar-bg: #0c1527;
    --sidebar-bg-2: #101d35;
    --accent: #4d91ff;
    --accent-2: #7eb5ff;
    --accent-soft: #1b2a46;
    --surface: #171f34;
    --surface-2: #1d2742;
    --surface-3: #24304f;
    --app-bg: #0e1424;
    --text: #edf3ff;
    --muted: #a6b4cd;
    --border: #2d3b5f;
    --success-soft: #143325;
    --warning-soft: #3d300f;
    --danger-soft: #3f1b1f;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.28);
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 20px 45px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at 0% -20%, rgba(31, 111, 235, 0.14), transparent 36%),
        radial-gradient(circle at 100% 0%, rgba(16, 34, 63, 0.1), transparent 32%),
        var(--app-bg);
    color: var(--text);
    line-height: 1.45;
}

a {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    min-height: 100vh;
    position: sticky;
    top: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-sm);
}

.sidebar .brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px !important;
    padding-bottom: 20px !important;
}

.sidebar .brand h5 {
    font-weight: 700;
    letter-spacing: 0.3px;
}

.sidebar .nav {
    margin-top: 10px;
}

.sidebar .nav-link {
    color: #dfe9ff;
    border-radius: 12px;
    margin: 4px 0;
    padding: 11px 12px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all .18s ease;
}

.sidebar .nav-link i {
    width: 18px;
    text-align: center;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: translateX(2px);
}

.sidebar .nav-link.text-danger {
    color: #ffb4b4 !important;
}

.main-content {
    padding: 26px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.topbar h4 {
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.content-card {
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.content-card + .content-card {
    margin-top: 14px;
}

.content-card h4,
.content-card h5,
.content-card h6 {
    font-weight: 700;
    margin-bottom: 14px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    border-left: 4px solid var(--accent);
}

.stat-card::after {
    content: "";
    position: absolute;
    right: -20px;
    top: -20px;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(31, 111, 235, 0.2), transparent 70%);
}

.stat-card small {
    color: var(--muted);
    font-weight: 600;
}

.stat-card h3,
.stat-card h4 {
    margin: 8px 0 0;
    font-weight: 700;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    border-color: var(--border);
    border-radius: var(--radius-sm);
    min-height: 42px;
    padding: 9px 12px;
    background-color: var(--surface);
    color: var(--text);
}

.form-control::placeholder {
    color: #97a5bf;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(31, 111, 235, 0.16);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-sm {
    min-height: 32px;
}

.btn-primary {
    background: linear-gradient(180deg, var(--accent), #175fca);
    border-color: #175fca;
}

.btn-primary:hover {
    background: linear-gradient(180deg, #246fdc, #1558bd);
    border-color: #1558bd;
}

.btn-outline-primary {
    border-color: rgba(31, 111, 235, 0.35);
    color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent-soft);
    color: #0f3571;
}

.alert {
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}

.table {
    margin-bottom: 0;
    color: var(--text);
    vertical-align: middle;
}

.table-responsive {
    border-radius: var(--radius-sm);
}

.table > :not(caption) > * > * {
    border-color: var(--border);
    padding: 11px 12px;
}

.table thead th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    background: var(--surface-3);
    font-weight: 700;
}

.table tbody tr:hover {
    background: rgba(31, 111, 235, 0.05);
}

.table td form {
    margin: 0;
}

.task-table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

#newTaskTable {
    min-width: 1400px;
    margin-bottom: 0;
}

#newTaskTable thead th {
    white-space: nowrap;
}

.tasklist-dropdown .dropdown-menu {
    max-height: 280px;
    overflow-y: auto;
}

.tasklist-dropdown .dropdown-item {
    white-space: normal;
}

.table-danger-soft {
    background-color: var(--danger-soft) !important;
}

.table-warning-soft {
    background-color: var(--warning-soft) !important;
}

.table-success-soft {
    background-color: var(--success-soft) !important;
}

.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 10px;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    background-color: var(--surface);
    color: var(--text);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--accent-soft) !important;
    border: 1px solid transparent !important;
    color: var(--accent) !important;
}

.badge {
    font-weight: 700;
    letter-spacing: 0.2px;
    padding: 6px 8px;
}

.priority-badge {
    color: #000 !important;
}

.priority-badge.urgent {
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.06);
    }
    100% {
        transform: scale(1);
    }
}

.list-group-item {
    border-color: var(--border);
    background: transparent;
    color: var(--text);
}

.nav-tabs {
    border-bottom-color: var(--border);
}

.nav-tabs .nav-link {
    color: var(--muted);
    border-radius: 10px 10px 0 0;
    border: 1px solid transparent;
    font-weight: 600;
}

.nav-tabs .nav-link.active {
    color: var(--accent);
    background: var(--surface);
    border-color: var(--border) var(--border) transparent;
}

.modal-content {
    border-radius: var(--radius);
    border-color: var(--border);
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    box-shadow: var(--shadow-lg);
}

.modal-header,
.modal-footer {
    border-color: var(--border);
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.22), transparent 32%), linear-gradient(135deg, #0f2549, #1f6feb);
}

.auth-card {
    width: 100%;
    max-width: 500px;
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid #d9e4f3;
    padding: 28px;
    box-shadow: var(--shadow-lg);
}

.auth-card h4 {
    margin-bottom: 16px;
    font-weight: 700;
}

canvas {
    max-height: 320px;
}

.flatpickr-calendar {
    border-radius: 10px;
    border-color: var(--border);
    box-shadow: var(--shadow);
}

.swal2-popup {
    border-radius: 14px !important;
}

@media (max-width: 1200px) {
    .main-content {
        padding: 20px;
    }
}

@media (max-width: 992px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
        position: static;
    }

    .main-content {
        padding: 16px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 576px) {
    .content-card {
        padding: 14px;
    }

    .table > :not(caption) > * > * {
        padding: 9px 8px;
        font-size: 13px;
    }

    .btn {
        width: 100%;
    }
}
