:root {
    --bg-color: #F4F7F6; /*rgb(241, 226, 209);*/
    --surface-color: #FFFFFF; /* #fffdfa; */
    --primary-color:#256C67;  /* rgb(129, 11, 56); */
    --primary-dark: #123B38;
    --primary-soft: #DDEBE8;
    --accent-color: #D87332;
    --secondary-color: #D8E3E0; /* rgb(220, 195, 170); */
    --text-main: #182724; /* rgb(84, 26, 26); */
    --text-muted: #5F716D; /* #8a6d6d; */
    
    /* Badge colors */
    /* --badge-high: rgb(129, 11, 56);
    --badge-medium: #d48b41;
    --badge-low: #5a8264; */
    /* Priority: burnt orange */
    --badge-high-bg: #EA580C;
    --badge-high-text: #FFFFFF;
    
    --badge-medium-bg: #FB923C;
    --badge-medium-text: #FFFFFF;
    
    --badge-low-bg: #FFEDD5;
    --badge-low-text: #EA580C;  

    /* Status: teal */
    --badge-done-bg: #0D9488;
    --badge-done-text: #FFFFFF;
    
    --badge-pending-bg: #CCFBF1;
    --badge-pending-text: #0D9488;

}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Be Vietnam Pro', 'Segoe UI', Tahoma, sans-serif;
    background:
        radial-gradient(circle at 12% 0%, rgba(216, 115, 50, 0.09), transparent 28%),
        linear-gradient(180deg, #F7FAF8 0%, var(--bg-color) 46%, #EEF5F2 100%);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100dvh;
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.btn-primary:hover { opacity: 0.96; transform: translateY(-1px); }
.btn-primary:focus-visible,
.btn-outline:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(216, 115, 50, 0.28);
    outline-offset: 3px;
}
.btn-outline {
    min-height: 40px;
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------------- LOGIN PAGE ---------------- */
.login-body {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background:
        radial-gradient(circle at 14% 18%, rgba(216, 115, 50, 0.18), transparent 26%),
        linear-gradient(135deg, #EEF5F2 0%, #F9F5EE 54%, #DFECE8 100%);
}
.login-container {
    display: grid;
    grid-template-columns: minmax(280px, 0.92fr) minmax(320px, 1.08fr);
    width: min(960px, 100%);
    min-height: 560px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(18, 59, 56, 0.12);
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 28px 70px rgba(18, 59, 56, 0.18);
}
.login-banner {
    position: relative;
    color: #F9FCFB;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background:
        linear-gradient(150deg, rgba(18, 59, 56, 0.96), rgba(37, 108, 103, 0.92)),
        repeating-linear-gradient(135deg, rgba(255,255,255,0.08) 0 1px, transparent 1px 18px);
}
.login-banner::before {
    content: "";
    position: absolute;
    inset: 24px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 22px;
    pointer-events: none;
}
.login-brand-mark {
    position: absolute;
    top: 42px;
    left: 48px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 800;
    letter-spacing: 0.04em;
}
.login-banner h1 {
    position: relative;
    max-width: 8ch;
    font-size: clamp(42px, 6vw, 68px);
    line-height: 0.95;
    letter-spacing: -0.04em;
    margin-bottom: 20px;
}
.login-banner p {
    position: relative;
    max-width: 320px;
    color: rgba(249, 252, 251, 0.82);
    font-size: 17px;
}
.login-proof {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 34px;
}
.login-proof span {
    padding: 8px 11px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    color: rgba(249, 252, 251, 0.86);
    font-size: 12px;
    font-weight: 700;
}
.login-form-wrapper {
    padding: clamp(28px, 6vw, 64px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.login-form {
    width: min(100%, 420px);
    margin: 0 auto;
}
.login-eyebrow {
    color: var(--accent-color);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.login-form h2 {
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1.1;
    letter-spacing: -0.04em;
    margin-bottom: 12px;
}
.login-helper {
    color: var(--text-muted);
    margin-bottom: 30px;
}
.login-submit {
    width: 100%;
    min-height: 50px;
    margin-top: 10px;
    border-radius: 12px;
    background: var(--primary-dark);
    box-shadow: 0 12px 24px rgba(18, 59, 56, 0.2);
}

.input-group { margin-bottom: 15px; }
.input-group label { display: block; font-size: 14px; margin-bottom: 7px; font-weight: 700; }
.input-group input, .input-group select, .input-group textarea {
    width: 100%;
    min-height: 44px;
    padding: 11px 12px;
    border: 1px solid var(--secondary-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--text-main);
    font: inherit;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    border-color: var(--primary-color);
    background: var(--surface-color);
    box-shadow: 0 0 0 4px rgba(37, 108, 103, 0.12);
    outline: none;
}

/* ---------------- WORKSPACE ---------------- */
.top-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(16px);
    padding: 14px clamp(18px, 5vw, 48px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(18, 59, 56, 0.1);
}
.top-header .user-info {
    display: flex;
    align-items: center;
    gap: 24px;
}
.top-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
}
.logo-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--primary-dark);
    color: white;
    font-size: 13px;
    letter-spacing: 0.04em;
}
.top-header .user-info .btn-outline {
    border: 1px solid var(--secondary-color);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
}
.top-header .user-info .btn-outline:hover {
    border-color: #ef4444;
    color: #ef4444;
    background-color: #fef2f2;
}

.workspace { max-width: 1120px; margin: 34px auto 56px; padding: 0 20px; }
.workspace-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 26px;
}
.workspace-eyebrow {
    color: var(--accent-color);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.workspace-hero h1 {
    max-width: 680px;
    font-size: clamp(34px, 5vw, 56px);
    line-height: 1.02;
    letter-spacing: -0.045em;
}
.workspace-primary-action {
    min-width: 132px;
    background: var(--primary-dark);
    box-shadow: 0 12px 26px rgba(18, 59, 56, 0.18);
}

/* Stats */
.stats-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card {
    background: rgba(255, 255, 255, 0.84);
    padding: 22px;
    border-radius: 18px;
    box-shadow: 0 18px 38px rgba(18, 59, 56, 0.08);
    border: 1px solid rgba(18, 59, 56, 0.1);
}
.stat-card h3 { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card p { font-size: 36px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; }
.pending-value { color: var(--accent-color); }
.done-value { color: var(--primary-color); }

/* Action Bar */
.action-bar {
    display: grid;
    grid-template-columns: minmax(360px, auto) minmax(260px, 1fr);
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(18, 59, 56, 0.1);
    border-radius: 18px;
}
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.filters select, .filters input[type="date"] {
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--secondary-color);
    background: var(--surface-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 15px;
}

.search-box {
    position: relative;
}
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}
.search-box input {
    width: 100%;
    min-height: 44px;
    padding: 10px 15px 10px 42px;
    border-radius: 12px;
    border: 1px solid var(--secondary-color);
    background: var(--surface-color);
    color: var(--text-main);
    font: inherit;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 108, 103, 0.12);
    outline: none;
}

/* Task Grid */
.task-list-header {
    display: grid;
    grid-template-columns: minmax(280px, 3fr) minmax(100px, 1fr) minmax(120px, 1fr) minmax(100px, 1fr) 60px;
    padding: 14px 18px;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.task-item {
    display: grid;
    grid-template-columns: minmax(280px, 3fr) minmax(100px, 1fr) minmax(120px, 1fr) minmax(100px, 1fr) 60px;
    background: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
    padding: 16px 18px;
    border-radius: 16px;
    align-items: center;
    border: 1px solid rgba(18, 59, 56, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.task-item:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(18, 59, 56, 0.08); }

.task-info h4 { margin-bottom: 5px; font-size: 16px; }
.task-info p { font-size: 13px; color: var(--text-muted); }
.task-cell {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
}
.task-empty {
    padding: 34px;
    border: 1px dashed var(--secondary-color);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.64);
    text-align: center;
}
.task-empty h4 { font-size: 20px; margin-bottom: 6px; }
.task-empty p { color: var(--text-muted); }

/* Badges */
.badge {
    min-width: 76px;
    text-align: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    display: inline-block;
}
.badge.high { background: var(--badge-high-bg); color: var(--badge-high-text); }
.badge.medium { background: var(--badge-medium-bg); color: var(--badge-medium-text); }
.badge.low { background: var(--badge-low-bg); color: var(--badge-low-text); }

.badge.pending { background: var(--badge-pending-bg); color: var(--badge-pending-text); }
.badge.done { background: var(--badge-done-bg); color: var(--badge-done-text); }

.task-actions { display: flex; justify-content: flex-end; }
.task-actions button { background: none; border: none; cursor: pointer; color: var(--primary-color); font-weight: bold; padding: 5px;}

/* Modal (Popup) */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    width: 100%;
    height: 100%;
    padding: 20px;
    background: rgba(18, 39, 36, 0.48);
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: var(--surface-color);
    padding: 30px;
    border-radius: 18px;
    width: 520px;
    max-width: 100%;
    max-height: calc(100dvh - 40px);
    overflow: auto;
    box-shadow: 0 24px 70px rgba(18, 39, 36, 0.24);
}
.modal-content h2 {
    margin-bottom: 20px;
    font-size: 28px;
    letter-spacing: -0.03em;
}
.flex-row { display: flex; gap: 15px; }
.flex-row .input-group { flex: 1; }
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 10px; }

