/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { overflow-x: hidden; max-width: 100vw; }
html { scrollbar-gutter: stable; }

:root {
    /* AGP Brand Colors — extracted from brand guide */
    --agp-navy: #1B3668;
    --agp-navy-deep: #152B54;
    --agp-navy-light: #2A4F8F;
    --agp-sky: #7CCFE8;
    --agp-sky-light: #B0E8F8;
    --agp-lime: #CDFF6F;
    --agp-orange: #E08A3C;
    --agp-cream: #FCFCF5;

    /* Neutrals */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    /* Semantic — vivid, unmistakable */
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-600: #16a34a;
    --green-700: #15803d;
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-600: #dc2626;
    --red-700: #b91c1c;
    --amber-50: #fffbeb;
    --amber-100: #fef3c7;
    --amber-600: #d97706;

    /* Typography — AGP brand: clean sans-serif, monospace for data */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

body {
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 14px;
    background: #ffffff;
    color: var(--slate-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* AGP brand accent bar */
body::before {
    content: '';
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--agp-sky);
    z-index: 999;
    pointer-events: none;
}

.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100vh; }

#upload-screen .upload-container { flex: 1; }
#report-screen, #query-screen { display: none; }
#report-screen.active, #query-screen.active { display: block; min-height: auto; }

/* === Upload Screen === */
.upload-container {
    width: 100%;
    max-width: 1520px;
    margin: 0 auto;
    padding: 0 32px 48px;
}

.upload-container.compact { padding-top: 0; padding-bottom: 24px; }

.upload-logo {
    text-align: center;
    margin-bottom: 0;
    background: var(--agp-navy);
    margin: 0 -32px 24px;
    padding: 28px 32px 24px;
}

.compact-logo { margin-bottom: 24px; }

.page-title {
    display: inline-block;
    position: relative;
    padding-bottom: 0;
}

.page-title::after { display: none; }

.compact-logo h1, .compact-logo .page-title { font-size: 32px; text-transform: uppercase; letter-spacing: 3px; }
.compact-logo .subtitle { display: none; }
.compact-logo .brand-marks { margin-bottom: 10px; }
.compact-logo .agp-logo-mark { width: 52px; height: 52px; font-size: 17px; border-radius: 12px; }
.compact-logo .agp-wordmark { font-size: 22px; }

/* AGP Brand Mark */
.brand-marks {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.brand-agp {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agp-logo-mark {
    width: 48px;
    height: 48px;
    background: white;
    color: var(--agp-navy);
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.3px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
}

.agp-wordmark {
    font-family: var(--font-sans);
    font-size: 20px;
    font-weight: 600;
    color: white;
    letter-spacing: -0.3px;
}

.agp-wordmark-plus {
    font-weight: 400;
    color: var(--agp-sky);
}

/* N67 branding hidden — AGP-only header */
.brand-divider { display: none; }
.brand-n67 { display: none; }

.upload-logo h1 {
    font-family: var(--font-sans);
    font-size: 32px;
    font-weight: 700;
    color: var(--agp-sky-light);
    margin-bottom: 0;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.subtitle {
    color: var(--slate-500);
    font-size: 15px;
    max-width: 420px;
    margin: 0 auto;
}

/* === Library Controls Row === */
/* Shared chrome above the tab navigation: badge group on the left, prominent
   Snapshot anchor on the right. Visible on both Business Dashboard and
   My Dashboard tabs (parent sits OUTSIDE the per-tab view wrappers). */
.library-controls {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.library-badge-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-500);
    margin-bottom: 0;
}

.library-badge-inline svg { color: var(--slate-400); opacity: 0.6; }

.library-badge-range {
    font-weight: 400;
    color: var(--slate-400);
    font-size: 11px;
    margin-left: 2px;
}

.library-manage-link {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 11px;
    font-weight: 500;
    color: var(--slate-400);
    cursor: pointer;
    font-family: var(--font-sans);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.library-manage-link:hover { color: var(--agp-navy-light); }

/* Prominent Snapshot anchor — wraps the existing #home-month-select in a
   pill so the focus month is visible on both tabs. The <select> stays
   functional (native dropdown opens on click); appearance:none + a custom
   chevron background-image keeps the visual cohesive inside the pill. */
.snapshot-anchor {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: rgba(27, 54, 104, 0.04);
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.snapshot-anchor:hover {
    background: rgba(27, 54, 104, 0.08);
    border-color: var(--slate-300);
}

.snapshot-anchor-label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-400);
    user-select: none;
}

.home-month-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: transparent url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%231B3668' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><polyline points='3 4.75 6 7.75 9 4.75'/></svg>") no-repeat right center;
    background-size: 10px;
    border: none;
    padding: 0 14px 0 0;
    font-size: 13px;
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--agp-navy);
    cursor: pointer;
    line-height: 1.2;
}

.home-month-select:focus {
    outline: none;
}

/* === KPI Snapshot (larger cards with sparklines) === */
.kpi-snapshot {
    margin-bottom: 14px;
}

.kpi-snap-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.kpi-snap-card {
    padding: 16px 14px 12px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s;
}

.kpi-snap-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.1); }

.kpi-snap-card.snap-green { background: #f0fdf4; border: 1px solid #bbf7d0; }
.kpi-snap-card.snap-yellow { background: #fffbeb; border: 1px solid #fde68a; }
.kpi-snap-card.snap-red { background: #fef2f2; border: 1px solid #fecaca; }
.kpi-snap-card.snap-neutral { background: var(--slate-50); border: 1px solid var(--slate-200); }

.kpi-snap-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-600);
    margin-bottom: 5px;
}

.kpi-snap-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--agp-navy);
    font-family: var(--font-mono);
    line-height: 1.1;
}

.kpi-snap-card.snap-red .kpi-snap-value { color: var(--red-700); }
.kpi-snap-card.snap-green .kpi-snap-value { color: var(--green-700); }
.kpi-snap-card.snap-yellow .kpi-snap-value { color: #92400e; }

.kpi-snap-delta {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-600);
    margin-top: 3px;
}

.kpi-snap-value-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.kpi-snap-arrow {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.kpi-snap-arrow.up { color: var(--green-600); }
.kpi-snap-arrow.down { color: var(--red-600); }
.kpi-snap-arrow.flat { color: var(--slate-400); }

.kpi-sparkline {
    margin-top: 10px;
    height: 36px;
}

.kpi-sparkline svg {
    width: 100%;
    height: 36px;
}

.sparkline-line {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.snap-green .sparkline-line { stroke: var(--green-600); }
.snap-yellow .sparkline-line { stroke: var(--amber-600); }
.snap-red .sparkline-line { stroke: var(--red-600); }
.snap-neutral .sparkline-line { stroke: var(--slate-400); }

.sparkline-area {
    opacity: 0.1;
}

.snap-green .sparkline-area { fill: var(--green-600); }
.snap-yellow .sparkline-area { fill: var(--amber-600); }
.snap-red .sparkline-area { fill: var(--red-600); }
.snap-neutral .sparkline-area { fill: var(--slate-400); }

/* === Executive Dashboard === */
.exec-dashboard {
    margin-bottom: 24px;
}

/* Dashboard sub-header — legend row */
.dash-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 4px;
}

.dash-title {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 700;
    color: var(--agp-navy);
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.dash-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--slate-500);
}

