/* ==========================================================
   DASHBOARD
========================================================== */

.dashboard {

    display: flex;
    flex-direction: column;
    gap: 22px;

}

/* ==========================================================
   PAGE HEADER
========================================================== */

.dashboard-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 6px;

}

.dashboard-header h1 {

    font-size: 22px;

    font-weight: 600;

    color: var(--text);

}

.dashboard-header p {

    color: var(--text-light);

    margin-top: 4px;

    font-size: 13px;

}

/* ==========================================================
   STATS GRID
========================================================== */

.stats-grid {

    display: grid;

    grid-template-columns: repeat(5, 1fr);

    gap: 16px;

    margin-bottom: 26px;

}

.stat-card {

    background: var(--surface);

    border-radius: var(--radius);

    border: none;

    padding: 14px 16px;

    transition: .18s;

    box-shadow: var(--shadow-card);

}

.stat-card:hover {

    transform: translateY(-2px);
    box-shadow: var(--shadow);

}

.stat-top {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 10px;

}

.stat-title {

    color: var(--text-light);

    font-size: 11.5px;
    font-weight: 500;

}

.stat-value {

    font-size: 19px;

    font-weight: 700;

    margin-top: 3px;

    color: var(--text);

    letter-spacing: -.01em;

}

.stat-value.negative {

    color: var(--danger);

}

.stat-change {

    margin-top: 8px;

    font-size: 11.5px;

    font-weight: 600;

}

.stat-change.positive {

    color: #16A34A;

}

.stat-change.negative {

    color: #DC2626;

}

.stat-change-none {

    color: var(--text-faint);
    font-weight: 500;

}

.stat-change-label {

    color: var(--text-faint);
    font-weight: 500;

}

/* ==========================================================
   SIMPLE STAT CARDS
   (no icon — matches target dashboard UI)
========================================================== */

.stat-card-simple {

    background: var(--surface);

    border-radius: var(--radius);

    border: none;

    padding: 18px 20px;

    box-shadow: var(--shadow-card);

    transition: .18s;

}

.stat-card-simple:hover {

    transform: translateY(-2px);
    box-shadow: var(--shadow);

}

.stat-card-simple .stat-title {

    color: var(--text-light);

    font-size: 12.5px;
    font-weight: 500;

}

.stat-card-simple .stat-value {

    font-size: 24px;

    font-weight: 700;

    margin-top: 6px;

    color: var(--text);

    letter-spacing: -.01em;

}

/* ==========================================================
   GRID LAYOUT
========================================================== */

/* 3 equal columns: My Tasks / Leads by Stage / Active Projects in
   row 1 (all the same fixed height — .dashboard-panel-fixed), then
   the Income vs Expenses chart spanning the first two columns and
   Upcoming Deadlines in the 3rd, in row 2. Grid's default
   align-items: stretch makes Upcoming Deadlines match the chart's
   height automatically since they share a row track. */
.dashboard-grid {

    display: grid;

    grid-template-columns: repeat(3, 1fr);

    grid-template-rows: auto auto;

    gap: 16px;

}

.dashboard-col-wide {

    grid-column: span 2;

}

.dashboard-col {

    display: flex;

    flex-direction: column;

    gap: 16px;

}

/* Row 1's three panels (My Tasks, Leads by Stage, Active Projects) —
   fixed height so all three line up regardless of how many rows each
   has to show, with the body scrolling internally past that. Leads
   by Stage's donut+legend content is the anchor height everything
   else was set to match. */
.dashboard-panel-fixed {

    display: flex;
    flex-direction: column;

    height: 300px;

}

.dashboard-panel-fixed .panel-body {

    flex: 1;

    min-height: 0;

    overflow-y: auto;

    /* Scrollable, just without a visible scrollbar track — same
       content still scrolls via wheel/trackpad/keyboard/drag. */
    scrollbar-width: none;
    -ms-overflow-style: none;

}

.dashboard-panel-fixed .panel-body::-webkit-scrollbar {

    display: none;

}

.dashboard-panel-fixed .donut-panel-body {

    flex: 1;

    min-height: 0;

}

/* ==========================================================
   CONTENT PANEL
   (shared shell for tasks / projects / leads /
   weather / proposals / rfi panels)
========================================================== */

.content-panel {

    background: var(--surface);

    border-radius: var(--radius);

    border: none;

    padding: 18px 20px;

    box-shadow: var(--shadow-card);

}

