/* The appraisal, renovation and completed project lists. Built from the landing page's tiles so a report looks the same
   wherever it is listed. Each stage keeps the landing page's colour (set inline as --swatch): accent for appraisals,
   amber for renovations, green for completed */

.rl-root {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 0 24px;
    color: var(--color-text-primary);
}

    /* Several lists on one page. Each list's dialog sits between them, so this can't be an adjacent sibling */
    .rl-root ~ .rl-root {
        border-top: 1px dashed rgba(var(--color-accent-rgb), 0.35);
        padding-top: 24px;
    }

/* Page heading, the landing page's greeting panel tinted with the selected stage's colour */
.rl-head {
    display: flex;
    align-items: center;
    gap: 12px 16px;
    padding: 20px 24px;
    border: var(--tpt-border);
    border-radius: 8px;
    background: linear-gradient(120deg, color-mix(in srgb, var(--swatch) 18%, var(--color-bg-surface)), var(--color-bg-surface) 60%);
    box-shadow: var(--shadow-sm);
    transition: background 0.2s ease;
}

/* The stage's icon in the place of the landing page's initials */
.rl-head-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--swatch) 25%, var(--color-bg-surface));
    color: color-mix(in srgb, var(--swatch) 70%, black);
    font-size: 22px;
}

.rl-head-text {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.rl-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.rl-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.2;
}

/* Room for two lines whatever the stage, so the header keeps its height and the page below doesn't jump when switching tabs */
.rl-summary {
    max-width: 640px;
    min-height: 3em;
    margin: 2px 0 0;
    line-height: 1.5;
    color: var(--color-text-secondary);
}

/* Buttons, the same pills as the landing page */
.rl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: 0;
    border-radius: 999px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

    .rl-btn .e-icons {
        font-size: 12px;
    }

.rl-btn-primary {
    background: var(--color-accent);
    color: var(--color-text-on-accent);
}

    .rl-btn-primary:hover {
        background: var(--color-accent-hover);
        box-shadow: var(--shadow-sm);
    }

