/* Dashboard colour tokens */
:root {
    --ds-blue: #1d70b8;
    --ds-dark-blue: #003078;
    --ds-black: #0b0c0c;
    --ds-dark-grey: #505a5f;
    --ds-mid-grey: #b1b4b6;
    --ds-light-grey: #f3f2f1;
    --ds-green: #00703c;
    --ds-red: #d4351c;
    --ds-orange: #f47738;
}

/* Dashboard Hero Header */
.dashboard-hero {
    padding-bottom: 24px;
    margin-bottom: 32px;
    border-bottom: 4px solid var(--ds-black);
}

.dashboard-hero .service-kicker {
    font-size: 1.1rem;
    font-weight: 700;
    color: #505a5f;
    margin: 0 0 8px 0;
    text-transform: none;
}

.dashboard-hero .service-title {
    font-size: 2.2rem;
    font-weight: 700;
    color: #0b0c0c;
    margin: 0 0 16px 0;
    line-height: 1.15;
}

.dashboard-hero .service-lead {
    font-size: 1.15rem;
    color: #505a5f;
    margin: 0;
    max-width: 52rem;
    line-height: 1.5;
}

.dashboard-hero .service-lead a {
    color: #1d70b8;
    text-decoration: underline;
}

.dashboard-hero .service-lead a:hover {
    color: #003078;
}

.trust-panel {
    background: white;
    border: 1px solid var(--ds-mid-grey);
    border-left: 6px solid var(--ds-black);
    padding: 20px;
    margin-bottom: 24px;
}

.trust-panel h2 {
    margin: 0 0 12px 0;
    font-size: 19px;
}

.trust-panel p {
    max-width: 52rem;
    margin: 0 0 14px 0;
    line-height: 1.5;
}

.trust-panel p:last-child {
    margin-bottom: 0;
}

.trust-panel a {
    color: var(--ds-blue);
    text-decoration: underline;
}

.trust-list,
.definition-list {
    margin: 0 0 16px 0;
}

.trust-list div,
.definition-list div {
    display: grid;
    grid-template-columns: minmax(160px, 220px) 1fr;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--ds-light-grey);
}

.trust-list dt,
.definition-list dt {
    font-weight: 700;
}

.trust-list dd,
.definition-list dd {
    margin: 0;
}

@media (max-width: 860px) {
    .dashboard-hero .service-title {
        font-size: 1.8rem;
    }
}

/* Month Selector */
.month-selector {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--ds-light-grey);
    border-left: 4px solid var(--ds-blue);
}

.month-selector__row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
}

.month-selector__row label {
    white-space: nowrap;
}

.month-selector__row .apply-btn {
    flex: 0 0 auto;
}

.month-selector__row select[name="constabulary"],
.month-selector__row select[name="constabulary_a"],
.month-selector__row select[name="constabulary_b"] {
    min-width: 12rem;
}

.month-selector label {
    font-weight: 700;
}

.month-selector select {
    padding: 6px 10px;
    border: 2px solid var(--ds-black);
    font-size: 16px;
    min-width: 9rem;
}

.month-selector .apply-btn {
    padding: 8px 16px;
    background: var(--ds-black);
    color: white;
    border: none;
    font-weight: 700;
    cursor: pointer;
}

.month-selector .apply-btn:hover {
    background: #333333;
}

.trends-comparison-form {
    align-items: stretch;
}

.comparison-scope {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 10px 12px;
    min-width: 320px;
    flex: 1 1 420px;
    padding: 16px;
    background: #ffffff;
    border: 1px solid #b1b4b6;
}

.comparison-scope h3 {
    grid-column: 1 / -1;
    margin: 0 0 4px;
}

.comparison-scope label {
    align-self: end;
}

.comparison-scope-note {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    font-size: 0.95rem;
    color: var(--ds-dark-grey);
}

.comparison-summary-card p:last-child {
    margin-bottom: 0;
}

/* Stats Grid */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--ds-light-grey);
    padding: 20px;
    border-left: 4px solid var(--ds-blue);
}

.stat-card:nth-child(2) {
    border-left-color: var(--ds-green);
}

.stat-card:nth-child(3) {
    border-left-color: var(--ds-orange);
}

.stat-card:nth-child(4) {
    border-left-color: var(--ds-dark-grey);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--ds-black);
}

.stat-label {
    color: var(--ds-dark-grey);
    font-size: 14px;
}

/* Insights Grid */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.insight-card {
    background: white;
    border-left: 4px solid;
    padding: 16px;
    border-bottom: 1px solid var(--ds-mid-grey);
}

.insight-card h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    text-transform: uppercase;
}

.insight-card p {
    margin: 0;
    font-size: 16px;
}

.insight-card .detail {
    font-size: 14px;
    color: var(--ds-dark-grey);
}

.chart-note,
.detail {
    color: var(--ds-dark-grey);
    font-size: 14px;
}

.dashboard-details {
    margin-top: 16px;
    overflow-x: auto;
    max-width: 100%;
}

.dashboard-details summary {
    color: var(--ds-blue);
    cursor: pointer;
    font-weight: 700;
    text-decoration: underline;
}

.dashboard-details table {
    margin-top: 12px;
}

.metric-definitions {
    background: white;
    border-left: 4px solid var(--ds-blue);
    padding: 12px 16px;
    margin-bottom: 24px;
}

.section-disclosure {
    border-top: 2px solid var(--ds-black);
    padding-top: 12px;
    margin: 32px 0 20px 0;
}

.section-disclosure > summary {
    color: var(--ds-black);
    font-size: 1.25rem;
    text-decoration: none;
    cursor: pointer;
    display: block;
    position: relative;
    padding-right: 20px;
}