.dash-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dash-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.dash-dot-green { background: #16a34a; }
.dash-dot-red { background: #dc2626; }

.dash-legend-note {
    font-weight: 500;
    color: var(--slate-400);
    margin-left: 4px;
}

/* === KPI Grid — 4x2, with row gap for separation === */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    column-gap: 16px;
    row-gap: 24px;
    margin-bottom: 16px;
}

/* === KPI Widget Card === */
.kpi-widget {
    background: #ffffff;
    border: 1px solid #d5dbe5;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(27,54,104,0.07);
    transition: box-shadow 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
}

.kpi-widget:hover {
    box-shadow: 0 4px 16px rgba(27,54,104,0.12);
    transform: translateY(-1px);
}

/* === Card Header — navy top bar === */
.kpi-widget-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--agp-navy);
}

.kpi-widget-name {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: white;
}

.kpi-widget-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--agp-navy);
    background: var(--agp-sky);
    padding: 2px 7px;
    border-radius: 3px;
}

/* === Hero Number === */
.kpi-hero {
    padding: 14px 16px 14px;
    background: #ffffff;
}

.kpi-hero-value {
    font-family: var(--font-mono);
    font-size: 38px;
    font-weight: 700;
    color: var(--agp-navy);
    line-height: 1.05;
    letter-spacing: -1px;
}

.kpi-hero-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--slate-500);
    margin-top: 4px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* === Comparison Rows === */
.kpi-comps {
    border-top: 1px solid #e2e7ef;
    flex: 1;
    background: #f7f8fa;
}

.kpi-comp-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    padding: 8px 16px;
    gap: 8px;
    border-bottom: 1px solid #ebeef3;
}

.kpi-comp-row:last-child { border-bottom: none; }

.kpi-comp-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--slate-700);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.kpi-comp-vals {
    display: flex;
    align-items: baseline;
    gap: 6px;
    justify-content: flex-end;
}

.kpi-comp-actual {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--agp-navy);
}

.kpi-comp-target {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-500);
}

.kpi-comp-var {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    min-width: 64px;
    text-align: right;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: -0.2px;
}

.kpi-comp-var.favorable {
    color: #166534;
    background: #bbf7d0;
}

.kpi-comp-var.unfavorable {
    color: #991b1b;
    background: #fecaca;
}

.kpi-comp-var.neutral {
    color: var(--slate-500);
    background: #e8ecf1;
}

/* === Agency Sub-Segment Strip === */
.kpi-agency-strip {
    background: var(--agp-navy-deep);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.kpi-agency-tag {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--agp-navy);
    background: var(--agp-sky);
    padding: 2px 7px;
    border-radius: 3px;
}

.kpi-agency-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: white;
}

.kpi-agency-pct {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    margin-left: auto;
}

/* === Responsive === */
@media (max-width: 1200px) {
    .dash-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .dash-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .dash-grid { grid-template-columns: 1fr; }
    .dash-header-row { flex-direction: column; gap: 8px; align-items: flex-start; }
    .kpi-hero-value { font-size: 30px; }
    .upload-logo { margin: 0 -32px 16px; }
}

/* === Section Divider === */
.section-divider {
    border: none;
    border-top: 1px solid var(--slate-200);
    margin: 14px 0;
}

/* === Performance Snapshot Table === */
.perf-snapshot {
    margin-bottom: 10px;
    background: white;
    border: 1px solid var(--slate-200);
    border-left: 3px solid var(--agp-navy);
    border-radius: 0 10px 10px 0;
    padding: 14px 14px 14px 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.perf-snapshot-title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-600);
    margin-bottom: 10px;
}

.perf-snapshot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.perf-snapshot-table th {
    padding: 8px 10px;
    text-align: right;
    font-weight: 800;
    color: var(--agp-navy);
    font-size: 13px;
    border-bottom: 2px solid var(--slate-200);
}

.perf-snapshot-table th:first-child { text-align: left; }

.perf-snapshot-table td {
    padding: 9px 10px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--slate-800);
    border-bottom: 1px solid var(--slate-100);
}

.perf-snapshot-table td:first-child {
    text-align: left;
    font-family: var(--font-sans);
    font-weight: 700;
    color: var(--agp-navy);
}

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

.perf-snapshot-table tbody tr:nth-child(even) td { background: rgba(31,35,87,0.02); }

/* Bold the most recent month column (2nd column = first data col) */
.perf-snapshot-table td:nth-child(2) {
    font-weight: 800;
    color: var(--agp-navy);
}

.perf-snapshot-table th:nth-child(2) {
    color: var(--agp-navy);
    font-weight: 800;
}

.perf-cell-up { color: var(--green-700) !important; }
.perf-cell-down { color: var(--red-700) !important; }

.perf-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--slate-500);
}

.perf-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.perf-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.perf-legend-dot.perf-legend-green { background: var(--green-700); }
.perf-legend-dot.perf-legend-red { background: var(--red-700); }

.perf-legend-note {
    font-style: italic;
    color: var(--slate-400);
}

/* === Data Source Map === */
.source-map-details {
    margin-bottom: 14px;
}

.source-map-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-400);
    cursor: pointer;
    list-style: none;
    transition: all 0.15s;
}

.source-map-summary::-webkit-details-marker { display: none; }
.source-map-summary::before { content: '\25B6'; font-size: 8px; color: var(--slate-300); transition: transform 0.2s; }
.source-map-details[open] .source-map-summary::before { transform: rotate(90deg); }
.source-map-summary:hover { color: var(--slate-600); border-color: var(--slate-300); }

.source-map-content {
    margin-top: 8px;
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.source-map-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.source-map-table th {
    padding: 8px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--slate-50);
    border-bottom: 1px solid var(--slate-200);
}

.source-map-table td {
    padding: 6px 12px;
    color: var(--slate-600);
    font-weight: 500;
    border-bottom: 1px solid var(--slate-50);
    font-size: 12px;
}

.source-map-table td:first-child {
    font-weight: 700;
    color: var(--agp-navy);
}

.source-map-table td:nth-child(2) {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--slate-500);
}

.source-map-table td:nth-child(4) {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--slate-400);
}

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

.source-map-table tr.source-map-divider td {
    padding: 5px 12px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--agp-navy-light);
    background: rgba(31,35,87,0.03);
    border-bottom: 1px solid var(--slate-100);
}

.source-map-grid th:first-child { min-width: 120px; }

.source-map-grid td {
    vertical-align: top;
}

.sm-line {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--slate-600);
    line-height: 1.5;
}

.sm-line b {
    font-weight: 700;
    color: var(--slate-500);
}

.sm-calc {
    color: var(--slate-400);
}


.sm-tab, .sm-row, .sm-col { display: none; /* legacy, replaced by sm-line */ }

.sm-point {
    font-size: 11px;
    font-style: italic;
    color: var(--slate-400);
    font-weight: 500;
    text-align: center;
    vertical-align: middle;
}

.source-map-note {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--slate-400);
    font-style: italic;
    border-top: 1px solid var(--slate-100);
}

/* === Recent Activity (collapsible) === */
.recent-details {
    margin-bottom: 14px;
}

.recent-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--slate-500);
    cursor: pointer;
    list-style: none;
    transition: all 0.15s;
}

.recent-summary::-webkit-details-marker { display: none; }
.recent-summary::before { content: '\25B6'; font-size: 9px; color: var(--slate-400); transition: transform 0.2s; }
.recent-details[open] .recent-summary::before { transform: rotate(90deg); }
.recent-summary:hover { background: var(--slate-50); color: var(--agp-navy); }

.recent-activity {
    padding: 12px 0 0;
}

.recent-activity-title { display: none; }