/* Responsive: mobile */
@media (max-width: 768px) {
    .login-body { padding: 16px; align-items: flex-start; }
    .login-container { grid-template-columns: 1fr; min-height: auto; border-radius: 20px; }
    .login-banner { min-height: 330px; padding: 94px 28px 28px; }
    .login-brand-mark { top: 28px; left: 28px; }
    .login-banner h1 { font-size: 40px; margin-bottom: 16px; }
    .login-banner p { font-size: 16px; }
    .login-proof { margin-top: 24px; }
    .login-banner::before { inset: 16px; border-radius: 16px; }
    .login-form-wrapper { padding: 28px 22px; }
    .login-helper { margin-bottom: 22px; }
    .login-form { width: 100%; }
    .top-header { align-items: flex-start; gap: 14px; }
    .top-header .user-info { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
    .workspace { margin-top: 26px; padding: 0 16px; }
    .workspace-hero { align-items: stretch; flex-direction: column; }
    .workspace-primary-action { width: 100%; }
    .stats-container { grid-template-columns: 1fr; }
    .action-bar { grid-template-columns: 1fr; gap: 12px; }
    .filters { display: grid; grid-template-columns: 1fr; }
    .task-list-header { display: none; }
    .task-item { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
    .task-cell {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
    }
    .task-cell::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 12px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }
    .task-actions { justify-content: flex-start; }
    .flex-row { flex-direction: column; gap: 0; }
}

/* ================= ACTION DROPDOWN MENU ================= */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.btn-dots {
    background: none;
    border: none;
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0 10px;
    letter-spacing: 2px;
}

/* Hidden menu container */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: var(--surface-color);
    min-width: 130px;
    box-shadow: 0px 8px 16px rgba(84, 26, 26, 0.15); 
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    z-index: 10;
    overflow: hidden;
}