/* Stretches to match the Income vs Expenses chart's height (both
   share row 2 of .dashboard-grid, whose default align-items:
   stretch does the equalizing) and scrolls its own body instead of
   overflowing past that height. */
/* Members (no Leads by Stage panel, no Pipeline Value tile — see
   applyDashboardRoleLayout() in dashboard.js): row 1 is two equal
   panels, row 2 keeps the chart wide; four stat tiles. Wide screens
   only — the breakpoints below already stack everything. */
@media (min-width: 1201px) {

    .dashboard-grid.dashboard-grid--no-leads {

        grid-template-columns: repeat(6, 1fr);

    }

    .dashboard-grid--no-leads > .dashboard-panel-fixed {

        grid-column: span 3;

    }

    .dashboard-grid--no-leads > .dashboard-col-wide {

        grid-column: span 4;

    }

    .dashboard-grid--no-leads > #deadlinesPanel {

        grid-column: span 2;

    }

}

@media (min-width: 1501px) {

    .stats-grid.stats-grid--four {

        grid-template-columns: repeat(4, 1fr);

    }

}

/* Members (Phase 4a): no money either, so one tile (Active Projects) and
   Upcoming Deadlines across the second row. */
.stats-grid.stats-grid--no-money {

    grid-template-columns: minmax(0, 360px);

}

@media (min-width: 1201px) {

    .dashboard-grid--no-leads.dashboard-grid--no-money > #deadlinesPanel {

        grid-column: 1 / -1;

    }

}

#deadlinesPanel {

    display: flex;
    flex-direction: column;

}

#deadlinesPanel .panel-body {

    flex: 1;

    min-height: 0;

    overflow-y: auto;

}

.panel-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 12px;

}

.panel-header h3 {

    font-size: 14.5px;
    font-weight: 600;

}

.panel-body {

    display: flex;

    flex-direction: column;

}

.empty-row {

    color: var(--text-light);

    font-size: 13px;

    padding: 10px 0;

}

/* ==========================================================
   MY TASKS PANEL
========================================================== */

.task-row {

    display: flex;

    align-items: center;

    gap: 10px;

    padding: 8px 0;

    border-bottom: 1px solid var(--hairline);

    cursor: pointer;

}

.task-row:hover .task-title {

    color: var(--primary);

}

.task-row:last-child {

    border-bottom: none;

}

.task-row input[type="checkbox"] {

    width: 15px;

    height: 15px;

    accent-color: var(--primary);

}

.task-title {

    flex: 1;

    font-size: 13px;

    color: var(--text);

}

.priority-badge {

    font-size: 10.5px;

    font-weight: 600;

    padding: 3px 9px;

    border-radius: 999px;

    text-transform: lowercase;

}

.priority-high {

    background: #FEE2E2;

    color: var(--danger);

}

.priority-medium,
.priority-med {

    background: #FEF3C7;

    color: var(--warning);

}

.priority-low {

    background: #DCFCE7;

    color: var(--success);

}

/* Dark mode — see tasks.css's identical priority background
   overrides for the full explanation. */
body[data-theme="dark"] .priority-high {

    background: rgba(239, 68, 68, .16);
    color: #FCA5A5;
}

body[data-theme="dark"] .priority-medium,
body[data-theme="dark"] .priority-med {

    background: rgba(245, 158, 11, .16);
    color: #FCD34D;
}

body[data-theme="dark"] .priority-low {

    background: rgba(34, 197, 94, .16);
    color: #86EFAC;
}

.task-due-date {

    flex-shrink: 0;

    font-size: 11.5px;
    color: var(--text-light);

    width: 44px;

    text-align: right;

}

/* ==========================================================
   ACTIVE PROJECTS PANEL
========================================================== */

.project-item {

    padding: 10px 0;

    border-bottom: 1px solid var(--hairline);

    cursor: pointer;

}

.project-item:hover .project-name {

    color: var(--primary);

}

.project-item:last-child {

    border-bottom: none;

}

.project-item-top {

    display: flex;

    justify-content: space-between;

    align-items: center;

    font-weight: 600;

    font-size: 13px;

    margin-bottom: 7px;

}

.project-name {

    color: var(--text);

}

.project-budget {

    color: var(--text);

}

.progress-bar {

    height: 6px;

    background: var(--control-track);

    border-radius: 999px;

    overflow: hidden;

}

.progress-fill {

    height: 100%;

    background: var(--primary);

    border-radius: 999px;

}

