/* =====================================================================================================================
   Rules & Tags (the mobile Rules & Tags page, the tag picker, the rule editor, preview, log and composer, and the tag
   chips on transaction rows). Ported from the mobile theme keys one for one:
     TagsIconColor / TagsAccentColor ......... --rt-accent      TagsAccentSoftColor / TagsIconBackground ... --rt-accent-soft
     TagsHeroBorderColor ..................... --rt-border      RulesConditionRowColor .................... --rt-row
     TagsButtonDisabled* ..................... --rt-disabled-*  RulesComposer* ............................ --rt-composer-*
     TagsSelectionRowColor ................... --rt-selection   TagSwatch{Key}Color / {Key}SoftColor ....... .tag-c-{key}
   Prefixes: --rt-* tokens, rt- page and dialogs, tag- chips. Shared primitives (tx-btn, tx-field-box, txp-bone) come
   from transaction-popups.css. Dark mode follows data-bs-theme="dark" on <html>.
   ===================================================================================================================== */

:root {
    --rt-accent: #DB2777;
    --rt-accent-soft: #FCE7F3;
    --rt-border: #F5C2DC;
    --rt-row: #F7F8FF;
    --rt-card: #FFFFFF;
    --rt-card-border: hsl(calc(249.6deg + var(--ci-accent-shift, 0deg)) 75.76% 93.53%);
    --rt-selection: rgba(252, 231, 243, .80);
    --rt-disabled-bg: #EEF0F5;
    --rt-disabled-border: #E0E3EB;
    --rt-disabled-text: #A3A8B9;
    --rt-composer-hero: linear-gradient(158deg, hsl(calc(251.43deg + var(--ci-accent-shift, 0deg)) 91.3% 95.49%) 0%, hsl(calc(250deg + var(--ci-accent-shift, 0deg)) 100% 97.65%) 45%, #FCFDFD 100%);
    --rt-composer-border: hsl(calc(256.6deg + var(--ci-accent-shift, 0deg)) 74.6% 87.65%);
    --rt-composer-btn: linear-gradient(135deg, hsl(calc(247.83deg + var(--ci-accent-shift, 0deg)) 76.3% 58.63%) 0%, hsl(calc(262.12deg + var(--ci-accent-shift, 0deg)) 83.26% 57.84%) 100%);
    --rt-composer-btn-text: #FFFFFF;
    --rt-composer-pill-bg: hsl(calc(251.43deg + var(--ci-accent-shift, 0deg)) 91.3% 95.49%);
    --rt-composer-pill-text: hsl(calc(253.7deg + var(--ci-accent-shift, 0deg)) 67.5% 52.94%);
    --rt-band-enabled: var(--rt-accent);
    --rt-band-paused: #565973;
    --rt-band-working: #B45309;
    --rt-band-failed: #FF392B;
    --rt-menu-bg: #FFFFFF;
    --rt-menu-shadow: 0 14px 36px rgba(31, 42, 68, .16);
    --rt-archived-bg: #F3F6FF;
    --rt-archived-text: #565973;
}

[data-bs-theme="dark"] {
    --rt-accent: #F472B6;
    --rt-accent-soft: #3B1F33;
    --rt-border: #4A2440;
    --rt-row: #161A2B;
    --rt-card: transparent;
    --rt-card-border: #2B3045;
    --rt-selection: rgba(59, 31, 51, .70);
    --rt-disabled-bg: #1A1F2E;
    --rt-disabled-border: #2A3042;
    --rt-disabled-text: #5C6378;
    --rt-composer-hero: linear-gradient(158deg, hsl(calc(247.5deg + var(--ci-accent-shift, 0deg)) 40% 23.53%) 0%, hsl(calc(244.29deg + var(--ci-accent-shift, 0deg)) 35% 15.69%) 45%, #0B0F19 100%);
    --rt-composer-border: hsl(calc(256deg + var(--ci-accent-shift, 0deg)) 41.67% 28.24%);
    --rt-composer-btn: linear-gradient(135deg, hsl(calc(247.94deg + var(--ci-accent-shift, 0deg)) 83.95% 68.24%) 0%, hsl(calc(259.82deg + var(--ci-accent-shift, 0deg)) 72.73% 69.8%) 100%);
    --rt-composer-btn-text: #FFFFFF;
    --rt-composer-pill-bg: hsl(calc(246.98deg + var(--ci-accent-shift, 0deg)) 36.75% 22.94%);
    --rt-composer-pill-text: hsl(calc(252.5deg + var(--ci-accent-shift, 0deg)) 94.74% 85.1%);
    --rt-band-paused: #EEEEEE;
    --rt-band-working: #FBBF24;
    --rt-band-failed: #FF392B;
    --rt-menu-bg: #1B2132;
    --rt-menu-shadow: 0 14px 36px rgba(0, 0, 0, .40);
    --rt-archived-bg: #1F2233;
    --rt-archived-text: #EEEEEE;
}

/* ------------------------------------------------------------------ Tag colors (TagSwatch{Key}Color / SoftColor) */

.tag-c-violet { --tag-strong: hsl(calc(247.83deg + var(--ci-accent-shift, 0deg)) 76.3% 58.63%); --tag-soft: hsl(calc(246.92deg + var(--ci-accent-shift, 0deg)) 100% 94.9%); }
.tag-c-blue { --tag-strong: #2563EB; --tag-soft: #DBEAFE; }
.tag-c-aqua { --tag-strong: #0D9488; --tag-soft: #CCFBF1; }
.tag-c-green { --tag-strong: #16A34A; --tag-soft: #DCFCE7; }
.tag-c-amber { --tag-strong: #B45309; --tag-soft: #F6DDB2; }
.tag-c-rose { --tag-strong: #EF4444; --tag-soft: #FEE2E2; }
.tag-c-indigo { --tag-strong: hsl(calc(243.4deg + var(--ci-accent-shift, 0deg)) 75.36% 58.63%); --tag-soft: #E0E7FF; }
.tag-c-slate { --tag-strong: #475569; --tag-soft: #E2E8F0; }
.tag-c-pink { --tag-strong: #DB2777; --tag-soft: #FCE7F3; }

[data-bs-theme="dark"] .tag-c-violet { --tag-strong: hsl(calc(247.94deg + var(--ci-accent-shift, 0deg)) 83.95% 68.24%); --tag-soft: hsl(calc(250.71deg + var(--ci-accent-shift, 0deg)) 35% 15.69%); }
[data-bs-theme="dark"] .tag-c-blue { --tag-strong: #60A5FA; --tag-soft: #1E3354; }
[data-bs-theme="dark"] .tag-c-aqua { --tag-strong: #2DD4BF; --tag-soft: #163A3B; }
[data-bs-theme="dark"] .tag-c-green { --tag-strong: #34D399; --tag-soft: #223A2B; }
[data-bs-theme="dark"] .tag-c-amber { --tag-strong: #F2B557; --tag-soft: #45331A; }
[data-bs-theme="dark"] .tag-c-rose { --tag-strong: #F87171; --tag-soft: #3A1F1F; }
[data-bs-theme="dark"] .tag-c-indigo { --tag-strong: #A5B4FC; --tag-soft: hsl(calc(245.62deg + var(--ci-accent-shift, 0deg)) 44.44% 28.24%); }
[data-bs-theme="dark"] .tag-c-slate { --tag-strong: #94A3B8; --tag-soft: #273041; }
[data-bs-theme="dark"] .tag-c-pink { --tag-strong: #F472B6; --tag-soft: #3B1F33; }

/* ------------------------------------------------------------------ Chips (Controls/Tags/TagChip) */

.tag-chip {
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 96px;
    height: 18px;
    padding: 0 7px;
    border-radius: 10px;
    background: var(--tag-soft);
    color: var(--tag-strong);
    font-family: var(--tx-font);
    font-weight: 500;
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
}

.tag-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tag-chip.tag-chip-lg {
    max-width: 220px;
    height: 26px;
    padding: 0 10px;
    font-size: 12px;
}

.tag-chip.tag-archived {
    background: var(--rt-archived-bg);
    color: var(--rt-archived-text);
}

/* A row's tag line (TagSummary: three chips, then "+N more"). */
.tag-line {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.tag-line-more {
    flex: 0 0 auto;
    font-family: var(--tx-font-text);
    font-size: 10.5px;
    color: var(--tx-muted);
    white-space: nowrap;
}

/* ------------------------------------------------------------------ Shared bits */

.rt-root {
    font-family: var(--tx-font);
    color: var(--tx-text);
}

.rt-chip-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--rt-border);
    border-radius: 12px;
    background: var(--rt-accent-soft);
    color: var(--rt-accent);
    font-size: 15px;
}

.rt-chip-icon.rt-chip-sm {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    font-size: 12px;
}

.rt-help {
    margin: 0;
    font-family: var(--tx-font-text);
    font-size: 12px;
    line-height: 1.45;
    color: var(--tx-muted);
}

.rt-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    font-family: var(--tx-font-text);
    font-size: 12.5px;
    color: var(--tx-amount-expense);
}

.rt-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 10px 10px 16px;
}

.rt-notice-text {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    font-family: var(--tx-font-text);
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--tx-text);
}

.rt-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--tx-border);
    border-radius: 14px;
    background: var(--tx-wrapper);
    color: var(--tx-text);
    font-size: 14px;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, transform .12s ease;
}

.rt-icon-btn:hover:not(:disabled) {
    border-color: var(--rt-border);
}

.rt-icon-btn:active:not(:disabled) {
    transform: scale(.96);
}

.rt-icon-btn:disabled {
    opacity: .5;
    cursor: default;
}

.rt-icon-btn.rt-icon-btn-plain {
    border-color: transparent;
    background: transparent;
    color: var(--tx-muted);
}

.rt-btn-accent {
    background: var(--rt-accent);
    color: #FFFFFF;
}

[data-bs-theme="dark"] .rt-btn-accent {
    color: #0B0F19;
}

.rt-btn-accent:hover:not(:disabled) {
    filter: brightness(1.05);
}

/* The mobile TagPickerFilledButtonStyle: a disabled filled button sinks into a theme-tuned well. */
.rt-btn-filled:disabled {
    border: 1px solid var(--rt-disabled-border);
    background: var(--rt-disabled-bg);
    color: var(--rt-disabled-text);
    opacity: 1;
}

.rt-btn-outline {
    border: 1px solid var(--tx-entry-border);
    background: transparent;
    color: var(--tx-text);
}

.rt-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 0 6px 8px;
    border: 0;
    background: transparent;
    color: var(--rt-accent);
    font-family: var(--tx-font);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
}

.rt-link .tx-glyph {
    font-size: 11px;
}

.rt-link .rt-link-chevron {
    font-size: 9px;
}

.rt-link.rt-link-primary {
    color: var(--tx-primary);
}

.rt-switch {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    width: 44px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 13px;
    background: var(--tx-thumb-off);
    cursor: pointer;
    transition: background-color .18s ease;
}

.rt-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    transition: transform .18s ease, background-color .18s ease;
}

.rt-switch.is-on {
    background: var(--tx-thumb-on);
}

.rt-switch.is-on::after {
    transform: translateX(18px);
    background: var(--tx-thumb);
}

[data-bs-theme="dark"] .rt-switch.is-on::after {
    background: #0B0F19;
}

.rt-switch:disabled {
    opacity: .5;
    cursor: default;
}

@media (prefers-reduced-motion: reduce) {
    .rt-switch,
    .rt-switch::after {
        transition: none;
    }
}

.rt-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--rt-accent-soft);
    border-top-color: var(--rt-accent);
    border-radius: 50%;
    animation: rt-spin .8s linear infinite;
}

@keyframes rt-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .rt-spinner {
        animation-duration: 2.4s;
    }
}

/* ------------------------------------------------------------------ Page (Views/RulesAndTagsPage) */

/* Full width of the admin content area: no max-width. Wide screens get the multi-column grids below. */
.rt-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    min-width: 0;
    padding: 8px 0 32px;
}

.rt-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: start;
    gap: 8px;
}

.rt-head-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rt-head-title h1 {
    margin: 0;
    font-family: var(--tx-font);
    font-weight: 600;
    font-size: 26px;
    color: var(--tx-text);
}

.rt-head-text {
    margin: 4px 0 0;
    font-family: var(--tx-font-text);
    font-size: 14px;
    color: var(--tx-text);
}

.rt-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rt-segments {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.rt-segment {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--rt-card-border);
    border-radius: 20px;
    background: var(--rt-card);
    color: var(--tx-text);
    font-family: var(--tx-font);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.rt-segment .tx-glyph {
    font-size: 13px;
    color: var(--tx-muted);
}

.rt-segment.is-selected {
    border-color: var(--rt-accent);
    background: var(--rt-accent-soft);
}

.rt-segment.is-selected .tx-glyph {
    color: var(--rt-accent);
}

.rt-card {
    padding: 12px 14px;
    border: 1px solid var(--rt-card-border);
    border-radius: 16px;
    background: var(--rt-card);
}

.rt-howto {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 10px;
}

.rt-howto > .tx-glyph {
    margin-top: 2px;
    font-size: 16px;
    color: var(--rt-accent);
}

.rt-howto strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
}

.rt-section-head {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
}

.rt-section-head > .tx-glyph {
    font-size: 16px;
    color: var(--rt-accent);
    text-align: center;
}

.rt-section-head h2 {
    margin: 0;
    font-family: var(--tx-font);
    font-weight: 600;
    font-size: 20px;
    color: var(--tx-text);
}

.rt-count {
    font-family: var(--tx-font-text);
    font-size: 12px;
    color: var(--tx-muted);
}

.rt-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rt-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Rules and tags flow into as many columns as the width allows (auto-fill keeps a lone card at its natural size). */
.rt-list-rules,
.rt-list-tags {
    display: grid;
    gap: 10px;
}

.rt-list-rules {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
}

.rt-list-tags {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

/* How it works, and on Rules the Describe a rule hero beside it. */
.rt-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}

.rt-caution {
    color: var(--tx-caution);
}

.rt-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.rt-empty strong {
    font-weight: 600;
    font-size: 14px;
}

/* "Describe a rule": the AI-violet hero (RulesComposerHeroBrush). */
.rt-describe {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--rt-composer-border);
    border-radius: 16px;
    background: var(--rt-composer-hero);
    color: var(--tx-text);
    text-align: left;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .2s ease;
}

.rt-describe:hover {
    box-shadow: 0 8px 26px hsl(calc(247.83deg + var(--ci-accent-shift, 0deg)) 76.3% 58.63% / .14);
}

.rt-describe:active {
    transform: scale(.99);
}

.rt-describe-art {
    position: relative;
    display: grid;
    place-items: center;
    width: 64px;
    height: 56px;
}

.rt-describe-art > .tx-glyph {
    position: absolute;
    font-size: 46px;
    color: var(--tx-primary);
    opacity: .12;
}

/* The AI page's brain (AiBrainSynapse), scaled into the hero; its own watermark glyph gives way to the hero's. */
.rt-describe-art .ai-brain,
.rt-composer-hero .ai-brain {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 170px;
    height: 150px;
    margin: 0;
    transform: translate(-50%, -50%) scale(.36);
}

.rt-describe-art .ai-brain-glyph,
.rt-composer-hero .ai-brain-glyph {
    display: none;
}

.rt-composer-hero > .rt-describe-art {
    width: 56px;
}

.rt-describe-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.rt-describe-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
    font-size: 16px;
}

.rt-describe-title .tx-glyph {
    font-size: 15px;
    color: var(--tx-primary);
}

.rt-wave {
    background: linear-gradient(90deg, var(--tx-text) 0%, var(--tx-text) 35%, var(--tx-primary) 50%, var(--tx-text) 65%, var(--tx-text) 100%);
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rt-wave 3.2s ease-in-out infinite;
}

@keyframes rt-wave {
    0% { background-position: 100% 0; }
    60%, 100% { background-position: -20% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .rt-wave {
        animation: none;
        color: var(--tx-text);
        background: none;
    }
}

.rt-ai-pill {
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 9px;
    background: var(--rt-composer-pill-bg);
    color: var(--rt-composer-pill-text);
    font-weight: 600;
    font-size: 9px;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.rt-describe-chevron {
    font-size: 12px;
    color: var(--tx-primary);
    opacity: .8;
}

/* A rule row: the 4px band, then name, summary, status and the action chips. */
.rt-rule {
    display: grid;
    grid-template-columns: 4px minmax(0, 1fr);
    overflow: visible;
    border: 1px solid var(--rt-card-border);
    border-radius: 16px;
    background: var(--rt-card);
}

.rt-rule-band {
    border-radius: 16px 0 0 16px;
    background: var(--rt-band-enabled);
}

.rt-rule.is-paused .rt-rule-band { background: var(--rt-band-paused); opacity: .55; }
.rt-rule.is-working .rt-rule-band { background: var(--rt-band-working); }
.rt-rule.is-failed .rt-rule-band { background: var(--rt-band-failed); }

.rt-rule-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 6px;
    padding: 8px 10px;
}

.rt-rule-name {
    overflow: hidden;
    margin: 0;
    font-weight: 600;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-rule-summary {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    font-family: var(--tx-font-text);
    font-size: 12px;
    color: var(--tx-muted);
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.rt-rule-controls {
    display: flex;
    grid-row: span 2;
    align-items: center;
    gap: 2px;
}

.rt-rule-status {
    grid-column: 1 / -1;
    margin: 0;
    font-family: var(--tx-font-text);
    font-size: 12px;
    color: var(--tx-text);
}

.rt-rule.is-working .rt-rule-status { color: var(--tx-caution); }
.rt-rule.is-failed .rt-rule-status { color: var(--tx-amount-expense); }

.rt-rule-chips {
    display: flex;
    flex-wrap: wrap;
    grid-column: 1 / -1;
    align-items: center;
    gap: 4px;
}

.rt-action-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.rt-action-prefix {
    font-weight: 600;
    font-size: 10px;
    color: var(--tx-muted);
}

.rt-action-pill {
    display: inline-flex;
    align-items: center;
    max-width: 180px;
    height: 18px;
    overflow: hidden;
    padding: 0 7px;
    border-radius: 9px;
    background: var(--tx-pill-bg);
    color: var(--tx-pill-text);
    font-weight: 500;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A tag row of the Tags segment. */
.rt-tag-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border: 1px solid var(--rt-card-border);
    border-radius: 16px;
    background: var(--rt-card);
}

.rt-tag-row-meta {
    display: flex;
    flex-direction: column;
    font-family: var(--tx-font-text);
    font-size: 11px;
    color: var(--tx-muted);
}

/* Skeleton rows (SfShimmer): txp-bone bones in the row shapes. */
.rt-skel-rule {
    display: grid;
    grid-template-columns: 4px minmax(0, 1fr);
    border: 1px solid var(--rt-card-border);
    border-radius: 16px;
    background: var(--rt-card);
}

.rt-skel-rule > .txp-bone:first-child {
    height: 100%;
    border-radius: 16px 0 0 16px;
}

.rt-skel-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 12px 12px 10px;
}

.rt-skel-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ------------------------------------------------------------------ Action menu (the mobile action sheets) */

.rt-menu {
    position: relative;
    display: inline-flex;
}

.rt-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: transparent;
}

.rt-menu-list {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 1091;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    margin: 0;
    padding: 6px;
    border: 1px solid var(--tx-border);
    border-radius: 14px;
    background: var(--rt-menu-bg);
    box-shadow: var(--rt-menu-shadow);
    list-style: none;
    animation: rt-menu-in .14s ease-out;
}

.rt-menu-list.rt-menu-up {
    top: auto;
    bottom: calc(100% + 4px);
}

@keyframes rt-menu-in {
    from { opacity: 0; transform: translateY(-4px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.rt-menu-title {
    overflow: hidden;
    padding: 6px 10px 8px;
    font-weight: 600;
    font-size: 12px;
    color: var(--tx-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--tx-text);
    font-family: var(--tx-font);
    font-weight: 500;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}

.rt-menu-item:hover,
.rt-menu-item:focus-visible {
    background: var(--tx-surface);
}

.rt-menu-item .tx-glyph {
    width: 16px;
    font-size: 12.5px;
    color: var(--tx-muted);
    text-align: center;
}

.rt-menu-item.is-critical,
.rt-menu-item.is-critical .tx-glyph {
    color: var(--tx-critical);
}

.rt-menu-sep {
    height: 1px;
    margin: 4px 6px;
    background: var(--tx-border);
}

/* ------------------------------------------------------------------ Dialogs (editor, preview, log, composer, tag) */

.e-dialog.rt-dialog {
    border: 1px solid var(--tx-border);
    border-radius: 16px;
    background: var(--tx-page);
    box-shadow: var(--tx-dialog-shadow);
    overflow: hidden;
}

.e-dialog.rt-dialog .e-dlg-content {
    padding: 0;
    background: var(--tx-page);
    color: var(--tx-text);
    overflow: hidden;
}

.rt-dialog + .e-dlg-overlay {
    background-color: var(--tx-overlay);
}

.e-dlg-container:has(> .rt-dialog) > .e-dlg-overlay {
    background-color: var(--tx-overlay);
}

@media (max-width: 640px) {
    .e-dialog.rt-dialog.rt-dialog-full {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0;
        top: 0 !important;
        left: 0 !important;
    }
}

.rt-dlg {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
    max-height: inherit;
    min-height: 0;
}

.rt-dlg-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    padding: 18px 18px 8px;
}

.rt-dlg-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.rt-dlg-title h2 {
    overflow: hidden;
    margin: 0;
    font-weight: 600;
    font-size: 22px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-dlg-sub {
    grid-column: 1 / -1;
    margin: 0;
    font-family: var(--tx-font-text);
    font-size: 12px;
    line-height: 1.45;
    color: var(--tx-muted);
}

.rt-dlg-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 18px 20px;
    overscroll-behavior: contain;
}

.rt-dlg-foot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 12px 18px 18px;
    border-top: 1px solid var(--tx-border);
    background: var(--tx-page);
}

.rt-dlg-foot.rt-dlg-foot-one {
    grid-template-columns: 1fr;
}

.rt-busy {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--tx-font-text);
    font-size: 13px;
    color: var(--tx-muted);
}

.rt-label {
    margin: 0;
    font-weight: 600;
    font-size: 14px;
    color: var(--tx-text);
}

.rt-input {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--tx-entry-border);
    border-radius: 12px;
    outline: 0;
    background: var(--tx-input-bg);
    color: var(--tx-text);
    font-family: var(--tx-font-text);
    font-size: 14px;
    transition: border-color .15s ease;
}

.rt-input:focus {
    border-color: var(--tx-primary);
}

.rt-input::placeholder {
    color: var(--tx-light-text);
}

/* Pick lists are ChipSelect (chip-select.css); in the rule editor they match the inputs' 46px height and 14px radius. */
.rt-editor .cs-select.tx-field-box {
    border-color: var(--tx-tile-border);
    border-radius: 14px;
}

.rt-editor .cs-select.tx-field-box:focus-within {
    border-color: var(--tx-primary);
}

.rt-input.rt-amount {
    text-align: right;
}

.rt-input.is-invalid {
    border-color: var(--tx-amount-expense);
}

.rt-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rt-section-title {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.rt-section-title > .tx-glyph {
    font-size: 16px;
    color: var(--rt-accent);
    text-align: center;
}

.rt-section-title h3 {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
}

.rt-toggle-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--rt-card-border);
    border-radius: 12px;
    background: var(--rt-row);
}

.rt-toggle-row > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 14px;
}

.rt-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 32px;
}

