/* «نقشهٔ RFM» (rfm-) — segment map of the club members. Same tokens and parts as the ready widgets (.w, .btn, .seg, .badge, .input, .dlg, .pop). */
.rfm { container-type: inline-size; grid-template-rows: auto auto minmax(0, 1fr); }
.rfm .w-actions { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 12px 0; min-width: 0; }
.rfm .w-body { grid-row: 3; gap: 0; }
.rfm .btn { white-space: nowrap; }

/* header: search (right), count, filter, period (far left) */
.rfm-q { flex: 0 1 260px; min-width: 0; height: 34px; min-height: 34px; gap: 6px; }
.rfm-q input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; font: inherit; font-size: 13.5px; color: var(--foreground); padding: 0; }
.rfm-q .i { width: 15px; height: 15px; flex: none; color: var(--muted-foreground); }
.rfm-cnt { font-size: 12.5px; color: var(--muted-foreground); white-space: nowrap; }
.rfm-fil { height: 30px; }
.rfm-fil .rfm-fn:not(:empty) { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-inline-start: 2px; border-radius: 99px; background: var(--primary); color: var(--primary-foreground); font-size: 11px; }
.rfm-per { margin-inline-start: auto; }
.rfm-per button { white-space: nowrap; }
.rfm-per button[aria-pressed="true"] { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

/* body */
.rfm-main { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; padding: 10px 0 0; }
.rfm-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.rfm-card { flex: 1; min-height: 0; display: flex; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 8px; background: var(--card); }

/* the map: F labels (far right), 5×5 segment grid, R labels underneath */
.rfm-plot { flex: 1; min-height: 0; min-width: 0; display: grid; grid-template-columns: 20px 24px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 18px 20px; column-gap: 6px; row-gap: 4px; }
.rfm-yl { grid-area: 1 / 1; writing-mode: vertical-rl; transform: rotate(180deg); align-self: center; justify-self: center; font-size: 12px; color: var(--muted-foreground); white-space: nowrap; }
.rfm-yn { grid-area: 1 / 2; display: grid; grid-template-rows: repeat(5, minmax(0, 1fr)); gap: 4px; min-height: 0; }
.rfm-yn i, .rfm-xn i { font-style: normal; font-size: 12px; color: var(--muted-foreground); display: flex; align-items: center; justify-content: center; min-width: 0; }
.rfm-grid { grid-area: 1 / 3; min-height: 0; min-width: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(5, minmax(0, 1fr)); gap: 4px; }
.rfm-xn { grid-area: 2 / 3; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.rfm-xl { grid-area: 3 / 3; font-size: 12px; color: var(--muted-foreground); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: center; }

/* segment tile: name, members and share, value; the bubble is the segment's share of total value */
.rfm-blk { position: relative; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 2px; padding: 8px 10px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--c) 40%, var(--border)); background: color-mix(in srgb, var(--c) 13%, var(--card)); color: var(--foreground); font: inherit; text-align: start; cursor: pointer; transition: box-shadow .15s, background .15s; }
.rfm-blk:hover { background: color-mix(in srgb, var(--c) 20%, var(--card)); }
.rfm-blk:hover, .rfm-blk:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 45%, transparent); }
.rfm-blk:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.rfm-blk.is-empty { opacity: .6; }
.rfm-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: calc(100% - 64px); }
.rfm-tx > b { font-family: Morabba, inherit; font-weight: 500; font-size: 14px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rfm-nums { font-size: 12px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rfm-val { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rfm-bub { position: absolute; inset-inline-end: 10px; inset-block-end: 8px; width: var(--bub, 12px); height: var(--bub, 12px); border-radius: 50%; background: var(--c); opacity: .85; pointer-events: none; }

/* hover tooltip */
.rfm-tip { position: absolute; z-index: 4; width: 220px; max-width: calc(100% - 12px); pointer-events: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--popover); box-shadow: var(--shadow-pop); font-size: 12.5px; }
.rfm-tip[hidden] { display: none; }
.rfm-tip > b { font-family: Morabba, inherit; font-weight: 500; font-size: 14px; }
.rfm-tip > small { color: var(--muted-foreground); line-height: 1.6; }
.rfm-tip > em { font-style: normal; font-size: 11.5px; color: var(--muted-foreground); margin-top: 2px; }
.rfm-tr { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; width: 100%; }
.rfm-tr span { color: var(--muted-foreground); }

/* states: loading skeleton, error, empty */
.rfm-busy { font-size: 12.5px; color: var(--muted-foreground); padding: 0 2px 6px; }
.rfm-sk { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rfm-sk .sk { height: 100%; min-height: 60px; }
.rfm-state { flex: 1; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 16px; text-align: center; border: 1px dashed var(--border); border-radius: 10px; min-height: 0; }
.rfm-state > b { font-family: Morabba, inherit; font-weight: 500; font-size: 16px; }
.rfm-state > span { font-size: 13px; color: var(--muted-foreground); line-height: 1.8; max-width: 380px; }
.rfm-state .btn { margin-top: 6px; }
.rfm-err { border-color: color-mix(in srgb, var(--destructive) 40%, var(--border)); background: color-mix(in srgb, var(--destructive) 5%, var(--card)); }
.rfm-err > b { color: var(--destructive); }

/* member search results and «فیلتر» popovers */
.pop.rfm-pop { padding: 6px; }
.rfm-res { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--foreground); font: inherit; text-align: start; cursor: pointer; }
.rfm-res:hover, .rfm-res:focus-visible { background: var(--muted); outline: 0; }
.rfm-rt { display: grid; flex: 1; min-width: 0; }
.rfm-rt b { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rfm-rt small { font-size: 11.5px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rfm-res em { font-style: normal; font-size: 11.5px; color: var(--muted-foreground); white-space: nowrap; }
.rfm-res-e, .rfm-more { padding: 8px; font-size: 12.5px; color: var(--muted-foreground); }
.rfm-fp { padding: 8px; }
.rfm-fp > b { font-family: Morabba, inherit; font-weight: 500; font-size: 15px; }
.rfm-fp > small { display: block; font-size: 12px; color: var(--muted-foreground); margin: 2px 0 8px; line-height: 1.7; }
.rfm-ck { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.rfm-ck:hover { background: var(--muted); }
.rfm-ck input { accent-color: var(--primary); margin: 0; }
.rfm-ck em { margin-inline-start: auto; font-style: normal; font-size: 12px; color: var(--muted-foreground); }
.rfm-fpf { display: flex; justify-content: flex-start; margin-top: 6px; }

/* segment dialog */
.dlg.rfm-dlg { width: min(640px, calc(100% - 24px)); max-height: 92%; display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; overflow: hidden; }
.rfm-dh { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rfm-dh > i { width: 6px; align-self: stretch; border-radius: 4px; flex: none; }
.rfm-dh > div { flex: 1; min-width: 0; }
.rfm-dh h5 { margin: 0 0 2px; }
.rfm-dh small { display: block; font-size: 12px; color: var(--muted-foreground); line-height: 1.7; }
.rfm-dh .badge { flex: none; }
.rfm-ds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rfm-ds > div { display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.rfm-ds small { font-size: 11.5px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rfm-ds b { font-family: Morabba, inherit; font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rfm-dact { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 8%, var(--card)); font-size: 13px; line-height: 1.8; }
.rfm-dact > .i { width: 16px; height: 16px; flex: none; margin-top: 4px; color: var(--primary); }
.rfm-dact > span { min-width: 0; }
.rfm-tw { position: relative; min-height: 0; max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.rfm-tbl { width: 100%; min-width: 460px; border-collapse: collapse; font-size: 12.5px; }
.rfm-tbl th { position: sticky; top: 0; z-index: 1; text-align: start; font-weight: 500; font-size: 12px; color: var(--muted-foreground); background: var(--popover); padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rfm-tbl td { padding: 7px 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); white-space: nowrap; }
.rfm-tbl tr:last-child td { border-bottom: 0; }
.rfm-tbl tr.on td { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.rfm-who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 180px; }
.rfm-who b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.rfm-sc { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 5px; border-radius: 6px; font-style: normal; font-size: 11.5px; font-weight: 600; background: var(--muted); color: var(--foreground); }
.rfm-sc[data-v="1"] { background: color-mix(in srgb, var(--red) 15%, var(--card)); color: var(--red); }
.rfm-sc[data-v="2"] { background: color-mix(in srgb, var(--amber) 18%, var(--card)); color: color-mix(in srgb, var(--amber) 75%, var(--foreground)); }
.rfm-sc[data-v="4"] { background: color-mix(in srgb, var(--green) 16%, var(--card)); color: var(--success-ink); }
.rfm-sc[data-v="5"] { background: color-mix(in srgb, var(--green) 30%, var(--card)); color: var(--success-ink); }
.rfm-dempty { padding: 16px; text-align: center; font-size: 13px; color: var(--muted-foreground); border: 1px dashed var(--border); border-radius: 10px; }
.dlg.rfm-dlg .foot { align-items: center; margin-top: 0; }
.dlg.rfm-dlg .foot > [data-m=cancel] { margin-inline-start: auto; }

/* narrow: the map becomes a list of segment cards; the page never scrolls, the list does */
@container (max-width: 560px) {
  .rfm .w-actions { gap: 6px; }
  .rfm-q { flex: 1 1 100%; max-width: none; }
  .rfm-per { margin-inline-start: 0; width: 100%; }
  .rfm-per button { flex: 1; }
  .rfm-main { overflow-y: auto; }
  .rfm-card { border: 0; padding: 0; background: transparent; }
  .rfm-plot { display: block; }
  .rfm-yl, .rfm-yn, .rfm-xn, .rfm-xl { display: none; }
  .rfm-grid { display: flex; flex-direction: column; gap: 8px; }
  .rfm-blk { grid-column: auto !important; grid-row: auto !important; flex-direction: row; align-items: center; justify-content: space-between; min-height: 66px; padding: 10px 12px; }
  .rfm-tx { max-width: none; flex: 1; }
  .rfm-bub { position: static; flex: none; margin-inline-start: 10px; }
  .rfm-sk { grid-template-columns: 1fr; grid-template-rows: none; }
  .rfm-sk .sk { min-height: 50px; }
  .rfm-tip { width: 200px; }
  .dlg.rfm-dlg { width: calc(100% - 20px); padding: 14px; }
  .rfm-ds { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .rfm-ds b { font-size: 14px; }
  .rfm-dh small { font-size: 11.5px; }
}
