:root {
    --brand-navy: #2b2a6e;
    --brand-navy-dark: #1f1e52;
    --brand-gold: #d9a125;
    --bs-primary: var(--brand-navy);
    --bs-primary-rgb: 43, 42, 110;
    --bs-link-color: var(--brand-navy);
    --bs-link-color-rgb: 43, 42, 110;
    --bs-link-hover-color: var(--brand-gold);
    --bs-link-hover-color-rgb: 217, 161, 37;
}

body {
    background-color: #ffffff;
}

.btn-primary {
    --bs-btn-bg: var(--brand-navy);
    --bs-btn-border-color: var(--brand-navy);
    --bs-btn-hover-bg: var(--brand-gold);
    --bs-btn-hover-border-color: var(--brand-gold);
    --bs-btn-active-bg: #c4901f;
    --bs-btn-active-border-color: #c4901f;
    --bs-btn-disabled-bg: var(--brand-navy);
    --bs-btn-disabled-border-color: var(--brand-navy);
    --bs-btn-focus-shadow-rgb: 43, 42, 110;
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-navy);
    --bs-btn-border-color: var(--brand-navy);
    --bs-btn-hover-bg: var(--brand-navy);
    --bs-btn-hover-border-color: var(--brand-navy);
    --bs-btn-active-bg: var(--brand-navy);
    --bs-btn-active-border-color: var(--brand-navy);
}

.badge.bg-primary {
    background-color: var(--brand-navy) !important;
}

.app-sidebar {
    min-height: 100vh;
    background: #ffffff;
    border-right: 1px solid #e5e9f2;
}

.app-sidebar .sidebar-brand {
    color: #1f2937;
}

.app-sidebar .sidebar-brand i {
    color: var(--brand-navy);
}

.app-sidebar .nav-link {
    color: #475569;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.app-sidebar .nav-link.active,
.app-sidebar .nav-link:hover {
    color: #fff;
    background: var(--brand-navy);
}

.app-sidebar .nav-link .bi-chevron-down {
    color: inherit;
}

.app-sidebar .collapse .nav-link,
.app-sidebar .collapsing .nav-link {
    color: #64748b;
    font-size: 0.85rem;
}

.app-sidebar .collapse .nav-link.active,
.app-sidebar .collapse .nav-link:hover {
    color: #fff;
    background: var(--brand-navy);
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        overflow-y: auto;
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 0 0 30px rgba(15, 23, 42, 0.2);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1040;
    }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.page-header h1,
.page-header h2,
.page-header h3,
.page-header h4 {
    font-size: clamp(1.1rem, 1.5vw + 0.75rem, 1.75rem);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.stat-card {
    background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
    border: 1px solid #e5e9f2;
    border-radius: 16px;
    padding: 18px;
    min-height: 100px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

.stat-card span {
    color: #64748b;
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.stat-card strong {
    font-size: 22px;
    color: #0f172a;
}

/* KPI strip */
.kpi-card {
    background: #fff;
    border: 1px solid #e5e9f2;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
    height: 100%;
}

.kpi-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: rgba(43, 42, 110, 0.1);
    color: var(--brand-navy);
    flex-shrink: 0;
}

.kpi-body span {
    display: block;
    color: #64748b;
    font-size: 0.8rem;
}

.kpi-body strong {
    font-size: 20px;
    color: #0f172a;
}

.kpi-progress {
    height: 6px;
    border-radius: 999px;
    background: #eef1f8;
    overflow: hidden;
}

.kpi-progress > span {
    display: block;
    height: 100%;
    background: var(--brand-navy);
    border-radius: 999px;
}

/* Overview cards (status breakdown with % bars) */
.overview-card {
    background: #fff;
    border: 1px solid #e5e9f2;
    border-radius: 14px;
    padding: 16px;
    height: 100%;
}

.overview-card h6 {
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 12px;
}

.overview-row {
    margin-bottom: 10px;
}

.overview-row:last-child {
    margin-bottom: 0;
}

.overview-row-link {
    display: block;
    margin: -4px -6px 10px;
    padding: 4px 6px;
    border-radius: 8px;
    transition: background-color .15s ease;
}

.overview-row-link:last-child {
    margin-bottom: -4px;
}

.overview-row-link:hover {
    background-color: #f1f5f9;
}

.overview-row-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: #475569;
    margin-bottom: 4px;
}

.overview-row-label strong {
    color: #0f172a;
}

.overview-bar-track {
    height: 6px;
    border-radius: 999px;
    background: #eef1f8;
    overflow: hidden;
}

.overview-bar-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
}

/* Latest activity feed */
.activity-feed {
    max-height: 340px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #eef1f8;
}

.activity-item:last-child {
    border-bottom: 0;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-navy);
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-item-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1e293b;
}

