/* ================================================================
 *  STYLE — TaskFlow-inspired design system
 *  Fonts: Inter (body), Plus Jakarta Sans (display)
 *  Palette: Indigo/Violet/Slate with glass morphism
 * ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
    --brand-50:  #eef2ff;  --brand-100: #e0e7ff;  --brand-200: #c7d2fe;
    --brand-300: #a5b4fc;  --brand-400: #818cf8;  --brand-500: #6366f1;
    --brand-600: #4f46e5;  --brand-700: #4338ca;  --brand-800: #3730a3;
    --red-soft: #fef2f2;   --red-border: #fecaca;
    --amber-soft: #fffbeb; --amber-border: #fde68a;
    --green-soft: #f0fdf4; --green-border: #bbf7d0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
    --shadow-xl: 0 20px 48px rgba(0,0,0,0.1);
    --radius-sm: 10px; --radius-md: 14px; --radius-lg: 20px; --radius-xl: 24px;
    --surface-1: #ffffff;   --surface-2: #f8fafc;    --surface-3: #f1f5f9;
    --text-primary: #1e293b; --text-secondary: #64748b; --text-muted: #94a3b8;
    --border-default: #e2e8f0; --border-subtle: #f1f5f9;
}

* { font-family: 'Inter', system-ui, -apple-system, sans-serif; }
body {
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 50%, #f5f3ff 100%);
    min-height: 100vh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Scrollbar — Webkit + Firefox */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }

/* ================================================================
 *  ANIMATIONS
 * ================================================================ */