.project-meta {

    font-size: 11.5px;

    color: var(--text-light);

    margin-top: 6px;

}

/* ==========================================================
   LEADS BY STAGE PANEL (donut chart)
   See renderDonutSvg()/renderLeadsPanel() in dashboard.js. Colors
   are set inline per-segment (SVG stroke can't read a CSS class
   the way `background` can), keyed off LEAD_STAGE_COLORS there —
   keep that object in sync with any stage color changes made here.
========================================================== */

.donut-panel-body {

    display: flex;
    align-items: center;
    gap: 20px;

}

.donut-wrap {

    position: relative;

    width: 120px;
    height: 120px;

    flex-shrink: 0;

}

.donut-svg {

    width: 100%;
    height: 100%;

    transform: rotate(-90deg);

}

.donut-track {

    fill: none;
    stroke: var(--border-soft);
    stroke-width: 14;

}

.donut-segment {

    fill: none;
    stroke-width: 14;

    transition: stroke-dasharray .3s ease;

}

.donut-center {

    position: absolute;
    inset: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

}

.donut-total {

    font-size: 22px;
    font-weight: 700;
    color: var(--text);

}

.donut-total-label {

    font-size: 10px;
    color: var(--text-light);
    text-align: center;

}

.donut-legend {

    flex: 1;

    display: flex;
    flex-direction: column;
    gap: 7px;

    min-height: 0;

    overflow-y: auto;

}

.legend-row {

    display: flex;
    align-items: center;
    gap: 8px;

    font-size: 12.5px;

}

.legend-dot {

    width: 8px;
    height: 8px;
    border-radius: 50%;

    flex-shrink: 0;

}

.legend-label {

    flex: 1;

    color: var(--text);

}

.legend-count {

    font-weight: 600;
    color: var(--text);

}

.legend-pct {

    width: 32px;

    text-align: right;

    color: var(--text-light);

}

/* ==========================================================
   UPCOMING DEADLINES PANEL
   Merges open Tasks (past/upcoming due dates) and incomplete
   Projects (past/upcoming end dates) into one sorted list —
   see renderDeadlinesPanel() in dashboard.js.
========================================================== */

.deadline-row {

    display: flex;

    align-items: center;

    gap: 10px;

    padding: 9px 0;

    border-bottom: 1px solid var(--hairline);

    cursor: pointer;

}

.deadline-row:last-child {

    border-bottom: none;

}

.deadline-type-badge {

    font-size: 10px;

    font-weight: 700;

    text-transform: uppercase;

    letter-spacing: .02em;

    padding: 3px 8px;

    border-radius: 999px;

    flex-shrink: 0;

}

.deadline-type-task {

    background: var(--primary-light);

    color: var(--primary-dark);

}

.deadline-type-project {

    background: #EDE9FE;

    color: #6D28D9;

}

.deadline-title {

    flex: 1;

    font-size: 13px;

    color: var(--text);

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

}

.deadline-date {

    font-size: 12px;

    font-weight: 600;

    color: var(--text-light);

    flex-shrink: 0;

}

.deadline-date.overdue {

    color: var(--danger);

}

/* ==========================================================
   INCOME VS EXPENSES CHART
   See buildLineChartSvg()/renderChartPanel() in dashboard.js.
========================================================== */

.chart-range-select {

    width: auto;

    padding: 6px 10px;

    font-size: 12.5px;

}

.chart-legend {

    display: flex;
    gap: 16px;

    margin: 10px 0 6px;

    font-size: 12.5px;
    color: var(--text-light);

}

.chart-legend span {

    display: flex;
    align-items: center;
    gap: 6px;

}

.chart-dot {

    width: 8px;
    height: 8px;
    border-radius: 50%;

    display: inline-block;

}

.chart-dot-income {

    background: var(--success);

}

.chart-dot-expense {

    background: var(--danger);

}

.chart-svg-wrap {

    width: 100%;

}

.line-chart-svg {

    width: 100%;
    height: 190px;
    display: block;

}

.chart-gridline {

    stroke: var(--hairline);
    stroke-width: 1;

}

.chart-axis-label {

    font-size: 10px;
    fill: var(--text-3);

}

.chart-area {

    stroke: none;
    opacity: .12;

}

.chart-area-income {

    fill: var(--success);

}

.chart-area-expense {

    fill: var(--danger);

}