.section-disclosure > summary::-webkit-details-marker,
.section-disclosure > summary::marker {
    display: none;
}

.section-disclosure > summary::after {
    content: '▸';
    position: absolute;
    right: 0;
    top: 0;
    color: var(--ds-dark-grey);
    font-size: 1rem;
    line-height: 1.25;
}

.section-disclosure[open] > summary::after {
    content: '▾';
}

.section-title-details {
    border-top: 0;
    padding: 0;
    margin: 32px 0 20px 0;
}

.section-title-details > summary {
    color: var(--ds-black);
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 2px solid var(--ds-black);
    padding: 0 0 10px 0;
    margin: 0 0 16px 0;
}

/* Layout Grids */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

/* Cards */
.card {
    background: white;
    padding: 20px;
    border: 1px solid var(--ds-mid-grey);
    border-bottom: 4px solid var(--ds-mid-grey);
    width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.card h2 {
    font-size: 19px;
    font-weight: 700;
    margin: 0 0 16px 0;
}

.card h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: var(--ds-black);
}

.card h3 .find-rate-subtitle {
    font-weight: 400;
    color: var(--ds-dark-grey);
    font-size: 14px;
}

/* Chart Containers */
.chart-container {
    position: relative;
    width: 100%;
}

.chart-container.h250 { height: 250px; }
.chart-container.h300 { height: 300px; }
.chart-container.h350 { height: 350px; }
.chart-container.h400 { height: 400px; }
.chart-container.h450 { height: 450px; }
.chart-container.h600 { height: 600px; }

/* Section Titles */
.section-title {
    color: var(--ds-black);
    padding: 0 0 10px 0;
    margin: 32px 0 16px 0;
    font-weight: 700;
    font-size: 1.25rem;
    border-bottom: 2px solid var(--ds-black);
}

.section-title h2,
.section-title h3 {
    color: var(--ds-black);
    margin: 0;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--ds-mid-grey);
}

th {
    font-weight: 700;
    background: var(--ds-light-grey);
}

tr:hover {
    background: #fafafa;
}

/* Rate indicators */
.low-rate {
    color: var(--ds-red);
    font-weight: 700;
}

.high-rate {
    color: var(--ds-green);
    font-weight: 700;
}

.rate-bar {
    display: inline-block;
    height: 16px;
    vertical-align: middle;
    margin-right: 6px;
}

/* Ring chart center label */
.ring-wrapper {
    position: relative;
}

.ring-center-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.ring-center-label .ring-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--ds-black);
    line-height: 1.1;
}

.ring-center-label .ring-sub {
    font-size: 14px;
    color: var(--ds-dark-grey);
}

/* Disclaimer */
.disclaimer {
    border-left: 6px solid var(--ds-black);
    background: white;
    padding: 16px;
    margin: 20px 0;
    font-size: 14px;
    color: var(--ds-dark-grey);
}

.disclaimer strong {
    color: var(--ds-black);
}

.disclaimer a {
    color: var(--ds-blue);
    text-decoration: underline;
}

.disclaimer a:hover {
    color: var(--ds-dark-blue);
}

/* Alert tag */
.alert-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #fdf2f4;
    color: var(--ds-red);
    font-size: 12px;
    font-weight: 700;
}

/* ── Additional stat grid column variants ───────────────────────────── */

/* 5-column stat grid (used by all_time_summary_dashboard) */
.stats-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

/* Override nth-child border colours for 5-card grids */
.stats-5 .stat-card:nth-child(5) {
    border-left-color: var(--ds-red);
}

/* ── Stat change badge (used by trends_dashboard) ────────────────────── */
/* Badge displayed beneath a stat value to show month-over-month movement */
.stat-change {
    display: inline-block;
    margin-top: 6px;
    font-size: 13px;
    font-weight: 700;
    padding: 2px 8px;
    background: var(--ds-light-grey);
    color: var(--ds-dark-grey);
}

/* Directional movement badges use neutral contrast rather than good/bad semantics */
.stat-change.direction-up {
    background: #fff1e5;
    color: #8f3d00;
}

.stat-change.direction-down {
    background: #eef4ff;
    color: var(--ds-blue);
}

.stat-change.direction-flat,
.stat-change.neutral {
    background: var(--ds-light-grey);
    color: var(--ds-dark-grey);
}

/* ── Table change colour helpers (trends_dashboard) ─────────────────── */
.change-direction-down {
    color: var(--ds-blue);
    font-weight: 700;
}

.change-direction-up {
    color: #8f3d00;
    font-weight: 700;
}

.change-direction-flat,
.change-neutral {
    color: var(--ds-dark-grey);
    font-weight: 700;
}

/* ── "vs" separator label in trends month selector ───────────────────── */
.vs-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--ds-dark-grey);
    text-transform: uppercase;
}

/* ── Extra chart container heights ──────────────────────────────────── */
.chart-container.h500 { height: 500px; }

/* ── Data range badge (all_time_summary_dashboard) ───────────────────── */
.data-range-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: var(--ds-light-grey);
    color: var(--ds-dark-grey);
    font-size: 14px;
    font-weight: 700;
    border-left: 4px solid var(--ds-blue);
}

/* Responsive */
@media (max-width: 900px) {
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-5 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .stats {
        grid-template-columns: 1fr;
    }
    .stats-5 {
        grid-template-columns: 1fr;
    }
    .month-selector {
        flex-direction: column;
        align-items: flex-start;
    }
    .month-selector__row {
        flex-wrap: nowrap;
        overflow-x: auto;
        width: 100%;
        padding-bottom: 2px;
    }
    .comparison-scope {
        grid-template-columns: 1fr;
        width: 100%;
        min-width: 0;
    }
    .trust-list div,
    .definition-list div {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
