/**
 * Farasync v1.0.0 (Phase 2) — Rewards tab styles.
 * Scoped under .farasync-rw-* so nothing leaks into other tabs.
 */

.farasync-rw-card {
    background: #fff;
    border: 1px solid #e2e6ec;
    border-radius: 10px;
    padding: 14px 18px 16px;
    margin: 0 0 16px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.farasync-rw-card > h3 {
    margin: .2em 0 .5em;
    font-size: 15px;
}

/* Master switch card */
.farasync-rw-master {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.farasync-rw-master .farasync-rw-hint {
    flex-basis: 100%;
    color: #64748b;
    font-size: 12px;
    line-height: 1.9;
}

.farasync-rw-banner p {
    margin: 8px 12px;
}

/* Tier tables */
.farasync-rw-tiers td,
.farasync-rw-tiers th {
    vertical-align: middle;
}
.farasync-rw-tiers .farasync-rw-tier-del {
    color: #b32d2e;
    text-decoration: none;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.farasync-rw-tiers.is-readonly td {
    color: #334155;
}

/* v1.0.0 — money inputs: bigger, readable, thousands-grouped (LTR digits
   inside the RTL page). Applies to tier min/reward + approval amounts. */
.farasync-rw-num {
    font-size: 15px !important;
    line-height: 1.5 !important;
    min-width: 170px;
    width: 170px;
    max-width: 100%;
    padding: 6px 10px !important;
    height: auto !important;
    border: 1px solid #cdd5e0 !important;
    border-radius: 7px !important;
    background: #fff !important;
    box-shadow: none !important;
    text-align: left;
    letter-spacing: .3px;
}
.farasync-rw-num:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .15) !important;
    outline: none;
}
.farasync-rw-num:disabled {
    background: #f6f7f9 !important;
    color: #94a3b8 !important;
}
@media (max-width: 600px) {
    .farasync-rw-num {
        width: 100%;
        min-width: 0;
    }
}

/* v1.0.0 — money input + currency-unit suffix (تومان/ریال) as one field */
.farasync-rw-money {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
}
.farasync-rw-money .farasync-rw-num {
    flex: 1 1 auto;
    width: 200px;
}
.farasync-rw-unit {
    color: #475569;
    font-size: 12.5px;
    font-weight: 600;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 3px 9px;
    white-space: nowrap;
    line-height: 1.7;
}

/* v1.0.0 — «از امروز به مدت [X] ماه» quick-set row */
.farasync-range-month-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.farasync-range-month-label {
    color: #475569;
    font-size: 12.5px;
    font-weight: 600;
}
.farasync-range-month-wrap select.farasync-range-month {
    min-width: 130px;
    border-radius: 6px;
    border-color: #cdd5e0;
    padding: 3px 26px 3px 10px;
    height: auto;
}
.farasync-range-month-unit {
    color: #64748b;
    font-size: 12px;
}

.farasync-rw-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0 0;
}
.farasync-rw-actions .description {
    margin: 0;
}
.farasync-rw-danger {
    border-top: 1px dashed #f0d7d7;
    padding-top: 10px;
    margin-top: 14px;
}

/* v1.0.0 (user request): lifecycle buttons — the ORANGE
   «پایان زودهنگام» marks a logical state change (deadline flow by
   hand) and sits FIRST; the RED «لغو کمپین» marks destruction and
   sits a beat away (extra gap) so a mis-click is unlikely. Tooltips
   are the server-rendered title attributes on the buttons. */