/* The three stages as tabs, each showing how many reports it holds */
.rl-stages {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.rl-stage {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid color-mix(in srgb, var(--swatch) 40%, transparent);
    border-left: 4px solid var(--swatch);
    border-radius: 6px;
    /* The header's wash, in the stage's own colour, as on the landing page's stage links */
    background: linear-gradient(120deg, color-mix(in srgb, var(--swatch) 16%, transparent), var(--color-bg-surface) 60%);
    color: var(--color-text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

    .rl-stage:hover {
        background: linear-gradient(120deg, color-mix(in srgb, var(--swatch) 26%, transparent), color-mix(in srgb, var(--swatch) 6%, var(--color-bg-surface)) 60%);
        box-shadow: var(--shadow-sm);
        color: var(--color-text-primary);
    }

    /* The open stage is filled edge to edge rather than washed, so it can't be mistaken for the others */
    .rl-stage.active, .rl-stage.active:hover {
        background: color-mix(in srgb, var(--swatch) 26%, var(--color-bg-surface));
        border-color: color-mix(in srgb, var(--swatch) 70%, transparent);
        border-left-color: var(--swatch);
        box-shadow: var(--shadow-sm);
    }

.rl-stage-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rl-stage-count {
    flex: 0 0 auto;
    min-width: 28px;
    padding: 1px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--swatch) 22%, transparent);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Headline figures for the stage. Each holds a ReportKpiTile, which sizes itself to the box it is given */
.rl-kpis {
    display: grid;
    /* Every stage and filter shows three figures, which share the row and line up under the three stage tabs */
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

    /* A filter with no figures, e.g. Owner-occupied before there are any homes, shouldn't leave a gap */
    .rl-kpis:not(:has(.rl-kpi)) {
        display: none;
    }

/* Tall enough for the tile to keep its line of context, which it drops below 120px of content */
.rl-kpi {
    height: 152px;
    min-width: 0;
    border: 1px solid color-mix(in srgb, var(--swatch) 35%, transparent);
    border-radius: 8px;
    background: var(--color-bg-surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

    /* A figure that names a report opens it, so it lifts on hover like the report tiles below */
    .rl-kpi:has(.rk-clickable):hover, .rl-kpi:has(.rk-clickable):focus-within {
        box-shadow: var(--shadow-md);
        transform: translateY(-1px);
    }

    /* These tiles are narrower than the report's, so their context gets two lines rather than being cut off */
    .rl-kpi .rk-context {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
        line-height: 1.3;
    }

/* The toolbar and the reports it narrows down, in one panel styled like the landing page's cards */
.rl-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 16px;
    border: var(--tpt-border);
    border-radius: 8px;
    background: var(--color-bg-surface);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

/* Search, sort and filter, ruled off from the reports below */
.rl-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    padding-bottom: 14px;
    border-bottom: 1px dashed rgba(var(--color-accent-rgb), 0.35);
}

.rl-search {
    position: relative;
    flex: 1 1 260px;
    max-width: 360px;
}

    .rl-search .e-icons {
        position: absolute;
        top: 50%;
        left: 12px;
        transform: translateY(-50%);
        font-size: 12px;
        color: var(--color-text-secondary);
        pointer-events: none;
    }

.rl-input, .rl-select {
    height: 36px;
    border: var(--tpt-border);
    border-radius: 999px;
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    font-size: 0.875rem;
}

.rl-input {
    width: 100%;
    padding: 0 14px 0 32px;
}

.rl-select {
    padding: 0 12px;
    cursor: pointer;
}

    .rl-input:focus, .rl-select:focus {
        outline: 2px solid var(--color-accent-hover);
        outline-offset: 1px;
    }

.rl-count {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

/* Tiles */
.rl-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rl-tile {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid color-mix(in srgb, var(--swatch) 40%, transparent);
    border-top: 4px solid var(--swatch);
    border-radius: 6px;
    background: color-mix(in srgb, var(--swatch) 5%, var(--color-bg-surface));
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

    .rl-tile:hover, .rl-tile:focus-within {
        box-shadow: var(--shadow-md);
        transform: translateY(-1px);
    }

/* The tile body is the button that opens the report. The actions sit outside it in the footer */
.rl-tile-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 12px 14px 10px;
    border: 0;
    background: none;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.rl-tile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.rl-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rl-sub {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rl-text-warn {
    color: color-mix(in srgb, var(--color-warning) 70%, black);
    font-weight: 600;
}

.rl-chip {
    flex: 0 0 auto;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(var(--color-accent-rgb), 0.18);
    color: var(--color-accent-hover);
    font-size: 0.7rem;
    font-weight: 600;
}

    .rl-chip.rl-chip-let {
        background: color-mix(in srgb, var(--color-success) 18%, transparent);
        color: #2E7D52;
    }

    .rl-chip.rl-chip-home {
        background: color-mix(in srgb, var(--color-warning) 18%, transparent);
        color: var(--color-text-primary);
    }

.rl-progress {
    display: block;
    height: 6px;
    margin: 8px 0 2px;
    border-radius: 999px;
    background: rgba(var(--color-accent-rgb), 0.15);
    overflow: hidden;
}

.rl-progress-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--color-accent);
}

    .rl-progress-fill.rl-over {
        background: var(--color-warning);
    }

.rl-figures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed rgba(var(--color-accent-rgb), 0.35);
}

    .rl-figures > span {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .rl-figures.rl-figures-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* One line each, so every value sits on the same row */
    .rl-figures .rl-label {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

/* Profit and loss, the same greens and reds as the change chips */
.rl-value.rl-good {
    color: #2E7D52;
}

.rl-value.rl-bad {
    color: #A8302F;
}

.rl-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Just the actions, on the right */
.rl-tile-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 4px 6px 6px 14px;
    border-top: 1px dashed rgba(var(--color-accent-rgb), 0.35);
}

.rl-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 2px;
}

.rl-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--color-text-secondary);
    cursor: pointer;
}

    .rl-icon-btn:hover {
        background: rgba(var(--color-accent-rgb), 0.18);
        color: var(--color-accent-hover);
    }

    .rl-icon-btn.rl-icon-danger:hover {
        background: color-mix(in srgb, var(--color-danger) 18%, transparent);
        color: #A8302F;
    }

/* Nothing in this stage yet, or nothing matching the search */
.rl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 24px;
    border: 1px dashed rgba(var(--color-accent-rgb), 0.45);
    border-radius: 8px;
    background: var(--color-bg-surface);
    text-align: center;
}

    .rl-empty h2 {
        margin: 4px 0 0;
        font-size: 1.15rem;
        font-weight: 600;
    }

    .rl-empty p {
        max-width: 460px;
        margin: 0 0 4px;
        color: var(--color-text-secondary);
    }

.rl-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--swatch) 20%, transparent);
    color: color-mix(in srgb, var(--swatch) 70%, black);
    font-size: 18px;
}

/* Focus */
.rl-btn:focus-visible, .rl-stage:focus-visible, .rl-tile-main:focus-visible, .rl-icon-btn:focus-visible {
    outline: 2px solid var(--color-accent-hover);
    outline-offset: 2px;
}

/* Narrow screens */
@media (max-width: 575.98px) {
    /* Three across leaves no room for the names, so they stack as compact rows */
    .rl-stages {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
    }

    .rl-stage {
        padding: 7px 12px;
    }

    .rl-head {
        flex-wrap: wrap;
        padding: 16px;
    }

        .rl-head .rl-btn {
            width: 100%;
            justify-content: center;
        }

    .rl-head-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    /* A zero basis keeps the title and summary beside the icon, as the landing page's greeting does, rather than wrapping under it */
    .rl-head-text {
        flex: 1 1 0;
    }

    .rl-title {
        font-size: 1.3rem;
    }

    .rl-panel {
        padding: 10px;
    }

    .rl-search {
        max-width: none;
    }

    .rl-count {
        margin-left: 0;
    }
}
