/* ─────────────────────────────────────────────────────────────────────
   Rules engine — visual rule builder + list page.

   Design system (state-of-the-art, n8n / Linear / Zapier vibe):
     - Soft shadows instead of hard borders on cards
     - Generous whitespace on a 4/8/12/16/24/32 scale
     - One color rail per AND/OR group (no per-row colored borders)
     - Color used for STATE (focus, error, status), not decoration
     - 150ms ease transitions across the board
     - Inputs lift on focus, never just border-color change

   Color rail convention (matches the brief screenshot):
     - AND group  → indigo rail
     - OR  group  → green  rail
   ───────────────────────────────────────────────────────────────────── */

:root {
    --rules-and:        #4f46e5;
    --rules-or:         #10b981;
    --rules-and-tint:   #eef2ff;
    --rules-or-tint:    #ecfdf5;
    --rules-and-soft:   rgba(79, 70, 229, 0.08);
    --rules-or-soft:    rgba(16, 185, 129, 0.08);

    --rules-text:       #0f172a;
    --rules-text-muted: #64748b;
    --rules-text-dim:   #94a3b8;
    --rules-border:     rgba(15, 23, 42, 0.08);
    --rules-border-soft:rgba(15, 23, 42, 0.05);
    --rules-card-bg:    #ffffff;
    --rules-page-bg:    #f5f7fa;
    --rules-input-bg:   #ffffff;

    --rules-danger:     #dc2626;
    --rules-danger-tint:#fef2f2;
    --rules-alert:      #f59e0b;
    --rules-alert-tint: #fef3c7;
    --rules-live:       #10b981;
    --rules-live-tint:  #d1fae5;

    --rules-shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --rules-shadow-md:  0 4px 8px rgba(15, 23, 42, 0.04), 0 2px 4px rgba(15, 23, 42, 0.06);
    --rules-shadow-lg:  0 12px 24px rgba(15, 23, 42, 0.06), 0 4px 8px rgba(15, 23, 42, 0.04);
    --rules-focus-ring: 0 0 0 3px var(--rules-and-soft);
}

/* ─── Page chrome ──────────────────────────────────────────────────── */
.rules-page {
    background: var(--rules-page-bg);
    min-height: 100%;
    padding: 32px 24px 64px;
    color: var(--rules-text);
    font-feature-settings: 'cv11', 'ss01';
}
.rules-loading {
    padding: 80px;
    text-align: center;
    color: var(--rules-text-muted);
    font-size: 13px;
}
.rules-section-h {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--rules-text-muted);
    margin: 0 0 14px;
}
.rules-section-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--rules-text-muted);
    margin: 20px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.rules-link {
    color: var(--rules-and);
    text-decoration: none;
    font-weight: 500;
}
.rules-link:hover { text-decoration: underline; }

/* ─── Buttons ──────────────────────────────────────────────────────── */
.rules-btn {
    appearance: none;
    border: 1px solid var(--rules-border);
    background: #fff;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--rules-text);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
    line-height: 1;
}
.rules-btn:hover  { background: #f8fafc; border-color: rgba(15, 23, 42, 0.14); }
.rules-btn:active { transform: scale(0.98); }
.rules-btn:disabled,
.rules-btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.rules-btn--primary {
    background: var(--rules-and);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}
.rules-btn--primary:hover { background: #4338ca; box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3); }
.rules-btn--alert {
    background: var(--rules-alert);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(245, 158, 11, 0.2);
}
.rules-btn--alert:hover { background: #d97706; }
.rules-btn--danger {
    color: var(--rules-danger);
    border-color: rgba(220, 38, 38, 0.2);
    background: #fff;
}
.rules-btn--danger:hover { background: var(--rules-danger-tint); border-color: rgba(220, 38, 38, 0.3); }
.rules-btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--rules-text-muted);
}
.rules-btn--ghost:hover { background: rgba(15, 23, 42, 0.04); color: var(--rules-text); }

/* ─── List page ────────────────────────────────────────────────────── */
.rules-list { max-width: 1200px; margin: 0 auto; }
.rules-list__head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.rules-list__title {
    font-size: 28px; font-weight: 700; margin: 0;
    letter-spacing: -0.02em;
}
.rules-list__sub {
    font-size: 14px;
    color: var(--rules-text-muted);
    margin-bottom: 28px;
    line-height: 1.6;
    max-width: 680px;
}
.rules-list__sub code {
    background: rgba(15, 23, 42, 0.05);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'SF Mono', Menlo, Monaco, monospace;
}
.rules-list__filters {
    display: flex; gap: 12px; margin-bottom: 20px;
}
.rules-list__search,
.rules-list__filter {
    border: 1px solid var(--rules-border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    outline: none;
    background: #fff;
    color: var(--rules-text);
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rules-list__search { flex: 1; max-width: 360px; }
.rules-list__search::placeholder { color: var(--rules-text-dim); }
.rules-list__search:focus,
.rules-list__filter:focus {
    border-color: var(--rules-and);
    box-shadow: var(--rules-focus-ring);
}

.rules-list__table {
    background: var(--rules-card-bg);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--rules-shadow-sm);
}
/* Row grid:
   Rule (name + meta) │ Applied to │ Conditions │ Status │ Activity │ Edit
   Two-line cells (primary + sub) so each column has its own visual rhythm. */
.rules-list__row {
    display: grid;
    grid-template-columns: minmax(min(220px, 100%), 1.7fr) minmax(160px, 1fr) 140px 80px 130px 70px;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--rules-border-soft);
    cursor: pointer;
    transition: background 0.12s ease;
    gap: 16px;
}
.rules-list__row:last-child { border-bottom: none; }
.rules-list__row:hover { background: rgba(79, 70, 229, 0.03); }
.rules-list__row--head {
    cursor: default;
    background: #fafbfc;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--rules-text-muted);
    letter-spacing: 0.06em;
}
.rules-list__row--head:hover { background: #fafbfc; }
.rules-list__cell { font-size: 13px; min-width: 0; }

/* Two-line cell pattern: primary (semibold) + sub (smaller, muted) */
.rules-list__name        { font-weight: 600; color: var(--rules-text); }
.rules-list__meta        { font-size: 12px; color: var(--rules-text-muted); margin-top: 2px; }
.rules-list__applied     {
    display: flex; align-items: center; gap: 8px;
    font-weight: 500; color: var(--rules-text);
    min-width: 0;
}
.rules-list__applied-icon { flex-shrink: 0; }
.rules-list__applied-text {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}

.rules-list__applied-sub { font-size: 11px; color: var(--rules-text-muted);
                           font-family: 'SF Mono', Menlo, Monaco, monospace;
                           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.rules-list__cond-count  { font-weight: 500; color: var(--rules-text); }
.rules-list__cond-sub    { font-size: 11px; color: var(--rules-text-muted); margin-top: 2px; }
.rules-list__act-count   { font-weight: 500; color: var(--rules-text); }
.rules-list__act-sub     { font-size: 11px; color: var(--rules-text-muted); margin-top: 2px; }
.rules-list__act-empty   { color: var(--rules-text-dim); }
.rules-list__edit {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--rules-and);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.12s ease;
}
.rules-list__edit:hover { background: var(--rules-and-soft); }

.rules-list__empty {
    padding: 80px 20px;
    text-align: center;
    color: var(--rules-text-muted);
}
.rules-list__empty h3 {
    margin: 16px 0 8px;
    color: var(--rules-text);
    font-size: 18px;
    font-weight: 600;
}
.rules-list__empty p  { margin: 0 0 24px; }
.rules-list__empty-icon { font-size: 44px; opacity: 0.4; }
.rules-list__empty--err { color: var(--rules-danger); }

/* Status pill */
.rules-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.4;
}
.rules-pill::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.rules-pill--off   { background: #f1f5f9; color: #64748b; }
.rules-pill--alert { background: var(--rules-alert-tint); color: #92400e; }
.rules-pill--live  { background: var(--rules-live-tint); color: #047857; }

/* ─── Builder ──────────────────────────────────────────────────────── */
/* Full-width inside the main-content area, with generous breathing room
   on ultra-wide screens. The previous 1400px cap left the builder
   visually offset on 1920+ displays. Now it fills its parent and centers
   naturally because each card inside is grid-fr-sized. */
.rules-builder {
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    display: flex; flex-direction: column; gap: 20px;
}

/* Summary bar */
.rules-summary {
    background: var(--rules-card-bg);
    border-radius: 14px;
    padding: 16px 22px;
    display: grid;
    grid-template-columns: minmax(min(240px, 100%), 360px) auto 1fr;
    align-items: center;
    gap: 18px;
    position: sticky;
    top: 16px;
    z-index: 10;
    box-shadow: var(--rules-shadow-md);
}
.rules-summary__name-wrap { display: flex; }
.rules-summary__name {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--rules-text);
    outline: none;
    background: transparent;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    letter-spacing: -0.01em;
}
.rules-summary__name::placeholder { color: var(--rules-text-dim); font-weight: 500; }
.rules-summary__name:focus,
.rules-summary__name:hover {
    background: #fafbfc;
}
.rules-summary__name:focus {
    border-color: var(--rules-and);
    box-shadow: var(--rules-focus-ring);
    background: #fff;
}
/* Status segmented control — Off / Alert / Live, clickable.
   Replaces the previous read-only pill so users can flip status from the
   summary bar instead of being forced to use the three save buttons.   */
.rules-summary__status-wrap {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}
.rules-summary__status-btn {
    appearance: none;
    border: none;
    background: transparent;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--rules-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.rules-summary__status-btn::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}
.rules-summary__status-btn:hover { color: var(--rules-text); }
.rules-summary__status-btn.is-active::before { opacity: 1; }
.rules-summary__status-btn--off.is-active {
    background: #ffffff;
    color: #64748b;
    box-shadow: var(--rules-shadow-sm);
}
.rules-summary__status-btn--alert.is-active {
    background: var(--rules-alert-tint);
    color: #92400e;
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.2);
}
.rules-summary__status-btn--live.is-active {
    background: var(--rules-live-tint);
    color: #047857;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.2);
}
.rules-summary__sentence {
    color: var(--rules-text-muted);
    font-size: 13px;
    line-height: 1.6;
}

/* 2-column grid: [scope] | [conditions on top, actions + schedule below].
   Actions moved out of a 3rd column so a wide leaf (metric-to-metric) gets the
   full content width and can't overlap the action panel. */
.rules-builder__grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    align-items: start;
}
.rules-builder__col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.rules-builder__col > * {
    background: var(--rules-card-bg);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--rules-shadow-sm);
}
.rules-builder__col--conditions {
    background: var(--rules-card-bg);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--rules-shadow-sm);
    /* A very wide leaf scrolls within the card instead of overflowing it. */
    min-width: 0;
    overflow-x: auto;
}
/* Content column: conditions stacked on top of the actions+schedule row. */
.rules-builder__main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;          /* let the column shrink so overflow-x can engage */
}
/* Actions + Schedule, side by side, beneath the conditions. */
.rules-builder__below {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .rules-builder__below { grid-template-columns: 1fr; }
}