.rt-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px;
    padding: 8px 10px;
    border: 1px solid var(--rt-card-border);
    border-radius: 12px;
    background: var(--rt-row);
}

.rt-row.has-error {
    border-color: var(--tx-amount-expense);
}

.rt-row-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.rt-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
}

.rt-range {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.rt-multi {
    display: flex;
    flex-direction: column;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 6px;
    border: 1px solid var(--tx-entry-border);
    border-radius: 12px;
    background: var(--tx-input-bg);
}

.rt-multi label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    font-family: var(--tx-font-text);
    font-size: 13px;
    cursor: pointer;
}

.rt-multi input {
    accent-color: var(--tx-primary);
}

.rt-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border: 1px dashed var(--rt-border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--rt-accent-soft) 35%, transparent);
}

.rt-group-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
}

.rt-group-head strong {
    display: block;
    font-weight: 600;
    font-size: 13px;
}

.rt-group-any {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.rt-btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.rt-add-btn {
    justify-self: start;
    border: 1px solid var(--tx-border);
    background: var(--tx-wrapper);
    color: var(--tx-text);
}

.rt-btn-row .rt-add-btn {
    justify-self: stretch;
}

/* The preview sheet's sample rows. */
.rt-sample {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 4px;
    border-bottom: 1px solid var(--tx-border);
}

.rt-sample:last-child {
    border-bottom: 0;
}

.rt-sample-date {
    font-family: var(--tx-font-text);
    font-size: 11.5px;
    color: var(--tx-muted);
}

.rt-sample-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.rt-sample-name {
    overflow: hidden;
    font-weight: 600;
    font-size: 13.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-sample-sub {
    overflow: hidden;
    font-family: var(--tx-font-text);
    font-size: 11.5px;
    color: var(--tx-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-sample-amount {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--tx-negative);
}

.rt-sample-amount.is-inflow {
    color: var(--tx-positive);
}

.rt-pending {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 7px;
    background: var(--tx-caution-soft);
    color: var(--tx-caution);
    font-size: 9.5px;
    font-weight: 600;
}

.rt-preview-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 18px;
}

.rt-preview-count .tx-glyph {
    color: var(--rt-accent);
}

.rt-note {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--tx-pill-bg);
    color: var(--tx-pill-text);
    font-family: var(--tx-font-text);
    font-size: 12px;
}

/* The log. */
.rt-details {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 4px 12px;
    margin: 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--tx-surface);
    font-size: 12.5px;
}