.farasync-rw-actions .button.farasync-rw-btn-finish,
.farasync-rw-actions .button.farasync-rw-btn-cancel {
    color: #fff;
    border-radius: 6px;
}
.farasync-rw-actions .button.farasync-rw-btn-finish {
    background: #f08300;
    border-color: #d97a00;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.farasync-rw-actions .button.farasync-rw-btn-finish:hover,
.farasync-rw-actions .button.farasync-rw-btn-finish:focus-visible {
    background: #d97a00;
    border-color: #c56e00;
    color: #fff;
}
.farasync-rw-actions .button.farasync-rw-btn-finish:disabled,
.farasync-rw-actions .button.farasync-rw-btn-finish[disabled] {
    background: #f08300;
    border-color: #d97a00;
    color: rgba(255, 255, 255, 0.75);
    opacity: 0.75;
}
.farasync-rw-btn-finish + .farasync-rw-btn-cancel {
    margin-inline-start: 18px;
}
.farasync-rw-actions .button.farasync-rw-btn-cancel {
    background: #d63638;
    border-color: #c02f31;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.farasync-rw-actions .button.farasync-rw-btn-cancel:hover,
.farasync-rw-actions .button.farasync-rw-btn-cancel:focus-visible {
    background: #b32d2e;
    border-color: #9c2627;
    color: #fff;
}
.farasync-rw-actions .button.farasync-rw-btn-cancel:disabled,
.farasync-rw-actions .button.farasync-rw-btn-cancel[disabled] {
    background: #d63638;
    border-color: #c02f31;
    color: rgba(255, 255, 255, 0.75);
    opacity: 0.75;
}

/* Campaign card */
.farasync-rw-camp-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.farasync-rw-camp-head h3 {
    margin: 0;
    font-size: 16px;
}
.farasync-rw-window {
    color: #475569;
    margin: 6px 0 10px;
}
.farasync-rw-live {
    background: #f0f7ff;
    border: 1px solid #d7e8ff;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 10px 0;
}
.farasync-rw-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.8;
}
.farasync-rw-status.is-scheduled { background: #eef2ff; color: #4338ca; }
.farasync-rw-status.is-running   { background: #dcfce7; color: #15803d; }
.farasync-rw-status.is-ended     { background: #fff7ed; color: #c2410c; }
.farasync-rw-status.is-closed    { background: #f1f5f9; color: #475569; }
.farasync-rw-status.is-cancelled { background: #fee2e2; color: #b91c1c; }

.farasync-rw-badge {
    display: inline-block;
    margin-inline-start: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
}
.farasync-rw-badge.is-approved { background: #dcfce7; color: #15803d; }
.farasync-rw-badge.is-rejected { background: #fee2e2; color: #b91c1c; }

/* Approval queue */
.farasync-rw-queue td,
.farasync-rw-queue th {
    vertical-align: top;
}
.farasync-rw-queue .description {
    display: block;
    margin-top: 2px;
}
.farasync-rw-detail summary {
    cursor: pointer;
    color: #2563eb;
    font-size: 12px;
    margin-top: 4px;
}
.farasync-rw-detail ul {
    margin: 4px 0 0;
    padding-inline-start: 16px;
    font-size: 12px;
    color: #475569;
}

/* v1.0.0 (user request): row-click selection for the approval queue —
   pending rows carry .farasync-rw-selectable (whole row is one big click
   target instead of the tiny checkbox) and .is-selected when picked:
   indigo wash + an inset bar on the inline-start edge, clearly visible
   over the WP striped zebra. td-level background because .striped paints
   the row itself and td wins the cascade. */
.farasync-rw-queue tbody tr.farasync-rw-selectable {
    cursor: pointer;
}
.farasync-rw-queue tbody tr.farasync-rw-selectable td:first-child {
    position: relative;
}
.farasync-rw-queue tbody tr.farasync-rw-selectable.is-selected td {
    background: #eef2ff !important;
}
.farasync-rw-queue tbody tr.farasync-rw-selectable.is-selected td:first-child::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #4f46e5;
    border-radius: 0 3px 3px 0;
}
[dir="ltr"] .farasync-rw-queue tbody tr.farasync-rw-selectable.is-selected td:first-child::before {
    border-radius: 3px 0 0 3px;
}
/* the checkbox itself grows to a comfortable tap target */
.farasync-rw-queue .farasync-rw-pick {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* History */
.farasync-rw-history td,
.farasync-rw-history th {
    vertical-align: middle;
}

/* Health */
.farasync-rw-health-out {
    white-space: pre-line;
    font-size: 13px;
    line-height: 2;
    margin-top: 6px;
}
.farasync-rw-health-out.is-ok  { color: #15803d; }
.farasync-rw-health-out.is-err { color: #b91c1c; }

/* Toast */
.farasync-rw-toast {
    position: fixed;
    bottom: 22px;
    inset-inline-start: 50%;
    transform: translateX(50%);
    background: #111827;
    color: #f9fafb;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    z-index: 99999;
    max-width: 80vw;
}
.farasync-rw-toast.is-visible { opacity: 1; }
.farasync-rw-toast.is-err { background: #7f1d1d; }

/* ----------------------------------------------------------------------
   v1.0.0 — MOBILE (user request: «این تب پاداش‌ها هم در حالت موبایل مرتب
   و منظم کن») — tidy phone layout: full-width cards, stacked form rows,
   scrollable wide tables, tap-friendly buttons.
   ---------------------------------------------------------------------- */
@media (max-width: 782px) {
    .farasync-rw-card {
        padding: 12px 12px 14px;
        border-radius: 9px;
        margin-bottom: 12px;
    }
    .farasync-rw-card > h3 {
        font-size: 14.5px;
    }
    .farasync-rw-master {
        gap: 8px;
    }
    .farasync-rw-master .farasync-rw-hint {
        font-size: 11.5px;
    }

    /* form-table rows stack: label above the field */
    .farasync-rw-card .form-table,
    .farasync-rw-card .form-table tbody {
        display: block;
        width: 100%;
    }
    .farasync-rw-card .form-table tr {
        display: block;
        margin: 0 0 14px;
    }
    .farasync-rw-card .form-table th,
    .farasync-rw-card .form-table td {
        display: block;
        width: 100%;
        padding: 0 0 6px;
    }
    .farasync-rw-card .form-table td .description {
        display: block;
        margin-top: 4px;
        line-height: 1.8;
    }
    #farasync-rw-new-name {
        width: 100% !important;
        max-width: 100% !important;
    }
    input[type="date"]#farasync-rw-new-from,
    input[type="date"]#farasync-rw-new-to {
        width: 100%;
        max-width: 100%;
        min-height: 40px;
    }

    /* wide tables get a tidy horizontal scroll instead of squeezing
       (queue only — tiers & history reflow into cards below, v1.0.0) */
    .farasync-rw-queue {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .farasync-rw-queue tbody {
        display: table;
        width: max-content;
        min-width: 100%;
        border-collapse: collapse;
    }
    .farasync-rw-queue .farasync-rw-amt {
        width: 130px;
        min-width: 130px;
    }

    /* --------------------------------------------------------------
       v1.0.0 (user report: «در حالت موبایل مناسب نیست») — «سطوح این
       کمپین» tiers become one card per tier: captioned stacked fields
       + a 32px round delete button pinned to the free corner (same X
       family as the fullscreen sheets). Server rows AND JS-added rows
       both carry data-label, so captions come from CSS attr().
       -------------------------------------------------------------- */
    .farasync-rw-tiers {
        display: block;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        overflow: visible;
    }
    .farasync-rw-tiers thead {
        display: none !important;
    }
    .farasync-rw-tiers tbody {
        display: block;
        width: 100%;
    }
    .farasync-rw-tiers tbody tr,
    .farasync-rw-card .form-table .farasync-rw-tiers tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 32px;
        grid-template-areas:
            "min del"
            "reward del";
        align-content: start;
        column-gap: 10px;
        background: #fff !important;
        border: 1px solid #e2e6ec;
        border-radius: 10px;
        padding: 10px 12px 12px;
        margin: 0 0 10px;
        box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    }
    .farasync-rw-tiers tbody tr td {
        display: block;
        width: 100%;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }
    .farasync-rw-tiers td:nth-child(1) { grid-area: min; }
    .farasync-rw-tiers td:nth-child(2) { grid-area: reward; margin-top: 10px; }
    .farasync-rw-tiers td.farasync-rw-tier-act {
        grid-area: del;
        justify-self: end;
        align-self: start;
    }
    .farasync-rw-tiers td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin: 0 2px 5px;
        color: #64748b;
        font-size: 11.5px;
        font-weight: 600;
    }
    /* tier rows keep inputs stacked but roomy */
    .farasync-rw-money {
        display: flex;
    }
    .farasync-rw-money .farasync-rw-num {
        width: 100%;
        min-width: 120px;
        font-size: 16px !important;
        padding: 8px 10px !important;
    }
    /* delete button: 32px family X (tap-friendly, mirrors the sheets) */
    .farasync-rw-tiers .farasync-rw-tier-del {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        padding: 0;
        border: 1px solid rgba(225, 29, 72, .28);
        border-radius: 999px;
        background: rgba(225, 29, 72, .07);
        color: #e11d48;
        font-size: 17px;
        line-height: 1;
        cursor: pointer;
    }
    .farasync-rw-tiers .farasync-rw-tier-del:hover {
        background: #e11d48;
        border-color: #e11d48;
        color: #fff;
    }
    /* read-only tier cards: single column, dashed divider between fields */
    .farasync-rw-tiers.is-readonly tbody tr {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "min"
            "reward";
    }
    .farasync-rw-tiers.is-readonly tbody tr td:nth-child(2) {
        margin-top: 8px;
        padding-top: 8px !important;
        border-top: 1px dashed #edf0f5 !important;
    }
    .farasync-rw-tiers.is-readonly td[data-label]::before {
        margin-bottom: 1px;
    }

    /* --------------------------------------------------------------
       v1.0.0 — «تاریخچهٔ کمپین‌ها» becomes one card per campaign:
       the name is the card title, every other cell gets its column
       caption from data-label. The whole card stays tappable for the
       winners-details sheet (is-openable rows).
       -------------------------------------------------------------- */
    .farasync-rw-history {
        display: block;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        overflow: visible;
    }
    .farasync-rw-history thead {
        display: none !important;
    }
    .farasync-rw-history tbody {
        display: block;
        width: 100%;
    }
    .farasync-rw-history tbody tr {
        display: block;
        background: #fff !important;
        border: 1px solid #e2e6ec;
        border-radius: 10px;
        padding: 10px 12px 8px;
        margin: 0 0 10px;
        box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    }
    .farasync-rw-history tbody tr td {
        display: block;
        width: 100%;
        padding: 3px 0 !important;
        border: 0 !important;
        background: transparent !important;
        font-size: 12.5px;
    }
    .farasync-rw-history tbody tr td::before {
        content: attr(data-label) ':';
        color: #64748b;
        font-weight: 600;
        margin-inline-end: 6px;
        font-size: 11.5px;
    }
    .farasync-rw-history td.farasync-rw-h-name {
        font-size: 13.5px;
        padding-bottom: 5px !important;
        border-bottom: 1px dashed #edf0f5 !important;
        margin-bottom: 4px;
    }
    .farasync-rw-history td.farasync-rw-h-name::before {
        content: none;
    }
    .farasync-rw-history tr.is-openable {
        border-inline-start: 3px solid #6366f1;
        cursor: pointer;
    }
    .farasync-rw-history tr.is-openable:active {
        background: #f5f6ff !important;
    }

    /* actions: big tap targets, wrap neatly */
    .farasync-rw-actions {
        gap: 6px;
    }
    .farasync-rw-actions .button {
        min-height: 38px;
    }
    .farasync-rw-actions .button.button-primary,
    #farasync-rw-create {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .farasync-rw-toast {
        max-width: calc(100vw - 28px);
        bottom: 14px;
        text-align: center;
    }
}
@media (max-width: 380px) {
    .farasync-rw-card {
        padding: 10px 9px 12px;
    }
    .farasync-rw-unit {
        font-size: 11.5px;
        padding: 2px 7px;
    }
}

/* ----------------------------------------------------------------------
   Representative panel boxes (front-end) — kept in the same file so the
   admin package ships one rewards stylesheet. Scoped .farasync-rw-rep-*.
   ---------------------------------------------------------------------- */

.farasync-rw-rep {
    margin: 0 0 18px;
    display: grid;
    gap: 12px;
}

.farasync-rw-rep-credit,
.farasync-rw-rep-progress {
    background: linear-gradient(135deg, #101a33 0%, #1b2b52 100%);
    color: #e8eefc;
    border-radius: 14px;
    padding: 16px 20px;
    box-shadow: 0 6px 18px rgba(16, 26, 51, .18);
}

.farasync-rw-rep-credit {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.farasync-rw-rep-credit-icon {
    font-size: 22px;
    line-height: 1.2;
    color: #f5c66b;
}
.farasync-rw-rep-credit-body {
    display: grid;
    gap: 2px;
}
.farasync-rw-rep-credit-num {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .2px;
}
.farasync-rw-rep-credit-label {
    font-size: 13px;
    opacity: .85;
}
.farasync-rw-rep-credit-hint {
    font-size: 12px;
    opacity: .65;
    line-height: 1.9;
    margin-top: 4px;
}

.farasync-rw-rep-progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 15px;
    font-weight: 700;
}
.farasync-rw-rep-window {
    font-size: 12px;
    font-weight: 400;
    opacity: .7;
}
.farasync-rw-rep-bar {
    position: relative;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    overflow: hidden;
    margin: 12px 0 10px;
}
.farasync-rw-rep-bar-fill {
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #f5c66b, #f0a94e);
    transition: width .5s ease;
}
.farasync-rw-rep-stats,
.farasync-rw-rep-next {
    margin: 0;
    font-size: 13px;
    opacity: .85;
    line-height: 2;
}
.farasync-rw-rep-next.is-done {
    color: #f5c66b;
    opacity: 1;
    font-weight: 600;
}

/* ======================================================================
   v1.0.0 — campaign-history details modal + the clickable history row
   ====================================================================== */
.farasync-rw-history-row.is-openable {
    cursor: pointer;
    transition: background .12s ease;
}
.farasync-rw-history-row.is-openable:hover {
    background: #eff6ff;
}
.farasync-rw-history-row.is-openable:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}
.farasync-rw-history-row.is-openable .farasync-rw-history-winners:hover {
    background: linear-gradient(135deg, #ffd88a, #f2b94e);
}
.farasync-rw-history-winners {
    display: inline-block;
    margin-inline-start: 8px;
    padding: 1px 9px;
    font-size: 11px;
    font-weight: 700;
    color: #22160a;
    background: linear-gradient(135deg, #ffe9b8, #f5c66b);
    border-radius: 999px;
    white-space: nowrap;
    transition: background .12s ease;
}

.farasync-rw-cmodal {
    position: fixed;
    inset: 0;
    z-index: 100160;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(2px);
}
.farasync-rw-cmodal.is-open { display: flex; }
.farasync-rw-cmodal-box {
    position: relative;
    width: min(720px, 100%);
    max-height: min(84vh, 760px);
    overflow: auto;
    padding: 22px 24px;
    color: #1e293b;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .35);
    animation: farasync-rw-cmodal-pop .28s cubic-bezier(.22, 1.2, .36, 1) both;
}
@keyframes farasync-rw-cmodal-pop {
    from { opacity: 0; transform: translateY(14px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* v1.0.0 (user request): the campaign-modal X now uses the SAME close
   control as every other dialog (`.farasync-action-dialog-close`): the
   boxed 30×30 gray square, the two-stroke SVG X, red on hover — the old
   bare `&times;` text glyph (transparent, pill-shaped) is gone. */
.farasync-rw-cmodal-x {
    position: absolute;
    top: 10px;
    inset-inline-end: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
}
.farasync-rw-cmodal-x svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 2;
    display: block;
}
.farasync-rw-cmodal-x:hover { color: #ffffff; background: #ef4444; border-color: #ef4444; }
/* v1.0.0: mobile fullscreen header band — hidden on desktop/tablet where
   the modal stays the centered card with the floating corner X above. */
.farasync-rw-cmodal-band { display: none; }
.farasync-rw-cmodal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 800;
}
.farasync-rw-cmodal-status {
    padding: 2px 11px;
    font-size: 11.5px;
    font-weight: 700;
    color: #065f46;
    background: #d1fae5;
    border-radius: 999px;
}
.farasync-rw-cmodal-window { margin: 0 0 14px; font-size: 12.5px; color: #64748b; }
.farasync-rw-cmodal-tiers { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 16px; }
.farasync-rw-cmodal-tier {
    padding: 5px 12px;
    font-size: 12px;
    color: #312e81;
    background: #eef2ff;
    border: 1px solid #e0e7ff;
    border-radius: 999px;
}
.farasync-rw-cmodal-sub { margin: 16px 0 8px; font-size: 13.5px; font-weight: 800; }
.farasync-rw-cmodal-twrap { overflow-x: auto; }
.farasync-rw-cmodal-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.farasync-rw-cmodal-table th,
.farasync-rw-cmodal-table td { padding: 8px 10px; text-align: start; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
.farasync-rw-cmodal-table th { font-weight: 700; color: #475569; background: #f8fafc; }
.farasync-rw-cmodal-code { direction: ltr; unicode-bidi: embed; font-size: 11.5px; }
.farasync-rw-cmodal-spent,
.farasync-rw-cmodal-usable {
    display: inline-block;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
}
.farasync-rw-cmodal-spent { color: #7f1d1d; background: #fee2e2; }
.farasync-rw-cmodal-usable { color: #065f46; background: #d1fae5; }
.farasync-rw-cmodal-rej { margin: 0; padding-inline-start: 18px; font-size: 12.5px; color: #7f1d1d; }
.farasync-rw-cmodal-empty { font-size: 12.5px; color: #64748b; }
.farasync-rw-cmodal-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 18px;
    padding: 12px 16px;
    font-size: 12.5px;
    color: #334155;
    background: #f1f5f9;
    border-radius: 10px;
}
.farasync-rw-cmodal-totals b { font-size: 13.5px; }
.farasync-rw-cmodal-loading { font-size: 13px; color: #475569; }
.farasync-rw-cmodal-loading.is-err { color: #b91c1c; }
@media (max-width: 600px) {
    /* v1.0.0 (user request): the campaign-details sheet opens FULL SCREEN
       on phones — the same treatment as the notifications panel and the
       admin popups (edge-to-edge, zero card chrome). The old 88vh
       bottom-sheet is gone: one exact screen, the pinned gradient band on
       top, and the BODY scrolling inside between band and screen floor. */
    .farasync-rw-cmodal { padding: 0; align-items: stretch; }
    .farasync-rw-cmodal-box {
        display: flex;
        flex-direction: column;
        width: 100vw;
        max-width: none;
        height: 100vh;
        height: 100dvh;      /* beats the URL-bar shrink on iOS/Android */
        max-height: none;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: hidden;    /* the body scrolls, the band never moves */
        overscroll-behavior: contain;
    }
    /* --- the band: mirrors .farasync-bell-head (gradient + safe-area) --- */
    .farasync-rw-cmodal-band {
        display: flex;
        align-items: center;
        gap: 10px;
        flex: 0 0 auto;
        padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
        background: linear-gradient(121deg, #0f172a 0%, #172554 48%, #312e81 100%);
        color: #ffffff;
        border-bottom: 1px solid rgba(255, 255, 255, 0.13);
    }
    .farasync-rw-cmodal-band-ico {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 30px;
        height: 30px;
        border-radius: 9px;
        background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
        color: #ffffff;
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.40);
    }
    .farasync-rw-cmodal-band-ico svg { width: 16px; height: 16px; }
    .farasync-rw-cmodal-band-title {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #ffffff;
        font-size: 14.5px;
        font-weight: 700;
        line-height: 1.6;
    }
    /* the floating corner X is replaced by the FAMILY X inside the band —
       same 32px translucent circle as the bell panel, red on hover */
    .farasync-rw-cmodal-x { display: none; }
    .farasync-rw-cmodal-x.is-band {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        position: static;
        top: auto;
        inset-inline-end: auto;
        width: 30px;
        height: 30px;
        margin: 0;
        padding: 0;
        color: #64748b;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        box-shadow: none;
        cursor: pointer;
        appearance: none;
        -webkit-appearance: none;
    }
    .farasync-rw-cmodal-x.is-band:hover,
    .farasync-rw-cmodal-x.is-band:focus {
        background: #ef4444;
        border-color: #ef4444;
        color: #ffffff;
    }
    /* the body becomes the scroll area between band and screen floor
       (the desktop box padding is gone — the body carries its own) */
    .farasync-rw-cmodal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 16px 14px calc(20px + env(safe-area-inset-bottom, 0px));
    }
}

/* ======================================================================
   v1.0.0 — campaign-details modal REDESIGN (user request: «طراحیش رو
   بهتر و مرتب تر کن، داخل موبایل هم درست نمایش بده») — hero card, level
   cards, winner cards, three totals tiles. Fully fluid under 600px.
   ====================================================================== */
.farasync-rw-cd-hero {
    margin: 0 0 14px;
    padding: 14px 16px;
    background: linear-gradient(121deg, #0f172a 0%, #172554 55%, #312e81 100%);
    border-radius: 14px;
    color: #e2e8f0;
}
.farasync-rw-cd-hero-top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.farasync-rw-cd-hero-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    color: #c7d2fe;
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 10px;
}
.farasync-rw-cd-hero-ico svg { width: 18px; height: 18px; }
.farasync-rw-cd-title {
    margin: 0;
    font-size: 16.5px;
    font-weight: 800;
    color: #ffffff;
}
.farasync-rw-cd-status {
    padding: 2px 11px;
    font-size: 11px;
    font-weight: 700;
    color: #86efac;
    background: rgba(34, 197, 94, .16);
    border: 1px solid rgba(74, 222, 128, .45);
    border-radius: 999px;
}
.farasync-rw-cd-window {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 0;
    font-size: 12.5px;
}
.farasync-rw-cd-win-lbl { color: rgba(226, 232, 240, .65); }
.farasync-rw-cd-win-val { color: #ffffff; font-weight: 600; }

.farasync-rw-cd-sec-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 18px 0 9px;
    font-size: 13.5px;
    font-weight: 800;
    color: #1e293b;
}
.farasync-rw-cd-sec-title::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: #e2e8f0;
}
.farasync-rw-cd-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 7px;
    font-size: 11px;
    font-weight: 700;
    color: #4338ca;
    background: #eef2ff;
    border-radius: 999px;
}

.farasync-rw-cd-tiers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
}
.farasync-rw-cd-tier {
    display: grid;
    gap: 5px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
}
.farasync-rw-cd-tier-lvl {
    font-size: 11px;
    font-weight: 800;
    color: #6366f1;
}
.farasync-rw-cd-tier-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 12.5px;
    color: #334155;
}
.farasync-rw-cd-tier-row b { font-size: 13.5px; color: #0f172a; }
.farasync-rw-cd-tier-row.is-reward b { color: #b45309; }
.farasync-rw-cd-tier-lbl { font-size: 11px; color: #64748b; }

.farasync-rw-cd-winners {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}
.farasync-rw-cd-winner {
    display: grid;
    gap: 7px;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}
.farasync-rw-cd-winner-head {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}
.farasync-rw-cd-winner-name {
    font-size: 13px;
    font-weight: 800;
    color: #0f172a;
    overflow-wrap: anywhere;
}
.farasync-rw-cd-tier-chip {
    flex: 0 0 auto;
    padding: 1px 9px;
    font-size: 10.5px;
    font-weight: 700;
    color: #4338ca;
    background: #eef2ff;
    border-radius: 999px;
}
.farasync-rw-cd-winner-amount {
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-size: 12px;
    color: #64748b;
}
.farasync-rw-cd-winner-amount b {
    font-size: 17px;
    color: #15803d;
}
.farasync-rw-cd-pill {
    display: inline-block;
    margin-inline-start: 6px;
    padding: 1px 9px;
    font-size: 10.5px;
    font-weight: 700;
    border-radius: 999px;
}
.farasync-rw-cd-pill.is-usable { color: #065f46; background: #d1fae5; }
.farasync-rw-cd-pill.is-spent  { color: #7f1d1d; background: #fee2e2; }
.farasync-rw-cd-winner-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 14px;
    font-size: 11.5px;
    color: #64748b;
}
.farasync-rw-cd-winner-meta b { color: #334155; }
.farasync-rw-cd-code {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 9px;
}
.farasync-rw-cd-code-lbl { font-size: 10.5px; color: #94a3b8; white-space: nowrap; }
.farasync-rw-cd-code code {
    direction: ltr;
    unicode-bidi: embed;
    font-size: 11.5px;
    color: #0f172a;
    overflow-wrap: anywhere;
}
.farasync-rw-cd-empty { font-size: 12.5px; color: #64748b; }
.farasync-rw-cd-rej {
    margin: 0;
    padding-inline-start: 18px;
    font-size: 12.5px;
    color: #7f1d1d;
}

.farasync-rw-cd-totals {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 18px;
}
.farasync-rw-cd-total {
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    background: #f1f5f9;
    border-radius: 11px;
    text-align: center;
}
.farasync-rw-cd-total-lbl {
    font-size: 10.5px;
    color: #64748b;
}
.farasync-rw-cd-total b { font-size: 14.5px; color: #0f172a; }
.farasync-rw-cd-total.is-remaining { background: #ecfdf5; }
.farasync-rw-cd-total.is-remaining b { color: #047857; }

@media (max-width: 600px) {
    .farasync-rw-cd-tiers,
    .farasync-rw-cd-winners { grid-template-columns: 1fr; }
    .farasync-rw-cd-totals { grid-template-columns: 1fr; gap: 6px; }
    .farasync-rw-cd-hero { padding: 12px 13px; }
    .farasync-rw-cd-title { font-size: 15px; }
    .farasync-rw-cd-winner-amount b { font-size: 15.5px; }
}

/* ====================================================================
 * v1.0.0 (X55 UI audit) — the campaign-modal X joins the unified
 * close-control family: red hover, no rotate flourish, focus ring.
 * ==================================================================== */
.farasync-rw-cmodal-x {
    transform: none;
    transition: background-color .15s ease, color .15s ease;
}
.farasync-rw-cmodal-x:hover,
.farasync-rw-cmodal-x:focus-visible {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
    outline: none;
}
/* ====================================================================
 * v1.0.0 (X60) — calculation method control, locked tier rows and the
 * always-editable end-date row. Same token family as the rest of the
 * tab (#2271b1 blue accents, slate greys, 6/10px radii).
 * ==================================================================== */

/* Method chip (locked state) + editable select in the campaign head */
.farasync-rw-method {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.farasync-rw-method.is-locked {
    cursor: help;
}
.farasync-rw-method-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 12px;
    line-height: 1.8;
    white-space: nowrap;
}
.farasync-rw-method-chip .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: #94a3b8;
}
.farasync-rw-method select {
    max-width: 260px;
    vertical-align: middle;
}

/* Locked tier rows — earned tiers are never re-priced.
   v1.0.0 (X65): the tooltip is row-level now (title on the <tr>) —
   the whole row gets cursor:help, and disabled inputs inside a locked
   row switch to pointer-events:none so hovering DIRECTLY over a field
   still falls through to the row and fires the native title tooltip
   (disabled controls otherwise swallow mouse events in Blink). */
.farasync-rw-tiers tr.is-locked {
    cursor: help;
}
.farasync-rw-tiers tr.is-locked td {
    background: #f8fafc;
}
.farasync-rw-tiers tr.is-locked input {
    background: #eef2f7 !important;
    color: #94a3b8 !important;
    border-color: #e2e8f0 !important;
    cursor: not-allowed;
}
.farasync-rw-tiers tr.is-locked input[disabled] {
    pointer-events: none;
}
.farasync-rw-tier-lock {
    color: #94a3b8;
    font-size: 14px;
    width: 14px;
    height: 14px;
    margin: 0 0 2px 6px; /* RTL: icon sits before the field */
    vertical-align: middle;
    cursor: help;
    flex: 0 0 auto;
}
[dir="ltr"] .farasync-rw-tier-lock {
    margin: 0 6px 2px 0;
}

/* End-date editor row */
.farasync-rw-end-edit {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 12px;
}
.farasync-rw-end-edit label {
    font-weight: 600;
}
.farasync-rw-end-edit input[type="date"] {
    min-width: 150px;
}
.farasync-rw-end-edit .description {
    flex-basis: 100%;
    margin: 2px 0 0;
}