.chart-line {

    fill: none;
    stroke-width: 2;

}

.chart-line-income {

    stroke: var(--success);

}

.chart-line-expense {

    stroke: var(--danger);

}

.chart-point {

    cursor: pointer;

}

.chart-point-income {

    fill: var(--success);

}

.chart-point-expense {

    fill: var(--danger);

}

/* ==========================================================
   ACTIVITY PANEL
========================================================== */

.activity-panel {

    background: var(--surface);

    border-radius: var(--radius);

    border: none;

    padding: 20px;

    box-shadow: var(--shadow-card);

}

.activity-item {

    display: flex;

    align-items: center;

    gap: 13px;

    padding: 13px 0;

    border-bottom: 1px solid var(--hairline);

}

.activity-item:last-child {

    border-bottom: none;

}

.activity-avatar {

    width: 38px;

    height: 38px;

    border-radius: 50%;

    background: var(--primary-light);

    display: flex;

    justify-content: center;

    align-items: center;

    color: var(--primary);

    font-weight: 700;

    font-size: 13px;

}

.activity-content h4 {

    font-size: 13.5px;

    margin-bottom: 3px;

}

.activity-content p {

    color: var(--text-light);

    font-size: 12.5px;

}

.activity-time {

    margin-left: auto;

    color: var(--text-faint);

    font-size: 12px;

}

/* ==========================================================
   RECENT PROJECTS
========================================================== */

.recent-projects {

    background: var(--surface);

    border-radius: var(--radius);

    border: none;

    padding: 20px;

    box-shadow: var(--shadow-card);

}

.project-row {

    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 14px 0;

    border-bottom: 1px solid var(--hairline);

}

.project-row:last-child {

    border-bottom: none;

}

.project-info h4 {

    margin-bottom: 3px;

    font-size: 13.5px;

}

.project-info span {

    color: var(--text-light);

    font-size: 12.5px;

}

/* ==========================================================
   QUICK ACTIONS
========================================================== */

.quick-actions {

    display: grid;

    grid-template-columns: repeat(4, 1fr);

    gap: 14px;

}

.action-card {

    display: block;

    background: var(--surface);

    border: none;

    border-radius: var(--radius);

    padding: 22px;

    text-align: center;

    text-decoration: none;
    color: var(--text);

    cursor: pointer;

    transition: .18s;

    box-shadow: var(--shadow-card);

}

.action-card:hover {

    transform: translateY(-3px);

    border-color: var(--primary);

    box-shadow: var(--shadow);

}

.action-icon {

    width: 48px;

    height: 48px;

    border-radius: var(--radius);

    margin: auto;

    margin-bottom: 14px;

    background: var(--primary-light);

    color: var(--primary);

    display: flex;

    align-items: center;

    justify-content: center;

    font-size: 22px;

}

.action-card h3 {

    font-size: 14px;

}

.action-card p {

    margin-top: 4px;

    font-size: 12px;
    color: var(--text-light);

}

/* ==========================================================
   RESPONSIVE
========================================================== */

@media (max-width:1500px){

    .stats-grid{

        grid-template-columns:repeat(3,1fr);

    }

}

@media (max-width:1200px){

    .stats-grid{

        grid-template-columns:repeat(2,1fr);

    }

    .dashboard-grid{

        grid-template-columns:1fr;

    }

    .dashboard-col-wide{

        grid-column: span 1;

    }

    .dashboard-panel-fixed{

        height: auto;
        max-height: 300px;

    }

}

@media (max-width:768px){

    .dashboard-header{

        flex-direction:column;

        align-items:flex-start;

        gap:16px;

    }

    .stats-grid{

        grid-template-columns:1fr;

    }

    .quick-actions{

        grid-template-columns:repeat(2,1fr);

    }

    .weather-strip{

        grid-template-columns:repeat(3,1fr);

    }

}

@media (max-width:480px){

    .quick-actions{

        grid-template-columns:1fr;

    }

    .weather-strip{

        grid-template-columns:repeat(2,1fr);

    }

}

/* Dark mode tint for pills without their own override: translucent hue background with a lighter text of the same hue. */
body[data-theme="dark"] .deadline-type-project {
    background: rgba(139, 92, 246, .16);
    color: #C4B5FD;
}


/* Phase 5b: whose tasks the money tiles count (organisation vs visible). */
.money-scope-note {

    margin: -8px 0 16px;

    font-size: 12px;

    color: var(--text-faint);

}