.rt-details dt {
    font-weight: 600;
    color: var(--tx-muted);
}

.rt-details dd {
    margin: 0;
    font-family: var(--tx-font-text);
    color: var(--tx-text);
    overflow-wrap: anywhere;
}

.rt-run {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 10px;
    padding: 9px 2px;
    border-bottom: 1px solid var(--tx-border);
}

.rt-run:last-child {
    border-bottom: 0;
}

.rt-run.is-undone {
    opacity: .5;
}

.rt-run-name {
    overflow: hidden;
    font-weight: 600;
    font-size: 13.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-run-when {
    font-family: var(--tx-font-text);
    font-size: 11.5px;
    color: var(--tx-muted);
    text-align: right;
}

.rt-run-change {
    grid-column: 1 / -1;
    font-family: var(--tx-font-text);
    font-size: 12px;
    color: var(--tx-text);
    overflow-wrap: anywhere;
}

.rt-run-meta {
    display: flex;
    flex-wrap: wrap;
    grid-column: 1 / -1;
    gap: 6px;
}

.rt-run-meta span {
    padding: 1px 7px;
    border-radius: 8px;
    background: var(--tx-surface);
    font-size: 10.5px;
    color: var(--tx-muted);
}

.rt-run-meta .rt-undone {
    background: var(--tx-caution-soft);
    color: var(--tx-caution);
}

/* The composer. */
.rt-composer-hero {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--rt-composer-border);
    border-radius: 16px;
    background: var(--rt-composer-hero);
}