.recent-activity-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--slate-700);
    line-height: 1.5;
    background: var(--slate-50);
    border: 1px solid var(--slate-100);
    border-radius: 10px;
}

.activity-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.activity-icon.report {
    background: var(--agp-navy);
    color: var(--agp-sky);
}

.activity-icon.query {
    background: var(--agp-sky);
    color: var(--agp-navy);
}

.activity-text-wrap {
    flex: 1;
    min-width: 0;
}

.activity-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    color: var(--slate-700);
}

.activity-time {
    font-size: 12px;
    font-weight: 500;
    color: var(--slate-400);
    margin-top: 3px;
}

.activity-no-data {
    font-size: 12px;
    color: var(--slate-400);
    font-style: italic;
}

/* === Home Footer === */
.home-footer {
    padding: 16px 24px;
    text-align: center;
}

.home-footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 11px;
    color: var(--slate-400);
}

.home-footer-dot {
    width: 3px;
    height: 3px;
    background: var(--slate-300);
    border-radius: 50%;
}

/* === Library Drawer (slide-in panel) === */
.library-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.25s;
}

.library-overlay.visible { opacity: 1; }

.library-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    z-index: 201;
    box-shadow: -8px 0 30px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
}

.library-drawer.visible {
    transform: translateX(0);
    visibility: visible;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.drawer-title {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--agp-navy);
}

.drawer-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--slate-400);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}

.drawer-close:hover { background: var(--slate-100); color: var(--slate-700); }

.drawer-subtitle {
    padding: 8px 24px 16px;
    font-size: 13px;
    color: var(--slate-500);
    line-height: 1.5;
}

/* Add New MPR button in drawer */
.drawer-add-section {
    padding: 0 24px 12px;
}

.drawer-add-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--agp-navy);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s;
    box-shadow: 0 2px 6px rgba(27,54,104,0.15);
    position: relative;
    z-index: 1;
}

.drawer-add-btn:hover {
    background: var(--agp-navy-light);
    box-shadow: 0 4px 12px rgba(27,54,104,0.25);
}

.drawer-add-btn svg { stroke: var(--agp-sky); }

.drawer-upload-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 24px 16px;
    padding: 14px;
    border: 2px dashed var(--slate-300);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--agp-navy-light);
    transition: all 0.15s;
}

.drawer-upload-zone:hover {
    border-color: var(--agp-navy-light);
    background: #f0f3ff;
}

.drawer-upload-zone svg { opacity: 0.5; }

.drawer-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-500);
}

.drawer-count {
    font-weight: 600;
    color: var(--slate-400);
    text-transform: none;
    letter-spacing: 0;
}

.drawer-list {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 0 24px 24px;
}

.drawer-month-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.drawer-month-item:hover {
    border-color: var(--agp-navy-light);
    background: #f8f9ff;
}

.drawer-month-item.selected {
    border-color: var(--agp-navy);
    background: #eef0ff;
}

.drawer-month-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer-month-dot {
    width: 8px;
    height: 8px;
    background: var(--green-600);
    border-radius: 50%;
}

.drawer-month-dot.focus {
    width: 10px;
    height: 10px;
    background: var(--agp-navy);
    box-shadow: 0 0 0 3px rgba(31, 35, 87, 0.15);
}

.drawer-month-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--agp-navy);
}

.drawer-month-meta {
    font-size: 11px;
    color: var(--slate-400);
    margin-top: 1px;
}

.drawer-month-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.drawer-focus-tag {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--agp-navy);
    padding: 2px 6px;
    background: rgba(31, 35, 87, 0.08);
    border-radius: 3px;
}

.drawer-delete-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--slate-300);
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.15s;
}

.drawer-month-item:hover .drawer-delete-btn { opacity: 1; }
.drawer-delete-btn:hover { color: var(--red-600); background: var(--red-50); }

/* Parse Progress */
.parse-progress {
    margin: 12px 0;
}

.parse-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--slate-200);
    border-radius: 2px;
    overflow: hidden;
}

.parse-progress-fill {
    width: 0%;
    height: 100%;
    background: var(--agp-navy);
    border-radius: 2px;
    transition: width 0.3s;
}

.parse-status {
    font-size: 12px;
    color: var(--slate-500);
    margin-top: 6px;
    text-align: center;
}

/* Toolbar Select */
.toolbar-select {
    padding: 6px 10px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: white;
    font-size: 13px;
    font-family: var(--font-sans);
    cursor: pointer;
}

.toolbar-select option {
    background: var(--agp-navy);
    color: white;
}

/* === Admin Login Button === */
.admin-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    background: white;
    border: 1px dashed var(--slate-300);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-500);
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s;
}

.admin-login-btn:hover {
    border-color: var(--agp-navy-light);
    color: var(--agp-navy);
    background: #f8f9ff;
}

.admin-login-btn svg { opacity: 0.5; }
.admin-login-btn:hover svg { opacity: 1; }

/* === Admin Modal === */
.admin-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 380px;
    max-width: 90vw;
    background: white;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
    z-index: 202;
    padding: 28px;
}

.admin-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--agp-navy);
    margin-bottom: 8px;
}

.admin-modal-header svg { color: var(--agp-navy-light); }

.admin-modal-text {
    font-size: 13px;
    color: var(--slate-500);
    margin-bottom: 16px;
    line-height: 1.5;
}

.admin-password-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.15s;
}

.admin-password-input:focus {
    border-color: var(--agp-navy);
    box-shadow: 0 0 0 3px rgba(31, 35, 87, 0.08);
}

.admin-error {
    font-size: 12px;
    color: var(--red-600);
    margin-top: 6px;
}

.admin-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: flex-end;
}

.admin-modal-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s;
}

.admin-modal-btn.secondary {
    background: white;
    border: 1px solid var(--slate-200);
    color: var(--slate-600);
}

.admin-modal-btn.secondary:hover {
    background: var(--slate-50);
}

.admin-modal-btn.primary {
    background: var(--agp-navy);
    border: none;
    color: white;
}

.admin-modal-btn.primary:hover {
    background: var(--agp-navy-light);
}

/* === Admin Indicator === */
.admin-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(205, 255, 111, 0.15);
    border: 1px solid rgba(205, 255, 111, 0.3);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Train Intelligence === */
.admin-actions-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.admin-train-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--agp-navy);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s;
}

.admin-train-btn:hover { background: var(--agp-navy-light); }
.admin-train-btn svg { stroke: var(--agp-sky); }

.train-drawer { width: 480px; }

.train-form {
    padding: 0 24px 16px;
}

.train-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--slate-800);
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
    margin-bottom: 10px;
}

.train-textarea:focus {
    border-color: var(--agp-navy);
    box-shadow: 0 0 0 3px rgba(31,35,87,0.08);
}

.train-textarea::placeholder { color: var(--slate-400); }

.train-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.train-field { display: flex; flex-direction: column; gap: 4px; }

.train-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--slate-500);
}

.train-select, .train-input {
    padding: 8px 10px;
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--slate-700);
    outline: none;
}

.train-select:focus, .train-input:focus { border-color: var(--agp-navy); }

.train-save-btn {
    width: 100%;
    padding: 10px;
    background: var(--agp-navy);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s;
}

.train-save-btn:hover { background: var(--agp-navy-light); }
.train-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.train-status {
    text-align: center;
    font-size: 13px;
    margin-top: 8px;
    font-weight: 500;
}

.train-status.success { color: var(--green-600); }
.train-status.error { color: var(--red-600); }

