/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #8b5cf6;
    --accent-hover: #a78bfa;
    --accent-glow: rgba(139, 92, 246, 0.3);
    --purple: #8b5cf6;
    --blue: #3b82f6;
    --cyan: #06b6d4;
    --green: #10b981;
    --amber: #f59e0b;
    --red: #ef4444;
    --pink: #ec4899;
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --detail-w: 420px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0,0,0,0.3);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(241, 245, 249, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-input: rgba(0, 0, 0, 0.04);
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

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

html { font-size: 15px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    height: var(--topbar-h);
}

.brand-icon {
    font-size: 28px;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.93rem;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.nav-item .material-icons-round { font-size: 22px; transition: color var(--transition); }

.nav-item:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(236, 72, 153, 0.08));
    color: var(--accent);
}

.nav-item.active .material-icons-round { color: var(--accent); }

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.storage-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.storage-info .material-icons-round { font-size: 16px; color: var(--green); }

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ===== Top Bar ===== */
.topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
}

.menu-toggle { display: none; }

.topbar-search {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 40px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition);
}

.topbar-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.topbar-search .material-icons-round { font-size: 20px; color: var(--text-muted); }

.topbar-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
}

.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary .material-icons-round { font-size: 18px; }

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon {
    width: 38px; height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0;
}

.btn-icon .material-icons-round { font-size: 20px; }

.btn-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(139, 92, 246, 0.1);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(239, 68, 68, 0.12);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-success {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(16, 185, 129, 0.12);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-success:hover {
    background: rgba(16, 185, 129, 0.25);
}

/* ===== Views ===== */
.view {
    display: none;
    flex: 1;
    padding: 28px;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

.view.active { display: flex; flex-direction: column; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.view-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.view-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ===== Stats Row ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(8px);
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px; height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 24px;
}

.stat-card[data-accent="purple"] .stat-icon {
    background: rgba(139, 92, 246, 0.15);
    color: var(--purple);
}
.stat-card[data-accent="blue"] .stat-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--blue);
}
.stat-card[data-accent="amber"] .stat-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--amber);
}
.stat-card[data-accent="green"] .stat-icon {
    background: rgba(16, 185, 129, 0.15);
    color: var(--green);
}

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 20px;
    flex: 1;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    max-height: 420px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h2 .material-icons-round { font-size: 20px; color: var(--accent); }

.panel-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

/* Pending Tasks */
.pending-panel { grid-row: span 2; }

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    color: var(--text-muted);
    text-align: center;
    gap: 4px;
}

.empty-state .material-icons-round { font-size: 36px; opacity: 0.4; margin-bottom: 8px; }
.empty-state p { font-size: 0.88rem; }
.empty-state.large { padding: 64px; }
.empty-state.large .material-icons-round { font-size: 56px; }
.empty-state.large h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 4px; }

/* ===== Task Item ===== */
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
}

.task-item:hover {
    background: var(--bg-glass);
    border-color: var(--border);
}

.task-checkbox {
    width: 20px; height: 20px;
    min-width: 20px;
    border: 2px solid var(--border-hover);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    margin-top: 2px;
}

.task-checkbox:hover { border-color: var(--accent); }

.task-checkbox.checked {
    background: var(--green);
    border-color: var(--green);
}

.task-checkbox.checked::after {
    content: '✓';
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.task-info { flex: 1; min-width: 0; }

.task-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-word;
}

.task-item.completed .task-title {
    text-decoration: line-through;
    opacity: 0.5;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.task-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.task-badge.high { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.task-badge.medium { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.task-badge.low { background: rgba(16, 185, 129, 0.15); color: var(--green); }

.task-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-date.overdue { color: var(--red); font-weight: 600; }

.task-date .material-icons-round { font-size: 14px; }

.task-project-tag {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(139, 92, 246, 0.1);
    color: var(--purple);
}

/* ===== Deadline Item ===== */
.deadline-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    cursor: pointer;
}

.deadline-item:hover { background: var(--bg-glass); }

.deadline-date-box {
    width: 48px; height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(139, 92, 246, 0.1);
    flex-shrink: 0;
}

.deadline-date-box .day { font-size: 1.1rem; font-weight: 800; color: var(--accent); line-height: 1; }
.deadline-date-box .month { font-size: 0.65rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }

.deadline-date-box.overdue { background: rgba(239, 68, 68, 0.1); }
.deadline-date-box.overdue .day { color: var(--red); }

.deadline-info { flex: 1; min-width: 0; }
.deadline-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 2px; }
.deadline-project { font-size: 0.78rem; color: var(--text-muted); }

/* ===== Activity Item ===== */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
}

.activity-dot {
    width: 8px; height: 8px;
    min-width: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 6px;
}