.rt-composer-box {
    position: relative;
}

.rt-composer-box textarea {
    min-height: 96px;
    resize: vertical;
}

.rt-composer-count {
    position: absolute;
    right: 10px;
    bottom: 8px;
    font-family: var(--tx-font-text);
    font-size: 11px;
    color: var(--tx-light-text);
}

.rt-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rt-example {
    padding: 6px 10px;
    border: 1px solid var(--rt-composer-border);
    border-radius: 14px;
    background: transparent;
    color: var(--tx-text);
    font-family: var(--tx-font-text);
    font-size: 12px;
    cursor: pointer;
}

.rt-example:hover {
    background: var(--rt-composer-pill-bg);
}

.rt-btn-ai {
    border: 0;
    background: var(--rt-composer-btn);
    color: var(--rt-composer-btn-text);
}

.rt-thinking {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px 8px;
    text-align: center;
}

.rt-thinking-quote {
    font-family: var(--tx-font-text);
    font-size: 13px;
    font-style: italic;
    color: var(--tx-muted);
}

.rt-thinking-status {
    min-height: 20px;
    font-weight: 600;
    font-size: 14px;
    color: var(--tx-text);
}

.rt-result {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--rt-composer-border);
    border-radius: 14px;
    background: var(--tx-surface);
}

