/* ==================== DTP Dashboard — Methodist design system ==================== */
/* Roboto + Antonio (Methodist primary fonts), brand palette, sidebar layout.
   Brand source: 01-programme/brand-guidelines.md.
   Tokens cross-referenced with the WS-P15 prototype's design tokens (which
   were extracted from methodist.org.uk live, 24 Apr 2026), so the dashboard
   reads as part of the same Methodist design family. */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700;900&family=Roboto+Condensed:wght@400;700&family=Antonio:wght@700&display=swap');

:root {
    /* Layout */
    --sidebar-width: 240px;
    --summary-bar-height: 72px;
    --table-row-min-height: 48px;

    /* ---- Brand fonts ---- */
    --font-body: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    --font-condensed: 'Roboto Condensed', 'Roboto', Arial, sans-serif;
    --font-display: 'Antonio', 'Roboto Condensed', Arial, sans-serif;

    /* ---- Neutral surfaces (kept calm — this is a working tool) ---- */
    --bg: #f8f9fa;
    --surface: #ffffff;
    --surface-solid: #fff;
    --surface-alt: #f1f3f5;
    --border: #e9ecef;
    --border-subtle: #f1f3f5;
    --text: #221C35;        /* Methodist navy — replaces near-black */
    --text-secondary: #4a4458;
    --text-tertiary: #7d868c;  /* Brand mid-grey (Pantone 430) */

    /* ---- Methodist brand palette ---- */
    /* Primary */
    --accent: #c51718;          /* Methodist Red — Pantone 186 */
    --accent-hover: #8e1538;    /* Dark Red — Pantone 1955 */
    --accent-light: rgba(197,23,24,0.08);

    /* Secondary mids (used for status, tiers, RAID categories below) */
    --mc-purple: #8f4899;
    --mc-blue: #234e9d;
    --mc-orange: #f6a117;
    --mc-orange-dark: #ee7623;
    --mc-yellow: #ffcd00;
    --mc-teal: #008996;
    --mc-pink: #cb007b;
    --mc-green: #459d68;
    --mc-green-dark: #006548;

    /* ---- Status (mapped to brand mids) ---- */
    --status-green: #459d68;    /* Mid green */
    --status-amber: #f6a117;    /* Mid orange (closer to Methodist amber than yellow) */
    --status-red: #c51718;      /* Methodist red */
    --green: #459d68;
    --amber: #f6a117;
    --red: #c51718;
    --teal: #008996;            /* Mid teal */
    --purple: #8f4899;          /* Mid purple */

    /* ---- Status pills ---- */
    --status-on-track: #459d68;
    --status-at-risk: #f6a117;
    --status-blocked: #c51718;
    --status-waiting: #008996;
    --status-complete: #7d868c;
    --status-not-started: #e5e7eb;
    --status-idea: #f3f4f6;

    /* ---- Maturity tiers ---- */
    --tier-leading: #459d68;     /* Mid green */
    --tier-established: #234e9d; /* Mid blue */
    --tier-developing: #f6a117;  /* Mid orange */
    --tier-minimal: #c51718;     /* Methodist red */

    /* ---- RAID categories (semantic mapping) ---- */
    --raid-risk: #c51718;        /* Methodist red */
    --raid-assumption: #234e9d;  /* Mid blue */
    --raid-issue: #f6a117;       /* Mid orange */
    --raid-dependency: #8f4899;  /* Mid purple */

    /* Sidebar */
    --sidebar-bg: #fafafa;
    --sidebar-border: #e9ecef;
    --sidebar-item-hover: #f1f3f5;
    --sidebar-item-active: #fef2f2;
    --sidebar-text: #6b7280;
    --sidebar-text-active: #c51718;

    /* Tokens */
    --radius: 8px;
    --radius-lg: 12px;
    --gap: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --separator: #e5e7eb;
    --max-width: 1400px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0a0a;
        --surface: #141414;
        --surface-solid: #141414;
        --surface-alt: #1f1f1f;
        --border: #262626;
        --border-subtle: #1a1a1a;
        --text: #f9fafb;
        --text-secondary: #d1d5db;
        --text-tertiary: #6b7280;
        --accent-light: rgba(197,23,24,0.15);
        --separator: #262626;
        --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
        --shadow-md: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.2);
        --status-not-started: #374151;
        --status-idea: #1f2937;

        --sidebar-bg: #0f0f0f;
        --sidebar-border: #1f1f1f;
        --sidebar-item-hover: #1a1a1a;
        --sidebar-item-active: rgba(197,23,24,0.12);
        --sidebar-text: #9ca3af;
        --sidebar-text-active: #ef4444;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    font-size: 14px;
    letter-spacing: -0.1px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    min-height: 100vh;
}

