/* Report dialog ("Rapport", report.js). Only #modal-report and rp- classes; nothing here changes
   an existing rule. Colours come from the theme tokens in styles.css. */

/* Above the phone drawers (z-index 1500), below the toasts (9999) */
#modal-report.modal-backdrop {
    z-index: 1600;
}
#modal-report .rp-dialog {
    width: min(1040px, 96vw);
    max-width: 96vw;
    height: min(88vh, 900px);
    overflow: hidden;
}
#modal-report .rp-dialog:focus {
    outline: none;
}

/* ---------- Tabs ---------- */
.rp-tabs {
    display: flex;
    gap: 0;
    padding: 12px 24px 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
    flex: none;
}
.rp-tab {
    min-height: 40px;
    padding: 0 14px;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}
.rp-tab:hover {
    color: var(--ink);
}
.rp-tab[aria-selected="true"] {
    color: var(--ink);
    font-weight: 600;
    border-bottom-color: var(--ink);
}

/* ---------- Body ---------- */
#modal-report .rp-body {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    gap: 16px;
    font-family: var(--font-ui);
    color: var(--ink);
}
#modal-report .rp-body:focus {
    outline: none;
}
#modal-report .rp-body p.rp-status,
#modal-report .rp-body p.rp-empty {
    color: var(--muted);
}
#modal-report .rp-body p.rp-lead {
    color: var(--ink);
    font-family: var(--font-title);
    font-size: 22px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}
#modal-report .rp-body p.rp-note {
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink);
}
#modal-report .rp-body p.rp-foot {
    font-size: 13px;
}

/* ---------- Overview ---------- */
.rp-stats {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
}
.rp-stat {
    padding: 12px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    min-width: 0;
}
.rp-stat dt {
    font-size: 12px;
    color: var(--muted);
}
.rp-stat dd {
    margin: 4px 0 0;
    font-size: 24px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.rp-bars h4 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
}
.rp-bars ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rp-bar-row {
    display: grid;
    grid-template-columns: minmax(80px, 180px) minmax(60px, 1fr) auto;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}
.rp-bar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rp-bar-track {
    height: 10px;
    background: var(--fill);
    border-radius: 2px;
    overflow: hidden;
}
.rp-bar-fill {
    display: block;
    height: 100%;
    background: var(--ink);
}
.rp-bar-count {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- Tables ---------- */
.rp-table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
#modal-report .rp-body p.rp-count {
    color: var(--muted);
    font-size: 13px;
}
/* Wide tables scroll sideways in their own box, never the page. flex: none: in the body's flex
   column a scrolling box would otherwise shrink and scroll up and down on its own too. */
.rp-table-wrap {
    flex: none;
    max-width: 100%;
    overflow-x: auto;
    border-top: 1px solid var(--line-strong);
}
.rp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.rp-table th,
.rp-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
    vertical-align: top;
}
.rp-table td.wide {
    white-space: normal;
    min-width: 14em;
}
.rp-table th.num,
.rp-table td.num {
    text-align: right;
}
.rp-table th {
    padding: 0;
    color: var(--muted);
    font-weight: 600;
}
.rp-sort {
    width: 100%;
    min-height: 36px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: inherit;
    white-space: nowrap;
    cursor: pointer;
}
.rp-table th.num .rp-sort {
    justify-content: flex-end;
}
.rp-sort:hover,
.rp-table th[aria-sort] .rp-sort {
    color: var(--ink);
}
.rp-sort-mark {
    font-size: 9px;
}
.rp-table tr.rp-link {
    cursor: pointer;
}
.rp-table tr.rp-link:hover td {
    background: var(--fill);
}
.rp-table tr.rp-link:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}
.rp-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Phone (same breakpoint as MOBILE_QUERY in app.js): the dialog fills the screen ---------- */
@media (max-width: 850px) {
    #modal-report.modal-backdrop {
        padding: 0;
        height: 100vh;
        height: 100dvh;
    }
    #modal-report .rp-dialog {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh;
        border: 0;
        border-radius: 0;
    }
    #modal-report .modal-header {
        padding: 8px 8px 8px 16px;
    }
    .rp-tabs {
        padding: 4px 8px 0;
    }
    .rp-tab {
        min-height: 44px;
        flex: 1;
        padding: 0 8px;
    }
    #modal-report .rp-body {
        padding: 16px;
    }
    #modal-report .modal-footer {
        padding: 12px 16px;
    }
    #modal-report .modal-footer .btn {
        flex: 1;
    }
    .rp-sort {
        min-height: 44px;
    }
    .rp-table td {
        padding: 10px 8px;
    }
    .rp-bar-row {
        grid-template-columns: minmax(70px, 110px) minmax(40px, 1fr) auto;
        gap: 8px;
    }
}