.rt-result h3 {
    margin: 0;
    font-weight: 600;
    font-size: 15px;
}

.rt-result-badge {
    align-self: flex-start;
    padding: 2px 9px;
    border-radius: 9px;
    background: var(--rt-composer-pill-bg);
    color: var(--rt-composer-pill-text);
    font-size: 11px;
    font-weight: 600;
}

.rt-bullets {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding-left: 18px;
    font-family: var(--tx-font-text);
    font-size: 12.5px;
}

.rt-question {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--tx-caution-soft);
    color: var(--tx-text);
    font-family: var(--tx-font-text);
    font-size: 12.5px;
}

.rt-question .tx-glyph {
    color: var(--tx-caution);
}

/* Describe a rule: the tag the rule needs doesn't exist yet (ask before creating it). */
.rt-tag-ask {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--rt-composer-border);
    border-radius: 12px;
    background: var(--rt-composer-pill-bg);
    color: var(--tx-text);
    font-family: var(--tx-font-text);
    font-size: 12.5px;
}

.rt-tag-ask > .tx-glyph {
    margin-top: 2px;
    color: var(--rt-composer-pill-text);
}

.rt-tag-ask-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.rt-tag-ask-names {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rt-tag-ask .rt-result-badge {
    background: var(--tx-surface);
}

.rt-outcome-created .rt-section-title > .tx-glyph {
    color: var(--tx-positive);
}

.rt-outcome-declined .rt-section-title > .tx-glyph {
    color: var(--rt-composer-pill-text);
}

.rt-outcome-failed .rt-section-title > .tx-glyph {
    color: var(--tx-caution);
}

/* Not quite / No / Yes, create it. */
.rt-dlg-foot.rt-dlg-foot-three {
    grid-template-columns: 1fr 1fr 1.4fr;
}

@media (max-width: 420px) {
    .rt-dlg-foot.rt-dlg-foot-three {
        grid-template-columns: 1fr 1fr;
    }

    .rt-dlg-foot.rt-dlg-foot-three > :first-child {
        grid-column: 1 / -1;
        order: 3;
    }
}

/* The tag editor's swatches. */
.rt-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.rt-swatch {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.rt-swatch > span {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 50%;
    background: var(--tag-strong);
    color: #FFFFFF;
    font-size: 10px;
    transition: transform .12s ease, box-shadow .15s ease;
}

.rt-swatch.is-selected > span {
    box-shadow: 0 0 0 2px var(--tx-page), 0 0 0 4px var(--tag-strong);
    transform: scale(1.04);
}

.rt-merge-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rt-merge-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--rt-card-border);
    border-radius: 12px;
    background: var(--rt-card);
    color: var(--tx-text);
    font-size: 12px;
    cursor: pointer;
}