.train-divider {
    border-top: 1px solid var(--slate-200);
    margin: 8px 24px 12px;
}

.train-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px 8px;
}

.train-toggle-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    color: var(--slate-500);
    cursor: pointer;
}

.train-toggle-label input { cursor: pointer; }

.train-memory-card {
    padding: 12px 14px;
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    margin-bottom: 8px;
}

.train-memory-card.inactive {
    opacity: 0.5;
    background: var(--slate-50);
}

.train-memory-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--slate-700);
    line-height: 1.5;
    margin-bottom: 8px;
}

.train-memory-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--slate-400);
}

.train-memory-tags {
    display: flex;
    gap: 6px;
}

.train-memory-tag {
    padding: 1px 6px;
    background: var(--agp-cream);
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    color: var(--agp-navy);
}

.train-memory-tag.report { background: #dbeafe; color: #1e40af; }
.train-memory-tag.query { background: #fef3c7; color: #92400e; }
.train-memory-tag.both { background: #dcfce7; color: #15803d; }

.train-deactivate-btn {
    padding: 3px 8px;
    background: none;
    border: 1px solid var(--red-100);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--red-600);
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s;
}

.train-deactivate-btn:hover { background: var(--red-50); }

.drop-zone {
    border: 2px dashed var(--slate-300);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--agp-navy-light);
    background: #f0f3ff;
}

.upload-icon {
    width: 40px;
    height: 40px;
    color: var(--agp-navy-light);
    margin-bottom: 12px;
    opacity: 0.5;
}

.drop-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--agp-navy);
    margin-bottom: 4px;
}

.drop-subtext {
    font-size: 14px;
    color: var(--slate-400);
}

.file-list {
    margin-top: 16px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
}

.file-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-icon {
    width: 32px;
    height: 32px;
    background: #eef4e8;
    border: 1px solid #d5e4c8;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #4a7c2e;
}

.file-name {
    font-weight: 500;
    color: var(--slate-700);
}

.file-period {
    font-size: 13px;
    color: var(--slate-400);
}

.file-remove {
    background: none;
    border: none;
    color: var(--slate-400);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
}

.file-remove:hover { color: var(--red-600); }

.generate-btn {
    width: 100%;
    margin-top: 24px;
    padding: 14px 24px;
    background: var(--agp-navy);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.generate-btn:hover:not(:disabled) {
    background: var(--agp-navy-light);
}

.generate-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.upload-footer-note {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--slate-400);
    letter-spacing: 0.3px;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(124,207,232,0.3);
    border-top-color: var(--agp-sky);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === Report Toolbar === */
.report-toolbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px;
    background: var(--agp-navy);
    border-bottom: 2px solid var(--agp-sky);
    box-shadow: 0 2px 8px rgba(31,35,87,0.2);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sans);
}

.toolbar-btn svg { stroke: rgba(255,255,255,0.7); }

.toolbar-btn:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.25);
    color: white;
}

.toolbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-agp-mark {
    width: 34px;
    height: 28px;
    background: var(--agp-navy);
    color: white;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: -0.3px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-brand-text {
    font-family: var(--font-display);
    font-size: 16px;
    color: white;
    letter-spacing: -0.2px;
}

.toolbar-right {
    display: flex;
    gap: 8px;
}

/* === Report Content === */
.report-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 48px 48px 80px;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(31,35,87,0.06);
}

/* Report Header */
.report-header {
    border-bottom: 3px solid var(--agp-navy);
    padding-bottom: 24px;
    margin-bottom: 32px;
}

.report-header-brands {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.header-agp-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-agp-mark {
    width: 40px;
    height: 36px;
    background: var(--agp-navy);
    color: white;
    font-family: var(--font-sans);
    letter-spacing: -0.3px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-agp-name {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--agp-navy);
}

.header-n67-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--slate-400);
}

.header-n67-mark {
    width: 24px;
    height: 24px;
    background: var(--slate-800);
    color: white;
    font-size: 9px;
    font-weight: 700;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.3px;
}

.header-n67-text {
    font-weight: 500;
    color: var(--slate-500);
}

.report-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 400;
    color: var(--agp-navy);
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}

.report-period {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--agp-navy-light);
    margin-bottom: 16px;
    opacity: 0.7;
}

.report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    font-size: 13px;
    color: var(--slate-500);
}

.report-meta span { display: flex; align-items: center; gap: 6px; }

.report-meta strong {
    color: var(--agp-navy);
    font-weight: 600;
}

.classification-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--agp-navy);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

/* Sections */
.report-section {
    margin-bottom: 36px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 400;
    color: var(--agp-navy);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--agp-navy);
    margin-bottom: 16px;
}

.section-subtitle {
    font-size: 18px;
    font-weight: 600;
    color: var(--agp-navy);
    margin: 20px 0 10px;
}

.report-text {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.75;
    color: var(--slate-700);
    margin-bottom: 14px;
}

.report-text strong {
    color: var(--agp-navy);
    font-weight: 700;
}

/* KPI Cards Row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.kpi-card {
    background: var(--agp-cream);
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    padding: 16px;
    border-top: 3px solid var(--agp-navy);
}

.kpi-card.status-red {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-top: 3px solid var(--red-600);
}
.kpi-card.status-red .kpi-label { color: var(--red-700); }
.kpi-card.status-red .kpi-value { color: var(--red-700); }

.kpi-card.status-yellow {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-top: 3px solid var(--amber-600);
}
.kpi-card.status-yellow .kpi-label { color: #92400e; }
.kpi-card.status-yellow .kpi-value { color: #92400e; }

.kpi-card.status-green {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-top: 3px solid var(--green-600);
}
.kpi-card.status-green .kpi-label { color: var(--green-700); }
.kpi-card.status-green .kpi-value { color: var(--green-700); }

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--agp-navy-light);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--agp-navy);
    margin-bottom: 4px;
    font-family: var(--font-mono);
}

.kpi-delta {
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-delta.positive { color: var(--green-600); }
.kpi-delta.negative { color: var(--red-600); }
.kpi-delta.neutral { color: var(--slate-500); }

.kpi-sub {
    font-size: 11px;
    color: var(--slate-400);
    margin-top: 2px;
}

/* Metric Tables */
.metric-table-wrapper {
    overflow-x: auto;
    margin: 16px 0 20px;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
}

.metric-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.metric-table thead {
    background: var(--agp-navy);
}

.metric-table th {
    padding: 10px 14px;
    text-align: right;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    border-bottom: none;
    white-space: nowrap;
    font-size: 13px;
}

.metric-table th:first-child {
    text-align: left;
    min-width: 160px;
}

.metric-table td {
    padding: 9px 14px;
    text-align: right;
    color: var(--slate-700);
    border-bottom: 1px solid var(--slate-100);
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
}

.metric-table td:first-child {
    text-align: left;
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--agp-navy);
}

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

.metric-table tr.total-row td {
    font-weight: 700;
    border-top: 2px solid var(--slate-200);
    background: var(--agp-cream);
}

.metric-table tr:hover td {
    background: #f0f3ff;
}

.cell-positive { color: var(--green-700) !important; }
.cell-negative { color: var(--red-700) !important; }
.cell-highlight { background: var(--amber-50) !important; }

/* Focus Areas & Actions */
.focus-list {
    list-style: none;
    counter-reset: focus;
}

.focus-item {
    counter-increment: focus;
    margin-bottom: 16px;
    padding: 16px 16px 16px 48px;
    background: var(--agp-cream);
    border: 1px solid var(--slate-200);
    border-left: 3px solid var(--agp-orange);
    border-radius: 0 8px 8px 0;
    position: relative;
}

