/* Morning briefing — per-account status cards. */

/* ============================================================
   Tabbed shell — Briefing tab + Reports tab inside one page.
   ============================================================ */
.monitor-shell {
    /* The centered 1320px content column every non-editor page uses (DESIGN_SYSTEM.md). It was
       full-bleed; wide critical-action tables scroll inside their own card, so the cap no longer
       truncates the right-edge Open button. */
    max-width: 1320px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 28px 0;
    box-sizing: border-box;
}

/* Page header (title + sub) — always at top, above tabs. */
.monitor-page-header {
    margin-bottom: 12px;
}

/* Rebuild bar — cache pill + Rebuild button, sits between the title
   and the tab strip. Always visible, applies to all tabs. */
.monitor-headerbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-bottom: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.monitor-tabs {
    display: flex; gap: 4px;
    margin: 8px 0 0;
    border-bottom: 2px solid #ececf3;
    overflow-x: auto; scrollbar-width: none;   /* phones: the last tab (Reports) was cut off and unreachable */
}
.monitor-tabs::-webkit-scrollbar { display: none; }
.monitor-tab-btn {
    white-space: nowrap; flex: 0 0 auto;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 18px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 600;
    color: #6e6e8a;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.monitor-tab-btn:hover {
    color: #1a1a2e;
    background: #fafafd;
}
.monitor-tab-btn.active {
    color: #5B53E8;
    border-bottom-color: #5B53E8;
}
.monitor-tab-icon {
    font-size: 16px; line-height: 1;
}
.monitor-tab-content {
    display: block;
}
.monitor-tab-content > .briefing-page,
.monitor-tab-content > .reports-page {
    padding-top: 16px;
}
/* The tab bodies sit in the shell's column: no second horizontal inset, so the body lines up with
   the page header (it was 24px further right: header x=104, body x=128 — QA 2026-11-08). */
.monitor-tab-content.briefing-page { padding-left: 0; padding-right: 0; }
.monitor-tab-content > .reports-page { max-width: none; padding-left: 0; padding-right: 0; }
@media (max-width: 700px) {
    .monitor-shell { padding: 20px 16px 0; }
}

/* Default briefing-page padding (now scoped inside the monitor shell). */
.briefing-page {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 16px 24px 64px;
    font-size: 13px;
    color: #1a1a2e;
    box-sizing: border-box;
}

/* ---------- Header ---------- */
.briefing-header { margin-bottom: 16px; }
.briefing-title h1 {
    font-size: 26px; font-weight: 800; letter-spacing: -0.01em;
    margin-bottom: 4px; color: #0e0e1f;
}
.briefing-sub {
    font-size: 13px; color: #6e6e8a; line-height: 1.5;
    max-width: 720px;
}

