.fm-page {
    padding: 24px 28px 48px;
    direction: rtl;
}

/* ── Top bar ─────────────────────────────────────────────────────── */
.fm-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.fm-topbar-start {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fm-topbar-end {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fm-back-btn {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
}

.fm-back-btn:hover { background: #f1f5f9; }

.fm-breadcrumb {
    font-size: var(--motiva-font-size-caption, 12px);
    color: #94a3b8;
}

.fm-title {
    font-size: var(--motiva-font-size-h2, 22px);
    font-weight: 800;
    color: #1e293b;
    margin: 0;
}

/* ── State / toast ───────────────────────────────────────────────── */
.fm-state {
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 12px;
    color: #64748b;
    padding: 32px 24px;
    text-align: center;
    font-size: var(--motiva-font-size-body, 14px);
}

.fm-state-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.fm-toast {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: var(--motiva-font-size-sm, 13px);
    margin-bottom: 14px;
}

.fm-toast-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

/* ── Status pill ─────────────────────────────────────────────────── */
.fm-status {
    display: inline-block;
    font-size: var(--motiva-font-size-caption, 11px);
    font-weight: 700;
    border-radius: 999px;
    padding: 3px 10px;
    line-height: 1.2;
}

.fm-status-open   { color: #065f46; background: #d1fae5; }
.fm-status-closed { color: #475569; background: #f1f5f9; }
.fm-status-draft  { color: #92400e; background: #fef3c7; }

/* ── Card list ───────────────────────────────────────────────────── */
.fm-list {
    display: grid;
    gap: 14px;
}

.fm-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.fm-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.fm-card-head-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.fm-card-title {
    font-size: var(--motiva-font-size-h3, 17px);
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.fm-card-year {
    font-size: var(--motiva-font-size-caption, 12px);
    color: #64748b;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 3px 10px;
}

.fm-card-meta {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.fm-meta-item { display: flex; flex-direction: column; gap: 2px; }
.fm-meta-label { font-size: var(--motiva-font-size-caption, 11px); color: #94a3b8; }
.fm-meta-value { font-size: var(--motiva-font-size-sm, 13px); color: #334155; font-weight: 600; }

.fm-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.fm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: var(--motiva-font-size-control, 13px);
    font-weight: 600;
    cursor: pointer;
    border: none;
}

.fm-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.fm-btn-primary {
    background: #1e293b;
    color: #fff;
}
.fm-btn-primary:hover:not(:disabled) { background: #0f172a; }

.fm-btn-secondary {
    background: #fff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}
.fm-btn-secondary:hover:not(:disabled) { background: #f1f5f9; }

.fm-btn-danger {
    background: #fff;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.fm-btn-danger:hover:not(:disabled) { background: #fef2f2; }

/* ── Editor panel ────────────────────────────────────────────────── */
.fm-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.fm-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
}

.fm-panel-title {
    font-size: var(--motiva-font-size-item, 15px);
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.fm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}

.fm-field { display: flex; flex-direction: column; gap: 4px; }
.fm-field-full { grid-column: 1 / -1; }

.fm-label {
    font-size: var(--motiva-font-size-caption, 12px);
    color: #475569;
    font-weight: 700;
}

.fm-req { color: #b91c1c; }

.fm-input,
.fm-textarea {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: var(--motiva-font-size-body, 14px);
    color: #1e293b;
    background: #fff;
    font-family: inherit;
    direction: rtl;
}

.fm-input:focus,
.fm-textarea:focus {
    outline: none;
    border-color: #1e293b;
    box-shadow: 0 0 0 2px rgba(30, 41, 59, 0.08);
}

.fm-input:disabled { background: #f1f5f9; color: #64748b; }

.fm-textarea { resize: vertical; min-height: 56px; }

.fm-check-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--motiva-font-size-sm, 13px);
    color: #334155;
    cursor: pointer;
    padding-top: 18px;
}

/* ── Block cards ─────────────────────────────────────────────────── */
.fm-empty-block {
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 10px;
    color: #94a3b8;
    text-align: center;
    padding: 24px 12px;
    font-size: var(--motiva-font-size-sm, 13px);
}

.fm-block-list {
    display: grid;
    gap: 14px;
}

.fm-block-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
}

.fm-block-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.fm-block-head-main {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.fm-block-type {
    font-size: var(--motiva-font-size-caption, 11px);
    font-weight: 700;
    color: #1e3a8a;
    background: #e0e7ff;
    border-radius: 999px;
    padding: 3px 10px;
}

.fm-block-system {
    font-size: var(--motiva-font-size-caption, 11px);
    font-weight: 700;
    color: #475569;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 3px 8px;
}

.fm-block-required {
    font-size: var(--motiva-font-size-caption, 11px);
    font-weight: 700;
    color: #b91c1c;
    background: #fef2f2;
    border-radius: 999px;
    padding: 3px 8px;
}

.fm-block-actions { display: flex; gap: 4px; }

.fm-icon-btn {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
}

.fm-icon-btn:hover:not(:disabled) { background: #f1f5f9; }
.fm-icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.fm-icon-btn-danger { color: #b91c1c; border-color: #fecaca; }
.fm-icon-btn-danger:hover:not(:disabled) { background: #fef2f2; }

.fm-block-card-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

/* ── Options inside choice/ranking blocks ───────────────────────── */
.fm-options-section {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.fm-options-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
}

.fm-options-title {
    font-size: var(--motiva-font-size-control, 13px);
    font-weight: 700;
    color: #475569;
    margin: 0;
}

.fm-options-note {
    font-size: var(--motiva-font-size-caption, 11px);
    color: #92400e;
    background: #fef3c7;
    border-radius: 999px;
    padding: 3px 10px;
}

.fm-options-list {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
    display: grid;
    gap: 6px;
}

.fm-option-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.fm-option-label { flex: 1.4; }
.fm-option-value { flex: 1; }

.fm-option-add {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-top: 8px;
    border-top: 1px dashed #e2e8f0;
}

/* ── Modal ───────────────────────────────────────────────────────── */
.fm-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1000;
}

.fm-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 14px;
    padding: 22px 24px;
    width: min(520px, 92vw);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    z-index: 1001;
}

.fm-modal-title {
    font-size: var(--motiva-font-size-h3, 18px);
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 12px;
}

.fm-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    margin-top: 14px;
}

@media (max-width: 720px) {
    .fm-grid { grid-template-columns: 1fr; }
    .fm-option-row { flex-wrap: wrap; }
}

/* ── Duplicate-form modal ─────────────────────────────────────────────── */
.fm-dup-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 110;
}
.fm-dup-modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(440px, 92vw);
    background: var(--g-surface, #fff);
    border: 1px solid var(--g-border, rgba(15,23,42,0.10));
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(15,23,42,0.20);
    z-index: 120;
    display: flex; flex-direction: column;
}
.fm-dup-header {
    padding: 14px 18px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(15,23,42,0.08);
}
.fm-dup-title { font-size: 1.05rem; font-weight: 700; color: var(--g-text-strong, #0f172a); }
.fm-dup-close {
    background: transparent; border: 0; cursor: pointer;
    color: var(--g-text-muted, #64748b);
    padding: 6px; border-radius: 6px;
}
.fm-dup-close:hover { background: rgba(15,23,42,0.06); color: var(--g-text-strong, #0f172a); }

.fm-dup-body   { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.fm-dup-source { color: var(--g-text-muted, #64748b); font-size: 0.9rem; }
.fm-dup-source strong { color: var(--g-text-strong, #0f172a); }
.fm-dup-field  { display: flex; flex-direction: column; gap: 4px; }
.fm-dup-label  { font-size: 0.82rem; font-weight: 600; color: var(--g-text-muted, #64748b); }
.fm-dup-required { color: #dc2626; }
.fm-dup-input {
    height: 38px; padding: 0 12px;
    border: 1px solid var(--g-border, rgba(15,23,42,0.12));
    border-radius: 8px;
    background: var(--g-surface, #fff);
    font-size: 0.92rem; font-family: inherit;
}
.fm-dup-input-error { border-color: #dc2626; }
.fm-dup-hint {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.82rem; color: var(--g-text-muted, #64748b);
    background: rgba(15,23,42,0.04);
    border-radius: 8px; padding: 8px 10px;
}
.fm-dup-error {
    display: inline-flex; align-items: center; gap: 6px;
    color: #991b1b; background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.20);
    border-radius: 8px; padding: 8px 10px; font-size: 0.88rem;
}

.fm-dup-footer {
    padding: 12px 18px;
    display: flex; justify-content: flex-end; gap: 8px;
    border-top: 1px solid rgba(15,23,42,0.08);
}

.fm-dup-spinner {
    display: inline-block; width: 12px; height: 12px;
    border: 2px solid rgba(255,255,255,0.45); border-top-color: #fff;
    border-radius: 50%; animation: fm-dup-spin 0.8s linear infinite;
}
@keyframes fm-dup-spin { to { transform: rotate(360deg); } }

/* ── Form builder ─────────────────────────────────────────────────────── */
.fb-page    { padding: 24px; max-width: 1320px; margin: 0 auto;
              display: flex; flex-direction: column; gap: 16px; }
.fb-topbar  { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.fb-topbar-start { display: flex; align-items: center; gap: 14px; }
.fb-topbar-end   { display: flex; gap: 8px; flex-wrap: wrap; }
.fb-back-btn {
    width: 36px; height: 36px; border-radius: 10px; border: 0;
    background: rgba(15,23,42,0.06); color: #475569;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.fb-back-btn:hover { background: rgba(15,23,42,0.10); color: #0f172a; }
.fb-breadcrumb { font-size: 0.78rem; color: #64748b; margin-bottom: 2px; }
.fb-page-title { margin: 0; font-size: 1.4rem; font-weight: 700; color: #0f172a; }

.fb-grid {
    display: grid; grid-template-columns: 360px 1fr; gap: 16px;
}
@media (max-width: 980px) { .fb-grid { grid-template-columns: 1fr; } }

.fb-card {
    background: #fff;
    border: 1px solid rgba(15,23,42,0.08);
    border-radius: 12px;
    padding: 18px 20px;
    display: flex; flex-direction: column; gap: 12px;
}
.fb-card-title { margin: 0 0 8px; font-size: 1.05rem; font-weight: 700; color: #0f172a; }

.fb-field         { display: flex; flex-direction: column; gap: 4px; }
.fb-field-inline  { display: flex; align-items: center; gap: 8px; }
.fb-label         { font-size: 0.82rem; font-weight: 600; color: #64748b; }
.fb-required      { color: #dc2626; }
.fb-optional      { color: #94a3b8; font-weight: 400; font-size: 0.78rem; }

.fb-input {
    height: 38px; padding: 0 12px;
    border: 1px solid rgba(15,23,42,0.12);
    border-radius: 8px;
    background: #fff;
    font-size: 0.92rem; font-family: inherit;
    color: #0f172a;
}
.fb-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.10); }
.fb-input-error { border-color: #dc2626; }
.fb-textarea    { height: auto; padding: 8px 12px; resize: vertical; }
.fb-textarea-sm { height: auto; padding: 6px 10px; resize: vertical; }
.fb-num         { width: 110px; }

.fb-check-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.fb-check     { accent-color: #2563eb; width: 16px; height: 16px; }

.fb-error {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 10px; border-radius: 8px;
    background: rgba(239,68,68,0.06); color: #991b1b;
    border: 1px solid rgba(239,68,68,0.20);
    font-size: 0.88rem;
}
.fb-success {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 10px; border-radius: 8px;
    background: rgba(16,185,129,0.08); color: #065f46;
    border: 1px solid rgba(16,185,129,0.30);
    font-size: 0.88rem;
}
.fb-spinner-sm {
    display: inline-block; width: 12px; height: 12px;
    border: 2px solid rgba(15,23,42,0.20); border-top-color: #0f172a;
    border-radius: 50%; animation: fm-dup-spin 0.8s linear infinite;
}

/* Blocks */
.fb-blocks-card    { gap: 14px; }
.fb-blocks-header  { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fb-add-row        { display: flex; gap: 8px; align-items: center; }
.fb-add-select     { min-width: 200px; }

.fb-empty {
    background: rgba(15,23,42,0.03);
    border: 1px dashed rgba(15,23,42,0.16);
    border-radius: 10px;
    padding: 20px; text-align: center; color: #64748b;
}
.fb-empty .oi { margin-inline-end: 6px; }
.fb-empty-sm  { padding: 10px; font-size: 0.85rem; }

.fb-blocks-list { display: flex; flex-direction: column; gap: 12px; }
.fb-block {
    border: 1px solid rgba(15,23,42,0.10);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}
.fb-block-head {
    background: rgba(15,23,42,0.03);
    padding: 8px 12px;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    border-bottom: 1px solid rgba(15,23,42,0.06);
}
.fb-block-head-start { display: inline-flex; align-items: center; gap: 8px; }
.fb-block-head-end   { display: inline-flex; align-items: center; gap: 4px; }
.fb-block-num   { font-weight: 700; color: #475569; font-size: 0.85rem; }
.fb-block-kind  { background: rgba(37,99,235,0.10); color: #1e40af;
                  padding: 2px 10px; border-radius: 999px;
                  font-size: 0.78rem; font-weight: 600; }

.fb-icon-btn {
    border: 0; background: transparent; cursor: pointer;
    color: #64748b; padding: 6px; border-radius: 6px;
}
.fb-icon-btn:hover:not(:disabled) { background: rgba(15,23,42,0.06); color: #0f172a; }
.fb-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.fb-icon-danger:hover:not(:disabled) { background: rgba(239,68,68,0.10); color: #991b1b; }

.fb-block-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }

.fb-options       { display: flex; flex-direction: column; gap: 6px; }
.fb-options-head  { display: flex; align-items: center; justify-content: space-between; }
.fb-options-list  { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.fb-option-row    { display: grid; grid-template-columns: 1fr 200px 36px; gap: 8px; align-items: center; }
.fb-option-value  { color: #475569; }
.fb-btn-sm        { padding: 4px 10px; font-size: 0.82rem; }

.fb-rank-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