.focus-item::before {
    content: counter(focus);
    position: absolute;
    left: 14px;
    top: 16px;
    width: 22px;
    height: 22px;
    background: var(--agp-orange);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.focus-title {
    font-weight: 700;
    color: var(--agp-navy);
    font-size: 14px;
    margin-bottom: 6px;
}

.focus-detail {
    font-size: 13.5px;
    color: var(--slate-600);
    line-height: 1.65;
}

.action-group {
    margin-bottom: 24px;
}

.action-group-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--agp-navy);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-group-title .badge {
    display: inline-flex;
    padding: 2px 8px;
    background: var(--agp-navy);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.action-list {
    list-style: none;
    padding-left: 0;
}

.action-item {
    position: relative;
    padding: 10px 12px 10px 28px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--slate-700);
    line-height: 1.6;
}

.action-item::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 16px;
    width: 6px;
    height: 6px;
    background: var(--agp-navy);
    border-radius: 50%;
}

/* Momentum Items */
.momentum-list {
    list-style: none;
}

.momentum-item {
    padding: 10px 12px 10px 28px;
    margin-bottom: 6px;
    background: var(--green-50);
    border: 1px solid var(--green-100);
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--slate-700);
    line-height: 1.6;
    position: relative;
}

.momentum-item::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 16px;
    width: 6px;
    height: 6px;
    background: var(--green-600);
    border-radius: 50%;
}

/* === DECISIONS REQUIRED Section === */
.decisions-required {
    margin-bottom: 36px;
    border: 2px solid var(--agp-orange);
    border-radius: 10px;
    overflow: hidden;
}

.decisions-required-header {
    background: var(--agp-orange);
    color: white;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-display);
    display: flex;
    align-items: center;
    gap: 10px;
}

.decisions-required-header .icon {
    font-size: 20px;
}

.decision-card {
    padding: 20px;
    border-bottom: 1px solid var(--slate-200);
}

.decision-card:last-child { border-bottom: none; }

.decision-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.decision-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--agp-navy);
    line-height: 1.4;
}

.decision-context {
    font-size: 15px;
    font-weight: 500;
    color: var(--slate-600);
    line-height: 1.65;
    margin-bottom: 12px;
}

.decision-options {
    margin-bottom: 10px;
    background: #f0f4fa;
    border-radius: 8px;
    padding: 14px 18px;
}

.decision-options-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-500);
    margin-bottom: 6px;
}

.decision-option {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    color: var(--slate-600);
}

.decision-option-bullet {
    width: 5px;
    height: 5px;
    min-width: 5px;
    background: var(--slate-400);
    border-radius: 50%;
    margin-top: 6px;
}

.decision-recommended {
    padding: 10px 14px;
    background: #fef5e7;
    border: 1px solid #f5deb3;
    border-left: 3px solid var(--agp-orange);
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: var(--slate-700);
    line-height: 1.6;
}

.decision-recommended strong {
    color: var(--agp-orange);
    font-weight: 700;
}

/* === Signal Badges === */
.signal-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.signal-badge.high-dollar {
    background: var(--red-50);
    color: var(--red-700);
    border: 1px solid var(--red-100);
}

.signal-badge.small-dollar {
    background: var(--blue-50);
    color: var(--agp-navy-light);
    border: 1px solid var(--blue-100);
}

/* === So What / Now What / If We Do Nothing === */
.bu-section {
    margin-bottom: 32px;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    overflow: hidden;
}

.bu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--agp-navy);
    color: white;
}

.bu-name {
    font-family: var(--font-display);
    font-size: 18px;
}

.insight-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.so-what-box {
    padding: 16px 20px;
    border-right: 1px solid var(--slate-200);
    border-bottom: 1px solid var(--slate-200);
}

.now-what-box {
    padding: 16px 20px;
    border-bottom: 1px solid var(--slate-200);
}

.insight-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.insight-label.so-what { color: var(--agp-navy-light); }
.insight-label.now-what { color: var(--agp-orange); }
.insight-label.consequence { color: var(--red-600); }

.insight-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--slate-700);
    line-height: 1.65;
}

.now-what-meta {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--slate-100);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--slate-600);
}

.meta-tag.owner { background: #fef5e7; color: var(--agp-orange); }
.meta-tag.horizon { background: var(--agp-cream); color: var(--agp-navy); }

.consequence-box {
    padding: 14px 20px;
    background: var(--red-50);
    border-top: 1px solid var(--red-100);
}

.consequence-text {
    font-size: 14px;
    color: var(--red-700);
    line-height: 1.6;
    font-weight: 600;
}

.bu-metrics-wrapper {
    padding: 0 20px 16px;
}

/* === Owned Actions Table === */
.owned-actions-section {
    margin-bottom: 36px;
}

.owned-action-card {
    margin-bottom: 10px;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    overflow: hidden;
}

.owned-action-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 14px 16px;
    background: white;
    gap: 12px;
}

.owned-action-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--agp-navy);
    line-height: 1.5;
    flex: 1;
}

.owned-action-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 10px;
}

.owned-action-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-top: 1px solid var(--slate-100);
}

.action-detail-cell {
    padding: 10px 16px;
    border-right: 1px solid var(--slate-100);
    font-size: 12.5px;
}

.action-detail-cell:last-child { border-right: none; }

.action-detail-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-500);
    margin-bottom: 4px;
}

.action-detail-value {
    color: var(--slate-700);
    line-height: 1.5;
}

.action-detail-value.consequence-text {
    color: var(--red-600);
    font-weight: 500;
}

/* === Simplified Action Checklist === */
.action-checklist-group {
    margin-bottom: 16px;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    overflow: hidden;
}

.action-checklist-owner {
    padding: 10px 16px;
    background: var(--agp-navy);
    color: white;
    font-size: 13px;
    font-weight: 700;
}

.action-checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--slate-100);
    font-size: 15px;
    font-weight: 500;
    color: var(--slate-700);
    line-height: 1.5;
}

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

.action-checkbox {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 2px solid var(--slate-300);
    border-radius: 3px;
    margin-top: 2px;
}

.action-horizon-tag {
    display: inline-flex;
    padding: 1px 6px;
    background: var(--agp-cream);
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    color: var(--agp-navy);
    margin-left: 6px;
    white-space: nowrap;
}

/* === Balance Sheet Status Legend === */
.bs-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--slate-50);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--slate-600);
}

.bs-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.bs-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.bs-dot.bs-positive { background: var(--green-600); }
.bs-dot.bs-monitor { background: var(--amber-600); }
.bs-dot.bs-neutral { background: var(--agp-sky); }
.bs-dot.bs-watch { background: var(--red-600); }

/* === Forward Projections === */
.projection-status-red { color: var(--red-700) !important; font-weight: 600; }
.projection-status-yellow { color: #92400e !important; font-weight: 600; }
.projection-status-green { color: var(--green-700) !important; font-weight: 600; }

.projections-assumptions {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--slate-50);
    border-radius: 6px;
    font-size: 11px;
    color: var(--slate-500);
    font-style: italic;
    line-height: 1.5;
}

/* === Client Metrics === */
.client-metrics-section {
    margin-bottom: 20px;
}

/* === Action Buttons === */
.main-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.main-actions.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sans);
    border: 2px solid var(--agp-navy);
    background: var(--agp-navy);
    color: white;
    box-shadow: 0 1px 4px rgba(27,54,104,0.1);
}

