:root {
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --border: #e9ecef;
    --border-soft: #f1f3f5;
    --text-muted: #6c757d;
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.07);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 248px;
    --topbar-h: 60px;
}

/* ---------- App layout ---------- */
.layout-app {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: var(--sidebar-w);
    background: #ffffff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 1050;
}
.sidebar-header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 0.7rem;
    text-decoration: none;
    color: #212529;
    font-weight: 700;
    font-size: 1.1rem;
}
.sidebar-brand:hover { color: #0d6efd; }
.sidebar-nav {
    flex: 1;
    padding: 0.85rem 0.65rem;
    overflow-y: auto;
}
.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #adb5bd;
    padding: 0.5rem 0.85rem 0.35rem;
}
.sidebar-link {
    display: flex; align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    color: #495057;
    text-decoration: none;
    margin-bottom: 0.15rem;
    font-size: 0.92rem;
    transition: background-color .12s ease, color .12s ease;
    position: relative;
}
.sidebar-link:hover { background: #f1f3f5; color: #212529; }
.sidebar-link.active {
    background: #eaf3ff;
    color: #0a58ca;
    font-weight: 600;
}
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -0.65rem;
    top: 25%; bottom: 25%;
    width: 3px;
    background: #0d6efd;
    border-radius: 0 3px 3px 0;
}
.sidebar-link i { font-size: 1.05rem; width: 18px; text-align: center; }
.sidebar-link-count {
    margin-left: auto;
    background: #e9ecef;
    color: #495057;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
}
.sidebar-link.active .sidebar-link-count {
    background: #cfe2ff;
    color: #0a58ca;
}
.sidebar-link-count.badge-danger-soft { background: #fde2e4; color: #b02a37; }
.sidebar-link-count:empty,
.sidebar-link-count:is([data-zero]) { display: none; }

.sidebar-footer {
    padding: 0.85rem;
    border-top: 1px solid var(--border-soft);
}
.user-card {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.5rem;
    border-radius: 10px;
}
.user-card-info { min-width: 0; flex: 1; }
.user-card-name { font-weight: 600; font-size: 0.9rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-email { font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-action { flex-shrink: 0; }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(16, 24, 40, 0.45);
    z-index: 1049;
}
.sidebar-backdrop.show { display: block; }

.main-area {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 0.55rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: var(--topbar-h);
}
.topbar-hamburger { width: 38px; height: 38px; padding: 0; }
.topbar-search {
    flex: 1 1 auto;
    max-width: 460px;
    background: var(--bg);
    border-radius: 8px;
    padding: 0.4rem 0.85rem;
    display: flex; align-items: center;
    gap: 0.55rem;
    border: 1px solid transparent;
    transition: border-color .15s ease, background-color .15s ease;
}
.topbar-search:focus-within {
    background: #fff;
    border-color: #b6d4fe;
    box-shadow: 0 0 0 0.18rem rgba(13,110,253,0.12);
}
.topbar-search i { color: #6c757d; }
.topbar-search input {
    flex: 1;
    border: 0;
    background: transparent;
    outline: none;
    font-size: 0.92rem;
}
.topbar-select {
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: #fff;
    font-size: 0.88rem;
    padding: 0.32rem 1.7rem 0.32rem 0.75rem;
    min-width: 140px;
}
.topbar-actions {
    margin-left: auto;
    display: flex; align-items: center; gap: 0.4rem;
}

.main-content {
    padding: 1.5rem 1.5rem 3rem;
    flex: 1;
}
.main-content.admin-content {
    max-width: 980px;
    width: 100%;
    margin: 0 auto;
}
.page-hero { margin-bottom: 1.5rem; }
.page-hero h2 { font-size: 1.5rem; }
.page-title {
    display: flex; align-items: center; gap: 0.55rem;
    font-weight: 600;
    font-size: 1rem;
    color: #212529;
}
.page-title i { color: #0d6efd; font-size: 1.1rem; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #ffffff;
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0.35rem 0.4rem;
    padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 12px rgba(16, 24, 40, 0.06);
}
.bottom-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.25rem;
    color: #6c757d;
    text-decoration: none;
    font-size: 0.68rem;
    line-height: 1;
    gap: 0.25rem;
    position: relative;
    border-radius: 10px;
    transition: color .12s ease, background-color .12s ease;
}
.bottom-nav-item:hover, .bottom-nav-item:focus { color: #495057; background: #f8f9fa; }
.bottom-nav-item.active { color: #0d6efd; }
.bottom-nav-item.active i { transform: scale(1.06); }
.bottom-nav-item i { font-size: 1.3rem; transition: transform .12s ease; }
.bottom-nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 22px);
    min-width: 18px;
    height: 18px;
    background: #6c757d;
    color: #fff;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}
.bottom-nav-badge[hidden] { display: none; }
.bottom-nav-badge-danger { background: #dc3545; }

/* Mobile: hide sidebar entirely; bottom-nav takes over */
@media (max-width: 991.98px) {
    .sidebar,
    .sidebar-backdrop,
    .topbar-hamburger { display: none !important; }
    .bottom-nav { display: flex; }
    .main-content { padding: 1rem 1rem 5.5rem; }
    .topbar { padding: 0.5rem 0.85rem; gap: 0.4rem; }
    .topbar-search { padding: 0.35rem 0.7rem; }
    /* Modals + dropdowns should sit above the bottom nav */
    .modal { z-index: 1060; }
    .modal-backdrop { z-index: 1059; }

    /* Notification dropdown: span the viewport so it isn't clipped
       (the bell isn't at the viewport right edge — the "+" button sits to its right) */
    .notif-dropdown {
        position: fixed !important;
        top: calc(var(--topbar-h) + 0.3rem) !important;
        right: 0.6rem !important;
        left: 0.6rem !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - var(--topbar-h) - 6rem) !important;
        margin-top: 0 !important;
        z-index: 1055;
    }
    .notif-list { max-height: calc(100vh - var(--topbar-h) - 9rem) !important; }
}
@media (max-width: 575.98px) {
    .page-hero h2 { font-size: 1.2rem; }
    .stat-card { padding: 0.7rem 0.85rem; gap: 0.65rem; }
    .stat-value { font-size: 1.35rem; }
    .stat-icon { width: 38px; height: 38px; font-size: 1.05rem; }
}


body {
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #212529;
}

/* ---------- Brand mark (used in sidebar) ---------- */
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #0d6efd 0%, #6f42c1 100%);
    color: #fff;
    border-radius: 8px;
    font-size: 1rem;
    box-shadow: 0 2px 6px rgba(13,110,253,0.25);
}
.brand-mark-img {
    width: 32px; height: 32px;
    border-radius: 8px;
    object-fit: cover;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ---------- Stat cards ---------- */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.5px;
}
.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    font-weight: 500;
}

/* ---------- Kanban columns ---------- */
.kanban-column {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 220px;
}
.kanban-header {
    padding: 0.75rem 1rem;
    background: #fafbfd;
    border-bottom: 1px solid var(--border-soft);
    font-weight: 600;
    font-size: 0.92rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #212529;
}
.kanban-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #adb5bd;
}
.kanban-todo  .kanban-dot { background: #6c757d; }
.kanban-doing .kanban-dot { background: #0d6efd; }
.kanban-done  .kanban-dot { background: #198754; }
.kanban-count {
    background: var(--border-soft);
    color: #495057;
    padding: 0.12rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
}
.kanban-list {
    padding: 0.75rem;
    flex-grow: 1;
    min-height: 120px;
}

/* ---------- Task cards ---------- */
.task-card {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 3px solid #adb5bd;
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.task-card:hover {
    transform: translateY(-1px);
    border-color: #ced4da;
    box-shadow: var(--shadow-md);
}
.task-card.priority-High   { border-left-color: #dc3545; }
.task-card.priority-Medium { border-left-color: #fd7e14; }
.task-card.priority-Low    { border-left-color: #20c997; }

.task-priority-pill {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    letter-spacing: 0.2px;
    text-transform: uppercase;
}
.task-priority-pill.priority-High   { background: #f8d7da; color: #842029; }
.task-priority-pill.priority-Medium { background: #ffe5d0; color: #8a4a13; }
.task-priority-pill.priority-Low    { background: #d1f2e6; color: #0d6c4d; }

.task-timer {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font-size: 0.72rem; font-weight: 600;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    background: #e9ecef;
    color: #495057;
    font-variant-numeric: tabular-nums;
}
.task-timer-running {
    background: #cfe2ff;
    color: #084298;
}
.task-timer-running i { animation: timer-pulse 1.6s ease-in-out infinite; }
@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

/* ---------- Avatars ---------- */
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 0.85rem;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.avatar-sm { width: 26px; height: 26px; font-size: 0.72rem; }
.avatar-lg { width: 40px; height: 40px; font-size: 1rem; }

/* ---------- Install steps modal ---------- */
.install-step-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.install-step-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.6rem 0.85rem;
    background: #f8f9fa;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.4;
}
.install-step-list .step-num {
    flex-shrink: 0;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
}

/* ---------- Modals ---------- */
.modal-content {
    border-radius: var(--radius);
    border: 0;
    box-shadow: 0 20px 60px rgba(16,24,40,0.18);
}
.modal-header { border-bottom-color: var(--border-soft); }
.modal-footer { border-top-color: var(--border-soft); }

/* ---------- Comments ---------- */
.comment-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 0.6rem;
}
.comment-meta { font-size: 0.78rem; color: var(--text-muted); }
.comment-link a { word-break: break-all; }
.comment-image-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.comment-image {
    max-width: 100%;
    max-height: 220px;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: zoom-in;
    transition: transform 0.15s ease;
    object-fit: cover;
}
.comment-image:hover { transform: scale(1.01); }

.comment-image-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.comment-image-thumb {
    position: relative;
    width: 96px; height: 96px;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    background: #fff;
}
.comment-image-thumb img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.comment-image-thumb-remove {
    position: absolute;
    top: 4px; right: 4px;
    width: 22px; height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(33, 37, 41, 0.78);
    color: #fff;
    font-size: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    line-height: 1;
    transition: background-color .12s ease;
}
.comment-image-thumb-remove:hover { background: rgba(33, 37, 41, 0.95); }

/* ---------- Due dates ---------- */
.due-overdue { color: #dc3545; font-weight: 600; }
.due-soon    { color: #fd7e14; font-weight: 600; }

/* ---------- Empty states ---------- */
.empty-state {
    text-align: center;
    padding: 2.25rem 1rem;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 1.8rem;
    color: #ced4da;
    margin-bottom: 0.5rem;
}

/* ---------- Notifications bell ---------- */
.notif-bell { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; }
.notif-bell .badge { font-size: 0.62rem; min-width: 18px; padding: 0.15rem 0.35rem; }
.notif-bell.has-unread i { animation: bell-shake 1s ease-in-out 1; }
@keyframes bell-shake {
    0%, 100% { transform: rotate(0); }
    20%, 60% { transform: rotate(-12deg); }
    40%, 80% { transform: rotate(12deg); }
}
.notif-dropdown {
    width: 360px;
    max-width: calc(100vw - 1.5rem);
    max-height: 80vh;
    overflow: hidden;
    /* Force right-align with the bell since data-bs-display="static" turns off Popper */
    right: 0 !important;
    left: auto !important;
    margin-top: 0.4rem;
}
/* Only apply flex layout when the dropdown is actually open
   (otherwise display:flex would override Bootstrap's display:none for the closed state) */
.notif-dropdown.show {
    display: flex !important;
    flex-direction: column;
}
.notif-list { overflow-y: auto; max-height: 60vh; }
.notif-empty { padding: 2.25rem 1rem; }
.notif-empty i { display: block; margin: 0 auto; }
.notif-item {
    display: flex; gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-soft);
    cursor: pointer;
    transition: background-color 0.12s ease;
}
.notif-item:hover { background-color: #f8f9fa; }
.notif-item.unread { background-color: #eaf3ff; }
.notif-item.unread:hover { background-color: #dfecfe; }
.notif-item .notif-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}
.notif-icon-assigned    { background: #eaf3ff; color: #0d6efd; }
.notif-icon-commented   { background: #fff3cd; color: #8a4a13; }
.notif-icon-status_changed { background: #e9ecef; color: #495057; }
.notif-icon-completed   { background: #d1f2e6; color: #0d6c4d; }
.notif-text { font-size: 0.85rem; line-height: 1.35; min-width: 0; flex: 1; }
.notif-text .notif-msg { word-break: break-word; }
.notif-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ---------- Drag & drop ---------- */
.task-ghost {
    opacity: 0.4;
    background: #eef3ff !important;
    border-left-color: #0d6efd !important;
}
.task-chosen {
    box-shadow: 0 10px 24px rgba(13, 110, 253, 0.18);
}
.task-dragging {
    opacity: 0.9;
    transform: rotate(1.5deg);
    cursor: grabbing;
}
.task-card {
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.task-card:active { cursor: grabbing; }
.kanban-list {
    transition: background-color 0.15s ease;
}
.kanban-list.sortable-drag-over {
    background-color: rgba(13, 110, 253, 0.04);
}

/* ---------- Utilities ---------- */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

/* ---------- Status badge (legacy compat) ---------- */
.badge-status-to-do       { background: #6c757d; }
.badge-status-in-progress { background: #0d6efd; }
.badge-status-done        { background: #198754; }