/* ==================== MOBILE HEADER ==================== */

.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1001;
    height: calc(48px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
    align-items: center;
    gap: 12px;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:hover { background: var(--surface-alt); }

.mobile-title {
    font-family: var(--font-condensed);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ==================== SIDEBAR ==================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1002;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
}

.sidebar-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-brand-name {
    font-family: var(--font-condensed);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand-sub {
    font-size: 11px;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 8px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
    cursor: pointer;
    border-left: 3px solid transparent;
    margin-bottom: 2px;
}

.sidebar-item:hover {
    background: var(--sidebar-item-hover);
    color: var(--text);
}

.sidebar-item.active {
    background: var(--sidebar-item-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-item.active .sidebar-icon {
    opacity: 1;
    stroke: var(--accent);
}

.sidebar-item:hover .sidebar-icon { opacity: 1; }

.sidebar-icon-text {
    width: 18px;
    font-size: 9px;
    font-weight: 700;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.6;
    letter-spacing: -0.3px;
}

.sidebar-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.sidebar-ext-icon {
    width: 10px;
    height: 10px;
    opacity: 0.4;
    flex-shrink: 0;
}

.sidebar-external:hover .sidebar-ext-icon { opacity: 0.7; }

.sidebar-footer {
    padding: 0 8px 12px;
}

.sidebar-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 8px 12px;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    padding: 8px 12px 4px;
}

/* ==================== MAIN WRAPPER ==================== */

.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== SUMMARY BAR ==================== */

.summary-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    min-height: var(--summary-bar-height);
}

.summary-metrics {
    display: flex;
    gap: 16px;
    flex: 1;
    overflow-x: auto;
}

.summary-card {
    flex: 1;
    min-width: 120px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: var(--surface-alt);
    border: 1px solid var(--border-subtle);
}

.summary-card-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0;
    margin-bottom: 2px;
}

.summary-card-value {
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-gauge { flex-shrink: 0; }

.summary-number {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    font-feature-settings: "tnum";
    color: var(--text);
}

.summary-unit {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
}

/* ==================== MAIN CONTENT ==================== */

.main-content {
    flex: 1;
    padding: 24px;
    max-width: var(--max-width);
}

.view-header {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}
/* Methodist vertical red rule — brand grace note next to page titles. */
.view-header::before {
    content: "";
    display: block;
    width: 3px;
    height: 26px;
    background: var(--accent);
    border-radius: 1px;
    flex-shrink: 0;
}

.page-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    color: var(--text);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: var(--gap);
}

/* ==================== EMPTY STATES ==================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 13px;
    color: var(--text-tertiary);
    max-width: 400px;
    line-height: 1.6;
}

/* ==================== CARDS ==================== */

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    padding: 16px;
    min-height: 80px;
    transition: box-shadow 0.15s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-full { grid-column: 1 / -1; }
.card-half { }
.card-third { }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.card-header::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--text-tertiary);
    border-bottom: 1.5px solid var(--text-tertiary);
    transform: rotate(45deg);
    transition: transform 0.25s ease;
    margin-left: 8px;
    flex-shrink: 0;
}

.card.collapsed .card-header::after {
    transform: rotate(-45deg);
}

.card-header[style*="cursor: default"]::after {
    display: none;
}

.card-body {
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    max-height: 2000px;
    opacity: 1;
}

.card.collapsed .card-body {
    max-height: 0;
    opacity: 0;
}

.card-compact {
    display: none;
    margin-top: 8px;
}

.card.collapsed .card-compact {
    display: flex;
    gap: 12px;
    align-items: baseline;
}

.compact-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-feature-settings: "tnum";
    letter-spacing: -0.02em;
}

.compact-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.card-label {
    font-family: var(--font-condensed);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
}