.action-btn svg { stroke: var(--agp-sky); }

.action-btn:hover:not(:disabled) {
    background: var(--agp-navy-light);
    border-color: var(--agp-navy-light);
    box-shadow: 0 4px 14px rgba(27,54,104,0.2);
}

.action-btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }

/* Primary gets the accent treatment */
.primary-action {
    background: var(--agp-navy);
    color: white;
    border-color: var(--agp-navy);
}
.primary-action svg { stroke: var(--agp-sky); }

.secondary-action {
    background: var(--agp-navy);
    color: white;
    border-color: var(--agp-navy);
}
.secondary-action svg { stroke: var(--agp-sky); }

.train-action {
    background: var(--agp-navy);
    color: white;
    border-color: var(--agp-navy);
}
.train-action svg { stroke: var(--agp-sky); }

/* Report toolbar query button */
.toolbar-query-btn {
    background: var(--agp-navy) !important;
    border: none !important;
    color: white !important;
    font-weight: 700 !important;
    padding: 7px 16px !important;
}

.toolbar-query-btn:hover {
    background: var(--agp-navy-light) !important;
}

.toolbar-query-btn svg { stroke: var(--agp-sky) !important; }

.toolbar-train-btn {
    background: var(--agp-navy) !important;
    border: none !important;
    color: white !important;
    font-weight: 700 !important;
    padding: 7px 16px !important;
}

.toolbar-train-btn:hover { background: var(--agp-navy-light) !important; }
.toolbar-train-btn svg { stroke: var(--agp-sky) !important; }

.compact-drop { padding: 28px 24px; }
.compact-drop .upload-icon { width: 28px; height: 28px; margin-bottom: 6px; }
.compact-drop .drop-text { font-size: 14px; }
.compact-drop .drop-subtext { font-size: 12px; }

/* === Query Screen === */
.query-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

.query-header {
    text-align: center;
    margin-bottom: 24px;
}

.query-title {
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--agp-navy);
    margin-bottom: 6px;
}

.query-subtitle {
    font-size: 14px;
    color: var(--slate-500);
}

.query-input-row {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
}

.query-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--slate-200);
    border-right: none;
    border-radius: 10px 0 0 10px;
    font-size: 15px;
    font-family: var(--font-sans);
    color: var(--slate-800);
    outline: none;
    transition: border-color 0.15s;
}

.query-input:focus {
    border-color: var(--agp-navy);
}

.query-input::placeholder { color: var(--slate-400); }

.query-submit-btn {
    padding: 14px 20px;
    background: var(--agp-navy);
    border: 2px solid var(--agp-navy);
    border-radius: 0 10px 10px 0;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
}

.query-submit-btn:hover { background: var(--agp-navy-light); }
.query-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.query-submit-btn svg { stroke: var(--agp-sky); }

.query-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 24px;
}

.query-suggestion {
    padding: 7px 14px;
    background: white;
    border: 1px solid var(--agp-navy);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--agp-navy);
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s;
}

.query-suggestion:hover {
    background: var(--agp-navy);
    color: white;
    border-color: var(--agp-navy-light);
    color: var(--agp-navy);
}

.query-results {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Query Answer Card */
.query-answer-card {
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    overflow: hidden;
}

.query-answer-question {
    padding: 14px 18px;
    background: var(--agp-cream);
    border-bottom: 1px solid var(--slate-200);
    font-size: 18px;
    font-weight: 700;
    color: var(--agp-navy);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.query-answer-question svg { min-width: 16px; margin-top: 2px; opacity: 0.5; }

.query-answer-divider {
    height: 1px;
    background: var(--slate-200);
    margin: 0 18px;
}

.query-answer-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--slate-400);
    margin-bottom: 12px;
}

.query-answer-body {
    padding: 20px 18px 18px;
}

.query-answer-text {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.7;
    color: var(--slate-700);
    margin-bottom: 14px;
}

/* Formatted query answer sections */
.qa-section-header {
    font-size: 14px;
    font-weight: 800;
    color: var(--agp-navy);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 10px 0 6px;
    margin-top: 12px;
    border-bottom: 2px solid var(--agp-navy);
    margin-bottom: 8px;
}

.qa-section-header:first-child { margin-top: 0; }

/* Executive insight/action card */
.qa-executive-card {
    background: #f0f4fa;
    border-radius: 8px;
    padding: 16px 20px;
    margin-top: 16px;
}

.qa-executive-card .qa-section-header {
    margin-top: 12px;
}

.qa-executive-card .qa-section-header:first-child {
    margin-top: 0;
}

.qa-insight-body,
.qa-insight-body .qa-text {
    color: var(--agp-navy);
}

.qa-insight-sublabel {
    font-size: 14px;
    font-weight: 800;
    color: var(--agp-navy);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 10px 0 2px;
    margin-top: 12px;
    margin-bottom: 4px;
}

.qa-insight-sublabel:first-child {
    margin-top: 0;
}

.qa-insight-text {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.6;
    color: var(--agp-navy);
    margin-bottom: 2px;
}

.qa-text {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.7;
    color: var(--slate-700);
    margin-bottom: 8px;
}

.qa-text strong, .query-answer-text strong {
    font-weight: 700;
    color: var(--agp-navy);
}

.qa-list {
    list-style: none;
    padding: 0;
    margin: 6px 0 12px;
}

.qa-list li {
    position: relative;
    padding: 5px 0 5px 18px;
    font-size: 15px;
    font-weight: 500;
    color: var(--slate-700);
    line-height: 1.6;
}

.qa-list li::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 13px;
    width: 5px;
    height: 5px;
    background: var(--agp-navy);
    border-radius: 50%;
}

.qa-list li strong {
    font-weight: 700;
    color: var(--agp-navy);
}

.qa-dollar {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--agp-navy);
}

.qa-summary {
    font-size: 14px;
    font-weight: 500;
    font-style: italic;
    color: var(--slate-500);
    line-height: 1.65;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--slate-200);
}

.query-metrics-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.query-metric-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    font-size: 13px;
}

.query-metric-chip .metric-label {
    color: var(--slate-500);
    font-weight: 500;
}

.query-metric-chip .metric-value {
    color: var(--agp-navy);
    font-weight: 700;
    font-family: var(--font-mono);
}

.query-metric-chip .metric-context {
    color: var(--slate-400);
    font-size: 11px;
}

.query-sources {
    border-top: 1px solid var(--slate-100);
    padding-top: 12px;
}

.query-sources-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-600);
    margin-bottom: 8px;
}

.query-source-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--slate-600);
}

.query-source-tag {
    display: inline-flex;
    padding: 2px 8px;
    background: var(--agp-cream);
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
    color: var(--agp-navy);
}

.query-followup {
    margin-top: 12px;
    padding: 8px 12px;
    background: #f8f9ff;
    border-radius: 6px;
    font-size: 12px;
    color: var(--slate-500);
    cursor: pointer;
    transition: all 0.15s;
}

.query-followup:hover {
    background: #eef0ff;
    color: var(--agp-navy);
}

.query-followup strong { color: var(--agp-navy-light); }

/* Query Data Verification Table */
.query-data-verification {
    border-top: 1px solid var(--slate-100);
    padding-top: 12px;
    margin-bottom: 8px;
}

.query-verify-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 6px;
}

.query-verify-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 700;
    color: var(--slate-700);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--slate-200);
}

.query-verify-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--slate-100);
    vertical-align: top;
    font-weight: 500;
    font-size: 14px;
}

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