/* ---------- Top metrics + cache + rebuild ---------- */
.briefing-topbar {
    display: flex; gap: 18px; align-items: center;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: linear-gradient(135deg, #fafafd, #f4f4fb);
    border: 1px solid #ececf3;
    border-radius: 12px;
    margin-bottom: 14px;
}
.briefing-totals {
    display: flex; gap: 28px; flex: 1;
    flex-wrap: wrap;
}
.briefing-total { display: flex; flex-direction: column; gap: 2px; min-width: 80px; }
.briefing-total-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    color: #6e6e8a;
}
.briefing-total-value {
    font-size: 18px; font-weight: 800; color: #0e0e1f;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}
.briefing-cache-pill {
    padding: 5px 11px;
    border-radius: 14px;
    font-size: 11px; font-weight: 600;
    background: #f0f0f7;
    color: #6e6e8a;
    white-space: nowrap;
}
.briefing-cache-pill.briefing-cache-fresh   { background: #ecfdf5; color: #047857; }
.briefing-cache-pill.briefing-cache-cached  { background: #eff6ff; color: #1d4ed8; }
.briefing-cache-pill.briefing-cache-stale   { background: #fef2f2; color: #b91c1c; }
.briefing-cache-pill:empty { display: none; }
.briefing-rebuild-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: #5B53E8; color: #fff;
    border: none; border-radius: 7px;
    font-size: 12.5px; font-weight: 600;
    cursor: pointer; transition: background 0.12s;
}
.briefing-rebuild-btn:hover { background: #4f46e5; }

/* ---------- Controls (filters + sort) ---------- */
.briefing-controls {
    display: flex; gap: 18px; align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.briefing-chips { display: flex; gap: 8px; flex-wrap: wrap; }   /* wraps on phones instead of running off the screen (audit 2026-11-08) */
.briefing-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    background: #fff; border: 1.5px solid #ececf3;
    border-radius: 18px;
    font-size: 12px; font-weight: 600; color: #4a4a6a;
    cursor: pointer;
    transition: all 0.12s;
}
.briefing-chip:hover { border-color: #d4d4e0; }
.briefing-chip-count {
    background: #ececf3; color: #4a4a6a;
    padding: 1px 7px; border-radius: 10px;
    font-size: 10.5px; font-variant-numeric: tabular-nums;
}
.briefing-chip-all.active    { background: #5B53E8; color: #fff; border-color: #5B53E8; }
.briefing-chip-all.active .briefing-chip-count { background: rgba(255,255,255,0.25); color: #fff; }
.briefing-chip-red.active    { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.briefing-chip-red.active .briefing-chip-count { background: #fecaca; color: #b91c1c; }
.briefing-chip-yellow.active { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.briefing-chip-yellow.active .briefing-chip-count { background: #fed7aa; color: #c2410c; }
.briefing-chip-green.active  { background: #ecfdf5; color: #047857; border-color: #bbf7d0; }
.briefing-chip-green.active .briefing-chip-count { background: #bbf7d0; color: #047857; }

/* Account-name search — sits between the status chips and the sort. */
.briefing-search {
    display: flex; align-items: center; gap: 7px;
    background: #fff; border: 1px solid #d4d4e0; border-radius: 8px;
    padding: 7px 10px; margin-left: auto;
    min-width: 200px;
}
.briefing-search input {
    flex: 1; min-width: 0; border: none; background: none; outline: none;
    font-size: 12.5px; color: #1a1a2e; font-family: inherit;
}
.briefing-sort { display: flex; align-items: center; gap: 8px; }
.briefing-sort-label {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: #4a4a6a;
}
.briefing-sort-select {
    background: #fff; border: 1px solid #d4d4e0;
    border-radius: 7px; padding: 7px 10px;
    font-size: 12.5px; color: #1a1a2e;
    font-family: inherit;
}

/* ---------- Loading / empty / error ---------- */
.briefing-loading, .briefing-empty, .briefing-error {
    text-align: center;
    padding: 50px 30px;
    background: #fff;
    border: 1px dashed #d4d4e0;
    border-radius: 12px;
    color: #6e6e8a;
    font-size: 13.5px;
}
.briefing-empty h3 { font-size: 16px; color: #1a1a2e; margin-bottom: 6px; }
.briefing-error {
    background: #fef2f2; border-color: #fecaca; color: #b91c1c;
}

/* ---------- Card grid ---------- */
/* Each account card now spans 100% width — the eye reads top-down,
   one client at a time. Inside each card sits a 4-column grid showing
   3d / 7d / 30d / actions side-by-side. */
.briefing-grid-host {}
.briefing-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.briefing-card {
    background: #fff;
    border: 1.5px solid #ececf3;
    border-radius: 14px;
    padding: 16px 18px;
    display: flex; flex-direction: column;
    gap: 12px;
    transition: box-shadow 0.15s, transform 0.15s;
    width: 100%;
}
.briefing-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}
.briefing-card-red    { border-color: #fecaca; background: linear-gradient(180deg, #fff 0%, #fef2f2 100%); }
.briefing-card-yellow { border-color: #fed7aa; background: linear-gradient(180deg, #fff 0%, #fff7ed 100%); }
.briefing-card-green  { border-color: #bbf7d0; background: linear-gradient(180deg, #fff 0%, #f6fef9 100%); }

/* Placeholder while a per-connection fetch is in flight. */
.briefing-card-placeholder {
    border-style: dashed;
    opacity: 0.85;
    background: #fafafd;
    min-height: 110px;
}
.briefing-card-placeholder .briefing-status-dot {
    background: #d4d4e0;
    animation: briefing-pulse 1.4s ease-in-out infinite;
}
.briefing-placeholder-status {
    font-size: 11.5px; color: #6e6e8a;
    padding: 6px 0 0 22px;
    font-style: italic;
}
.briefing-card-placeholder.briefing-placeholder-failed .briefing-status-dot { background: #ef4444; animation: none; }
.briefing-card-placeholder.briefing-placeholder-failed .briefing-placeholder-status { color: #b91c1c; font-style: normal; font-weight: 600; }
/* Per-connection Retry on a failed card — re-fetches just that account. */
.briefing-placeholder-retry {
    margin: 8px 0 0 22px;
    display: inline-flex; align-items: center;
    font-size: 12px; font-weight: 600; color: #b91c1c;
    background: #fff; border: 1px solid #fca5a5; border-radius: 7px;
    padding: 5px 12px; cursor: pointer; font-family: inherit;
}
.briefing-placeholder-retry:hover { background: #fef2f2; }
.briefing-placeholder-retry:disabled { opacity: .6; cursor: default; }
@keyframes briefing-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.2); }
}
.briefing-cache-pill.briefing-cache-loading {
    background: #eff6ff; color: #1d4ed8;
    animation: briefing-loading-pulse 1.6s ease-in-out infinite;
}
@keyframes briefing-loading-pulse {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}

/* ============================================================
   Critical-actions table — used to sit BELOW the account cards;
   now lives in its OWN tab with no dashed border / extra padding.
   ============================================================ */
.briefing-critical-host {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 2px dashed #ececf3;
}
/* When the critical-actions block is the SOLE content of its tab
   (the new "Critical actions" tab), drop the divider and top
   padding — there's nothing above it that needs separating from. */
.briefing-critical-host-standalone {
    margin-top: 8px;
    padding-top: 0;
    border-top: none;
}

/* Totals strip when it's the first element of the Overview tab —
   gets its own bottom margin since there's no longer a topbar
   wrapper providing the space. */
.briefing-totals-standalone {
    margin-bottom: 16px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #fafafd, #f4f4fb);
    border: 1px solid #ececf3;
    border-radius: 12px;
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
}
.briefing-critical-header {
    display: flex; align-items: baseline; gap: 16px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.briefing-critical-title {
    font-size: 18px; font-weight: 800; letter-spacing: -0.01em;
    color: #0e0e1f;
    display: flex; align-items: center; gap: 10px;
    margin: 0;
}
.briefing-critical-count {
    background: #fef2f2; color: #b91c1c;
    font-size: 12px; font-weight: 700;
    padding: 2px 9px; border-radius: 10px;
    font-variant-numeric: tabular-nums;
}
.briefing-critical-more {
    font-size: 11.5px; color: #6e6e8a;
}
/* Export the current view (scope + bucket filter) as CSV — right edge of the header. */
.briefing-critical-export {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: #4a4a6a;
    background: #fff; border: 1px solid #d4d4e0; border-radius: 7px;
    padding: 6px 11px; cursor: pointer; font-family: inherit;
}
.briefing-critical-export:hover { background: #fafafd; color: #1a1a2e; }
.briefing-critical-empty {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    padding: 20px;
    font-size: 13px;
    color: #047857;
    text-align: center;
}

/* Filter tabs above the critical-actions table. Each tab carries
   a counter; clicking switches the table's bucket filter. Empty
   buckets render as faded + non-clickable. */
.briefing-action-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 2px solid #ececf3;
    padding-bottom: 0;
}
/* Account-scope select at the tabs row's right edge — narrows the
   table (and the bucket counts) to one client. */
.briefing-acct-filter {
    margin-left: auto;
    margin-bottom: 6px;
    max-width: 260px;
    background: #fff; border: 1px solid #d4d4e0;
    border-radius: 7px; padding: 6px 9px;
    font-size: 12.5px; color: #1a1a2e;
    font-family: inherit;
}
.briefing-action-tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 13px;
    font-weight: 600;
    color: #6e6e8a;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.briefing-action-tab:hover:not(.empty) {
    color: #1a1a2e;
    background: #fafafd;
}
.briefing-action-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: #ececf3;
    color: #4a4a6a;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: background 0.12s, color 0.12s;
}
.briefing-action-tab.empty {
    color: #646B78;
    cursor: not-allowed;
}
.briefing-action-tab.empty .briefing-action-tab-count {
    background: #f4f4f8;
    color: #646B78;
}
/* Active state — colored bar + colored count badge per bucket */
.briefing-action-tab-losing.active  { color: #b91c1c; border-bottom-color: #ef4444; }
.briefing-action-tab-losing.active  .briefing-action-tab-count { background: #fecaca; color: #b91c1c; }
.briefing-action-tab-fatigue.active { color: #86198f; border-bottom-color: #a855f7; }
.briefing-action-tab-fatigue.active .briefing-action-tab-count { background: #f5d0fe; color: #86198f; }
.briefing-action-tab-scale.active   { color: #047857; border-bottom-color: #10b981; }
.briefing-action-tab-scale.active   .briefing-action-tab-count { background: #bbf7d0; color: #047857; }
.briefing-action-tab-all.active     { color: #4338ca; border-bottom-color: #5B53E8; }
.briefing-action-tab-all.active     .briefing-action-tab-count { background: #ddd6fe; color: #4338ca; }

.briefing-critical-host {
    /* Allow the table to scroll horizontally inside this host if the
       viewport is genuinely too narrow for all 9 columns. Cleaner than
       hiding the right-edge content like the global main-content
       overflow:hidden was doing. */
    overflow-x: auto;
}
.briefing-critical-table {
    width: 100%;
    min-width: 1100px;          /* below this the columns truly can't fit */
    border-collapse: separate; border-spacing: 0;
    table-layout: fixed;            /* fixed = column widths come from the THs */
    background: #fff;
    border: 1px solid #ececf3;
    border-radius: 14px;
    overflow: hidden;
    font-size: 12.5px;
}
/* Column widths — each metric gets its own narrow column so eyes
   can scan a vertical axis (e.g. compare ROAS down the page). */
.briefing-critical-th-entity   { width: auto;   }
.briefing-critical-th-account  { width: 110px;  }
.briefing-critical-th-num      { width: 95px;   }
.briefing-critical-th-actions  { width: 175px;  }
/* Higher-specificity right-align — the global `.briefing-critical-table th`
   rule below sets text-align:left and would otherwise win on cascade order. */
.briefing-critical-table th.briefing-critical-th-num { text-align: right; }

.briefing-critical-table th {
    text-align: left;
    padding: 13px 14px;
    background: #fafafd;
    border-bottom: 2px solid #ececf3;
    font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: #4a4a6a;
    white-space: nowrap;
}
.briefing-critical-table td {
    padding: 14px 12px;
    border-bottom: 1px solid #ececf3;
    vertical-align: middle;
    overflow: hidden;
}
.briefing-critical-table th {
    padding: 13px 12px;
}
.briefing-critical-table tr:last-child td { border-bottom: none; }
.briefing-critical-row { transition: background 0.12s; }
.briefing-critical-row:hover { background: #fafafd; }

/* Coloured left edge on the FIRST cell (Entity now) per tag —
   strong visual signal at scan time. */
.briefing-critical-row-kill    td:first-child { box-shadow: inset 5px 0 0 #ef4444; padding-left: 22px !important; }
.briefing-critical-row-scale   td:first-child { box-shadow: inset 5px 0 0 #10b981; padding-left: 22px !important; }
.briefing-critical-row-fatigue td:first-child { box-shadow: inset 5px 0 0 #a855f7; padding-left: 22px !important; }

/* Action pills inline with the entity, stacked beneath the name +
   parent chain. They're the strongest visual signal in the row and
   sit right next to the entity they describe. */
.briefing-critical-pill-row {
    display: flex; flex-wrap: wrap; gap: 5px;
    margin-top: 6px;
}
.briefing-critical-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 14px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    white-space: nowrap;
    max-width: 100%;
    line-height: 1.2;
}
.briefing-critical-pill-icon {
    font-size: 11px;
    line-height: 1;
    flex-shrink: 0;
}
.briefing-critical-pill-kill    { background: #fef2f2; color: #b91c1c; box-shadow: 0 0 0 1px #fecaca; }
.briefing-critical-pill-scale   { background: #ecfdf5; color: #047857; box-shadow: 0 0 0 1px #bbf7d0; }
.briefing-critical-pill-fatigue { background: #fdf4ff; color: #86198f; box-shadow: 0 0 0 1px #f5d0fe; }

/* ENTITY column */
.briefing-critical-entity-cell { max-width: 320px; min-width: 210px; }
.briefing-critical-entity-name {
    font-size: 13.5px; font-weight: 700; color: #0e0e1f;
    overflow: hidden; text-overflow: ellipsis;
    line-height: 1.3;
}
.briefing-critical-parents {
    font-size: 11px; color: #646B78;
    margin-top: 3px;
    overflow: hidden; text-overflow: ellipsis;
}
/* Context line — account name + parent chain on one row. Account
   sits in a "visible but not flashy" indigo: enough contrast to
   stand out as the grouping key without competing with the entity
   name above. Parent chain is the existing muted grey. */
.briefing-critical-context {
    font-size: 11px;
    margin-top: 3px;
    line-height: 1.45;
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
}
.briefing-critical-acct-inline {
    /* Same solid-indigo pill as the briefing card top — strongest
       signal in the line so the account jumps out as the grouping
       key when the eye scans down the column. */
    display: inline-block;
    background: #4f46e5;
    color: #fff;
    font-weight: 700;
    padding: 1px 9px;
    border-radius: 10px;
    font-size: 10.5px;
    letter-spacing: 0.01em;
    vertical-align: 1px;
}
.briefing-critical-context-sep {
    color: #646B78;
    margin: 0 5px;
}
.briefing-critical-parents-inline {
    color: #646B78;
}

/* ACCOUNT column — pill style */
.briefing-critical-acct-cell {
    width: 150px;
}
.briefing-critical-acct-pill {
    display: inline-block;
    font-size: 11.5px; font-weight: 600;
    color: #1a1a2e;
    background: #f0f0f7;
    padding: 4px 11px;
    border-radius: 12px;
    white-space: nowrap;
    max-width: 130px;
    overflow: hidden; text-overflow: ellipsis;
}

/* Number columns — Spend / Revenue / CPA / ROAS / Purchases. Each
   gets its own cell, right-aligned, tabular-nums so the digits stack
   visually down the column. Color classes encode breakeven check. */
.briefing-critical-num-cell {
    text-align: right;
    vertical-align: middle;
}
.briefing-critical-num {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a2e;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    white-space: nowrap;
    line-height: 1.2;
}
.briefing-critical-num-strong  { font-size: 14px; color: #0e0e1f; }
.briefing-critical-num-good    { color: #047857; }
.briefing-critical-num-warn    { color: #c2410c; }
.briefing-critical-num-bad     { color: #b91c1c; }
.briefing-critical-num-neutral { color: #6e6e8a; font-weight: 600; }
.briefing-critical-num-aux     { color: #4a4a6a; font-weight: 600; }

/* Sub-line under a number — used to show breakeven targets next to
   ROAS values so the comparison is on-screen instead of remembered. */
.briefing-critical-num-sub {
    font-size: 10px;
    color: #646B78;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

/* ACTIONS column — toggle + Open stacked vertically so every row
   aligns regardless of metric pill widths. The Open link gets its
   own line below the toggle (matches the Reports tab layout). */
.briefing-critical-actions {
    width: 175px;
    text-align: right;
}
.briefing-critical-actions > .critical-toggle {
    vertical-align: middle;
    margin-right: 4px;
}
.briefing-critical-btn {
    display: inline-block;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #d4d4e0;
    border-radius: 7px;
    font-size: 11.5px; font-weight: 600;
    color: #1a1a2e;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.12s;
}
.briefing-critical-btn-pause {
    background: #1a1a2e; color: #fff; border-color: #1a1a2e;
}
.briefing-critical-btn-pause:hover { background: #0e0e1f; transform: translateY(-1px); }
.briefing-critical-btn-pause:disabled { opacity: 0.5; cursor: progress; transform: none; }
.briefing-critical-btn-link {
    display: block;        /* drop to its own line below the toggle / +15% */
    margin-top: 10px;      /* spacing from the toggle / +15% button above */
    font-size: 10.5px;
    color: #6e6e8a;
    padding: 5px 10px;
    white-space: nowrap;
}
.briefing-critical-btn-link:hover {
    border-color: #5B53E8; color: #5B53E8;
}

/* +15% Increase button — only shown on SCALE rows. Solid green so it
   reads as a "positive action" affordance distinct from the toggle. */
.briefing-critical-btn-increase {
    background: #10b981; color: #fff; border-color: #10b981;
    margin-right: 4px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.briefing-critical-btn-increase:hover  { background: #059669; border-color: #059669; }
.briefing-critical-btn-increase:disabled { opacity: 0.6; cursor: progress; }
.briefing-critical-btn-done {
    background: #047857 !important;
    border-color: #047857 !important;
    color: #fff !important;
    cursor: default;
}

/* ============================================================
   On/Off toggle — iOS-style switch. PILL COLOR is the signal
   (green = on, grey = off, faded = unknown). No inline labels —
   they produced "Off On" visual noise that looked broken.
   ============================================================ */
.critical-toggle {
    display: inline-block;
    position: relative;
    width: 38px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 11px;
    background: #cbd5e1;
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.18s;
    flex-shrink: 0;
}
.critical-toggle:hover { filter: brightness(0.95); }
.critical-toggle:focus-visible {
    outline: 2px solid #5B53E8;
    outline-offset: 2px;
}

.critical-toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: left 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.critical-toggle-off              { background: #cbd5e1; }
.critical-toggle-off .critical-toggle-knob { left: 2px; }

.critical-toggle-on               { background: #10b981; }
.critical-toggle-on .critical-toggle-knob  { left: 18px; }

.critical-toggle-unknown          { background: #f0f0f7; opacity: 0.7; }
.critical-toggle-unknown .critical-toggle-knob {
    left: 10px;
    background: #d4d4e0;
}

.critical-toggle-pending {
    pointer-events: none;
    opacity: 0.5;
}
.critical-toggle-pending .critical-toggle-knob {
    animation: critical-toggle-spin 0.8s linear infinite;
}
@keyframes critical-toggle-spin {
    0%   { transform: rotate(0deg)   scale(1); }
    50%  { transform: rotate(180deg) scale(0.8); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ========================================================================
   FULL-WIDTH CARD (briefing-card-full) — used in Overview tab.
   Header row | windows grid (3d/7d/30d/actions) | callout
   ======================================================================== */

.briefing-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.briefing-card-header-left {
    display: flex; align-items: center; gap: 10px;
    flex: 1; min-width: 0;
}
.briefing-card-tags {
    display: flex; flex-wrap: wrap; gap: 6px;
    justify-content: flex-end;
}

/* 4-column grid: 3d / 7d / 30d / actions. Each window column is a
   compact metric block. Actions column has fixed width so the three
   data columns can flex evenly. */
.briefing-windows {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 180px;
    gap: 0;
    border-top: 1px solid #ececf3;
    border-bottom: 1px solid #ececf3;
}
.briefing-window {
    padding: 12px 16px;
    display: flex; flex-direction: column;
    gap: 8px;
    border-right: 1px solid #ececf3;
}
.briefing-windows-actions {
    padding: 12px 16px;
    display: flex; flex-direction: column;
    gap: 6px;
    justify-content: center;
}
.briefing-windows-actions .briefing-action {
    flex: 0 0 auto;
}
.briefing-window-label {
    font-size: 9.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: #6e6e8a;
}
.briefing-window-spend {
    display: flex; flex-direction: column; gap: 2px;
}
.briefing-window-spend-lbl {
    /* "Cost" tag above the big value — same scale as the other
       sub-stat labels (REVENUE / PURCH. / CPA / ROAS) so the eye
       reads them as one consistent family. Matches the chart's
       legend chip wording so users connect the orange line to
       the big number above it. */
    font-size: 9.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: #6e6e8a;
}
.briefing-window-spend-val {
    font-size: 19px; font-weight: 800; color: #0e0e1f;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.briefing-window-sub {
    display: flex; flex-direction: column;
    gap: 4px;
    padding-top: 4px;
    border-top: 1px dashed #ececf3;
}
.briefing-substat {
    display: flex; align-items: baseline; gap: 8px;
    font-size: 11.5px;
    line-height: 1.3;
    flex-wrap: nowrap;
}
.briefing-substat-lbl {
    font-size: 9.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: #646B78;
    flex: 0 0 56px;
}
.briefing-substat-val {
    font-weight: 700; color: #1a1a2e;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
}
.briefing-substat-hint {
    font-size: 10px; color: #646B78;
    margin-left: auto;
    white-space: nowrap;
}

/* ROAS color coding inside sub-stats */
.briefing-val-good { color: #047857; }
.briefing-val-warn { color: #c2410c; }
.briefing-val-bad  { color: #b91c1c; }

/* Card top: status dot + name (legacy compact card path — kept so
   placeholders still render correctly while a fetch is in flight) */
.briefing-card-top {
    display: flex; align-items: center; gap: 10px;
}
.briefing-status-dot {
    width: 12px; height: 12px; border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}
.briefing-card-red    .briefing-status-dot { background: #ef4444; }
.briefing-card-yellow .briefing-status-dot { background: #f59e0b; }
.briefing-card-green  .briefing-status-dot { background: #10b981; }
.briefing-card-name {
    /* Purple pill matching the inline-account treatment in the
       critical-actions table. White text on solid indigo is the
       single most visible label in the card — the account is the
       grouping key, so it gets the strongest signal. */
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    background: #4f46e5;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    letter-spacing: 0.01em;
}
.briefing-spend-trend {
    padding: 2px 7px; border-radius: 10px;
    font-size: 10.5px; font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.briefing-trend-up   { background: #ecfdf5; color: #047857; }
.briefing-trend-down { background: #fef2f2; color: #b91c1c; }

/* Status reasons sub-line */
.briefing-status-reasons {
    font-size: 11.5px;
    color: #4a4a6a;
    line-height: 1.4;
    padding: 0 0 0 22px;     /* aligned with the name after the dot */
    margin-top: -4px;
}

/* Metrics grid (2×2) */
.briefing-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 18px;
    padding: 6px 0;
    border-top: 1px solid #ececf3;
    border-bottom: 1px solid #ececf3;
}
.briefing-metric {}
.briefing-metric-label {
    font-size: 9.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: #6e6e8a;
}
.briefing-metric-value {
    font-size: 16px; font-weight: 800; color: #0e0e1f;
    font-variant-numeric: tabular-nums;
    margin-top: 2px; line-height: 1.1;
}
.briefing-metric-hint {
    font-size: 10.5px; color: #646B78;
    margin-top: 2px;
}

/* Smart-tag mini-strip */
.briefing-strip {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.briefing-tag-mini {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10.5px; font-weight: 700;
}
.briefing-tag-mini-num { font-variant-numeric: tabular-nums; }
.briefing-tag-mini-lbl { letter-spacing: 0.04em; }
.briefing-tag-mini-kill    { background: #fef2f2; color: #b91c1c; }
.briefing-tag-mini-watch   { background: #fff7ed; color: #c2410c; }
.briefing-tag-mini-scale   { background: #ecfdf5; color: #047857; }
.briefing-tag-mini-fatigue { background: #fdf4ff; color: #86198f; }
.briefing-strip-clean {
    font-size: 11px; color: #646B78;
    padding: 2px 0;
}

/* "Look at this first" callout */
.briefing-callout {
    padding: 8px 10px;
    border-radius: 8px;
    line-height: 1.45;
}
.briefing-callout-label {
    font-size: 9.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; margin-bottom: 2px;
}
.briefing-callout-body {
    font-size: 11.5px; color: #1a1a2e;
}
.briefing-callout-body strong { color: #0e0e1f; }
.briefing-callout-body em { font-style: italic; color: #b91c1c; font-weight: 600; }

.briefing-callout-bleed   { background: #fef2f2; }
.briefing-callout-bleed   .briefing-callout-label { color: #b91c1c; }
.briefing-callout-fatigue { background: #fdf4ff; }
.briefing-callout-fatigue .briefing-callout-label { color: #86198f; }
.briefing-callout-winner  { background: #ecfdf5; }
.briefing-callout-winner  .briefing-callout-label { color: #047857; }

/* Footer */
.briefing-card-footer {
    display: flex; gap: 8px; align-items: center;
    margin-top: auto;
}
.briefing-action {
    flex: 1;
    text-align: center;
    padding: 7px 10px;
    background: #fff;
    border: 1px solid #d4d4e0;
    border-radius: 7px;
    font-size: 11.5px; font-weight: 600;
    color: #1a1a2e;
    text-decoration: none;
    transition: all 0.12s;
}
.briefing-action:hover {
    border-color: #5B53E8;
    color: #5B53E8;
}
.briefing-action-primary {
    background: #1a1a2e; color: #fff; border-color: #1a1a2e;
}
.briefing-action-primary:hover {
    background: #0e0e1f; color: #fff;
}

/* ========================================================================
   30-DAY TREND CHART (briefing-card-chart) — Overview tab card
   ======================================================================== */

.briefing-card-chart {
    border-top: 1px solid #ececf3;
    padding: 12px 16px;
    background: linear-gradient(180deg, #fafafd 0%, #fff 100%);
    border-radius: 0 0 10px 10px;
}

/* Container that holds the SVG + legend + tooltip. Positioned so the
   tooltip can sit absolutely over the chart area. */
.metric-chart-host {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Legend strip — 4 chips, one per metric. Doubles as on/off toggle. */
.metric-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
}
.metric-chart-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #fff;
    border: 1px solid #ececf3;
    border-radius: 18px;
    font-size: 11px;
    color: #1a1a2e;
    cursor: pointer;
    transition: all 0.12s;
    user-select: none;
}
.metric-chart-chip:hover {
    border-color: #d4d4e0;
    background: #fafafd;
}
.metric-chart-chip-off {
    opacity: 0.42;
}
.metric-chart-chip-off .metric-chart-dot {
    background: #d4d4e0 !important;
}
.metric-chart-dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}
.metric-chart-chip-lbl {
    font-weight: 600;
    letter-spacing: 0.01em;
}
.metric-chart-chip-val {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #0e0e1f;
    border-left: 1px solid #ececf3;
    padding-left: 7px;
    margin-left: 2px;
}

/* SVG canvas — full width, fixed aspect via viewBox.
   `preserveAspectRatio: none` lets the chart stretch with the card. */
.metric-chart-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}
.metric-chart-gridline {
    stroke: #ececf3;
    stroke-width: 1;
    stroke-dasharray: 2,3;
}
.metric-chart-xlabel {
    font-size: 9.5px;
    font-weight: 600;
    fill: #9494a8;
    letter-spacing: 0.04em;
}

/* Right-side ROAS Y-axis labels — color-matched to the purple ROAS
   line below them so the user reads "the purple line lives on this
   axis" at a glance, while gridlines stay neutral gray. */
.metric-chart-ylabel {
    font-size: 9.5px;
    font-weight: 700;
    fill: #8b5cf6;            /* matches ROAS line color */
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* "ROAS" header above the Y-axis tick column — makes it obvious which
   metric the right-axis labels belong to. Same purple as the ticks for
   visual continuity; uppercase + letter-spaced so it reads as an axis
   title, not as data. */
.metric-chart-yaxis-title {
    font-size: 8.5px;
    font-weight: 800;
    fill: #8b5cf6;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* Breakeven reference line — dashed red horizontal at the user's
   configured breakeven ROAS. Sits above gridlines so it's the most
   visible horizontal marker on the chart. */
.metric-chart-breakeven {
    stroke: #ef4444;
    stroke-width: 1.2;
    stroke-dasharray: 4,3;
    opacity: 0.65;
}
.metric-chart-breakeven-lbl {
    font-size: 9.5px;
    font-weight: 700;
    fill: #b91c1c;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.metric-chart-guide {
    stroke: #6e6e8a;
    stroke-width: 1;
    stroke-dasharray: 3,3;
    pointer-events: none;
}
.metric-chart-hoverdot {
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}
.metric-chart-overlay {
    cursor: crosshair;
}

/* Tooltip — absolutely positioned by JS, snaps to the hovered day. */
.metric-chart-tooltip {
    position: absolute;
    z-index: 5;
    min-width: 168px;
    background: #1a1a2e;
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 6px 22px rgba(0,0,0,0.18);
    font-size: 11px;
    line-height: 1.4;
    pointer-events: none;
    transition: left 0.04s, top 0.04s;
}
.metric-chart-tt-date {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #c4b5fd;
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.metric-chart-tt-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 1.5px 0;
}
.metric-chart-tt-row.metric-chart-tt-off {
    opacity: 0.4;
}
.metric-chart-tt-dot {
    width: 7px; height: 7px; border-radius: 50%;
    flex-shrink: 0;
}
.metric-chart-tt-lbl {
    color: #646B78;
    font-weight: 500;
}
.metric-chart-tt-val {
    margin-left: auto;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
}

.metric-chart-empty {
    text-align: center;
    padding: 20px 14px;
    font-size: 11.5px;
    color: #646B78;
    background: #fafafd;
    border-radius: 8px;
}

/* Responsive: stack the 4-column windows grid on narrow viewports.
   Below 900px the columns get too cramped to read the spend/CPA pairs;
   we collapse to 2 columns (3d|7d row, then 30d|actions row) so the
   sub-stats still have room to breathe. */
@media (max-width: 900px) {
    .briefing-windows {
        grid-template-columns: 1fr 1fr;
    }
    .briefing-window {
        border-right: 1px solid #ececf3;
        border-bottom: 1px solid #ececf3;
    }
    .briefing-window:nth-child(2n) { border-right: none; }
    .briefing-windows-actions {
        border-top: 1px solid #ececf3;
        grid-column: 1 / -1;
        flex-direction: row;
    }
    .briefing-windows-actions .briefing-action { flex: 1; }
}
@media (max-width: 540px) {
    .briefing-windows {
        grid-template-columns: 1fr;
    }
    .briefing-window {
        border-right: none;
        border-bottom: 1px solid #ececf3;
    }
    /* Chip values get noisy at narrow widths — drop the legend trailing
       numbers and let the chart speak for itself. */
    .metric-chart-chip-val {
        display: none;
    }
}

/* Critical-actions pane: "nothing was measured" is not an all-clear (QA 2026-09-02). */
.briefing-critical-errors { margin: 8px 0 0 18px; padding: 0; font-size: 13px; }
.briefing-critical-errors li { margin: 2px 0; overflow-wrap: anywhere; }
.briefing-critical-partial { margin-top: 8px; font-size: 12.5px; color: #9A6B0E; }
