/* Meta Automation hub (#automation/meta) — Pulse · Boost · Rules.
   The shell (layout/rail/tabs) reuses .settings-* from app.css; this file adds
   the hub header, the empty/CTA states, and the Pulse triage board. Palette
   matches the Settings page (neutral grays) plus health-state accents. */

/* Standard centered content column for non-full-width pages = 1320px (DESIGN_SYSTEM.md).
   Pulse / Boost / Rules all share it — only the editor/studio are full-bleed surfaces. The
   Rules builder's CONDITIONS panel gets its room from this 1320 column + its leaves wrap
   gracefully (css/rules.css) rather than overflowing. */
.automation-page { max-width: 1320px; margin: 0 auto; padding: 32px 20px 80px; box-sizing: border-box; }   /* top padding: Pulse/Boost sat flush against the top edge */
/* Rules embedded in the hub: no second page background (it stopped part-way down as a lighter
   panel) and no second set of page padding — the hub column provides both. */
.automation-body .rules-page { background: transparent; padding: 0; min-height: 0; }
/* --wide retained as an alias (same 1320 column) for the Boost tab's explicit call site. */
.automation-page--wide { max-width: 1320px; }
.automation-head { margin-bottom: 4px; }
.automation-sub {
    margin: 6px 0 0;
    font-size: 13.5px;
    color: var(--text-secondary, #6b7280);
    line-height: 1.5;
    max-width: 640px;
}

/* Empty / coming-soon / connect-Meta states (Boost placeholder, no-data Pulse) */
.automation-empty {
    border: 1px dashed #e5e7eb;
    border-radius: 12px;
    padding: 32px 28px;
    text-align: center;
    color: var(--text-secondary, #6b7280);
    background: #fcfcfd;
}
.automation-empty h2 { margin: 0 0 8px; font-size: 16px; color: #1a1a1a; font-weight: 650; }
.automation-empty p { margin: 0 auto 16px; font-size: 13.5px; line-height: 1.55; max-width: 460px; }
.automation-empty .rules-btn { margin-top: 4px; }
.automation-boost-coming { text-align: left; }
.automation-boost-coming h2 { text-align: left; }
.automation-boost-coming p { margin-left: 0; }

/* ── Pulse triage board ─────────────────────────────────────────────────── */
.pulse-intro {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 12.5px;
    color: var(--text-muted, #9ca3af);
}
.pulse-intro-text { color: var(--text-secondary, #6b7280); }
.pulse-status { font-size: 12px; color: var(--text-muted, #9ca3af); }
/* Board filters (N12) — name search + health class, riding the intro bar */
.pulse-intro { align-items: center; }
.pulse-search { margin-left: auto; width: 200px; max-width: 34%; height: 30px; border: 1px solid var(--border, #e2e4ea); border-radius: 8px; padding: 0 10px; font-size: 12.5px; font-family: inherit; outline: none; background: var(--bg-primary, #fff); color: var(--text-primary, #2a3343); }
.pulse-search:focus { border-color: var(--accent, #5b53e8); box-shadow: 0 0 0 3px rgba(91,83,232,.1); }
.pulse-health { height: 30px; border: 1px solid var(--border, #e2e4ea); border-radius: 8px; padding: 0 8px; font-size: 12.5px; font-family: inherit; outline: none; background: var(--bg-primary, #fff); color: var(--text-primary, #2a3343); cursor: pointer; }
.pulse-health:focus { border-color: var(--accent, #5b53e8); box-shadow: 0 0 0 3px rgba(91,83,232,.1); }

.pulse-list { display: flex; flex-direction: column; gap: 8px; }

.pulse-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    border: 1px solid #ececef;
    border-left-width: 3px;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.pulse-row:hover { background: #fcfcfd; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06); }
.pulse-row:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 1px; }
.pulse-row--bad   { border-left-color: #dc2626; }
.pulse-row--warn  { border-left-color: #d97706; }
.pulse-row--scale { border-left-color: #2563eb; }
.pulse-row--good  { border-left-color: #16a34a; }

.pulse-row-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.pulse-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: #16a34a; }
.pulse-dot--bad   { background: #dc2626; }
.pulse-dot--warn  { background: #d97706; }
.pulse-dot--scale { background: #2563eb; }
.pulse-dot--good  { background: #16a34a; }

.pulse-row-name-wrap { min-width: 0; }
.pulse-row-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pulse-row-alert {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}
.pulse-row-alert--bad   { color: #dc2626; }
.pulse-row-alert--warn  { color: #b45309; }
.pulse-row-alert--scale { color: #2563eb; }
.pulse-row-alert--good  { color: #16a34a; }

.pulse-row-metrics { display: flex; align-items: center; gap: 22px; flex: 0 0 auto; }
.pulse-metric { text-align: right; min-width: 56px; }
.pulse-metric-val { font-size: 14px; font-weight: 650; color: #1a1a1a; font-variant-numeric: tabular-nums; }
.pulse-metric-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted, #9ca3af); margin-top: 1px; }
.pulse-metric--attn .pulse-metric-val { color: #dc2626; }
.pulse-metric--scale .pulse-metric-val { color: #2563eb; }

/* Loading skeleton (N15) — placeholder rows while the briefing fan-out streams in */
.pulse-row--skeleton { pointer-events: none; cursor: default; }
.pulse-skel { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--border, #eef0f4) 25%, var(--bg-secondary, #f7f8fa) 50%, var(--border, #eef0f4) 75%); background-size: 200% 100%; animation: pulseShimmer 1.4s ease-in-out infinite; }
.pulse-skel--dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.pulse-skel--name { width: 150px; height: 13px; margin-bottom: 6px; }
.pulse-skel--alert { width: 96px; height: 10px; }
.pulse-skel--metric { width: 56px; height: 28px; }
@keyframes pulseShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .pulse-skel { animation: none; } }

@media (max-width: 560px) {
    .pulse-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .pulse-row-metrics { justify-content: space-between; gap: 12px; }
    .pulse-metric { text-align: left; }
    /* Stacked, the row is full width — let the alert wrap instead of ellipsing what is wrong. */
    .pulse-row-alert { white-space: normal; max-width: none; }
}

/* ── Boost tab ──────────────────────────────────────────────────────────── */
.boost-connrow { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.boost-grid { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
.boost-section-title { font-size: 13px; font-weight: 650; color: #1a1a1a; margin-bottom: 10px; }
.boost-muted { font-size: 13px; color: var(--text-muted, #9ca3af); padding: 8px 0; }
.boost-lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted, #9ca3af); margin: 0 0 4px; }
.boost-select, .boost-input {
    width: 100%; box-sizing: border-box; padding: 8px 10px; font-size: 13.5px;
    border: 1px solid #e2e3e7; border-radius: 8px; background: #fff; color: #1a1a1a;
}
.boost-select:focus, .boost-input:focus { outline: none; border-color: var(--accent, #5B53E8); }
.boost-field-row { display: flex; gap: 10px; margin-top: 12px; }
.boost-field { flex: 1 1 0; min-width: 0; }
.boost-settings > .boost-lbl { margin-top: 4px; }
.boost-settings > .boost-select { margin-bottom: 4px; }

/* Posts list */
.boost-postlist { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.boost-post { display: flex; gap: 12px; padding: 10px; border: 1px solid #ececef; border-radius: 10px; cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.boost-post:hover { background: #fcfcfd; }
.boost-post.is-selected { border-color: var(--accent, #5B53E8); box-shadow: 0 0 0 1px var(--accent, #5B53E8) inset; }
.boost-post:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 1px; }
.boost-post-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; background: #f1f1f3; }
.boost-post-thumb--empty { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.boost-post-body { min-width: 0; flex: 1 1 auto; }
.boost-post-msg { font-size: 13px; color: #1a1a1a; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.boost-post-eng { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--text-secondary, #6b7280); }
.boost-tag-dark { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: #b45309; background: #fffbeb; padding: 1px 6px; border-radius: 5px; }
.boost-posts-sub { font-size: 12px; color: var(--text-secondary, #6b7280); line-height: 1.45; margin: -4px 0 12px; max-width: 380px; }
.boost-post-msgrow { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.boost-tag-suggested { flex: 0 0 auto; font-size: 10.5px; font-weight: 650; letter-spacing: 0.02em; color: #15803d; background: #ecfdf3; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.boost-stat-reach { font-weight: 650; color: #1a1a1a; }
.boost-stat-total { font-weight: 650; color: #1a1a1a; }

/* AI (Claude Haiku) ranking — top-3 pick badge + highlight, limited-offer penalty */
.boost-tag-aipick { flex: 0 0 auto; font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; color: #fff; background: linear-gradient(90deg, #7c3aed, #5B53E8); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.boost-post--pick { border-color: #c7bcf5; box-shadow: 0 0 0 1px #ede9fe inset; }
.boost-post-reason { font-size: 11.5px; color: var(--text-secondary, #6b7280); font-style: italic; line-height: 1.4; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.boost-post-date { color: var(--text-secondary, #6b7280); }
.boost-tag-limited { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: #92400e; background: #fef3c7; padding: 1px 6px; border-radius: 5px; }
.boost-post--dimmed { opacity: 0.6; transition: opacity 0.15s ease; }
.boost-post--dimmed:hover, .boost-post--dimmed.is-selected { opacity: 1; }

/* Already-boosted marker on the picker */
.boost-tag-boosted { font-weight: 650; color: #1d4ed8; background: #eff6ff; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.boost-tag-boosted--paused { color: #92400e; background: #fffbeb; }
.boost-post--boosted { border-color: #bfdbfe; box-shadow: 0 0 0 1px #eff6ff inset; }
.boost-post--boosted.boost-post--pick { box-shadow: 0 0 0 1px #ede9fe inset; }   /* AI pick highlight wins */

/* Smart auto-boost rule — top-of-tab panel */
.boost-autoboost-host { margin: 0 0 16px; }
.boost-autoboost { border: 1px solid var(--border, #e5e7eb); border-radius: 12px; padding: 14px 16px; background: linear-gradient(180deg, #faf5ff, #fff); }
.boost-autoboost.is-on { border-color: #c7bcf5; box-shadow: 0 0 0 1px #ede9fe inset; }
.boost-autoboost-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.boost-autoboost-title { font-size: 14px; font-weight: 700; color: #5b21b6; }
.boost-autoboost-toggle { margin-left: auto; }
.boost-autoboost-sub { font-size: 12px; color: var(--text-secondary, #6b7280); line-height: 1.45; margin-top: 4px; max-width: 560px; }
.boost-autoboost-body { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.boost-autoboost-apopts { display: flex; flex-direction: column; gap: 8px; padding: 8px 10px; border-left: 2px solid #ddd6fe; background: #faf5ff; border-radius: 0 8px 8px 0; }
.boost-autoboost-save { align-self: flex-start; margin-top: 2px; }

/* Auto vs Manual source tag on active boosts */
.boost-tag-source { font-size: 10.5px; font-weight: 650; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.boost-tag-source--auto { color: #5b21b6; background: #f3e8ff; }
.boost-tag-source--manual { color: #374151; background: #f3f4f6; }

/* Page-token expired / missing → red "how to fix it" panel */
.boost-token-warn { border: 1px solid #fecaca; background: #fef2f2; border-radius: 12px; padding: 16px 18px; margin-top: 4px; max-width: 520px; }
.boost-token-warn-title { font-size: 14.5px; font-weight: 650; color: #b91c1c; margin-bottom: 6px; }
.boost-token-warn-body { font-size: 13px; color: #7f1d1d; line-height: 1.55; }
.boost-token-warn-steps { margin: 10px 0 14px; padding-left: 20px; font-size: 12.5px; color: #7f1d1d; line-height: 1.55; }
.boost-token-warn-steps li { margin: 4px 0; }
.boost-token-warn-btn { display: inline-block; padding: 8px 14px; font-size: 13px; font-weight: 600; color: #fff; background: #dc2626; border: none; border-radius: 8px; cursor: pointer; }
.boost-token-warn-btn:hover { background: #b91c1c; }
.boost-token-warn-btn:focus-visible { outline: 2px solid #dc2626; outline-offset: 2px; }

/* Guardrail block */
.boost-guardrail { margin-top: 16px; padding: 12px; border: 1px solid #ececef; border-radius: 10px; background: #fcfcfd; }
.boost-toggle { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: #1a1a1a; cursor: pointer; font-weight: 500; }
.boost-toggle input { width: 16px; height: 16px; accent-color: var(--accent, #5B53E8); }
.boost-guardrail-note { font-size: 12px; color: var(--text-secondary, #6b7280); line-height: 1.5; margin-top: 8px; }
.boost-guardrail-note--dim { color: var(--text-muted, #9ca3af); }
.boost-go { width: 100%; margin-top: 16px; justify-content: center; }

/* Active boosts */
.boost-active { margin-top: 28px; border-top: 1px solid #f0f0f2; padding-top: 18px; }
.boost-activelist { display: flex; flex-direction: column; gap: 8px; }
.boost-activerow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 14px; border: 1px solid #ececef; border-radius: 10px; }
.boost-activerow--paused { opacity: 0.72; }
.boost-activerow-title { font-size: 13.5px; font-weight: 600; color: #1a1a1a; }
.boost-activerow-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 3px; font-size: 12px; color: var(--text-secondary, #6b7280); }
.boost-status { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; padding: 1px 7px; border-radius: 5px; background: #f1f1f3; color: #4b5563; }
.boost-status--active { background: #ecfdf3; color: #15803d; }
.boost-status--paused { background: #f3f4f6; color: #6b7280; }
.boost-guardrail-chip { font-size: 11.5px; color: #4f46e5; background: #eef2ff; padding: 1px 7px; border-radius: 5px; }
.boost-stat { font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
    .boost-grid { grid-template-columns: 1fr; }
}

/* ── Section header (one section at a time; the sidebar submenu drives nav) ── */
.automation-section-head { margin-bottom: 18px; }
.automation-section-title { font-size: 20px; font-weight: 650; color: #1a1a1a; margin: 0; }
.automation-section-head .automation-sub { margin-top: 4px; }

/* ── Sidebar submenu — Shopify-style children under the Meta item ──────────── */
.nav-parent .nav-chevron { margin-left: auto; opacity: 0.45; transition: transform 0.18s ease; flex: 0 0 auto; }
.nav-parent[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); opacity: 0.75; }
.sidebar:not(.is-expanded) .nav-parent .nav-chevron { display: none; }
.nav-parent--current .nav-label { color: var(--text-primary, #1a1a1a); font-weight: 600; }

.nav-submenu {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.2s ease, opacity 0.18s ease;
}
.nav-submenu.is-open { max-height: 280px; opacity: 1; }
/* Keyboard focus into a child reveals the submenu too (honors "open on focus"),
   WITHOUT fighting the parent's click-to-toggle: the parent keeps focus after a
   click, so we trigger on focus WITHIN the submenu (a child) only — never the
   parent itself, which would pin it open and break the close-click. */
.nav-submenu:focus-within { max-height: 280px; opacity: 1; }

/* Expanded submenu: a file-TREE hanging off the parent item (user 2026-07-03: "tree like
   structure … must start on the same position aligned left as the parent menu" — re-requesting
   the 2026-07-01 tree that a later flatten removed). Geometry per the user's earlier explicit
   corrections (#66 + the 07-01 "remove the padding, start at the same level as the main menu"
   pass): child LABELS start at 14px — the same left level as the main-menu items' content
   (12px) — NOT indented under the parent's text (the rejected 45px), and the branch (├ per
   child, └ on the last) lives in the LEFT GUTTER: per-child vertical spine + horizontal tick
   at left:3px. NO child icons.
   Active = BOLD label ONLY — no background pill, no accent bar, branch stays NEUTRAL ("on
   selected just bold text … no left element"). The child ::before is REPURPOSED as the spine,
   which also replaces the GLOBAL .sidebar .nav-item.active::before 3px accent bar from
   app.css; the .active variants re-assert the spine at higher specificity so the bar can
   never leak back. */
.sidebar.is-expanded .nav-submenu {
    position: relative;
    /* .nav-group is align-items:center and only .nav-item gets width:100% in the expanded
       sidebar — without this the submenu SHRINK-WRAPS and floats centered ~38px right of
       the parent (THE misalignment behind "must start aligned left as the parent menu").
       Stretch it to the parent item's full width so children share its left edge. */
    width: 100%;
    margin: 1px 0 5px;
    padding-left: 0;
}
.sidebar.is-expanded .nav-child {
    position: relative;
    min-height: 32px;
    padding: 7px 12px 7px 34px;   /* label clears the tick (spine 21px + tick 7px + gap) */
}
/* Spine (the │ of ├): 1px HAIRLINE (user 2026-07-04: "the line is too width big, make it
   slimmer") dropped from the PARENT ICON's center — item padding 12px + 20px icon → center
   ≈ x21 ("align the line in the same spot as the icon for Meta"). Full row height so
   consecutive rows read as one trunk. :hover is re-asserted IDENTICAL so neither the global
   .nav-item:hover pill nor any accent bar can restyle the branch on mouse-over ("remove the
   line on mouse hover"). */
.sidebar.is-expanded .nav-child::before,
.sidebar.is-expanded .nav-child:hover::before,
.sidebar.is-expanded .nav-child.active::before {
    content: "";
    position: absolute;
    left: 21px;
    top: 0;
    bottom: 0;
    width: 1px;
    height: auto;
    transform: none;
    border-radius: 0;
    background: var(--border, #e0e0e6);
}
/* Last child = └ : the spine stops at its tick (half height). */
.sidebar.is-expanded .nav-child:last-child::before,
.sidebar.is-expanded .nav-child:hover:last-child::before,
.sidebar.is-expanded .nav-child.active:last-child::before {
    bottom: auto;
    height: 50%;
    border-radius: 0;
}
/* Tick (the ─ of ├): spine → label, 1px hairline. The :hover re-assertion must ALSO
   neutralize every property the global tooltip rule ([data-tooltip]:hover::after,
   app.css) sets on this SAME pseudo-element — its margin-left:8px + padding:4px 8px
   + font-size otherwise leak through the per-property cascade and turn the tick into
   a padded grey bar drawn OVER the label on mouse-over ("that line over the menu"). */
.sidebar.is-expanded .nav-child::after,
.sidebar.is-expanded .nav-child:hover::after,
.sidebar.is-expanded .nav-child.active::after {
    content: "";
    position: absolute;
    left: 21px;
    top: 50%;
    width: 7px;
    height: 1px;
    transform: translateY(-50%);
    border-radius: 0;
    background: var(--border, #e0e0e6);
    margin: 0;
    padding: 0;
    font-size: 0;
    line-height: 0;
    color: transparent;
    box-shadow: none;
    z-index: auto;
}
/* Hover = subtle text emphasis only — no background pill over the gutter/branch. */
.sidebar.is-expanded .nav-child:hover { background: transparent; box-shadow: none; }
.sidebar.is-expanded .nav-child:hover .nav-label { color: var(--text-primary, #1a1a1a); }
.sidebar.is-expanded .nav-child .nav-label { font-size: 12.5px; }
.sidebar.is-expanded .nav-child > svg[width] { display: none; }   /* no icon */
.sidebar.is-expanded .nav-child.active,
.sidebar.is-expanded .nav-child.active:hover {
    background: transparent;      /* kill the global .nav-item.active accent-subtle pill (the "blob") */
    box-shadow: none;
    color: var(--text-primary, #1a1a1a);
}
.sidebar.is-expanded .nav-child.active .nav-label { font-weight: 700; color: var(--text-primary, #1a1a1a); }

/* Collapsed rail: children are compact icon rows tucked under the parent. */
.sidebar:not(.is-expanded) .nav-submenu.is-open { margin: 2px 0; }
.sidebar:not(.is-expanded) .nav-child { width: 40px !important; height: 38px !important; margin: 0 auto; }
.sidebar:not(.is-expanded) .nav-child svg[width] { width: 19px !important; height: 19px !important; }

/* Pulse → Notifications drill-down (2026-07) */
.pulse-metric--link { cursor: pointer; border-radius: 8px; }
.pulse-metric--link:hover .pulse-metric-val { text-decoration: underline; }

/* Pulse: per-account read failures stay on the pane (QA 2026-09-02). */
.pulse-acct-errors { text-align: left; }
.pulse-acct-errors ul { margin: 6px 0 0 18px; padding: 0; }
.pulse-acct-errors li { margin: 2px 0; overflow-wrap: anywhere; }
.pulse-acct-errors__name { font-weight: 600; }
.pulse-acct-errors p { margin: 8px 0 0; color: #5B6473; }

/* Phones: the intro text was squeezed to one word per line and the sort select ran off the screen. The text takes its
   own row; search + selects share the next one(s) (audit 2026-11-08). */
@media (max-width: 600px) {
    .pulse-intro { flex-wrap: wrap; row-gap: 8px; }
    .pulse-intro > :first-child { flex: 1 1 100%; }
    .pulse-search { margin-left: 0; flex: 1 1 100%; width: auto; max-width: none; }
    .pulse-health { flex: 1 1 0; min-width: 0; }
}