.rt-merge-item:hover {
    border-color: var(--rt-border);
}

/* ------------------------------------------------------------------ The popup's Tags row (Controls/Tags/TransactionTagsRow) */

.rt-tags-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rt-tags-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.rt-tags-tile {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 5px 12px;
    border: 1px solid var(--tx-tile-border);
    border-radius: 12px;
    background: var(--tx-input-bg);
    color: var(--tx-text);
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease;
}

.rt-tags-tile:hover:not(.is-readonly) {
    border-color: var(--rt-border);
}

.rt-tags-tile.is-readonly {
    cursor: default;
}

.rt-tags-flex {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    min-width: 0;
}

.rt-tags-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--tx-font-text);
    font-size: 13px;
    color: var(--tx-light-text);
}

.rt-tags-text.is-error {
    color: var(--tx-amount-expense);
}

.rt-add-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px;
    border-radius: 10px;
    background: var(--rt-accent-soft);
    color: var(--rt-accent);
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
}

.rt-add-pill .tx-glyph {
    font-size: 10px;
}

.rt-picker-host {
    margin-top: 4px;
    padding: 12px;
    border: 1px solid var(--rt-border);
    border-radius: 12px;
    background: var(--tx-input-bg);
    animation: rt-menu-in .16s ease-out;
}

/* ------------------------------------------------------------------ Tag picker (Controls/Tags/TagPickerView) */

.rt-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rt-picker-head {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.rt-picker-head .rt-chip-icon {
    border: 0;
    border-radius: 11px;
}

.rt-picker-head strong {
    display: block;
    font-weight: 600;
    font-size: 15px;
}

.rt-picker-head small {
    font-family: var(--tx-font-text);
    font-size: 11px;
    color: var(--tx-light-text);
}

.rt-search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--tx-entry-border);
    border-radius: 10px;
    background: var(--tx-page);
}

.rt-search:focus-within {
    border-color: var(--tx-primary);
}

.rt-search .tx-glyph {
    font-size: 12px;
    color: var(--tx-light-text);
}

.rt-search input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--tx-text);
    font-family: var(--tx-font-text);
    font-size: 14px;
}

.rt-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* A picker pill (TagPickerPill): All is filled in the soft shade; Some and None are outlined in the swatch. */
.rt-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--tag-strong);
    border-radius: 10px;
    background: transparent;
    color: var(--tx-text);
    font-family: var(--tx-font);
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, transform .12s ease;
}

.rt-pill .tx-glyph {
    font-size: 10px;
    color: var(--tag-strong);
}

.rt-pill > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-pill.is-all {
    border-color: var(--tag-soft);
    background: var(--tag-soft);
    color: var(--tag-strong);
}

.rt-pill.is-some {
    color: var(--tag-strong);
}

.rt-pill:active {
    transform: scale(.97);
}

.rt-pill:disabled {
    opacity: .55;
    cursor: default;
}

.rt-restore {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--rt-accent-soft);
    font-weight: 500;
    font-size: 13px;
}

.rt-new-tag {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rt-caption {
    margin: 0;
    font-family: var(--tx-font-text);
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--tx-text);
    opacity: .7;
}

.rt-new-tag-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.rt-new-tag-row .rt-input {
    min-height: 38px;
    border-radius: 10px;
    background: var(--tx-page);
}

.rt-new-tag-row .tx-btn {
    min-height: 38px;
    border-radius: 10px;
}

.rt-picker-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.rt-picker-actions .tx-btn {
    min-height: 38px;
    border-radius: 15px;
}

/* ------------------------------------------------------------------ The popup's Rules section */

.rt-rules-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rt-rules-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
}

.rt-rule-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rt-rule-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 210px;
    height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: 14px;
    background: var(--tx-pill-bg);
    color: var(--tx-pill-text);
    font-family: var(--tx-font);
    font-weight: 500;
    font-size: 11.5px;
    cursor: pointer;
}

.rt-rule-pill .tx-glyph {
    font-size: 10px;
}

.rt-rule-pill > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-create-rule {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--tx-text);
    text-align: left;
    cursor: pointer;
}

.rt-create-rule-badge {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 17px;
    background: var(--tx-pill-bg);
    color: var(--tx-primary);
    font-size: 13px;
}

.rt-create-rule-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.rt-create-rule-text strong {
    overflow: hidden;
    font-weight: 600;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-create-rule-text small {
    font-family: var(--tx-font-text);
    font-size: 11px;
    color: var(--tx-muted);
}

.rt-create-rule > .tx-glyph {
    font-size: 11px;
    color: var(--tx-primary);
    opacity: .75;
}

/* ------------------------------------------------------------------ Transactions grid: tag filter, selection bar */

.rt-grid-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.rt-grid-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.rt-filter {
    position: relative;
}

.rt-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 4px 12px;
    border: 1px solid var(--tx-border);
    border-radius: 17px;
    background: var(--tx-wrapper);
    color: var(--tx-text);
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
}

.rt-filter-btn .tx-glyph {
    color: var(--rt-accent);
}

.rt-filter-btn.is-active {
    border-color: var(--rt-accent);
    background: var(--rt-accent-soft);
}

.rt-filter-badge {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--rt-accent);
    color: #FFFFFF;
    font-size: 10.5px;
    font-weight: 600;
}

/* The Tags button sits at the right end of the Transactions filter bar, so the panel hangs from the button's right edge
   and opens leftward; a left anchor pushed it past the viewport. Phones get a bottom sheet (below). */
.rt-filter-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    z-index: 1091;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    padding: 12px;
    border: 1px solid var(--tx-border);
    border-radius: 14px;
    background: var(--rt-menu-bg);
    box-shadow: var(--rt-menu-shadow);
    animation: rt-menu-in .14s ease-out;
}

.rt-filter-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

/* Phones: the panel is a bottom sheet across the screen, so it never runs off either side whatever the button's position. */
@media (max-width: 575.98px) {
    .rt-filter-panel {
        position: fixed;
        top: auto;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        left: 12px;
        width: auto;
        max-height: min(70vh, 520px);
        overflow-y: auto;
        border-radius: 18px;
    }
}