.sortable-ghost { opacity: 0.4; background: #f0f9ff !important; border: 2px dashed #6366f1 !important; }
.sortable-chosen { box-shadow: 0 8px 24px rgba(99,102,241,0.3) !important; transform: scale(1.02); z-index: 10; }
.sortable-drag { opacity: 0.9; cursor: grabbing !important; }

.dependency-badge {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 2px 6px; background: #f5f3ff; color: #7c3aed;
    border: 1px solid #ddd6fe; border-radius: 10px; font-size: 10px; font-weight: 500;
}

/* ================================================================
 *  GANTT CHART STYLES
 * ================================================================ */
.gantt-mode-btn { background: #f1f5f9; color: #64748b; border: none; cursor: pointer; transition: all 0.2s; }
.gantt-mode-btn:hover { background: #e2e8f0; }

/* Gantt bar colors by priority */
.gantt-bar-done .bar     { fill: #22c55e !important; }
.gantt-bar-done .bar-progress { fill: #16a34a !important; }
.gantt-bar-high .bar     { fill: #ef4444 !important; }
.gantt-bar-high .bar-progress { fill: #dc2626 !important; }
.gantt-bar-medium .bar   { fill: #f59e0b !important; }
.gantt-bar-medium .bar-progress { fill: #d97706 !important; }
.gantt-bar-low .bar      { fill: #3b82f6 !important; }
.gantt-bar-low .bar-progress { fill: #2563eb !important; }
.gantt-bar-none .bar     { fill: #94a3b8 !important; }
.gantt-bar-none .bar-progress { fill: #64748b !important; }

/* Gantt popup */
.gantt-popup {
    background: white; border-radius: 10px; padding: 12px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15); min-width: 200px; max-width: 300px; font-size: 13px;
}
.gantt-popup h5 { font-weight: 600; color: #1e293b; margin-bottom: 8px; font-size: 14px; }
.gantt-popup p { color: #64748b; margin: 2px 0; }
.gantt-popup .desc { color: #94a3b8; font-size: 12px; margin-top: 6px; font-style: italic; }

/* Override Frappe Gantt defaults */
.gantt .grid-header { fill: #f8fafc !important; stroke: #e2e8f0 !important; }
.gantt .grid-row:nth-child(even) { fill: #f8fafc !important; }
.gantt .grid-row { fill: white !important; }
.gantt .lower-text, .gantt .upper-text { fill: #64748b !important; font-size: 11px !important; }
.gantt .bar-wrapper:hover .bar { filter: brightness(1.1); }
.gantt .arrow { stroke: #c7d2fe !important; stroke-width: 1.5 !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.15); } 50% { box-shadow: 0 0 0 6px rgba(239,68,68,0.06); } }
@keyframes progressStripe { 0% { background-position: 1rem 0; } 100% { background-position: 0 0; } }
@keyframes checkPop { 0% { transform: scale(0); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.anim-fade-in   { animation: fadeUp 0.3s ease-out forwards; }
.anim-spin      { animation: spin 0.8s linear infinite; }
.anim-pulse     { animation: pulse 2s ease-in-out infinite; }
.anim-slide-in  { animation: slideInRight 0.35s ease-out forwards; }

/* View transitions (todo ↔ weekly) */
.view-fade-in  { animation: fadeUp 0.25s ease-out forwards !important; }
.view-fade-out { animation: fadeOut 0.12s ease-in forwards !important; }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ================================================================
 *  AUTH PAGE
 * ================================================================ */
#authView {
    min-height: 100vh; display: none; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 50%, #f5f3ff 100%);
}
.auth-card {
    background: white; border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
    padding: 40px; width: 100%; max-width: 400px; border: 1px solid #e2e8f0;
}
.auth-title {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 24px; font-weight: 800; color: #1e293b; text-align: center;
}
.auth-subtitle { font-size: 14px; color: #64748b; text-align: center; margin-top: 6px; }

/* ================================================================
 *  GLASS CARDS
 * ================================================================ */
.glass {
    background: rgba(255,255,255,0.7); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}
.glass-strong {
    background: rgba(255,255,255,0.85); backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.4); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* ================================================================
 *  HEADER
 * ================================================================ */
header {
    background: rgba(255,255,255,0.85); backdrop-filter: blur(12px);
    border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; z-index: 40;
}
.header-title {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 20px; font-weight: 800; color: #1e293b;
}
.header-subtitle { font-size: 12px; color: #94a3b8; }

/* ================================================================
 *  CUSTOM CHECKBOX
 * ================================================================ */
.custom-checkbox {
    appearance: none; -webkit-appearance: none;
    width: 20px; height: 20px; border: 2px solid #cbd5e1; border-radius: 6px;
    cursor: pointer; position: relative; transition: all 0.2s; flex-shrink: 0;
}
.custom-checkbox:hover { border-color: var(--brand-400); background: var(--brand-50); }
.custom-checkbox:checked { background: var(--brand-600); border-color: var(--brand-600); }
.custom-checkbox:checked::after {
    content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
    font-size: 12px; color: white; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

/* ================================================================
 *  TASK CARDS
 * ================================================================ */
.task-card {
    background: white; border-radius: var(--radius-md); border: 1px solid #e2e8f0;
    transition: all 0.2s ease; position: relative; overflow: hidden; cursor: grab;
}
.task-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: #cbd5e1; }
.task-card.completed { opacity: 0.6; background: #f8fafc; }
.task-card.completed .task-title { text-decoration: line-through; color: #94a3b8; }
.task-card.overdue { animation: pulseGlow 2.5s infinite; }

.task-card.priority-high   { border-left: 4px solid #ef4444; }
.task-card.priority-medium { border-left: 4px solid #f59e0b; }
.task-card.priority-low    { border-left: 4px solid #3b82f6; }
.task-card.priority-none   { border-left: 4px solid #9ca3af; }

.task-card.completed.priority-high,
.task-card.completed.priority-medium,
.task-card.completed.priority-low,
.task-card.completed.priority-none { border-left: 4px solid #22c55e; }

/* Priority badge */
.priority-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 9999px; font-size: 10px; font-weight: 600; line-height: 1.4;
}
.priority-badge.high   { background: #fef2f2; color: #dc2626; }
.priority-badge.medium { background: #fffbeb; color: #d97706; }
.priority-badge.low    { background: #eff6ff; color: #2563eb; }
.priority-badge.none   { background: #f8fafc; color: #64748b; }

.priority-dot { width: 6px; height: 6px; border-radius: 50%; }
.priority-dot.high   { background: #ef4444; }
.priority-dot.medium { background: #f59e0b; }
.priority-dot.low    { background: #3b82f6; }
.priority-dot.none   { background: #94a3b8; }

/* Overdue badge */
.overdue-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 8px; border-radius: 9999px; font-size: 10px;
    font-weight: 600; background: #fef2f2; color: #dc2626;
    animation: pulseGlow 2.5s infinite;
}

/* Recurrence badge */
.recurrence-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 9999px;
    background: #f5f3ff; color: #7c3aed; font-weight: 500;
}

/* Action buttons */
.task-action-btn {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; color: #94a3b8; transition: all 0.15s;
    background: none; border: none; cursor: pointer;
}
.task-action-btn:hover { background: #f1f5f9; }
.task-action-btn.edit:hover   { color: #3b82f6; background: #eff6ff; }
.task-action-btn.delete:hover { color: #ef4444; background: #fef2f2; }
.task-action-btn.restore:hover { color: #22c55e; background: #f0fdf4; }

/* Countdown text */
.countdown-text { font-size: 11px; font-weight: 500; }
.countdown-text.overdue { color: #ef4444; }
.countdown-text.urgent  { color: #f59e0b; }
.countdown-text.normal  { color: #94a3b8; }

/* ================================================================
 *  FILTER BUTTONS
 * ================================================================ */
.filter-btn {
    padding: 8px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
    color: #64748b; background: white; border: 1px solid #e2e8f0; cursor: pointer; transition: all 0.2s;
}
.filter-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.filter-btn.active {
    background: var(--brand-600); color: white; border-color: var(--brand-600);
    box-shadow: 0 2px 8px rgba(79,70,229,0.25);
}

/* ================================================================
 *  DROP ZONE
 * ================================================================ */
.drop-zone {
    border: 2px dashed #cbd5e1; border-radius: var(--radius-md); padding: 24px;
    text-align: center; cursor: pointer; transition: all 0.2s; background: #f8fafc;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--brand-400); background: #eef2ff; transform: scale(1.01);
}

/* ================================================================
 *  DEPARTMENT CARDS
 * ================================================================ */
.dept-card {
    padding: 10px 8px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer;
    transition: all 0.2s; text-align: center; border: 2px solid #e2e8f0;
    background: #f8fafc; color: #64748b; font-weight: 500; line-height: 1.3;
    word-break: keep-all; user-select: none;
}
.dept-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dept-card.selected {
    background: linear-gradient(135deg, #6366f1, #4f46e5); border-color: #4338ca;
    color: white; box-shadow: 0 4px 14px rgba(79,70,229,0.3); transform: scale(1.03);
}
.dept-card.filled { background: #f0fdf4; border-color: #86efac; color: #166534; }
.dept-card.filled::after { content: ' \2705'; font-size: 10px; opacity: 0.7; }

/* ================================================================
 *  TOASTS
 * ================================================================ */
.toast {
    position: fixed; top: 20px; right: 20px; padding: 14px 22px; border-radius: 12px;
    color: white; font-weight: 500; font-size: 13px; z-index: 1000;
    animation: slideInRight 0.3s ease-out; max-width: 400px;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15); backdrop-filter: blur(8px);
}
.toast-success { background: linear-gradient(135deg, #059669, #10b981); }
.toast-error   { background: linear-gradient(135deg, #dc2626, #ef4444); }
.toast-info    { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.toast-warning { background: linear-gradient(135deg, #d97706, #f59e0b); }
.toast-progress { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.toast-icon { font-size: 16px; opacity: 0.9; flex-shrink: 0; }

/* ================================================================
 *  EMPTY STATES
 * ================================================================ */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state-icon {
    width: 72px; height: 72px; border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px; font-size: 28px;
}
.empty-state-icon.tasks   { background: #eff6ff; color: #93c5fd; }
.empty-state-icon.reports { background: #f0fdf4; color: #86efac; }
.empty-state-icon.history { background: #fffbeb; color: #fcd34d; }
.empty-state-icon.trash   { background: #fef2f2; color: #fca5a5; }
.empty-state-icon.search  { background: #f8fafc; color: #cbd5e1; }

.empty-state-title {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 16px; font-weight: 700; color: #475569; margin-bottom: 6px;
}
.empty-state-desc { font-size: 13px; color: #94a3b8; max-width: 280px; margin: 0 auto; }

/* ================================================================
 *  LOADING SKELETON
 * ================================================================ */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px;
}

/* ================================================================
 *  MODAL
 * ================================================================ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 50;
    animation: fadeIn 0.15s ease-out;
}
.modal-content {
    background: white; border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
    width: 100%; max-height: 85vh; overflow-y: auto; animation: fadeUp 0.2s ease-out;
}

/* ================================================================
 *  BUTTON STYLES
 * ================================================================ */
.btn-primary {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
    color: white; font-weight: 600; border-radius: 12px; padding: 10px 20px;
    font-size: 13px; border: none; cursor: pointer; transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(79,70,229,0.2); display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,70,229,0.3); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { background: #cbd5e1; box-shadow: none; cursor: not-allowed; transform: none; }

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444); color: white; font-weight: 600;
    border-radius: 12px; padding: 10px 20px; font-size: 13px; border: none;
    cursor: pointer; transition: all 0.2s; box-shadow: 0 2px 8px rgba(239,68,68,0.2);
}
.btn-danger:hover { box-shadow: 0 4px 14px rgba(239,68,68,0.3); }

.btn-ghost {
    background: #f1f5f9; color: #475569; font-weight: 600; border-radius: 12px;
    padding: 10px 20px; font-size: 13px; border: none; cursor: pointer; transition: all 0.2s;
}
.btn-ghost:hover { background: #e2e8f0; }

/* ================================================================
 *  INPUT STYLES
 * ================================================================ */
.input-modern {
    width: 100%; padding: 10px 14px; border: 1.5px solid #e2e8f0; border-radius: 12px;
    font-size: 13px; background: #f8fafc; transition: all 0.2s; outline: none;
}
.input-modern:focus { border-color: var(--brand-400); background: white; box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.input-modern::placeholder { color: #94a3b8; }

/* ================================================================
 *  PASSWORD TOGGLE
 * ================================================================ */
.pwd-toggle {
    background: none; border: none; cursor: pointer; padding: 4px;
    color: #94a3b8; display: flex; align-items: center; transition: color 0.15s;
}
.pwd-toggle:hover { color: #475569; }

/* ================================================================
 *  TAB NAVIGATION (Weekly Report)
 * ================================================================ */
.weekly-tab {
    flex: 1; padding: 12px 16px; font-size: 13px; font-weight: 600; color: #64748b;
    background: transparent; border: none; border-radius: 12px; cursor: pointer;
    transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.weekly-tab:hover { color: var(--brand-700); background: rgba(255,255,255,0.5); }
.weekly-tab.active { background: white; color: var(--brand-600); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

/* ================================================================
 *  STAT CARDS
 * ================================================================ */
.stat-card {
    background: white; border-radius: var(--radius-md); padding: 16px 20px;
    border: 1px solid #e2e8f0; transition: all 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-value { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 28px; font-weight: 800; }
.stat-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }

/* ================================================================
 *  AI LOADING
 * ================================================================ */
.ai-loading {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px; background: #eef2ff; border-radius: 12px; font-size: 13px; color: var(--brand-700);
}
.ai-loading i { animation: spin 0.8s linear infinite; }

/* ================================================================
 *  HISTORY DATE GROUP HEADER
 * ================================================================ */
.history-group-header {
    background: linear-gradient(135deg, #fffbeb, #fef3c7); padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* ================================================================
 *  RESPONSIVE — Mobile-first optimizations
 * ================================================================ */

/* Hidden on desktop, shown on mobile via media query */
.mobile-only-short { display: none; }

/* --- Touch target baseline --- */
@media (max-width: 768px) {
    /* Ensure minimum 44px touch targets */
    button, .filter-btn, .task-action-btn, .dept-card, .weekly-tab,
    [data-action] { min-height: 44px; }

    /* Inputs: 16px to prevent iOS zoom */
    input, select, textarea { font-size: 16px !important; }
    .input-modern { font-size: 16px !important; padding: 12px 14px; }

    /* --- Header: compact layout --- */
    header .max-w-7xl { padding-left: 12px; padding-right: 12px; }
    header .max-w-7xl > .flex { flex-wrap: wrap; gap: 8px; }
    .header-title { font-size: 16px; }
    .header-subtitle { display: none; }

    /* Header logo */
    header .w-10.h-10 { width: 36px; height: 36px; }
    header .w-10.h-10 i { font-size: 14px; }

    /* Header buttons row: scrollable */
    header .flex.items-center.gap-4 {
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
        width: 100%;
    }
    header .flex.items-center.gap-4::-webkit-scrollbar { display: none; }

    /* Header buttons: smaller text, compact */
    header button span.hidden.sm\:inline { display: none; }
    header .px-3.py-1\\.5 { padding: 6px 10px; font-size: 12px; }
    header .px-3.py-2 { padding: 6px 10px; font-size: 12px; }
    header .flex.items-center.gap-2.px-3.py-1\\.5 { padding: 4px 8px; font-size: 12px; }
    header .flex.items-center.gap-2.px-3.py-2 { padding: 4px 8px; font-size: 11px; }

    /* User greeting: compact */
    header .flex.items-center.gap-2.px-3.py-1\\.5.bg-gray-50 { font-size: 12px; padding: 4px 8px; }
    header #currentUserName { font-size: 12px; }
    header [data-action="handle-logout"] { padding: 6px 10px; font-size: 12px; }

    /* --- Main content: tighter padding --- */
    main.max-w-7xl { padding-left: 12px; padding-right: 12px; padding-top: 12px; padding-bottom: 12px; }

    /* --- Filter buttons: horizontal scroll --- */
    .filter-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap !important;
        padding-bottom: 4px;
        width: 100%;
    }
    .filter-scroll::-webkit-scrollbar { display: none; }
    .filter-btn { white-space: nowrap; flex-shrink: 0; padding: 8px 14px; font-size: 13px; }

    /* Icon-only buttons: hide text, keep icon visible */
    .mobile-icon-only { font-size: 0 !important; padding: 8px 10px !important; min-width: 44px; justify-content: center; gap: 0 !important; }
    .mobile-icon-only i { font-size: 16px !important; margin: 0 !important; }
    .mobile-icon-only .mobile-btn-text { display: none; }

    /* Completely hide on mobile */
    .mobile-hide { display: none !important; }

    /* Show only on mobile */
    .mobile-only-short { display: inline !important; }

    /* Model switcher: narrower on mobile */
    #quickModelSwitch { min-width: 70px !important; font-size: 13px !important; }

    /* System switch buttons: compact */
    .system-switch-btn.mobile-icon-only { padding: 8px 10px !important; }

    /* --- Task cards --- */
    .task-card { padding: 14px !important; }
    .task-card:hover { transform: none; }
    .task-action-btn { width: 40px; height: 40px; }

    /* --- Task form: stack grids --- */
    #taskFormContent .grid.grid-cols-2 { grid-template-columns: 1fr; }

    /* --- Task list header buttons: wrap --- */
    .task-list-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .task-list-actions button { flex: 1; min-width: calc(50% - 4px); justify-content: center; font-size: 12px; padding: 8px 10px; }

    /* --- Weekly report tabs: compact --- */
    #weeklyNavTabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    #weeklyNavTabs::-webkit-scrollbar { display: none; }
    .weekly-tab { padding: 10px 12px; font-size: 13px; white-space: nowrap; min-width: auto; }
    .weekly-tab i { display: none; }

    /* --- Weekly content sections: tighter padding --- */
    #weeklyContent .p-6 { padding: 16px; }
    #weeklyContent .flex.items-center.justify-between { flex-direction: column; align-items: flex-start; gap: 12px; }
    #weeklyContent .flex.flex-wrap.gap-2 { width: 100%; }
    #weeklyContent .flex.flex-wrap.gap-2 button { flex: 1; min-width: calc(50% - 4px); }

    /* Department cards: 2 columns on mobile */
    #departmentCards { grid-template-columns: repeat(2, 1fr) !important; }
    .dept-card { font-size: 13px; padding: 12px 8px; }

    /* Weekly action buttons row */
    #weeklyContent .mt-4.flex.gap-2 { flex-direction: column; }
    #weeklyContent .mt-4.flex.gap-2 button { width: 100%; }

    /* --- Modals: full-screen on mobile --- */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-content {
        max-height: 90vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        width: 100%; max-width: 100%;
    }

    /* --- Toasts: full-width top bar --- */
    .toast {
        left: 12px; right: 12px; top: 12px;
        max-width: none; text-align: center;
        justify-content: center;
    }

    /* --- Calendar: compact day cells --- */
    .calendar-day { min-height: 60px; padding: 2px 3px; }
    .calendar-day-num { font-size: 12px; }
    .calendar-day-num.today-num { width: 22px; height: 22px; font-size: 12px; }
    .calendar-task-item { font-size: 10px; padding: 2px 3px; }
    .calendar-task-count { font-size: 10px; padding: 0 4px; }
    .calendar-holiday { font-size: 9px; }
    .calendar-weekday { font-size: 11px; }

    /* --- Stats: stack cards --- */
    .grid.grid-cols-2.md\\:grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 22px; }
    .stat-card { padding: 12px 14px; }

    /* --- Auth card: tighter padding --- */
    .auth-card { padding: 24px 20px; margin: 12px; }

    /* --- AI input panel --- */
    #aiInputContent .flex.gap-2.mb-4 button { font-size: 13px; padding: 10px; }

    /* --- Command palette: full-width --- */
    #commandPaletteOverlay .max-w-xl { margin: 8px; max-width: calc(100% - 16px); }
    #commandPaletteOverlay .max-h-\\[360px\\] { max-height: 50vh; }

    /* --- Gantt chart: horizontal scroll --- */
    #ganttContainer { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    #ganttContainer svg { min-width: 600px; }

    /* --- Pagination: compact --- */
    #paginationContainer { flex-wrap: wrap; justify-content: center; }
    #paginationContainer button { padding: 6px 10px; font-size: 12px; min-width: 36px; }
}

/* --- Very small screens (iPhone SE, etc.) --- */
@media (max-width: 375px) {
    .header-title { font-size: 14px; }
    .auth-card { padding: 20px 16px; }
    .filter-btn { padding: 6px 10px; font-size: 12px; }
    .task-card { padding: 12px !important; }
    .dept-card { font-size: 12px; padding: 10px 6px; }
    #departmentCards { grid-template-columns: repeat(2, 1fr) !important; gap: 6px; }
    .weekly-tab { font-size: 12px; padding: 8px 10px; }
    main.max-w-7xl { padding-left: 8px; padding-right: 8px; }
    .calendar-day { min-height: 48px; }
    .calendar-task-item { display: none; }
    .calendar-task-count { font-size: 9px; }
}

/* --- Tablet: intermediate layout --- */
@media (min-width: 769px) and (max-width: 1024px) {
    #departmentCards { grid-template-columns: repeat(4, 1fr) !important; }
    .filter-btn { padding: 8px 14px; font-size: 13px; }
}

/* ================================================================
 *  DARK MODE — CSS Custom Properties
 * ================================================================ */
.dark { color-scheme: dark; }
.dark body { background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #1e1b4b 100%); }

.dark {
    --surface-1: #1e293b; --surface-2: #0f172a; --surface-3: #334155;
    --text-primary: #e2e8f0; --text-secondary: #94a3b8; --text-muted: #64748b;
    --border-default: #334155; --border-subtle: #1e293b;
    scrollbar-color: #475569 transparent;
}

.dark .auth-card { background: var(--surface-1); border-color: var(--border-default); }
.dark header { background: var(--surface-2); border-color: var(--border-default); }
.dark .task-card { background: var(--surface-1); border-color: var(--border-default); }
.dark .task-card:hover { border-color: #475569; }
.dark .task-card.completed { background: #0f172a; border-color: #1e293b; }
.dark .task-title { color: var(--text-primary); }
.dark .task-card p.text-gray-500 { color: var(--text-secondary); }

.dark .filter-btn { background: var(--surface-3); color: var(--text-secondary); border-color: var(--border-default); }
.dark .filter-btn:hover { background: #475569; }
.dark .filter-btn.active { background: var(--brand-600); color: white; border-color: var(--brand-600); }

.dark .drop-zone { background: var(--surface-2); border-color: var(--border-default); }
.dark .drop-zone:hover, .dark .drop-zone.drag-over { background: #1e1b4b; border-color: var(--brand-500); }

.dark .dept-card { background: var(--surface-1); border-color: var(--border-default); }
.dark .dept-card:hover { background: #334155; }

.dark .modal-overlay { background: rgba(0,0,0,0.6); }
.dark .modal-content { background: var(--surface-1); border-color: var(--border-default); }

.dark .input-modern { background: var(--surface-2); border-color: var(--border-default); color: var(--text-primary); }
.dark .input-modern:focus { border-color: var(--brand-400); background: var(--surface-2); }

.dark .toast-success { background: linear-gradient(135deg, #065f46, #059669); }
.dark .toast-error   { background: linear-gradient(135deg, #991b1b, #dc2626); }
.dark .toast-info    { background: linear-gradient(135deg, #1e40af, #2563eb); }
.dark .toast-warning { background: linear-gradient(135deg, #92400e, #d97706); }

.dark .empty-state-title { color: var(--text-secondary); }
.dark .empty-state-desc  { color: var(--text-muted); }

.dark .ai-loading { background: #1e1b4b; color: var(--brand-300); }

.dark select, .dark input[type="date"], .dark input[type="datetime-local"], .dark textarea {
    background: var(--surface-1); border-color: var(--border-default); color: var(--text-primary);
}

/* Tailwind class overrides */
.dark .bg-white { background-color: var(--surface-1) !important; }
.dark .bg-gray-50 { background-color: var(--surface-2) !important; }
.dark .bg-gray-100 { background-color: var(--surface-1) !important; }
.dark .text-gray-800 { color: var(--text-primary) !important; }
.dark .text-gray-700 { color: #cbd5e1 !important; }
.dark .text-gray-600 { color: var(--text-secondary) !important; }
.dark .text-gray-500 { color: var(--text-secondary) !important; }
.dark .text-gray-400 { color: var(--text-muted) !important; }
.dark .text-gray-300 { color: #475569 !important; }
.dark .border-gray-200 { border-color: var(--border-default) !important; }
.dark .border-gray-100 { border-color: var(--border-default) !important; }

/* Weekly Report gradient backgrounds */
.dark .from-blue-50 { --tw-gradient-from: #1e1b4b !important; }
.dark .to-indigo-50 { --tw-gradient-to: #1e1b4b !important; }
.dark .from-green-50 { --tw-gradient-from: #052e16 !important; }
.dark .to-emerald-50 { --tw-gradient-to: #052e16 !important; }
.dark .from-amber-50 { --tw-gradient-from: #451a03 !important; }
.dark .to-orange-50 { --tw-gradient-to: #451a03 !important; }
.dark .from-purple-50 { --tw-gradient-from: #2e1065 !important; }
.dark .to-pink-50 { --tw-gradient-to: #2e1065 !important; }
.dark .from-violet-50 { --tw-gradient-from: #2e1065 !important; }
.dark .from-blue-100  { background-color: #1e3a5f !important; }
.dark .from-green-100 { background-color: #14532d !important; }

.dark .border-blue-100, .dark .border-green-100, .dark .border-amber-100,
.dark .border-purple-100, .dark .border-blue-200, .dark .border-green-200,
.dark .border-amber-200, .dark .border-purple-200 { border-color: var(--border-default) !important; }

/* Weekly report & summary inner cards (consolidated) */
.dark .bg-blue-50    { background-color: #1e3a5f !important; }
.dark .bg-green-50   { background-color: #14532d !important; }
.dark .bg-red-50     { background-color: #7f1d1d !important; }
.dark .bg-amber-50   { background-color: #78350f !important; }
.dark .bg-violet-100 { background-color: #3b0764 !important; }
.dark .bg-purple-50  { background-color: #2e1065 !important; }
.dark .bg-pink-50    { background-color: #4a1942 !important; }
.dark .bg-green-100  { background-color: #14532d !important; }
.dark .bg-red-100    { background-color: #7f1d1d !important; }

.dark .text-blue-700   { color: #93c5fd !important; }
.dark .text-blue-600   { color: #60a5fa !important; }
.dark .text-green-600  { color: #4ade80 !important; }
.dark .text-green-700  { color: #86efac !important; }
.dark .text-red-500, .dark .text-red-600 { color: #f87171 !important; }
.dark .text-amber-700  { color: #fcd34d !important; }
.dark .text-violet-700 { color: #c4b5fd !important; }
.dark .tabular-nums { color: inherit; }

/* Gradient buttons — keep vibrant in dark mode */
.dark .from-violet-500, .dark .from-blue-500,
.dark .from-green-500, .dark .from-red-500 { filter: brightness(1.1); }

/* Weekly nav tabs */
.dark #weeklyNavTabs { background-color: var(--surface-2) !important; }
.dark #weeklyNavTabs button { color: var(--text-secondary) !important; }
.dark #weeklyNavTabs button.text-blue-600 { color: #60a5fa !important; background-color: var(--surface-1) !important; }

/* Theme toggle button */
.theme-toggle {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 10px; background: #f1f5f9; border: 1px solid #e2e8f0;
    cursor: pointer; transition: all 0.2s; color: #64748b;
}
.theme-toggle:hover { background: #e2e8f0; }
.dark .theme-toggle { background: var(--surface-3); border-color: #475569; color: var(--text-secondary); }
.dark .theme-toggle:hover { background: #475569; }

/* ================================================================
 *  TAG BADGE STYLES
 * ================================================================ */
.tag-badge {
    display: inline-flex; align-items: center; padding: 2px 8px;
    border-radius: 12px; font-size: 11px; font-weight: 500; line-height: 1.4; white-space: nowrap;
}
.tag-chip {
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
    border-radius: 16px; font-size: 12px; font-weight: 500; cursor: default; transition: all 0.15s;
}
.tag-chip .remove-tag {
    cursor: pointer; opacity: 0.6; transition: opacity 0.15s; font-size: 10px; margin-left: 2px;
}
.tag-chip .remove-tag:hover { opacity: 1; }

/* ================================================================
 *  REDUCED MOTION
 * ================================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
/* ================================================================
 *  CALENDAR VIEW STYLES
 * ================================================================ */

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.calendar-weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    padding: 6px 0;
}

.calendar-grid-inner {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    /* Prevent long content from expanding columns */
    table-layout: fixed;
}

.calendar-day {
    min-height: 100px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #fff;
    overflow: hidden;
    min-width: 0;
}

.calendar-day:hover {
    border-color: #818cf8;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.calendar-day.today {
    border-color: #6366f1;
    background: #eef2ff;
}

.calendar-day.selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.calendar-day.other-month {
    background: #f9fafb;
    opacity: 0.5;
}

.calendar-day.has-tasks {
    background: #fafafe;
}

.calendar-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.calendar-day-num {
    font-size: 15px;
    font-weight: 500;
    color: #374151;
}

.calendar-day-num.today-num {
    background: #6366f1;
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.calendar-task-count {
    font-size: 12px;
    background: #6366f1;
    color: #fff;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.calendar-task-item {
    padding: 3px 5px;
    margin-bottom: 2px;
    border-radius: 4px;
    background: #f9fafb;
    font-size: 13px;
    line-height: 1.3;
    overflow: hidden;
    max-width: 100%;
}

.calendar-task-title {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #374151;
    max-width: 100%;
}

.calendar-holiday {
    font-size: 10px;
    color: #dc2626;
    background: #fef2f2;
    padding: 1px 4px;
    border-radius: 3px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    line-height: 1.4;
}

.calendar-workday {
    font-size: 9px;
    color: #ffffff;
    background: #f59e0b;
    padding: 0px 4px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 2px;
    font-weight: 600;
}

.calendar-more {'
    font-size: 12px;
    color: #6366f1;
    text-align: center;
    padding: 2px 0;
    font-weight: 500;
}

