:root {
    --primary: #5c6bc0;
    --primary-dark: #3f51b5;
    --primary-light: #7986cb;
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
    --bg-body: #f0f2f5;
    --card-shadow: 0 2px 8px rgba(0,0,0,.08);
    --card-shadow-hover: 0 4px 16px rgba(0,0,0,.12);
    --radius: 12px;
    --transition: .25s ease;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: #333;
    margin: 0;
    min-height: 100vh;
}

/* Material Card */
.material-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    border: none;
    transition: box-shadow var(--transition);
}
.material-card:hover { box-shadow: var(--card-shadow-hover); }

/* Layout */
.app-wrapper { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1a237e 0%, #283593 100%);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

.app-sidebar.collapsed { width: var(--sidebar-collapsed); }
.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .user-info,
.app-sidebar.collapsed .sidebar-toggle i { display: none; }
.app-sidebar.collapsed .sidebar-toggle i.bi-chevron-left::before { content: "\f285"; }

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: margin-left var(--transition);
    display: flex;
    flex-direction: column;
}

.app-sidebar.collapsed ~ .app-main { margin-left: var(--sidebar-collapsed); }

.app-header {
    height: var(--header-height);
    background: #fff;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-content { padding: 1.5rem; flex: 1; }

/* Sidebar */
.sidebar-brand {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-icon {
    width: 40px; height: 40px;
    background: rgba(255,255,255,.15);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.brand-text { flex: 1; min-width: 0; }
.brand-title { display: block; font-weight: 700; font-size: 1.1rem; }
.brand-sub { display: block; font-size: .7rem; opacity: .7; }

.sidebar-toggle { color: rgba(255,255,255,.7) !important; padding: 0; }

.sidebar-user {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.user-avatar {
    width: 40px; height: 40px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .75rem; opacity: .7; }

.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.25rem;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    transition: all var(--transition);
    position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.nav-item.active::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px; background: #fff; border-radius: 0 4px 4px 0;
}
.nav-item i { font-size: 1.15rem; width: 24px; text-align: center; flex-shrink: 0; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.1); }

/* Header */
.header-left { display: flex; align-items: center; gap: 1rem; }
.page-title { font-size: 1.25rem; font-weight: 600; margin: 0; }
.header-right { display: flex; align-items: center; gap: .75rem; }

.btn-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    color: #666;
    transition: background var(--transition);
}
.btn-icon:hover { background: #f0f0f0; }

.notif-dot {
    position: absolute; top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: #f44336;
    border-radius: 50%;
}

.notif-dropdown { width: 360px; max-height: 420px; }
.notif-header {
    padding: .75rem 1rem;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}
.notif-header a { font-size: .8rem; font-weight: 400; }
.notif-list { max-height: 300px; overflow-y: auto; }
.notif-item {
    padding: .75rem 1rem;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background var(--transition);
}
.notif-item:hover { background: #f8f9fa; }
.notif-item.unread { background: #e8eaf6; }
.notif-item .notif-title { font-weight: 600; font-size: .85rem; }
.notif-item .notif-msg { font-size: .8rem; color: #666; }
.notif-item .notif-time { font-size: .7rem; color: #999; }
.notif-footer {
    display: block; text-align: center; padding: .75rem;
    border-top: 1px solid #eee; font-size: .85rem;
}

.timer-widget {
    display: flex; align-items: center; gap: .5rem;
    background: #fff3e0; padding: .35rem .75rem;
    border-radius: 20px; font-size: .85rem;
}

/* Stats */
.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-value { display: block; font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { display: block; font-size: .8rem; color: #888; margin-top: .25rem; }

.kpi-score { font-size: 3.5rem; font-weight: 700; color: var(--primary); }
.kpi-breakdown { font-size: .85rem; color: #666; }

.card-section-title { font-weight: 600; margin-bottom: 1rem; color: #444; }

/* Kanban */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    min-height: 500px;
}

.kanban-column { display: flex; flex-direction: column; }
.kanban-column-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}
.kanban-column-title { font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .5px; }
.kanban-list {
    padding: .75rem;
    flex: 1;
    min-height: 200px;
    overflow-y: auto;
    max-height: calc(100vh - 280px);
}

.kanban-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: .75rem;
    margin-bottom: .5rem;
    cursor: grab;
    transition: box-shadow var(--transition), transform var(--transition);
}
.kanban-card:hover { box-shadow: var(--card-shadow-hover); }
.kanban-card.dragging { opacity: .5; transform: rotate(2deg); }
.kanban-card.overdue { border-left: 3px solid #f44336; }

.kanban-card-title { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.kanban-card-meta { font-size: .75rem; color: #888; }
.kanban-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: .5rem; }

.priority-badge {
    font-size: .65rem;
    padding: .15rem .5rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}
.priority-low { background: #e8f5e9; color: #2e7d32; }
.priority-medium { background: #fff3e0; color: #ef6c00; }
.priority-high { background: #fce4ec; color: #c62828; }
.priority-urgent { background: #f44336; color: #fff; }

.checklist-progress {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: .5rem;
    overflow: hidden;
}
.checklist-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width var(--transition);
}

/* Activity Feed */
.activity-feed { max-height: 300px; overflow-y: auto; }
.activity-item {
    padding: .5rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: .85rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-item .act-time { font-size: .75rem; color: #999; }

/* Detail */
.detail-section { margin-bottom: 1.5rem; }
.detail-section h6 { font-weight: 600; margin-bottom: .75rem; }
.detail-sidebar { position: sticky; top: 1rem; }

.checklist-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem 0;
}
.checklist-item.done label { text-decoration: line-through; color: #999; }

.comment-item {
    padding: .5rem .75rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: .5rem;
}
.comment-item .comment-author { font-weight: 600; font-size: .85rem; }
.comment-item .comment-text { font-size: .85rem; }
.comment-item .comment-time { font-size: .7rem; color: #999; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a237e 0%, #5c6bc0 50%, #7986cb 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 1rem; }
.login-card { padding: 2.5rem; }
.login-brand { text-align: center; margin-bottom: 2rem; }
.brand-icon-lg {
    width: 64px; height: 64px;
    background: var(--primary);
    color: #fff;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1rem;
}
.login-brand h2 { font-weight: 700; margin-bottom: .25rem; }
.login-brand p { color: #888; margin: 0; }
.login-demo { text-align: center; }

/* Buttons */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Table */
.table th { font-weight: 600; font-size: .85rem; color: #666; border-bottom-width: 1px; }
.table td { vertical-align: middle; font-size: .9rem; }

.status-badge {
    font-size: .75rem;
    padding: .25rem .6rem;
    border-radius: 20px;
    font-weight: 600;
}
.status-todo { background: #eceff1; color: #546e7a; }
.status-in_progress { background: #fff8e1; color: #f57f17; }
.status-review { background: #e1f5fe; color: #0277bd; }
.status-completed { background: #e8f5e9; color: #2e7d32; }

/* Project cards */
.project-card { padding: 1.25rem; }
.project-card h5 { font-weight: 600; }
.project-progress { height: 6px; background: #e0e0e0; border-radius: 3px; margin: .75rem 0; }
.project-progress-bar { height: 100%; background: var(--primary); border-radius: 3px; }

/* Notification page */
.notif-page-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.notif-page-item.unread { background: #e8eaf6; }

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1035;
}
.sidebar-overlay.show { display: block; }

/* Responsive */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0 !important; }
    .kanban-board { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 575.98px) {
    .app-content { padding: 1rem; }
    .kanban-board { grid-template-columns: 1fr; }
    .stat-value { font-size: 1.4rem; }
    .notif-dropdown { width: 300px; }
}

/* Toastr override */
#toast-container > div { border-radius: 8px; box-shadow: var(--card-shadow-hover); }