.rt-selection-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px 12px;
    border: 1px solid var(--rt-border);
    border-radius: 14px;
    background: var(--rt-selection);
    color: var(--tx-text);
    font-weight: 600;
    font-size: 13.5px;
}

.rt-selection-bar > div {
    display: flex;
    gap: 8px;
}

.admin-transactions-grid .e-row.e-active td,
.admin-transactions-grid .e-row[aria-selected="true"] td {
    background-color: var(--rt-selection) !important;
}

/* Tablet and up: the segment control stops stretching across the page. */
@media (min-width: 768px) {
    .rt-segments {
        grid-template-columns: repeat(2, minmax(160px, 220px));
        justify-content: start;
    }
}

/* Desktop: How it works and Describe a rule share a row. */
@media (min-width: 992px) {
    .rt-intro.has-describe {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    .rt-intro.has-describe > .rt-card {
        align-content: center;
    }
}

/* Wide desktop: a little more air around the page and between the cards. */
@media (min-width: 1400px) {
    .rt-page {
        gap: 20px;
    }

    .rt-list-rules,
    .rt-list-tags {
        gap: 12px;
    }

    .rt-list-rules {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
    }
}

@media (max-width: 640px) {
    .rt-head {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .rt-head-actions {
        grid-column: 2;
        grid-row: 1;
    }

    .rt-describe {
        grid-template-columns: 48px minmax(0, 1fr) auto;
    }

    .rt-describe-art {
        width: 48px;
    }

    .rt-pair,
    .rt-btn-row {
        grid-template-columns: 1fr;
    }

    .rt-options {
        padding-left: 0;
    }
}

/* Dashboard recent activity: the row's tag line sits under the date, on its own line. */
.dbx-tx-tags {
    flex-basis: 100%;
    margin-top: 4px;
}

.dbx-tx-tags:empty {
    display: none;
}

/* The button group sits in the section header, right of the "7 of 50" count (like the rest of the site's section actions). */
.rt-section-actions { display: inline-flex; align-items: center; gap: 8px; margin-left: 6px; }
.rt-icon-btn.rt-icon-btn-sm { width: 34px; height: 34px; border-radius: 12px; font-size: 13px; }
.rt-new-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    background: var(--rt-accent);
    color: #fff;
    font-family: var(--tx-font);
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 8px 18px -10px var(--rt-accent);
    transition: filter .15s ease, transform .12s ease;
}
.rt-new-btn:hover:not(:disabled) { filter: brightness(1.06); }
.rt-new-btn:active:not(:disabled) { transform: scale(.97); }
.rt-new-btn:focus-visible { outline: 2px solid var(--rt-accent); outline-offset: 2px; }
.rt-new-btn:disabled { opacity: .5; cursor: default; }
[data-bs-theme="dark"] .rt-new-btn { color: #1B0F17; }

@media (max-width: 575.98px) {
    .rt-section-head { grid-template-columns: 24px minmax(0, 1fr) auto; }
    .rt-section-head .rt-section-actions { grid-column: 1 / -1; justify-content: flex-end; margin-left: 0; }
}

/* ------------------------------------------------------------------ Rule editor (TransactionRuleEditorDialog)
   The mobile TransactionRuleEditorPopup's layout: the live rule card in the header, then carded sections on the page
   color (TxPopupSurface), each with a 40px icon tile, title, subtitle and a count pill; an All / Any segmented choice
   (SegmentedMenu* -> --tx-seg-*) instead of a switch; AND / OR chips between rows and groups; dashed group brackets;
   accent add tiles. Scoped to .rt-editor so the other Rules & Tags dialogs keep their look. */

.rt-editor .rt-dlg-head {
    row-gap: 14px;
    padding: 20px 20px 12px;
}

.rt-editor .rt-dlg-body {
    gap: 18px;
    padding: 8px 20px 28px;
}

/* The editor's fields: no box of its own (the cards stay children of the body's column), disabled as one when the rule
   uses an action this version can't edit. */
.rt-fieldset {
    display: contents;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.rt-fieldset:disabled .rt-card {
    opacity: 0.72;
}

.rt-editor .rt-dlg-foot {
    padding: 14px 20px 20px;
}

/* The live rule card: WHEN and THEN lines of chips. */
.rt-rule-card {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 168px;
    overflow-y: auto;
    padding: 12px 14px;
    border: 1px solid var(--rt-border);
    border-radius: 16px;
    background: linear-gradient(158deg, color-mix(in srgb, var(--rt-accent-soft) 70%, transparent) 0%, var(--tx-surface) 60%);
    overscroll-behavior: contain;
}

.rt-rule-line {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
}

.rt-rule-key {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    font-weight: 600;
    font-size: 10.5px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--rt-accent);
}

.rt-rule-key.is-then {
    color: var(--tx-primary);
}

.rt-rule-key > .tx-glyph {
    font-size: 11px;
}

.rt-rule-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.rt-rule-chip {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    min-height: 28px;
    padding: 3px 10px;
    border: 1px solid var(--tx-tile-border);
    border-radius: 10px;
    background: var(--tx-hero-tile);
    font-family: var(--tx-font-text);
    font-size: 12.5px;
    line-height: 1.35;
    color: var(--tx-muted);
    overflow-wrap: anywhere;
}

.rt-rule-chip.is-empty {
    border-style: dashed;
    background: transparent;
    color: var(--tx-light-text);
}

.rt-rule-icon {
    font-size: 11px;
    color: var(--rt-accent);
}

.rt-rule-chip.is-action .rt-rule-icon {
    color: var(--tx-primary);
}

.rt-rule-field {
    font-weight: 600;
    color: var(--tx-text);
}

.rt-rule-value {
    font-weight: 600;
    color: var(--tx-text);
}

.rt-rule-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 6px 4px 8px;
    border: 1.5px dashed var(--tx-tile-border);
    border-radius: 12px;
}

.rt-rule-group-icon {
    font-size: 11px;
    color: var(--tx-pill-text);
}

.rt-rule-join,
.rt-join > span {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-family: var(--tx-font);
    font-weight: 600;
    font-size: 10px;
    letter-spacing: .08em;
}

.rt-rule-join.is-and,
.rt-join.is-and > span {
    background: color-mix(in srgb, var(--tx-primary) 14%, transparent);
    color: var(--tx-primary);
}

.rt-rule-join.is-or,
.rt-join.is-or > span {
    background: var(--rt-accent-soft);
    color: var(--rt-accent);
}

/* Section cards. */
.rt-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border-radius: 20px;
    background: var(--tx-surface);
}

