/*
 * OOSA v2 editorial design system — single source of truth.
 *
 * Used by both:
 *   - Reports v2 (HTMLReportBuilder reads this file, inlines into report HTML)
 *   - Portal v2 (client_service_v2 templates <link> to /static/css/oosa-v2.css)
 *
 * Self-contained: defines its own :root tokens. NOT brand-color-overridable;
 * the editorial palette is fixed across brands by design (consistent product
 * feel; clients still get their own logos via the cover section / portal
 * header, not via CSS variables).
 *
 * Canonical visual reference: oosa-sample-report.html. Keep in sync.
 */

/* Montserrat @font-face declarations live in oosa-fonts.css — single
   source of truth shared with standalone templates. Import here so
   anything linking oosa-v2.css also gets the fonts. */
@import url("oosa-fonts.ed9416579017.css");

:root {
    --bg: #f8f5ef;
    --paper: #ffffff;
    --ink: #111827;
    --soft: #334155;
    --muted: #5b6472;
    --rule: #e7e1d4;
    --teal: #0f766e;
    --teal-soft: #e6f1ef;
    --blue: #1d4ed8;
    --success: #157347;
    --danger: #b42318;
}

* { box-sizing: border-box; }

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    margin: 0;
    padding: 0;
    line-height: 1.55;
}

/*
 * The single paper. All sections render inside this one container.
 * Top margin gives the nav breathing room beneath it. Side gutter on
 * narrow viewports prevents the paper from touching screen edges.
 */
.report-paper {
    max-width: 920px;
    margin: 40px auto;
    background: var(--paper);
    padding: 56px 64px;
    border-radius: 18px;
    box-shadow: 0 1px 0 rgba(17,24,39,.04), 0 24px 48px -24px rgba(17,24,39,.08);
}
@media (max-width: 960px) {
    .report-paper { margin: 24px 16px; padding: 40px 28px; }
}

/*
 * `.page` used to be a separate card per section. Under v2 it's now an
 * internal divider — sections sit on the same paper, separated by a
 * subtle horizontal rule. Cover gets no top divider.
 */
.page {
    max-width: none;
    margin: 0;
    padding: 56px 0 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid var(--rule);
}
.page:first-child {
    padding-top: 0;
    border-top: 0;
}

/* Slim header band — keeps executive summary above the fold */
.cover { padding-top: 0; padding-bottom: 32px; border-top: 0; }
.cover h1 { font-size: 40px; line-height: 1.1; margin: 0; }

/*
 * PDF / print layout.
 *
 * @page sets a custom page size so WeasyPrint (and browser print) give
 * enough horizontal space for the 920 px report design.
 *
 * Width maths:
 *   page width 280mm − 2 × 18mm side margin = 244mm ≈ 922 px at 96 dpi
 *   The 920 px report-paper (max-width: none in print) fits with ~1 px
 *   to spare, so 7-column tables never overflow the page.
 *
 * Height: 396mm keeps an ~A4 aspect ratio (1 : √2) at the wider width.
 * WeasyPrint flows multi-section content across as many pages as needed
 * regardless of this value; it only controls where page breaks fall.
 */
@page {
    size: 280mm 396mm;
    margin: 24mm 18mm;
}
@media print {
    body { background: #ffffff; padding: 0; margin: 0; }
    .report-paper {
        max-width: none;
        margin: 0;
        /* padding is now supplied by @page margin above — zero here avoids
           double-indenting content in WeasyPrint. Browser print retains the
           @page margin too, so this is safe for both rendering paths. */
        padding: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .page { break-inside: avoid; }
    .doc-footer { margin-top: 24px; padding: 0; }
}

.eyebrow {
    font-size: 11px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}

h1 {
    font-size: 56px;
    line-height: 1.05;
    letter-spacing: -.02em;
    font-weight: 800;
    margin: 16px 0 12px;
}

h2 {
    font-size: 22px;
    letter-spacing: -.005em;
    font-weight: 700;
    margin: 0 0 24px;
}

h3 {
    font-size: 14px;
    letter-spacing: .02em;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 12px;
}

p { color: var(--soft); margin: 0 0 12px; }

.meta {
    display: flex;
    gap: 32px;
    color: var(--muted);
    font-size: 13px;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--rule);
}
.meta b { color: var(--ink); font-weight: 600; }

.section { margin-top: 56px; }
.section:first-of-type { margin-top: 0; }
.rule { height: 1px; background: var(--rule); border: 0; margin: 0 0 32px; }

/* Headline metric grid (Executive Summary) */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
}
/* Custom-marketing-cost extras — sit below .stat-grid, only rendered when
   the brand uploaded custom report sources for the period. Kept off the
   4-tile grid so the headline KPIs stay apples-to-apples month over month. */