.activity-text { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.activity-text strong { color: var(--text-primary); font-weight: 600; }
.activity-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ===== Progress Item ===== */
.progress-item {
    padding: 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.progress-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.progress-item-name { font-size: 0.88rem; font-weight: 600; }
.progress-item-pct { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
    background: linear-gradient(90deg, var(--purple), var(--pink));
}

/* ===== Projects Grid ===== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    flex: 1;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.project-card[data-color="purple"]::before { background: linear-gradient(90deg, var(--purple), var(--pink)); }
.project-card[data-color="blue"]::before { background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.project-card[data-color="green"]::before { background: linear-gradient(90deg, var(--green), var(--cyan)); }
.project-card[data-color="amber"]::before { background: linear-gradient(90deg, var(--amber), var(--red)); }
.project-card[data-color="pink"]::before { background: linear-gradient(90deg, var(--pink), var(--purple)); }
.project-card[data-color="cyan"]::before { background: linear-gradient(90deg, var(--cyan), var(--blue)); }

.project-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.project-card-title { font-size: 1.1rem; font-weight: 700; }

.project-card-status {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.project-card-status.active { background: rgba(16, 185, 129, 0.12); color: var(--green); }
.project-card-status.on-hold { background: rgba(245, 158, 11, 0.12); color: var(--amber); }
.project-card-status.completed { background: rgba(59, 130, 246, 0.12); color: var(--blue); }

.project-card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.project-card-tasks {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.project-card-tasks .material-icons-round { font-size: 16px; }

.project-card-dates {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== Calendar ===== */
.calendar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calendar-month-label {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 180px;
    text-align: center;
}

.calendar-wrapper { flex: 1; overflow-y: auto; }

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

.cal-header {
    padding: 12px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cal-day {
    min-height: 100px;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    cursor: default;
    position: relative;
}

.cal-day:hover { border-color: var(--border-hover); }

.cal-day.empty { background: transparent; border-color: transparent; }

.cal-day.today {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.cal-day-number {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.cal-day.today .cal-day-number { color: var(--accent); font-weight: 800; }

.cal-event {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-weight: 500;
}

.cal-event.deadline { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.cal-event.start { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.cal-event.task { background: rgba(59, 130, 246, 0.15); color: var(--blue); }

/* ===== Timeline ===== */
.timeline-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-range-label {
    font-size: 1rem;
    font-weight: 700;
    min-width: 200px;
    text-align: center;
}

.timeline-wrapper {
    flex: 1;
    overflow: auto;
}

.timeline-chart {
    min-width: 100%;
    position: relative;
}

.timeline-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 5;
}

.timeline-label-col {
    width: 200px;
    min-width: 200px;
    padding: 10px 16px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
}

.timeline-dates {
    display: flex;
    flex: 1;
}

.timeline-date-col {
    flex: 1;
    min-width: 40px;
    padding: 10px 4px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
}

.timeline-date-col.today { color: var(--accent); background: rgba(139, 92, 246, 0.05); }

.timeline-row {
    display: flex;
    border-bottom: 1px solid var(--border);
    min-height: 48px;
    align-items: center;
}

.timeline-row-label {
    width: 200px;
    min-width: 200px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-right: 1px solid var(--border);
}

.timeline-row-bars {
    display: flex;
    flex: 1;
    position: relative;
    height: 48px;
    align-items: center;
}

.timeline-bar {
    position: absolute;
    height: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    min-width: 24px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 8px;
}

.timeline-bar:hover {
    transform: scaleY(1.3);
    box-shadow: var(--shadow);
    z-index: 2;
}

.timeline-bar.purple { background: linear-gradient(90deg, var(--purple), var(--pink)); }
.timeline-bar.blue { background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.timeline-bar.green { background: linear-gradient(90deg, var(--green), var(--cyan)); }
.timeline-bar.amber { background: linear-gradient(90deg, var(--amber), var(--red)); }
.timeline-bar.pink { background: linear-gradient(90deg, var(--pink), var(--purple)); }
.timeline-bar.cyan { background: linear-gradient(90deg, var(--cyan), var(--blue)); }

.timeline-today-line {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--accent);
    z-index: 3;
    pointer-events: none;
}

.timeline-today-line::before {
    content: 'Today';
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

/* ===== Notes Grid ===== */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    flex: 1;
    align-content: start;
}

.note-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.note-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.note-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.note-card-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.note-color-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
}

/* ===== Detail Panel ===== */
.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.detail-overlay.active { opacity: 1; pointer-events: all; }

.detail-panel {
    position: fixed;
    top: 0; right: 0;
    width: var(--detail-w);
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 201;
    transform: translateX(100%);
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
}

.detail-panel.active { transform: translateX(0); }

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.detail-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.detail-field {
    margin-bottom: 14px;
}

.detail-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-field-value {
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.detail-task-list { list-style: none; }

.detail-task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.detail-task-item:last-child { border-bottom: none; }

.detail-actions {
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
    width: 560px;
    max-width: 92vw;
    max-height: 85vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition);
}

.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 1.15rem; font-weight: 700; }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ===== Form Styles ===== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group label .required { color: var(--red); }

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

.form-select option { background: var(--bg-secondary); color: var(--text-primary); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.filter-select {
    padding: 5px 28px 5px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2394a3b8' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.filter-select option { background: var(--bg-secondary); }

/* Color picker circles */
.color-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all var(--transition);
}

.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--bg-secondary); }

.color-option[data-color="purple"] { background: var(--purple); }
.color-option[data-color="blue"] { background: var(--blue); }
.color-option[data-color="green"] { background: var(--green); }
.color-option[data-color="amber"] { background: var(--amber); }
.color-option[data-color="pink"] { background: var(--pink); }
.color-option[data-color="cyan"] { background: var(--cyan); }

/* Inline task add */
.inline-task-add {
    display: flex;
    gap: 8px;
    padding: 10px 0;
}

.inline-task-add input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
}

.inline-task-add input:focus {
    border-color: var(--accent);
}

/* ===== Quick Add Menu ===== */
.quick-add-menu {
    position: absolute;
    top: calc(var(--topbar-h) - 4px);
    right: 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 150;
    display: none;
    min-width: 180px;
}

.quick-add-menu.active { display: block; animation: fadeIn 0.2s ease; }

.quick-add-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    font-family: inherit;
    text-align: left;
}

.quick-add-item:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.quick-add-item .material-icons-round { font-size: 20px; color: var(--accent); }

/* ===== Search Results ===== */
.search-results {
    position: absolute;
    top: calc(var(--topbar-h));
    left: 28px;
    width: 420px;
    max-width: calc(100vw - 56px);
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 150;
    display: none;
    padding: 8px;
}

.search-results.active { display: block; animation: fadeIn 0.2s ease; }

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.search-result-item:hover { background: var(--bg-glass); }

.search-result-item .material-icons-round { font-size: 20px; color: var(--accent); }

.search-result-info { flex: 1; }
.search-result-name { font-size: 0.9rem; font-weight: 600; }
.search-result-type { font-size: 0.75rem; color: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .pending-panel { grid-row: auto; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 300;
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px; height: 38px;
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-secondary);
        cursor: pointer;
    }
    .view { padding: 20px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .projects-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

/* ===== Drag & Drop (macOS-style) ===== */
.draggable-item {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.draggable-item .drag-handle {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    opacity: 0;
    transition: opacity var(--transition);
    color: var(--text-muted);
    z-index: 5;
    font-size: 16px;
    border-radius: 4px;
}

.draggable-item:hover .drag-handle {
    opacity: 0.6;
}

.draggable-item .drag-handle:hover {
    opacity: 1;
    background: var(--bg-glass);
}

.draggable-item .drag-handle:active {
    cursor: grabbing;
}

/* Lifted state: macOS window pick-up */
.draggable-item.dragging {
    z-index: 1000 !important;
    pointer-events: none;
    transform: scale(1.04) rotate(1.5deg);
    box-shadow: 0 22px 70px rgba(0,0,0,0.45), 0 0 0 1px rgba(139,92,246,0.3);
    opacity: 0.92;
    transition: none;
}

/* Ghost placeholder */
.drag-placeholder {
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    background: rgba(139,92,246,0.06);
    transition: all 0.2s ease;
    min-height: 60px;
}

/* Siblings shift smoothly */
.drag-container > * {
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.drag-container > .dragging {
    transition: none;
}

/* Task item drag adjustments */
.task-item.draggable-item .drag-handle {
    top: 50%;
    left: 4px;
    transform: translateY(-50%);
}

.task-item.draggable-item {
    padding-left: 28px;
}

/* ===== Resizable Cards ===== */
.resizable-card {
    position: relative;
}

.resize-wrapper {
    position: absolute;
    bottom: 6px;
    right: 6px;
    z-index: 10;
}

.resize-handle {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition), background var(--transition);
    color: var(--text-muted);
    font-size: 15px;
    border-radius: 4px;
}

.resizable-card:hover .resize-handle {
    opacity: 0.5;
}

.resize-handle:hover {
    opacity: 1 !important;
    background: var(--bg-glass);
    color: var(--accent);
}

/* Size picker dropdown */
.size-picker {
    position: absolute;
    bottom: 32px;
    right: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 50;
    display: none;
    min-width: 130px;
}

.size-picker.active {
    display: block;
    animation: fadeIn 0.15s ease;
}

.size-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    border: none;
    background: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all var(--transition);
}

.size-option:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.size-option.current {
    color: var(--accent);
    background: rgba(139,92,246,0.1);
}

.size-option .material-icons-round {
    font-size: 16px;
}

/* Card size classes */
.project-card.size-wide,
.note-card.size-wide {
    grid-column: span 2;
}

.project-card.size-tall,
.note-card.size-tall {
    grid-row: span 2;
}

.project-card.size-large,
.note-card.size-large {
    grid-column: span 2;
    grid-row: span 2;
}

/* When tall, show more content */
.note-card.size-tall .note-card-body,
.note-card.size-large .note-card-body {
    -webkit-line-clamp: 12;
}

.project-card.size-tall .project-card-desc,
.project-card.size-large .project-card-desc {
    -webkit-line-clamp: 6;
}

@media (max-width: 768px) {
    .project-card.size-wide,
    .note-card.size-wide,
    .project-card.size-large,
    .note-card.size-large {
        grid-column: span 1;
    }
}