.rt-card-head {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.rt-card-head h3 {
    margin: 0;
    font-weight: 600;
    font-size: 17px;
    color: var(--tx-text);
}

.rt-card-head p {
    margin: 2px 0 0;
    font-family: var(--tx-font-text);
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--tx-muted);
}

.rt-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 13px;
    font-size: 16px;
}

.rt-card-icon.is-when {
    background: var(--rt-accent-soft);
    color: var(--rt-accent);
}

.rt-card-icon.is-then {
    background: var(--tx-pill-bg);
    color: var(--tx-pill-text);
}

.rt-card-icon.is-options {
    background: var(--tx-tile-bg);
    color: var(--tx-muted);
}

.rt-count-pill {
    align-self: start;
    padding: 4px 9px;
    border-radius: 10px;
    background: var(--tx-tile-bg);
    font-weight: 600;
    font-size: 11px;
    color: var(--tx-muted);
    white-space: nowrap;
}

.rt-caption {
    margin: 0;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--tx-muted);
}

.rt-editor .rt-card > .rt-caption {
    margin-bottom: -8px;
}

.rt-input-icon {
    position: relative;
}

.rt-input-icon > .tx-glyph {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--tx-light-text);
    pointer-events: none;
}

.rt-input-icon > .rt-input {
    padding-left: 38px;
}

.rt-editor .rt-input {
    min-height: 46px;
    border-color: var(--tx-tile-border);
    border-radius: 14px;
    font-size: 14.5px;
}

.rt-editor .rt-input:focus {
    border-color: var(--tx-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tx-primary) 18%, transparent);
}

/* All / Any: the segmented track. */
.rt-match {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rt-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--tx-tile-border);
    border-radius: 15px;
    background: var(--tx-seg-track);
}

.rt-choice-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    height: 40px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    font-family: var(--tx-font-text);
    font-size: 13.5px;
    color: var(--tx-seg-text);
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.rt-choice-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-choice-chip > .tx-glyph {
    font-size: 12px;
}

.rt-choice-chip:hover:not(.is-selected) {
    color: var(--tx-text);
}

.rt-choice-chip:focus-visible {
    outline: 2px solid var(--tx-primary);
    outline-offset: 1px;
}

.rt-choice-chip.is-selected {
    border-color: var(--tx-seg-pill-border);
    background: var(--tx-seg-pill);
    box-shadow: 0 2px 8px var(--tx-seg-pill-shadow);
    font-family: var(--tx-font);
    font-weight: 600;
    color: var(--tx-seg-selected-text);
}

.rt-choice-chip.is-selected > .tx-glyph {
    color: var(--tx-seg-selected-glyph);
}

.rt-choice.is-compact .rt-choice-chip {
    height: 34px;
    font-size: 13px;
}

/* Rows and the AND / OR chips between them. */
.rt-rows {
    display: flex;
    flex-direction: column;
}

.rt-rows.is-spaced {
    gap: 12px;
}

.rt-join {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    height: 36px;
}

.rt-join::before,
.rt-join::after {
    content: "";
    height: 1px;
    background: var(--tx-tile-border);
}

.rt-join > span {
    grid-column: 2;
    grid-row: 1;
}

.rt-join::after {
    grid-column: 3;
    grid-row: 1;
}

.rt-editor .rt-row {
    gap: 8px;
    padding: 12px 10px 12px 14px;
    border-color: var(--tx-tile-border);
    border-radius: 16px;
    background: var(--tx-hero-tile);
}

.rt-editor .rt-row.has-error {
    border-color: var(--tx-amount-expense);
}

.rt-editor .rt-row-fields {
    gap: 10px;
}

.rt-editor .rt-pair {
    gap: 8px;
}

.rt-editor .rt-row > .rt-icon-btn {
    align-self: start;
}

/* Groups: a dashed bracket with its own All / Any. */
.rt-group-wrap {
    display: flex;
    flex-direction: column;
}

.rt-editor .rt-group {
    gap: 12px;
    padding: 14px 14px 16px;
    border: 1.5px dashed var(--tx-tile-border);
    border-radius: 18px;
    background: transparent;
}

.rt-editor .rt-group-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
}

.rt-group-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: var(--tx-pill-bg);
    color: var(--tx-pill-text);
    font-size: 13px;
}

.rt-editor .rt-group-head strong {
    font-size: 14px;
}

.rt-editor .rt-group-head span:not(.rt-group-icon) {
    display: block;
    font-family: var(--tx-font-text);
    font-size: 11.5px;
    color: var(--tx-muted);
}

/* Add condition / group / action: a quiet tile with an accent plus; dimmed at the limit. */
.rt-add-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.rt-add-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--tx-tile-border);
    border-radius: 14px;
    background: var(--tx-hero-tile);
    font-family: var(--tx-font);
    font-weight: 600;
    font-size: 14px;
    color: var(--tx-primary);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.rt-add-tile:hover:not(:disabled) {
    border-color: var(--tx-primary);
}

.rt-add-tile:disabled {
    opacity: .45;
    cursor: default;
}

.rt-add-tile > .tx-glyph {
    font-size: 13px;
}

.rt-add-tile.is-inline {
    justify-self: start;
    align-self: flex-start;
}

.rt-add-tile.is-full {
    width: 100%;
}

.rt-add-note {
    margin-top: -8px;
    padding-left: 2px;
}

/* Options: icon, words, switch; hairline between. */
.rt-option-list {
    display: flex;
    flex-direction: column;
}

.rt-option {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    min-height: 56px;
    padding: 10px 0;
}

.rt-option + .rt-option {
    border-top: 1px solid var(--tx-tile-border);
}

.rt-option > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.rt-option-title {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--tx-text);
}

.rt-option-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--tx-tile-bg);
    color: var(--tx-muted);
    font-size: 13px;
}

@media (max-width: 640px) {
    .rt-editor .rt-dlg-head {
        padding: 16px 16px 10px;
    }

    .rt-editor .rt-dlg-body {
        gap: 16px;
        padding: 6px 16px 24px;
    }

    .rt-card {
        padding: 16px;
    }

    .rt-rule-line {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .rt-rule-key {
        min-height: 0;
    }

    .rt-editor .rt-pair {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rt-choice-chip,
    .rt-add-tile {
        transition: none;
    }
}