.stat-extras {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-extra-row {
    display: grid;
    grid-template-columns: 1fr auto 2fr;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 13px;
    align-items: baseline;
}
.stat-extra-row .label {
    color: var(--soft);
    font-weight: 600;
}
.stat-extra-row .value {
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.stat-extra-row .break {
    color: var(--muted);
    font-size: 12px;
}
.stat {
    background: var(--paper);
    padding: 20px 18px;
}
.stat .label {
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}
.stat .value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.stat .delta {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.flag {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--danger);
    background: #fdecea;
    padding: 2px 8px;
    border-radius: 999px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}
th, td {
    text-align: left;
    padding: 14px 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--rule);
}
th {
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 1px solid var(--ink);
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 0; }

/* tACOS bar */
.tacos-bar {
    height: 8px;
    background: var(--rule);
    border-radius: 999px;
    overflow: hidden;
    margin: 12px 0 6px;
    position: relative;
}
.tacos-fill { height: 100%; background: var(--teal); border-radius: 999px; }
.tacos-target {
    position: absolute;
    top: -4px; bottom: -4px;
    width: 2px;
    background: var(--ink);
}
.tacos-legend {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
}

/* Insight panel */
.insight {
    border-left: 3px solid var(--teal);
    background: var(--teal-soft);
    padding: 18px 22px;
    margin-top: 24px;
}
.insight h3 { color: var(--teal); margin-bottom: 8px; }
.insight p { color: var(--ink); margin: 0; }

/* Numbered steps (Next Steps section) */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li {
    counter-increment: step;
    padding: 16px 0 16px 44px;
    border-bottom: 1px solid var(--rule);
    position: relative;
    color: var(--soft);
}
.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0; top: 16px;
    width: 28px; height: 28px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.steps li b { color: var(--ink); font-weight: 600; }
.steps li:last-child { border-bottom: 0; }

/* Doc footer */
.doc-footer {
    max-width: 920px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    padding: 24px 24px 40px;
    gap: 16px;
    flex-wrap: wrap;
}
.mark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--ink);
}
.mark .dot {
    width: 10px; height: 10px;
    background: var(--teal);
    border-radius: 999px;
    display: inline-block;
}

/*
 * Automations section — adapted from the OOSA Landing `.run` component.
 * Dark navy header band, diff-row body, light footer. Intentionally
 * different from the rest of v2's all-light styling because this is the
 * "engine room" — a glimpse of what OOSA does between reports.
 */