.card-updated {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ==================== DETAIL LINK ==================== */

.card-detail-link {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    padding: 2px 0;
    margin-left: auto;
    margin-right: 8px;
    white-space: nowrap;
}

.card-detail-link:hover { opacity: 0.7; }

/* ==================== METRICS ==================== */

.metric-value {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    font-feature-settings: "tnum";
    line-height: 1.1;
    color: var(--text);
}

.metric-value-sm {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-feature-settings: "tnum";
    line-height: 1.1;
}

.metric-unit {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-tertiary);
}

.metric-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.stat-row {
    display: flex;
    gap: var(--gap);
    flex-wrap: wrap;
}

.stat-item {
    flex: 1;
    min-width: 100px;
    text-align: center;
}

/* ==================== PROGRESS BARS ==================== */

.progress-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--surface-alt);
    overflow: hidden;
    margin: 6px 0;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

.progress-label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 140px;
    flex-shrink: 0;
}

.progress-track { flex: 1; position: relative; }

.progress-value {
    font-size: 12px;
    font-weight: 600;
    font-feature-settings: "tnum";
    min-width: 40px;
    text-align: right;
}

.progress-target {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 10px;
    background: var(--text-tertiary);
    border-radius: 1px;
    opacity: 0.5;
}

/* ==================== STATUS PILLS ==================== */