.verify-desc {
    font-weight: 700;
    font-size: 14px;
    color: var(--agp-navy);
    max-width: 180px;
}

.verify-val {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 14px;
    color: var(--agp-navy);
}

.verify-raw {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 14px;
    color: var(--slate-700);
    background: var(--slate-50);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--slate-200);
}

.verify-source {
    font-size: 13px;
    font-weight: 500;
    color: var(--slate-600);
}

.verify-field {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--slate-600);
    margin-top: 2px;
}

.verify-meaning {
    display: block;
    font-size: 13px;
    color: var(--agp-navy-light);
    font-style: italic;
    font-weight: 500;
    margin-top: 1px;
}

.verify-pass {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #dcfce7;
    color: var(--green-700);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
}

.verify-fail {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #fee2e2;
    color: var(--red-700);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
}

.verify-unknown {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--amber-100);
    color: var(--amber-600);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
}

/* Query Rate Limit */
.query-rate-limit {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    gap: 8px;
}

.rate-limit-icon {
    font-size: 28px;
    opacity: 0.6;
}

.rate-limit-msg {
    font-size: 15px;
    font-weight: 700;
    color: var(--amber-600);
}

.rate-limit-countdown {
    font-size: 14px;
    font-weight: 500;
    color: var(--slate-500);
}

.countdown-num {
    font-family: var(--font-mono);
    font-weight: 800;
    color: var(--agp-navy);
    font-size: 16px;
}

.rate-limit-retry {
    margin-top: 8px;
    padding: 8px 20px;
    background: var(--agp-navy);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s;
}

.rate-limit-retry:hover:not(:disabled) { background: var(--agp-navy-light); }
.rate-limit-retry:disabled { opacity: 0.4; cursor: not-allowed; }

/* Query Loading */
.query-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: var(--slate-500);
    font-size: 14px;
}

.query-loading .spinner {
    border-color: rgba(31, 35, 87, 0.15);
    border-top-color: var(--agp-navy);
}

.toolbar-label {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
}

@media print { .query-container { display: none; } }

/* === Comparison Note === */
.comparison-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--agp-cream);
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    font-size: 11px;
    color: var(--slate-500);
    margin-bottom: 20px;
}

.comparison-note strong { color: var(--agp-navy); }

/* Footer */
.report-footer {
    margin-top: 48px;
    padding-top: 16px;
    border-top: 2px solid var(--agp-navy);
    font-size: 12px;
    color: var(--slate-400);
    line-height: 1.7;
}

.report-footer-brands {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
}

.footer-prepared-by {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--slate-400);
    font-style: normal;
}

.footer-n67-mark {
    width: 20px;
    height: 20px;
    background: var(--slate-700);
    color: white;
    font-size: 8px;
    font-weight: 700;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.3px;
}

.footer-agp {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--slate-400);
}

.footer-agp-mark {
    width: 26px;
    height: 20px;
    background: var(--agp-navy);
    color: white;
    font-family: var(--font-sans);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: -0.3px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Markdown Report === */
.markdown-report {
    font-size: 16px;
    font-weight: 500;
    color: var(--slate-700);
    line-height: 1.75;
}

.markdown-report .section-title {
    margin-top: 32px;
}

.markdown-report .section-title:first-child {
    margin-top: 0;
}

.markdown-report ul.md-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 16px;
}

.markdown-report ul.md-list li {
    position: relative;
    padding: 6px 0 6px 20px;
    font-size: 15px;
    color: var(--slate-700);
}

.markdown-report ul.md-list li::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 14px;
    width: 5px;
    height: 5px;
    background: var(--agp-navy);
    border-radius: 50%;
}

.markdown-report strong {
    color: var(--agp-navy);
    font-weight: 700;
}

.markdown-report .metric-table-wrapper {
    margin: 12px 0 20px;
}

.markdown-report .invest-pivot-card {
    background: #f0f4fa;
    border-radius: 8px;
    padding: 14px 18px;
    margin: 12px 0 20px;
}

.markdown-report .invest-pivot-card ul.md-list {
    margin-bottom: 0;
}

.markdown-report .invest-pivot-label {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--agp-navy);
    padding-bottom: 6px;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--agp-navy);
}

/* Print Styles */
@media print {
    body { background: white; }
    .report-toolbar { display: none; }
    .report-content {
        max-width: none;
        padding: 24px;
        box-shadow: none;
        margin: 0;
    }
    .report-header { page-break-after: avoid; }
    .report-section { page-break-inside: avoid; }
    .metric-table-wrapper { border: 1px solid #999; }
    .metric-table thead { background: #1F2357 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .metric-table th { color: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .kpi-card { border: 1px solid #ccc; border-top: 3px solid #1F2357; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .focus-item { border: 1px solid #ccc; border-left: 3px solid #E08A3C; }
    .focus-item::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .momentum-item { border: 1px solid #ccc; background: #f5f9f0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .action-item { border: 1px solid #ccc; }
    .classification-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .action-group-title .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Responsive */
@media (max-width: 768px) {
    .report-content { padding: 24px 20px 48px; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .report-title { font-size: 22px; }
    .report-meta { flex-direction: column; gap: 8px; }
    .brand-marks { flex-direction: column; gap: 12px; }
    .brand-divider { width: 40px; height: 1px; }
    .report-header-brands { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* === My Dashboard — Tab Navigation & Empty State (Phase 1: UI shell) === */
.dashboard-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--slate-200);
    margin-bottom: 20px;
}

.dash-tab {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--slate-400);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.dash-tab:hover {
    color: var(--agp-navy);
    background: var(--slate-50);
}

.dash-tab.active {
    color: var(--agp-navy);
    border-bottom-color: var(--agp-sky);
}

/* === My Dashboard — two-column layout (Phase 4) === */
/* The library is absolutely positioned so its (tall) content never grows the
   layout — the layout height is driven entirely by the grid column, and the
   library fills that height (top:0/bottom:0) and scrolls internally. */
.my-dash-layout {
    display: block;
    position: relative;
}

.my-dash-library {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 240px;
    min-height: 0;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    padding: 12px 8px;                              /* 12px bottom = panel closure */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;                          /* Firefox: hidden until hover */
    scrollbar-color: var(--slate-300) transparent;
}

.my-dash-library:hover { scrollbar-width: thin; }

.my-dash-library::-webkit-scrollbar { width: 0; }
.my-dash-library:hover::-webkit-scrollbar { width: 6px; }
.my-dash-library::-webkit-scrollbar-track { background: var(--slate-100); border-radius: 3px; }
.my-dash-library::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 3px; }

/* Panel header — "METRICS" anchor + live count badge, hairline below */
.my-dash-lib-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(27, 54, 104, 0.10);
}

.my-dash-lib-title {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--agp-navy);
}

.my-dash-lib-count {
    font-size: 10px;
    font-weight: 600;
    color: var(--slate-400);
    background: rgba(27, 54, 104, 0.06);
    padding: 2px 6px;
    border-radius: 10px;
}

/* Group labels — sentence-case strings in HTML, uppercased here */
.my-dash-lib-section { margin-bottom: 0; }
.my-dash-lib-section + .my-dash-lib-section { margin-top: 14px; }

.my-dash-lib-group-label {
    padding-left: 10px;
    margin-bottom: 6px;
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--slate-400);
}

/* Rows — tight list rows; no border, no default background */
.my-dash-lib-tile {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 8px;
    margin-bottom: 2px;
    border-radius: 6px;
    border-left: 2px solid transparent;             /* reserves the Added accent's space */
    cursor: grab;
    transition: background 0.12s, opacity 0.12s, box-shadow 0.12s, transform 0.12s;
}

.my-dash-lib-tile:last-child { margin-bottom: 0; }

.my-dash-lib-tile:hover {
    background: rgba(100, 116, 139, 0.06);          /* ~6% slate tint */
}

.my-dash-lib-tile.dragging {
    opacity: 0.7;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
}

/* Added — teal-tinted, left accent, muted text, not draggable, no grip-dots */
.my-dash-lib-tile.added {
    background: rgba(124, 207, 232, 0.16);          /* ~teal tint (--agp-sky) */
    border-left-color: var(--agp-sky);
    cursor: default;
}

.my-dash-lib-tile.added:hover {
    background: rgba(124, 207, 232, 0.16);          /* no extra hover state */
}

.my-dash-lib-tile.added .my-dash-lib-tile-name {
    color: var(--slate-500);                        /* muted slate text */
}

/* Grip-dots — Available rows only (Added rows render an empty 12px spacer) */
.my-dash-lib-grip {
    flex: 0 0 12px;
    font-size: 10px;
    line-height: 1;
    letter-spacing: -1px;
    text-align: center;
    color: var(--slate-400);
    opacity: 0.5;
    user-select: none;
}

.my-dash-lib-tile-name {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--agp-navy);
    overflow-wrap: anywhere;
}