/* ─── Scope panel ──────────────────────────────────────────────────── */
.rules-scope {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.rules-field {
    display: block;
}
.rules-field__label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--rules-text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.rules-field__select,
.rules-field__input {
    width: 100%;
    border: 1px solid var(--rules-border);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13px;
    outline: none;
    background: var(--rules-input-bg);
    color: var(--rules-text);
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rules-field__select:hover,
.rules-field__input:hover { border-color: rgba(15, 23, 42, 0.14); }
.rules-field__select:focus,
.rules-field__input:focus {
    border-color: var(--rules-and);
    box-shadow: var(--rules-focus-ring);
}
.rules-field__input::placeholder { color: var(--rules-text-dim); }
.rules-field__hint {
    font-size: 12px;
    color: var(--rules-text-muted);
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.03);
    border-radius: 10px;
    line-height: 1.5;
}
.rules-field__hint--warn {
    background: var(--rules-alert-tint);
    color: #78350f;
}

/* A field whose control is a block list (the account picker) rather than an
   inline input — stacks the label above the control. */
.rules-field--block { display: flex; flex-direction: column; gap: 6px; }

/* ── Unified ad-account list ──────────────────────────────────────────
   Every linked ad account across all platforms. Click a row to select it;
   selected rows tint accent, errored ones tint red with a "Sync error"
   badge. The platform is derived from the selection — no separate field. */
.rules-acct { display: flex; flex-direction: column; gap: 6px; }
.rules-acct__list { display: flex; flex-direction: column; gap: 6px; }
.rules-acct__row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    appearance: none;
    cursor: pointer;
    padding: 9px 11px;
    background: #fff;
    border: 1px solid var(--rules-border);
    border-radius: 11px;
    font-family: inherit;
    transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.rules-acct__row:hover:not(.is-disabled):not(.is-selected) { border-color: rgba(15, 23, 42, 0.16); }
/* Selected = green treatment + a green check badge top-right (no checkbox). */
.rules-acct__row.is-selected {
    background: #f3fbf6;
    border-color: #b9e6cb;
    box-shadow: inset 0 0 0 1px rgba(34, 160, 107, 0.30);
    padding-right: 32px;
}
.rules-acct__row.is-error.is-selected {
    background: #fef2f2;
    border-color: #fca5a5;
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.25);
}
.rules-acct__row.is-disabled { opacity: 0.5; cursor: not-allowed; }
.rules-acct__sel {
    position: absolute; top: 8px; right: 8px;
    flex: 0 0 auto;
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: #15803d;
    color: #fff;
}
.rules-acct__sel svg { width: 11px; height: 11px; }
/* Brand badge for platforms without a logo asset (Meta uses .fb-icon). */
.rules-acct__brand {
    flex: 0 0 auto;
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
    font-size: 9.5px; font-weight: 800; letter-spacing: -0.02em;
    background: #eef0f4; color: #5b6473;
}
.rules-acct__brand--google { background: #fde8e6; color: #c5372c; }
.rules-acct__brand--tiktok { background: #e8f7f8; color: #0b8f9c; }
.rules-acct__brand--pinterest { background: #fde7ea; color: #c8123c; }
.rules-acct__brand--bing { background: #e6f2ee; color: #0b7a5b; }
.rules-acct__brand--snapchat { background: #fff7d6; color: #9a8500; }
.rules-acct .fb-icon { flex: 0 0 auto; }
.rules-acct__txt { flex: 1; min-width: 0; }
.rules-acct__name {
    font-size: 13px; font-weight: 600; color: var(--rules-text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rules-acct__sub {
    font-size: 11px; color: var(--rules-text-muted);
    font-family: 'SF Mono', Menlo, Monaco, monospace;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-top: 1px;
}
.rules-acct__status {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 600; margin-top: 3px;
}
.rules-acct__status.is-ok { color: #15803d; }
.rules-acct__status.is-error { color: var(--rules-danger); }
.rules-acct__dot {
    width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto;
    background: currentColor;
}
.rules-acct__remove {
    appearance: none; border: none; background: transparent;
    color: var(--rules-text-dim); cursor: pointer;
    font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 6px;
    flex-shrink: 0; transition: all 0.12s ease;
}
.rules-acct__remove:hover { background: var(--rules-danger-tint); color: var(--rules-danger); }
.rules-acct__note {
    font-size: 11px; color: var(--rules-text-dim);
    padding: 0 2px; line-height: 1.4; min-height: 14px;
}
.rules-acct__note.is-warn { color: #b45309; }

.rules-checkbox-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 10px;
    align-items: center;
}
.rules-checkbox-row input[type="checkbox"] {
    accent-color: var(--rules-and);
    width: 14px; height: 14px;
    cursor: pointer;
}
.rules-checkbox-row__lbl {
    font-size: 13px;
    cursor: pointer;
    color: var(--rules-text);
}
.rules-scope__count {
    margin-top: 16px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--rules-and-soft), rgba(79, 70, 229, 0.04));
    border-radius: 10px;
    font-size: 12px;
    color: var(--rules-text);
}
.rules-scope__count-label { color: var(--rules-text-muted); }
.rules-scope__count-num   { font-weight: 700; color: var(--rules-and); margin-left: 4px; }

/* ─── Conditions tree ──────────────────────────────────────────────── */
/* Bracket-style nested groups (blue = AND, amber = OR) with a centered
   operator pill on the spine, 6-dot drag handles, and add-buttons that sit
   BELOW the bracket. Colors are scoped here so they don't disturb the global
   --rules-or (green) used by the simulator / NL summary. */
.rules-conditions {
    font-size: 13px;
    --cnd-and-line:    #93b1e8;
    --cnd-and-pill-bg: #e9effb;
    --cnd-and-pill-tx: #4f6699;
    --cnd-or-line:     #e8ac55;
    --cnd-or-pill-bg:  #fbebd1;
    --cnd-or-pill-tx:  #9a6b28;
}

.rules-group { margin: 0; }
.rules-group--root { margin-top: 0; }

/* Body = the bracket rail + the child rows it spans. The add-buttons are a
   sibling AFTER the body, so the bracket stops above them. */
.rules-group__body {
    display: grid;
    grid-template-columns: 56px 1fr;
    align-items: stretch;
}
.rules-group__rail { position: relative; }
/* The `[` bracket: left spine + short top/bottom feet, drawn with borders. */
.rules-group__rail::before {
    content: '';
    position: absolute;
    left: 27px; right: 4px; top: 3px; bottom: 3px;
    border: 1.5px solid var(--cnd-and-line);
    border-right: none;
    border-radius: 11px 0 0 11px;
    pointer-events: none;
}
.rules-group--or > .rules-group__body > .rules-group__rail::before {
    border-color: var(--cnd-or-line);
}

/* Operator pill — centered on the spine, horizontal text, tinted background
   that covers the line behind it. Click toggles AND ↔ OR. */
.rules-group__op {
    position: absolute;
    top: 50%; left: 27px;
    transform: translate(-50%, -50%);
    appearance: none;
    border: none;
    cursor: pointer;
    background: var(--cnd-and-pill-bg);
    color: var(--cnd-and-pill-tx);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 4px 9px;
    border-radius: 8px;
    writing-mode: horizontal-tb;
    font-family: inherit;
    z-index: 1;
    transition: filter 0.12s ease, box-shadow 0.12s ease;
}
.rules-group--or > .rules-group__body > .rules-group__rail > .rules-group__op {
    background: var(--cnd-or-pill-bg);
    color: var(--cnd-or-pill-tx);
}
.rules-group__op:hover { filter: brightness(0.96); box-shadow: var(--rules-focus-ring); }

/* AND | OR SWITCH (2026-11-06) — a switchable group's join: both options stacked on the spine, the active
   one filled, the other a quiet button, in a white capsule with a soft shadow so it reads as a control
   (the single pill did not say it could be clicked). Static (non-switchable) groups keep .rules-group__op. */
.rules-group__switch {
    position: absolute;
    top: 50%; left: 27px;
    transform: translate(-50%, -50%);
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px;
    background: #fff;
    border: 1px solid #e3e6ee;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 6px rgba(16, 24, 40, .06);
}
.rules-group__sw {
    appearance: none;
    border: none;
    background: transparent;
    color: #646B78;
    font-family: inherit;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .05em;
    line-height: 1;
    min-width: 40px;
    padding: 7px 0;
    border-radius: 7px;
    cursor: pointer;
    transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.rules-group__sw:hover:not(.is-on) { background: #f1f2f6; color: #3b414c; }
.rules-group__sw:focus-visible { outline: none; box-shadow: var(--rules-focus-ring, 0 0 0 3px rgba(91, 83, 232, .25)); }
.rules-group__sw.is-on { cursor: default; color: #fff; }
.rules-group__sw--and.is-on { background: var(--accent, #5B53E8); box-shadow: 0 1px 2px rgba(91, 83, 232, .35); }
.rules-group__sw--or.is-on  { background: #d97706; box-shadow: 0 1px 2px rgba(217, 119, 6, .35); }

/* Delete-group × — sits on the spine top, revealed on rail hover. */
.rules-group__del {
    position: absolute;
    top: -3px; left: 27px;
    transform: translateX(-50%);
    appearance: none;
    border: none;
    background: #fff;
    color: var(--rules-text-dim);
    width: 18px; height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 1px var(--rules-border);
    opacity: 0;
    z-index: 2;
    transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.rules-group__rail:hover .rules-group__del { opacity: 1; }
.rules-group__del:hover { background: var(--rules-danger-tint); color: var(--rules-danger); }

.rules-group__children {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0;
    min-width: 0;
}

/* --norail: a group with <2 conditions has no AND/OR join to show, so the
   46px bracket gutter is dropped. The single condition row (and the add
   button) then sit flush-left instead of under an orphaned "[ OR" heading. */
.rules-group--norail > .rules-group__body { grid-template-columns: 1fr; }
.rules-group--norail > .rules-group__add { padding-left: 0; }

/* Add-buttons row — below the bracket, indented under the children column. */
.rules-group__add {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-left: 56px;
    margin-top: 8px;
}
.rules-group__add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    appearance: none;
    border: none;
    background: none;
    color: var(--rules-and);
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    padding: 6px 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.12s ease, background 0.12s ease;
}
.rules-group__add-btn:hover { color: var(--rules-and-hover, #4338ca); background: var(--rules-and-soft); }
.rules-group__add-btn:disabled { color: var(--rules-text-dim); cursor: not-allowed; background: none; }
.rules-group__add-ico { flex-shrink: 0; }

/* Root add-bar → filled neutral buttons (the bottom "Add filter" / "Add group"). */
.rules-group__add--root { margin-top: 14px; gap: 10px; }
.rules-group__add--root .rules-group__add-btn {
    background: #eff1f6;
    color: var(--rules-and);
    font-weight: 700;
    padding: 11px 18px;
    border-radius: 10px;
}
.rules-group__add--root .rules-group__add-btn:hover { background: #e5e8f1; color: var(--rules-and); }

/* Leaf row — inputs sit inline on ONE line while they fit (the wide CONDITIONS
   column means they almost always do). When a leaf is genuinely too wide for the
   column (e.g. a metric-to-metric compare with its own window + multiplier), it
   WRAPS to a second line inside the same card instead of overflowing the panel
   sideways. `gap` supplies the 8px row gap between wrapped lines; the group's
   bracket rail is `align-items: stretch` so it grows with the taller leaf. */
.rules-leaf {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: #fff;
    border: 1px solid var(--rules-border);
    border-radius: 12px;
    flex-wrap: wrap;
    min-width: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rules-leaf:hover { border-color: rgba(15, 23, 42, 0.14); box-shadow: var(--rules-shadow-sm); }
.rules-leaf__grip {
    color: #646B78;
    cursor: grab;
    display: inline-flex;
    align-items: center;
    user-select: none;
    flex-shrink: 0;
}
.rules-leaf__grip svg { display: block; }
.rules-leaf__grip:active { cursor: grabbing; }
.rules-leaf select,
.rules-leaf input {
    border: 1px solid var(--rules-border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    background: #fff;
    color: var(--rules-text);
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rules-leaf select:hover,
.rules-leaf input:hover { border-color: rgba(15, 23, 42, 0.14); }
.rules-leaf select:focus,
.rules-leaf input:focus {
    border-color: var(--rules-and);
    box-shadow: var(--rules-focus-ring);
}
.rules-leaf__metric { font-weight: 600; min-width: 130px; flex-shrink: 1; }
.rules-leaf__window { min-width: 130px; flex-shrink: 1; }
.rules-leaf__op { font-weight: 700; min-width: 52px; text-align: center; }
.rules-leaf__value {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 1;
    min-width: 0;
}
.rules-leaf__value-kind { font-style: italic; color: var(--rules-text-muted); font-size: 12px; }
.rules-leaf__value-input { width: 90px; flex-shrink: 0; }

/* Property leaves — string text input gets more room, enum dropdowns size to content,
   multi-select shows inline checkbox-label pairs that wrap. */
.rules-leaf__value-input--string { width: 200px; }
.rules-leaf__value-input--enum   { width: auto; min-width: 150px; }
.rules-leaf__value-input--bool   { width: auto; min-width: 90px; }
.rules-leaf--property .rules-leaf__metric { min-width: 170px; }
.rules-leaf--property .rules-leaf__op     { min-width: auto; padding: 4px 8px; }
.rules-leaf__value-multi {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    align-items: center;
    max-width: 320px;
    padding: 4px 0;
    font-size: 12px;
}
.rules-leaf__value-multi label {
    margin-right: 4px;
    color: var(--rules-text);
    cursor: pointer;
}
.rules-leaf__value-mult,
.rules-leaf__value-pct { width: 60px; flex-shrink: 0; }
.rules-leaf__value-mult-wrap {
    color: var(--rules-text-muted);
    padding: 0 2px;
    font-size: 13px;
    flex-shrink: 0;
}
.rules-leaf__unit {
    color: var(--rules-text-muted);
    font-size: 12px;
    margin-left: -2px;
    flex-shrink: 0;
}
.rules-leaf__del {
    appearance: none;
    margin-left: auto;
    border: none;
    background: transparent;
    color: #646B78;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
    transition: all 0.12s ease;
}
.rules-leaf__del:hover {
    background: var(--rules-danger-tint);
    color: var(--rules-danger);
}
/* The × never wraps (user, 2026-11-06: "the x is in the next line, increasing the height"). It is pinned to
   the row's right edge, vertically centred, and the row reserves that space — so a narrow popup wraps only
   the controls themselves, never the × onto a line of its own.
   Doubled class = beats the per-place `.x .rules-leaf { padding: … }` overrides (editor, boost, wizard). */
.rules-leaf.rules-leaf:has(> .rules-leaf__del) { position: relative; padding-right: 42px; }
.rules-leaf > .rules-leaf__del { position: absolute; top: 50%; right: 7px; transform: translateY(-50%); margin: 0; }

/* Pause one condition (js/shared/conditions.js → condPauseToggle, 2026-11-09): a small switch at the start of the
   row. Paused = the row is dimmed, its controls struck through, a "Paused" tag — it is kept, every matcher skips it. */
.rules-leaf__pause {
    appearance: none; flex-shrink: 0; position: relative; width: 28px; height: 16px; padding: 0; margin: 0 2px 0 0;
    border: 0; border-radius: 999px; background: var(--accent, #5B53E8); cursor: pointer; transition: background .15s ease;
}
.rules-leaf__pause-knob {
    position: absolute; top: 2px; left: 14px; width: 12px; height: 12px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .15s ease;
}
.rules-leaf__pause.is-off { background: #cbd5e1; }
.rules-leaf__pause.is-off .rules-leaf__pause-knob { left: 2px; }
.rules-leaf__pause:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 2px; }
.rules-leaf.is-paused > :not(.rules-leaf__pause):not(.rules-leaf__del):not(.rules-leaf__paused-tag) { opacity: .45; }
.rules-leaf.is-paused select, .rules-leaf.is-paused input { text-decoration: line-through; }
.rules-leaf__paused-tag {
    flex-shrink: 0; font-size: 11px; font-weight: 600; color: #475467; background: #f2f4f7; border-radius: 6px; padding: 2px 7px;
}

/* ─── Actions panel ────────────────────────────────────────────────── */
.rules-actions { display: flex; flex-direction: column; gap: 14px; }
.rules-actions__stack { display: flex; flex-direction: column; gap: 12px; }
.rules-actions__add {
    appearance: none;
    border: 1px dashed rgba(15, 23, 42, 0.15);
    background: transparent;
    border-radius: 10px;
    padding: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--rules-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.rules-actions__add:hover {
    border-color: var(--rules-and);
    color: var(--rules-and);
    background: var(--rules-and-soft);
    border-style: solid;
}

.rules-action-card {
    border-left: 3px solid var(--rules-and);
    border-radius: 10px;
    padding: 14px;
    background: #fafbfc;
    transition: background 0.15s ease;
}
.rules-action-card:hover { background: #f5f7fa; }
.rules-action-card--safe     { border-left-color: var(--rules-and); }
.rules-action-card--notify   { border-left-color: var(--rules-alert); }
.rules-action-card--budget   { border-left-color: var(--rules-or);    }
.rules-action-card--creative { border-left-color: #8b5cf6;            }

.rules-action-card__head {
    display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.rules-action-card__type {
    flex: 1;
    border: 1px solid var(--rules-border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 600;
    background: #fff;
    color: var(--rules-text);
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rules-action-card__type:focus {
    border-color: var(--rules-and);
    box-shadow: var(--rules-focus-ring);
}
.rules-action-card__del {
    appearance: none;
    border: none;
    background: transparent;
    color: #646B78;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.12s ease;
}
.rules-action-card__del:hover { background: var(--rules-danger-tint); color: var(--rules-danger); }
.rules-action-card__params { display: flex; flex-direction: column; gap: 10px; }
.rules-action-card__field { display: flex; flex-direction: column; gap: 5px; }
.rules-action-card__field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--rules-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.rules-action-card__field-help { font-size: 11px; color: var(--rules-text-muted); line-height: 1.5; }
.rules-action-card__no-params { font-size: 12px; color: var(--rules-text-muted); font-style: italic; padding: 4px 0; }
.rules-action-card__input,
.rules-action-card__select,
.rules-action-card__textarea {
    border: 1px solid var(--rules-border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    outline: none;
    background: #fff;
    font-family: inherit;
    color: var(--rules-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rules-action-card__input:focus,
.rules-action-card__select:focus,
.rules-action-card__textarea:focus {
    border-color: var(--rules-and);
    box-shadow: var(--rules-focus-ring);
}
.rules-action-card__textarea { min-height: 64px; resize: vertical; }

/* Channel multi-picker — chip style instead of stacked checkboxes */
.rules-action-card__multi {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0;
}
.rules-action-card__multi input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.rules-action-card__multi label {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: #fff;
    color: var(--rules-text-muted);
    border: 1px solid var(--rules-border);
    cursor: pointer;
    user-select: none;
    transition: all 0.12s ease;
    text-transform: capitalize;
}
.rules-action-card__multi label:hover { background: rgba(15, 23, 42, 0.04); }
.rules-action-card__multi input[type="checkbox"]:checked + label {
    background: var(--rules-and-soft);
    color: var(--rules-and);
    border-color: rgba(79, 70, 229, 0.3);
    font-weight: 600;
}

.rules-action-card__cap {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--rules-border-soft);
}
.rules-action-card__cap > summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--rules-text-muted);
    font-weight: 600;
    list-style: none;
}
.rules-action-card__cap > summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.15s ease;
}
.rules-action-card__cap[open] > summary::before { transform: rotate(90deg); }
.rules-action-card__cap[open] { padding-bottom: 4px; }
.rules-action-card__cap[open] .rules-action-card__field { margin-top: 8px; }

/* ─── Schedule panel ───────────────────────────────────────────────── */
.rules-schedule { display: flex; flex-direction: column; gap: 14px; }
.rules-schedule__mode {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
    padding: 4px;
    background: #f1f5f9;
    border-radius: 12px;
}
.rules-schedule__mode-btn {
    appearance: none;
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--rules-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.rules-schedule__mode-btn.is-active {
    background: #fff;
    color: var(--rules-and);
    box-shadow: var(--rules-shadow-sm);
}
.rules-schedule__placeholder {
    font-size: 12px;
    color: var(--rules-text-muted);
    background: rgba(15, 23, 42, 0.03);
    padding: 14px;
    border-radius: 10px;
    line-height: 1.6;
}
.rules-schedule__placeholder strong { color: var(--rules-text); }
.rules-schedule__placeholder-hint { margin-top: 6px; font-size: 11px; opacity: 0.8; }

/* ── Weekly picker ───────────────────────────────────────────────────── */
.rules-schedule__weekly {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rules-schedule__presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.rules-schedule__preset-label {
    font-size: 11px;
    color: var(--rules-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 4px;
}
.rules-schedule__preset {
    padding: 4px 10px;
    border: 1px solid var(--rules-border);
    border-radius: 999px;
    background: var(--rules-card-bg);
    color: var(--rules-text);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}
.rules-schedule__preset:hover {
    border-color: var(--rules-accent);
    color: var(--rules-accent);
}
.rules-schedule__sub-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--rules-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}
.rules-schedule__days {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.rules-schedule__day {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--rules-border);
    background: var(--rules-card-bg);
    color: var(--rules-text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}
.rules-schedule__day:hover { border-color: var(--rules-accent); }
.rules-schedule__day.is-active {
    background: var(--rules-accent);
    color: #fff;
    border-color: var(--rules-accent);
}
.rules-schedule__times {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.rules-schedule__times-empty {
    font-size: 11px;
    color: var(--rules-text-muted);
    font-style: italic;
}
.rules-schedule__time-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
}
.rules-schedule__time-pill-l {
    font-size: 12px;
    font-weight: 600;
    color: var(--rules-accent);
    font-variant-numeric: tabular-nums;
}
.rules-schedule__time-pill-x {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--rules-accent);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    font-family: inherit;
}
.rules-schedule__time-pill-x:hover {
    background: var(--rules-accent);
    color: #fff;
}
.rules-schedule__time-adder {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.rules-schedule__time-adder-sel {
    padding: 4px 8px;
    border: 1px solid var(--rules-border);
    border-radius: 6px;
    background: var(--rules-card-bg);
    color: var(--rules-text);
    font-size: 12px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}
.rules-schedule__time-adder-btn {
    padding: 5px 10px;
    border: 1px solid var(--rules-border);
    border-radius: 6px;
    background: var(--rules-card-bg);
    color: var(--rules-text);
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.rules-schedule__time-adder-btn:hover {
    border-color: var(--rules-accent);
    color: var(--rules-accent);
}
.rules-schedule__preview {
    font-size: 12px;
    color: var(--rules-text-muted);
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.03);
    border-radius: 6px;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
.rules-schedule__limits { display: flex; flex-direction: column; gap: 8px; }
.rules-schedule__limit { display: grid; grid-template-columns: minmax(0, 1fr) 172px; align-items: center; gap: 10px; }
.rules-schedule__limit-label { font-size: 13px; color: var(--rules-text, #1f2937); }
@media (max-width: 560px) { .rules-schedule__limit { grid-template-columns: 1fr; gap: 4px; } }
.rules-schedule__preview.is-warning {
    background: #fef3c7;
    color: #78350f;
}

/* ─── Numeric stepper ──────────────────────────────────────────────────
   Replaces <input type="number"> across condition leaves + action params.
   The wrapper looks like a single field; ± buttons are full-height tap
   targets at each end. Caller-supplied className (rules-leaf__value-*,
   rules-action-card__input) sets the width via flex rules; the visual
   shell here wins for border/padding/background. */
.rules-stepper {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--rules-border);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    height: 42px;                 /* up from 32px — bigger tap targets */
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rules-stepper:focus-within {
    border-color: var(--rules-accent);
    box-shadow: var(--focus-ring);
}
.rules-stepper__btn {
    flex: 0 0 38px;                /* up from 26px — chunkier ± buttons */
    width: 38px;
    border: 0;
    background: rgba(15, 23, 42, 0.04);
    color: var(--rules-text);
    font-size: 20px;               /* up from 16px */
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    padding: 0;
    user-select: none;
    transition: background-color 0.1s ease, color 0.1s ease;
}
.rules-stepper__btn:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.12);
    color: var(--rules-accent);
}
.rules-stepper__btn:active:not(:disabled) {
    background: var(--rules-accent);
    color: #fff;
}
.rules-stepper__btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.rules-stepper__btn--minus { border-right: 1px solid var(--rules-border); }
.rules-stepper__btn--plus  { border-left:  1px solid var(--rules-border); }
.rules-stepper__input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    border: 0;
    padding: 0 10px;
    background: transparent;
    color: var(--rules-text);
    font-size: 15px;               /* up from 13px */
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    outline: none;
    font-variant-numeric: tabular-nums;
}
.rules-stepper__input::placeholder {
    color: var(--rules-text-muted);
    opacity: 0.8;
    font-weight: 400;
}
.rules-stepper__unit {
    flex: 0 0 auto;
    align-self: center;
    color: var(--rules-text-muted);
    font-size: 13px;
    padding-right: 10px;
    user-select: none;
}

/* Width hints for stepper instances inside condition leaves + action cards.
   The visual shell above provides border/padding; these just set width. */
.rules-stepper.rules-leaf__value-input,
.rules-stepper.rules-leaf__value-pct,
.rules-stepper.rules-leaf__value-mult { padding: 0; }
.rules-stepper.rules-leaf__value-input { min-width: 150px; }
.rules-stepper.rules-leaf__value-pct   { width: 140px; }
.rules-stepper.rules-leaf__value-mult  { width: 140px; }
.rules-stepper.rules-action-card__input {
    border-radius: 10px;
    padding: 0;
    background: #fff;
    min-width: 150px;
}

/* ─── Footer + simulator strip ─────────────────────────────────────── */
.rules-builder__simulator {
    background: var(--rules-card-bg);
    border-radius: 14px;
    padding: 0;
    box-shadow: var(--rules-shadow-sm);
    overflow: hidden;
}

/* Phase 2 simulator strip — collapsible card with seg control + result */
.rules-sim__header-row {
    display: flex;
    align-items: stretch;
    width: 100%;
}
.rules-sim__header {
    flex: 1 1 auto;
    background: none;
    border: 0;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: var(--rules-text);
    transition: background-color 0.15s ease;
}
.rules-sim__header:hover { background: rgba(15, 23, 42, 0.03); }

/* Re-run shortcut — only shown when the strip is stale. Sits in the
   header row next to the collapse-toggle so the user can refresh
   without expanding the panel. */
.rules-sim__rerun {
    flex: 0 0 auto;
    margin: 8px 14px 8px 0;
    padding: 6px 14px;
    background: #f59e0b;
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.25);
    transition: background-color 0.15s ease;
}
.rules-sim__rerun:hover { background: #d97706; }
.rules-sim__header-label {
    font-size: 13px;
    font-weight: 600;
    flex: 0 0 auto;
}
.rules-sim__header-hint {
    font-size: 12px;
    color: var(--rules-text-muted);
    flex: 1 1 auto;
}
.rules-sim__header-arrow {
    color: var(--rules-text-muted);
    font-size: 14px;
}
.rules-sim.is-stale .rules-sim__header-hint { color: #b45309; }
.rules-sim.is-stale .rules-sim__header-label::after {
    content: ' ●';
    color: #b45309;
}

.rules-sim__body {
    padding: 0 22px 18px 22px;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.rules-sim__controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 0 12px 0;
}
.rules-sim__seg {
    display: inline-flex;
    border: 1px solid var(--rules-border);
    border-radius: 8px;
    overflow: hidden;
}
.rules-sim__seg-btn {
    background: var(--rules-card-bg);
    border: 0;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--rules-text-muted);
    cursor: pointer;
    font-family: inherit;
}
.rules-sim__seg-btn.is-active {
    background: var(--rules-accent);
    color: #fff;
}
.rules-sim__days {
    padding: 7px 10px;
    border: 1px solid var(--rules-border);
    border-radius: 8px;
    font-size: 12px;
    background: var(--rules-card-bg);
    color: var(--rules-text);
    font-family: inherit;
}
.rules-sim__run {
    margin-left: auto;
    padding: 7px 18px;
    background: var(--rules-accent);
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.rules-sim__run:disabled { opacity: 0.5; cursor: default; }

/* "Refresh from Meta" button — secondary action next to Run. Only shown
   when there's a cached result to invalidate; clicking it bypasses the
   server-side result cache and burns one fresh Meta API call. */
.rules-sim__refresh {
    padding: 7px 14px;
    background: var(--rules-card-bg);
    color: var(--rules-text);
    border: 1px solid var(--rules-border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.rules-sim__refresh:hover:not(:disabled) { background: rgba(15, 23, 42, 0.04); }
.rules-sim__refresh:disabled { opacity: 0.5; cursor: default; }

.rules-sim__status {
    font-size: 12px;
    color: var(--rules-text-muted);
    padding: 4px 0;
    min-height: 16px;
}

.rules-sim__result { margin-top: 8px; }

.rules-sim__summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.rules-sim__metric {
    flex: 0 0 auto;
    padding: 10px 16px;
    border: 1px solid var(--rules-border);
    border-radius: 10px;
    background: var(--rules-card-bg);
    min-width: 120px;
}
.rules-sim__metric.is-primary {
    background: linear-gradient(135deg, #5B53E8 0%, #8b5cf6 100%);
    border-color: transparent;
    color: #fff;
}
.rules-sim__metric.is-primary .rules-sim__metric-v,
.rules-sim__metric.is-primary .rules-sim__metric-l { color: #fff; }
.rules-sim__metric-v {
    font-size: 22px;
    font-weight: 700;
    color: var(--rules-text);
    line-height: 1.1;
}
.rules-sim__metric-l {
    font-size: 11px;
    color: var(--rules-text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.rules-sim__truncated {
    font-size: 11px;
    color: var(--rules-text-muted);
    align-self: center;
    font-style: italic;
}

.rules-sim__section-h {
    font-size: 11px;
    font-weight: 700;
    color: var(--rules-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 14px 0 6px;
}
.rules-sim__caption {
    font-size: 12px;
    color: var(--rules-text-muted);
    margin-bottom: 6px;
}

.rules-sim__entity-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
}
.rules-sim__entity {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.02);
    font-size: 12px;
}
/* Two-row variant: top = path + level pill, bottom = metric chips */
.rules-sim__entity--two-row {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 10px;
    gap: 6px;
}
.rules-sim__entity-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.rules-sim__entity-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.rules-sim__metric-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    cursor: help;       /* signals the tooltip */
    line-height: 1.5;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: transform 0.1s ease, box-shadow 0.12s ease;
}
.rules-sim__metric-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.rules-sim__metric-chip.is-pass {
    background: rgba(16, 185, 129, 0.10);
    color: #047857;
    border-color: rgba(16, 185, 129, 0.25);
}
.rules-sim__metric-chip.is-pass:hover {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.45);
}
.rules-sim__metric-chip.is-fail {
    background: rgba(239, 68, 68, 0.08);
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.22);
}
.rules-sim__metric-chip.is-fail:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.40);
}
.rules-sim__metric-chip.is-no-data {
    background: rgba(245, 158, 11, 0.10);
    color: #78350f;
    border-color: rgba(245, 158, 11, 0.25);
}
.rules-sim__metric-chip.is-no-data:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.45);
}
.rules-sim__metric-chip-l {
    opacity: 0.8;
    font-weight: 500;
}
.rules-sim__metric-chip-v {
    font-weight: 700;
}
.rules-sim__entity-name {
    flex: 1 1 auto;
    color: var(--rules-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Full Campaign › AdSet › Ad path. Renders inline with chevron separators.
   The leaf segment (the entity the rule targets) is rendered in stronger
   weight so the eye lands on it; parent context fades back. */
.rules-sim__entity-path {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;            /* allow flex children to shrink for ellipsis */
    overflow: hidden;
}
.rules-sim__entity-seg {
    color: var(--rules-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 0 1 auto;
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 5px;
    transition: background-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
/* Anchor segments — clickable Ads Manager deep links. Hover state is
   loud + obvious so the user knows the entire label is a target: tinted
   background, accent color, and an external-link glyph after the text.
   The same hover applies to both parent (campaign, adset) and leaf
   (ad) segments so the affordance is uniform across the breadcrumb. */
a.rules-sim__entity-seg {
    cursor: pointer;
    position: relative;
}
a.rules-sim__entity-seg:hover {
    background: rgba(99, 102, 241, 0.10);
    color: var(--rules-accent);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
    text-decoration: none;
}
a.rules-sim__entity-seg:hover::after {
    content: ' ↗';
    font-size: 10px;
    color: var(--rules-accent);
    margin-left: 2px;
    opacity: 0.8;
}
a.rules-sim__entity-seg:focus-visible {
    outline: 2px solid var(--rules-accent);
    outline-offset: 1px;
}
.rules-sim__entity-seg.is-leaf {
    color: var(--rules-text);
    font-weight: 600;
    flex: 1 1 auto;
}

/* Fallback segments: ID-only labels rendered when Meta withheld the
   name (partner-shared / permission-masked parents). Italic + dashed
   bottom border so the user can tell at a glance which segments are
   names vs bare IDs. */
.rules-sim__entity-seg.is-fallback {
    font-style: italic;
    opacity: 0.9;
}
.rules-sim__entity-seg.is-fallback.is-leaf {
    font-weight: 500;
}
a.rules-sim__entity-seg.is-fallback {
    box-shadow: inset 0 -1px 0 0 currentColor;
}
a.rules-sim__entity-seg.is-fallback:hover {
    box-shadow:
        inset 0 -2px 0 0 var(--rules-accent),
        inset 0 0 0 1px rgba(99, 102, 241, 0.25);
}
.rules-sim__entity-sep {
    color: var(--rules-text-muted);
    flex: 0 0 auto;
    opacity: 0.6;
    font-size: 11px;
}
.rules-sim__entity-level {
    flex: 0 0 auto;
    font-size: 10px;
    color: var(--rules-text-muted);
    background: rgba(15, 23, 42, 0.06);
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.rules-sim__entity-date {
    flex: 0 0 84px;
    font-size: 11px;
    color: var(--rules-text-muted);
    font-variant-numeric: tabular-nums;
}

.rules-sim__empty {
    padding: 10px;
    font-size: 12px;
    color: var(--rules-text-muted);
    text-align: center;
    border: 1px dashed var(--rules-border);
    border-radius: 6px;
}

.rules-sim__warn {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    color: #78350f;
    margin-bottom: 10px;
}
.rules-sim__warn > div + div { margin-top: 4px; }

.rules-sim__err {
    background: #fee2e2;
    border-left: 3px solid #ef4444;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    color: #7f1d1d;
    margin-bottom: 10px;
}
.rules-sim__err ul { margin: 4px 0 0 18px; padding: 0; }

.rules-sim__spark {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 44px;
    padding: 0 2px;
    background: rgba(15, 23, 42, 0.02);
    border-radius: 4px;
}
.rules-sim__spark-bar {
    flex: 1 1 0;
    background: var(--rules-accent);
    border-radius: 1px;
    min-height: 2px;
}

.rules-sim__trace-list { display: flex; flex-direction: column; gap: 8px; }
.rules-sim__trace {
    padding: 8px 10px;
    border: 1px solid var(--rules-border);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.01);
}
.rules-sim__trace-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--rules-text);
}
.rules-sim__trace-group { padding-left: 10px; border-left: 2px solid var(--rules-border); margin: 4px 0; }
.rules-sim__trace-group.is-pass { border-left-color: #10b981; }
.rules-sim__trace-group.is-fail { border-left-color: #ef4444; }
.rules-sim__trace-op { font-size: 11px; font-weight: 700; color: var(--rules-text-muted); }
.rules-sim__trace-leaf { font-size: 11px; padding: 2px 0; font-family: ui-monospace, monospace; }
.rules-sim__trace-leaf.is-pass { color: #047857; }
.rules-sim__trace-leaf.is-fail { color: #991b1b; }
.rules-sim__trace-leaf-actual { color: var(--rules-text-muted); }
.rules-sim__trace-leaf-note { color: #b45309; font-style: italic; }

.rules-builder__footer {
    background: var(--rules-card-bg);
    border-radius: 14px;
    padding: 16px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: var(--rules-shadow-sm);
}
.rules-builder__footer-left,
.rules-builder__footer-right {
    display: flex; gap: 8px;
    align-items: center;
}

/* Footer-mounted Off/On status toggle — sits next to the Save button.
   Reuses the .rules-summary__status-wrap base styling; this rule just
   adds a slight right-margin so it doesn't crowd Save. */
.rules-footer__status { margin-right: 4px; }

/* Validation banner — friendly tone, clear hierarchy */
.rules-builder__err {
    background: var(--rules-danger-tint);
    border-radius: 14px;
    padding: 14px 18px;
    font-size: 13px;
    color: #7f1d1d;
    box-shadow: var(--rules-shadow-sm);
    border-left: 3px solid var(--rules-danger);
}
.rules-builder__err strong {
    display: block;
    color: var(--rules-danger);
    margin-bottom: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.rules-builder__err ul {
    margin: 0; padding-left: 20px;
    line-height: 1.7;
}
.rules-builder__err li::marker { color: var(--rules-danger); }

/* ─── Responsive — collapse to single column under 1100px ─────────── */
/* ─── List page head — two CTAs side-by-side ───────────────────────── */
.rules-list__head-actions {
    display: flex; gap: 10px;
}

/* ─── AI on-ramp bar — utility aesthetic ────────────────────────────
   No purple gradients, no uppercase labels, no decorative icons.
   Just a labelled input + button, sized like every other form field
   on the page. The AI capability speaks through use, not chrome.    */
.rules-ai-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--rules-border);
    border-radius: 10px;
    margin-bottom: 16px;
}
.rules-ai-bar__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rules-ai-bar__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--rules-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.rules-ai-bar__input {
    width: 100%;
    border: 1px solid var(--rules-border);
    background: #fff;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--rules-text);
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rules-ai-bar__input::placeholder { color: var(--rules-text-dim); }
.rules-ai-bar__input:focus {
    border-color: var(--rules-and);
    box-shadow: var(--rules-focus-ring);
}
/* Default rules-btn--primary styling already applies — no special overrides */

/* ─── Empty state — 3-CTA row ──────────────────────────────────────── */
.rules-list__empty-cta {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* ─── Builder mode toggle ──────────────────────────────────────────── */
.rules-summary__mode {
    display: flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}
.rules-summary__mode-btn {
    appearance: none;
    border: none;
    background: transparent;
    border-radius: 7px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--rules-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.rules-summary__mode-btn:hover { color: var(--rules-text); }
.rules-summary__mode-btn.is-active {
    background: #fff;
    color: var(--rules-and);
    box-shadow: var(--rules-shadow-sm);
}

/* Builder mode reflects in the summary bar grid.
   NO `!important` here. It was unnecessary — this rule already beats the base .rules-summary
   above it on source order alone (identical specificity, declared later) — and it was actively
   harmful: `!important` also beat the @media (max-width:700px) override further down, which
   collapses this bar to a single column on a phone. That override is not weaker, it is simply
   not important, and an author `!important` wins regardless of order or specificity. So the
   mobile rule silently did nothing and the summary bar kept four tracks on a 320px screen. */
/* Two rows (user 2026-11-04 — one row was cluttered): [name ……… Simple/Advanced] on top, the
   plain-language summary under the heading across the full width. */
.rules-summary {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 6px;
}
.rules-summary__sentence {
    grid-column: 1 / -1;
    padding: 0 14px;              /* lines up with the name input's text */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;        /* the bar is sticky — keep it short; full text in the tooltip */
    line-clamp: 3;
    overflow: hidden;
}

/* AI warnings banner */
.rules-builder__ai-warnings {
    background: linear-gradient(135deg, #fefce8 0%, #faf5ff 100%);
    border: 1px solid rgba(217, 119, 6, 0.2);
    border-radius: 14px;
    padding: 14px 18px;
    position: relative;
    box-shadow: var(--rules-shadow-sm);
}
.rules-builder__ai-warnings strong {
    display: block;
    margin-bottom: 6px;
    color: #92400e;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.rules-builder__ai-warnings ul {
    margin: 0; padding-left: 20px;
    font-size: 13px;
    color: var(--rules-text);
    line-height: 1.6;
}
.rules-builder__ai-warnings-x {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--rules-text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}
.rules-builder__ai-warnings-x:hover { background: rgba(15, 23, 42, 0.05); color: var(--rules-text); }

.rules-actions__hidden-note {
    font-size: 11px;
    color: var(--rules-text-dim);
    text-align: center;
    padding: 8px;
    background: rgba(15, 23, 42, 0.03);
    border-radius: 8px;
    margin-top: 8px;
    font-style: italic;
}

/* ─── Modal shell — modern, refined ──────────────────────────────────
   Lighter shadow stack, larger radius, calmer animation easing.
   The backdrop blur stays — it's the single most modern touch in a
   modal experience and runs hardware-accelerated on every browser. */
.rules-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.40);
    backdrop-filter: blur(6px) saturate(120%);
    -webkit-backdrop-filter: blur(6px) saturate(120%);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    animation: rules-modal-in 0.2s ease;
}
.rules-modal-backdrop.is-leaving { opacity: 0; transition: opacity 0.18s ease; }
@keyframes rules-modal-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.rules-modal {
    background: #fff;
    border-radius: 20px;
    box-shadow:
        0 32px 64px -12px rgba(15, 23, 42, 0.18),
        0 0 0 1px rgba(15, 23, 42, 0.04);
    max-width: 1020px; width: 100%; max-height: 88vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: rules-modal-pop 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes rules-modal-pop {
    from { transform: translateY(16px) scale(0.985); opacity: 0; }
    to   { transform: translateY(0)    scale(1);     opacity: 1; }
}
.rules-modal__head {
    display: flex; align-items: flex-start; gap: 16px;
    padding: 28px 32px 20px;
}
.rules-modal__title-wrap { flex: 1; min-width: 0; }
.rules-modal__title {
    font-size: 22px; font-weight: 600; margin: 0 0 6px;
    letter-spacing: -0.02em;
    color: var(--rules-text);
}
.rules-modal__subtitle {
    font-size: 13px;
    color: var(--rules-text-muted);
    margin: 0;
    line-height: 1.6;
    max-width: 620px;
}
.rules-modal__empty {
    padding: 80px 20px;
    text-align: center;
    color: var(--rules-text-muted);
}

/* ─── Template picker — modern card grid ───────────────────────────── */
.rules-template-picker__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 32px 20px;
}
.rules-template-picker__filter {
    appearance: none;
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--rules-text-muted);
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: inherit;
}
.rules-template-picker__filter:hover {
    background: rgba(15, 23, 42, 0.04);
    color: var(--rules-text);
}
.rules-template-picker__filter.is-active {
    background: var(--rules-text);
    color: #fff;
}
.rules-template-picker__grid-mount {
    flex: 1;
    overflow-y: auto;
    padding: 4px 32px 32px;
}
.rules-template-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 12px;
}

/* Card — hairline border, subtle shadow on hover, icon in a soft tile */
.rules-template-card {
    appearance: none;
    text-align: left;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
    transition:
        transform 0.18s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.18s cubic-bezier(0.16, 1, 0.3, 1),
        border-color 0.15s ease;
    font-family: inherit;
    position: relative;
}
.rules-template-card:hover {
    border-color: rgba(15, 23, 42, 0.12);
    transform: translateY(-2px);
    box-shadow:
        0 12px 24px -8px rgba(15, 23, 42, 0.08),
        0 0 0 1px rgba(79, 70, 229, 0.08);
}
.rules-template-card:active {
    transform: translateY(0);
    transition-duration: 0.05s;
}

/* Icon sits in a soft rounded tile for visual weight without competing
   with the title. Background tints subtly by category. */
.rules-template-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.04);
    transition: background 0.15s ease;
}
.rules-template-card:hover .rules-template-card__icon {
    background: rgba(79, 70, 229, 0.08);
}

.rules-template-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.rules-template-card__name-wrap {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 0;
}
.rules-template-card__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--rules-text);
    letter-spacing: -0.01em;
    line-height: 1.35;
}
.rules-template-card__star {
    font-size: 11px;
    color: #f59e0b;
    line-height: 1;
}
.rules-template-card__desc {
    font-size: 12.5px;
    color: var(--rules-text-muted);
    line-height: 1.55;
}

.rules-template-card__meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}
.rules-template-card__diff,
.rules-template-card__cat {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}
.rules-template-card__diff--beginner     { background: rgba(16, 185, 129, 0.10); color: #047857; }
.rules-template-card__diff--intermediate { background: rgba(59, 130, 246, 0.10); color: #1e40af; }
.rules-template-card__diff--advanced     { background: rgba(168, 85, 247, 0.10); color: #7e22ce; }
.rules-template-card__cat--safety        { background: rgba(239, 68, 68, 0.08);  color: #991b1b; }
.rules-template-card__cat--scaling       { background: rgba(16, 185, 129, 0.08); color: #047857; }
.rules-template-card__cat--cleanup       { background: rgba(100, 116, 139, 0.10);color: #475569; }
.rules-template-card__cat--alerts        { background: rgba(245, 158, 11, 0.10); color: #92400e; }
.rules-template-card__cat--video         { background: rgba(139, 92, 246, 0.10); color: #6d28d9; }
.rules-template-card__cat--attribution   { background: rgba(14, 165, 233, 0.10); color: #075985; }

.rules-template-card__source {
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid rgba(15, 23, 42, 0.05);
    font-size: 11px;
    color: var(--rules-text-dim);
    line-height: 1.4;
}

@media (max-width: 1100px) {
    /* Stack scope on top of the conditions/actions column. Leaves already
       wrap by default (see .rules-leaf), so no leaf override is needed here. */
    .rules-builder__grid {
        grid-template-columns: 1fr;
    }
}
/* Tablet — drop the lower-priority columns (Conditions count, Activity)
   so the row stays scannable: Name + Applied to + Status + Edit. */
@media (max-width: 1100px) {
    .rules-list__row { grid-template-columns: minmax(200px, 1.7fr) minmax(140px, 1fr) 80px 70px; }
    .rules-list__row .col-cond,
    .rules-list__row .col-activity { display: none; }
}
@media (max-width: 700px) {
    .rules-page { padding: 20px 16px 40px; }
    /* Mobile — name + status only. Everything else collapses into the
       row's hover/click destination (the builder). */
    .rules-list__row { grid-template-columns: 1fr 80px; gap: 8px; }
    .rules-list__row .col-applied,
    .rules-list__row .col-cond,
    .rules-list__row .col-activity,
    .rules-list__row .col-actions { display: none; }
    .rules-summary {
        grid-template-columns: 1fr;
        gap: 10px;
        /* Not sticky on a phone: stacked, it is ~200px tall and pinned it covered half of a
           390px-tall viewport while the user edited conditions (QA 2026-11-08). */
        position: static;
    }
}

/* Popular star icon on template cards */
.rules-template-card__name-wrap {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 4px;
}
.rules-template-card__name-wrap .rules-template-card__name { margin: 0; }
.rules-template-card__star {
    font-size: 12px;
    color: #f59e0b;
    line-height: 1;
}
.rules-template-card__source {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--rules-border-soft);
    font-size: 10px;
    color: var(--rules-text-dim);
    font-style: italic;
    line-height: 1.4;
}

/* Popular tab pill gets a gradient treatment */
.rules-template-picker__filter[data-cat="popular"].is-active {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: transparent;
}

/* ─── Empty hero — single-focus design ────────────────────────────
   When the page has no rules, replaces the AI-bar + filters + table
   with a centered single-column hero. The AI input is the primary
   action; Templates + Build from scratch sit underneath as quiet
   secondary cards.

   Centered column anchored at 640px so the page reads tight even on
   ultra-wide screens. Real typography, no gradients, no illustrations
   — just confident proportions.                                    */
/* ─── Polaris-style empty hero ───────────────────────────────────
   Single white card, centered on a soft gray page background.
   Outlined SVG icon at top, semibold title, muted subtitle, the AI
   input as the primary action, and two plain text-link secondaries.
   Matches Shopify Admin's empty-state pattern:
     - 8px border radius (square-leaning)
     - Hairline border + barely-visible shadow
     - Polaris ink/subdued text colors
     - 600 weight headings (semibold, not bold)            */

/* Shopify-ish page background */
.rules-list--empty-mode {
    max-width: 760px;
    margin: 0 auto;
}
.rules-list--empty-mode .rules-list__head {
    display: block;
    margin-bottom: 24px;
    text-align: left;
    padding: 0 4px;
}
.rules-list--empty-mode .rules-list__title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 2px;
    color: #202223;            /* Polaris ink */
    letter-spacing: -0.01em;
}
.rules-list--empty-mode .rules-list__sub {
    font-size: 13px;
    color: #6d7175;            /* Polaris subdued */
    margin-bottom: 0;
}

/* The hero card itself — the Polaris Card pattern */
.rules-hero-card {
    background: #ffffff;
    border: 1px solid #e1e3e5;          /* Polaris divider */
    border-radius: 8px;
    box-shadow: 0 1px 0 rgba(22, 29, 37, 0.05);   /* Polaris card shadow */
    padding: 48px 32px 36px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.rules-hero-card__icon {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: #f1f8f5;                 /* very soft Shopify-green tint */
    color: #008060;                      /* Polaris primary green */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.rules-hero-card__title {
    font-size: 18px;
    font-weight: 600;
    color: #202223;
    margin: 0 0 6px;
    letter-spacing: -0.005em;
    line-height: 1.4;
}
.rules-hero-card__subtitle {
    font-size: 14px;
    color: #6d7175;
    margin: 0 0 24px;
    line-height: 1.55;
    max-width: 440px;
}

/* AI input area inside the hero card. The renderAIBar component
   produces label + input + button — we just constrain its width
   and override its default margin so it sits flush.              */
.rules-hero-card__ai {
    width: 100%;
    max-width: 480px;
    margin: 0 auto 16px;
}
.rules-hero-card__ai .rules-ai-bar {
    margin: 0;
    border: 1px solid #c9cccf;
    background: #fff;
    padding: 12px;
}
.rules-hero-card__ai .rules-ai-bar__label {
    text-align: left;
    color: #6d7175;
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}
.rules-hero-card__ai .rules-ai-bar__input {
    text-align: left;
    border-color: #c9cccf;
}
.rules-hero-card__ai .rules-ai-bar__input:focus {
    border-color: #008060;
    box-shadow: 0 0 0 2px rgba(0, 128, 96, 0.2);
}
/* Polaris primary button — dark, square-ish, restrained */
.rules-hero-card__ai .rules-ai-bar__btn,
.rules-hero-card__ai .rules-btn--primary {
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #1a1a1a;
    border-radius: 6px;
    font-weight: 500;
    padding: 8px 16px;
    box-shadow: none;
}
.rules-hero-card__ai .rules-btn--primary:hover {
    background: #303030;
    border-color: #303030;
    box-shadow: none;
}

/* Secondary text-link row — Polaris plain action style */
.rules-hero-card__links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: #6d7175;
}
.rules-hero-card__or {
    color: #646B78;
}
.rules-hero-card__sep {
    color: #646B78;
    margin: 0 2px;
}
.rules-hero-card__link {
    appearance: none;
    background: none;
    border: none;
    color: #2c6ecb;            /* Polaris link */
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 2px;
    text-decoration: none;
    transition: color 0.12s ease;
}
.rules-hero-card__link:hover {
    color: #1f5199;
    text-decoration: underline;
}

@media (max-width: 600px) {
    .rules-hero-card { padding: 32px 20px; }
    .rules-hero-card__title { font-size: 17px; }
}

/* Responsive */
@media (max-width: 800px) {
    .rules-empty__cards    { grid-template-columns: 1fr; }
    .rules-empty__how-row  { grid-template-columns: 1fr; gap: 2px; }
}

/* ── AI automation composer card (renderAIBar — "Describe your automation") ── */
.rules-ai-card {
    position: relative;
    overflow: hidden;
    background: var(--rules-card-bg, #fff);
    border: 1px solid var(--rules-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}
.rules-ai-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, #5B53E8, #8b5cf6, #a855f7);
}
.rules-ai-card__head { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 14px; }
.rules-ai-card__icon {
    flex: 0 0 42px; width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; color: #fff;
    background: linear-gradient(135deg, #5B53E8, #8b5cf6 55%, #a855f7);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.32);
}
.rules-ai-card__titles { flex: 1; min-width: 0; }
.rules-ai-card__title { margin: 1px 0 4px; font-size: 16px; font-weight: 700; color: var(--rules-text); }
.rules-ai-card__sub { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--rules-text-muted); }
.rules-ai-card__input {
    width: 100%; box-sizing: border-box; resize: vertical; min-height: 72px;
    padding: 12px 14px; font: inherit; font-size: 14px; line-height: 1.5;
    color: var(--rules-text); background: var(--rules-input-bg, #fff);
    border: 1px solid var(--rules-border); border-radius: 12px;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.rules-ai-card__input::placeholder { color: var(--rules-text-dim); }
.rules-ai-card__input:focus { outline: none; border-color: #5B53E8; box-shadow: var(--focus-ring); }
.rules-ai-card__chips { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 12px 0 4px; }
.rules-ai-card__chips-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--rules-text-dim); margin-right: 2px; }
.rules-ai-card__chip {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 12px; color: var(--rules-text-muted);
    background: var(--rules-and-tint, #eef2ff); border: 1px solid transparent;
    border-radius: 999px; padding: 5px 11px; cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
}
.rules-ai-card__chip:hover { color: #4f46e5; border-color: #5B53E8; }
.rules-ai-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.rules-ai-card__hint { font-size: 12px; color: var(--rules-text-dim); }
.rules-ai-card__btn { display: inline-flex; align-items: center; gap: 7px; background: linear-gradient(135deg, #5B53E8, #7c3aed); border: 0; box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3); }
.rules-ai-card__btn:hover { filter: brightness(1.05); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4); }
.rules-ai-card__btn:disabled { opacity: 0.65; cursor: default; }
.rules-ai-card__btn-ico { display: inline-flex; }

/* ── Activity modal — per-rule run history (Phase 2B) ─────────────────── */
.rules-activity-modal { width: 640px; max-width: calc(100vw - 32px); }
.rules-activity-body { max-height: 64vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.rules-activity-loading, .rules-activity-empty {
    padding: 22px 8px; text-align: center;
    font-size: 13px; color: var(--text-secondary, #6b7280);
}
.rules-activity-run {
    border: 1px solid var(--border-subtle, #e5e7eb); border-radius: 10px;
    padding: 10px 12px; background: #fff;
}
.rules-activity-run__top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.rules-activity-run__time { font-size: 12.5px; font-weight: 600; color: var(--text-primary, #1a1a2e); }
.rules-activity-run__counts { font-size: 12px; color: var(--text-secondary, #6b7280); }
.rules-activity-run__dur { font-size: 11px; color: #646B78; margin-left: auto; }
.rules-activity-mode {
    font-size: 10px; font-weight: 800; letter-spacing: 0.4px;
    padding: 2px 7px; border-radius: 999px;
}
.rules-activity-mode--live { background: #dcfce7; color: #166534; }
.rules-activity-mode--log  { background: #fef3c7; color: #92400e; }
.rules-activity-item {
    font-size: 12.5px; line-height: 1.5; padding: 2px 0 2px 4px;
    color: var(--text-primary, #1f2937);
}
.rules-activity-item--executed      { color: #166534; }
.rules-activity-item--would_execute { color: #92400e; }
.rules-activity-item--failed        { color: #b91c1c; }
.rules-activity-item--skipped_cap,
.rules-activity-item--skipped_noop,
.rules-activity-item--halted,
.rules-activity-item--quiet         { color: #6b7280; }
.rules-list__cell--clickable { cursor: pointer; }
.rules-list__cell--clickable:hover .rules-list__act-count,
.rules-list__cell--clickable:hover .rules-list__act-sub { text-decoration: underline; }
.rules-list__activity-btn { margin-right: 6px; }

/* ── Account history modal — per-account change ledger ─────────────────── */
.rules-acct-history__bar {
    display: flex; align-items: center; gap: 10px;
    padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle, #e5e7eb);
}
.rules-acct-history__label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary, #6b7280); }
.rules-acct-history__select {
    flex: 1; min-width: 0;
    font-size: 13px; padding: 7px 10px;
    border: 1px solid var(--border-subtle, #d1d5db); border-radius: 8px;
    background: #fff; color: var(--text-primary, #1f2937);
}
.rules-acct-history__feed { display: flex; flex-direction: column; }
.rules-acct-entry {
    padding: 9px 4px;
    border-bottom: 1px solid var(--border-subtle, #f3f4f6);
}
.rules-acct-entry:last-child { border-bottom: none; }
.rules-acct-entry__meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 3px; }
.rules-acct-entry__rule {
    font-size: 11.5px; color: var(--text-secondary, #6b7280);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%;
}
.rules-acct-history__more { align-self: center; margin-top: 4px; }

/* ── Rules created by the ads wizard: the ads / budget they are linked to (js/shared/rule-watch.js) ── */
.rule-watch-line { margin-top: 5px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12px; color: #646B78; }
.rule-watch-line__lbl { font-weight: 600; color: #3B414C; }
.rule-watch-line__item { color: var(--accent, #5B53E8); text-decoration: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.rule-watch-line__item:hover { text-decoration: underline; }
.rule-watch-line__more { color: #646B78; }
.rule-watch-panel { margin: 0 0 14px; padding: 10px 12px; border: 1px solid #E9EAEE; border-radius: 10px; background: #F8F9FB; }
.rule-watch-panel__title { font-size: 12.5px; font-weight: 700; color: #14171F; }
.rule-watch-panel__sub { margin-top: 2px; font-size: 11.5px; line-height: 1.45; color: #646B78; }
.rule-watch-panel__list { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow-y: auto; }
.rule-watch-panel__row { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 12.5px; }
.rule-watch-panel__kind { flex: 0 0 auto; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: #646B78; }
.rule-watch-panel__link { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent, #5B53E8); text-decoration: none; }
a.rule-watch-panel__link:hover { text-decoration: underline; }
.rule-watch-panel__del { margin-left: auto; flex: 0 0 auto; width: 22px; height: 22px; border: 0; border-radius: 6px; background: transparent; color: #646B78; font-size: 15px; line-height: 1; cursor: pointer; }
.rule-watch-panel__del:hover:not(:disabled) { background: #FDECEC; color: #C2410C; }
.rule-watch-panel__del:disabled { opacity: .35; cursor: not-allowed; }
.rules-leaf__value-avgof { max-width: 150px; }
.rule-watch-line__chip { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.rule-watch-line__thumb { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; flex: 0 0 auto; background: #EEF0F4; box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06); }
.rule-watch-panel__row { align-items: center; }
.rule-watch-panel__thumb { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; flex: 0 0 auto; background: #EEF0F4; box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06); }

/* ── ONE CONDITION COMPONENT (js/shared/conditions.js, 2026-11-06) ─────────────────────────────────────
   Tier cards + the empty-state add bar, shared by every tiered condition UI (smart labels, Remove products,
   feed position tiers …). The group / leaf chrome above (.rules-group / .rules-leaf) is the same everywhere. */
.cnd-add0 { padding-left: 0 !important; margin-top: 0 !important; }
.cnd-empty { font-size: 12px; color: #646B78; }
.cnd-tiers-host { display: block; }
.cnd-tiers { margin-top: 11px; display: flex; flex-direction: column; gap: 9px; }
.cnd-tier { border: 1px solid #ECEDF1; border-radius: 11px; background: #FFFFFF; overflow: hidden; }
.cnd-tier__head { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-bottom: 1px solid #F0F1F4; }
.cnd-tier__num { width: 20px; height: 20px; border-radius: 6px; background: #EEEDFC; color: #5B53E8; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.cnd-tier__tag { font-size: 11px; font-weight: 700; color: #5B6473; text-transform: uppercase; letter-spacing: .04em; }
.cnd-tier__spacer { flex: 1; }
.cnd-tier__del { margin-left: auto; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border: none; background: none; color: #646B78; cursor: pointer; border-radius: 7px; }
.cnd-tier__del:hover { background: #F2F3F6; color: #6B7280; }
.cnd-tier__del svg { width: 15px; height: 15px; }
.cnd-tier__conds { padding: 10px 11px; display: flex; flex-direction: column; gap: 7px; }
/* A tier that does not run right now (e.g. outside its own schedule): still editable, visibly dimmed. */
.cnd-tier.is-off { background: #FBFBFC; }
.cnd-tier.is-off .cnd-tier__conds, .cnd-tier.is-off .cnd-tier__out { opacity: .6; }
.cnd-tier__empty { font-size: 11.5px; color: #646B78; padding: 2px 0; }
.cnd-tier__out { display: flex; align-items: center; gap: 8px; padding: 10px 11px; border-top: 1px solid #F0F1F4; background: #FBFEFC; }
.cnd-tier__arrow { display: flex; color: #22A06B; flex: 0 0 auto; }
.cnd-tier__arrow svg { width: 15px; height: 15px; }
.cnd-tier__outlbl { font-size: 11.5px; font-weight: 600; color: #5B6473; flex: 0 0 auto; }
.cnd-fallback { border: 1px solid #E4F0E9; border-radius: 12px; background: #FBFEFC; padding: 11px 12px; display: flex; align-items: center; gap: 9px; }
.cnd-fallback__lbl { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: #3B414C; flex: 0 0 auto; }
.cnd-fallback__star { width: 20px; height: 20px; border-radius: 6px; background: #F2F3F6; color: #646B78; font-size: 12px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.cnd-fallback > :last-child:not(.cnd-tier__arrow):not(.cnd-fallback__lbl) { flex: 1 1 auto; min-width: 0; }
.cnd-fallback__hint { margin: 6px 2px 0; font-size: 11.5px; color: #646B78; }
.cnd-tier__out > :last-child:not(.cnd-tier__arrow) { flex: 1 1 auto; min-width: 0; }
.cnd-addtier { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin-top: 2px; padding: 7px 12px; border-radius: 9px;
    font-size: 12.5px; font-weight: 600; color: #1C8C56; background: #E9F7EF; border: 1px dashed #BCE3CC; cursor: pointer; }
.cnd-addtier:hover { background: #DFF3E8; }
.cnd-addtier svg { width: 14px; height: 14px; }

/* Live counts — standard part of the condition component (2026-11-06): a line under a group, one per tier
   card and a total after the tiers. While recounting, the last numbers stay visible with a small spinner. */
.cnd-count { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-height: 20px; font-size: 12px; color: #14171F; }
.cnd-count.is-empty { display: none; }
.cnd-count.is-loading > :not(.cnd-count__spin) { opacity: .55; transition: opacity .15s; }
.cnd-count strong { font-weight: 700; }
.cnd-count__k { color: #646B78; }
.cnd-count__err { color: #B42318; }
.cnd-count--group { margin: 10px 0 0 2px; }
.cnd-count--tier { margin: 0; padding: 9px 16px 11px; border-top: 1px dashed #EEF0F3; }   /* inside the tier card: same inset as its rows (user, 2026-11-17) */
.cnd-count--total { margin: 2px 2px 10px; padding: 8px 0 0; font-size: 12.5px; }
.cnd-count__spin { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #DEDBF8; border-top-color: #5B53E8; animation: cnd-count-spin .7s linear infinite; flex: 0 0 auto; }
@keyframes cnd-count-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cnd-count__spin { animation-duration: 2s; } }

/* Phone / tablet (QA 2026-11-08). A `1fr` track is minmax(auto, 1fr): it grew to the builder's
   min-content (410px on a 390px phone), so the scope + conditions cards ran off-screen and were
   clipped. The list header kept three buttons on one row (Build from scratch ~370px past the edge)
   and the four stat cards never wrapped. The list's inline styles need !important to be beaten. */
@media (max-width: 1100px) {
    .rules-builder__grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .rules-leaf__value { flex-wrap: wrap; row-gap: 6px; }
    .apx-head { flex-direction: column !important; gap: 14px !important; }
    .apx-head-actions { flex-wrap: wrap !important; flex: 1 1 auto !important; }
    .apx-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 900px) {
    .rules-builder__below { grid-template-columns: minmax(0, 1fr); }
    .rules-builder__col select { max-width: 100%; }
}

/* Simulator "Copy results" — had no style at all (raw browser button), audit 2026-11-08. */
.rules-sim__copy { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid #E2E4EA;
    border-radius: 8px; background: #fff; color: #374151; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.rules-sim__copy:hover { background: #F7F7F9; border-color: #D4D6DD; }
.rules-sim__copy:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 2px; }
.rules-sim__copy[hidden] { display: none; }

/* ── Text value: type ⇄ pick, and the value picker (js/shared/conditions.js, 2026-11-20) ───────────────────── */
.rules-leaf__valslot { display: inline-flex; min-width: 0; }
.rules-leaf__mode { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0;
    border: 1px solid var(--rules-border, #E2E4EA); border-radius: 8px; background: #fff; color: #6B7280; cursor: pointer; }
.rules-leaf__mode:hover { background: #F7F7F9; color: #14171F; }
.rules-leaf__mode[aria-pressed="true"] { background: #EEEDFD; border-color: #C9C6F8; color: var(--accent, #5B53E8); }
.rules-leaf__mode:focus-visible, .rules-leaf__pick:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 2px; }
.rules-leaf__pick { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 4px 26px 4px 10px; border: 1px solid var(--rules-border, #E2E4EA);
    border-radius: 8px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236B7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 9px center;
    color: var(--rules-text, #14171F); font: inherit; font-size: 13px; text-align: left; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rules-leaf__pick:hover { border-color: rgba(15, 23, 42, 0.22); }
.rules-leaf__pick.is-empty { color: #646B78; }
.rules-leaf__pick--multi { width: auto; min-width: 200px; max-width: 420px; flex-shrink: 1; }
.rules-leaf__chip { flex: 0 1 auto; max-width: 120px; overflow: hidden; text-overflow: ellipsis; padding: 1px 7px; border-radius: 999px; background: #EEEDFD; color: #3F38B8; font-size: 12px; font-weight: 600; }
.rules-leaf__chip--more { flex: 0 0 auto; background: #F1F2F5; color: #4B5563; }
.cnd-vp { position: fixed; z-index: 100000; display: flex; flex-direction: column; max-height: min(360px, calc(100vh - 16px)); background: #fff; border: 1px solid #E2E4EA;
    border-radius: 12px; box-shadow: 0 16px 40px rgba(16, 24, 40, 0.20); overflow: hidden; font-size: 13px; color: #14171F; }
.cnd-vp__search { flex: 0 0 auto; margin: 8px; padding: 7px 10px; border: 1px solid #E2E4EA; border-radius: 8px; font: inherit; font-size: 13px; outline: none; }
.cnd-vp__search:focus { border-color: var(--accent, #5B53E8); box-shadow: 0 0 0 3px rgba(91, 83, 232, 0.12); }
.cnd-vp__list { flex: 1 1 auto; overflow-y: auto; padding: 0 4px 4px; min-height: 40px; }
.cnd-vp__row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: 7px; background: none; font: inherit; font-size: 13px; color: inherit; text-align: left; cursor: pointer; }
.cnd-vp__row:hover, .cnd-vp__row:focus-visible { background: #F4F4F8; outline: none; }
.cnd-vp__row.is-on { background: #EEEDFD; }
.cnd-vp__row:disabled { opacity: 0.45; cursor: not-allowed; }
.cnd-vp__box { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border: 1.5px solid #C5C9D3; border-radius: 4px; color: #fff; }
.cnd-vp__row.is-on .cnd-vp__box { background: var(--accent, #5B53E8); border-color: var(--accent, #5B53E8); }
.cnd-vp__val { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cnd-vp__n { flex: 0 0 auto; color: #646B78; font-size: 12px; font-variant-numeric: tabular-nums; }
.cnd-vp__msg { padding: 12px 10px; color: #6B7280; font-size: 12.5px; }
.cnd-vp__msg--err { color: #B42318; }
.cnd-vp__foot { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; padding: 6px 10px; border-top: 1px solid #F0F1F4; }
.cnd-vp__info { color: #646B78; font-size: 12px; }
.cnd-vp__done { height: 28px; padding: 0 14px; border: 0; border-radius: 7px; background: var(--accent, #5B53E8); color: #fff; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.cnd-vp__done:hover { filter: brightness(0.94); }
@media (pointer: coarse) { .rules-leaf__mode { width: 40px; height: 40px; } .cnd-vp__row { padding: 11px 8px; } }