.status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.pill-on-track { background: rgba(39,174,96,0.12); color: #1e8449; }
.pill-at-risk { background: rgba(243,156,18,0.12); color: #c0850a; }
.pill-blocked { background: rgba(231,76,60,0.12); color: #c0392b; }
.pill-waiting { background: rgba(52,152,219,0.12); color: #2471a3; }
.pill-complete { background: var(--surface-alt); color: var(--text-tertiary); }
.pill-not-started { background: var(--surface-alt); color: var(--text-tertiary); }
.pill-idea { background: var(--status-idea); color: var(--text-tertiary); }
.pill-high { background: rgba(231,76,60,0.12); color: #c0392b; }
.pill-medium { background: rgba(243,156,18,0.12); color: #c0850a; }

@media (prefers-color-scheme: dark) {
    .pill-on-track { background: rgba(39,174,96,0.2); color: #2ecc71; }
    .pill-at-risk { background: rgba(243,156,18,0.2); color: #f5b041; }
    .pill-blocked { background: rgba(231,76,60,0.2); color: #ec7063; }
    .pill-waiting { background: rgba(52,152,219,0.2); color: #5dade2; }
    .pill-high { background: rgba(231,76,60,0.2); color: #ec7063; }
    .pill-medium { background: rgba(243,156,18,0.2); color: #f5b041; }
}

/* ==================== RADIAL GAUGE ==================== */

.gauge-container { display: flex; align-items: center; gap: 24px; }
.gauge-svg { flex-shrink: 0; }
.gauge-dimensions { flex: 1; }

/* ==================== TABLES ==================== */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table-scroll .data-table {
    min-width: 500px;
}

.data-table th {
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    min-height: var(--table-row-min-height);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    min-height: var(--table-row-min-height);
    height: var(--table-row-min-height);
}

.data-table tr:last-child td { border-bottom: none; }

/* Alternating row backgrounds */
.data-table tbody tr:nth-child(even) td {
    background: var(--surface-alt);
}

.data-table tr:hover td { background: var(--accent-light); }

/* ==================== PROJECT LIST ==================== */

.project-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
    min-height: var(--table-row-min-height);
}

.project-item:last-child { border-bottom: none; }

.project-name { font-size: 13px; font-weight: 600; flex: 1; }
.project-meta { font-size: 12px; color: var(--text-tertiary); }

/* ==================== TIMELINE ==================== */

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    min-height: var(--table-row-min-height);
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}

.dot-pending { background: var(--accent); }
.dot-complete { background: var(--green); }
.dot-overdue { background: var(--amber); }

.timeline-content { flex: 1; }
.timeline-date { font-size: 11px; font-weight: 600; color: var(--text-tertiary); }
.timeline-text { font-size: 13px; color: var(--text-secondary); margin-top: 1px; }
.timeline-source { font-size: 11px; color: var(--text-tertiary); }

/* ==================== RAID QUADRANT ==================== */

.raid-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.raid-cell {
    text-align: center;
    padding: 14px 8px;
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.raid-count { font-size: 1.8rem; font-weight: 700; font-feature-settings: "tnum"; line-height: 1.1; }
.raid-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); margin-top: 4px; }

.raid-risk { border-left: 3px solid var(--raid-risk); }
.raid-assumption { border-left: 3px solid var(--raid-assumption); }
.raid-issue { border-left: 3px solid var(--raid-issue); }
.raid-dependency { border-left: 3px solid var(--raid-dependency); }

/* ==================== DONUT / LEGEND ==================== */

.donut-container { display: flex; align-items: center; gap: 20px; }
.donut-legend { flex: 1; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-count { font-weight: 600; font-feature-settings: "tnum"; margin-left: auto; }

/* ==================== PIPELINE ==================== */

.pipeline-stage { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.pipeline-stage:last-child { border-bottom: none; }
.pipeline-count { font-size: 1.6rem; font-weight: 700; font-feature-settings: "tnum"; min-width: 40px; }
.pipeline-label { font-size: 13px; font-weight: 500; }
.pipeline-sublabel { font-size: 12px; color: var(--text-tertiary); }

/* ==================== COMMS ==================== */

.comms-item { padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.comms-item:last-child { border-bottom: none; }
.comms-meta { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--text-tertiary); margin-bottom: 2px; }
.comms-subject { font-size: 13px; color: var(--text-secondary); }
.channel-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; background: var(--surface-alt); color: var(--text-tertiary); }

/* ==================== THEME BARS ==================== */

.theme-bar-item { margin: 6px 0; }
.theme-bar-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 3px; display: flex; justify-content: space-between; }
.theme-bar-count { font-weight: 600; font-feature-settings: "tnum"; color: var(--text); }
.theme-bar { height: 8px; border-radius: 4px; background: var(--surface-alt); overflow: hidden; }
.theme-bar-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.5s ease; }
.theme-bar-fill.connexion-wide { background: var(--green); }

/* ==================== TOOLTIP ==================== */

.tooltip-trigger { cursor: pointer; -webkit-tap-highlight-color: transparent; position: relative; }
.tooltip-trigger:hover { opacity: 0.85; }

.tooltip-popover {
    display: none;
    position: fixed;
    z-index: 2000;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
    padding: 12px 16px;
    max-width: 300px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    pointer-events: none;
}

.tooltip-popover.visible { display: block; animation: tooltip-in 0.2s ease; }
@keyframes tooltip-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.tooltip-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.tooltip-list { list-style: none; padding: 0; margin: 0; }
.tooltip-list li { padding: 2px 0; border-bottom: 1px solid var(--border); }
.tooltip-list li:last-child { border-bottom: none; }

/* ==================== BACK BUTTON ==================== */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    margin-bottom: 4px;
}

.back-link::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-left: 1.5px solid var(--accent);
    border-bottom: 1.5px solid var(--accent);
    transform: rotate(45deg);
}

.back-link:hover { opacity: 0.7; }

/* ==================== LOADING ==================== */

.loading { color: var(--text-tertiary); font-size: 13px; padding: 20px; text-align: center; }

/* ==================== SETTINGS ==================== */

.settings-category { margin-bottom: 24px; }
.settings-category-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); margin-bottom: 8px; padding-left: 16px; }
.settings-list { background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.settings-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); }
.settings-item:last-child { border-bottom: none; }
.settings-label { font-size: 14px; }

.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; inset: 0; background: #d1d5db; border-radius: 24px; transition: background 0.3s; cursor: pointer; }
.toggle-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.15); transition: transform 0.3s; }
.toggle input:checked + .toggle-track { background: var(--green); }
.toggle input:checked + .toggle-track::after { transform: translateX(20px); }

/* ==================== DETAIL PAGES ==================== */

.detail-section { margin-bottom: 28px; }
.detail-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); margin-bottom: 10px; }
.detail-card { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; margin-bottom: var(--gap); border: 1px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.detail-meta-item { padding: 10px; border-radius: var(--radius); background: var(--surface-alt); }
.detail-meta-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); margin-bottom: 4px; }
.detail-meta-value { font-size: 1.2rem; font-weight: 700; font-feature-settings: "tnum"; }

/* ==================== EXPLORER ==================== */

.explorer-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    height: 100vh;
    overflow: hidden;
    margin: -24px;
}

.explorer-map { position: relative; min-height: 300px; }
.explorer-map .leaflet-container { height: 100%; width: 100%; background: var(--bg); }