/* === My Dashboard — grid column === */
.my-dash-grid-col {
    margin-left: 252px;                             /* 240px library + 12px gap */
    min-width: 0;
}

.my-dash-grid-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 22px;
    margin-bottom: 10px;
}

.my-dash-clear-link {
    appearance: none;
    background: none;
    border: none;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-400);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s;
}

.my-dash-clear-link:hover { color: var(--red-600); }

/* === My Dashboard — empty slot === */
.my-dash-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 218px;
    background: #ffffff;
    border: 2px dashed var(--slate-300);
    border-radius: 8px;
    transition: background 0.15s, border-color 0.15s;
}

.my-dash-slot-hint {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-400);
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--agp-navy);
    color: white;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    padding: 12px 22px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(27,54,104,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 600px) {
    .dashboard-tabs { flex-wrap: wrap; }
    .dash-tab { flex: 1; padding: 10px 8px; }
}

/* === My Dashboard — card wrap, body, remove button & drag visuals (Phase 4) === */
.my-dash-card-wrap { position: relative; }

.my-dash-card-body { cursor: grab; }
.my-dash-card-wrap.dragging .my-dash-card-body { cursor: grabbing; }

.my-dash-card-wrap.dragging {
    opacity: 0.7;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
}

.my-dash-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--agp-navy);
    color: white;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, transform 0.15s;
    z-index: 3;
}

.my-dash-card-wrap:hover .my-dash-remove { opacity: 1; }

.my-dash-remove:hover {
    background: var(--red-600);
    transform: scale(1.1);
}

/* Hide the × during any active drag to prevent accidental removal */
.my-dash-dragging .my-dash-remove { display: none; }

/* Valid drop-target highlight (works for library→grid and grid reorder) */
.my-dash-dragging .my-dash-card-wrap.drag-over,
.my-dash-dragging .my-dash-slot.drag-over {
    outline: 2px dashed var(--agp-sky);
    outline-offset: -2px;
    background: rgba(124, 207, 232, 0.12);
}

/* Pending / loading placeholder card body */
.my-dash-pending-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 181px;
    background: #f7f8fa;
    border-top: 1px solid #e2e7ef;
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-400);
}

/* My Dashboard cards are ~28px narrower than Business Dashboard tiles (the
   library panel takes that width). Tighten only the comparison-row horizontal
   padding + column gap so the value column ("vs 7,616") stays on one line.
   ID-scoped to #my-dash-grid — Business Dashboard's .kpi-comp-row is untouched.
   Fonts, header band, and card structure are unchanged. */
#my-dash-grid {
    column-gap: 8px;
}

/* Breathing room on the narrower (271px) My Dashboard cards: push the hero
   number + "YTD" sub-label in by +12px, and the comparison-row content in by
   +4px on the left. Comp-row total horizontal padding stays at 12px (8 + 4) —
   the verified ceiling that keeps the value column single-line. */
#my-dash-grid .kpi-hero {
    padding-left: 28px;
}

#my-dash-grid .kpi-comp-row {
    padding-left: 8px;
    padding-right: 4px;
    column-gap: 4px;
}

/* Variance pill sizes to content here (vs the uniform 64px floor on Business
   Dashboard) — reclaims the last few px so "vs 7,616" stays on one line. */
#my-dash-grid .kpi-comp-var {
    min-width: 0;
}

/* === My Dashboard — responsive: stack library above the grid === */
@media (max-width: 900px) {
    .my-dash-library {
        position: static;
        width: 100%;
        margin-bottom: 16px;
    }
    .my-dash-grid-col { margin-left: 0; }
    .my-dash-lib-sections {
        display: flex;
        gap: 14px;
        overflow-x: auto;
        padding-bottom: 4px;
    }
    .my-dash-lib-section {
        flex: 0 0 240px;
        margin-bottom: 0;
    }
    /* Group spacing is vertical-stack only — reset for the horizontal strip */
    .my-dash-lib-section + .my-dash-lib-section {
        margin-top: 0;
    }
}

/* === Profitability Reports (Kantata) — Phase 5 Part 1 === */
/* All rules scoped under .kantata-* — never touch existing drawer / MPR styles. */
.kantata-divider {
    height: 1px;
    background: var(--slate-200);
    margin: 4px 24px 12px;
}
.kantata-list {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 0 24px 12px;
}
.kantata-empty {
    color: var(--slate-400);
    font-size: 13px;
    text-align: center;
    padding: 12px 0 16px;
}
.kantata-month-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    margin-bottom: 6px;
}
.kantata-month-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kantata-month-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--agp-sky);
    flex-shrink: 0;
}
.kantata-month-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--agp-navy);
}
.kantata-month-meta {
    font-size: 11px;
    color: var(--slate-400);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 230px;
}
.kantata-delete-btn {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--slate-300);
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.15s;
}
.kantata-month-item:hover .kantata-delete-btn { opacity: 1; }
.kantata-delete-btn:hover { color: var(--red-600); background: var(--red-50); }

.kantata-upload-section {
    flex: 0 0 auto;
    padding: 12px 24px 20px;
    background: #f8f9ff;
    border-top: 1px solid var(--slate-200);
}
.kantata-upload-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}
.kantata-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-500);
}
.kantata-select,
.kantata-file {
    padding: 8px 10px;
    background: white;
    border: 1px solid var(--slate-300);
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--agp-navy);
    width: 100%;
}
.kantata-select:focus,
.kantata-file:focus {
    outline: none;
    border-color: var(--agp-navy-light);
}
.kantata-file {
    padding: 6px 8px;
    font-size: 12px;
}
.kantata-error {
    color: var(--red-600);
    font-size: 12px;
    margin: 2px 0 8px;
}
.kantata-upload-btn {
    width: 100%;
    padding: 10px;
    background: var(--agp-sky, #38bdf8);
    color: var(--agp-navy);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s;
}
.kantata-upload-btn:hover:not(:disabled) {
    background: var(--agp-navy);
    color: white;
}
.kantata-upload-btn:disabled {
    background: var(--slate-200);
    color: var(--slate-400);
    cursor: not-allowed;
}