.activity-item-meta {
    font-size: 0.72rem;
    color: #94a3b8;
}

.status-pill {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.7rem;
    color: #fff;
    padding: 0.3em 0.6em;
    border-radius: 0.375rem;
}

.status-pending { background: #94a3b8; }
.status-assigned { background: #2563eb; }
.status-in_progress { background: #f59e0b; }
.status-waiting_parts { background: #8b5cf6; }
.status-completed { background: #16a34a; }
.status-delivered { background: #0f766e; }
.status-not_started { background: #94a3b8; }
.status-on_hold { background: #8b5cf6; }
.status-cancelled { background: #dc2626; }
.status-done { background: #16a34a; }

.timeline {
    position: relative;
    padding-left: 18px;
}

.timeline:before {
    content: "";
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #cbd5e1;
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0f766e;
    position: absolute;
    left: -18px;
    top: 5px;
}

.image-card {
    display: block;
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
}

.image-card img {
    width: 100%;
    height: 170px;
    object-fit: cover;
}

.image-card span {
    display: block;
    padding: 10px;
    font-weight: 600;
    color: #334155;
}

.map-frame {
    width: 100%;
    min-height: 240px;
    border: 0;
    border-radius: 14px;
}

/* Task dashboard */
.priority-low { background: #16a34a; }
.priority-medium { background: #f59e0b; }
.priority-high { background: #dc2626; }

.task-chip {
    display: block;
    color: #fff;
    font: inherit;
    font-size: 0.72rem;
    padding: 0.25em 0.5em;
    border-radius: 0.375rem;
    margin-bottom: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    text-align: left;
    width: 100%;
}

.task-chip.is-completed {
    opacity: 0.55;
    text-decoration: line-through;
}

.task-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 2px;
}

.dash-view-panel { display: none; }
.dash-view-panel.active { display: block; }

@media (max-width: 767.98px) {
    #view-week,
    #view-month {
        overflow-x: auto;
    }

    .dash-week-grid,
    .dash-month-grid,
    #month-weekday-header {
        min-width: 640px;
    }
}

.dash-week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.dash-week-col {
    border: 1px solid #e5e9f2;
    border-radius: 12px;
    padding: 8px;
    min-height: 160px;
    background: #fff;
}

.dash-week-col.is-today {
    border-color: var(--brand-navy);
    box-shadow: 0 0 0 1px var(--brand-navy);
}

.dash-week-col-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 6px;
    text-align: center;
}

.dash-month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.dash-day-cell {
    font: inherit;
    border: 1px solid #e5e9f2;
    border-radius: 10px;
    padding: 6px;
    min-height: 76px;
    background: #fff;
    cursor: pointer;
    text-align: left;
}

.dash-day-cell:hover {
    border-color: var(--brand-navy);
}

.dash-day-cell.is-muted {
    background: #f8fafc;
    color: #94a3b8;
}

.dash-day-cell.is-today {
    border-color: var(--brand-navy);
    box-shadow: 0 0 0 1px var(--brand-navy);
}

.dash-day-cell .date-num {
    font-size: 0.8rem;
    font-weight: 600;
}

.dash-mini-month {
    border: 1px solid #e5e9f2;
    border-radius: 12px;
    padding: 10px;
    background: #fff;
}

.dash-mini-month-title {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-align: center;
    cursor: pointer;
    color: var(--brand-navy);
}

.dash-mini-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
}

.dash-mini-cell {
    aspect-ratio: 1 / 1;
    border-radius: 3px;
    cursor: pointer;
}

.heat-0 { background: #eef1f8; }
.heat-1 { background: rgba(43, 42, 110, 0.35); }
.heat-2 { background: rgba(43, 42, 110, 0.65); }
.heat-3 { background: rgba(43, 42, 110, 1); }