.explorer-panel {
    overflow-y: auto;
    padding: var(--gap);
    border-left: 1px solid var(--border);
    background: var(--bg);
}

.breadcrumb { display: flex; flex-wrap: wrap; gap: 2px; font-size: 12px; color: var(--text-tertiary); margin-bottom: 12px; align-items: center; }
.breadcrumb a { color: var(--accent); text-decoration: none; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 4px; }

.filter-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
    margin-bottom: 8px;
}
.filter-select {
    font-size: 12px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 6px;
    background: var(--surface);
    color: var(--text);
    min-width: 0;
    width: 100%;
}
.filter-reset {
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 6px;
    padding: 5px 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.filter-reset.active {
    opacity: 1;
}

.explorer-search {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    margin-bottom: 12px;
}

.explorer-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.explorer-search::placeholder { color: var(--text-tertiary); }

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.search-results.visible { display: block; }
.search-result-item { padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; font-size: 13px; }
.search-result-item:hover { background: var(--accent-light); }
.search-result-item:last-child { border-bottom: none; }
.search-result-type { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
.search-result-detail { font-size: 12px; color: var(--text-tertiary); }

.district-card-sm {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.district-card-sm:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(197,23,24,0.08); }
.district-card-sm .dc-name { font-size: 14px; font-weight: 600; }
.district-card-sm .dc-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.district-card-sm .dc-score { text-align: right; flex-shrink: 0; }
.district-card-sm .dc-maturity { font-size: 1.2rem; font-weight: 800; font-feature-settings: "tnum"; }

.circuit-item, .church-item { padding: 10px 0; border-bottom: 1px solid var(--border-subtle); cursor: pointer; }
.circuit-item:last-child, .church-item:last-child { border-bottom: none; }
.circuit-item:hover, .church-item:hover { opacity: 0.8; }

.church-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; flex-shrink: 0; }

.explorer-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.explorer-stat { text-align: center; padding: 10px 6px; border-radius: var(--radius); background: var(--surface-alt); }
.explorer-stat-value { font-size: 1.3rem; font-weight: 800; font-feature-settings: "tnum"; }
.explorer-stat-label { font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; }

.map-legend {
    position: absolute;
    bottom: 20px;
    left: 12px;
    z-index: 1000;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
}

.legend-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.legend-dot-sm { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

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

/* Tablet: sidebar collapsible */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
        opacity: 1;
    }

    .mobile-header {
        display: flex;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .summary-bar {
        top: calc(48px + env(safe-area-inset-top)); /* Below mobile header, including iOS safe area */
    }

    .summary-metrics {
        flex-wrap: wrap;
    }

    .summary-card {
        min-width: 100px;
        flex: 0 0 calc(50% - 8px);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .main-content { padding: 16px; }

    .dashboard-grid { grid-template-columns: 1fr; gap: 12px; }
    .card-full, .card-half, .card-third { grid-column: auto; }
    .card { padding: 12px; overflow: hidden; }

    .page-title { font-size: 18px; }
    .metric-value { font-size: 2rem; }
    .metric-value-sm { font-size: 1.5rem; }
    .gauge-container { flex-direction: column; align-items: center; }
    .gauge-dimensions { width: 100%; }
    .progress-label { min-width: 90px; font-size: 11px; }
    .progress-value { min-width: 30px; font-size: 11px; }
    .donut-container { flex-direction: column; align-items: center; gap: 12px; }
    .donut-legend { width: 100%; }
    .stat-row { gap: 8px; }
    .stat-item { min-width: 70px; }
    .project-item { flex-wrap: wrap; gap: 6px; }
    .project-name { font-size: 12px; }
    .raid-grid { gap: 6px; }
    .raid-count { font-size: 1.4rem; }
    .pipeline-count { font-size: 1.2rem; min-width: 30px; }

    .card-header { flex-wrap: wrap; gap: 4px; }
    .card-label { font-size: 10px; }
    .card-detail-link { font-size: 10px; }
    .card-updated { font-size: 10px; }

    .summary-bar {
        padding: 8px 16px;
        min-height: auto;
    }

    .summary-card {
        flex: 0 0 calc(50% - 8px);
    }

    .summary-card:last-child {
        flex: 0 0 100%;
    }

    .explorer-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 50vh 1fr;
        height: auto;
    }
    .explorer-panel {
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .explorer-stat-row { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .explorer-stat-value { font-size: 1rem; }
    .district-card-sm { padding: 10px 12px; }
    .district-card-sm .dc-name { font-size: 13px; }
    .district-card-sm .dc-maturity { font-size: 1rem; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ==================== PRINT ==================== */

@media print {
    .sidebar, .mobile-header, .summary-bar { display: none; }
    .main-wrapper { margin-left: 0; }
    body { background: #fff; color: #000; }
    .card { background: #fff; border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
    .dashboard-grid { gap: 8px; }
}

/* Panel info button — small "?" affordance in card headers that
   exposes the panel description on hover/tap. Injected by
   panels.js after htmx swaps. */
.panel-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    margin-right: auto;
    border-radius: 50%;
    background: var(--surface-alt);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: help;
    user-select: none;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}
.panel-info-btn:hover,
.panel-info-btn:focus-visible {
    background: var(--accent);
    color: white;
    outline: none;
}
.panel-info-btn:focus-visible {
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* About page link in sidebar footer */
.sidebar-about-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    margin: 4px 0;
    font-size: 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 6px;
}
.sidebar-about-link:hover { background: var(--sidebar-item-hover); color: var(--text); }

/* Panel info tooltips can be wide — give them more room */
.tooltip-popover {
    max-width: 360px;
    line-height: 1.5;
}

/* ============================================================
   Audit Summary Panel
   ============================================================ */

.audit-signals {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.audit-signal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    background: var(--surface-alt);
    border: 1px solid var(--border-subtle);
}

.audit-signal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    flex-shrink: 0;
}

.audit-signal-good .audit-signal-dot { background: #2ecc71; }
.audit-signal-warn .audit-signal-dot { background: #f39c12; }
.audit-signal-bad .audit-signal-dot { background: var(--raid-risk); }

.audit-signal-label {
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10.5px;
    font-weight: 600;
}

.audit-signal-value {
    color: var(--text-primary);
    font-weight: 600;
}

.audit-verdict {
    margin: 4px 0 18px;
    padding: 12px 16px;
    border-left: 3px solid var(--accent);
    background: var(--surface-alt);
    color: var(--text-primary);
    font-size: 13.5px;
    line-height: 1.55;
    font-style: italic;
    border-radius: 0 6px 6px 0;
}

.audit-rollup {
    margin-bottom: 14px;
}

.audit-rollup-bar {
    display: flex;
    height: 8px;
    background: var(--surface-alt);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 6px;
}

.audit-rollup-seg {
    height: 100%;
}

.audit-rollup-done { background: #2ecc71; }
.audit-rollup-progress { background: var(--accent); }
.audit-rollup-set-aside { background: var(--text-tertiary); }
.audit-rollup-pending { background: var(--border); }

.audit-rollup-counts {
    display: flex;
    gap: 14px;
    font-size: 11.5px;
    color: var(--text-secondary);
}

.audit-recs {
    display: flex;
    flex-direction: column;
}

.audit-rec {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    cursor: default;
}

.audit-rec:last-child {
    border-bottom: none;
}

.audit-rec-id {
    color: var(--text-tertiary);
    font-weight: 700;
    font-size: 11.5px;
    min-width: 22px;
    text-align: right;
}

.audit-rec-title {
    flex: 1;
    color: var(--text-primary);
    line-height: 1.4;
}

.audit-rec-target {
    color: var(--text-tertiary);
    font-size: 11px;
    flex-shrink: 0;
}

.audit-pill-pending { background: var(--surface-alt); color: var(--text-tertiary); }
.audit-pill-not_started { background: var(--surface-alt); color: var(--text-tertiary); }
.audit-pill-in_progress { background: rgba(245, 158, 11, 0.12); color: #b45309; }
.audit-pill-done { background: rgba(46, 204, 113, 0.14); color: #1e8449; }
.audit-pill-set_aside { background: rgba(127, 140, 141, 0.14); color: #5d6d7e; }

@media (prefers-color-scheme: dark) {
    .audit-pill-in_progress { background: rgba(245, 158, 11, 0.2); color: #f5b041; }
    .audit-pill-done { background: rgba(46, 204, 113, 0.18); color: #58d68d; }
    .audit-pill-set_aside { background: rgba(127, 140, 141, 0.22); color: #aab7b8; }
}