/* JS toggles this class to show the menu */
.dropdown-menu.show {
    display: flex;
    flex-direction: column;
}

/* Dropdown action buttons */
.dropdown-menu button {
    background: none;
    border: none;
    padding: 12px 15px;
    text-align: left;
    cursor: pointer;
    color: var(--text-main);
    font-size: 14px;
    width: 100%;
    transition: background-color 0.2s;
}

.dropdown-menu button:hover {
    background-color: var(--bg-color);
}

/* Destructive action */
.dropdown-menu button.delete-btn {
    color: #d32f2f; 
    border-top: 1px solid #f0e6e6;
}
.dropdown-menu button.delete-btn:hover {
    background-color: #fce4e4; 
}

/* ================= COMPLETED TASK STATE ================= */
.task-item.task-completed {
    opacity: 0.55;
    background-color: transparent;
    border: 1px dashed var(--secondary-color);
    box-shadow: none;
}

.task-item.task-completed:hover {
    transform: none;
}

.task-item.task-completed .task-info h4 {
    text-decoration: line-through;
    color: var(--text-muted);
}


/* ================= HIỆU ỨNG THÔNG BÁO LỖI ================= */
.auth-error {
    background-color: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FCA5A5;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    display: none; /* Mặc định ẩn, chỉ hiện khi có lỗi do JS kích hoạt */
    text-align: center;
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.05);
}