.run {
    margin-top: 16px;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 14px;
    overflow: hidden;
}
.run-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;
    padding: 18px 22px;
    background: #0b0f1a;
    color: #e7e1d4;
    border-bottom: 1px solid var(--rule);
}
.run-id { display: flex; flex-direction: column; gap: 4px; }
.run-pill {
    display: inline-block;
    align-self: flex-start;
    background: #34d399;
    color: #062a22;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    font-variant-numeric: tabular-nums;
}
.run-stamp { font-size: 12.5px; color: rgba(255,255,255,.55); letter-spacing: .02em; font-weight: 500; }
.run-status { display: flex; gap: 18px; flex-wrap: wrap; }
.run-stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.run-stat b { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -.01em; }
.run-stat span { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.45); margin-top: 4px; font-weight: 600; }
.run-stat.ok b { color: #34d399; }

.diff { list-style: none; margin: 0; padding: 0; }
.diff-row {
    display: grid;
    grid-template-columns: 96px 100px 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--rule);
    font-size: 13px;
    color: var(--soft);
}
.diff-row:last-child { border-bottom: 0; }
.diff-time { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.diff-tag {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    padding: 4px 8px;
    border-radius: 5px;
    background: var(--teal-soft);
    color: var(--teal);
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.diff-tag.write { background: rgba(16,185,129,.12); color: #047857; }
.diff-tag.write.down { background: #fdecea; color: var(--danger); }
.diff-tag.harvest { background: #fff4e0; color: #92400e; }
.diff-tag.pause { background: #fdecea; color: var(--danger); }
.diff-tag.log { background: var(--rule); color: var(--muted); }
.diff-msg { color: var(--soft); }
.diff-msg b { color: var(--ink); font-weight: 700; }
.diff-msg .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--ink);
    background: var(--bg);
    padding: 1px 5px;
    border-radius: 3px;
}
.diff-state {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.diff-state::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--muted);
}
.diff-state.ok { color: var(--success); }
.diff-state.ok::before { background: var(--success); }
.diff-state.hold { color: #92400e; }
.diff-state.hold::before { background: #f59e0b; }

.run-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 14px 22px;
    background: var(--bg);
    border-top: 1px solid var(--rule);
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
}
.run-cad { font-weight: 700; color: var(--ink); letter-spacing: .04em; font-size: 11px; text-transform: uppercase; }

@media print {
    .run-head { background: #0b0f1a !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .diff-tag, .diff-state::before, .run-pill, .run-stat.ok b {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ============================================================
 * Portal-specific additions (forms, embedded report frame,
 * item lists, two-column grids). Reports v2 doesn't use these
 * — keeping them grouped so we can split into a portal bundle
 * if the file gets unwieldy.
 * ============================================================ */

.portal-frame {
    margin-top: 16px;
    border: 1px solid var(--rule);
    border-radius: 14px;
    overflow: hidden;
    background: var(--paper);
}
.portal-frame iframe {
    width: 100%;
    height: 560px;
    border: 0;
    display: block;
}

.button {
    display: inline-block;
    font-family: inherit;
    line-height: 1.2;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .02em;
    border: 0;
    cursor: pointer;
}
.button.secondary {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--ink);
}
.button.small { padding: 6px 12px; font-size: 12px; }

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}
@media (max-width: 720px) {
    .two-col { grid-template-columns: 1fr; gap: 32px; }
}

.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--rule);
}
.item-list li:last-child { border-bottom: 0; }
.item-title { font-weight: 600; color: var(--ink); }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.item-body { font-size: 14px; color: var(--soft); margin-top: 4px; }

/*
 * Campaign alerts (currently Amazon-only; reusable for other channels).
 * Critical = red, warning = orange. Each card has its own action footer
 * with Acknowledge + Resolve buttons; JS removes the card on success.
 */
.alerts-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.alert-card {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-left: 4px solid var(--muted);
    border-radius: 10px;
    padding: 14px 18px;
}
.alert-card.alert-critical { border-left-color: var(--danger); background: #fff8f7; }
.alert-card.alert-warning  { border-left-color: #d97706; background: #fffbf2; }

.alert-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.alert-severity-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-right: 8px;
}
.alert-severity-critical { background: var(--danger); color: #fff; }
.alert-severity-warning  { background: #d97706; color: #fff; }
.alert-type-label { font-weight: 700; color: var(--ink); font-size: 14px; }
.alert-when { font-size: 12px; color: var(--muted); }

.alert-card-body { font-size: 13.5px; color: var(--soft); line-height: 1.5; }
.alert-campaign { margin-bottom: 6px; }
.alert-campaign strong { color: var(--ink); font-size: 14px; }
.alert-meta { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.alert-explainer { margin: 8px 0 12px; color: var(--soft); }
.alert-explainer strong { color: var(--ink); font-weight: 700; }

.alert-context {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px 16px;
    margin: 8px 0 12px;
    padding: 10px 12px;
    background: rgba(17, 24, 39, 0.03);
    border-radius: 8px;
}
.alert-context > div { display: flex; flex-direction: column; }
.alert-context dt {
    font-size: 10.5px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}
.alert-context dd {
    margin: 2px 0 0;
    font-size: 13.5px;
    color: var(--ink);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Choice-framed prompt — the main decision the client has to make */
.alert-prompt {
    color: var(--soft);
    line-height: 1.55;
    margin: 8px 0 12px;
    font-size: 14px;
}
.alert-prompt strong { color: var(--ink); font-weight: 700; }

/* AI-generated recommendation block — visually subordinate to the alert
   itself (slight teal tint, ribbon-style left border) so the user can
   tell it apart from the deterministic explainer. */
.alert-ai-rec {
    margin: 8px 0 12px;
    padding: 10px 12px 6px;
    background: var(--teal-soft);
    border-left: 3px solid var(--teal);
    border-radius: 6px;
}
.alert-ai-rec-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}
.alert-prompt-ai {
    margin: 0 0 4px;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
}
.ai-attr {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--teal);
}
.ai-attr-time {
    font-size: 11px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.alert-rec-generate, .alert-rec-regen {
    /* These live inside .alert-prompt / .alert-ai-rec; small inline action */
    margin-left: 6px;
}
.alert-rec-loading {
    color: var(--muted);
    font-style: italic;
    margin-left: 6px;
    font-size: 12.5px;
}

.alert-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.alert-action-status {
    font-size: 12px;
    color: var(--muted);
    min-height: 16px;
}
.alert-card.is-resolving { opacity: .55; pointer-events: none; transition: opacity .25s ease; }

/* Secondary self-serve actions on each alert (Ask AI · Get help) — text
   links separated by a divider; visually subordinate to the primary
   accept/resolve buttons. */
.alert-secondary-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--rule);
    font-size: 12px;
}
.alert-link-btn {
    background: transparent;
    border: 0;
    color: var(--teal);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 6px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(15, 118, 110, 0.35);
}
.alert-link-btn:hover {
    color: var(--ink);
    text-decoration-color: var(--ink);
}

/* Inline period badge — "MTD" next to the latest-report period heading */
.period-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 999px;
    vertical-align: middle;
    position: relative;
    top: -2px;
}

.status-pill {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    border-radius: 999px;
    background: var(--rule);
    color: var(--muted);
}
.status-pill.open { background: rgba(16,185,129,.12); color: #047857; }
.status-pill.done, .status-pill.completed, .status-pill.closed { background: var(--rule); color: var(--muted); }
.status-pill.in_progress { background: #fff4e0; color: #92400e; }
/* Experiment statuses */
.status-pill.proposed { background: var(--rule); color: var(--muted); }
.status-pill.active { background: rgba(16,185,129,.12); color: #047857; }
.status-pill.running { background: rgba(16,185,129,.12); color: #047857; }
.status-pill.paused { background: #fff4e0; color: #92400e; }
.status-pill.concluded { background: rgba(15,118,110,.1); color: #0f766e; }
/* Strategy statuses */
.status-pill.planned { background: rgba(59,130,246,.1); color: #1d4ed8; }
.status-pill.testing { background: #fff4e0; color: #92400e; }
.status-pill.scaling { background: rgba(16,185,129,.12); color: #047857; }
.status-pill.draft { background: var(--rule); color: var(--muted); }
.status-pill.ready { background: rgba(59,130,246,.1); color: #1d4ed8; }
/* Risk level indicators */
.risk-pill { display: inline-block; padding: 2px 7px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 999px; }
.risk-pill.low { background: rgba(16,185,129,.1); color: #047857; }
.risk-pill.medium { background: #fff4e0; color: #92400e; }
.risk-pill.high { background: rgba(239,68,68,.1); color: #b91c1c; }
/* status-chip (inline table use) */
.status-chip { display: inline-block; padding: 2px 7px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border-radius: 4px; background: var(--rule); color: var(--muted); }
.status-chip--green { background: rgba(16,185,129,.12); color: #047857; }
.status-chip--blue { background: rgba(59,130,246,.1); color: #1d4ed8; }
.status-chip--yellow { background: #fff4e0; color: #92400e; }
.status-chip--red { background: rgba(239,68,68,.1); color: #b91c1c; }

.portal-form {
    display: grid;
    gap: 10px;
    margin: 12px 0 20px;
    padding: 14px;
    background: var(--bg);
    border-radius: 10px;
}
.portal-form input[type="text"],
.portal-form input[type="date"],
.portal-form input[type="email"],
.portal-form input[type="number"],
.portal-form select,
.portal-form textarea {
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink);
    width: 100%;
}
.portal-form label {
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}
.portal-form .field { display: flex; flex-direction: column; }
.portal-form button { justify-self: start; }

.empty-state {
    color: var(--muted);
    font-style: italic;
    padding: 12px 0;
    font-size: 13.5px;
}

/* ============================================================
 * Top nav bar (sticky)
 * ============================================================ */
.topnav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--rule);
    box-shadow: 0 1px 0 rgba(17, 24, 39, 0.02);
}
.topnav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.topnav-divider {
    width: 1px;
    height: 20px;
    background: var(--rule);
    display: inline-block;
}
.topnav-spacer { flex: 1; min-width: 16px; }

/* "OOSA.ai" wordmark — match the marketing landing nav.
   Wrapper `.brand` carries the logo + wordmark; `.brand-mark` is the
   text-only span. Same letter-spacing + weight as landing so the user
   doesn't experience a visual jump when crossing into the portal. */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    letter-spacing: .04em;
    text-decoration: none;
    line-height: 1;
}
.brand img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}
.brand-mark {
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    letter-spacing: .04em;
    font-size: 17px;
    color: var(--ink);
    text-decoration: none;
    line-height: 1;
}
/* The wordmark's ".ai" suffix uses the LANDING's teal (#15803d, which
   is actually a forest green — the variable name is misleading). The
   portal's --teal (#0f766e, true cyan-teal) is used elsewhere for
   tacos charts, badges, etc. — keep those untouched. Only the brand
   accent needs to match landing exactly. */
.brand-mark .brand-tld { color: #15803d; font-weight: 800; }
/* Back-compat selector — older templates still use .ai-suffix. */
.brand-mark .ai-suffix { color: #15803d; font-weight: 800; }

/* Brand selector (dropdown) */
.brand-selector { position: relative; }
.brand-selector-btn {
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}
.brand-selector-btn:hover { border-color: var(--ink); }
.brand-selector-menu {
    position: absolute;
    top: 110%;
    left: 0;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 10px;
    box-shadow: 0 12px 32px -8px rgba(17,24,39,.18);
    min-width: 200px;
    display: none;
    max-height: 360px;
    overflow-y: auto;
}
.brand-selector.open .brand-selector-menu { display: block; }
.brand-selector-menu li a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--ink);
    font-size: 13.5px;
    border-radius: 6px;
}
.brand-selector-menu li a:hover { background: var(--bg); }
.brand-selector-menu li a.current { background: var(--ink); color: #fff; font-weight: 600; }

.brand-selector-static {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

/* Top-level primary nav: Home | Channels */
.topnav-primary {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 4px;
    align-items: center;
}
.topnav-primary > li > a,
.topnav-primary > li > .channels-menu-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    color: var(--soft);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    background: transparent;
    border: 0;
    font-family: inherit;
    cursor: pointer;
}
.topnav-primary > li > a:hover,
.topnav-primary > li > .channels-menu-btn:hover {
    color: var(--ink);
    background: var(--bg);
}
.topnav-primary > li > a.active,
.topnav-primary > li > .channels-menu-btn.active {
    color: var(--ink);
    background: var(--bg);
}

/* Channels dropdown — same affordance as brand selector */
.channels-menu { position: relative; }
.channels-menu-panel {
    position: absolute;
    top: 110%;
    left: 0;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 10px;
    box-shadow: 0 12px 32px -8px rgba(17,24,39,.18);
    min-width: 220px;
    display: none;
    z-index: 45;
}
.channels-menu.open .channels-menu-panel { display: block; }
.channels-menu-panel li { position: relative; }
.channels-menu-panel li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--ink);
    font-size: 13.5px;
    border-radius: 6px;
}
.channels-menu-panel li a:hover { background: var(--bg); }
.channels-menu-panel li a.current { background: var(--ink); color: #fff; font-weight: 600; }

/*
 * Amazon marketplaces — always-visible nested list inside the Channels
 * dropdown when a brand has multiple marketplaces. Avoids hover-only
 * affordances (unreliable on touch) and shows the user the full set
 * even when some are credentialed-but-not-enabled (disabled state).
 */
.channel-submarkets {
    list-style: none;
    margin: 4px 0 6px 16px;
    padding: 0 0 0 8px;
    border-left: 1px solid var(--rule);
}
.channel-submarkets li a {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 10px;
    color: var(--soft);
    text-decoration: none;
    font-size: 12.5px;
    border-radius: 6px;
}
.channel-submarkets li a:hover { background: var(--bg); color: var(--ink); }
.channel-submarkets li a.current { background: var(--ink); color: #fff; font-weight: 600; }
.channel-submarkets li a.disabled {
    opacity: .45;
    pointer-events: none;
}
.channel-submarkets .mp-code {
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .04em;
    min-width: 22px;
}
.channel-submarkets .mp-label { font-size: 12px; color: var(--muted); }
.channel-submarkets li a.current .mp-label { color: rgba(255,255,255,.7); }

/* In-page marketplace switcher (Amazon channel page) */
.marketplace-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding: 4px;
    margin: 16px 0 24px;
}
.marketplace-tabs a {
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
}
.marketplace-tabs a:hover { color: var(--ink); }
.marketplace-tabs a.current { background: var(--ink); color: #fff; }
.marketplace-tabs a.disabled { opacity: .35; pointer-events: none; }

.topnav-cog {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    text-decoration: none;
    padding: 7px;
    border-radius: 8px;
    opacity: .5;
    line-height: 0;
    transition: opacity .15s ease, background .15s ease;
}
.topnav-cog:hover { opacity: 1; background: rgba(17,24,39,.06); }

.topnav-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ink);
    color: #fff;
    text-decoration: none;
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}
.topnav-action:hover { background: #000; }

/* ============================================================
 * Ask AI panel (click-to-reveal)
 * ============================================================ */
.ask-ai-wrap { position: relative; }
.ask-ai-panel {
    position: absolute;
    top: 110%;
    right: 0;
    width: 360px;
    max-width: 90vw;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 14px;
    padding: 18px 18px 16px;
    box-shadow: 0 24px 48px -16px rgba(17,24,39,.18);
    z-index: 40;
}
.ask-ai-panel h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    text-transform: none;
    letter-spacing: 0;
}
.ask-ai-badge {
    display: inline-flex;
    align-items: center; justify-content: center;
    font-size: 14px;
    line-height: 1;
    margin-left: 4px;
    filter: grayscale(1);
}
.ask-ai-btn:hover .ask-ai-badge { filter: none; }

/* ============================================================
 * Report Bug component (reusable)
 *
 * Two render contexts:
 *  - Inline beside a section header (.section-head-row > .report-bug-wrap)
 *    — the toggle sits to the right of the h2, beta affordance up top.
 *  - Standalone bottom-of-section (legacy fallback) — right-aligned.
 * ============================================================ */
.section-head-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin: 0 0 8px;
}
.section-head-row h2 { margin: 0; }

.report-bug-wrap {
    margin: 0;
    flex-shrink: 0;
}
.report-bug-toggle {
    background: var(--paper);
    border: 1px dashed var(--muted);
    color: var(--ink);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}
.report-bug-toggle:hover { border-color: var(--ink); background: var(--bg); }
.report-bug-toggle[aria-expanded="true"] {
    background: var(--ink);
    color: #fff;
    border-style: solid;
    border-color: var(--ink);
}
.report-bug-panel {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 10px;
    text-align: left;
    width: 100%;
}

/* Floating variant — fixed bottom-right of the viewport */
.report-bug-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 90;
}
.report-bug-float .report-bug-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    top: auto;
    margin-top: 0;
    width: 320px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
}

/*
 * Sub-nav row (managers only) — sits directly below the main nav,
 * holds the "Preview as" switcher. Visually distinct (lighter weight,
 * centered) since it's a rendering control, not navigation.
 */
.topnav-sub {
    position: sticky;
    top: 53px;   /* below the main nav (which is ~52–53px tall) */
    z-index: 49;
    background: rgba(248, 245, 239, 0.94);
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--rule);
}
.topnav-sub-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}
.topnav-sub-label {
    font-size: 10.5px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}

/* Role switcher (manager <-> client preview) — managers only */
.role-switcher {
    display: inline-flex;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding: 3px;
    font-size: 12px;
}
.role-switcher-opt {
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: .02em;
    transition: background .12s ease, color .12s ease;
}
.role-switcher-opt:hover { color: var(--ink); }
.role-switcher-opt.active {
    background: var(--ink);
    color: #fff;
}

/* Ask AI export button — outline pill with tooltip hint */
.ask-ai-btn {
    border: 1px solid var(--ink);
    background: transparent;
    color: var(--ink);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.ask-ai-btn::after {
    content: "?";
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 14px; height: 14px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    margin-left: 2px;
}
.ask-ai-btn:hover { background: var(--ink); color: #fff; }
.ask-ai-btn:hover::after { background: #fff; color: var(--ink); }

.toast-list { list-style: none; margin: 0 0 16px; padding: 0; }
.toast-list li {
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--teal-soft);
    color: var(--teal);
    border-left: 3px solid var(--teal);
    font-size: 13px;
    margin-bottom: 6px;
}
.toast-list li.error { background: #fdecea; color: var(--danger); border-left-color: var(--danger); }

/* Foundation placeholder — visible while v2 sections roll in commit-by-commit */
.v2-placeholder {
    max-width: 720px;
    margin: 96px auto;
    text-align: center;
    color: var(--muted);
}
.v2-placeholder h2 { color: var(--ink); margin-bottom: 16px; }
.v2-placeholder code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    color: var(--ink);
}

/* Branded loading spinner — used by HTMX lazy widgets (_widget_skeleton.html) */
@keyframes oosa-spin {
    to { transform: rotate(360deg); }
}
.oosa-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--rule);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: oosa-spin 0.9s linear infinite;
}
.widget-skeleton {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    color: var(--muted);
    gap: 12px;
    font-size: 13px;
    padding: 24px;
    border: 1px solid var(--rule);
    border-radius: 12px;
    background: var(--paper);
}

/* ─── Correlation section (shared by report and portal) ─────────────────── */
.corr-row { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.corr-row:last-child { border-bottom: none; }
.corr-platform { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.corr-score { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.corr-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.corr-bar-wrap { height: 6px; background: var(--rule); border-radius: 3px; margin-bottom: 8px; }
.corr-bar { height: 6px; background: var(--teal); border-radius: 3px; }
.corr-text { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.r2-badge {
    display: inline-block; font-size: 11px; font-weight: 700;
    letter-spacing: .05em; border-radius: 4px; padding: 2px 7px;
}
.r2-badge-pos { background: rgba(15,118,110,.1); color: var(--teal); }
.r2-badge-neg { background: rgba(180,35,24,.08); color: #b42318; }
